matterbridge-open-tuya 0.1.0 → 0.2.0
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.
- package/CHANGELOG.md +6 -0
- package/README.md +25 -19
- package/apps/frontend/build/app.js +25 -3
- package/apps/frontend/build/app.js.map +4 -4
- package/dist/accessory/endpoints.js +33 -2
- package/dist/accessory/layout.js +1 -0
- package/dist/accessory/lightControl.js +74 -0
- package/dist/accessory/matterState.js +48 -2
- package/dist/accessory/tuyaAccessory.js +70 -8
- package/dist/features.js +58 -4
- package/dist/lightState.js +12 -0
- package/dist/mapping.js +77 -0
- package/npm-shrinkwrap.json +20 -20
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../node_modules/qrcode-generator/qrcode.js", "../src/api.ts", "../src/state.ts", "../src/drafts.ts", "../src/render.ts", "../src/actions.ts", "../src/dom.ts", "../src/components.ts", "../src/screens/connect.ts", "../src/screens/done.ts", "../src/screens/find.ts", "../../../src/temperatureUnit.ts", "../src/readings.ts", "../src/screens/home.ts", "../src/screens/options.ts", "../src/qr.ts", "../src/screens/signIn.ts", "../src/theme.ts", "../src/app.ts"],
|
|
4
|
-
"sourcesContent": ["//---------------------------------------------------------------------\n//\n// QR Code Generator for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n// http://www.opensource.org/licenses/mit-license.php\n//\n// The word 'QR Code' is registered trademark of\n// DENSO WAVE INCORPORATED\n// http://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n\nvar qrcode = function() {\n\n //---------------------------------------------------------------------\n // qrcode\n //---------------------------------------------------------------------\n\n /**\n * qrcode\n * @param typeNumber 1 to 40\n * @param errorCorrectionLevel 'L','M','Q','H'\n */\n var qrcode = function(typeNumber, errorCorrectionLevel) {\n\n var PAD0 = 0xEC;\n var PAD1 = 0x11;\n\n var _typeNumber = typeNumber;\n var _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];\n var _modules = null;\n var _moduleCount = 0;\n var _dataCache = null;\n var _dataList = [];\n\n var _this = {};\n\n var makeImpl = function(test, maskPattern) {\n\n _moduleCount = _typeNumber * 4 + 17;\n _modules = function(moduleCount) {\n var modules = new Array(moduleCount);\n for (var row = 0; row < moduleCount; row += 1) {\n modules[row] = new Array(moduleCount);\n for (var col = 0; col < moduleCount; col += 1) {\n modules[row][col] = null;\n }\n }\n return modules;\n }(_moduleCount);\n\n setupPositionProbePattern(0, 0);\n setupPositionProbePattern(_moduleCount - 7, 0);\n setupPositionProbePattern(0, _moduleCount - 7);\n setupPositionAdjustPattern();\n setupTimingPattern();\n setupTypeInfo(test, maskPattern);\n\n if (_typeNumber >= 7) {\n setupTypeNumber(test);\n }\n\n if (_dataCache == null) {\n _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);\n }\n\n mapData(_dataCache, maskPattern);\n };\n\n var setupPositionProbePattern = function(row, col) {\n\n for (var r = -1; r <= 7; r += 1) {\n\n if (row + r <= -1 || _moduleCount <= row + r) continue;\n\n for (var c = -1; c <= 7; c += 1) {\n\n if (col + c <= -1 || _moduleCount <= col + c) continue;\n\n if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )\n || (0 <= c && c <= 6 && (r == 0 || r == 6) )\n || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {\n _modules[row + r][col + c] = true;\n } else {\n _modules[row + r][col + c] = false;\n }\n }\n }\n };\n\n var getBestMaskPattern = function() {\n\n var minLostPoint = 0;\n var pattern = 0;\n\n for (var i = 0; i < 8; i += 1) {\n\n makeImpl(true, i);\n\n var lostPoint = QRUtil.getLostPoint(_this);\n\n if (i == 0 || minLostPoint > lostPoint) {\n minLostPoint = lostPoint;\n pattern = i;\n }\n }\n\n return pattern;\n };\n\n var setupTimingPattern = function() {\n\n for (var r = 8; r < _moduleCount - 8; r += 1) {\n if (_modules[r][6] != null) {\n continue;\n }\n _modules[r][6] = (r % 2 == 0);\n }\n\n for (var c = 8; c < _moduleCount - 8; c += 1) {\n if (_modules[6][c] != null) {\n continue;\n }\n _modules[6][c] = (c % 2 == 0);\n }\n };\n\n var setupPositionAdjustPattern = function() {\n\n var pos = QRUtil.getPatternPosition(_typeNumber);\n\n for (var i = 0; i < pos.length; i += 1) {\n\n for (var j = 0; j < pos.length; j += 1) {\n\n var row = pos[i];\n var col = pos[j];\n\n if (_modules[row][col] != null) {\n continue;\n }\n\n for (var r = -2; r <= 2; r += 1) {\n\n for (var c = -2; c <= 2; c += 1) {\n\n if (r == -2 || r == 2 || c == -2 || c == 2\n || (r == 0 && c == 0) ) {\n _modules[row + r][col + c] = true;\n } else {\n _modules[row + r][col + c] = false;\n }\n }\n }\n }\n }\n };\n\n var setupTypeNumber = function(test) {\n\n var bits = QRUtil.getBCHTypeNumber(_typeNumber);\n\n for (var i = 0; i < 18; i += 1) {\n var mod = (!test && ( (bits >> i) & 1) == 1);\n _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;\n }\n\n for (var i = 0; i < 18; i += 1) {\n var mod = (!test && ( (bits >> i) & 1) == 1);\n _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;\n }\n };\n\n var setupTypeInfo = function(test, maskPattern) {\n\n var data = (_errorCorrectionLevel << 3) | maskPattern;\n var bits = QRUtil.getBCHTypeInfo(data);\n\n // vertical\n for (var i = 0; i < 15; i += 1) {\n\n var mod = (!test && ( (bits >> i) & 1) == 1);\n\n if (i < 6) {\n _modules[i][8] = mod;\n } else if (i < 8) {\n _modules[i + 1][8] = mod;\n } else {\n _modules[_moduleCount - 15 + i][8] = mod;\n }\n }\n\n // horizontal\n for (var i = 0; i < 15; i += 1) {\n\n var mod = (!test && ( (bits >> i) & 1) == 1);\n\n if (i < 8) {\n _modules[8][_moduleCount - i - 1] = mod;\n } else if (i < 9) {\n _modules[8][15 - i - 1 + 1] = mod;\n } else {\n _modules[8][15 - i - 1] = mod;\n }\n }\n\n // fixed module\n _modules[_moduleCount - 8][8] = (!test);\n };\n\n var mapData = function(data, maskPattern) {\n\n var inc = -1;\n var row = _moduleCount - 1;\n var bitIndex = 7;\n var byteIndex = 0;\n var maskFunc = QRUtil.getMaskFunction(maskPattern);\n\n for (var col = _moduleCount - 1; col > 0; col -= 2) {\n\n if (col == 6) col -= 1;\n\n while (true) {\n\n for (var c = 0; c < 2; c += 1) {\n\n if (_modules[row][col - c] == null) {\n\n var dark = false;\n\n if (byteIndex < data.length) {\n dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);\n }\n\n var mask = maskFunc(row, col - c);\n\n if (mask) {\n dark = !dark;\n }\n\n _modules[row][col - c] = dark;\n bitIndex -= 1;\n\n if (bitIndex == -1) {\n byteIndex += 1;\n bitIndex = 7;\n }\n }\n }\n\n row += inc;\n\n if (row < 0 || _moduleCount <= row) {\n row -= inc;\n inc = -inc;\n break;\n }\n }\n }\n };\n\n var createBytes = function(buffer, rsBlocks) {\n\n var offset = 0;\n\n var maxDcCount = 0;\n var maxEcCount = 0;\n\n var dcdata = new Array(rsBlocks.length);\n var ecdata = new Array(rsBlocks.length);\n\n for (var r = 0; r < rsBlocks.length; r += 1) {\n\n var dcCount = rsBlocks[r].dataCount;\n var ecCount = rsBlocks[r].totalCount - dcCount;\n\n maxDcCount = Math.max(maxDcCount, dcCount);\n maxEcCount = Math.max(maxEcCount, ecCount);\n\n dcdata[r] = new Array(dcCount);\n\n for (var i = 0; i < dcdata[r].length; i += 1) {\n dcdata[r][i] = 0xff & buffer.getBuffer()[i + offset];\n }\n offset += dcCount;\n\n var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);\n var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);\n\n var modPoly = rawPoly.mod(rsPoly);\n ecdata[r] = new Array(rsPoly.getLength() - 1);\n for (var i = 0; i < ecdata[r].length; i += 1) {\n var modIndex = i + modPoly.getLength() - ecdata[r].length;\n ecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;\n }\n }\n\n var totalCodeCount = 0;\n for (var i = 0; i < rsBlocks.length; i += 1) {\n totalCodeCount += rsBlocks[i].totalCount;\n }\n\n var data = new Array(totalCodeCount);\n var index = 0;\n\n for (var i = 0; i < maxDcCount; i += 1) {\n for (var r = 0; r < rsBlocks.length; r += 1) {\n if (i < dcdata[r].length) {\n data[index] = dcdata[r][i];\n index += 1;\n }\n }\n }\n\n for (var i = 0; i < maxEcCount; i += 1) {\n for (var r = 0; r < rsBlocks.length; r += 1) {\n if (i < ecdata[r].length) {\n data[index] = ecdata[r][i];\n index += 1;\n }\n }\n }\n\n return data;\n };\n\n var createData = function(typeNumber, errorCorrectionLevel, dataList) {\n\n var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectionLevel);\n\n var buffer = qrBitBuffer();\n\n for (var i = 0; i < dataList.length; i += 1) {\n var data = dataList[i];\n buffer.put(data.getMode(), 4);\n buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );\n data.write(buffer);\n }\n\n // calc num max data.\n var totalDataCount = 0;\n for (var i = 0; i < rsBlocks.length; i += 1) {\n totalDataCount += rsBlocks[i].dataCount;\n }\n\n if (buffer.getLengthInBits() > totalDataCount * 8) {\n throw 'code length overflow. ('\n + buffer.getLengthInBits()\n + '>'\n + totalDataCount * 8\n + ')';\n }\n\n // end code\n if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {\n buffer.put(0, 4);\n }\n\n // padding\n while (buffer.getLengthInBits() % 8 != 0) {\n buffer.putBit(false);\n }\n\n // padding\n while (true) {\n\n if (buffer.getLengthInBits() >= totalDataCount * 8) {\n break;\n }\n buffer.put(PAD0, 8);\n\n if (buffer.getLengthInBits() >= totalDataCount * 8) {\n break;\n }\n buffer.put(PAD1, 8);\n }\n\n return createBytes(buffer, rsBlocks);\n };\n\n _this.addData = function(data, mode) {\n\n mode = mode || 'Byte';\n\n var newData = null;\n\n switch(mode) {\n case 'Numeric' :\n newData = qrNumber(data);\n break;\n case 'Alphanumeric' :\n newData = qrAlphaNum(data);\n break;\n case 'Byte' :\n newData = qr8BitByte(data);\n break;\n case 'Kanji' :\n newData = qrKanji(data);\n break;\n default :\n throw 'mode:' + mode;\n }\n\n _dataList.push(newData);\n _dataCache = null;\n };\n\n _this.isDark = function(row, col) {\n if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {\n throw row + ',' + col;\n }\n return _modules[row][col];\n };\n\n _this.getModuleCount = function() {\n return _moduleCount;\n };\n\n _this.make = function() {\n if (_typeNumber < 1) {\n var typeNumber = 1;\n\n for (; typeNumber < 40; typeNumber++) {\n var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, _errorCorrectionLevel);\n var buffer = qrBitBuffer();\n\n for (var i = 0; i < _dataList.length; i++) {\n var data = _dataList[i];\n buffer.put(data.getMode(), 4);\n buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );\n data.write(buffer);\n }\n\n var totalDataCount = 0;\n for (var i = 0; i < rsBlocks.length; i++) {\n totalDataCount += rsBlocks[i].dataCount;\n }\n\n if (buffer.getLengthInBits() <= totalDataCount * 8) {\n break;\n }\n }\n\n _typeNumber = typeNumber;\n }\n\n makeImpl(false, getBestMaskPattern() );\n };\n\n _this.createTableTag = function(cellSize, margin) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var qrHtml = '';\n\n qrHtml += '<table style=\"';\n qrHtml += ' border-width: 0px; border-style: none;';\n qrHtml += ' border-collapse: collapse;';\n qrHtml += ' padding: 0px; margin: ' + margin + 'px;';\n qrHtml += '\">';\n qrHtml += '<tbody>';\n\n for (var r = 0; r < _this.getModuleCount(); r += 1) {\n\n qrHtml += '<tr>';\n\n for (var c = 0; c < _this.getModuleCount(); c += 1) {\n qrHtml += '<td style=\"';\n qrHtml += ' border-width: 0px; border-style: none;';\n qrHtml += ' border-collapse: collapse;';\n qrHtml += ' padding: 0px; margin: 0px;';\n qrHtml += ' width: ' + cellSize + 'px;';\n qrHtml += ' height: ' + cellSize + 'px;';\n qrHtml += ' background-color: ';\n qrHtml += _this.isDark(r, c)? '#000000' : '#ffffff';\n qrHtml += ';';\n qrHtml += '\"/>';\n }\n\n qrHtml += '</tr>';\n }\n\n qrHtml += '</tbody>';\n qrHtml += '</table>';\n\n return qrHtml;\n };\n\n _this.createSvgTag = function(cellSize, margin, alt, title) {\n\n var opts = {};\n if (typeof arguments[0] == 'object') {\n // Called by options.\n opts = arguments[0];\n // overwrite cellSize and margin.\n cellSize = opts.cellSize;\n margin = opts.margin;\n alt = opts.alt;\n title = opts.title;\n }\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n // Compose alt property surrogate\n alt = (typeof alt === 'string') ? {text: alt} : alt || {};\n alt.text = alt.text || null;\n alt.id = (alt.text) ? alt.id || 'qrcode-description' : null;\n\n // Compose title property surrogate\n title = (typeof title === 'string') ? {text: title} : title || {};\n title.text = title.text || null;\n title.id = (title.text) ? title.id || 'qrcode-title' : null;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var c, mc, r, mr, qrSvg='', rect;\n\n rect = 'l' + cellSize + ',0 0,' + cellSize +\n ' -' + cellSize + ',0 0,-' + cellSize + 'z ';\n\n qrSvg += '<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"';\n qrSvg += !opts.scalable ? ' width=\"' + size + 'px\" height=\"' + size + 'px\"' : '';\n qrSvg += ' viewBox=\"0 0 ' + size + ' ' + size + '\" ';\n qrSvg += ' preserveAspectRatio=\"xMinYMin meet\"';\n qrSvg += (title.text || alt.text) ? ' role=\"img\" aria-labelledby=\"' +\n escapeXml([title.id, alt.id].join(' ').trim() ) + '\"' : '';\n qrSvg += '>';\n qrSvg += (title.text) ? '<title id=\"' + escapeXml(title.id) + '\">' +\n escapeXml(title.text) + '</title>' : '';\n qrSvg += (alt.text) ? '<description id=\"' + escapeXml(alt.id) + '\">' +\n escapeXml(alt.text) + '</description>' : '';\n qrSvg += '<rect width=\"100%\" height=\"100%\" fill=\"white\" cx=\"0\" cy=\"0\"/>';\n qrSvg += '<path d=\"';\n\n for (r = 0; r < _this.getModuleCount(); r += 1) {\n mr = r * cellSize + margin;\n for (c = 0; c < _this.getModuleCount(); c += 1) {\n if (_this.isDark(r, c) ) {\n mc = c*cellSize+margin;\n qrSvg += 'M' + mc + ',' + mr + rect;\n }\n }\n }\n\n qrSvg += '\" stroke=\"transparent\" fill=\"black\"/>';\n qrSvg += '</svg>';\n\n return qrSvg;\n };\n\n _this.createDataURL = function(cellSize, margin) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n return createDataURL(size, size, function(x, y) {\n if (min <= x && x < max && min <= y && y < max) {\n var c = Math.floor( (x - min) / cellSize);\n var r = Math.floor( (y - min) / cellSize);\n return _this.isDark(r, c)? 0 : 1;\n } else {\n return 1;\n }\n } );\n };\n\n _this.createImgTag = function(cellSize, margin, alt) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n\n var img = '';\n img += '<img';\n img += '\\u0020src=\"';\n img += _this.createDataURL(cellSize, margin);\n img += '\"';\n img += '\\u0020width=\"';\n img += size;\n img += '\"';\n img += '\\u0020height=\"';\n img += size;\n img += '\"';\n if (alt) {\n img += '\\u0020alt=\"';\n img += escapeXml(alt);\n img += '\"';\n }\n img += '/>';\n\n return img;\n };\n\n var escapeXml = function(s) {\n var escaped = '';\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charAt(i);\n switch(c) {\n case '<': escaped += '<'; break;\n case '>': escaped += '>'; break;\n case '&': escaped += '&'; break;\n case '\"': escaped += '"'; break;\n default : escaped += c; break;\n }\n }\n return escaped;\n };\n\n var _createHalfASCII = function(margin) {\n var cellSize = 1;\n margin = (typeof margin == 'undefined')? cellSize * 2 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n var y, x, r1, r2, p;\n\n var blocks = {\n '\u2588\u2588': '\u2588',\n '\u2588 ': '\u2580',\n ' \u2588': '\u2584',\n ' ': ' '\n };\n\n var blocksLastLineNoMargin = {\n '\u2588\u2588': '\u2580',\n '\u2588 ': '\u2580',\n ' \u2588': ' ',\n ' ': ' '\n };\n\n var ascii = '';\n for (y = 0; y < size; y += 2) {\n r1 = Math.floor((y - min) / cellSize);\n r2 = Math.floor((y + 1 - min) / cellSize);\n for (x = 0; x < size; x += 1) {\n p = '\u2588';\n\n if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {\n p = ' ';\n }\n\n if (min <= x && x < max && min <= y+1 && y+1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {\n p += ' ';\n }\n else {\n p += '\u2588';\n }\n\n // Output 2 characters per pixel, to create full square. 1 character per pixels gives only half width of square.\n ascii += (margin < 1 && y+1 >= max) ? blocksLastLineNoMargin[p] : blocks[p];\n }\n\n ascii += '\\n';\n }\n\n if (size % 2 && margin > 0) {\n return ascii.substring(0, ascii.length - size - 1) + Array(size+1).join('\u2580');\n }\n\n return ascii.substring(0, ascii.length-1);\n };\n\n _this.createASCII = function(cellSize, margin) {\n cellSize = cellSize || 1;\n\n if (cellSize < 2) {\n return _createHalfASCII(margin);\n }\n\n cellSize -= 1;\n margin = (typeof margin == 'undefined')? cellSize * 2 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n var y, x, r, p;\n\n var white = Array(cellSize+1).join('\u2588\u2588');\n var black = Array(cellSize+1).join(' ');\n\n var ascii = '';\n var line = '';\n for (y = 0; y < size; y += 1) {\n r = Math.floor( (y - min) / cellSize);\n line = '';\n for (x = 0; x < size; x += 1) {\n p = 1;\n\n if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {\n p = 0;\n }\n\n // Output 2 characters per pixel, to create full square. 1 character per pixels gives only half width of square.\n line += p ? white : black;\n }\n\n for (r = 0; r < cellSize; r += 1) {\n ascii += line + '\\n';\n }\n }\n\n return ascii.substring(0, ascii.length-1);\n };\n\n _this.renderTo2dContext = function(context, cellSize) {\n cellSize = cellSize || 2;\n var length = _this.getModuleCount();\n for (var row = 0; row < length; row++) {\n for (var col = 0; col < length; col++) {\n context.fillStyle = _this.isDark(row, col) ? 'black' : 'white';\n context.fillRect(row * cellSize, col * cellSize, cellSize, cellSize);\n }\n }\n }\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrcode.stringToBytes\n //---------------------------------------------------------------------\n\n qrcode.stringToBytesFuncs = {\n 'default' : function(s) {\n var bytes = [];\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charCodeAt(i);\n bytes.push(c & 0xff);\n }\n return bytes;\n }\n };\n\n qrcode.stringToBytes = qrcode.stringToBytesFuncs['default'];\n\n //---------------------------------------------------------------------\n // qrcode.createStringToBytes\n //---------------------------------------------------------------------\n\n /**\n * @param unicodeData base64 string of byte array.\n * [16bit Unicode],[16bit Bytes], ...\n * @param numChars\n */\n qrcode.createStringToBytes = function(unicodeData, numChars) {\n\n // create conversion map.\n\n var unicodeMap = function() {\n\n var bin = base64DecodeInputStream(unicodeData);\n var read = function() {\n var b = bin.read();\n if (b == -1) throw 'eof';\n return b;\n };\n\n var count = 0;\n var unicodeMap = {};\n while (true) {\n var b0 = bin.read();\n if (b0 == -1) break;\n var b1 = read();\n var b2 = read();\n var b3 = read();\n var k = String.fromCharCode( (b0 << 8) | b1);\n var v = (b2 << 8) | b3;\n unicodeMap[k] = v;\n count += 1;\n }\n if (count != numChars) {\n throw count + ' != ' + numChars;\n }\n\n return unicodeMap;\n }();\n\n var unknownChar = '?'.charCodeAt(0);\n\n return function(s) {\n var bytes = [];\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charCodeAt(i);\n if (c < 128) {\n bytes.push(c);\n } else {\n var b = unicodeMap[s.charAt(i)];\n if (typeof b == 'number') {\n if ( (b & 0xff) == b) {\n // 1byte\n bytes.push(b);\n } else {\n // 2bytes\n bytes.push(b >>> 8);\n bytes.push(b & 0xff);\n }\n } else {\n bytes.push(unknownChar);\n }\n }\n }\n return bytes;\n };\n };\n\n //---------------------------------------------------------------------\n // QRMode\n //---------------------------------------------------------------------\n\n var QRMode = {\n MODE_NUMBER : 1 << 0,\n MODE_ALPHA_NUM : 1 << 1,\n MODE_8BIT_BYTE : 1 << 2,\n MODE_KANJI : 1 << 3\n };\n\n //---------------------------------------------------------------------\n // QRErrorCorrectionLevel\n //---------------------------------------------------------------------\n\n var QRErrorCorrectionLevel = {\n L : 1,\n M : 0,\n Q : 3,\n H : 2\n };\n\n //---------------------------------------------------------------------\n // QRMaskPattern\n //---------------------------------------------------------------------\n\n var QRMaskPattern = {\n PATTERN000 : 0,\n PATTERN001 : 1,\n PATTERN010 : 2,\n PATTERN011 : 3,\n PATTERN100 : 4,\n PATTERN101 : 5,\n PATTERN110 : 6,\n PATTERN111 : 7\n };\n\n //---------------------------------------------------------------------\n // QRUtil\n //---------------------------------------------------------------------\n\n var QRUtil = function() {\n\n var PATTERN_POSITION_TABLE = [\n [],\n [6, 18],\n [6, 22],\n [6, 26],\n [6, 30],\n [6, 34],\n [6, 22, 38],\n [6, 24, 42],\n [6, 26, 46],\n [6, 28, 50],\n [6, 30, 54],\n [6, 32, 58],\n [6, 34, 62],\n [6, 26, 46, 66],\n [6, 26, 48, 70],\n [6, 26, 50, 74],\n [6, 30, 54, 78],\n [6, 30, 56, 82],\n [6, 30, 58, 86],\n [6, 34, 62, 90],\n [6, 28, 50, 72, 94],\n [6, 26, 50, 74, 98],\n [6, 30, 54, 78, 102],\n [6, 28, 54, 80, 106],\n [6, 32, 58, 84, 110],\n [6, 30, 58, 86, 114],\n [6, 34, 62, 90, 118],\n [6, 26, 50, 74, 98, 122],\n [6, 30, 54, 78, 102, 126],\n [6, 26, 52, 78, 104, 130],\n [6, 30, 56, 82, 108, 134],\n [6, 34, 60, 86, 112, 138],\n [6, 30, 58, 86, 114, 142],\n [6, 34, 62, 90, 118, 146],\n [6, 30, 54, 78, 102, 126, 150],\n [6, 24, 50, 76, 102, 128, 154],\n [6, 28, 54, 80, 106, 132, 158],\n [6, 32, 58, 84, 110, 136, 162],\n [6, 26, 54, 82, 110, 138, 166],\n [6, 30, 58, 86, 114, 142, 170]\n ];\n var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);\n var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);\n var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);\n\n var _this = {};\n\n var getBCHDigit = function(data) {\n var digit = 0;\n while (data != 0) {\n digit += 1;\n data >>>= 1;\n }\n return digit;\n };\n\n _this.getBCHTypeInfo = function(data) {\n var d = data << 10;\n while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {\n d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) );\n }\n return ( (data << 10) | d) ^ G15_MASK;\n };\n\n _this.getBCHTypeNumber = function(data) {\n var d = data << 12;\n while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {\n d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) );\n }\n return (data << 12) | d;\n };\n\n _this.getPatternPosition = function(typeNumber) {\n return PATTERN_POSITION_TABLE[typeNumber - 1];\n };\n\n _this.getMaskFunction = function(maskPattern) {\n\n switch (maskPattern) {\n\n case QRMaskPattern.PATTERN000 :\n return function(i, j) { return (i + j) % 2 == 0; };\n case QRMaskPattern.PATTERN001 :\n return function(i, j) { return i % 2 == 0; };\n case QRMaskPattern.PATTERN010 :\n return function(i, j) { return j % 3 == 0; };\n case QRMaskPattern.PATTERN011 :\n return function(i, j) { return (i + j) % 3 == 0; };\n case QRMaskPattern.PATTERN100 :\n return function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; };\n case QRMaskPattern.PATTERN101 :\n return function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; };\n case QRMaskPattern.PATTERN110 :\n return function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; };\n case QRMaskPattern.PATTERN111 :\n return function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; };\n\n default :\n throw 'bad maskPattern:' + maskPattern;\n }\n };\n\n _this.getErrorCorrectPolynomial = function(errorCorrectLength) {\n var a = qrPolynomial([1], 0);\n for (var i = 0; i < errorCorrectLength; i += 1) {\n a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) );\n }\n return a;\n };\n\n _this.getLengthInBits = function(mode, type) {\n\n if (1 <= type && type < 10) {\n\n // 1 - 9\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 10;\n case QRMode.MODE_ALPHA_NUM : return 9;\n case QRMode.MODE_8BIT_BYTE : return 8;\n case QRMode.MODE_KANJI : return 8;\n default :\n throw 'mode:' + mode;\n }\n\n } else if (type < 27) {\n\n // 10 - 26\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 12;\n case QRMode.MODE_ALPHA_NUM : return 11;\n case QRMode.MODE_8BIT_BYTE : return 16;\n case QRMode.MODE_KANJI : return 10;\n default :\n throw 'mode:' + mode;\n }\n\n } else if (type < 41) {\n\n // 27 - 40\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 14;\n case QRMode.MODE_ALPHA_NUM : return 13;\n case QRMode.MODE_8BIT_BYTE : return 16;\n case QRMode.MODE_KANJI : return 12;\n default :\n throw 'mode:' + mode;\n }\n\n } else {\n throw 'type:' + type;\n }\n };\n\n _this.getLostPoint = function(qrcode) {\n\n var moduleCount = qrcode.getModuleCount();\n\n var lostPoint = 0;\n\n // LEVEL1\n\n for (var row = 0; row < moduleCount; row += 1) {\n for (var col = 0; col < moduleCount; col += 1) {\n\n var sameCount = 0;\n var dark = qrcode.isDark(row, col);\n\n for (var r = -1; r <= 1; r += 1) {\n\n if (row + r < 0 || moduleCount <= row + r) {\n continue;\n }\n\n for (var c = -1; c <= 1; c += 1) {\n\n if (col + c < 0 || moduleCount <= col + c) {\n continue;\n }\n\n if (r == 0 && c == 0) {\n continue;\n }\n\n if (dark == qrcode.isDark(row + r, col + c) ) {\n sameCount += 1;\n }\n }\n }\n\n if (sameCount > 5) {\n lostPoint += (3 + sameCount - 5);\n }\n }\n };\n\n // LEVEL2\n\n for (var row = 0; row < moduleCount - 1; row += 1) {\n for (var col = 0; col < moduleCount - 1; col += 1) {\n var count = 0;\n if (qrcode.isDark(row, col) ) count += 1;\n if (qrcode.isDark(row + 1, col) ) count += 1;\n if (qrcode.isDark(row, col + 1) ) count += 1;\n if (qrcode.isDark(row + 1, col + 1) ) count += 1;\n if (count == 0 || count == 4) {\n lostPoint += 3;\n }\n }\n }\n\n // LEVEL3\n\n for (var row = 0; row < moduleCount; row += 1) {\n for (var col = 0; col < moduleCount - 6; col += 1) {\n if (qrcode.isDark(row, col)\n && !qrcode.isDark(row, col + 1)\n && qrcode.isDark(row, col + 2)\n && qrcode.isDark(row, col + 3)\n && qrcode.isDark(row, col + 4)\n && !qrcode.isDark(row, col + 5)\n && qrcode.isDark(row, col + 6) ) {\n lostPoint += 40;\n }\n }\n }\n\n for (var col = 0; col < moduleCount; col += 1) {\n for (var row = 0; row < moduleCount - 6; row += 1) {\n if (qrcode.isDark(row, col)\n && !qrcode.isDark(row + 1, col)\n && qrcode.isDark(row + 2, col)\n && qrcode.isDark(row + 3, col)\n && qrcode.isDark(row + 4, col)\n && !qrcode.isDark(row + 5, col)\n && qrcode.isDark(row + 6, col) ) {\n lostPoint += 40;\n }\n }\n }\n\n // LEVEL4\n\n var darkCount = 0;\n\n for (var col = 0; col < moduleCount; col += 1) {\n for (var row = 0; row < moduleCount; row += 1) {\n if (qrcode.isDark(row, col) ) {\n darkCount += 1;\n }\n }\n }\n\n var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;\n lostPoint += ratio * 10;\n\n return lostPoint;\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // QRMath\n //---------------------------------------------------------------------\n\n var QRMath = function() {\n\n var EXP_TABLE = new Array(256);\n var LOG_TABLE = new Array(256);\n\n // initialize tables\n for (var i = 0; i < 8; i += 1) {\n EXP_TABLE[i] = 1 << i;\n }\n for (var i = 8; i < 256; i += 1) {\n EXP_TABLE[i] = EXP_TABLE[i - 4]\n ^ EXP_TABLE[i - 5]\n ^ EXP_TABLE[i - 6]\n ^ EXP_TABLE[i - 8];\n }\n for (var i = 0; i < 255; i += 1) {\n LOG_TABLE[EXP_TABLE[i] ] = i;\n }\n\n var _this = {};\n\n _this.glog = function(n) {\n\n if (n < 1) {\n throw 'glog(' + n + ')';\n }\n\n return LOG_TABLE[n];\n };\n\n _this.gexp = function(n) {\n\n while (n < 0) {\n n += 255;\n }\n\n while (n >= 256) {\n n -= 255;\n }\n\n return EXP_TABLE[n];\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // qrPolynomial\n //---------------------------------------------------------------------\n\n function qrPolynomial(num, shift) {\n\n if (typeof num.length == 'undefined') {\n throw num.length + '/' + shift;\n }\n\n var _num = function() {\n var offset = 0;\n while (offset < num.length && num[offset] == 0) {\n offset += 1;\n }\n var _num = new Array(num.length - offset + shift);\n for (var i = 0; i < num.length - offset; i += 1) {\n _num[i] = num[i + offset];\n }\n return _num;\n }();\n\n var _this = {};\n\n _this.getAt = function(index) {\n return _num[index];\n };\n\n _this.getLength = function() {\n return _num.length;\n };\n\n _this.multiply = function(e) {\n\n var num = new Array(_this.getLength() + e.getLength() - 1);\n\n for (var i = 0; i < _this.getLength(); i += 1) {\n for (var j = 0; j < e.getLength(); j += 1) {\n num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );\n }\n }\n\n return qrPolynomial(num, 0);\n };\n\n _this.mod = function(e) {\n\n if (_this.getLength() - e.getLength() < 0) {\n return _this;\n }\n\n var ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );\n\n var num = new Array(_this.getLength() );\n for (var i = 0; i < _this.getLength(); i += 1) {\n num[i] = _this.getAt(i);\n }\n\n for (var i = 0; i < e.getLength(); i += 1) {\n num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);\n }\n\n // recursive call\n return qrPolynomial(num, 0).mod(e);\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // QRRSBlock\n //---------------------------------------------------------------------\n\n var QRRSBlock = function() {\n\n var RS_BLOCK_TABLE = [\n\n // L\n // M\n // Q\n // H\n\n // 1\n [1, 26, 19],\n [1, 26, 16],\n [1, 26, 13],\n [1, 26, 9],\n\n // 2\n [1, 44, 34],\n [1, 44, 28],\n [1, 44, 22],\n [1, 44, 16],\n\n // 3\n [1, 70, 55],\n [1, 70, 44],\n [2, 35, 17],\n [2, 35, 13],\n\n // 4\n [1, 100, 80],\n [2, 50, 32],\n [2, 50, 24],\n [4, 25, 9],\n\n // 5\n [1, 134, 108],\n [2, 67, 43],\n [2, 33, 15, 2, 34, 16],\n [2, 33, 11, 2, 34, 12],\n\n // 6\n [2, 86, 68],\n [4, 43, 27],\n [4, 43, 19],\n [4, 43, 15],\n\n // 7\n [2, 98, 78],\n [4, 49, 31],\n [2, 32, 14, 4, 33, 15],\n [4, 39, 13, 1, 40, 14],\n\n // 8\n [2, 121, 97],\n [2, 60, 38, 2, 61, 39],\n [4, 40, 18, 2, 41, 19],\n [4, 40, 14, 2, 41, 15],\n\n // 9\n [2, 146, 116],\n [3, 58, 36, 2, 59, 37],\n [4, 36, 16, 4, 37, 17],\n [4, 36, 12, 4, 37, 13],\n\n // 10\n [2, 86, 68, 2, 87, 69],\n [4, 69, 43, 1, 70, 44],\n [6, 43, 19, 2, 44, 20],\n [6, 43, 15, 2, 44, 16],\n\n // 11\n [4, 101, 81],\n [1, 80, 50, 4, 81, 51],\n [4, 50, 22, 4, 51, 23],\n [3, 36, 12, 8, 37, 13],\n\n // 12\n [2, 116, 92, 2, 117, 93],\n [6, 58, 36, 2, 59, 37],\n [4, 46, 20, 6, 47, 21],\n [7, 42, 14, 4, 43, 15],\n\n // 13\n [4, 133, 107],\n [8, 59, 37, 1, 60, 38],\n [8, 44, 20, 4, 45, 21],\n [12, 33, 11, 4, 34, 12],\n\n // 14\n [3, 145, 115, 1, 146, 116],\n [4, 64, 40, 5, 65, 41],\n [11, 36, 16, 5, 37, 17],\n [11, 36, 12, 5, 37, 13],\n\n // 15\n [5, 109, 87, 1, 110, 88],\n [5, 65, 41, 5, 66, 42],\n [5, 54, 24, 7, 55, 25],\n [11, 36, 12, 7, 37, 13],\n\n // 16\n [5, 122, 98, 1, 123, 99],\n [7, 73, 45, 3, 74, 46],\n [15, 43, 19, 2, 44, 20],\n [3, 45, 15, 13, 46, 16],\n\n // 17\n [1, 135, 107, 5, 136, 108],\n [10, 74, 46, 1, 75, 47],\n [1, 50, 22, 15, 51, 23],\n [2, 42, 14, 17, 43, 15],\n\n // 18\n [5, 150, 120, 1, 151, 121],\n [9, 69, 43, 4, 70, 44],\n [17, 50, 22, 1, 51, 23],\n [2, 42, 14, 19, 43, 15],\n\n // 19\n [3, 141, 113, 4, 142, 114],\n [3, 70, 44, 11, 71, 45],\n [17, 47, 21, 4, 48, 22],\n [9, 39, 13, 16, 40, 14],\n\n // 20\n [3, 135, 107, 5, 136, 108],\n [3, 67, 41, 13, 68, 42],\n [15, 54, 24, 5, 55, 25],\n [15, 43, 15, 10, 44, 16],\n\n // 21\n [4, 144, 116, 4, 145, 117],\n [17, 68, 42],\n [17, 50, 22, 6, 51, 23],\n [19, 46, 16, 6, 47, 17],\n\n // 22\n [2, 139, 111, 7, 140, 112],\n [17, 74, 46],\n [7, 54, 24, 16, 55, 25],\n [34, 37, 13],\n\n // 23\n [4, 151, 121, 5, 152, 122],\n [4, 75, 47, 14, 76, 48],\n [11, 54, 24, 14, 55, 25],\n [16, 45, 15, 14, 46, 16],\n\n // 24\n [6, 147, 117, 4, 148, 118],\n [6, 73, 45, 14, 74, 46],\n [11, 54, 24, 16, 55, 25],\n [30, 46, 16, 2, 47, 17],\n\n // 25\n [8, 132, 106, 4, 133, 107],\n [8, 75, 47, 13, 76, 48],\n [7, 54, 24, 22, 55, 25],\n [22, 45, 15, 13, 46, 16],\n\n // 26\n [10, 142, 114, 2, 143, 115],\n [19, 74, 46, 4, 75, 47],\n [28, 50, 22, 6, 51, 23],\n [33, 46, 16, 4, 47, 17],\n\n // 27\n [8, 152, 122, 4, 153, 123],\n [22, 73, 45, 3, 74, 46],\n [8, 53, 23, 26, 54, 24],\n [12, 45, 15, 28, 46, 16],\n\n // 28\n [3, 147, 117, 10, 148, 118],\n [3, 73, 45, 23, 74, 46],\n [4, 54, 24, 31, 55, 25],\n [11, 45, 15, 31, 46, 16],\n\n // 29\n [7, 146, 116, 7, 147, 117],\n [21, 73, 45, 7, 74, 46],\n [1, 53, 23, 37, 54, 24],\n [19, 45, 15, 26, 46, 16],\n\n // 30\n [5, 145, 115, 10, 146, 116],\n [19, 75, 47, 10, 76, 48],\n [15, 54, 24, 25, 55, 25],\n [23, 45, 15, 25, 46, 16],\n\n // 31\n [13, 145, 115, 3, 146, 116],\n [2, 74, 46, 29, 75, 47],\n [42, 54, 24, 1, 55, 25],\n [23, 45, 15, 28, 46, 16],\n\n // 32\n [17, 145, 115],\n [10, 74, 46, 23, 75, 47],\n [10, 54, 24, 35, 55, 25],\n [19, 45, 15, 35, 46, 16],\n\n // 33\n [17, 145, 115, 1, 146, 116],\n [14, 74, 46, 21, 75, 47],\n [29, 54, 24, 19, 55, 25],\n [11, 45, 15, 46, 46, 16],\n\n // 34\n [13, 145, 115, 6, 146, 116],\n [14, 74, 46, 23, 75, 47],\n [44, 54, 24, 7, 55, 25],\n [59, 46, 16, 1, 47, 17],\n\n // 35\n [12, 151, 121, 7, 152, 122],\n [12, 75, 47, 26, 76, 48],\n [39, 54, 24, 14, 55, 25],\n [22, 45, 15, 41, 46, 16],\n\n // 36\n [6, 151, 121, 14, 152, 122],\n [6, 75, 47, 34, 76, 48],\n [46, 54, 24, 10, 55, 25],\n [2, 45, 15, 64, 46, 16],\n\n // 37\n [17, 152, 122, 4, 153, 123],\n [29, 74, 46, 14, 75, 47],\n [49, 54, 24, 10, 55, 25],\n [24, 45, 15, 46, 46, 16],\n\n // 38\n [4, 152, 122, 18, 153, 123],\n [13, 74, 46, 32, 75, 47],\n [48, 54, 24, 14, 55, 25],\n [42, 45, 15, 32, 46, 16],\n\n // 39\n [20, 147, 117, 4, 148, 118],\n [40, 75, 47, 7, 76, 48],\n [43, 54, 24, 22, 55, 25],\n [10, 45, 15, 67, 46, 16],\n\n // 40\n [19, 148, 118, 6, 149, 119],\n [18, 75, 47, 31, 76, 48],\n [34, 54, 24, 34, 55, 25],\n [20, 45, 15, 61, 46, 16]\n ];\n\n var qrRSBlock = function(totalCount, dataCount) {\n var _this = {};\n _this.totalCount = totalCount;\n _this.dataCount = dataCount;\n return _this;\n };\n\n var _this = {};\n\n var getRsBlockTable = function(typeNumber, errorCorrectionLevel) {\n\n switch(errorCorrectionLevel) {\n case QRErrorCorrectionLevel.L :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];\n case QRErrorCorrectionLevel.M :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];\n case QRErrorCorrectionLevel.Q :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];\n case QRErrorCorrectionLevel.H :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];\n default :\n return undefined;\n }\n };\n\n _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {\n\n var rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);\n\n if (typeof rsBlock == 'undefined') {\n throw 'bad rs block @ typeNumber:' + typeNumber +\n '/errorCorrectionLevel:' + errorCorrectionLevel;\n }\n\n var length = rsBlock.length / 3;\n\n var list = [];\n\n for (var i = 0; i < length; i += 1) {\n\n var count = rsBlock[i * 3 + 0];\n var totalCount = rsBlock[i * 3 + 1];\n var dataCount = rsBlock[i * 3 + 2];\n\n for (var j = 0; j < count; j += 1) {\n list.push(qrRSBlock(totalCount, dataCount) );\n }\n }\n\n return list;\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // qrBitBuffer\n //---------------------------------------------------------------------\n\n var qrBitBuffer = function() {\n\n var _buffer = [];\n var _length = 0;\n\n var _this = {};\n\n _this.getBuffer = function() {\n return _buffer;\n };\n\n _this.getAt = function(index) {\n var bufIndex = Math.floor(index / 8);\n return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;\n };\n\n _this.put = function(num, length) {\n for (var i = 0; i < length; i += 1) {\n _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);\n }\n };\n\n _this.getLengthInBits = function() {\n return _length;\n };\n\n _this.putBit = function(bit) {\n\n var bufIndex = Math.floor(_length / 8);\n if (_buffer.length <= bufIndex) {\n _buffer.push(0);\n }\n\n if (bit) {\n _buffer[bufIndex] |= (0x80 >>> (_length % 8) );\n }\n\n _length += 1;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrNumber\n //---------------------------------------------------------------------\n\n var qrNumber = function(data) {\n\n var _mode = QRMode.MODE_NUMBER;\n var _data = data;\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _data.length;\n };\n\n _this.write = function(buffer) {\n\n var data = _data;\n\n var i = 0;\n\n while (i + 2 < data.length) {\n buffer.put(strToNum(data.substring(i, i + 3) ), 10);\n i += 3;\n }\n\n if (i < data.length) {\n if (data.length - i == 1) {\n buffer.put(strToNum(data.substring(i, i + 1) ), 4);\n } else if (data.length - i == 2) {\n buffer.put(strToNum(data.substring(i, i + 2) ), 7);\n }\n }\n };\n\n var strToNum = function(s) {\n var num = 0;\n for (var i = 0; i < s.length; i += 1) {\n num = num * 10 + chatToNum(s.charAt(i) );\n }\n return num;\n };\n\n var chatToNum = function(c) {\n if ('0' <= c && c <= '9') {\n return c.charCodeAt(0) - '0'.charCodeAt(0);\n }\n throw 'illegal char :' + c;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrAlphaNum\n //---------------------------------------------------------------------\n\n var qrAlphaNum = function(data) {\n\n var _mode = QRMode.MODE_ALPHA_NUM;\n var _data = data;\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _data.length;\n };\n\n _this.write = function(buffer) {\n\n var s = _data;\n\n var i = 0;\n\n while (i + 1 < s.length) {\n buffer.put(\n getCode(s.charAt(i) ) * 45 +\n getCode(s.charAt(i + 1) ), 11);\n i += 2;\n }\n\n if (i < s.length) {\n buffer.put(getCode(s.charAt(i) ), 6);\n }\n };\n\n var getCode = function(c) {\n\n if ('0' <= c && c <= '9') {\n return c.charCodeAt(0) - '0'.charCodeAt(0);\n } else if ('A' <= c && c <= 'Z') {\n return c.charCodeAt(0) - 'A'.charCodeAt(0) + 10;\n } else {\n switch (c) {\n case ' ' : return 36;\n case '$' : return 37;\n case '%' : return 38;\n case '*' : return 39;\n case '+' : return 40;\n case '-' : return 41;\n case '.' : return 42;\n case '/' : return 43;\n case ':' : return 44;\n default :\n throw 'illegal char :' + c;\n }\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qr8BitByte\n //---------------------------------------------------------------------\n\n var qr8BitByte = function(data) {\n\n var _mode = QRMode.MODE_8BIT_BYTE;\n var _data = data;\n var _bytes = qrcode.stringToBytes(data);\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _bytes.length;\n };\n\n _this.write = function(buffer) {\n for (var i = 0; i < _bytes.length; i += 1) {\n buffer.put(_bytes[i], 8);\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrKanji\n //---------------------------------------------------------------------\n\n var qrKanji = function(data) {\n\n var _mode = QRMode.MODE_KANJI;\n var _data = data;\n\n var stringToBytes = qrcode.stringToBytesFuncs['SJIS'];\n if (!stringToBytes) {\n throw 'sjis not supported.';\n }\n !function(c, code) {\n // self test for sjis support.\n var test = stringToBytes(c);\n if (test.length != 2 || ( (test[0] << 8) | test[1]) != code) {\n throw 'sjis not supported.';\n }\n }('\\u53cb', 0x9746);\n\n var _bytes = stringToBytes(data);\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return ~~(_bytes.length / 2);\n };\n\n _this.write = function(buffer) {\n\n var data = _bytes;\n\n var i = 0;\n\n while (i + 1 < data.length) {\n\n var c = ( (0xff & data[i]) << 8) | (0xff & data[i + 1]);\n\n if (0x8140 <= c && c <= 0x9FFC) {\n c -= 0x8140;\n } else if (0xE040 <= c && c <= 0xEBBF) {\n c -= 0xC140;\n } else {\n throw 'illegal char at ' + (i + 1) + '/' + c;\n }\n\n c = ( (c >>> 8) & 0xff) * 0xC0 + (c & 0xff);\n\n buffer.put(c, 13);\n\n i += 2;\n }\n\n if (i < data.length) {\n throw 'illegal char at ' + (i + 1);\n }\n };\n\n return _this;\n };\n\n //=====================================================================\n // GIF Support etc.\n //\n\n //---------------------------------------------------------------------\n // byteArrayOutputStream\n //---------------------------------------------------------------------\n\n var byteArrayOutputStream = function() {\n\n var _bytes = [];\n\n var _this = {};\n\n _this.writeByte = function(b) {\n _bytes.push(b & 0xff);\n };\n\n _this.writeShort = function(i) {\n _this.writeByte(i);\n _this.writeByte(i >>> 8);\n };\n\n _this.writeBytes = function(b, off, len) {\n off = off || 0;\n len = len || b.length;\n for (var i = 0; i < len; i += 1) {\n _this.writeByte(b[i + off]);\n }\n };\n\n _this.writeString = function(s) {\n for (var i = 0; i < s.length; i += 1) {\n _this.writeByte(s.charCodeAt(i) );\n }\n };\n\n _this.toByteArray = function() {\n return _bytes;\n };\n\n _this.toString = function() {\n var s = '';\n s += '[';\n for (var i = 0; i < _bytes.length; i += 1) {\n if (i > 0) {\n s += ',';\n }\n s += _bytes[i];\n }\n s += ']';\n return s;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // base64EncodeOutputStream\n //---------------------------------------------------------------------\n\n var base64EncodeOutputStream = function() {\n\n var _buffer = 0;\n var _buflen = 0;\n var _length = 0;\n var _base64 = '';\n\n var _this = {};\n\n var writeEncoded = function(b) {\n _base64 += String.fromCharCode(encode(b & 0x3f) );\n };\n\n var encode = function(n) {\n if (n < 0) {\n // error.\n } else if (n < 26) {\n return 0x41 + n;\n } else if (n < 52) {\n return 0x61 + (n - 26);\n } else if (n < 62) {\n return 0x30 + (n - 52);\n } else if (n == 62) {\n return 0x2b;\n } else if (n == 63) {\n return 0x2f;\n }\n throw 'n:' + n;\n };\n\n _this.writeByte = function(n) {\n\n _buffer = (_buffer << 8) | (n & 0xff);\n _buflen += 8;\n _length += 1;\n\n while (_buflen >= 6) {\n writeEncoded(_buffer >>> (_buflen - 6) );\n _buflen -= 6;\n }\n };\n\n _this.flush = function() {\n\n if (_buflen > 0) {\n writeEncoded(_buffer << (6 - _buflen) );\n _buffer = 0;\n _buflen = 0;\n }\n\n if (_length % 3 != 0) {\n // padding\n var padlen = 3 - _length % 3;\n for (var i = 0; i < padlen; i += 1) {\n _base64 += '=';\n }\n }\n };\n\n _this.toString = function() {\n return _base64;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // base64DecodeInputStream\n //---------------------------------------------------------------------\n\n var base64DecodeInputStream = function(str) {\n\n var _str = str;\n var _pos = 0;\n var _buffer = 0;\n var _buflen = 0;\n\n var _this = {};\n\n _this.read = function() {\n\n while (_buflen < 8) {\n\n if (_pos >= _str.length) {\n if (_buflen == 0) {\n return -1;\n }\n throw 'unexpected end of file./' + _buflen;\n }\n\n var c = _str.charAt(_pos);\n _pos += 1;\n\n if (c == '=') {\n _buflen = 0;\n return -1;\n } else if (c.match(/^\\s$/) ) {\n // ignore if whitespace.\n continue;\n }\n\n _buffer = (_buffer << 6) | decode(c.charCodeAt(0) );\n _buflen += 6;\n }\n\n var n = (_buffer >>> (_buflen - 8) ) & 0xff;\n _buflen -= 8;\n return n;\n };\n\n var decode = function(c) {\n if (0x41 <= c && c <= 0x5a) {\n return c - 0x41;\n } else if (0x61 <= c && c <= 0x7a) {\n return c - 0x61 + 26;\n } else if (0x30 <= c && c <= 0x39) {\n return c - 0x30 + 52;\n } else if (c == 0x2b) {\n return 62;\n } else if (c == 0x2f) {\n return 63;\n } else {\n throw 'c:' + c;\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // gifImage (B/W)\n //---------------------------------------------------------------------\n\n var gifImage = function(width, height) {\n\n var _width = width;\n var _height = height;\n var _data = new Array(width * height);\n\n var _this = {};\n\n _this.setPixel = function(x, y, pixel) {\n _data[y * _width + x] = pixel;\n };\n\n _this.write = function(out) {\n\n //---------------------------------\n // GIF Signature\n\n out.writeString('GIF87a');\n\n //---------------------------------\n // Screen Descriptor\n\n out.writeShort(_width);\n out.writeShort(_height);\n\n out.writeByte(0x80); // 2bit\n out.writeByte(0);\n out.writeByte(0);\n\n //---------------------------------\n // Global Color Map\n\n // black\n out.writeByte(0x00);\n out.writeByte(0x00);\n out.writeByte(0x00);\n\n // white\n out.writeByte(0xff);\n out.writeByte(0xff);\n out.writeByte(0xff);\n\n //---------------------------------\n // Image Descriptor\n\n out.writeString(',');\n out.writeShort(0);\n out.writeShort(0);\n out.writeShort(_width);\n out.writeShort(_height);\n out.writeByte(0);\n\n //---------------------------------\n // Local Color Map\n\n //---------------------------------\n // Raster Data\n\n var lzwMinCodeSize = 2;\n var raster = getLZWRaster(lzwMinCodeSize);\n\n out.writeByte(lzwMinCodeSize);\n\n var offset = 0;\n\n while (raster.length - offset > 255) {\n out.writeByte(255);\n out.writeBytes(raster, offset, 255);\n offset += 255;\n }\n\n out.writeByte(raster.length - offset);\n out.writeBytes(raster, offset, raster.length - offset);\n out.writeByte(0x00);\n\n //---------------------------------\n // GIF Terminator\n out.writeString(';');\n };\n\n var bitOutputStream = function(out) {\n\n var _out = out;\n var _bitLength = 0;\n var _bitBuffer = 0;\n\n var _this = {};\n\n _this.write = function(data, length) {\n\n if ( (data >>> length) != 0) {\n throw 'length over';\n }\n\n while (_bitLength + length >= 8) {\n _out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );\n length -= (8 - _bitLength);\n data >>>= (8 - _bitLength);\n _bitBuffer = 0;\n _bitLength = 0;\n }\n\n _bitBuffer = (data << _bitLength) | _bitBuffer;\n _bitLength = _bitLength + length;\n };\n\n _this.flush = function() {\n if (_bitLength > 0) {\n _out.writeByte(_bitBuffer);\n }\n };\n\n return _this;\n };\n\n var getLZWRaster = function(lzwMinCodeSize) {\n\n var clearCode = 1 << lzwMinCodeSize;\n var endCode = (1 << lzwMinCodeSize) + 1;\n var bitLength = lzwMinCodeSize + 1;\n\n // Setup LZWTable\n var table = lzwTable();\n\n for (var i = 0; i < clearCode; i += 1) {\n table.add(String.fromCharCode(i) );\n }\n table.add(String.fromCharCode(clearCode) );\n table.add(String.fromCharCode(endCode) );\n\n var byteOut = byteArrayOutputStream();\n var bitOut = bitOutputStream(byteOut);\n\n // clear code\n bitOut.write(clearCode, bitLength);\n\n var dataIndex = 0;\n\n var s = String.fromCharCode(_data[dataIndex]);\n dataIndex += 1;\n\n while (dataIndex < _data.length) {\n\n var c = String.fromCharCode(_data[dataIndex]);\n dataIndex += 1;\n\n if (table.contains(s + c) ) {\n\n s = s + c;\n\n } else {\n\n bitOut.write(table.indexOf(s), bitLength);\n\n if (table.size() < 0xfff) {\n\n if (table.size() == (1 << bitLength) ) {\n bitLength += 1;\n }\n\n table.add(s + c);\n }\n\n s = c;\n }\n }\n\n bitOut.write(table.indexOf(s), bitLength);\n\n // end code\n bitOut.write(endCode, bitLength);\n\n bitOut.flush();\n\n return byteOut.toByteArray();\n };\n\n var lzwTable = function() {\n\n var _map = {};\n var _size = 0;\n\n var _this = {};\n\n _this.add = function(key) {\n if (_this.contains(key) ) {\n throw 'dup key:' + key;\n }\n _map[key] = _size;\n _size += 1;\n };\n\n _this.size = function() {\n return _size;\n };\n\n _this.indexOf = function(key) {\n return _map[key];\n };\n\n _this.contains = function(key) {\n return typeof _map[key] != 'undefined';\n };\n\n return _this;\n };\n\n return _this;\n };\n\n var createDataURL = function(width, height, getPixel) {\n var gif = gifImage(width, height);\n for (var y = 0; y < height; y += 1) {\n for (var x = 0; x < width; x += 1) {\n gif.setPixel(x, y, getPixel(x, y) );\n }\n }\n\n var b = byteArrayOutputStream();\n gif.write(b);\n\n var base64 = base64EncodeOutputStream();\n var bytes = b.toByteArray();\n for (var i = 0; i < bytes.length; i += 1) {\n base64.writeByte(bytes[i]);\n }\n base64.flush();\n\n return 'data:image/gif;base64,' + base64;\n };\n\n //---------------------------------------------------------------------\n // returns qrcode function.\n\n return qrcode;\n}();\n\n// multibyte support\n!function() {\n\n qrcode.stringToBytesFuncs['UTF-8'] = function(s) {\n // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array\n function toUTF8Array(str) {\n var utf8 = [];\n for (var i=0; i < str.length; i++) {\n var charcode = str.charCodeAt(i);\n if (charcode < 0x80) utf8.push(charcode);\n else if (charcode < 0x800) {\n utf8.push(0xc0 | (charcode >> 6),\n 0x80 | (charcode & 0x3f));\n }\n else if (charcode < 0xd800 || charcode >= 0xe000) {\n utf8.push(0xe0 | (charcode >> 12),\n 0x80 | ((charcode>>6) & 0x3f),\n 0x80 | (charcode & 0x3f));\n }\n // surrogate pair\n else {\n i++;\n // UTF-16 encodes 0x10000-0x10FFFF by\n // subtracting 0x10000 and splitting the\n // 20 bits of 0x0-0xFFFFF into two halves\n charcode = 0x10000 + (((charcode & 0x3ff)<<10)\n | (str.charCodeAt(i) & 0x3ff));\n utf8.push(0xf0 | (charcode >>18),\n 0x80 | ((charcode>>12) & 0x3f),\n 0x80 | ((charcode>>6) & 0x3f),\n 0x80 | (charcode & 0x3f));\n }\n }\n return utf8;\n }\n return toUTF8Array(s);\n };\n\n}();\n\n(function (factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof exports === 'object') {\n module.exports = factory();\n }\n}(function () {\n return qrcode;\n}));\n", "/**\n * @file apps/frontend/src/api.ts\n * @description What the plugin's API sends and takes, and the call to it: see src/setup/setupApi.ts in the plugin.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DATA_CENTERS, LAN_VERSIONS } from '../../../src/config.js';\nimport type { SetupReplies, SetupReply } from '../../../src/setup/setupApi.js';\n\n// The types are the plugin's own, so the page and the plugin cannot drift apart. They are only types: nothing of the\n// plugin is loaded in the browser. The page has its own words for some of them.\nexport type { TuyaDeviceExposure as Exposure } from '../../../src/config.js';\nexport type { ControlRef, DeviceFeatures, SensorFeature, SwitchFeature } from '../../../src/features.js';\nexport type { DeviceSupport, ProbeResult } from '../../../src/setup/probe.js';\nexport type { FoundDevice as ListedDevice, QrLoginState, SetupAccount, SetupDevice as StoredDevice, SetupState } from '../../../src/setup/setupApi.js';\n\n/** A data center of the Tuya developer platform, such as `eu`. */\nexport type DataCenter = (typeof DATA_CENTERS)[number];\n\n/** A protocol version a device speaks on the LAN, such as `3.3`. */\nexport type LanVersion = (typeof LAN_VERSIONS)[number];\n\n/** A request the plugin serves, by its method and its path after `api/`. */\nexport type Route = keyof SetupReplies;\n\n/** The reply to a request, with what the plugin sends back when the request worked. */\nexport type Reply<R extends Route> = ({ ok: true } & SetupReplies[R]) | Extract<SetupReply, { ok: false }>;\n\n/** The data centers of the Tuya developer platform, as the page names them: `DATA_CENTERS` in the plugin. */\nexport const dataCenterNames: Readonly<Record<DataCenter, string>> = {\n 'cn': 'China',\n 'us': 'Western America',\n 'us-e': 'Eastern America',\n 'eu': 'Central Europe',\n 'eu-w': 'Western Europe',\n 'in': 'India',\n 'sg': 'Singapore',\n};\n\n/** The protocol versions a device speaks on the LAN: `LAN_VERSIONS` in the plugin. */\nexport const lanVersions: readonly LanVersion[] = ['3.1', '3.2', '3.3', '3.4', '3.5'];\n\n/** The id of the meter of the main outlet among the features left out: `meterFeatureId` in the plugin. */\nexport const meterFeatureId = 'meter';\n\n/**\n * Call the plugin\n *\n * Every request is a GET or a POST, so that every reply has a body that says whether it worked: Matterbridge answers\n * a DELETE with 204 and no body, whatever the plugin returns.\n *\n * @param {R} route The method and the path, such as `POST probe`.\n * @param {unknown} [body] The JSON body.\n * @returns {Promise<Reply<R>>} The reply, with `ok: false` and the reason when the call did not work.\n */\nexport async function api<R extends Route>(route: R, body?: unknown): Promise<Reply<R>> {\n try {\n const [method, path] = route.split(' ');\n const init: RequestInit = { method };\n if (body !== undefined) {\n init.headers = { 'Content-Type': 'application/json' };\n init.body = JSON.stringify(body);\n }\n const response = await fetch(new URL(`api/${path}`, document.baseURI), init);\n if (response.status === 503) return { ok: false, error: 'The plugin is not running. Start it in Matterbridge, then reload this page.' };\n const reply = (await response.json()) as Reply<R> | { error?: string };\n if ('ok' in reply) return reply;\n return { ok: false, error: reply.error ?? `The plugin answered with status ${response.status}` };\n } catch {\n return { ok: false, error: 'Matterbridge did not answer. Check that it is running, then try again.' };\n }\n}\n", "/**\n * @file apps/frontend/src/state.ts\n * @description What the setup page knows at any moment, and what it reads from that.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DataCenter, DeviceFeatures, Exposure, LanVersion, ListedDevice, ProbeResult, QrLoginState, SetupState } from './api.js';\n\n/** What the page knows of the device a draft is about: what the Tuya cloud lists of it. */\nexport interface DraftDevice {\n deviceId: string;\n /** Its name in the Smart Life app. */\n cloudName?: string;\n productKey: string;\n category?: string;\n}\n\n/** One device on its way through Connect and Options. */\nexport interface Draft extends Exposure {\n device: DraftDevice;\n name: string;\n /** The host the device is reached at on the LAN, or empty to find it there by its broadcasts. */\n host: string;\n /** The protocol version it speaks at `host`, or empty while no host is given. */\n version: LanVersion | '';\n /** Whether the device is reached through the Tuya cloud alone, never on the LAN. */\n isCloudOnly: boolean;\n isNew: boolean;\n /** The catalog entry the controls are named by, once the plugin found it. */\n catalogFile?: string;\n /** The cloud's model of the device, which the controls are named by when the catalog does not list its product. */\n model?: ProbeResult['model'];\n productName?: string;\n /** What the device can show in Matter, once the plugin read it. */\n features?: DeviceFeatures;\n /** The controls the device last reported. */\n values?: ProbeResult['values'];\n probe?: ProbeResult;\n}\n\nexport type ScreenName = 'loading' | 'home' | 'signIn' | 'find' | 'connect' | 'options' | 'done';\n\n/** The sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform. */\nexport interface SignIn {\n method: 'smartLife' | 'developer';\n userCode: string;\n accessId: string;\n dataCenter: DataCenter;\n}\n\n/** What the page knows at any moment: the screen it is on, the state the plugin sent, and what the user is doing. */\nexport const view = {\n screen: 'loading' as ScreenName,\n setup: undefined as SetupState | undefined,\n signIn: { method: 'smartLife', userCode: '', accessId: '', dataCenter: 'eu' } as SignIn,\n /** The sign in by QR code, as the plugin last told it. */\n login: { status: 'idle' } as QrLoginState,\n devices: [] as ListedDevice[],\n selected: new Set<string>(),\n queue: [] as Draft[],\n saved: [] as string[],\n /** The devices this run is done with, in the order it went through them. */\n handled: [] as { label: string; isSaved: boolean }[],\n isBusy: false,\n busyText: '',\n error: '',\n /** A note for the user that is no problem, such as what to do after a change. */\n info: '',\n confirmingRemoval: '',\n confirmingSignOut: false,\n};\n\n/**\n * Get the device the run is on\n *\n * @returns {Draft | undefined} The device, or undefined when no run is going on.\n */\nexport function currentDraft(): Draft | undefined {\n return view.queue[0];\n}\n\n/**\n * Get what a device is called on the page: its name, or its device ID until it has one\n *\n * @param {Draft} draft The device.\n * @returns {string} The name, or the device ID.\n */\nexport function draftLabel(draft: Draft): string {\n return draft.name === '' ? draft.device.deviceId : draft.name;\n}\n\n/**\n * Describe a device as the Smart Life app knows it, to tell it apart: its product, its device ID and its name there\n *\n * @param {DraftDevice} device The device.\n * @param {string} [productName] The name the product is sold under, once the plugin found it.\n * @returns {string} The description.\n */\nexport function deviceLabel(device: DraftDevice, productName?: string): string {\n const product = productName === undefined ? 'device' : productName;\n return device.cloudName === undefined ? `${product} ${device.deviceId}` : `${product} ${device.deviceId}, named \"${device.cloudName}\" in the Smart Life app`;\n}\n", "/**\n * @file apps/frontend/src/drafts.ts\n * @description The drafts the Connect and Options steps work on, and the choices of how a device appears in Matter.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DeviceFeatures, Exposure, ListedDevice, StoredDevice } from './api.js';\nimport { type Draft, view } from './state.js';\n\n/** The longest name Matter takes. */\nconst maxNameLength = 32;\n\n/**\n * Tell whether two models of a device say the same\n *\n * The stored model and the one the cloud gives hold the same fields in another order, which says nothing.\n *\n * @param {unknown} left One model, or undefined for a device without one.\n * @param {unknown} right The other model, or undefined for a device without one.\n * @returns {boolean} True when both hold the same data points, whatever the order of their fields.\n */\nexport function hasSameModel(left: unknown, right: unknown): boolean {\n if (!isFields(left) || !isFields(right)) return JSON.stringify(left) === JSON.stringify(right);\n const names = Object.keys(left);\n return names.length === Object.keys(right).length && names.every((name) => hasSameModel(left[name], right[name]));\n}\n\n/**\n * Tell whether a value of a model is an object of named fields, whose order says nothing\n *\n * @param {unknown} value The value.\n * @returns {boolean} False for an array, whose order says something, and for any other value.\n */\nfunction isFields(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Copy the choices of how a device appears in Matter, and nothing else\n *\n * @param {Exposure} source What to copy them from.\n * @returns {Exposure} The choices.\n */\nexport function pickExposure(source: Exposure): Exposure {\n return { hiddenFeatures: [...source.hiddenFeatures], addedFeatures: [...source.addedFeatures], isComposed: source.isComposed };\n}\n\n/**\n * Get the feature that is the device itself, and always shown: its first outlet, or its first sensor when it has no outlet\n *\n * @param {DeviceFeatures} features What the device can show.\n * @returns {string | undefined} The id of the feature, or undefined for a device with neither.\n */\nexport function mainFeatureId(features: DeviceFeatures): string | undefined {\n return (features.outlets[0] ?? features.sensors[0])?.id;\n}\n\n/**\n * Drop the choices a device has no use for\n *\n * A feature the device does not have is neither left out nor added, so that the options stored are those of what it\n * can do.\n *\n * @param {Exposure} exposure The choices.\n * @param {DeviceFeatures} features What the device can show.\n * @returns {Exposure} The choices that apply to it.\n */\nexport function fitExposure(exposure: Exposure, features: DeviceFeatures): Exposure {\n const main = mainFeatureId(features);\n const shown = new Set([...features.outlets, ...features.sensors].map((feature) => feature.id).filter((id) => id !== main));\n if (features.meter !== undefined && features.outlets.length > 0) shown.add('meter');\n const added = new Set(features.settingSwitches.map((feature) => feature.id));\n return {\n hiddenFeatures: exposure.hiddenFeatures.filter((id) => shown.has(id)),\n addedFeatures: exposure.addedFeatures.filter((id) => added.has(id)),\n isComposed: exposure.isComposed,\n };\n}\n\n/**\n * Find a name no device has yet: the name in the Smart Life app, or that name with a number after it, such as \"Desk Lamp 2\"\n *\n * @param {string} base The name in the Smart Life app.\n * @param {ReadonlySet<string>} taken The names in use.\n * @returns {string} The name, of at most 32 characters.\n */\nfunction uniqueName(base: string, taken: ReadonlySet<string>): string {\n const trimmed = base.trim().slice(0, maxNameLength).trimEnd();\n if (trimmed === '' || !taken.has(trimmed)) return trimmed;\n for (let count = 2; ; count++) {\n const suffix = ` ${count}`;\n const name = `${trimmed.slice(0, maxNameLength - suffix.length).trimEnd()}${suffix}`;\n if (!taken.has(name)) return name;\n }\n}\n\n/**\n * Draft the devices picked in the Find step, each named after its name in the Smart Life app\n *\n * Two devices can share a name there, so each draft gets one no stored device and no draft before it has.\n *\n * @param {readonly ListedDevice[]} devices The devices picked.\n * @returns {Draft[]} The drafts, new and with nothing left out or added yet.\n */\nexport function draftsFromDevices(devices: readonly ListedDevice[]): Draft[] {\n const taken = new Set((view.setup?.devices ?? []).map((device) => device.name));\n return devices.map((listed) => {\n const name = uniqueName(listed.name, taken);\n taken.add(name);\n return {\n device: { deviceId: listed.deviceId, cloudName: listed.name, productKey: listed.productKey, category: listed.category },\n name,\n host: '',\n version: '',\n isCloudOnly: false,\n isNew: true,\n hiddenFeatures: [],\n addedFeatures: [],\n isComposed: false,\n };\n });\n}\n\n/**\n * Draft a stored device, to check it again and change its options\n *\n * @param {StoredDevice} device The device as the plugin stores it.\n * @returns {Draft} The draft, with its options as stored.\n */\nexport function draftFromStored(device: StoredDevice): Draft {\n return {\n device: { deviceId: device.deviceId, cloudName: device.cloudName, productKey: device.productKey, category: device.category },\n name: device.name,\n host: device.host ?? '',\n version: device.version ?? '',\n isCloudOnly: device.isCloudOnly ?? false,\n isNew: false,\n catalogFile: device.catalogFile,\n model: device.model,\n productName: device.productName,\n features: device.features,\n values: device.values,\n ...pickExposure(device),\n };\n}\n", "/**\n * @file apps/frontend/src/render.ts\n * @description Draws the screen the setup page is on. The screens are handed in by app.ts, so that they and the\n * actions can call for a redraw without this file depending on them.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Child } from './dom.js';\nimport { currentDraft, type ScreenName, view } from './state.js';\n\nexport type Screens = Record<ScreenName, () => Child[]>;\n\nlet screens: Screens | undefined;\n\n/**\n * Tell the page what each screen draws\n *\n * @param {Screens} all What each screen draws, by its name.\n * @returns {void}\n */\nexport function setScreens(all: Screens): void {\n screens = all;\n}\n\n/**\n * Draw the screen the page is on\n *\n * What the user is typing is kept when the same form redraws around it, with the focus and the caret where they were.\n *\n * @returns {void}\n */\nexport function render(): void {\n const root = document.getElementById('app');\n if (root === null || screens === undefined) return;\n // Keep what the user is typing when the same form redraws around it, and never carry it over to another form.\n const form = `${view.screen}:${currentDraft()?.device.deviceId ?? ''}`;\n const isSameForm = root.dataset.form === form;\n const active = document.activeElement;\n const activeId = active instanceof HTMLElement ? active.id : '';\n // Where the caret is in the field being typed in, so that a redraw while typing does not move it to the end.\n const caret =\n active instanceof HTMLInputElement && (active.type === 'text' || active.type === 'password') ? { start: active.selectionStart, end: active.selectionEnd } : undefined;\n const typed = new Map<string, string>();\n for (const input of root.querySelectorAll<HTMLInputElement>('input[type=text], input[type=email], input[type=password]')) {\n if (input.id !== '') typed.set(input.id, input.value);\n }\n root.replaceChildren(...screens[view.screen]().filter((child): child is Node | string => child !== false && child !== null && child !== undefined));\n root.dataset.form = form;\n if (!isSameForm) return;\n for (const [id, value] of typed) {\n const input = document.getElementById(id);\n if (input instanceof HTMLInputElement) input.value = value;\n }\n if (activeId === '') return;\n const focused = document.getElementById(activeId);\n focused?.focus();\n if (caret !== undefined && focused instanceof HTMLInputElement) focused.setSelectionRange(caret.start, caret.end);\n}\n", "/**\n * @file apps/frontend/src/actions.ts\n * @description What the buttons of the setup page do: each call to the plugin and where the page goes next.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { api, type DataCenter, type QrLoginState, type SetupState, type StoredDevice } from './api.js';\nimport { draftFromStored, fitExposure, hasSameModel, pickExposure } from './drafts.js';\nimport { render } from './render.js';\nimport { currentDraft, type Draft, draftLabel, view } from './state.js';\n\n/**\n * Run a call while the page shows that it is working\n *\n * @param {string} text What the page says meanwhile.\n * @param {() => Promise<T>} task The call.\n * @returns {Promise<T>} What the call returned.\n */\nasync function busy<T>(text: string, task: () => Promise<T>): Promise<T> {\n view.isBusy = true;\n view.busyText = text;\n view.error = '';\n view.info = '';\n render();\n try {\n return await task();\n } finally {\n view.isBusy = false;\n render();\n }\n}\n\n/**\n * Load the page: read the state, and go to the screen it calls for\n *\n * @returns {Promise<void>} Resolves when the first screen is drawn.\n */\nexport async function loadState(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) {\n view.error = reply.error;\n view.screen = 'home';\n render();\n return;\n }\n setSetup(reply.state);\n // With no account and no device yet, the page goes straight to signing in, and with no device yet to finding them.\n if (reply.state.account === undefined && reply.state.devices.length === 0) {\n startSignIn();\n return;\n }\n if (reply.state.account !== undefined && reply.state.devices.length === 0 && !reply.state.account.needsSignIn) {\n await search();\n return;\n }\n view.screen = 'home';\n render();\n void syncState();\n}\n\n/**\n * Read the device list of the account again behind the page as it opens, so that what changed in the Smart Life app\n * since the last read, such as a name, shows without waiting for the next one\n *\n * The page is redrawn only when the state changed: a redraw for nothing could land between a press and its click, and\n * lose the click.\n *\n * @returns {Promise<void>} Resolves when the list is read.\n */\nasync function syncState(): Promise<void> {\n if (view.setup?.account === undefined) return;\n const reply = await api('POST sync');\n if (!reply.ok || JSON.stringify(reply.state) === JSON.stringify(view.setup)) return;\n setSetup(reply.state);\n render();\n}\n\n// The state is read again this long after it showed a device connecting.\nconst connectingRefreshInMs = 2000;\nlet connectingRefresh: number | undefined;\n\n/**\n * Take the state the plugin sent, and read it again in a moment while a device connects, so that its status settles without a reload\n *\n * @param {SetupState} state The state.\n * @returns {void}\n */\nfunction setSetup(state: SetupState): void {\n view.setup = state;\n if (connectingRefresh !== undefined || !state.devices.some((device) => device.status === 'connecting')) return;\n connectingRefresh = window.setTimeout(() => {\n connectingRefresh = undefined;\n void followConnecting();\n }, connectingRefreshInMs);\n}\n\n/**\n * Read the state again while a device connects, and redraw the home screen when it changed\n *\n * The home screen alone shows the devices. Another screen is left as it is, and a state that did not change redraws\n * nothing: a redraw for nothing could land between a press and its click, and lose the click.\n *\n * @returns {Promise<void>} Resolves when the state is read.\n */\nasync function followConnecting(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) return;\n const hasChanged = JSON.stringify(reply.state) !== JSON.stringify(view.setup);\n setSetup(reply.state);\n if (hasChanged && view.screen === 'home') render();\n}\n\n/**\n * Read the state again, without redrawing\n *\n * @returns {Promise<void>} Resolves when the state is read.\n */\nasync function refreshState(): Promise<void> {\n const reply = await api('GET state');\n if (reply.ok) setSetup(reply.state);\n}\n\n/**\n * Go to the home screen, leaving a run of the setup, and read the state again behind it\n *\n * @returns {void}\n */\nexport function goHome(): void {\n stopQrPolling();\n view.queue = [];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'home';\n void refreshState().then(render);\n render();\n}\n\n/**\n * Go to the sign in, with the fields of the account signed in filled in\n *\n * @returns {void}\n */\nexport function startSignIn(): void {\n const account = view.setup?.account;\n if (account?.type === 'smartLife') view.signIn = { ...view.signIn, method: 'smartLife', userCode: account.userCode };\n if (account?.type === 'developer') view.signIn = { ...view.signIn, method: 'developer', accessId: account.accessId, dataCenter: account.dataCenter };\n view.login = { status: 'idle' };\n view.error = '';\n view.info = '';\n view.screen = 'signIn';\n render();\n}\n\n// The sign in by QR code is followed this often while the app has not confirmed it.\nconst qrPollIntervalInMs = 2000;\nlet qrPoll: number | undefined;\n\n/**\n * Stop following the sign in by QR code\n *\n * @returns {void}\n */\nfunction stopQrPolling(): void {\n window.clearInterval(qrPoll);\n qrPoll = undefined;\n}\n\n/**\n * Ask the plugin for a QR code to sign in with the Smart Life app, show it, and follow the scan\n *\n * @param {string} userCode The User Code the app shows under Settings > Account and Security.\n * @returns {Promise<void>} Resolves when the QR code is shown, or the refusal.\n */\nexport async function requestQrCode(userCode: string): Promise<void> {\n view.signIn.userCode = userCode;\n stopQrPolling();\n const reply = await busy('Asking the Smart Life cloud for a QR code\u2026', async () => api('POST qr-code', { userCode }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n view.login = reply.login;\n render();\n qrPoll = window.setInterval(() => void pollQrLogin(), qrPollIntervalInMs);\n}\n\n/**\n * Ask once how the sign in by QR code goes, and take the account once the scan is in\n *\n * @returns {Promise<void>} Resolves when the answer is taken.\n */\nasync function pollQrLogin(): Promise<void> {\n const reply = await api('GET qr-login');\n // A poll that failed is tried again at the next interval, unless the page left the sign in meanwhile.\n if (!reply.ok || view.screen !== 'signIn' || qrPoll === undefined) return;\n const { login } = reply;\n if (login.status === 'waiting') return;\n stopQrPolling();\n await takeLogin(login, reply.state);\n}\n\n/**\n * Take the outcome of the sign in by QR code\n *\n * @param {QrLoginState} login How the sign in went.\n * @param {SetupState} state The state, with the account once it is signed in.\n * @returns {Promise<void>} Resolves when the page shows it.\n */\nasync function takeLogin(login: QrLoginState, state: SetupState): Promise<void> {\n view.login = login;\n if (login.status !== 'signedIn') {\n render();\n return;\n }\n setSetup(state);\n await afterSignIn(state);\n}\n\n/**\n * Go on after a sign in: to the devices, unless they are set up already\n *\n * @param {SetupState} state The state, with the account signed in.\n * @returns {Promise<void>} Resolves when the next screen is drawn.\n */\nasync function afterSignIn(state: SetupState): Promise<void> {\n view.login = { status: 'idle' };\n if (state.devices.length === 0) await search();\n else goHome();\n}\n\n/**\n * Stop the sign in by QR code, here and in the plugin\n *\n * @returns {Promise<void>} Resolves when the plugin stopped waiting for the scan.\n */\nexport async function cancelQrCode(): Promise<void> {\n stopQrPolling();\n view.login = { status: 'idle' };\n await api('POST cancel-qr-code');\n render();\n}\n\n/**\n * Sign in with a cloud project of the Tuya developer platform\n *\n * @param {string} accessId The Access ID of the project.\n * @param {string} accessSecret The Access Secret of the project.\n * @param {DataCenter} dataCenter The data center of the project.\n * @returns {Promise<void>} Resolves when the account is signed in and the page went on, or shows the refusal.\n */\nexport async function signInDeveloper(accessId: string, accessSecret: string, dataCenter: DataCenter): Promise<void> {\n view.signIn = { ...view.signIn, accessId, dataCenter };\n const reply = await busy('Signing in to the Tuya developer platform\u2026', async () => api('POST developer-login', { accessId, accessSecret, dataCenter }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n setSetup(reply.state);\n await afterSignIn(reply.state);\n}\n\n/**\n * Sign out of the account: the devices stay, on the LAN alone\n *\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function signOut(): Promise<void> {\n const reply = await busy('Signing out\u2026', async () => api('POST sign-out'));\n view.confirmingSignOut = false;\n if (!reply.ok) view.error = reply.error;\n await refreshState();\n render();\n}\n\n/**\n * Go to the Find step, and list the devices of the account, with the ones the plugin can add picked\n *\n * @returns {Promise<void>} Resolves when the devices are shown, or the failure.\n */\nexport async function search(): Promise<void> {\n view.screen = 'find';\n const reply = await busy('Reading the devices of your Tuya account\u2026', async () => api('POST devices'));\n if (!reply.ok) {\n view.error = `The devices could not be read: ${reply.error}`;\n render();\n return;\n }\n await refreshState();\n view.devices = reply.devices;\n for (const device of reply.devices) {\n if (!device.isConfigured && device.support === 'supported') view.selected.add(device.deviceId);\n }\n render();\n}\n\n/**\n * Start a run of the setup through the Connect and Options steps, one device after the other\n *\n * @param {Draft[]} drafts The devices to set up, in order.\n * @returns {void}\n */\nexport function startQueue(drafts: Draft[]): void {\n view.queue = drafts;\n view.saved = [];\n view.handled = [];\n void enterConnect();\n}\n\n/**\n * Go straight to the options of a stored device, with the entry it is stored with\n *\n * The device is not checked first: its host can be changed while it does not answer, and it needs no account. Its\n * entry stays as chosen, so that opening the options never replaces it or the features chosen from it.\n *\n * @param {StoredDevice} device The device, whose catalog entry this version has.\n * @returns {void}\n */\nexport function openOptions(device: StoredDevice): void {\n view.queue = [draftFromStored(device)];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'options';\n render();\n}\n\n/**\n * Give a stored device a new client, or start it again, and show how it went\n *\n * @param {StoredDevice} device The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function reconnectDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Reconnecting ${device.name}\u2026`, async () => api('POST reconnect', { deviceId: device.deviceId }));\n if (reply.ok) setSetup(reply.state);\n else view.error = reply.error;\n render();\n}\n\n/**\n * Go to the Connect step of the next device of the run, or to the end of the run\n *\n * @returns {Promise<void>} Resolves when the device is checked, or the end is shown.\n */\nasync function enterConnect(): Promise<void> {\n const draft = currentDraft();\n if (draft === undefined) {\n view.screen = view.saved.length > 0 ? 'done' : 'home';\n await refreshState();\n render();\n return;\n }\n view.screen = 'connect';\n view.error = '';\n view.info = '';\n draft.probe = undefined;\n render();\n await check(draft);\n}\n\n/**\n * Check a device through the plugin, and go to its options once it answers\n *\n * @param {Draft} draft The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function check(draft: Draft): Promise<void> {\n const reply = await busy(`Connecting to ${draftLabel(draft)} on your network, and through the Tuya cloud\u2026`, async () => api('POST probe', { deviceId: draft.device.deviceId }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n const { result } = reply;\n draft.probe = result;\n if (result.status === 'signInRequired') await refreshState();\n if (result.status === 'ready' && result.features !== undefined && (result.catalogFile !== undefined || result.model !== undefined)) {\n draft.features = result.features;\n draft.values = result.values;\n draft.productName = result.productName;\n // A device set up again because its entry is gone has other features: the options are fitted to the ones it has.\n const hadEntry = draft.catalogFile !== undefined || draft.model !== undefined;\n if (hadEntry && (draft.catalogFile !== result.catalogFile || !hasSameModel(draft.model, result.model))) Object.assign(draft, { hiddenFeatures: [], addedFeatures: [] });\n draft.catalogFile = result.catalogFile;\n draft.model = result.model;\n Object.assign(draft, fitExposure(pickExposure(draft), result.features));\n view.screen = 'options';\n }\n render();\n}\n\n/**\n * Leave the device the run is on out, and go on to the next\n *\n * @returns {void}\n */\nexport function skipDraft(): void {\n const skipped = view.queue.shift();\n if (skipped !== undefined) view.handled.push({ label: draftLabel(skipped), isSaved: false });\n void enterConnect();\n}\n\n/**\n * Store a device with the options chosen, and go on to the next\n *\n * @param {Draft} draft The device, with its options.\n * @returns {Promise<void>} Resolves when the device is stored and the page went on, or shows what is wrong.\n */\nexport async function saveDraft(draft: Draft): Promise<void> {\n const name = draft.name.trim();\n const problem = checkName(draft, name) || checkHost(draft);\n if (problem !== '') {\n view.error = problem;\n render();\n return;\n }\n if (draft.catalogFile === undefined && draft.model === undefined) return;\n const { device } = draft;\n // An empty host is left out: the plugin finds the device by its broadcasts. A device on the cloud alone needs none.\n const hasHost = !draft.isCloudOnly && draft.host !== '';\n const saved = {\n deviceId: device.deviceId,\n name,\n productKey: device.productKey,\n catalogFile: draft.catalogFile,\n // A model names the controls by their codes in the device's category, which the plugin checks against the device list.\n model: draft.model,\n category: device.category,\n ...fitExposure(pickExposure(draft), draft.features ?? { outlets: [], settingSwitches: [], sensors: [] }),\n host: hasHost ? draft.host : undefined,\n version: hasHost ? draft.version : undefined,\n isCloudOnly: draft.isCloudOnly || undefined,\n };\n const reply = await busy(`Saving ${name}\u2026`, async () => api('POST device', { device: saved }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n setSetup(reply.state);\n view.saved.push(name);\n view.handled.push({ label: name, isSaved: true });\n view.queue.shift();\n await enterConnect();\n}\n\n/**\n * Tell what is wrong with the name of a draft: the plugin refuses a name another device has\n *\n * @param {Draft} draft The device.\n * @param {string} name Its name, trimmed.\n * @returns {string} What is wrong, or an empty text.\n */\nfunction checkName(draft: Draft, name: string): string {\n if (name === '') return 'Give the device a name: it is the name it gets in Matter.';\n const isTaken = (view.setup?.devices ?? []).some((device) => device.name === name && device.deviceId !== draft.device.deviceId);\n return isTaken ? `\"${name}\" is already the name of another device. Pick a different one.` : '';\n}\n\n/**\n * Tell what is wrong with the host of a draft: a host is given with the protocol version the device speaks there\n *\n * @param {Draft} draft The device.\n * @returns {string} What is wrong, or an empty text.\n */\nfunction checkHost(draft: Draft): string {\n if (draft.isCloudOnly || draft.host === '') return '';\n if (!/^[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?$/.test(draft.host)) return `\"${draft.host}\" is not a host name or an IPv4 address.`;\n return draft.version === '' ? 'Pick the protocol version the device speaks at that host, or leave the host empty.' : '';\n}\n\n// Matterbridge does not tell its own page when a plugin adds or removes a device, so its device list waits for a reload.\nexport const reloadNote = \"Matterbridge's own list of devices shows the change once you reload its page.\";\n\n/** A change of how a device appears in Matter waits for a restart, which the plugin asks Matterbridge for as well. */\nexport const restartNote = 'Restart Matterbridge to apply the new options in Matter: until then the device keeps its current endpoints.';\n\n/**\n * Remove a stored device from the plugin and from Matter\n *\n * @param {StoredDevice} device The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function removeDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Removing ${device.name}\u2026`, async () => api('POST remove-device', { deviceId: device.deviceId }));\n view.confirmingRemoval = '';\n if (reply.ok) view.info = `${device.name} is removed. ${reloadNote}`;\n else view.error = reply.error;\n await refreshState();\n render();\n}\n", "/**\n * @file apps/frontend/src/dom.ts\n * @description The one helper the setup page builds its elements with.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Child = Node | string | false | null | undefined;\n\n/**\n * Create an element\n *\n * @param {K} tag The tag name.\n * @param {Record<string, unknown>} [props] `class`, `on<event>` listeners, and anything else as a property when the element has it, else an attribute.\n * @param {...Child} children Nodes or text; false, null and undefined are skipped.\n * @returns {HTMLElementTagNameMap[K]} The element.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, props: Record<string, unknown> = {}, ...children: Child[]): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === false) continue;\n if (key === 'class') element.className = String(value);\n else if (key === 'html') element.innerHTML = String(value);\n else if (key.startsWith('on') && typeof value === 'function') element.addEventListener(key.slice(2), value as EventListener);\n else if (key in element) (element as unknown as Record<string, unknown>)[key] = value;\n else element.setAttribute(key, String(value));\n }\n for (const child of children) {\n if (child !== false && child !== null && child !== undefined) element.append(child);\n }\n return element;\n}\n", "/**\n * @file apps/frontend/src/components.ts\n * @description The pieces more than one screen of the setup page is made of.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Child, h } from './dom.js';\nimport { currentDraft, type Draft, draftLabel, type ScreenName, view } from './state.js';\n\n/**\n * Create a button, disabled while the page is busy\n *\n * @param {string} label What it says.\n * @param {() => void} onclick What it does.\n * @param {'primary' | 'quiet' | 'danger'} [kind] How it looks: the main action, a quiet one, or one that removes something. Defaults to quiet.\n * @param {boolean} [disabled] Whether it is disabled anyway. Defaults to false.\n * @returns {HTMLButtonElement} The button.\n */\nexport function button(label: string, onclick: () => void, kind: 'primary' | 'quiet' | 'danger' = 'quiet', disabled = false): HTMLButtonElement {\n return h('button', { type: 'button', class: `button ${kind}`, onclick, disabled: disabled || view.isBusy }, label);\n}\n\n/**\n * Show what the page is doing, or what went wrong, or a note for the user\n *\n * @returns {Child} The notice, or null when there is nothing to say.\n */\nexport function notice(): Child {\n if (view.isBusy) return h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), view.busyText);\n if (view.error !== '') return h('p', { class: 'notice problem', role: 'alert' }, view.error);\n if (view.info !== '') return h('p', { class: 'notice', role: 'status' }, view.info);\n return null;\n}\n\n/**\n * List the devices of this run, with the one the page is on marked\n *\n * Shown when a run sets up more than one device, so that it is plain which one the Connect and Options steps are about.\n *\n * @returns {Child} The list, or null for a run of one device, or of none that is new.\n */\nexport function unitStrip(): Child {\n const current = currentDraft();\n if (current === undefined || !current.isNew || view.handled.length + view.queue.length < 2) return null;\n const doing = view.screen === 'connect' ? 'Connecting' : 'Choosing options';\n return h(\n 'ol',\n { 'class': 'units', 'aria-label': 'Devices in this setup' },\n ...view.handled.map((unit) =>\n h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped')),\n ),\n ...view.queue.map((draft, index) =>\n h(\n 'li',\n { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined },\n h('strong', {}, draftLabel(draft)),\n h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting'),\n ),\n ),\n );\n}\n\n/**\n * Create the heading of a step that is about one device: the device first, then what the step does with it\n *\n * @param {Draft} draft The device.\n * @param {string} text What the step does with it.\n * @returns {HTMLElement} The heading.\n */\nexport function unitHeader(draft: Draft, text: string): HTMLElement {\n return h('header', { class: 'unit-header' }, h('h1', {}, draftLabel(draft)), h('p', { class: 'meta' }, text));\n}\n\n/**\n * Show the steps of the setup, Find, Connect and Options, with the current one marked\n *\n * @returns {Child} The steps, or null for a run that only checks devices set up already.\n */\nexport function steps(): Child {\n if (view.queue.length > 0 && !view.queue.some((draft) => draft.isNew)) return null;\n const names = ['Find', 'Connect', 'Options'];\n const screens: ScreenName[] = ['find', 'connect', 'options'];\n const current = screens.indexOf(view.screen);\n return h(\n 'ol',\n { class: 'steps' },\n ...names.map((name, index) => {\n let state = 'ahead';\n if (index < current) state = 'done';\n else if (index === current) state = 'current';\n return h('li', { 'class': state, 'aria-current': index === current ? 'step' : undefined }, name);\n }),\n );\n}\n", "/**\n * @file apps/frontend/src/screens/connect.ts\n * @description The Connect step: the plugin reads the device, on your network and through the Tuya cloud, and finds its catalog entry.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { check, goHome, skipDraft, startSignIn } from '../actions.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { currentDraft, deviceLabel, type Draft, view } from '../state.js';\n\n/**\n * Show what stands in the way of the device, or what the page needs before it can go on\n *\n * @param {Draft} draft The device.\n * @returns {Child} The panel, or null while the check has no answer, or the device answered.\n */\nfunction statusPanel(draft: Draft): Child {\n const status = draft.probe?.status;\n const label = draft.name === '' ? 'The device' : draft.name;\n const message = draft.probe?.message ?? 'unknown';\n if (status === 'signInRequired') {\n return h(\n 'div',\n { class: 'field' },\n h('p', { class: 'notice problem', role: 'alert' }, 'The Tuya cloud no longer accepts the sign in of this plugin.'),\n button('Sign in again', startSignIn, 'primary'),\n );\n }\n if (status === 'unreachable') {\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `${label} did not answer. Check that it is plugged in and shows as online in the Smart Life app, then try again. ${message}`,\n );\n }\n if (status === 'unsupported') return h('p', { class: 'notice problem', role: 'alert' }, `The plugin cannot control ${label}: ${message}`);\n if (status === 'failed') return h('p', { class: 'notice problem', role: 'alert' }, `${label} answered with an error: ${message}`);\n return null;\n}\n\n/**\n * Draw the Connect step: the check of the device the run is on\n *\n * @returns {Child[]} The screen.\n */\nexport function connectScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const canRetry = draft.probe?.status === 'unreachable' || draft.probe?.status === 'failed' || view.error !== '';\n const isOneOfMany = draft.isNew && view.queue.length > 1;\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Connecting to the ${deviceLabel(draft.device, draft.productName)}.`),\n notice(),\n view.isBusy ? null : statusPanel(draft),\n h(\n 'div',\n { class: 'footer' },\n canRetry ? button('Try again', () => void check(draft)) : null,\n button(isOneOfMany ? 'Skip this one' : 'Cancel', isOneOfMany ? skipDraft : goHome),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/done.ts\n * @description The end of a setup run: the devices it added.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, reloadNote, restartNote } from '../actions.js';\nimport { button } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { view } from '../state.js';\n\n/**\n * Draw the end of a run: the devices set up, and what to do next\n *\n * @returns {Child[]} The screen.\n */\nexport function doneScreen(): Child[] {\n const names = view.saved;\n const needsRestart = (view.setup?.devices ?? []).some((device) => names.includes(device.name) && device.needsRestart);\n return [\n h('header', {}, h('h1', {}, names.length === 1 ? `${names[0]} is set up` : `${names.length} devices are set up`)),\n h('p', { class: 'lead' }, 'They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page.'),\n needsRestart ? h('p', { class: 'help' }, h('strong', {}, restartNote)) : null,\n h('p', { class: 'help' }, reloadNote),\n h('div', { class: 'footer' }, button('Done', goHome, 'primary')),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/find.ts\n * @description The Find step: the devices of the account, and why the plugin cannot control one.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, search, startQueue } from '../actions.js';\nimport type { ListedDevice } from '../api.js';\nimport { button, notice, steps } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftsFromDevices } from '../drafts.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\n// A device the catalog does not list by its product may still match by its data points, which the Connect step reads.\nfunction isSelectable(device: ListedDevice): boolean {\n return !device.isConfigured && (device.support === 'supported' || device.support === 'unknownProduct');\n}\n\nfunction notesOf(device: ListedDevice): string[] {\n const notes: string[] = [];\n if (device.isConfigured) notes.push('Already set up.');\n if (device.support === 'unknownProduct') notes.push('The catalog does not list its product: the plugin checks its data points in the next step.');\n if (device.support === 'otherKind') notes.push('A kind of device the plugin does not control yet, such as a light: only switches, plugs and sensors for now.');\n if (device.support === 'gateway') notes.push('A gateway: the devices behind it are listed on their own.');\n if (device.support === 'gateway' || device.support === 'otherKind') return notes;\n if (!device.online) notes.push('The Tuya cloud says it is offline.');\n if (device.gatewayId !== undefined) notes.push('Behind a gateway.');\n if (device.lan !== undefined) notes.push(`Heard on your network at ${device.lan.host}.`);\n if (!device.hasLocalKey) notes.push('No local key from the cloud: reached through the cloud only.');\n return notes;\n}\n\nfunction deviceRow(device: ListedDevice): HTMLElement {\n const isAvailable = isSelectable(device);\n const id = `device-${device.deviceId}`;\n const checkbox = h('input', {\n type: 'checkbox',\n id,\n checked: isAvailable && view.selected.has(device.deviceId),\n disabled: !isAvailable,\n onchange: () => {\n if (checkbox.checked) view.selected.add(device.deviceId);\n else view.selected.delete(device.deviceId);\n render();\n },\n });\n return h(\n 'li',\n { class: isAvailable ? 'found' : 'found unavailable' },\n h(\n 'label',\n { for: id },\n checkbox,\n h(\n 'span',\n {},\n h('strong', {}, device.name),\n h('span', { class: 'meta' }, ` ${device.deviceId}, product ${device.productKey}${device.category === '' ? '' : `, category ${device.category}`}`),\n ...notesOf(device).map((note) => h('span', { class: 'meta note' }, note)),\n ),\n ),\n );\n}\n\n/**\n * Draw the Find step: the devices of the account, to pick the ones to set up\n *\n * @returns {Child[]} The screen.\n */\nexport function findScreen(): Child[] {\n const chosen = view.devices.filter((device) => view.selected.has(device.deviceId) && isSelectable(device));\n const continueLabel = chosen.length === 1 ? 'Set up 1 device' : `Set up ${chosen.length} devices`;\n return [\n steps(),\n h('header', {}, h('h1', {}, 'Your Tuya devices')),\n notice(),\n view.devices.length > 0 ? h('ul', { class: 'found-list' }, ...view.devices.map(deviceRow)) : null,\n !view.isBusy && view.devices.length === 0 && view.error === ''\n ? h('p', { class: 'empty' }, 'Your Tuya account has no device yet. Add your devices in the Smart Life app, then read the list again.')\n : null,\n h(\n 'div',\n { class: 'footer' },\n button('Read the list again', () => void search()),\n button('Cancel', goHome),\n button(continueLabel, () => startQueue(draftsFromDevices(chosen)), 'primary', chosen.length === 0),\n ),\n ];\n}\n", "/**\n * @file src/temperatureUnit.ts\n * @description This file contains how the unit of a temperature is read, which Matter and the setup page share.\n * @author Calvin Che\n * @created 2026-11-01\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ControlValues } from 'open-tuya';\n\nimport type { SensorFeature } from './features.js';\n\n/**\n * Get the unit of a temperature, on a device that switches its unit at runtime as well\n *\n * The setup page bundles this file, so it imports nothing at runtime.\n *\n * @param {ControlValues} values The controls the device reports.\n * @param {SensorFeature} feature The temperature sensor.\n * @returns {string | undefined} The unit the device reports, or the one the catalog gives.\n */\nexport function getTemperatureUnit(values: ControlValues, feature: SensorFeature): string | undefined {\n if (feature.unitFrom === undefined) return feature.unit;\n const unit = values[feature.component]?.[feature.unitFrom];\n return typeof unit === 'string' ? unit : feature.unit;\n}\n", "/**\n * @file apps/frontend/src/readings.ts\n * @description What a device reports, in a line the page can show.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getTemperatureUnit } from '../../../src/temperatureUnit.js';\nimport type { ControlRef, DeviceFeatures, ProbeResult, SensorFeature } from './api.js';\n\ntype Values = NonNullable<ProbeResult['values']>;\n\nfunction read(values: Values, ref: ControlRef): boolean | number | string | undefined {\n return values[ref.component]?.[ref.control];\n}\n\n// Such as \"21.5 \u00B0C\" or \"Open\".\nfunction describeSensor(feature: SensorFeature, value: boolean | number | string, values: Values): string {\n if (feature.kind === 'temperature') {\n const unit = getTemperatureUnit(values, feature);\n return `${String(value)} \u00B0${unit !== undefined && /^f/i.test(unit) ? 'F' : 'C'}`;\n }\n if (feature.kind === 'humidity') return `${String(value)} % humidity`;\n if (feature.kind === 'illuminance') return `${String(value)} lx`;\n const isDetected = value === true || value === 1 || value === 'true';\n if (feature.kind === 'occupancy') return isDetected ? 'Motion' : 'No motion';\n if (feature.kind === 'contact') return isDetected ? 'Open' : 'Closed';\n return isDetected ? 'Water leak' : 'No leak';\n}\n\n/**\n * Describe what a device reports, such as \"Outlet 1 on, Outlet 2 off, 12.3 W, 230 V\"\n *\n * @param {DeviceFeatures | undefined} features What the device can show.\n * @param {Values | undefined} values The controls it reported.\n * @returns {string} The description, or an empty text when it reported none of them.\n */\nexport function describeReadings(features: DeviceFeatures | undefined, values: Values | undefined): string {\n if (features === undefined || values === undefined) return '';\n const parts: string[] = [];\n const isSingleOutlet = features.outlets.length === 1;\n for (const outlet of features.outlets) {\n const value = read(values, outlet);\n if (typeof value === 'boolean') parts.push(isSingleOutlet ? (value ? 'On' : 'Off') : `${outlet.label} ${value ? 'on' : 'off'}`);\n }\n for (const sensor of features.sensors) {\n const value = read(values, sensor);\n if (value !== undefined) parts.push(describeSensor(sensor, value, values));\n }\n const { meter } = features;\n for (const reading of [meter?.power, meter?.voltage, meter?.current, meter?.energy]) {\n if (reading === undefined) continue;\n const value = read(values, reading);\n if (typeof value === 'number') parts.push(`${value} ${reading.unit}`);\n }\n if (features.battery !== undefined) {\n const value = read(values, features.battery);\n if (typeof value === 'number') parts.push(`battery ${value} %`);\n }\n return parts.join(', ');\n}\n", "/**\n * @file apps/frontend/src/screens/home.ts\n * @description The home of the setup page: the account, and the devices set up with how each is doing.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState, openOptions, reconnectDevice, removeDevice, search, signOut, startQueue, startSignIn } from '../actions.js';\nimport { dataCenterNames, meterFeatureId, type StoredDevice } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftFromStored, mainFeatureId } from '../drafts.js';\nimport { describeReadings } from '../readings.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nfunction joinList(parts: readonly string[]): string {\n return parts.length <= 1 ? (parts[0] ?? '') : `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;\n}\n\n// Such as \"an outlet, Outlet 2 and Outlet 3, the meter and a switch for the child lock, all as one device\".\nfunction describeExposure(device: StoredDevice): string {\n const { features } = device;\n if (features === undefined) return 'as it was set up';\n const main = mainFeatureId(features);\n const isShown = (id: string): boolean => id !== main && !device.hiddenFeatures.includes(id);\n const outlets = features.outlets.filter((outlet) => isShown(outlet.id)).map((outlet) => outlet.label);\n const sensors = features.sensors.filter((sensor) => isShown(sensor.id)).map((sensor) => sensor.label.toLowerCase());\n const settings = features.settingSwitches.filter((setting) => device.addedFeatures.includes(setting.id)).map((setting) => setting.label.toLowerCase());\n const first = features.outlets.length > 0 ? 'an outlet' : `a ${features.sensors[0]?.label.toLowerCase() ?? ''} sensor`;\n const parts = [first];\n if (outlets.length > 0) parts.push(joinList(outlets));\n if (features.meter !== undefined && features.outlets.length > 0 && !device.hiddenFeatures.includes(meterFeatureId)) parts.push('the meter');\n if (sensors.length > 0) parts.push(`a sensor for the ${joinList(sensors)}`);\n if (settings.length > 0) parts.push(`a switch for the ${joinList(settings)}`);\n if (features.battery !== undefined) parts.push('its battery');\n const isSeveral = parts.length > 1 || outlets.length > 1;\n return `${joinList(parts)}${isSeveral ? (device.isComposed ? ', all as one device' : ', each a device of its own') : ''}`;\n}\n\n// Where a device that is online is reached.\nconst routeNames = { lan: ' on your network', cloud: ' through the Tuya cloud' } as const;\n\n// A device that answers through the cloud was not reached on the LAN, where the plugin tries it first.\nfunction routeLine(device: StoredDevice): Child {\n if (device.status !== 'online' || device.route !== 'cloud' || device.isCloudOnly === true) return null;\n if (device.hasLan) {\n return h('p', { class: 'meta' }, 'It did not answer on your network, so the plugin reaches it through the Tuya cloud.');\n }\n return h(\n 'p',\n { class: 'meta' },\n 'It was not heard on your network, so the plugin reaches it through the Tuya cloud. Where the plugin cannot hear it, such as on another subnet, enter its IP address in its options.',\n );\n}\n\nfunction deviceRow(device: StoredDevice): HTMLElement {\n const online = `Online${device.route === undefined ? '' : routeNames[device.route]}`;\n const statusText = { online, connecting: 'Connecting\u2026', offline: 'Not answering', stopped: 'Not started' }[device.status];\n const isConfirming = view.confirmingRemoval === device.deviceId;\n const product = device.productName ?? `product ${device.productKey}`;\n const readings = device.status === 'online' ? describeReadings(device.features, device.values) : '';\n return h(\n 'li',\n { class: 'device' },\n h(\n 'div',\n { class: 'device-main' },\n h('h3', {}, device.name),\n h('p', { class: 'meta' }, h('span', { class: `status ${device.status}` }, statusText), ` ${product}, ${device.deviceId}. In Matter: ${describeExposure(device)}.`),\n readings === '' ? null : h('p', { class: 'meta readings' }, `${readings}.`),\n routeLine(device),\n device.status !== 'online' && device.error ? h('p', { class: 'meta problem-text' }, device.error) : null,\n device.needsRestart\n ? h('p', { class: 'meta' }, h('strong', {}, 'Restart Matterbridge'), ' to apply the new options in Matter. Until then it keeps its current endpoints.')\n : null,\n ),\n isConfirming\n ? h(\n 'div',\n { class: 'actions' },\n h('span', { class: 'meta' }, 'Remove it from Matter too?'),\n button('Remove', () => void removeDevice(device), 'danger'),\n button('Keep', () => {\n view.confirmingRemoval = '';\n render();\n }),\n )\n : h(\n 'div',\n { class: 'actions' },\n // A device whose entry this version no longer has is checked again to find one, which takes an account.\n device.features === undefined\n ? button('Set up again', () => startQueue([draftFromStored(device)]), 'quiet', view.setup?.account === undefined)\n : button('Options', () => openOptions(device), 'quiet'),\n device.features !== undefined && (device.status === 'offline' || device.status === 'stopped') ? button('Reconnect', () => void reconnectDevice(device), 'quiet') : null,\n button('Remove', () => {\n view.confirmingRemoval = device.deviceId;\n render();\n }),\n ),\n );\n}\n\nfunction accountPanel(): Child {\n const account = view.setup?.account;\n if (view.setup === undefined) return null;\n if (account === undefined) {\n return h(\n 'section',\n { class: 'account' },\n h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n 'No Tuya account is signed in. The devices below stay in Matter and are reached on your network alone, and new devices cannot be added, until you sign in.',\n ),\n button('Sign in', startSignIn, 'primary'),\n );\n }\n const signedIn =\n account.type === 'smartLife'\n ? `Signed in with the Smart Life app (User Code ${account.userCode}).`\n : `Signed in to the Tuya developer platform (project ${account.accessId}, data center ${dataCenterNames[account.dataCenter]}).`;\n const actions = view.confirmingSignOut\n ? [\n h('span', { class: 'meta' }, 'The devices stay in Matter, and keep working on your network.'),\n button('Sign out', () => void signOut(), 'danger'),\n button('Stay signed in', () => {\n view.confirmingSignOut = false;\n render();\n }),\n ]\n : [\n button(account.needsSignIn ? 'Sign in again' : 'Switch account', startSignIn, account.needsSignIn ? 'primary' : 'quiet'),\n button('Sign out', () => {\n view.confirmingSignOut = true;\n render();\n }),\n ];\n return h(\n 'section',\n { class: 'account' },\n h('p', { class: 'meta' }, signedIn),\n account.needsSignIn\n ? h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n 'The Tuya cloud no longer accepts this sign in. Sign in again to keep the devices reachable through the cloud and to add more.',\n )\n : null,\n h('div', { class: 'actions' }, ...actions),\n );\n}\n\nfunction discoveryNotice(): Child {\n const problem = view.setup?.discoveryError;\n if (problem === undefined) return null;\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `The plugin does not listen for devices on your network, so it reaches them through the Tuya cloud, or at the host given in their options: ${problem}`,\n );\n}\n\n/**\n * Draw the home screen: the account, and the stored devices with how each is doing\n *\n * @returns {Child[]} The screen.\n */\nexport function homeScreen(): Child[] {\n const devices = view.setup?.devices ?? [];\n const canAdd = view.setup?.account !== undefined && !view.setup.account.needsSignIn;\n return [\n h('header', {}, h('h1', {}, 'Tuya devices'), canAdd ? button('Add devices', () => void search(), 'primary') : null),\n notice(),\n accountPanel(),\n discoveryNotice(),\n devices.length === 0 && view.setup\n ? h('p', { class: 'empty' }, 'No device is set up yet. Add one to control it from Matter.')\n : h('ul', { class: 'devices' }, ...devices.map(deviceRow)),\n view.setup ? null : button('Try again', () => void loadState(), 'primary'),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/options.ts\n * @description The Options step: the name of the device in Matter, which of its features appear there, and how it is reached.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, saveDraft } from '../actions.js';\nimport { type DeviceFeatures, type LanVersion, lanVersions, meterFeatureId } from '../api.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { mainFeatureId } from '../drafts.js';\nimport { describeReadings } from '../readings.js';\nimport { render } from '../render.js';\nimport { currentDraft, deviceLabel, type Draft } from '../state.js';\n\nconst sensorKindNames = {\n temperature: 'temperature sensor',\n humidity: 'humidity sensor',\n illuminance: 'light sensor',\n occupancy: 'motion sensor',\n contact: 'contact sensor',\n waterLeak: 'water leak detector',\n} as const;\n\nfunction toggle(id: string, isOn: boolean, title: string, text: string, onpick: (isOn: boolean) => void): HTMLElement {\n const input = h('input', { type: 'checkbox', id, checked: isOn, onchange: () => onpick(input.checked) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction radio<T extends string>(group: string, value: T, current: T, title: string, text: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\n// A part of the main device has no name of its own in Matter: it is tagged with what it is.\nfunction placement(draft: Draft, label: string): string {\n return draft.isComposed ? `It appears as a part of \"${draft.name}\", tagged \"${label}\".` : `It appears as \"${draft.name} ${label}\".`;\n}\n\nfunction setShown(list: string[], id: string, isShown: boolean): string[] {\n const without = list.filter((candidate) => candidate !== id);\n return isShown ? [...without, id] : without;\n}\n\n// Redrawn as it is typed, so that the texts that name the device follow. A redraw when the field is left instead would\n// replace the button the click leaving it is on, and lose that click.\nfunction nameSection(draft: Draft): HTMLElement {\n const input = h('input', { type: 'text', id: 'device-name', value: draft.name, maxLength: 32, autocomplete: 'off', spellcheck: false });\n input.addEventListener('input', (event) => {\n draft.name = input.value.trim();\n // A redraw in the middle of a composition, such as of Japanese text, would end it.\n if (!(event as InputEvent).isComposing) render();\n });\n const cloudName = draft.device.cloudName;\n const cloudText = cloudName === undefined ? '' : `Its name in the Smart Life app is \"${cloudName}\". `;\n return h(\n 'section',\n {},\n h('h2', {}, h('label', { for: 'device-name' }, 'Name in Matter')),\n h(\n 'p',\n { class: 'help' },\n `${cloudText}The name here is what your Matter apps show, up to 32 characters, and no two devices of this plugin share one. A new name in the Smart Life app does not change it.`,\n ),\n h('div', { class: 'inline-form' }, input),\n );\n}\n\nfunction featureSection(draft: Draft, features: DeviceFeatures): HTMLElement {\n const main = mainFeatureId(features);\n const mainFeature = [...features.outlets, ...features.sensors].find((feature) => feature.id === main);\n const items: Child[] = [];\n for (const outlet of features.outlets) {\n if (outlet.id === main) continue;\n items.push(\n toggle(`feature-${outlet.id}`, !draft.hiddenFeatures.includes(outlet.id), outlet.label, `An on/off outlet. ${placement(draft, outlet.label)}`, (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, outlet.id, !isShown);\n render();\n }),\n );\n }\n if (features.meter !== undefined && features.outlets.length > 0) {\n const measures = [features.meter.power && 'power', features.meter.voltage && 'voltage', features.meter.current && 'current', features.meter.energy && 'energy used'].filter(\n (name) => typeof name === 'string',\n );\n items.push(\n toggle(\n 'feature-meter',\n !draft.hiddenFeatures.includes(meterFeatureId),\n 'Meter',\n `The ${measures.join(', ')} of \"${draft.name}\", which few Matter apps show yet: Home Assistant does.`,\n (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, meterFeatureId, !isShown);\n render();\n },\n ),\n );\n }\n for (const sensor of features.sensors) {\n if (sensor.id === main) continue;\n items.push(\n toggle(`feature-${sensor.id}`, !draft.hiddenFeatures.includes(sensor.id), sensor.label, `A ${sensorKindNames[sensor.kind]}. ${placement(draft, sensor.label)}`, (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, sensor.id, !isShown);\n render();\n }),\n );\n }\n for (const setting of features.settingSwitches) {\n items.push(\n toggle(\n `feature-${setting.id}`,\n draft.addedFeatures.includes(setting.id),\n setting.label,\n `A switch for a setting of the device. ${placement(draft, setting.label)}`,\n (isShown) => {\n draft.addedFeatures = setShown(draft.addedFeatures, setting.id, isShown);\n render();\n },\n ),\n );\n }\n const mainText = mainFeature === undefined ? '' : `${mainFeature.label} is the device itself in Matter, and always appears there. `;\n return h(\n 'section',\n {},\n h('h2', {}, 'What appears in Matter'),\n h('p', { class: 'help' }, items.length === 0 ? `${mainText}The device has nothing else to show.` : `${mainText}Choose what else appears with it.`),\n items.length === 0 ? null : h('div', { class: 'choices' }, ...items),\n );\n}\n\nfunction composedSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'One device or several'),\n h('p', { class: 'help' }, 'The other outlets, the sensors and the switches can be parts of the device in Matter, or devices of their own beside it.'),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'composed',\n draft.isComposed,\n 'Show it as one device',\n `Your Matter app has one device, \"${draft.name}\", and its parts move between rooms with it. A part has no name of its own in Matter, so an app may show the outlets as numbered outlets, and an app that shows no parts shows the device alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,\n (isComposed) => {\n draft.isComposed = isComposed;\n render();\n },\n ),\n ),\n );\n}\n\n// The host and the version are read as they are typed, with no redraw: no other text on the page names them.\nfunction hostFields(draft: Draft): HTMLElement {\n const host = h('input', {\n type: 'text',\n id: 'device-host',\n value: draft.host,\n placeholder: 'Leave empty to find it on your network',\n maxLength: 253,\n autocomplete: 'off',\n spellcheck: false,\n });\n host.addEventListener('input', () => {\n draft.host = host.value.trim();\n });\n const version = h(\n 'select',\n {\n id: 'device-version',\n onchange: () => {\n draft.version = version.value as LanVersion | '';\n },\n },\n h('option', { value: '', selected: draft.version === '' }, 'Not set'),\n ...lanVersions.map((value) => h('option', { value, selected: value === draft.version }, value)),\n );\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'device-host' }, 'IP address or host name (optional)'),\n h(\n 'p',\n { class: 'help' },\n 'Most devices need neither of these: leave both empty, and the plugin finds the device by the broadcasts it sends. Only where it does not hear the device on your network, such as on another subnet or in a Docker container without host networking, enter its IP address, ideally one your router keeps for it, and the protocol version it speaks, which the Smart Life app does not show: tinytuya or tuya-local tell it. For a device behind a gateway, enter those of the gateway.',\n ),\n h('div', { class: 'inline-form' }, host),\n h('label', { for: 'device-version' }, 'Protocol version (only with an IP address or host name)'),\n version,\n );\n}\n\nfunction connectionSection(draft: Draft): HTMLElement {\n const pick = (value: 'lan' | 'cloud'): void => {\n draft.isCloudOnly = value === 'cloud';\n render();\n };\n const current = draft.isCloudOnly ? 'cloud' : 'lan';\n const probeRoute = draft.probe?.route;\n let routeNote = '';\n if (probeRoute === 'lan') routeNote = ' It answered on your network just now.';\n else if (probeRoute === 'cloud') routeNote = ' It answered through the Tuya cloud just now: the plugin switches to your network once it hears the device there.';\n return h(\n 'section',\n {},\n h('h2', { id: 'connection-title' }, 'Connection'),\n h('p', { class: 'help' }, `How the plugin reaches the device.${routeNote}`),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'connection-title' },\n radio(\n 'connection',\n 'lan',\n current,\n 'On your network first, through the Tuya cloud otherwise',\n 'The plugin hears the device on your network by the broadcasts it sends, and follows it to a new IP address. It keeps working while the Tuya cloud or the internet is down.',\n pick,\n ),\n radio('connection', 'cloud', current, 'Through the Tuya cloud only', 'For a device that is not on the network of Matterbridge.', pick),\n ),\n draft.isCloudOnly ? null : hostFields(draft),\n );\n}\n\n/**\n * Draw the Options step: the name, the features, the layout and the connection of the device the run is on\n *\n * @returns {Child[]} The screen.\n */\nexport function optionsScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const features = draft.features ?? { outlets: [], settingSwitches: [], sensors: [] };\n const readings = describeReadings(draft.features, draft.values);\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Options for the ${deviceLabel(draft.device, draft.productName)}.`),\n readings === '' ? null : h('p', { class: 'meta readings' }, `It reports: ${readings}.`),\n nameSection(draft),\n featureSection(draft, features),\n composedSection(draft),\n connectionSection(draft),\n draft.isNew\n ? null\n : h(\n 'p',\n { class: 'help' },\n 'Changing what appears in Matter, or whether it is one device, takes effect at the next restart of Matterbridge, which this page and Matterbridge ask for. Until then the device keeps its current endpoints. The name and the connection change at once.',\n ),\n notice(),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', goHome),\n button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary'),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/qr.ts\n * @description Draws the QR code the Smart Life app scans to sign in.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport qrcode from 'qrcode-generator';\n\nimport { h } from './dom.js';\n\n/**\n * Draw a text as a QR code\n *\n * @param {string} text The text, such as the one the plugin gives for the sign in.\n * @returns {HTMLElement} The QR code, as a scalable drawing in a light box.\n */\nexport function qrCodeElement(text: string): HTMLElement {\n // Type 0 picks the smallest QR code the text fits in, at the middle level of error correction.\n const code = qrcode(0, 'M');\n code.addData(text);\n code.make();\n // The drawing is made by the library from the text alone, never markup: innerHTML is safe for it.\n return h('div', { 'class': 'qr', 'role': 'img', 'aria-label': 'QR code to scan with the Smart Life app', 'html': code.createSvgTag({ cellSize: 4, margin: 2, scalable: true }) });\n}\n", "/**\n * @file apps/frontend/src/screens/signIn.ts\n * @description The sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { cancelQrCode, goHome, requestQrCode, signInDeveloper } from '../actions.js';\nimport { type DataCenter, dataCenterNames } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { qrCodeElement } from '../qr.js';\nimport { render } from '../render.js';\nimport { type SignIn, view } from '../state.js';\n\nfunction methodChoice(method: SignIn['method'], title: string, text: string): HTMLElement {\n const id = `method-${method}`;\n const input = h('input', {\n type: 'radio',\n name: 'method',\n id,\n checked: view.signIn.method === method,\n onchange: () => {\n view.signIn.method = method;\n view.error = '';\n render();\n },\n });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction methodSection(): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', { id: 'method-title' }, 'How to sign in'),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'method-title' },\n methodChoice('smartLife', 'With the Smart Life app (recommended)', 'Scan a QR code with the Smart Life or Tuya Smart app your devices are in. Nothing to set up first.'),\n methodChoice(\n 'developer',\n 'With a cloud project of the Tuya developer platform',\n 'For a project you made on platform.tuya.com, with your app account linked to it. Its IoT Core trial has to be extended from time to time.',\n ),\n ),\n );\n}\n\nfunction userCodeForm(): Child[] {\n const input = h('input', { type: 'text', id: 'user-code', value: view.signIn.userCode, maxLength: 32, autocomplete: 'off', spellcheck: false });\n const submit = (): void => {\n const userCode = input.value.trim();\n if (userCode !== '') void requestQrCode(userCode);\n };\n input.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') submit();\n });\n return [\n h(\n 'div',\n { class: 'field' },\n h('label', { for: 'user-code' }, 'User Code'),\n h('p', { class: 'help' }, 'In the Smart Life app, open Me, then the settings, then Account and Security: the User Code is listed there. It is case-sensitive.'),\n h('div', { class: 'inline-form' }, input),\n ),\n h('div', { class: 'footer' }, button('Cancel', goHome), button('Show the QR code', submit, 'primary')),\n ];\n}\n\nfunction qrPanel(qrCode: string): Child[] {\n return [\n h('p', { class: 'lead' }, 'In the Smart Life app, tap the scan icon at the top of the home tab, scan this code, and confirm the sign in in the app.'),\n qrCodeElement(qrCode),\n h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Waiting for the app to confirm\u2026'),\n h('p', { class: 'help' }, 'The plugin signs in as Home Assistant does, so the app may name Home Assistant. The code stays valid for a few minutes.'),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', () => void cancelQrCode()),\n ),\n ];\n}\n\nfunction smartLifeForm(): Child[] {\n const { login } = view;\n if (login.status === 'waiting' && login.qrCode !== undefined) return qrPanel(login.qrCode);\n const problem =\n login.status === 'expired'\n ? 'The QR code was not scanned in time. Show a new one to try again.'\n : login.status === 'failed'\n ? `The sign in did not work: ${login.message ?? 'unknown'}`\n : '';\n return [problem === '' ? null : h('p', { class: 'notice problem', role: 'alert' }, problem), ...userCodeForm()];\n}\n\nfunction developerForm(): Child[] {\n const accessId = h('input', { type: 'text', id: 'access-id', value: view.signIn.accessId, maxLength: 128, autocomplete: 'username', spellcheck: false });\n const accessSecret = h('input', { type: 'password', id: 'access-secret', maxLength: 128, autocomplete: 'current-password' });\n const dataCenter = h(\n 'select',\n { id: 'data-center' },\n ...(Object.keys(dataCenterNames) as DataCenter[]).map((code) => h('option', { value: code, selected: code === view.signIn.dataCenter }, `${dataCenterNames[code]} (${code})`)),\n );\n const submit = (): void => {\n if (accessId.value.trim() === '' || accessSecret.value.trim() === '') return;\n void signInDeveloper(accessId.value.trim(), accessSecret.value.trim(), dataCenter.value as DataCenter);\n };\n accessSecret.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') submit();\n });\n return [\n h(\n 'p',\n { class: 'help' },\n 'The cloud project needs your Smart Life account linked to it, under Devices > Link App Account, and the IoT Core service. Its Access ID and Access Secret are on its overview page.',\n ),\n h('div', { class: 'field' }, h('label', { for: 'access-id' }, 'Access ID'), accessId),\n h('div', { class: 'field' }, h('label', { for: 'access-secret' }, 'Access Secret'), h('p', { class: 'help' }, 'It is kept in the configuration of the plugin.'), accessSecret),\n h(\n 'div',\n { class: 'field' },\n h('label', { for: 'data-center' }, 'Data center'),\n h('p', { class: 'help' }, 'The data center of your app account, which the project lists under Devices.'),\n dataCenter,\n ),\n h('div', { class: 'footer' }, button('Cancel', goHome), button('Sign in', submit, 'primary')),\n ];\n}\n\n/**\n * Draw the sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform\n *\n * @returns {Child[]} The screen.\n */\nexport function signInScreen(): Child[] {\n const isAgain = view.setup?.account !== undefined;\n const isWaiting = view.login.status === 'waiting';\n return [\n h('header', {}, h('h1', {}, isAgain ? 'Sign in to Tuya again' : 'Sign in to Tuya')),\n h(\n 'p',\n { class: 'lead' },\n 'The plugin lists your devices and gets the key each one encrypts its traffic with from the Tuya cloud, then reaches them on your network first. Your password is never asked for.',\n ),\n notice(),\n isWaiting ? null : methodSection(),\n ...(view.signIn.method === 'smartLife' ? smartLifeForm() : developerForm()),\n ];\n}\n", "/**\n * @file apps/frontend/src/theme.ts\n * @description Makes the setup page look like the Matterbridge page it is shown in.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Take the colours and the font of the Matterbridge page this one is shown in\n *\n * @returns {void}\n */\nexport function adoptHostTheme(): void {\n try {\n if (window.parent === window) return;\n const host = getComputedStyle(window.parent.document.body);\n for (const name of ['--primary-color', '--div-bg-color', '--div-text-color', '--main-bg-color', '--main-label-color', '--div-border-color', '--main-light-color']) {\n const value = host.getPropertyValue(name).trim();\n if (value !== '') document.documentElement.style.setProperty(`--host${name.slice(1)}`, value);\n }\n document.documentElement.style.setProperty('--host-font', host.fontFamily);\n } catch {\n // Opened on its own or from another origin: the page keeps its own colours.\n }\n}\n", "/**\n * @file apps/frontend/src/app.ts\n * @description The guided setup page of the Matterbridge Open Tuya plugin. Matterbridge serves it at\n * /plugins/matterbridge-open-tuya/ and it talks to the plugin through api/<path> below that address.\n * This file starts the page: the rest is in the files next to it.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState } from './actions.js';\nimport { h } from './dom.js';\nimport { render, setScreens } from './render.js';\nimport { connectScreen } from './screens/connect.js';\nimport { doneScreen } from './screens/done.js';\nimport { findScreen } from './screens/find.js';\nimport { homeScreen } from './screens/home.js';\nimport { optionsScreen } from './screens/options.js';\nimport { signInScreen } from './screens/signIn.js';\nimport { adoptHostTheme } from './theme.js';\n\nsetScreens({\n loading: () => [h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Loading\u2026')],\n home: homeScreen,\n signIn: signInScreen,\n find: findScreen,\n connect: connectScreen,\n options: optionsScreen,\n done: doneScreen,\n});\n\nadoptHostTheme();\nrender();\nvoid loadState();\n"],
|
|
5
|
-
"mappings": "2jBAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAiBA,IAAIC,IAAS,UAAW,CAWtB,IAAIA,EAAS,SAASC,EAAYC,EAAsB,CAEtD,IAAIC,EAAO,IACPC,EAAO,GAEPC,EAAcJ,EACdK,EAAwBC,EAAuBL,CAAoB,EACnEM,EAAW,KACXC,EAAe,EACfC,EAAa,KACbC,EAAY,CAAC,EAEbC,EAAQ,CAAC,EAETC,EAAW,SAASC,EAAMC,EAAa,CAEzCN,EAAeJ,EAAc,EAAI,GACjCG,GAAW,SAASQ,EAAa,CAE/B,QADIC,EAAU,IAAI,MAAMD,CAAW,EAC1BE,EAAM,EAAGA,EAAMF,EAAaE,GAAO,EAAG,CAC7CD,EAAQC,CAAG,EAAI,I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ACF,CCJAG,GAAW,CACT,QAAS,IAAM,CAACC,EAAE,IAAK,CAAE,MAAO,iBAAkB,KAAM,QAAS,EAAGA,EAAE,OAAQ,CAAE,MAAO,SAAU,CAAC,EAAG,eAAU,CAAC,EAChH,KAAMC,GACN,OAAQC,GACR,KAAMC,GACN,QAASC,GACT,QAASC,GACT,KAAMC,EACR,CAAC,EAEDC,GAAe,EACfC,EAAO,EACFC,GAAU",
|
|
6
|
-
"names": ["require_qrcode", "__commonJSMin", "exports", "module", "qrcode", "typeNumber", "errorCorrectionLevel", "PAD0", "PAD1", "_typeNumber", "_errorCorrectionLevel", "QRErrorCorrectionLevel", "_modules", "_moduleCount", "_dataCache", "_dataList", "_this", "makeImpl", "test", "maskPattern", "moduleCount", "modules", "row", "col", "setupPositionProbePattern", "setupPositionAdjustPattern", "setupTimingPattern", "setupTypeInfo", "setupTypeNumber", "createData", "mapData", "r", "c", "getBestMaskPattern", "minLostPoint", "pattern", "i", "lostPoint", "QRUtil", "pos", "j", "bits", "mod", "data", "inc", "bitIndex", "byteIndex", "maskFunc", "dark", "mask", "createBytes", "buffer", "rsBlocks", "offset", "maxDcCount", "maxEcCount", "dcdata", "ecdata", "dcCount", "ecCount", "rsPoly", "rawPoly", "qrPolynomial", "modPoly", "modIndex", "totalCodeCount", "index", "dataList", "QRRSBlock", "qrBitBuffer", "totalDataCount", "mode", "newData", "qrNumber", "qrAlphaNum", "qr8BitByte", "qrKanji", "cellSize", "margin", "qrHtml", "alt", "title", "opts", "size", "mc", "mr", "qrSvg", "rect", "escapeXml", "min", "max", "createDataURL", "x", "y", "img", "s", "escaped", "_createHalfASCII", "r1", "r2", "p", "blocks", "blocksLastLineNoMargin", "ascii", "white", "black", "line", "context", "length", "bytes", "unicodeData", "numChars", "unicodeMap", "bin", "base64DecodeInputStream", "read", "b", "count", "b0", "b1", "b2", "b3", "k", "v", "unknownChar", "QRMode", "QRMaskPattern", "PATTERN_POSITION_TABLE", "G15", "G18", "G15_MASK", "getBCHDigit", "digit", "d", "errorCorrectLength", "a", "QRMath", "type", "sameCount", "darkCount", "ratio", "EXP_TABLE", "LOG_TABLE", "n", "num", "shift", "_num", "e", "RS_BLOCK_TABLE", "qrRSBlock", "totalCount", "dataCount", "getRsBlockTable", "rsBlock", "list", "_buffer", "_length", "bufIndex", "bit", "_mode", "_data", "strToNum", "chatToNum", "getCode", "_bytes", "stringToBytes", "code", "byteArrayOutputStream", "off", "len", "base64EncodeOutputStream", "_buflen", "_base64", "writeEncoded", "encode", "padlen", "str", "_str", "_pos", "decode", "gifImage", "width", "height", "_width", "_height", "pixel", "out", "lzwMinCodeSize", "raster", "getLZWRaster", "bitOutputStream", "_out", "_bitLength", "_bitBuffer", "clearCode", "endCode", "bitLength", "table", "lzwTable", "byteOut", "bitOut", "dataIndex", "_map", "_size", "key", "getPixel", "gif", "base64", "toUTF8Array", "utf8", "charcode", "factory", "dataCenterNames", "lanVersions", "meterFeatureId", "api", "route", "body", "method", "path", "init", "response", "reply", "view", "currentDraft", "draftLabel", "draft", "deviceLabel", "device", "productName", "product", "maxNameLength", "hasSameModel", "left", "right", "isFields", "names", "name", "value", "pickExposure", "source", "mainFeatureId", "features", "fitExposure", "exposure", "main", "shown", "feature", "id", "added", "uniqueName", "base", "taken", "trimmed", "count", "suffix", "draftsFromDevices", "devices", "view", "device", "listed", "draftFromStored", "screens", "setScreens", "all", "render", "root", "form", "view", "currentDraft", "isSameForm", "active", "activeId", "caret", "typed", "input", "child", "id", "value", "focused", "busy", "text", "task", "view", "render", "loadState", "reply", "api", "setSetup", "startSignIn", "search", "syncState", "connectingRefreshInMs", "connectingRefresh", "state", "device", "followConnecting", "hasChanged", "refreshState", "goHome", "stopQrPolling", "account", "qrPollIntervalInMs", "qrPoll", "requestQrCode", "userCode", "pollQrLogin", "login", "takeLogin", "afterSignIn", "cancelQrCode", "signInDeveloper", "accessId", "accessSecret", "dataCenter", "signOut", "startQueue", "drafts", "enterConnect", "openOptions", "draftFromStored", "reconnectDevice", "draft", "currentDraft", "check", "draftLabel", "result", "hasSameModel", "fitExposure", "pickExposure", "skipDraft", "skipped", "saveDraft", "name", "problem", "checkName", "checkHost", "hasHost", "saved", "reloadNote", "restartNote", "removeDevice", "h", "tag", "props", "children", "element", "key", "value", "child", "button", "label", "onclick", "kind", "disabled", "h", "view", "notice", "unitStrip", "current", "currentDraft", "doing", "unit", "draft", "index", "draftLabel", "unitHeader", "text", "steps", "names", "name", "state", "statusPanel", "draft", "status", "label", "message", "h", "button", "startSignIn", "connectScreen", "currentDraft", "notice", "canRetry", "view", "isOneOfMany", "steps", "unitStrip", "unitHeader", "deviceLabel", "check", "skipDraft", "goHome", "doneScreen", "names", "view", "needsRestart", "device", "h", "restartNote", "reloadNote", "button", "goHome", "isSelectable", "device", "notesOf", "notes", "deviceRow", "isAvailable", "id", "checkbox", "h", "view", "render", "note", "findScreen", "chosen", "continueLabel", "steps", "notice", "button", "search", "goHome", "startQueue", "draftsFromDevices", "getTemperatureUnit", "values", "feature", "unit", "read", "values", "ref", "describeSensor", "feature", "value", "unit", "getTemperatureUnit", "isDetected", "describeReadings", "features", "parts", "isSingleOutlet", "outlet", "sensor", "meter", "reading", "joinList", "parts", "describeExposure", "device", "features", "main", "mainFeatureId", "isShown", "id", "outlets", "outlet", "sensors", "sensor", "settings", "setting", "meterFeatureId", "isSeveral", "routeNames", "routeLine", "h", "deviceRow", "statusText", "isConfirming", "view", "product", "readings", "describeReadings", "button", "removeDevice", "render", "startQueue", "draftFromStored", "openOptions", "reconnectDevice", "accountPanel", "account", "startSignIn", "signedIn", "dataCenterNames", "actions", "signOut", "discoveryNotice", "problem", "homeScreen", "devices", "canAdd", "search", "notice", "loadState", "sensorKindNames", "toggle", "id", "isOn", "title", "text", "onpick", "input", "h", "radio", "group", "value", "current", "placement", "draft", "label", "setShown", "list", "isShown", "without", "candidate", "nameSection", "event", "render", "cloudName", "cloudText", "featureSection", "features", "main", "mainFeatureId", "mainFeature", "feature", "items", "outlet", "measures", "name", "meterFeatureId", "sensor", "setting", "mainText", "composedSection", "isComposed", "hostFields", "host", "version", "lanVersions", "connectionSection", "pick", "probeRoute", "routeNote", "optionsScreen", "currentDraft", "notice", "readings", "describeReadings", "steps", "unitStrip", "unitHeader", "deviceLabel", "button", "goHome", "saveDraft", "import_qrcode_generator", "qrCodeElement", "text", "code", "qrcode", "h", "methodChoice", "method", "title", "text", "id", "input", "h", "view", "render", "methodSection", "userCodeForm", "submit", "userCode", "requestQrCode", "event", "button", "goHome", "qrPanel", "qrCode", "qrCodeElement", "cancelQrCode", "smartLifeForm", "login", "problem", "developerForm", "accessId", "accessSecret", "dataCenter", "dataCenterNames", "code", "signInDeveloper", "signInScreen", "isAgain", "isWaiting", "notice", "adoptHostTheme", "host", "name", "value", "setScreens", "h", "homeScreen", "signInScreen", "findScreen", "connectScreen", "optionsScreen", "doneScreen", "adoptHostTheme", "render", "loadState"]
|
|
3
|
+
"sources": ["../node_modules/qrcode-generator/qrcode.js", "../src/api.ts", "../src/state.ts", "../src/drafts.ts", "../src/render.ts", "../src/actions.ts", "../src/dom.ts", "../src/components.ts", "../src/screens/connect.ts", "../src/screens/done.ts", "../src/screens/find.ts", "../../../src/lightState.ts", "../../../src/temperatureUnit.ts", "../src/readings.ts", "../src/screens/home.ts", "../src/screens/options.ts", "../src/qr.ts", "../src/screens/signIn.ts", "../src/theme.ts", "../src/app.ts"],
|
|
4
|
+
"sourcesContent": ["//---------------------------------------------------------------------\n//\n// QR Code Generator for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n// http://www.opensource.org/licenses/mit-license.php\n//\n// The word 'QR Code' is registered trademark of\n// DENSO WAVE INCORPORATED\n// http://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n\nvar qrcode = function() {\n\n //---------------------------------------------------------------------\n // qrcode\n //---------------------------------------------------------------------\n\n /**\n * qrcode\n * @param typeNumber 1 to 40\n * @param errorCorrectionLevel 'L','M','Q','H'\n */\n var qrcode = function(typeNumber, errorCorrectionLevel) {\n\n var PAD0 = 0xEC;\n var PAD1 = 0x11;\n\n var _typeNumber = typeNumber;\n var _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];\n var _modules = null;\n var _moduleCount = 0;\n var _dataCache = null;\n var _dataList = [];\n\n var _this = {};\n\n var makeImpl = function(test, maskPattern) {\n\n _moduleCount = _typeNumber * 4 + 17;\n _modules = function(moduleCount) {\n var modules = new Array(moduleCount);\n for (var row = 0; row < moduleCount; row += 1) {\n modules[row] = new Array(moduleCount);\n for (var col = 0; col < moduleCount; col += 1) {\n modules[row][col] = null;\n }\n }\n return modules;\n }(_moduleCount);\n\n setupPositionProbePattern(0, 0);\n setupPositionProbePattern(_moduleCount - 7, 0);\n setupPositionProbePattern(0, _moduleCount - 7);\n setupPositionAdjustPattern();\n setupTimingPattern();\n setupTypeInfo(test, maskPattern);\n\n if (_typeNumber >= 7) {\n setupTypeNumber(test);\n }\n\n if (_dataCache == null) {\n _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);\n }\n\n mapData(_dataCache, maskPattern);\n };\n\n var setupPositionProbePattern = function(row, col) {\n\n for (var r = -1; r <= 7; r += 1) {\n\n if (row + r <= -1 || _moduleCount <= row + r) continue;\n\n for (var c = -1; c <= 7; c += 1) {\n\n if (col + c <= -1 || _moduleCount <= col + c) continue;\n\n if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )\n || (0 <= c && c <= 6 && (r == 0 || r == 6) )\n || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {\n _modules[row + r][col + c] = true;\n } else {\n _modules[row + r][col + c] = false;\n }\n }\n }\n };\n\n var getBestMaskPattern = function() {\n\n var minLostPoint = 0;\n var pattern = 0;\n\n for (var i = 0; i < 8; i += 1) {\n\n makeImpl(true, i);\n\n var lostPoint = QRUtil.getLostPoint(_this);\n\n if (i == 0 || minLostPoint > lostPoint) {\n minLostPoint = lostPoint;\n pattern = i;\n }\n }\n\n return pattern;\n };\n\n var setupTimingPattern = function() {\n\n for (var r = 8; r < _moduleCount - 8; r += 1) {\n if (_modules[r][6] != null) {\n continue;\n }\n _modules[r][6] = (r % 2 == 0);\n }\n\n for (var c = 8; c < _moduleCount - 8; c += 1) {\n if (_modules[6][c] != null) {\n continue;\n }\n _modules[6][c] = (c % 2 == 0);\n }\n };\n\n var setupPositionAdjustPattern = function() {\n\n var pos = QRUtil.getPatternPosition(_typeNumber);\n\n for (var i = 0; i < pos.length; i += 1) {\n\n for (var j = 0; j < pos.length; j += 1) {\n\n var row = pos[i];\n var col = pos[j];\n\n if (_modules[row][col] != null) {\n continue;\n }\n\n for (var r = -2; r <= 2; r += 1) {\n\n for (var c = -2; c <= 2; c += 1) {\n\n if (r == -2 || r == 2 || c == -2 || c == 2\n || (r == 0 && c == 0) ) {\n _modules[row + r][col + c] = true;\n } else {\n _modules[row + r][col + c] = false;\n }\n }\n }\n }\n }\n };\n\n var setupTypeNumber = function(test) {\n\n var bits = QRUtil.getBCHTypeNumber(_typeNumber);\n\n for (var i = 0; i < 18; i += 1) {\n var mod = (!test && ( (bits >> i) & 1) == 1);\n _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;\n }\n\n for (var i = 0; i < 18; i += 1) {\n var mod = (!test && ( (bits >> i) & 1) == 1);\n _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;\n }\n };\n\n var setupTypeInfo = function(test, maskPattern) {\n\n var data = (_errorCorrectionLevel << 3) | maskPattern;\n var bits = QRUtil.getBCHTypeInfo(data);\n\n // vertical\n for (var i = 0; i < 15; i += 1) {\n\n var mod = (!test && ( (bits >> i) & 1) == 1);\n\n if (i < 6) {\n _modules[i][8] = mod;\n } else if (i < 8) {\n _modules[i + 1][8] = mod;\n } else {\n _modules[_moduleCount - 15 + i][8] = mod;\n }\n }\n\n // horizontal\n for (var i = 0; i < 15; i += 1) {\n\n var mod = (!test && ( (bits >> i) & 1) == 1);\n\n if (i < 8) {\n _modules[8][_moduleCount - i - 1] = mod;\n } else if (i < 9) {\n _modules[8][15 - i - 1 + 1] = mod;\n } else {\n _modules[8][15 - i - 1] = mod;\n }\n }\n\n // fixed module\n _modules[_moduleCount - 8][8] = (!test);\n };\n\n var mapData = function(data, maskPattern) {\n\n var inc = -1;\n var row = _moduleCount - 1;\n var bitIndex = 7;\n var byteIndex = 0;\n var maskFunc = QRUtil.getMaskFunction(maskPattern);\n\n for (var col = _moduleCount - 1; col > 0; col -= 2) {\n\n if (col == 6) col -= 1;\n\n while (true) {\n\n for (var c = 0; c < 2; c += 1) {\n\n if (_modules[row][col - c] == null) {\n\n var dark = false;\n\n if (byteIndex < data.length) {\n dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);\n }\n\n var mask = maskFunc(row, col - c);\n\n if (mask) {\n dark = !dark;\n }\n\n _modules[row][col - c] = dark;\n bitIndex -= 1;\n\n if (bitIndex == -1) {\n byteIndex += 1;\n bitIndex = 7;\n }\n }\n }\n\n row += inc;\n\n if (row < 0 || _moduleCount <= row) {\n row -= inc;\n inc = -inc;\n break;\n }\n }\n }\n };\n\n var createBytes = function(buffer, rsBlocks) {\n\n var offset = 0;\n\n var maxDcCount = 0;\n var maxEcCount = 0;\n\n var dcdata = new Array(rsBlocks.length);\n var ecdata = new Array(rsBlocks.length);\n\n for (var r = 0; r < rsBlocks.length; r += 1) {\n\n var dcCount = rsBlocks[r].dataCount;\n var ecCount = rsBlocks[r].totalCount - dcCount;\n\n maxDcCount = Math.max(maxDcCount, dcCount);\n maxEcCount = Math.max(maxEcCount, ecCount);\n\n dcdata[r] = new Array(dcCount);\n\n for (var i = 0; i < dcdata[r].length; i += 1) {\n dcdata[r][i] = 0xff & buffer.getBuffer()[i + offset];\n }\n offset += dcCount;\n\n var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);\n var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);\n\n var modPoly = rawPoly.mod(rsPoly);\n ecdata[r] = new Array(rsPoly.getLength() - 1);\n for (var i = 0; i < ecdata[r].length; i += 1) {\n var modIndex = i + modPoly.getLength() - ecdata[r].length;\n ecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;\n }\n }\n\n var totalCodeCount = 0;\n for (var i = 0; i < rsBlocks.length; i += 1) {\n totalCodeCount += rsBlocks[i].totalCount;\n }\n\n var data = new Array(totalCodeCount);\n var index = 0;\n\n for (var i = 0; i < maxDcCount; i += 1) {\n for (var r = 0; r < rsBlocks.length; r += 1) {\n if (i < dcdata[r].length) {\n data[index] = dcdata[r][i];\n index += 1;\n }\n }\n }\n\n for (var i = 0; i < maxEcCount; i += 1) {\n for (var r = 0; r < rsBlocks.length; r += 1) {\n if (i < ecdata[r].length) {\n data[index] = ecdata[r][i];\n index += 1;\n }\n }\n }\n\n return data;\n };\n\n var createData = function(typeNumber, errorCorrectionLevel, dataList) {\n\n var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectionLevel);\n\n var buffer = qrBitBuffer();\n\n for (var i = 0; i < dataList.length; i += 1) {\n var data = dataList[i];\n buffer.put(data.getMode(), 4);\n buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );\n data.write(buffer);\n }\n\n // calc num max data.\n var totalDataCount = 0;\n for (var i = 0; i < rsBlocks.length; i += 1) {\n totalDataCount += rsBlocks[i].dataCount;\n }\n\n if (buffer.getLengthInBits() > totalDataCount * 8) {\n throw 'code length overflow. ('\n + buffer.getLengthInBits()\n + '>'\n + totalDataCount * 8\n + ')';\n }\n\n // end code\n if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {\n buffer.put(0, 4);\n }\n\n // padding\n while (buffer.getLengthInBits() % 8 != 0) {\n buffer.putBit(false);\n }\n\n // padding\n while (true) {\n\n if (buffer.getLengthInBits() >= totalDataCount * 8) {\n break;\n }\n buffer.put(PAD0, 8);\n\n if (buffer.getLengthInBits() >= totalDataCount * 8) {\n break;\n }\n buffer.put(PAD1, 8);\n }\n\n return createBytes(buffer, rsBlocks);\n };\n\n _this.addData = function(data, mode) {\n\n mode = mode || 'Byte';\n\n var newData = null;\n\n switch(mode) {\n case 'Numeric' :\n newData = qrNumber(data);\n break;\n case 'Alphanumeric' :\n newData = qrAlphaNum(data);\n break;\n case 'Byte' :\n newData = qr8BitByte(data);\n break;\n case 'Kanji' :\n newData = qrKanji(data);\n break;\n default :\n throw 'mode:' + mode;\n }\n\n _dataList.push(newData);\n _dataCache = null;\n };\n\n _this.isDark = function(row, col) {\n if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {\n throw row + ',' + col;\n }\n return _modules[row][col];\n };\n\n _this.getModuleCount = function() {\n return _moduleCount;\n };\n\n _this.make = function() {\n if (_typeNumber < 1) {\n var typeNumber = 1;\n\n for (; typeNumber < 40; typeNumber++) {\n var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, _errorCorrectionLevel);\n var buffer = qrBitBuffer();\n\n for (var i = 0; i < _dataList.length; i++) {\n var data = _dataList[i];\n buffer.put(data.getMode(), 4);\n buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );\n data.write(buffer);\n }\n\n var totalDataCount = 0;\n for (var i = 0; i < rsBlocks.length; i++) {\n totalDataCount += rsBlocks[i].dataCount;\n }\n\n if (buffer.getLengthInBits() <= totalDataCount * 8) {\n break;\n }\n }\n\n _typeNumber = typeNumber;\n }\n\n makeImpl(false, getBestMaskPattern() );\n };\n\n _this.createTableTag = function(cellSize, margin) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var qrHtml = '';\n\n qrHtml += '<table style=\"';\n qrHtml += ' border-width: 0px; border-style: none;';\n qrHtml += ' border-collapse: collapse;';\n qrHtml += ' padding: 0px; margin: ' + margin + 'px;';\n qrHtml += '\">';\n qrHtml += '<tbody>';\n\n for (var r = 0; r < _this.getModuleCount(); r += 1) {\n\n qrHtml += '<tr>';\n\n for (var c = 0; c < _this.getModuleCount(); c += 1) {\n qrHtml += '<td style=\"';\n qrHtml += ' border-width: 0px; border-style: none;';\n qrHtml += ' border-collapse: collapse;';\n qrHtml += ' padding: 0px; margin: 0px;';\n qrHtml += ' width: ' + cellSize + 'px;';\n qrHtml += ' height: ' + cellSize + 'px;';\n qrHtml += ' background-color: ';\n qrHtml += _this.isDark(r, c)? '#000000' : '#ffffff';\n qrHtml += ';';\n qrHtml += '\"/>';\n }\n\n qrHtml += '</tr>';\n }\n\n qrHtml += '</tbody>';\n qrHtml += '</table>';\n\n return qrHtml;\n };\n\n _this.createSvgTag = function(cellSize, margin, alt, title) {\n\n var opts = {};\n if (typeof arguments[0] == 'object') {\n // Called by options.\n opts = arguments[0];\n // overwrite cellSize and margin.\n cellSize = opts.cellSize;\n margin = opts.margin;\n alt = opts.alt;\n title = opts.title;\n }\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n // Compose alt property surrogate\n alt = (typeof alt === 'string') ? {text: alt} : alt || {};\n alt.text = alt.text || null;\n alt.id = (alt.text) ? alt.id || 'qrcode-description' : null;\n\n // Compose title property surrogate\n title = (typeof title === 'string') ? {text: title} : title || {};\n title.text = title.text || null;\n title.id = (title.text) ? title.id || 'qrcode-title' : null;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var c, mc, r, mr, qrSvg='', rect;\n\n rect = 'l' + cellSize + ',0 0,' + cellSize +\n ' -' + cellSize + ',0 0,-' + cellSize + 'z ';\n\n qrSvg += '<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"';\n qrSvg += !opts.scalable ? ' width=\"' + size + 'px\" height=\"' + size + 'px\"' : '';\n qrSvg += ' viewBox=\"0 0 ' + size + ' ' + size + '\" ';\n qrSvg += ' preserveAspectRatio=\"xMinYMin meet\"';\n qrSvg += (title.text || alt.text) ? ' role=\"img\" aria-labelledby=\"' +\n escapeXml([title.id, alt.id].join(' ').trim() ) + '\"' : '';\n qrSvg += '>';\n qrSvg += (title.text) ? '<title id=\"' + escapeXml(title.id) + '\">' +\n escapeXml(title.text) + '</title>' : '';\n qrSvg += (alt.text) ? '<description id=\"' + escapeXml(alt.id) + '\">' +\n escapeXml(alt.text) + '</description>' : '';\n qrSvg += '<rect width=\"100%\" height=\"100%\" fill=\"white\" cx=\"0\" cy=\"0\"/>';\n qrSvg += '<path d=\"';\n\n for (r = 0; r < _this.getModuleCount(); r += 1) {\n mr = r * cellSize + margin;\n for (c = 0; c < _this.getModuleCount(); c += 1) {\n if (_this.isDark(r, c) ) {\n mc = c*cellSize+margin;\n qrSvg += 'M' + mc + ',' + mr + rect;\n }\n }\n }\n\n qrSvg += '\" stroke=\"transparent\" fill=\"black\"/>';\n qrSvg += '</svg>';\n\n return qrSvg;\n };\n\n _this.createDataURL = function(cellSize, margin) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n return createDataURL(size, size, function(x, y) {\n if (min <= x && x < max && min <= y && y < max) {\n var c = Math.floor( (x - min) / cellSize);\n var r = Math.floor( (y - min) / cellSize);\n return _this.isDark(r, c)? 0 : 1;\n } else {\n return 1;\n }\n } );\n };\n\n _this.createImgTag = function(cellSize, margin, alt) {\n\n cellSize = cellSize || 2;\n margin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n\n var img = '';\n img += '<img';\n img += '\\u0020src=\"';\n img += _this.createDataURL(cellSize, margin);\n img += '\"';\n img += '\\u0020width=\"';\n img += size;\n img += '\"';\n img += '\\u0020height=\"';\n img += size;\n img += '\"';\n if (alt) {\n img += '\\u0020alt=\"';\n img += escapeXml(alt);\n img += '\"';\n }\n img += '/>';\n\n return img;\n };\n\n var escapeXml = function(s) {\n var escaped = '';\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charAt(i);\n switch(c) {\n case '<': escaped += '<'; break;\n case '>': escaped += '>'; break;\n case '&': escaped += '&'; break;\n case '\"': escaped += '"'; break;\n default : escaped += c; break;\n }\n }\n return escaped;\n };\n\n var _createHalfASCII = function(margin) {\n var cellSize = 1;\n margin = (typeof margin == 'undefined')? cellSize * 2 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n var y, x, r1, r2, p;\n\n var blocks = {\n '\u2588\u2588': '\u2588',\n '\u2588 ': '\u2580',\n ' \u2588': '\u2584',\n ' ': ' '\n };\n\n var blocksLastLineNoMargin = {\n '\u2588\u2588': '\u2580',\n '\u2588 ': '\u2580',\n ' \u2588': ' ',\n ' ': ' '\n };\n\n var ascii = '';\n for (y = 0; y < size; y += 2) {\n r1 = Math.floor((y - min) / cellSize);\n r2 = Math.floor((y + 1 - min) / cellSize);\n for (x = 0; x < size; x += 1) {\n p = '\u2588';\n\n if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {\n p = ' ';\n }\n\n if (min <= x && x < max && min <= y+1 && y+1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {\n p += ' ';\n }\n else {\n p += '\u2588';\n }\n\n // Output 2 characters per pixel, to create full square. 1 character per pixels gives only half width of square.\n ascii += (margin < 1 && y+1 >= max) ? blocksLastLineNoMargin[p] : blocks[p];\n }\n\n ascii += '\\n';\n }\n\n if (size % 2 && margin > 0) {\n return ascii.substring(0, ascii.length - size - 1) + Array(size+1).join('\u2580');\n }\n\n return ascii.substring(0, ascii.length-1);\n };\n\n _this.createASCII = function(cellSize, margin) {\n cellSize = cellSize || 1;\n\n if (cellSize < 2) {\n return _createHalfASCII(margin);\n }\n\n cellSize -= 1;\n margin = (typeof margin == 'undefined')? cellSize * 2 : margin;\n\n var size = _this.getModuleCount() * cellSize + margin * 2;\n var min = margin;\n var max = size - margin;\n\n var y, x, r, p;\n\n var white = Array(cellSize+1).join('\u2588\u2588');\n var black = Array(cellSize+1).join(' ');\n\n var ascii = '';\n var line = '';\n for (y = 0; y < size; y += 1) {\n r = Math.floor( (y - min) / cellSize);\n line = '';\n for (x = 0; x < size; x += 1) {\n p = 1;\n\n if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {\n p = 0;\n }\n\n // Output 2 characters per pixel, to create full square. 1 character per pixels gives only half width of square.\n line += p ? white : black;\n }\n\n for (r = 0; r < cellSize; r += 1) {\n ascii += line + '\\n';\n }\n }\n\n return ascii.substring(0, ascii.length-1);\n };\n\n _this.renderTo2dContext = function(context, cellSize) {\n cellSize = cellSize || 2;\n var length = _this.getModuleCount();\n for (var row = 0; row < length; row++) {\n for (var col = 0; col < length; col++) {\n context.fillStyle = _this.isDark(row, col) ? 'black' : 'white';\n context.fillRect(row * cellSize, col * cellSize, cellSize, cellSize);\n }\n }\n }\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrcode.stringToBytes\n //---------------------------------------------------------------------\n\n qrcode.stringToBytesFuncs = {\n 'default' : function(s) {\n var bytes = [];\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charCodeAt(i);\n bytes.push(c & 0xff);\n }\n return bytes;\n }\n };\n\n qrcode.stringToBytes = qrcode.stringToBytesFuncs['default'];\n\n //---------------------------------------------------------------------\n // qrcode.createStringToBytes\n //---------------------------------------------------------------------\n\n /**\n * @param unicodeData base64 string of byte array.\n * [16bit Unicode],[16bit Bytes], ...\n * @param numChars\n */\n qrcode.createStringToBytes = function(unicodeData, numChars) {\n\n // create conversion map.\n\n var unicodeMap = function() {\n\n var bin = base64DecodeInputStream(unicodeData);\n var read = function() {\n var b = bin.read();\n if (b == -1) throw 'eof';\n return b;\n };\n\n var count = 0;\n var unicodeMap = {};\n while (true) {\n var b0 = bin.read();\n if (b0 == -1) break;\n var b1 = read();\n var b2 = read();\n var b3 = read();\n var k = String.fromCharCode( (b0 << 8) | b1);\n var v = (b2 << 8) | b3;\n unicodeMap[k] = v;\n count += 1;\n }\n if (count != numChars) {\n throw count + ' != ' + numChars;\n }\n\n return unicodeMap;\n }();\n\n var unknownChar = '?'.charCodeAt(0);\n\n return function(s) {\n var bytes = [];\n for (var i = 0; i < s.length; i += 1) {\n var c = s.charCodeAt(i);\n if (c < 128) {\n bytes.push(c);\n } else {\n var b = unicodeMap[s.charAt(i)];\n if (typeof b == 'number') {\n if ( (b & 0xff) == b) {\n // 1byte\n bytes.push(b);\n } else {\n // 2bytes\n bytes.push(b >>> 8);\n bytes.push(b & 0xff);\n }\n } else {\n bytes.push(unknownChar);\n }\n }\n }\n return bytes;\n };\n };\n\n //---------------------------------------------------------------------\n // QRMode\n //---------------------------------------------------------------------\n\n var QRMode = {\n MODE_NUMBER : 1 << 0,\n MODE_ALPHA_NUM : 1 << 1,\n MODE_8BIT_BYTE : 1 << 2,\n MODE_KANJI : 1 << 3\n };\n\n //---------------------------------------------------------------------\n // QRErrorCorrectionLevel\n //---------------------------------------------------------------------\n\n var QRErrorCorrectionLevel = {\n L : 1,\n M : 0,\n Q : 3,\n H : 2\n };\n\n //---------------------------------------------------------------------\n // QRMaskPattern\n //---------------------------------------------------------------------\n\n var QRMaskPattern = {\n PATTERN000 : 0,\n PATTERN001 : 1,\n PATTERN010 : 2,\n PATTERN011 : 3,\n PATTERN100 : 4,\n PATTERN101 : 5,\n PATTERN110 : 6,\n PATTERN111 : 7\n };\n\n //---------------------------------------------------------------------\n // QRUtil\n //---------------------------------------------------------------------\n\n var QRUtil = function() {\n\n var PATTERN_POSITION_TABLE = [\n [],\n [6, 18],\n [6, 22],\n [6, 26],\n [6, 30],\n [6, 34],\n [6, 22, 38],\n [6, 24, 42],\n [6, 26, 46],\n [6, 28, 50],\n [6, 30, 54],\n [6, 32, 58],\n [6, 34, 62],\n [6, 26, 46, 66],\n [6, 26, 48, 70],\n [6, 26, 50, 74],\n [6, 30, 54, 78],\n [6, 30, 56, 82],\n [6, 30, 58, 86],\n [6, 34, 62, 90],\n [6, 28, 50, 72, 94],\n [6, 26, 50, 74, 98],\n [6, 30, 54, 78, 102],\n [6, 28, 54, 80, 106],\n [6, 32, 58, 84, 110],\n [6, 30, 58, 86, 114],\n [6, 34, 62, 90, 118],\n [6, 26, 50, 74, 98, 122],\n [6, 30, 54, 78, 102, 126],\n [6, 26, 52, 78, 104, 130],\n [6, 30, 56, 82, 108, 134],\n [6, 34, 60, 86, 112, 138],\n [6, 30, 58, 86, 114, 142],\n [6, 34, 62, 90, 118, 146],\n [6, 30, 54, 78, 102, 126, 150],\n [6, 24, 50, 76, 102, 128, 154],\n [6, 28, 54, 80, 106, 132, 158],\n [6, 32, 58, 84, 110, 136, 162],\n [6, 26, 54, 82, 110, 138, 166],\n [6, 30, 58, 86, 114, 142, 170]\n ];\n var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);\n var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);\n var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);\n\n var _this = {};\n\n var getBCHDigit = function(data) {\n var digit = 0;\n while (data != 0) {\n digit += 1;\n data >>>= 1;\n }\n return digit;\n };\n\n _this.getBCHTypeInfo = function(data) {\n var d = data << 10;\n while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {\n d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) );\n }\n return ( (data << 10) | d) ^ G15_MASK;\n };\n\n _this.getBCHTypeNumber = function(data) {\n var d = data << 12;\n while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {\n d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) );\n }\n return (data << 12) | d;\n };\n\n _this.getPatternPosition = function(typeNumber) {\n return PATTERN_POSITION_TABLE[typeNumber - 1];\n };\n\n _this.getMaskFunction = function(maskPattern) {\n\n switch (maskPattern) {\n\n case QRMaskPattern.PATTERN000 :\n return function(i, j) { return (i + j) % 2 == 0; };\n case QRMaskPattern.PATTERN001 :\n return function(i, j) { return i % 2 == 0; };\n case QRMaskPattern.PATTERN010 :\n return function(i, j) { return j % 3 == 0; };\n case QRMaskPattern.PATTERN011 :\n return function(i, j) { return (i + j) % 3 == 0; };\n case QRMaskPattern.PATTERN100 :\n return function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; };\n case QRMaskPattern.PATTERN101 :\n return function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; };\n case QRMaskPattern.PATTERN110 :\n return function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; };\n case QRMaskPattern.PATTERN111 :\n return function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; };\n\n default :\n throw 'bad maskPattern:' + maskPattern;\n }\n };\n\n _this.getErrorCorrectPolynomial = function(errorCorrectLength) {\n var a = qrPolynomial([1], 0);\n for (var i = 0; i < errorCorrectLength; i += 1) {\n a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) );\n }\n return a;\n };\n\n _this.getLengthInBits = function(mode, type) {\n\n if (1 <= type && type < 10) {\n\n // 1 - 9\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 10;\n case QRMode.MODE_ALPHA_NUM : return 9;\n case QRMode.MODE_8BIT_BYTE : return 8;\n case QRMode.MODE_KANJI : return 8;\n default :\n throw 'mode:' + mode;\n }\n\n } else if (type < 27) {\n\n // 10 - 26\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 12;\n case QRMode.MODE_ALPHA_NUM : return 11;\n case QRMode.MODE_8BIT_BYTE : return 16;\n case QRMode.MODE_KANJI : return 10;\n default :\n throw 'mode:' + mode;\n }\n\n } else if (type < 41) {\n\n // 27 - 40\n\n switch(mode) {\n case QRMode.MODE_NUMBER : return 14;\n case QRMode.MODE_ALPHA_NUM : return 13;\n case QRMode.MODE_8BIT_BYTE : return 16;\n case QRMode.MODE_KANJI : return 12;\n default :\n throw 'mode:' + mode;\n }\n\n } else {\n throw 'type:' + type;\n }\n };\n\n _this.getLostPoint = function(qrcode) {\n\n var moduleCount = qrcode.getModuleCount();\n\n var lostPoint = 0;\n\n // LEVEL1\n\n for (var row = 0; row < moduleCount; row += 1) {\n for (var col = 0; col < moduleCount; col += 1) {\n\n var sameCount = 0;\n var dark = qrcode.isDark(row, col);\n\n for (var r = -1; r <= 1; r += 1) {\n\n if (row + r < 0 || moduleCount <= row + r) {\n continue;\n }\n\n for (var c = -1; c <= 1; c += 1) {\n\n if (col + c < 0 || moduleCount <= col + c) {\n continue;\n }\n\n if (r == 0 && c == 0) {\n continue;\n }\n\n if (dark == qrcode.isDark(row + r, col + c) ) {\n sameCount += 1;\n }\n }\n }\n\n if (sameCount > 5) {\n lostPoint += (3 + sameCount - 5);\n }\n }\n };\n\n // LEVEL2\n\n for (var row = 0; row < moduleCount - 1; row += 1) {\n for (var col = 0; col < moduleCount - 1; col += 1) {\n var count = 0;\n if (qrcode.isDark(row, col) ) count += 1;\n if (qrcode.isDark(row + 1, col) ) count += 1;\n if (qrcode.isDark(row, col + 1) ) count += 1;\n if (qrcode.isDark(row + 1, col + 1) ) count += 1;\n if (count == 0 || count == 4) {\n lostPoint += 3;\n }\n }\n }\n\n // LEVEL3\n\n for (var row = 0; row < moduleCount; row += 1) {\n for (var col = 0; col < moduleCount - 6; col += 1) {\n if (qrcode.isDark(row, col)\n && !qrcode.isDark(row, col + 1)\n && qrcode.isDark(row, col + 2)\n && qrcode.isDark(row, col + 3)\n && qrcode.isDark(row, col + 4)\n && !qrcode.isDark(row, col + 5)\n && qrcode.isDark(row, col + 6) ) {\n lostPoint += 40;\n }\n }\n }\n\n for (var col = 0; col < moduleCount; col += 1) {\n for (var row = 0; row < moduleCount - 6; row += 1) {\n if (qrcode.isDark(row, col)\n && !qrcode.isDark(row + 1, col)\n && qrcode.isDark(row + 2, col)\n && qrcode.isDark(row + 3, col)\n && qrcode.isDark(row + 4, col)\n && !qrcode.isDark(row + 5, col)\n && qrcode.isDark(row + 6, col) ) {\n lostPoint += 40;\n }\n }\n }\n\n // LEVEL4\n\n var darkCount = 0;\n\n for (var col = 0; col < moduleCount; col += 1) {\n for (var row = 0; row < moduleCount; row += 1) {\n if (qrcode.isDark(row, col) ) {\n darkCount += 1;\n }\n }\n }\n\n var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;\n lostPoint += ratio * 10;\n\n return lostPoint;\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // QRMath\n //---------------------------------------------------------------------\n\n var QRMath = function() {\n\n var EXP_TABLE = new Array(256);\n var LOG_TABLE = new Array(256);\n\n // initialize tables\n for (var i = 0; i < 8; i += 1) {\n EXP_TABLE[i] = 1 << i;\n }\n for (var i = 8; i < 256; i += 1) {\n EXP_TABLE[i] = EXP_TABLE[i - 4]\n ^ EXP_TABLE[i - 5]\n ^ EXP_TABLE[i - 6]\n ^ EXP_TABLE[i - 8];\n }\n for (var i = 0; i < 255; i += 1) {\n LOG_TABLE[EXP_TABLE[i] ] = i;\n }\n\n var _this = {};\n\n _this.glog = function(n) {\n\n if (n < 1) {\n throw 'glog(' + n + ')';\n }\n\n return LOG_TABLE[n];\n };\n\n _this.gexp = function(n) {\n\n while (n < 0) {\n n += 255;\n }\n\n while (n >= 256) {\n n -= 255;\n }\n\n return EXP_TABLE[n];\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // qrPolynomial\n //---------------------------------------------------------------------\n\n function qrPolynomial(num, shift) {\n\n if (typeof num.length == 'undefined') {\n throw num.length + '/' + shift;\n }\n\n var _num = function() {\n var offset = 0;\n while (offset < num.length && num[offset] == 0) {\n offset += 1;\n }\n var _num = new Array(num.length - offset + shift);\n for (var i = 0; i < num.length - offset; i += 1) {\n _num[i] = num[i + offset];\n }\n return _num;\n }();\n\n var _this = {};\n\n _this.getAt = function(index) {\n return _num[index];\n };\n\n _this.getLength = function() {\n return _num.length;\n };\n\n _this.multiply = function(e) {\n\n var num = new Array(_this.getLength() + e.getLength() - 1);\n\n for (var i = 0; i < _this.getLength(); i += 1) {\n for (var j = 0; j < e.getLength(); j += 1) {\n num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );\n }\n }\n\n return qrPolynomial(num, 0);\n };\n\n _this.mod = function(e) {\n\n if (_this.getLength() - e.getLength() < 0) {\n return _this;\n }\n\n var ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );\n\n var num = new Array(_this.getLength() );\n for (var i = 0; i < _this.getLength(); i += 1) {\n num[i] = _this.getAt(i);\n }\n\n for (var i = 0; i < e.getLength(); i += 1) {\n num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);\n }\n\n // recursive call\n return qrPolynomial(num, 0).mod(e);\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // QRRSBlock\n //---------------------------------------------------------------------\n\n var QRRSBlock = function() {\n\n var RS_BLOCK_TABLE = [\n\n // L\n // M\n // Q\n // H\n\n // 1\n [1, 26, 19],\n [1, 26, 16],\n [1, 26, 13],\n [1, 26, 9],\n\n // 2\n [1, 44, 34],\n [1, 44, 28],\n [1, 44, 22],\n [1, 44, 16],\n\n // 3\n [1, 70, 55],\n [1, 70, 44],\n [2, 35, 17],\n [2, 35, 13],\n\n // 4\n [1, 100, 80],\n [2, 50, 32],\n [2, 50, 24],\n [4, 25, 9],\n\n // 5\n [1, 134, 108],\n [2, 67, 43],\n [2, 33, 15, 2, 34, 16],\n [2, 33, 11, 2, 34, 12],\n\n // 6\n [2, 86, 68],\n [4, 43, 27],\n [4, 43, 19],\n [4, 43, 15],\n\n // 7\n [2, 98, 78],\n [4, 49, 31],\n [2, 32, 14, 4, 33, 15],\n [4, 39, 13, 1, 40, 14],\n\n // 8\n [2, 121, 97],\n [2, 60, 38, 2, 61, 39],\n [4, 40, 18, 2, 41, 19],\n [4, 40, 14, 2, 41, 15],\n\n // 9\n [2, 146, 116],\n [3, 58, 36, 2, 59, 37],\n [4, 36, 16, 4, 37, 17],\n [4, 36, 12, 4, 37, 13],\n\n // 10\n [2, 86, 68, 2, 87, 69],\n [4, 69, 43, 1, 70, 44],\n [6, 43, 19, 2, 44, 20],\n [6, 43, 15, 2, 44, 16],\n\n // 11\n [4, 101, 81],\n [1, 80, 50, 4, 81, 51],\n [4, 50, 22, 4, 51, 23],\n [3, 36, 12, 8, 37, 13],\n\n // 12\n [2, 116, 92, 2, 117, 93],\n [6, 58, 36, 2, 59, 37],\n [4, 46, 20, 6, 47, 21],\n [7, 42, 14, 4, 43, 15],\n\n // 13\n [4, 133, 107],\n [8, 59, 37, 1, 60, 38],\n [8, 44, 20, 4, 45, 21],\n [12, 33, 11, 4, 34, 12],\n\n // 14\n [3, 145, 115, 1, 146, 116],\n [4, 64, 40, 5, 65, 41],\n [11, 36, 16, 5, 37, 17],\n [11, 36, 12, 5, 37, 13],\n\n // 15\n [5, 109, 87, 1, 110, 88],\n [5, 65, 41, 5, 66, 42],\n [5, 54, 24, 7, 55, 25],\n [11, 36, 12, 7, 37, 13],\n\n // 16\n [5, 122, 98, 1, 123, 99],\n [7, 73, 45, 3, 74, 46],\n [15, 43, 19, 2, 44, 20],\n [3, 45, 15, 13, 46, 16],\n\n // 17\n [1, 135, 107, 5, 136, 108],\n [10, 74, 46, 1, 75, 47],\n [1, 50, 22, 15, 51, 23],\n [2, 42, 14, 17, 43, 15],\n\n // 18\n [5, 150, 120, 1, 151, 121],\n [9, 69, 43, 4, 70, 44],\n [17, 50, 22, 1, 51, 23],\n [2, 42, 14, 19, 43, 15],\n\n // 19\n [3, 141, 113, 4, 142, 114],\n [3, 70, 44, 11, 71, 45],\n [17, 47, 21, 4, 48, 22],\n [9, 39, 13, 16, 40, 14],\n\n // 20\n [3, 135, 107, 5, 136, 108],\n [3, 67, 41, 13, 68, 42],\n [15, 54, 24, 5, 55, 25],\n [15, 43, 15, 10, 44, 16],\n\n // 21\n [4, 144, 116, 4, 145, 117],\n [17, 68, 42],\n [17, 50, 22, 6, 51, 23],\n [19, 46, 16, 6, 47, 17],\n\n // 22\n [2, 139, 111, 7, 140, 112],\n [17, 74, 46],\n [7, 54, 24, 16, 55, 25],\n [34, 37, 13],\n\n // 23\n [4, 151, 121, 5, 152, 122],\n [4, 75, 47, 14, 76, 48],\n [11, 54, 24, 14, 55, 25],\n [16, 45, 15, 14, 46, 16],\n\n // 24\n [6, 147, 117, 4, 148, 118],\n [6, 73, 45, 14, 74, 46],\n [11, 54, 24, 16, 55, 25],\n [30, 46, 16, 2, 47, 17],\n\n // 25\n [8, 132, 106, 4, 133, 107],\n [8, 75, 47, 13, 76, 48],\n [7, 54, 24, 22, 55, 25],\n [22, 45, 15, 13, 46, 16],\n\n // 26\n [10, 142, 114, 2, 143, 115],\n [19, 74, 46, 4, 75, 47],\n [28, 50, 22, 6, 51, 23],\n [33, 46, 16, 4, 47, 17],\n\n // 27\n [8, 152, 122, 4, 153, 123],\n [22, 73, 45, 3, 74, 46],\n [8, 53, 23, 26, 54, 24],\n [12, 45, 15, 28, 46, 16],\n\n // 28\n [3, 147, 117, 10, 148, 118],\n [3, 73, 45, 23, 74, 46],\n [4, 54, 24, 31, 55, 25],\n [11, 45, 15, 31, 46, 16],\n\n // 29\n [7, 146, 116, 7, 147, 117],\n [21, 73, 45, 7, 74, 46],\n [1, 53, 23, 37, 54, 24],\n [19, 45, 15, 26, 46, 16],\n\n // 30\n [5, 145, 115, 10, 146, 116],\n [19, 75, 47, 10, 76, 48],\n [15, 54, 24, 25, 55, 25],\n [23, 45, 15, 25, 46, 16],\n\n // 31\n [13, 145, 115, 3, 146, 116],\n [2, 74, 46, 29, 75, 47],\n [42, 54, 24, 1, 55, 25],\n [23, 45, 15, 28, 46, 16],\n\n // 32\n [17, 145, 115],\n [10, 74, 46, 23, 75, 47],\n [10, 54, 24, 35, 55, 25],\n [19, 45, 15, 35, 46, 16],\n\n // 33\n [17, 145, 115, 1, 146, 116],\n [14, 74, 46, 21, 75, 47],\n [29, 54, 24, 19, 55, 25],\n [11, 45, 15, 46, 46, 16],\n\n // 34\n [13, 145, 115, 6, 146, 116],\n [14, 74, 46, 23, 75, 47],\n [44, 54, 24, 7, 55, 25],\n [59, 46, 16, 1, 47, 17],\n\n // 35\n [12, 151, 121, 7, 152, 122],\n [12, 75, 47, 26, 76, 48],\n [39, 54, 24, 14, 55, 25],\n [22, 45, 15, 41, 46, 16],\n\n // 36\n [6, 151, 121, 14, 152, 122],\n [6, 75, 47, 34, 76, 48],\n [46, 54, 24, 10, 55, 25],\n [2, 45, 15, 64, 46, 16],\n\n // 37\n [17, 152, 122, 4, 153, 123],\n [29, 74, 46, 14, 75, 47],\n [49, 54, 24, 10, 55, 25],\n [24, 45, 15, 46, 46, 16],\n\n // 38\n [4, 152, 122, 18, 153, 123],\n [13, 74, 46, 32, 75, 47],\n [48, 54, 24, 14, 55, 25],\n [42, 45, 15, 32, 46, 16],\n\n // 39\n [20, 147, 117, 4, 148, 118],\n [40, 75, 47, 7, 76, 48],\n [43, 54, 24, 22, 55, 25],\n [10, 45, 15, 67, 46, 16],\n\n // 40\n [19, 148, 118, 6, 149, 119],\n [18, 75, 47, 31, 76, 48],\n [34, 54, 24, 34, 55, 25],\n [20, 45, 15, 61, 46, 16]\n ];\n\n var qrRSBlock = function(totalCount, dataCount) {\n var _this = {};\n _this.totalCount = totalCount;\n _this.dataCount = dataCount;\n return _this;\n };\n\n var _this = {};\n\n var getRsBlockTable = function(typeNumber, errorCorrectionLevel) {\n\n switch(errorCorrectionLevel) {\n case QRErrorCorrectionLevel.L :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];\n case QRErrorCorrectionLevel.M :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];\n case QRErrorCorrectionLevel.Q :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];\n case QRErrorCorrectionLevel.H :\n return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];\n default :\n return undefined;\n }\n };\n\n _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {\n\n var rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);\n\n if (typeof rsBlock == 'undefined') {\n throw 'bad rs block @ typeNumber:' + typeNumber +\n '/errorCorrectionLevel:' + errorCorrectionLevel;\n }\n\n var length = rsBlock.length / 3;\n\n var list = [];\n\n for (var i = 0; i < length; i += 1) {\n\n var count = rsBlock[i * 3 + 0];\n var totalCount = rsBlock[i * 3 + 1];\n var dataCount = rsBlock[i * 3 + 2];\n\n for (var j = 0; j < count; j += 1) {\n list.push(qrRSBlock(totalCount, dataCount) );\n }\n }\n\n return list;\n };\n\n return _this;\n }();\n\n //---------------------------------------------------------------------\n // qrBitBuffer\n //---------------------------------------------------------------------\n\n var qrBitBuffer = function() {\n\n var _buffer = [];\n var _length = 0;\n\n var _this = {};\n\n _this.getBuffer = function() {\n return _buffer;\n };\n\n _this.getAt = function(index) {\n var bufIndex = Math.floor(index / 8);\n return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;\n };\n\n _this.put = function(num, length) {\n for (var i = 0; i < length; i += 1) {\n _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);\n }\n };\n\n _this.getLengthInBits = function() {\n return _length;\n };\n\n _this.putBit = function(bit) {\n\n var bufIndex = Math.floor(_length / 8);\n if (_buffer.length <= bufIndex) {\n _buffer.push(0);\n }\n\n if (bit) {\n _buffer[bufIndex] |= (0x80 >>> (_length % 8) );\n }\n\n _length += 1;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrNumber\n //---------------------------------------------------------------------\n\n var qrNumber = function(data) {\n\n var _mode = QRMode.MODE_NUMBER;\n var _data = data;\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _data.length;\n };\n\n _this.write = function(buffer) {\n\n var data = _data;\n\n var i = 0;\n\n while (i + 2 < data.length) {\n buffer.put(strToNum(data.substring(i, i + 3) ), 10);\n i += 3;\n }\n\n if (i < data.length) {\n if (data.length - i == 1) {\n buffer.put(strToNum(data.substring(i, i + 1) ), 4);\n } else if (data.length - i == 2) {\n buffer.put(strToNum(data.substring(i, i + 2) ), 7);\n }\n }\n };\n\n var strToNum = function(s) {\n var num = 0;\n for (var i = 0; i < s.length; i += 1) {\n num = num * 10 + chatToNum(s.charAt(i) );\n }\n return num;\n };\n\n var chatToNum = function(c) {\n if ('0' <= c && c <= '9') {\n return c.charCodeAt(0) - '0'.charCodeAt(0);\n }\n throw 'illegal char :' + c;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrAlphaNum\n //---------------------------------------------------------------------\n\n var qrAlphaNum = function(data) {\n\n var _mode = QRMode.MODE_ALPHA_NUM;\n var _data = data;\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _data.length;\n };\n\n _this.write = function(buffer) {\n\n var s = _data;\n\n var i = 0;\n\n while (i + 1 < s.length) {\n buffer.put(\n getCode(s.charAt(i) ) * 45 +\n getCode(s.charAt(i + 1) ), 11);\n i += 2;\n }\n\n if (i < s.length) {\n buffer.put(getCode(s.charAt(i) ), 6);\n }\n };\n\n var getCode = function(c) {\n\n if ('0' <= c && c <= '9') {\n return c.charCodeAt(0) - '0'.charCodeAt(0);\n } else if ('A' <= c && c <= 'Z') {\n return c.charCodeAt(0) - 'A'.charCodeAt(0) + 10;\n } else {\n switch (c) {\n case ' ' : return 36;\n case '$' : return 37;\n case '%' : return 38;\n case '*' : return 39;\n case '+' : return 40;\n case '-' : return 41;\n case '.' : return 42;\n case '/' : return 43;\n case ':' : return 44;\n default :\n throw 'illegal char :' + c;\n }\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qr8BitByte\n //---------------------------------------------------------------------\n\n var qr8BitByte = function(data) {\n\n var _mode = QRMode.MODE_8BIT_BYTE;\n var _data = data;\n var _bytes = qrcode.stringToBytes(data);\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return _bytes.length;\n };\n\n _this.write = function(buffer) {\n for (var i = 0; i < _bytes.length; i += 1) {\n buffer.put(_bytes[i], 8);\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // qrKanji\n //---------------------------------------------------------------------\n\n var qrKanji = function(data) {\n\n var _mode = QRMode.MODE_KANJI;\n var _data = data;\n\n var stringToBytes = qrcode.stringToBytesFuncs['SJIS'];\n if (!stringToBytes) {\n throw 'sjis not supported.';\n }\n !function(c, code) {\n // self test for sjis support.\n var test = stringToBytes(c);\n if (test.length != 2 || ( (test[0] << 8) | test[1]) != code) {\n throw 'sjis not supported.';\n }\n }('\\u53cb', 0x9746);\n\n var _bytes = stringToBytes(data);\n\n var _this = {};\n\n _this.getMode = function() {\n return _mode;\n };\n\n _this.getLength = function(buffer) {\n return ~~(_bytes.length / 2);\n };\n\n _this.write = function(buffer) {\n\n var data = _bytes;\n\n var i = 0;\n\n while (i + 1 < data.length) {\n\n var c = ( (0xff & data[i]) << 8) | (0xff & data[i + 1]);\n\n if (0x8140 <= c && c <= 0x9FFC) {\n c -= 0x8140;\n } else if (0xE040 <= c && c <= 0xEBBF) {\n c -= 0xC140;\n } else {\n throw 'illegal char at ' + (i + 1) + '/' + c;\n }\n\n c = ( (c >>> 8) & 0xff) * 0xC0 + (c & 0xff);\n\n buffer.put(c, 13);\n\n i += 2;\n }\n\n if (i < data.length) {\n throw 'illegal char at ' + (i + 1);\n }\n };\n\n return _this;\n };\n\n //=====================================================================\n // GIF Support etc.\n //\n\n //---------------------------------------------------------------------\n // byteArrayOutputStream\n //---------------------------------------------------------------------\n\n var byteArrayOutputStream = function() {\n\n var _bytes = [];\n\n var _this = {};\n\n _this.writeByte = function(b) {\n _bytes.push(b & 0xff);\n };\n\n _this.writeShort = function(i) {\n _this.writeByte(i);\n _this.writeByte(i >>> 8);\n };\n\n _this.writeBytes = function(b, off, len) {\n off = off || 0;\n len = len || b.length;\n for (var i = 0; i < len; i += 1) {\n _this.writeByte(b[i + off]);\n }\n };\n\n _this.writeString = function(s) {\n for (var i = 0; i < s.length; i += 1) {\n _this.writeByte(s.charCodeAt(i) );\n }\n };\n\n _this.toByteArray = function() {\n return _bytes;\n };\n\n _this.toString = function() {\n var s = '';\n s += '[';\n for (var i = 0; i < _bytes.length; i += 1) {\n if (i > 0) {\n s += ',';\n }\n s += _bytes[i];\n }\n s += ']';\n return s;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // base64EncodeOutputStream\n //---------------------------------------------------------------------\n\n var base64EncodeOutputStream = function() {\n\n var _buffer = 0;\n var _buflen = 0;\n var _length = 0;\n var _base64 = '';\n\n var _this = {};\n\n var writeEncoded = function(b) {\n _base64 += String.fromCharCode(encode(b & 0x3f) );\n };\n\n var encode = function(n) {\n if (n < 0) {\n // error.\n } else if (n < 26) {\n return 0x41 + n;\n } else if (n < 52) {\n return 0x61 + (n - 26);\n } else if (n < 62) {\n return 0x30 + (n - 52);\n } else if (n == 62) {\n return 0x2b;\n } else if (n == 63) {\n return 0x2f;\n }\n throw 'n:' + n;\n };\n\n _this.writeByte = function(n) {\n\n _buffer = (_buffer << 8) | (n & 0xff);\n _buflen += 8;\n _length += 1;\n\n while (_buflen >= 6) {\n writeEncoded(_buffer >>> (_buflen - 6) );\n _buflen -= 6;\n }\n };\n\n _this.flush = function() {\n\n if (_buflen > 0) {\n writeEncoded(_buffer << (6 - _buflen) );\n _buffer = 0;\n _buflen = 0;\n }\n\n if (_length % 3 != 0) {\n // padding\n var padlen = 3 - _length % 3;\n for (var i = 0; i < padlen; i += 1) {\n _base64 += '=';\n }\n }\n };\n\n _this.toString = function() {\n return _base64;\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // base64DecodeInputStream\n //---------------------------------------------------------------------\n\n var base64DecodeInputStream = function(str) {\n\n var _str = str;\n var _pos = 0;\n var _buffer = 0;\n var _buflen = 0;\n\n var _this = {};\n\n _this.read = function() {\n\n while (_buflen < 8) {\n\n if (_pos >= _str.length) {\n if (_buflen == 0) {\n return -1;\n }\n throw 'unexpected end of file./' + _buflen;\n }\n\n var c = _str.charAt(_pos);\n _pos += 1;\n\n if (c == '=') {\n _buflen = 0;\n return -1;\n } else if (c.match(/^\\s$/) ) {\n // ignore if whitespace.\n continue;\n }\n\n _buffer = (_buffer << 6) | decode(c.charCodeAt(0) );\n _buflen += 6;\n }\n\n var n = (_buffer >>> (_buflen - 8) ) & 0xff;\n _buflen -= 8;\n return n;\n };\n\n var decode = function(c) {\n if (0x41 <= c && c <= 0x5a) {\n return c - 0x41;\n } else if (0x61 <= c && c <= 0x7a) {\n return c - 0x61 + 26;\n } else if (0x30 <= c && c <= 0x39) {\n return c - 0x30 + 52;\n } else if (c == 0x2b) {\n return 62;\n } else if (c == 0x2f) {\n return 63;\n } else {\n throw 'c:' + c;\n }\n };\n\n return _this;\n };\n\n //---------------------------------------------------------------------\n // gifImage (B/W)\n //---------------------------------------------------------------------\n\n var gifImage = function(width, height) {\n\n var _width = width;\n var _height = height;\n var _data = new Array(width * height);\n\n var _this = {};\n\n _this.setPixel = function(x, y, pixel) {\n _data[y * _width + x] = pixel;\n };\n\n _this.write = function(out) {\n\n //---------------------------------\n // GIF Signature\n\n out.writeString('GIF87a');\n\n //---------------------------------\n // Screen Descriptor\n\n out.writeShort(_width);\n out.writeShort(_height);\n\n out.writeByte(0x80); // 2bit\n out.writeByte(0);\n out.writeByte(0);\n\n //---------------------------------\n // Global Color Map\n\n // black\n out.writeByte(0x00);\n out.writeByte(0x00);\n out.writeByte(0x00);\n\n // white\n out.writeByte(0xff);\n out.writeByte(0xff);\n out.writeByte(0xff);\n\n //---------------------------------\n // Image Descriptor\n\n out.writeString(',');\n out.writeShort(0);\n out.writeShort(0);\n out.writeShort(_width);\n out.writeShort(_height);\n out.writeByte(0);\n\n //---------------------------------\n // Local Color Map\n\n //---------------------------------\n // Raster Data\n\n var lzwMinCodeSize = 2;\n var raster = getLZWRaster(lzwMinCodeSize);\n\n out.writeByte(lzwMinCodeSize);\n\n var offset = 0;\n\n while (raster.length - offset > 255) {\n out.writeByte(255);\n out.writeBytes(raster, offset, 255);\n offset += 255;\n }\n\n out.writeByte(raster.length - offset);\n out.writeBytes(raster, offset, raster.length - offset);\n out.writeByte(0x00);\n\n //---------------------------------\n // GIF Terminator\n out.writeString(';');\n };\n\n var bitOutputStream = function(out) {\n\n var _out = out;\n var _bitLength = 0;\n var _bitBuffer = 0;\n\n var _this = {};\n\n _this.write = function(data, length) {\n\n if ( (data >>> length) != 0) {\n throw 'length over';\n }\n\n while (_bitLength + length >= 8) {\n _out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );\n length -= (8 - _bitLength);\n data >>>= (8 - _bitLength);\n _bitBuffer = 0;\n _bitLength = 0;\n }\n\n _bitBuffer = (data << _bitLength) | _bitBuffer;\n _bitLength = _bitLength + length;\n };\n\n _this.flush = function() {\n if (_bitLength > 0) {\n _out.writeByte(_bitBuffer);\n }\n };\n\n return _this;\n };\n\n var getLZWRaster = function(lzwMinCodeSize) {\n\n var clearCode = 1 << lzwMinCodeSize;\n var endCode = (1 << lzwMinCodeSize) + 1;\n var bitLength = lzwMinCodeSize + 1;\n\n // Setup LZWTable\n var table = lzwTable();\n\n for (var i = 0; i < clearCode; i += 1) {\n table.add(String.fromCharCode(i) );\n }\n table.add(String.fromCharCode(clearCode) );\n table.add(String.fromCharCode(endCode) );\n\n var byteOut = byteArrayOutputStream();\n var bitOut = bitOutputStream(byteOut);\n\n // clear code\n bitOut.write(clearCode, bitLength);\n\n var dataIndex = 0;\n\n var s = String.fromCharCode(_data[dataIndex]);\n dataIndex += 1;\n\n while (dataIndex < _data.length) {\n\n var c = String.fromCharCode(_data[dataIndex]);\n dataIndex += 1;\n\n if (table.contains(s + c) ) {\n\n s = s + c;\n\n } else {\n\n bitOut.write(table.indexOf(s), bitLength);\n\n if (table.size() < 0xfff) {\n\n if (table.size() == (1 << bitLength) ) {\n bitLength += 1;\n }\n\n table.add(s + c);\n }\n\n s = c;\n }\n }\n\n bitOut.write(table.indexOf(s), bitLength);\n\n // end code\n bitOut.write(endCode, bitLength);\n\n bitOut.flush();\n\n return byteOut.toByteArray();\n };\n\n var lzwTable = function() {\n\n var _map = {};\n var _size = 0;\n\n var _this = {};\n\n _this.add = function(key) {\n if (_this.contains(key) ) {\n throw 'dup key:' + key;\n }\n _map[key] = _size;\n _size += 1;\n };\n\n _this.size = function() {\n return _size;\n };\n\n _this.indexOf = function(key) {\n return _map[key];\n };\n\n _this.contains = function(key) {\n return typeof _map[key] != 'undefined';\n };\n\n return _this;\n };\n\n return _this;\n };\n\n var createDataURL = function(width, height, getPixel) {\n var gif = gifImage(width, height);\n for (var y = 0; y < height; y += 1) {\n for (var x = 0; x < width; x += 1) {\n gif.setPixel(x, y, getPixel(x, y) );\n }\n }\n\n var b = byteArrayOutputStream();\n gif.write(b);\n\n var base64 = base64EncodeOutputStream();\n var bytes = b.toByteArray();\n for (var i = 0; i < bytes.length; i += 1) {\n base64.writeByte(bytes[i]);\n }\n base64.flush();\n\n return 'data:image/gif;base64,' + base64;\n };\n\n //---------------------------------------------------------------------\n // returns qrcode function.\n\n return qrcode;\n}();\n\n// multibyte support\n!function() {\n\n qrcode.stringToBytesFuncs['UTF-8'] = function(s) {\n // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array\n function toUTF8Array(str) {\n var utf8 = [];\n for (var i=0; i < str.length; i++) {\n var charcode = str.charCodeAt(i);\n if (charcode < 0x80) utf8.push(charcode);\n else if (charcode < 0x800) {\n utf8.push(0xc0 | (charcode >> 6),\n 0x80 | (charcode & 0x3f));\n }\n else if (charcode < 0xd800 || charcode >= 0xe000) {\n utf8.push(0xe0 | (charcode >> 12),\n 0x80 | ((charcode>>6) & 0x3f),\n 0x80 | (charcode & 0x3f));\n }\n // surrogate pair\n else {\n i++;\n // UTF-16 encodes 0x10000-0x10FFFF by\n // subtracting 0x10000 and splitting the\n // 20 bits of 0x0-0xFFFFF into two halves\n charcode = 0x10000 + (((charcode & 0x3ff)<<10)\n | (str.charCodeAt(i) & 0x3ff));\n utf8.push(0xf0 | (charcode >>18),\n 0x80 | ((charcode>>12) & 0x3f),\n 0x80 | ((charcode>>6) & 0x3f),\n 0x80 | (charcode & 0x3f));\n }\n }\n return utf8;\n }\n return toUTF8Array(s);\n };\n\n}();\n\n(function (factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof exports === 'object') {\n module.exports = factory();\n }\n}(function () {\n return qrcode;\n}));\n", "/**\n * @file apps/frontend/src/api.ts\n * @description What the plugin's API sends and takes, and the call to it: see src/setup/setupApi.ts in the plugin.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DATA_CENTERS, LAN_VERSIONS } from '../../../src/config.js';\nimport type { SetupReplies, SetupReply } from '../../../src/setup/setupApi.js';\n\n// The types are the plugin's own, so the page and the plugin cannot drift apart. They are only types: nothing of the\n// plugin is loaded in the browser. The page has its own words for some of them.\nexport type { TuyaDeviceExposure as Exposure } from '../../../src/config.js';\nexport type { ControlRef, DeviceFeatures, SensorFeature, SwitchFeature } from '../../../src/features.js';\nexport type { DeviceSupport, ProbeResult } from '../../../src/setup/probe.js';\nexport type { FoundDevice as ListedDevice, QrLoginState, SetupAccount, SetupDevice as StoredDevice, SetupState } from '../../../src/setup/setupApi.js';\n\n/** A data center of the Tuya developer platform, such as `eu`. */\nexport type DataCenter = (typeof DATA_CENTERS)[number];\n\n/** A protocol version a device speaks on the LAN, such as `3.3`. */\nexport type LanVersion = (typeof LAN_VERSIONS)[number];\n\n/** A request the plugin serves, by its method and its path after `api/`. */\nexport type Route = keyof SetupReplies;\n\n/** The reply to a request, with what the plugin sends back when the request worked. */\nexport type Reply<R extends Route> = ({ ok: true } & SetupReplies[R]) | Extract<SetupReply, { ok: false }>;\n\n/** The data centers of the Tuya developer platform, as the page names them: `DATA_CENTERS` in the plugin. */\nexport const dataCenterNames: Readonly<Record<DataCenter, string>> = {\n 'cn': 'China',\n 'us': 'Western America',\n 'us-e': 'Eastern America',\n 'eu': 'Central Europe',\n 'eu-w': 'Western Europe',\n 'in': 'India',\n 'sg': 'Singapore',\n};\n\n/** The protocol versions a device speaks on the LAN: `LAN_VERSIONS` in the plugin. */\nexport const lanVersions: readonly LanVersion[] = ['3.1', '3.2', '3.3', '3.4', '3.5'];\n\n/** The id of the meter of the main outlet among the features left out: `meterFeatureId` in the plugin. */\nexport const meterFeatureId = 'meter';\n\n/**\n * Call the plugin\n *\n * Every request is a GET or a POST, so that every reply has a body that says whether it worked: Matterbridge answers\n * a DELETE with 204 and no body, whatever the plugin returns.\n *\n * @param {R} route The method and the path, such as `POST probe`.\n * @param {unknown} [body] The JSON body.\n * @returns {Promise<Reply<R>>} The reply, with `ok: false` and the reason when the call did not work.\n */\nexport async function api<R extends Route>(route: R, body?: unknown): Promise<Reply<R>> {\n try {\n const [method, path] = route.split(' ');\n const init: RequestInit = { method };\n if (body !== undefined) {\n init.headers = { 'Content-Type': 'application/json' };\n init.body = JSON.stringify(body);\n }\n const response = await fetch(new URL(`api/${path}`, document.baseURI), init);\n if (response.status === 503) return { ok: false, error: 'The plugin is not running. Start it in Matterbridge, then reload this page.' };\n const reply = (await response.json()) as Reply<R> | { error?: string };\n if ('ok' in reply) return reply;\n return { ok: false, error: reply.error ?? `The plugin answered with status ${response.status}` };\n } catch {\n return { ok: false, error: 'Matterbridge did not answer. Check that it is running, then try again.' };\n }\n}\n", "/**\n * @file apps/frontend/src/state.ts\n * @description What the setup page knows at any moment, and what it reads from that.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DataCenter, DeviceFeatures, Exposure, LanVersion, ListedDevice, ProbeResult, QrLoginState, SetupState } from './api.js';\n\n/** What the page knows of the device a draft is about: what the Tuya cloud lists of it. */\nexport interface DraftDevice {\n deviceId: string;\n /** Its name in the Smart Life app. */\n cloudName?: string;\n productKey: string;\n category?: string;\n}\n\n/** One device on its way through Connect and Options. */\nexport interface Draft extends Exposure {\n device: DraftDevice;\n name: string;\n /** The host the device is reached at on the LAN, or empty to find it there by its broadcasts. */\n host: string;\n /** The protocol version it speaks at `host`, or empty while no host is given. */\n version: LanVersion | '';\n /** Whether the device is reached through the Tuya cloud alone, never on the LAN. */\n isCloudOnly: boolean;\n isNew: boolean;\n /** The catalog entry the controls are named by, once the plugin found it. */\n catalogFile?: string;\n /** The cloud's model of the device, which the controls are named by when the catalog does not list its product. */\n model?: ProbeResult['model'];\n productName?: string;\n /** What the device can show in Matter, once the plugin read it. */\n features?: DeviceFeatures;\n /** The controls the device last reported. */\n values?: ProbeResult['values'];\n probe?: ProbeResult;\n}\n\nexport type ScreenName = 'loading' | 'home' | 'signIn' | 'find' | 'connect' | 'options' | 'done';\n\n/** The sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform. */\nexport interface SignIn {\n method: 'smartLife' | 'developer';\n userCode: string;\n accessId: string;\n dataCenter: DataCenter;\n}\n\n/** What the page knows at any moment: the screen it is on, the state the plugin sent, and what the user is doing. */\nexport const view = {\n screen: 'loading' as ScreenName,\n setup: undefined as SetupState | undefined,\n signIn: { method: 'smartLife', userCode: '', accessId: '', dataCenter: 'eu' } as SignIn,\n /** The sign in by QR code, as the plugin last told it. */\n login: { status: 'idle' } as QrLoginState,\n devices: [] as ListedDevice[],\n selected: new Set<string>(),\n queue: [] as Draft[],\n saved: [] as string[],\n /** The devices this run is done with, in the order it went through them. */\n handled: [] as { label: string; isSaved: boolean }[],\n isBusy: false,\n busyText: '',\n error: '',\n /** A note for the user that is no problem, such as what to do after a change. */\n info: '',\n confirmingRemoval: '',\n confirmingSignOut: false,\n};\n\n/**\n * Get the device the run is on\n *\n * @returns {Draft | undefined} The device, or undefined when no run is going on.\n */\nexport function currentDraft(): Draft | undefined {\n return view.queue[0];\n}\n\n/**\n * Get what a device is called on the page: its name, or its device ID until it has one\n *\n * @param {Draft} draft The device.\n * @returns {string} The name, or the device ID.\n */\nexport function draftLabel(draft: Draft): string {\n return draft.name === '' ? draft.device.deviceId : draft.name;\n}\n\n/**\n * Describe a device as the Smart Life app knows it, to tell it apart: its product, its device ID and its name there\n *\n * @param {DraftDevice} device The device.\n * @param {string} [productName] The name the product is sold under, once the plugin found it.\n * @returns {string} The description.\n */\nexport function deviceLabel(device: DraftDevice, productName?: string): string {\n const product = productName === undefined ? 'device' : productName;\n return device.cloudName === undefined ? `${product} ${device.deviceId}` : `${product} ${device.deviceId}, named \"${device.cloudName}\" in the Smart Life app`;\n}\n", "/**\n * @file apps/frontend/src/drafts.ts\n * @description The drafts the Connect and Options steps work on, and the choices of how a device appears in Matter.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DeviceFeatures, Exposure, ListedDevice, StoredDevice } from './api.js';\nimport { type Draft, view } from './state.js';\n\n/** The longest name Matter takes. */\nconst maxNameLength = 32;\n\n/**\n * Tell whether two models of a device say the same\n *\n * The stored model and the one the cloud gives hold the same fields in another order, which says nothing.\n *\n * @param {unknown} left One model, or undefined for a device without one.\n * @param {unknown} right The other model, or undefined for a device without one.\n * @returns {boolean} True when both hold the same data points, whatever the order of their fields.\n */\nexport function hasSameModel(left: unknown, right: unknown): boolean {\n if (!isFields(left) || !isFields(right)) return JSON.stringify(left) === JSON.stringify(right);\n const names = Object.keys(left);\n return names.length === Object.keys(right).length && names.every((name) => hasSameModel(left[name], right[name]));\n}\n\n/**\n * Tell whether a value of a model is an object of named fields, whose order says nothing\n *\n * @param {unknown} value The value.\n * @returns {boolean} False for an array, whose order says something, and for any other value.\n */\nfunction isFields(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Copy the choices of how a device appears in Matter, and nothing else\n *\n * @param {Exposure} source What to copy them from.\n * @returns {Exposure} The choices.\n */\nexport function pickExposure(source: Exposure): Exposure {\n return { hiddenFeatures: [...source.hiddenFeatures], addedFeatures: [...source.addedFeatures], isComposed: source.isComposed };\n}\n\n/**\n * Get the feature that is the device itself, and always shown: its first light, else its first outlet, else its first sensor\n *\n * @param {DeviceFeatures} features What the device can show.\n * @returns {string | undefined} The id of the feature, or undefined for a device with none.\n */\nexport function mainFeatureId(features: DeviceFeatures): string | undefined {\n return (features.lights[0] ?? features.outlets[0] ?? features.sensors[0])?.id;\n}\n\n/**\n * Tell whether a device shows its meter: the plugin gives the meter to the main unit when it is an outlet\n *\n * @param {DeviceFeatures} features What the device can show.\n * @returns {boolean} True when the device has a meter and its main unit is an outlet.\n */\nexport function hasMeter(features: DeviceFeatures): boolean {\n const [outlet] = features.outlets;\n return features.meter !== undefined && outlet !== undefined && mainFeatureId(features) === outlet.id;\n}\n\n/**\n * Drop the choices a device has no use for\n *\n * A feature the device does not have is neither left out nor added, so that the options stored are those of what it\n * can do.\n *\n * @param {Exposure} exposure The choices.\n * @param {DeviceFeatures} features What the device can show.\n * @returns {Exposure} The choices that apply to it.\n */\nexport function fitExposure(exposure: Exposure, features: DeviceFeatures): Exposure {\n const main = mainFeatureId(features);\n const shown = new Set([...features.lights, ...features.outlets, ...features.sensors].map((feature) => feature.id).filter((id) => id !== main));\n if (hasMeter(features)) shown.add('meter');\n const added = new Set(features.settingSwitches.map((feature) => feature.id));\n return {\n hiddenFeatures: exposure.hiddenFeatures.filter((id) => shown.has(id)),\n addedFeatures: exposure.addedFeatures.filter((id) => added.has(id)),\n isComposed: exposure.isComposed,\n };\n}\n\n/**\n * Find a name no device has yet: the name in the Smart Life app, or that name with a number after it, such as \"Desk Lamp 2\"\n *\n * @param {string} base The name in the Smart Life app.\n * @param {ReadonlySet<string>} taken The names in use.\n * @returns {string} The name, of at most 32 characters.\n */\nfunction uniqueName(base: string, taken: ReadonlySet<string>): string {\n const trimmed = base.trim().slice(0, maxNameLength).trimEnd();\n if (trimmed === '' || !taken.has(trimmed)) return trimmed;\n for (let count = 2; ; count++) {\n const suffix = ` ${count}`;\n const name = `${trimmed.slice(0, maxNameLength - suffix.length).trimEnd()}${suffix}`;\n if (!taken.has(name)) return name;\n }\n}\n\n/**\n * Draft the devices picked in the Find step, each named after its name in the Smart Life app\n *\n * Two devices can share a name there, so each draft gets one no stored device and no draft before it has.\n *\n * @param {readonly ListedDevice[]} devices The devices picked.\n * @returns {Draft[]} The drafts, new and with nothing left out or added yet.\n */\nexport function draftsFromDevices(devices: readonly ListedDevice[]): Draft[] {\n const taken = new Set((view.setup?.devices ?? []).map((device) => device.name));\n return devices.map((listed) => {\n const name = uniqueName(listed.name, taken);\n taken.add(name);\n return {\n device: { deviceId: listed.deviceId, cloudName: listed.name, productKey: listed.productKey, category: listed.category },\n name,\n host: '',\n version: '',\n isCloudOnly: false,\n isNew: true,\n hiddenFeatures: [],\n addedFeatures: [],\n isComposed: false,\n };\n });\n}\n\n/**\n * Draft a stored device, to check it again and change its options\n *\n * @param {StoredDevice} device The device as the plugin stores it.\n * @returns {Draft} The draft, with its options as stored.\n */\nexport function draftFromStored(device: StoredDevice): Draft {\n return {\n device: { deviceId: device.deviceId, cloudName: device.cloudName, productKey: device.productKey, category: device.category },\n name: device.name,\n host: device.host ?? '',\n version: device.version ?? '',\n isCloudOnly: device.isCloudOnly ?? false,\n isNew: false,\n catalogFile: device.catalogFile,\n model: device.model,\n productName: device.productName,\n features: device.features,\n values: device.values,\n ...pickExposure(device),\n };\n}\n", "/**\n * @file apps/frontend/src/render.ts\n * @description Draws the screen the setup page is on. The screens are handed in by app.ts, so that they and the\n * actions can call for a redraw without this file depending on them.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Child } from './dom.js';\nimport { currentDraft, type ScreenName, view } from './state.js';\n\nexport type Screens = Record<ScreenName, () => Child[]>;\n\nlet screens: Screens | undefined;\n\n/**\n * Tell the page what each screen draws\n *\n * @param {Screens} all What each screen draws, by its name.\n * @returns {void}\n */\nexport function setScreens(all: Screens): void {\n screens = all;\n}\n\n/**\n * Draw the screen the page is on\n *\n * What the user is typing is kept when the same form redraws around it, with the focus and the caret where they were.\n *\n * @returns {void}\n */\nexport function render(): void {\n const root = document.getElementById('app');\n if (root === null || screens === undefined) return;\n // Keep what the user is typing when the same form redraws around it, and never carry it over to another form.\n const form = `${view.screen}:${currentDraft()?.device.deviceId ?? ''}`;\n const isSameForm = root.dataset.form === form;\n const active = document.activeElement;\n const activeId = active instanceof HTMLElement ? active.id : '';\n // Where the caret is in the field being typed in, so that a redraw while typing does not move it to the end.\n const caret =\n active instanceof HTMLInputElement && (active.type === 'text' || active.type === 'password') ? { start: active.selectionStart, end: active.selectionEnd } : undefined;\n const typed = new Map<string, string>();\n for (const input of root.querySelectorAll<HTMLInputElement>('input[type=text], input[type=email], input[type=password]')) {\n if (input.id !== '') typed.set(input.id, input.value);\n }\n root.replaceChildren(...screens[view.screen]().filter((child): child is Node | string => child !== false && child !== null && child !== undefined));\n root.dataset.form = form;\n if (!isSameForm) return;\n for (const [id, value] of typed) {\n const input = document.getElementById(id);\n if (input instanceof HTMLInputElement) input.value = value;\n }\n if (activeId === '') return;\n const focused = document.getElementById(activeId);\n focused?.focus();\n if (caret !== undefined && focused instanceof HTMLInputElement) focused.setSelectionRange(caret.start, caret.end);\n}\n", "/**\n * @file apps/frontend/src/actions.ts\n * @description What the buttons of the setup page do: each call to the plugin and where the page goes next.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { api, type DataCenter, type QrLoginState, type SetupState, type StoredDevice } from './api.js';\nimport { draftFromStored, fitExposure, hasSameModel, pickExposure } from './drafts.js';\nimport { render } from './render.js';\nimport { currentDraft, type Draft, draftLabel, view } from './state.js';\n\n/**\n * Run a call while the page shows that it is working\n *\n * @param {string} text What the page says meanwhile.\n * @param {() => Promise<T>} task The call.\n * @returns {Promise<T>} What the call returned.\n */\nasync function busy<T>(text: string, task: () => Promise<T>): Promise<T> {\n view.isBusy = true;\n view.busyText = text;\n view.error = '';\n view.info = '';\n render();\n try {\n return await task();\n } finally {\n view.isBusy = false;\n render();\n }\n}\n\n/**\n * Load the page: read the state, and go to the screen it calls for\n *\n * @returns {Promise<void>} Resolves when the first screen is drawn.\n */\nexport async function loadState(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) {\n view.error = reply.error;\n view.screen = 'home';\n render();\n return;\n }\n setSetup(reply.state);\n // With no account and no device yet, the page goes straight to signing in, and with no device yet to finding them.\n if (reply.state.account === undefined && reply.state.devices.length === 0) {\n startSignIn();\n return;\n }\n if (reply.state.account !== undefined && reply.state.devices.length === 0 && !reply.state.account.needsSignIn) {\n await search();\n return;\n }\n view.screen = 'home';\n render();\n void syncState();\n}\n\n/**\n * Read the device list of the account again behind the page as it opens, so that what changed in the Smart Life app\n * since the last read, such as a name, shows without waiting for the next one\n *\n * The page is redrawn only when the state changed: a redraw for nothing could land between a press and its click, and\n * lose the click.\n *\n * @returns {Promise<void>} Resolves when the list is read.\n */\nasync function syncState(): Promise<void> {\n if (view.setup?.account === undefined) return;\n const reply = await api('POST sync');\n if (!reply.ok || JSON.stringify(reply.state) === JSON.stringify(view.setup)) return;\n setSetup(reply.state);\n render();\n}\n\n// The state is read again this long after it showed a device connecting.\nconst connectingRefreshInMs = 2000;\nlet connectingRefresh: number | undefined;\n\n/**\n * Take the state the plugin sent, and read it again in a moment while a device connects, so that its status settles without a reload\n *\n * @param {SetupState} state The state.\n * @returns {void}\n */\nfunction setSetup(state: SetupState): void {\n view.setup = state;\n if (connectingRefresh !== undefined || !state.devices.some((device) => device.status === 'connecting')) return;\n connectingRefresh = window.setTimeout(() => {\n connectingRefresh = undefined;\n void followConnecting();\n }, connectingRefreshInMs);\n}\n\n/**\n * Read the state again while a device connects, and redraw the home screen when it changed\n *\n * The home screen alone shows the devices. Another screen is left as it is, and a state that did not change redraws\n * nothing: a redraw for nothing could land between a press and its click, and lose the click.\n *\n * @returns {Promise<void>} Resolves when the state is read.\n */\nasync function followConnecting(): Promise<void> {\n const reply = await api('GET state');\n if (!reply.ok) return;\n const hasChanged = JSON.stringify(reply.state) !== JSON.stringify(view.setup);\n setSetup(reply.state);\n if (hasChanged && view.screen === 'home') render();\n}\n\n/**\n * Read the state again, without redrawing\n *\n * @returns {Promise<void>} Resolves when the state is read.\n */\nasync function refreshState(): Promise<void> {\n const reply = await api('GET state');\n if (reply.ok) setSetup(reply.state);\n}\n\n/**\n * Go to the home screen, leaving a run of the setup, and read the state again behind it\n *\n * @returns {void}\n */\nexport function goHome(): void {\n stopQrPolling();\n view.queue = [];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'home';\n void refreshState().then(render);\n render();\n}\n\n/**\n * Go to the sign in, with the fields of the account signed in filled in\n *\n * @returns {void}\n */\nexport function startSignIn(): void {\n const account = view.setup?.account;\n if (account?.type === 'smartLife') view.signIn = { ...view.signIn, method: 'smartLife', userCode: account.userCode };\n if (account?.type === 'developer') view.signIn = { ...view.signIn, method: 'developer', accessId: account.accessId, dataCenter: account.dataCenter };\n view.login = { status: 'idle' };\n view.error = '';\n view.info = '';\n view.screen = 'signIn';\n render();\n}\n\n// The sign in by QR code is followed this often while the app has not confirmed it.\nconst qrPollIntervalInMs = 2000;\nlet qrPoll: number | undefined;\n\n/**\n * Stop following the sign in by QR code\n *\n * @returns {void}\n */\nfunction stopQrPolling(): void {\n window.clearInterval(qrPoll);\n qrPoll = undefined;\n}\n\n/**\n * Ask the plugin for a QR code to sign in with the Smart Life app, show it, and follow the scan\n *\n * @param {string} userCode The User Code the app shows under Settings > Account and Security.\n * @returns {Promise<void>} Resolves when the QR code is shown, or the refusal.\n */\nexport async function requestQrCode(userCode: string): Promise<void> {\n view.signIn.userCode = userCode;\n stopQrPolling();\n const reply = await busy('Asking the Smart Life cloud for a QR code\u2026', async () => api('POST qr-code', { userCode }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n view.login = reply.login;\n render();\n qrPoll = window.setInterval(() => void pollQrLogin(), qrPollIntervalInMs);\n}\n\n/**\n * Ask once how the sign in by QR code goes, and take the account once the scan is in\n *\n * @returns {Promise<void>} Resolves when the answer is taken.\n */\nasync function pollQrLogin(): Promise<void> {\n const reply = await api('GET qr-login');\n // A poll that failed is tried again at the next interval, unless the page left the sign in meanwhile.\n if (!reply.ok || view.screen !== 'signIn' || qrPoll === undefined) return;\n const { login } = reply;\n if (login.status === 'waiting') return;\n stopQrPolling();\n await takeLogin(login, reply.state);\n}\n\n/**\n * Take the outcome of the sign in by QR code\n *\n * @param {QrLoginState} login How the sign in went.\n * @param {SetupState} state The state, with the account once it is signed in.\n * @returns {Promise<void>} Resolves when the page shows it.\n */\nasync function takeLogin(login: QrLoginState, state: SetupState): Promise<void> {\n view.login = login;\n if (login.status !== 'signedIn') {\n render();\n return;\n }\n setSetup(state);\n await afterSignIn(state);\n}\n\n/**\n * Go on after a sign in: to the devices, unless they are set up already\n *\n * @param {SetupState} state The state, with the account signed in.\n * @returns {Promise<void>} Resolves when the next screen is drawn.\n */\nasync function afterSignIn(state: SetupState): Promise<void> {\n view.login = { status: 'idle' };\n if (state.devices.length === 0) await search();\n else goHome();\n}\n\n/**\n * Stop the sign in by QR code, here and in the plugin\n *\n * @returns {Promise<void>} Resolves when the plugin stopped waiting for the scan.\n */\nexport async function cancelQrCode(): Promise<void> {\n stopQrPolling();\n view.login = { status: 'idle' };\n await api('POST cancel-qr-code');\n render();\n}\n\n/**\n * Sign in with a cloud project of the Tuya developer platform\n *\n * @param {string} accessId The Access ID of the project.\n * @param {string} accessSecret The Access Secret of the project.\n * @param {DataCenter} dataCenter The data center of the project.\n * @returns {Promise<void>} Resolves when the account is signed in and the page went on, or shows the refusal.\n */\nexport async function signInDeveloper(accessId: string, accessSecret: string, dataCenter: DataCenter): Promise<void> {\n view.signIn = { ...view.signIn, accessId, dataCenter };\n const reply = await busy('Signing in to the Tuya developer platform\u2026', async () => api('POST developer-login', { accessId, accessSecret, dataCenter }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n setSetup(reply.state);\n await afterSignIn(reply.state);\n}\n\n/**\n * Sign out of the account: the devices stay, on the LAN alone\n *\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function signOut(): Promise<void> {\n const reply = await busy('Signing out\u2026', async () => api('POST sign-out'));\n view.confirmingSignOut = false;\n if (!reply.ok) view.error = reply.error;\n await refreshState();\n render();\n}\n\n/**\n * Go to the Find step, and list the devices of the account, with the ones the plugin can add picked\n *\n * @returns {Promise<void>} Resolves when the devices are shown, or the failure.\n */\nexport async function search(): Promise<void> {\n view.screen = 'find';\n const reply = await busy('Reading the devices of your Tuya account\u2026', async () => api('POST devices'));\n if (!reply.ok) {\n view.error = `The devices could not be read: ${reply.error}`;\n render();\n return;\n }\n await refreshState();\n view.devices = reply.devices;\n for (const device of reply.devices) {\n if (!device.isConfigured && device.support === 'supported') view.selected.add(device.deviceId);\n }\n render();\n}\n\n/**\n * Start a run of the setup through the Connect and Options steps, one device after the other\n *\n * @param {Draft[]} drafts The devices to set up, in order.\n * @returns {void}\n */\nexport function startQueue(drafts: Draft[]): void {\n view.queue = drafts;\n view.saved = [];\n view.handled = [];\n void enterConnect();\n}\n\n/**\n * Go straight to the options of a stored device, with the entry it is stored with\n *\n * The device is not checked first: its host can be changed while it does not answer, and it needs no account. Its\n * entry stays as chosen, so that opening the options never replaces it or the features chosen from it.\n *\n * @param {StoredDevice} device The device, whose catalog entry this version has.\n * @returns {void}\n */\nexport function openOptions(device: StoredDevice): void {\n view.queue = [draftFromStored(device)];\n view.saved = [];\n view.handled = [];\n view.error = '';\n view.info = '';\n view.screen = 'options';\n render();\n}\n\n/**\n * Give a stored device a new client, or start it again, and show how it went\n *\n * @param {StoredDevice} device The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function reconnectDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Reconnecting ${device.name}\u2026`, async () => api('POST reconnect', { deviceId: device.deviceId }));\n if (reply.ok) setSetup(reply.state);\n else view.error = reply.error;\n render();\n}\n\n/**\n * Go to the Connect step of the next device of the run, or to the end of the run\n *\n * @returns {Promise<void>} Resolves when the device is checked, or the end is shown.\n */\nasync function enterConnect(): Promise<void> {\n const draft = currentDraft();\n if (draft === undefined) {\n view.screen = view.saved.length > 0 ? 'done' : 'home';\n await refreshState();\n render();\n return;\n }\n view.screen = 'connect';\n view.error = '';\n view.info = '';\n draft.probe = undefined;\n render();\n await check(draft);\n}\n\n/**\n * Check a device through the plugin, and go to its options once it answers\n *\n * @param {Draft} draft The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function check(draft: Draft): Promise<void> {\n const reply = await busy(`Connecting to ${draftLabel(draft)} on your network, and through the Tuya cloud\u2026`, async () => api('POST probe', { deviceId: draft.device.deviceId }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n const { result } = reply;\n draft.probe = result;\n if (result.status === 'signInRequired') await refreshState();\n if (result.status === 'ready' && result.features !== undefined && (result.catalogFile !== undefined || result.model !== undefined)) {\n draft.features = result.features;\n draft.values = result.values;\n draft.productName = result.productName;\n // A device set up again because its entry is gone has other features: the options are fitted to the ones it has.\n const hadEntry = draft.catalogFile !== undefined || draft.model !== undefined;\n if (hadEntry && (draft.catalogFile !== result.catalogFile || !hasSameModel(draft.model, result.model))) Object.assign(draft, { hiddenFeatures: [], addedFeatures: [] });\n draft.catalogFile = result.catalogFile;\n draft.model = result.model;\n Object.assign(draft, fitExposure(pickExposure(draft), result.features));\n view.screen = 'options';\n }\n render();\n}\n\n/**\n * Leave the device the run is on out, and go on to the next\n *\n * @returns {void}\n */\nexport function skipDraft(): void {\n const skipped = view.queue.shift();\n if (skipped !== undefined) view.handled.push({ label: draftLabel(skipped), isSaved: false });\n void enterConnect();\n}\n\n/**\n * Store a device with the options chosen, and go on to the next\n *\n * @param {Draft} draft The device, with its options.\n * @returns {Promise<void>} Resolves when the device is stored and the page went on, or shows what is wrong.\n */\nexport async function saveDraft(draft: Draft): Promise<void> {\n const name = draft.name.trim();\n const problem = checkName(draft, name) || checkHost(draft);\n if (problem !== '') {\n view.error = problem;\n render();\n return;\n }\n if (draft.catalogFile === undefined && draft.model === undefined) return;\n const { device } = draft;\n // An empty host is left out: the plugin finds the device by its broadcasts. A device on the cloud alone needs none.\n const hasHost = !draft.isCloudOnly && draft.host !== '';\n const saved = {\n deviceId: device.deviceId,\n name,\n productKey: device.productKey,\n catalogFile: draft.catalogFile,\n // A model names the controls by their codes in the device's category, which the plugin checks against the device list.\n model: draft.model,\n category: device.category,\n ...fitExposure(pickExposure(draft), draft.features ?? { lights: [], outlets: [], settingSwitches: [], sensors: [] }),\n host: hasHost ? draft.host : undefined,\n version: hasHost ? draft.version : undefined,\n isCloudOnly: draft.isCloudOnly || undefined,\n };\n const reply = await busy(`Saving ${name}\u2026`, async () => api('POST device', { device: saved }));\n if (!reply.ok) {\n view.error = reply.error;\n render();\n return;\n }\n setSetup(reply.state);\n view.saved.push(name);\n view.handled.push({ label: name, isSaved: true });\n view.queue.shift();\n await enterConnect();\n}\n\n/**\n * Tell what is wrong with the name of a draft: the plugin refuses a name another device has\n *\n * @param {Draft} draft The device.\n * @param {string} name Its name, trimmed.\n * @returns {string} What is wrong, or an empty text.\n */\nfunction checkName(draft: Draft, name: string): string {\n if (name === '') return 'Give the device a name: it is the name it gets in Matter.';\n const isTaken = (view.setup?.devices ?? []).some((device) => device.name === name && device.deviceId !== draft.device.deviceId);\n return isTaken ? `\"${name}\" is already the name of another device. Pick a different one.` : '';\n}\n\n/**\n * Tell what is wrong with the host of a draft: a host is given with the protocol version the device speaks there\n *\n * @param {Draft} draft The device.\n * @returns {string} What is wrong, or an empty text.\n */\nfunction checkHost(draft: Draft): string {\n if (draft.isCloudOnly || draft.host === '') return '';\n if (!/^[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?$/.test(draft.host)) return `\"${draft.host}\" is not a host name or an IPv4 address.`;\n return draft.version === '' ? 'Pick the protocol version the device speaks at that host, or leave the host empty.' : '';\n}\n\n// Matterbridge does not tell its own page when a plugin adds or removes a device, so its device list waits for a reload.\nexport const reloadNote = \"Matterbridge's own list of devices shows the change once you reload its page.\";\n\n/** A change of how a device appears in Matter waits for a restart, which the plugin asks Matterbridge for as well. */\nexport const restartNote = 'Restart Matterbridge to apply the new options in Matter: until then the device keeps its current endpoints.';\n\n/**\n * Remove a stored device from the plugin and from Matter\n *\n * @param {StoredDevice} device The device.\n * @returns {Promise<void>} Resolves when the page shows the outcome.\n */\nexport async function removeDevice(device: StoredDevice): Promise<void> {\n const reply = await busy(`Removing ${device.name}\u2026`, async () => api('POST remove-device', { deviceId: device.deviceId }));\n view.confirmingRemoval = '';\n if (reply.ok) view.info = `${device.name} is removed. ${reloadNote}`;\n else view.error = reply.error;\n await refreshState();\n render();\n}\n", "/**\n * @file apps/frontend/src/dom.ts\n * @description The one helper the setup page builds its elements with.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Child = Node | string | false | null | undefined;\n\n/**\n * Create an element\n *\n * @param {K} tag The tag name.\n * @param {Record<string, unknown>} [props] `class`, `on<event>` listeners, and anything else as a property when the element has it, else an attribute.\n * @param {...Child} children Nodes or text; false, null and undefined are skipped.\n * @returns {HTMLElementTagNameMap[K]} The element.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, props: Record<string, unknown> = {}, ...children: Child[]): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === false) continue;\n if (key === 'class') element.className = String(value);\n else if (key === 'html') element.innerHTML = String(value);\n else if (key.startsWith('on') && typeof value === 'function') element.addEventListener(key.slice(2), value as EventListener);\n else if (key in element) (element as unknown as Record<string, unknown>)[key] = value;\n else element.setAttribute(key, String(value));\n }\n for (const child of children) {\n if (child !== false && child !== null && child !== undefined) element.append(child);\n }\n return element;\n}\n", "/**\n * @file apps/frontend/src/components.ts\n * @description The pieces more than one screen of the setup page is made of.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Child, h } from './dom.js';\nimport { currentDraft, type Draft, draftLabel, type ScreenName, view } from './state.js';\n\n/**\n * Create a button, disabled while the page is busy\n *\n * @param {string} label What it says.\n * @param {() => void} onclick What it does.\n * @param {'primary' | 'quiet' | 'danger'} [kind] How it looks: the main action, a quiet one, or one that removes something. Defaults to quiet.\n * @param {boolean} [disabled] Whether it is disabled anyway. Defaults to false.\n * @returns {HTMLButtonElement} The button.\n */\nexport function button(label: string, onclick: () => void, kind: 'primary' | 'quiet' | 'danger' = 'quiet', disabled = false): HTMLButtonElement {\n return h('button', { type: 'button', class: `button ${kind}`, onclick, disabled: disabled || view.isBusy }, label);\n}\n\n/**\n * Show what the page is doing, or what went wrong, or a note for the user\n *\n * @returns {Child} The notice, or null when there is nothing to say.\n */\nexport function notice(): Child {\n if (view.isBusy) return h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), view.busyText);\n if (view.error !== '') return h('p', { class: 'notice problem', role: 'alert' }, view.error);\n if (view.info !== '') return h('p', { class: 'notice', role: 'status' }, view.info);\n return null;\n}\n\n/**\n * List the devices of this run, with the one the page is on marked\n *\n * Shown when a run sets up more than one device, so that it is plain which one the Connect and Options steps are about.\n *\n * @returns {Child} The list, or null for a run of one device, or of none that is new.\n */\nexport function unitStrip(): Child {\n const current = currentDraft();\n if (current === undefined || !current.isNew || view.handled.length + view.queue.length < 2) return null;\n const doing = view.screen === 'connect' ? 'Connecting' : 'Choosing options';\n return h(\n 'ol',\n { 'class': 'units', 'aria-label': 'Devices in this setup' },\n ...view.handled.map((unit) =>\n h('li', { class: unit.isSaved ? 'done' : 'skipped' }, h('strong', {}, unit.label), h('span', { class: 'meta' }, unit.isSaved ? 'Added' : 'Skipped')),\n ),\n ...view.queue.map((draft, index) =>\n h(\n 'li',\n { 'class': index === 0 ? 'current' : 'ahead', 'aria-current': index === 0 ? 'true' : undefined },\n h('strong', {}, draftLabel(draft)),\n h('span', { class: 'meta' }, index === 0 ? doing : 'Waiting'),\n ),\n ),\n );\n}\n\n/**\n * Create the heading of a step that is about one device: the device first, then what the step does with it\n *\n * @param {Draft} draft The device.\n * @param {string} text What the step does with it.\n * @returns {HTMLElement} The heading.\n */\nexport function unitHeader(draft: Draft, text: string): HTMLElement {\n return h('header', { class: 'unit-header' }, h('h1', {}, draftLabel(draft)), h('p', { class: 'meta' }, text));\n}\n\n/**\n * Show the steps of the setup, Find, Connect and Options, with the current one marked\n *\n * @returns {Child} The steps, or null for a run that only checks devices set up already.\n */\nexport function steps(): Child {\n if (view.queue.length > 0 && !view.queue.some((draft) => draft.isNew)) return null;\n const names = ['Find', 'Connect', 'Options'];\n const screens: ScreenName[] = ['find', 'connect', 'options'];\n const current = screens.indexOf(view.screen);\n return h(\n 'ol',\n { class: 'steps' },\n ...names.map((name, index) => {\n let state = 'ahead';\n if (index < current) state = 'done';\n else if (index === current) state = 'current';\n return h('li', { 'class': state, 'aria-current': index === current ? 'step' : undefined }, name);\n }),\n );\n}\n", "/**\n * @file apps/frontend/src/screens/connect.ts\n * @description The Connect step: the plugin reads the device, on your network and through the Tuya cloud, and finds its catalog entry.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { check, goHome, skipDraft, startSignIn } from '../actions.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { currentDraft, deviceLabel, type Draft, view } from '../state.js';\n\n/**\n * Show what stands in the way of the device, or what the page needs before it can go on\n *\n * @param {Draft} draft The device.\n * @returns {Child} The panel, or null while the check has no answer, or the device answered.\n */\nfunction statusPanel(draft: Draft): Child {\n const status = draft.probe?.status;\n const label = draft.name === '' ? 'The device' : draft.name;\n const message = draft.probe?.message ?? 'unknown';\n if (status === 'signInRequired') {\n return h(\n 'div',\n { class: 'field' },\n h('p', { class: 'notice problem', role: 'alert' }, 'The Tuya cloud no longer accepts the sign in of this plugin.'),\n button('Sign in again', startSignIn, 'primary'),\n );\n }\n if (status === 'unreachable') {\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `${label} did not answer. Check that it is plugged in and shows as online in the Smart Life app, then try again. ${message}`,\n );\n }\n if (status === 'unsupported') return h('p', { class: 'notice problem', role: 'alert' }, `The plugin cannot control ${label}: ${message}`);\n if (status === 'failed') return h('p', { class: 'notice problem', role: 'alert' }, `${label} answered with an error: ${message}`);\n return null;\n}\n\n/**\n * Draw the Connect step: the check of the device the run is on\n *\n * @returns {Child[]} The screen.\n */\nexport function connectScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const canRetry = draft.probe?.status === 'unreachable' || draft.probe?.status === 'failed' || view.error !== '';\n const isOneOfMany = draft.isNew && view.queue.length > 1;\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Connecting to the ${deviceLabel(draft.device, draft.productName)}.`),\n notice(),\n view.isBusy ? null : statusPanel(draft),\n h(\n 'div',\n { class: 'footer' },\n canRetry ? button('Try again', () => void check(draft)) : null,\n button(isOneOfMany ? 'Skip this one' : 'Cancel', isOneOfMany ? skipDraft : goHome),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/done.ts\n * @description The end of a setup run: the devices it added.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, reloadNote, restartNote } from '../actions.js';\nimport { button } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { view } from '../state.js';\n\n/**\n * Draw the end of a run: the devices set up, and what to do next\n *\n * @returns {Child[]} The screen.\n */\nexport function doneScreen(): Child[] {\n const names = view.saved;\n const needsRestart = (view.setup?.devices ?? []).some((device) => names.includes(device.name) && device.needsRestart);\n return [\n h('header', {}, h('h1', {}, names.length === 1 ? `${names[0]} is set up` : `${names.length} devices are set up`)),\n h('p', { class: 'lead' }, 'They now appear in the Matter apps paired with Matterbridge. If Matterbridge is not paired yet, pair it from its home page.'),\n needsRestart ? h('p', { class: 'help' }, h('strong', {}, restartNote)) : null,\n h('p', { class: 'help' }, reloadNote),\n h('div', { class: 'footer' }, button('Done', goHome, 'primary')),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/find.ts\n * @description The Find step: the devices of the account, and why the plugin cannot control one.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, search, startQueue } from '../actions.js';\nimport type { ListedDevice } from '../api.js';\nimport { button, notice, steps } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftsFromDevices } from '../drafts.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\n// A device the catalog does not list by its product may still match by its data points, which the Connect step reads.\nfunction isSelectable(device: ListedDevice): boolean {\n return !device.isConfigured && (device.support === 'supported' || device.support === 'unknownProduct');\n}\n\nfunction notesOf(device: ListedDevice): string[] {\n const notes: string[] = [];\n if (device.isConfigured) notes.push('Already set up.');\n if (device.support === 'unknownProduct') notes.push('The catalog does not list its product: the plugin checks its data points in the next step.');\n if (device.support === 'otherKind') notes.push('A kind of device the plugin does not control yet, such as a fan: only lights, switches, plugs and sensors for now.');\n if (device.support === 'gateway') notes.push('A gateway: the devices behind it are listed on their own.');\n if (device.support === 'gateway' || device.support === 'otherKind') return notes;\n if (!device.online) notes.push('The Tuya cloud says it is offline.');\n if (device.gatewayId !== undefined) notes.push('Behind a gateway.');\n if (device.lan !== undefined) notes.push(`Heard on your network at ${device.lan.host}.`);\n if (!device.hasLocalKey) notes.push('No local key from the cloud: reached through the cloud only.');\n return notes;\n}\n\nfunction deviceRow(device: ListedDevice): HTMLElement {\n const isAvailable = isSelectable(device);\n const id = `device-${device.deviceId}`;\n const checkbox = h('input', {\n type: 'checkbox',\n id,\n checked: isAvailable && view.selected.has(device.deviceId),\n disabled: !isAvailable,\n onchange: () => {\n if (checkbox.checked) view.selected.add(device.deviceId);\n else view.selected.delete(device.deviceId);\n render();\n },\n });\n return h(\n 'li',\n { class: isAvailable ? 'found' : 'found unavailable' },\n h(\n 'label',\n { for: id },\n checkbox,\n h(\n 'span',\n {},\n h('strong', {}, device.name),\n h('span', { class: 'meta' }, ` ${device.deviceId}, product ${device.productKey}${device.category === '' ? '' : `, category ${device.category}`}`),\n ...notesOf(device).map((note) => h('span', { class: 'meta note' }, note)),\n ),\n ),\n );\n}\n\n/**\n * Draw the Find step: the devices of the account, to pick the ones to set up\n *\n * @returns {Child[]} The screen.\n */\nexport function findScreen(): Child[] {\n const chosen = view.devices.filter((device) => view.selected.has(device.deviceId) && isSelectable(device));\n const continueLabel = chosen.length === 1 ? 'Set up 1 device' : `Set up ${chosen.length} devices`;\n return [\n steps(),\n h('header', {}, h('h1', {}, 'Your Tuya devices')),\n notice(),\n view.devices.length > 0 ? h('ul', { class: 'found-list' }, ...view.devices.map(deviceRow)) : null,\n !view.isBusy && view.devices.length === 0 && view.error === ''\n ? h('p', { class: 'empty' }, 'Your Tuya account has no device yet. Add your devices in the Smart Life app, then read the list again.')\n : null,\n h(\n 'div',\n { class: 'footer' },\n button('Read the list again', () => void search()),\n button('Cancel', goHome),\n button(continueLabel, () => startQueue(draftsFromDevices(chosen)), 'primary', chosen.length === 0),\n ),\n ];\n}\n", "/**\n * @file src/lightState.ts\n * @description This file contains which of its brightnesses a light shows, which Matter and the setup page share.\n * @author Calvin Che\n * @created 2026-11-02\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ControlValues } from 'open-tuya';\n\nimport type { LightFeature, RangedControl } from './features.js';\n\n/**\n * Tell whether a light shows its colour now, rather than its white\n *\n * The setup page bundles this file, so it imports nothing at runtime.\n *\n * Edge cases:\n * - a light without a mode control shows its colour when it has no white brightness\n * - a mode such as a scene is no colour\n *\n * @param {LightFeature} light The light.\n * @param {ControlValues} values Every control the device reports, as last known.\n * @returns {boolean} True while it shows its colour.\n */\nexport function isShowingColor(light: LightFeature, values: ControlValues): boolean {\n if (light.color === undefined) return false;\n if (light.mode === undefined) return light.brightness === undefined;\n return values[light.component]?.[light.mode.control] === light.mode.color;\n}\n\n/**\n * Get the brightness a light's level stands for: that of the colour while the light shows its colour, else that of its white\n *\n * @param {LightFeature} light The light.\n * @param {boolean} isColor Whether the light shows its colour.\n * @returns {RangedControl | undefined} The brightness control, or undefined when the light has none.\n */\nexport function getBrightness(light: LightFeature, isColor: boolean): RangedControl | undefined {\n if (isColor && light.color?.brightness !== undefined) return light.color.brightness;\n return light.brightness ?? light.color?.brightness;\n}\n", "/**\n * @file src/temperatureUnit.ts\n * @description This file contains how the unit of a temperature is read, which Matter and the setup page share.\n * @author Calvin Che\n * @created 2026-11-01\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ControlValues } from 'open-tuya';\n\nimport type { SensorFeature } from './features.js';\n\n/**\n * Get the unit of a temperature, on a device that switches its unit at runtime as well\n *\n * The setup page bundles this file, so it imports nothing at runtime.\n *\n * @param {ControlValues} values The controls the device reports.\n * @param {SensorFeature} feature The temperature sensor.\n * @returns {string | undefined} The unit the device reports, or the one the catalog gives.\n */\nexport function getTemperatureUnit(values: ControlValues, feature: SensorFeature): string | undefined {\n if (feature.unitFrom === undefined) return feature.unit;\n const unit = values[feature.component]?.[feature.unitFrom];\n return typeof unit === 'string' ? unit : feature.unit;\n}\n", "/**\n * @file apps/frontend/src/readings.ts\n * @description What a device reports, in a line the page can show.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getBrightness, isShowingColor } from '../../../src/lightState.js';\nimport { getTemperatureUnit } from '../../../src/temperatureUnit.js';\nimport type { ControlRef, DeviceFeatures, ProbeResult, SensorFeature } from './api.js';\n\ntype Values = NonNullable<ProbeResult['values']>;\n\nfunction read(values: Values, ref: ControlRef): boolean | number | string | undefined {\n return values[ref.component]?.[ref.control];\n}\n\n// Such as \"21.5 \u00B0C\" or \"Open\".\nfunction describeSensor(feature: SensorFeature, value: boolean | number | string, values: Values): string {\n if (feature.kind === 'temperature') {\n const unit = getTemperatureUnit(values, feature);\n return `${String(value)} \u00B0${unit !== undefined && /^f/i.test(unit) ? 'F' : 'C'}`;\n }\n if (feature.kind === 'humidity') return `${String(value)} % humidity`;\n if (feature.kind === 'illuminance') return `${String(value)} lx`;\n const isDetected = value === true || value === 1 || value === 'true';\n if (feature.kind === 'occupancy') return isDetected ? 'Motion' : 'No motion';\n if (feature.kind === 'contact') return isDetected ? 'Open' : 'Closed';\n return isDetected ? 'Water leak' : 'No leak';\n}\n\n/**\n * Describe what a device reports, such as \"Outlet 1 on, Outlet 2 off, 12.3 W, 230 V\" or \"On at 50 %\"\n *\n * @param {DeviceFeatures | undefined} features What the device can show.\n * @param {Values | undefined} values The controls it reported.\n * @returns {string} The description, or an empty text when it reported none of them.\n */\nexport function describeReadings(features: DeviceFeatures | undefined, values: Values | undefined): string {\n if (features === undefined || values === undefined) return '';\n const parts: string[] = [];\n for (const light of features.lights) {\n const value = read(values, light);\n if (typeof value !== 'boolean') continue;\n const name = features.lights.length === 1 ? (value ? 'On' : 'Off') : `${light.label} ${value ? 'on' : 'off'}`;\n // The brightness of the colour while the light shows its colour, else that of its white: the level Matter shows.\n const brightness = getBrightness(light, isShowingColor(light, values));\n const level = brightness === undefined ? undefined : read(values, { component: light.component, control: brightness.control });\n const percent = brightness !== undefined && typeof level === 'number' ? Math.round(((level - brightness.min) / (brightness.max - brightness.min)) * 100) : undefined;\n parts.push(percent === undefined || !value ? name : `${name} at ${Math.max(percent, 1)} %`);\n }\n const isSingleOutlet = features.outlets.length === 1;\n for (const outlet of features.outlets) {\n const value = read(values, outlet);\n if (typeof value === 'boolean') parts.push(isSingleOutlet ? (value ? 'On' : 'Off') : `${outlet.label} ${value ? 'on' : 'off'}`);\n }\n for (const sensor of features.sensors) {\n const value = read(values, sensor);\n if (value !== undefined) parts.push(describeSensor(sensor, value, values));\n }\n const { meter } = features;\n for (const reading of [meter?.power, meter?.voltage, meter?.current, meter?.energy]) {\n if (reading === undefined) continue;\n const value = read(values, reading);\n if (typeof value === 'number') parts.push(`${value} ${reading.unit}`);\n }\n if (features.battery !== undefined) {\n const value = read(values, features.battery);\n if (typeof value === 'number') parts.push(`battery ${value} %`);\n }\n return parts.join(', ');\n}\n", "/**\n * @file apps/frontend/src/screens/home.ts\n * @description The home of the setup page: the account, and the devices set up with how each is doing.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState, openOptions, reconnectDevice, removeDevice, search, signOut, startQueue, startSignIn } from '../actions.js';\nimport { dataCenterNames, meterFeatureId, type StoredDevice } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { draftFromStored, hasMeter, mainFeatureId } from '../drafts.js';\nimport { describeReadings } from '../readings.js';\nimport { render } from '../render.js';\nimport { view } from '../state.js';\n\nfunction joinList(parts: readonly string[]): string {\n return parts.length <= 1 ? (parts[0] ?? '') : `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;\n}\n\n// Such as \"an outlet, Outlet 2 and Outlet 3, the meter and a switch for the child lock, all as one device\", or \"a light and Light 2\".\nfunction describeExposure(device: StoredDevice): string {\n const { features } = device;\n if (features === undefined) return 'as it was set up';\n const main = mainFeatureId(features);\n const isShown = (id: string): boolean => id !== main && !device.hiddenFeatures.includes(id);\n const lights = features.lights.filter((light) => isShown(light.id)).map((light) => light.label);\n const outlets = features.outlets.filter((outlet) => isShown(outlet.id)).map((outlet) => outlet.label);\n const sensors = features.sensors.filter((sensor) => isShown(sensor.id)).map((sensor) => sensor.label.toLowerCase());\n const settings = features.settingSwitches.filter((setting) => device.addedFeatures.includes(setting.id)).map((setting) => setting.label.toLowerCase());\n let first = `a ${features.sensors[0]?.label.toLowerCase() ?? ''} sensor`;\n if (features.lights.length > 0) first = 'a light';\n else if (features.outlets.length > 0) first = 'an outlet';\n const parts = [first];\n if (lights.length > 0) parts.push(joinList(lights));\n if (outlets.length > 0) parts.push(joinList(outlets));\n if (hasMeter(features) && !device.hiddenFeatures.includes(meterFeatureId)) parts.push('the meter');\n if (sensors.length > 0) parts.push(`a sensor for the ${joinList(sensors)}`);\n if (settings.length > 0) parts.push(`a switch for the ${joinList(settings)}`);\n if (features.battery !== undefined) parts.push('its battery');\n const isSeveral = parts.length > 1 || lights.length > 1 || outlets.length > 1;\n return `${joinList(parts)}${isSeveral ? (device.isComposed ? ', all as one device' : ', each a device of its own') : ''}`;\n}\n\n// Where a device that is online is reached.\nconst routeNames = { lan: ' on your network', cloud: ' through the Tuya cloud' } as const;\n\n// A device that answers through the cloud was not reached on the LAN, where the plugin tries it first.\nfunction routeLine(device: StoredDevice): Child {\n if (device.status !== 'online' || device.route !== 'cloud' || device.isCloudOnly === true) return null;\n if (device.hasLan) {\n return h('p', { class: 'meta' }, 'It did not answer on your network, so the plugin reaches it through the Tuya cloud.');\n }\n return h(\n 'p',\n { class: 'meta' },\n 'It was not heard on your network, so the plugin reaches it through the Tuya cloud. Where the plugin cannot hear it, such as on another subnet, enter its IP address in its options.',\n );\n}\n\nfunction deviceRow(device: StoredDevice): HTMLElement {\n const online = `Online${device.route === undefined ? '' : routeNames[device.route]}`;\n const statusText = { online, connecting: 'Connecting\u2026', offline: 'Not answering', stopped: 'Not started' }[device.status];\n const isConfirming = view.confirmingRemoval === device.deviceId;\n const product = device.productName ?? `product ${device.productKey}`;\n const readings = device.status === 'online' ? describeReadings(device.features, device.values) : '';\n return h(\n 'li',\n { class: 'device' },\n h(\n 'div',\n { class: 'device-main' },\n h('h3', {}, device.name),\n h('p', { class: 'meta' }, h('span', { class: `status ${device.status}` }, statusText), ` ${product}, ${device.deviceId}. In Matter: ${describeExposure(device)}.`),\n readings === '' ? null : h('p', { class: 'meta readings' }, `${readings}.`),\n routeLine(device),\n device.status !== 'online' && device.error ? h('p', { class: 'meta problem-text' }, device.error) : null,\n device.needsRestart\n ? h('p', { class: 'meta' }, h('strong', {}, 'Restart Matterbridge'), ' to apply the new options in Matter. Until then it keeps its current endpoints.')\n : null,\n ),\n isConfirming\n ? h(\n 'div',\n { class: 'actions' },\n h('span', { class: 'meta' }, 'Remove it from Matter too?'),\n button('Remove', () => void removeDevice(device), 'danger'),\n button('Keep', () => {\n view.confirmingRemoval = '';\n render();\n }),\n )\n : h(\n 'div',\n { class: 'actions' },\n // A device whose entry this version no longer has is checked again to find one, which takes an account.\n device.features === undefined\n ? button('Set up again', () => startQueue([draftFromStored(device)]), 'quiet', view.setup?.account === undefined)\n : button('Options', () => openOptions(device), 'quiet'),\n device.features !== undefined && (device.status === 'offline' || device.status === 'stopped') ? button('Reconnect', () => void reconnectDevice(device), 'quiet') : null,\n button('Remove', () => {\n view.confirmingRemoval = device.deviceId;\n render();\n }),\n ),\n );\n}\n\nfunction accountPanel(): Child {\n const account = view.setup?.account;\n if (view.setup === undefined) return null;\n if (account === undefined) {\n return h(\n 'section',\n { class: 'account' },\n h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n 'No Tuya account is signed in. The devices below stay in Matter and are reached on your network alone, and new devices cannot be added, until you sign in.',\n ),\n button('Sign in', startSignIn, 'primary'),\n );\n }\n const signedIn =\n account.type === 'smartLife'\n ? `Signed in with the Smart Life app (User Code ${account.userCode}).`\n : `Signed in to the Tuya developer platform (project ${account.accessId}, data center ${dataCenterNames[account.dataCenter]}).`;\n const actions = view.confirmingSignOut\n ? [\n h('span', { class: 'meta' }, 'The devices stay in Matter, and keep working on your network.'),\n button('Sign out', () => void signOut(), 'danger'),\n button('Stay signed in', () => {\n view.confirmingSignOut = false;\n render();\n }),\n ]\n : [\n button(account.needsSignIn ? 'Sign in again' : 'Switch account', startSignIn, account.needsSignIn ? 'primary' : 'quiet'),\n button('Sign out', () => {\n view.confirmingSignOut = true;\n render();\n }),\n ];\n return h(\n 'section',\n { class: 'account' },\n h('p', { class: 'meta' }, signedIn),\n account.needsSignIn\n ? h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n 'The Tuya cloud no longer accepts this sign in. Sign in again to keep the devices reachable through the cloud and to add more.',\n )\n : null,\n h('div', { class: 'actions' }, ...actions),\n );\n}\n\nfunction discoveryNotice(): Child {\n const problem = view.setup?.discoveryError;\n if (problem === undefined) return null;\n return h(\n 'p',\n { class: 'notice problem', role: 'alert' },\n `The plugin does not listen for devices on your network, so it reaches them through the Tuya cloud, or at the host given in their options: ${problem}`,\n );\n}\n\n/**\n * Draw the home screen: the account, and the stored devices with how each is doing\n *\n * @returns {Child[]} The screen.\n */\nexport function homeScreen(): Child[] {\n const devices = view.setup?.devices ?? [];\n const canAdd = view.setup?.account !== undefined && !view.setup.account.needsSignIn;\n return [\n h('header', {}, h('h1', {}, 'Tuya devices'), canAdd ? button('Add devices', () => void search(), 'primary') : null),\n notice(),\n accountPanel(),\n discoveryNotice(),\n devices.length === 0 && view.setup\n ? h('p', { class: 'empty' }, 'No device is set up yet. Add one to control it from Matter.')\n : h('ul', { class: 'devices' }, ...devices.map(deviceRow)),\n view.setup ? null : button('Try again', () => void loadState(), 'primary'),\n ];\n}\n", "/**\n * @file apps/frontend/src/screens/options.ts\n * @description The Options step: the name of the device in Matter, which of its features appear there, and how it is reached.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { goHome, saveDraft } from '../actions.js';\nimport { type DeviceFeatures, type LanVersion, lanVersions, meterFeatureId } from '../api.js';\nimport { button, notice, steps, unitHeader, unitStrip } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { hasMeter, mainFeatureId } from '../drafts.js';\nimport { describeReadings } from '../readings.js';\nimport { render } from '../render.js';\nimport { currentDraft, deviceLabel, type Draft } from '../state.js';\n\nconst sensorKindNames = {\n temperature: 'temperature sensor',\n humidity: 'humidity sensor',\n illuminance: 'light sensor',\n occupancy: 'motion sensor',\n contact: 'contact sensor',\n waterLeak: 'water leak detector',\n} as const;\n\nfunction toggle(id: string, isOn: boolean, title: string, text: string, onpick: (isOn: boolean) => void): HTMLElement {\n const input = h('input', { type: 'checkbox', id, checked: isOn, onchange: () => onpick(input.checked) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction radio<T extends string>(group: string, value: T, current: T, title: string, text: string, onpick: (value: T) => void): HTMLElement {\n const id = `${group}-${value}`;\n const input = h('input', { type: 'radio', name: group, id, checked: value === current, onchange: () => onpick(value) });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\n// A part of the main device has no name of its own in Matter: it is tagged with what it is.\nfunction placement(draft: Draft, label: string): string {\n return draft.isComposed ? `It appears as a part of \"${draft.name}\", tagged \"${label}\".` : `It appears as \"${draft.name} ${label}\".`;\n}\n\nfunction setShown(list: string[], id: string, isShown: boolean): string[] {\n const without = list.filter((candidate) => candidate !== id);\n return isShown ? [...without, id] : without;\n}\n\n// Redrawn as it is typed, so that the texts that name the device follow. A redraw when the field is left instead would\n// replace the button the click leaving it is on, and lose that click.\nfunction nameSection(draft: Draft): HTMLElement {\n const input = h('input', { type: 'text', id: 'device-name', value: draft.name, maxLength: 32, autocomplete: 'off', spellcheck: false });\n input.addEventListener('input', (event) => {\n draft.name = input.value.trim();\n // A redraw in the middle of a composition, such as of Japanese text, would end it.\n if (!(event as InputEvent).isComposing) render();\n });\n const cloudName = draft.device.cloudName;\n const cloudText = cloudName === undefined ? '' : `Its name in the Smart Life app is \"${cloudName}\". `;\n return h(\n 'section',\n {},\n h('h2', {}, h('label', { for: 'device-name' }, 'Name in Matter')),\n h(\n 'p',\n { class: 'help' },\n `${cloudText}The name here is what your Matter apps show, up to 32 characters, and no two devices of this plugin share one. A new name in the Smart Life app does not change it.`,\n ),\n h('div', { class: 'inline-form' }, input),\n );\n}\n\nfunction featureSection(draft: Draft, features: DeviceFeatures): HTMLElement {\n const main = mainFeatureId(features);\n const mainFeature = [...features.lights, ...features.outlets, ...features.sensors].find((feature) => feature.id === main);\n const items: Child[] = [];\n for (const light of features.lights) {\n if (light.id === main) continue;\n items.push(\n toggle(`feature-${light.id}`, !draft.hiddenFeatures.includes(light.id), light.label, `A light. ${placement(draft, light.label)}`, (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, light.id, !isShown);\n render();\n }),\n );\n }\n for (const outlet of features.outlets) {\n if (outlet.id === main) continue;\n items.push(\n toggle(`feature-${outlet.id}`, !draft.hiddenFeatures.includes(outlet.id), outlet.label, `An on/off outlet. ${placement(draft, outlet.label)}`, (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, outlet.id, !isShown);\n render();\n }),\n );\n }\n const { meter } = features;\n if (meter !== undefined && hasMeter(features)) {\n const measures = [meter.power && 'power', meter.voltage && 'voltage', meter.current && 'current', meter.energy && 'energy used'].filter((name) => typeof name === 'string');\n items.push(\n toggle(\n 'feature-meter',\n !draft.hiddenFeatures.includes(meterFeatureId),\n 'Meter',\n `The ${measures.join(', ')} of \"${draft.name}\", which few Matter apps show yet: Home Assistant does.`,\n (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, meterFeatureId, !isShown);\n render();\n },\n ),\n );\n }\n for (const sensor of features.sensors) {\n if (sensor.id === main) continue;\n items.push(\n toggle(`feature-${sensor.id}`, !draft.hiddenFeatures.includes(sensor.id), sensor.label, `A ${sensorKindNames[sensor.kind]}. ${placement(draft, sensor.label)}`, (isShown) => {\n draft.hiddenFeatures = setShown(draft.hiddenFeatures, sensor.id, !isShown);\n render();\n }),\n );\n }\n for (const setting of features.settingSwitches) {\n items.push(\n toggle(\n `feature-${setting.id}`,\n draft.addedFeatures.includes(setting.id),\n setting.label,\n `A switch for a setting of the device. ${placement(draft, setting.label)}`,\n (isShown) => {\n draft.addedFeatures = setShown(draft.addedFeatures, setting.id, isShown);\n render();\n },\n ),\n );\n }\n const mainText = mainFeature === undefined ? '' : `${mainFeature.label} is the device itself in Matter, and always appears there. `;\n return h(\n 'section',\n {},\n h('h2', {}, 'What appears in Matter'),\n h('p', { class: 'help' }, items.length === 0 ? `${mainText}The device has nothing else to show.` : `${mainText}Choose what else appears with it.`),\n items.length === 0 ? null : h('div', { class: 'choices' }, ...items),\n );\n}\n\nfunction composedSection(draft: Draft): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', {}, 'One device or several'),\n h('p', { class: 'help' }, 'The other lights, the outlets, the sensors and the switches can be parts of the device in Matter, or devices of their own beside it.'),\n h(\n 'div',\n { class: 'choices' },\n toggle(\n 'composed',\n draft.isComposed,\n 'Show it as one device',\n `Your Matter app has one device, \"${draft.name}\", and its parts move between rooms with it. A part has no name of its own in Matter, so an app may show the outlets as numbered outlets, and an app that shows no parts shows the device alone. Turned off, each is a device of its own with its own name, which your app puts in a room by itself.`,\n (isComposed) => {\n draft.isComposed = isComposed;\n render();\n },\n ),\n ),\n );\n}\n\n// The host and the version are read as they are typed, with no redraw: no other text on the page names them.\nfunction hostFields(draft: Draft): HTMLElement {\n const host = h('input', {\n type: 'text',\n id: 'device-host',\n value: draft.host,\n placeholder: 'Leave empty to find it on your network',\n maxLength: 253,\n autocomplete: 'off',\n spellcheck: false,\n });\n host.addEventListener('input', () => {\n draft.host = host.value.trim();\n });\n const version = h(\n 'select',\n {\n id: 'device-version',\n onchange: () => {\n draft.version = version.value as LanVersion | '';\n },\n },\n h('option', { value: '', selected: draft.version === '' }, 'Not set'),\n ...lanVersions.map((value) => h('option', { value, selected: value === draft.version }, value)),\n );\n return h(\n 'div',\n { class: 'field' },\n h('label', { for: 'device-host' }, 'IP address or host name (optional)'),\n h(\n 'p',\n { class: 'help' },\n 'Most devices need neither of these: leave both empty, and the plugin finds the device by the broadcasts it sends. Only where it does not hear the device on your network, such as on another subnet or in a Docker container without host networking, enter its IP address, ideally one your router keeps for it, and the protocol version it speaks, which the Smart Life app does not show: tinytuya or tuya-local tell it. For a device behind a gateway, enter those of the gateway.',\n ),\n h('div', { class: 'inline-form' }, host),\n h('label', { for: 'device-version' }, 'Protocol version (only with an IP address or host name)'),\n version,\n );\n}\n\nfunction connectionSection(draft: Draft): HTMLElement {\n const pick = (value: 'lan' | 'cloud'): void => {\n draft.isCloudOnly = value === 'cloud';\n render();\n };\n const current = draft.isCloudOnly ? 'cloud' : 'lan';\n const probeRoute = draft.probe?.route;\n let routeNote = '';\n if (probeRoute === 'lan') routeNote = ' It answered on your network just now.';\n else if (probeRoute === 'cloud') routeNote = ' It answered through the Tuya cloud just now: the plugin switches to your network once it hears the device there.';\n return h(\n 'section',\n {},\n h('h2', { id: 'connection-title' }, 'Connection'),\n h('p', { class: 'help' }, `How the plugin reaches the device.${routeNote}`),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'connection-title' },\n radio(\n 'connection',\n 'lan',\n current,\n 'On your network first, through the Tuya cloud otherwise',\n 'The plugin hears the device on your network by the broadcasts it sends, and follows it to a new IP address. It keeps working while the Tuya cloud or the internet is down.',\n pick,\n ),\n radio('connection', 'cloud', current, 'Through the Tuya cloud only', 'For a device that is not on the network of Matterbridge.', pick),\n ),\n draft.isCloudOnly ? null : hostFields(draft),\n );\n}\n\n/**\n * Draw the Options step: the name, the features, the layout and the connection of the device the run is on\n *\n * @returns {Child[]} The screen.\n */\nexport function optionsScreen(): Child[] {\n const draft = currentDraft();\n if (draft === undefined) return [notice()];\n const features = draft.features ?? { lights: [], outlets: [], settingSwitches: [], sensors: [] };\n const readings = describeReadings(draft.features, draft.values);\n return [\n steps(),\n unitStrip(),\n unitHeader(draft, `Options for the ${deviceLabel(draft.device, draft.productName)}.`),\n readings === '' ? null : h('p', { class: 'meta readings' }, `It reports: ${readings}.`),\n nameSection(draft),\n featureSection(draft, features),\n composedSection(draft),\n connectionSection(draft),\n draft.isNew\n ? null\n : h(\n 'p',\n { class: 'help' },\n 'Changing what appears in Matter, or whether it is one device, takes effect at the next restart of Matterbridge, which this page and Matterbridge ask for. Until then the device keeps its current endpoints. The name and the connection change at once.',\n ),\n notice(),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', goHome),\n button(draft.isNew ? `Add ${draft.name}` : 'Save options', () => void saveDraft(draft), 'primary'),\n ),\n ];\n}\n", "/**\n * @file apps/frontend/src/qr.ts\n * @description Draws the QR code the Smart Life app scans to sign in.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport qrcode from 'qrcode-generator';\n\nimport { h } from './dom.js';\n\n/**\n * Draw a text as a QR code\n *\n * @param {string} text The text, such as the one the plugin gives for the sign in.\n * @returns {HTMLElement} The QR code, as a scalable drawing in a light box.\n */\nexport function qrCodeElement(text: string): HTMLElement {\n // Type 0 picks the smallest QR code the text fits in, at the middle level of error correction.\n const code = qrcode(0, 'M');\n code.addData(text);\n code.make();\n // The drawing is made by the library from the text alone, never markup: innerHTML is safe for it.\n return h('div', { 'class': 'qr', 'role': 'img', 'aria-label': 'QR code to scan with the Smart Life app', 'html': code.createSvgTag({ cellSize: 4, margin: 2, scalable: true }) });\n}\n", "/**\n * @file apps/frontend/src/screens/signIn.ts\n * @description The sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { cancelQrCode, goHome, requestQrCode, signInDeveloper } from '../actions.js';\nimport { type DataCenter, dataCenterNames } from '../api.js';\nimport { button, notice } from '../components.js';\nimport { type Child, h } from '../dom.js';\nimport { qrCodeElement } from '../qr.js';\nimport { render } from '../render.js';\nimport { type SignIn, view } from '../state.js';\n\nfunction methodChoice(method: SignIn['method'], title: string, text: string): HTMLElement {\n const id = `method-${method}`;\n const input = h('input', {\n type: 'radio',\n name: 'method',\n id,\n checked: view.signIn.method === method,\n onchange: () => {\n view.signIn.method = method;\n view.error = '';\n render();\n },\n });\n return h('label', { class: 'choice', for: id }, input, h('span', {}, h('strong', {}, title), h('span', { class: 'meta' }, text)));\n}\n\nfunction methodSection(): HTMLElement {\n return h(\n 'section',\n {},\n h('h2', { id: 'method-title' }, 'How to sign in'),\n h(\n 'div',\n { 'class': 'choices', 'role': 'radiogroup', 'aria-labelledby': 'method-title' },\n methodChoice('smartLife', 'With the Smart Life app (recommended)', 'Scan a QR code with the Smart Life or Tuya Smart app your devices are in. Nothing to set up first.'),\n methodChoice(\n 'developer',\n 'With a cloud project of the Tuya developer platform',\n 'For a project you made on platform.tuya.com, with your app account linked to it. Its IoT Core trial has to be extended from time to time.',\n ),\n ),\n );\n}\n\nfunction userCodeForm(): Child[] {\n const input = h('input', { type: 'text', id: 'user-code', value: view.signIn.userCode, maxLength: 32, autocomplete: 'off', spellcheck: false });\n const submit = (): void => {\n const userCode = input.value.trim();\n if (userCode !== '') void requestQrCode(userCode);\n };\n input.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') submit();\n });\n return [\n h(\n 'div',\n { class: 'field' },\n h('label', { for: 'user-code' }, 'User Code'),\n h('p', { class: 'help' }, 'In the Smart Life app, open Me, then the settings, then Account and Security: the User Code is listed there. It is case-sensitive.'),\n h('div', { class: 'inline-form' }, input),\n ),\n h('div', { class: 'footer' }, button('Cancel', goHome), button('Show the QR code', submit, 'primary')),\n ];\n}\n\nfunction qrPanel(qrCode: string): Child[] {\n return [\n h('p', { class: 'lead' }, 'In the Smart Life app, tap the scan icon at the top of the home tab, scan this code, and confirm the sign in in the app.'),\n qrCodeElement(qrCode),\n h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Waiting for the app to confirm\u2026'),\n h('p', { class: 'help' }, 'The plugin signs in as Home Assistant does, so the app may name Home Assistant. The code stays valid for a few minutes.'),\n h(\n 'div',\n { class: 'footer' },\n button('Cancel', () => void cancelQrCode()),\n ),\n ];\n}\n\nfunction smartLifeForm(): Child[] {\n const { login } = view;\n if (login.status === 'waiting' && login.qrCode !== undefined) return qrPanel(login.qrCode);\n const problem =\n login.status === 'expired'\n ? 'The QR code was not scanned in time. Show a new one to try again.'\n : login.status === 'failed'\n ? `The sign in did not work: ${login.message ?? 'unknown'}`\n : '';\n return [problem === '' ? null : h('p', { class: 'notice problem', role: 'alert' }, problem), ...userCodeForm()];\n}\n\nfunction developerForm(): Child[] {\n const accessId = h('input', { type: 'text', id: 'access-id', value: view.signIn.accessId, maxLength: 128, autocomplete: 'username', spellcheck: false });\n const accessSecret = h('input', { type: 'password', id: 'access-secret', maxLength: 128, autocomplete: 'current-password' });\n const dataCenter = h(\n 'select',\n { id: 'data-center' },\n ...(Object.keys(dataCenterNames) as DataCenter[]).map((code) => h('option', { value: code, selected: code === view.signIn.dataCenter }, `${dataCenterNames[code]} (${code})`)),\n );\n const submit = (): void => {\n if (accessId.value.trim() === '' || accessSecret.value.trim() === '') return;\n void signInDeveloper(accessId.value.trim(), accessSecret.value.trim(), dataCenter.value as DataCenter);\n };\n accessSecret.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') submit();\n });\n return [\n h(\n 'p',\n { class: 'help' },\n 'The cloud project needs your Smart Life account linked to it, under Devices > Link App Account, and the IoT Core service. Its Access ID and Access Secret are on its overview page.',\n ),\n h('div', { class: 'field' }, h('label', { for: 'access-id' }, 'Access ID'), accessId),\n h('div', { class: 'field' }, h('label', { for: 'access-secret' }, 'Access Secret'), h('p', { class: 'help' }, 'It is kept in the configuration of the plugin.'), accessSecret),\n h(\n 'div',\n { class: 'field' },\n h('label', { for: 'data-center' }, 'Data center'),\n h('p', { class: 'help' }, 'The data center of your app account, which the project lists under Devices.'),\n dataCenter,\n ),\n h('div', { class: 'footer' }, button('Cancel', goHome), button('Sign in', submit, 'primary')),\n ];\n}\n\n/**\n * Draw the sign in: by QR code with the Smart Life app, or with a cloud project of the Tuya developer platform\n *\n * @returns {Child[]} The screen.\n */\nexport function signInScreen(): Child[] {\n const isAgain = view.setup?.account !== undefined;\n const isWaiting = view.login.status === 'waiting';\n return [\n h('header', {}, h('h1', {}, isAgain ? 'Sign in to Tuya again' : 'Sign in to Tuya')),\n h(\n 'p',\n { class: 'lead' },\n 'The plugin lists your devices and gets the key each one encrypts its traffic with from the Tuya cloud, then reaches them on your network first. Your password is never asked for.',\n ),\n notice(),\n isWaiting ? null : methodSection(),\n ...(view.signIn.method === 'smartLife' ? smartLifeForm() : developerForm()),\n ];\n}\n", "/**\n * @file apps/frontend/src/theme.ts\n * @description Makes the setup page look like the Matterbridge page it is shown in.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Take the colours and the font of the Matterbridge page this one is shown in\n *\n * @returns {void}\n */\nexport function adoptHostTheme(): void {\n try {\n if (window.parent === window) return;\n const host = getComputedStyle(window.parent.document.body);\n for (const name of ['--primary-color', '--div-bg-color', '--div-text-color', '--main-bg-color', '--main-label-color', '--div-border-color', '--main-light-color']) {\n const value = host.getPropertyValue(name).trim();\n if (value !== '') document.documentElement.style.setProperty(`--host${name.slice(1)}`, value);\n }\n document.documentElement.style.setProperty('--host-font', host.fontFamily);\n } catch {\n // Opened on its own or from another origin: the page keeps its own colours.\n }\n}\n", "/**\n * @file apps/frontend/src/app.ts\n * @description The guided setup page of the Matterbridge Open Tuya plugin. Matterbridge serves it at\n * /plugins/matterbridge-open-tuya/ and it talks to the plugin through api/<path> below that address.\n * This file starts the page: the rest is in the files next to it.\n * @author Calvin Che\n * @created 2026-10-29\n * @version 1.0.0\n * @license Apache-2.0\n *\n * Copyright 2026 Calvin Che.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadState } from './actions.js';\nimport { h } from './dom.js';\nimport { render, setScreens } from './render.js';\nimport { connectScreen } from './screens/connect.js';\nimport { doneScreen } from './screens/done.js';\nimport { findScreen } from './screens/find.js';\nimport { homeScreen } from './screens/home.js';\nimport { optionsScreen } from './screens/options.js';\nimport { signInScreen } from './screens/signIn.js';\nimport { adoptHostTheme } from './theme.js';\n\nsetScreens({\n loading: () => [h('p', { class: 'notice working', role: 'status' }, h('span', { class: 'spinner' }), 'Loading\u2026')],\n home: homeScreen,\n signIn: signInScreen,\n find: findScreen,\n connect: connectScreen,\n options: optionsScreen,\n done: doneScreen,\n});\n\nadoptHostTheme();\nrender();\nvoid loadState();\n"],
|
|
5
|
+
"mappings": "2jBAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAiBA,IAAIC,IAAS,UAAW,CAWtB,IAAIA,EAAS,SAASC,EAAYC,EAAsB,CAEtD,IAAIC,EAAO,IACPC,EAAO,GAEPC,EAAcJ,EACdK,EAAwBC,EAAuBL,CAAoB,EACnEM,EAAW,KACXC,EAAe,EACfC,EAAa,KACbC,EAAY,CAAC,EAEbC,EAAQ,CAAC,EAETC,EAAW,SAASC,EAAMC,EAAa,CAEzCN,EAAeJ,EAAc,EAAI,GACjCG,GAAW,SAASQ,EAAa,CAE/B,QADIC,EAAU,IAAI,MAAMD,CAAW,EAC1BE,EAAM,EAAGA,EAAMF,EAAaE,GAAO,EAAG,CAC7CD,EAAQC,CAAG,EAAI,IAAI,MAAMF,CAAW,EACpC,QAASG,EAAM,EAAGA,EAAMH,EAAaG,GAAO,EAC1CF,EAAQC,CAAG,EAAEC,CAAG,EAAI,IAExB,CACA,OAAOF,CACT,GAAER,CAAY,EAEdW,EAA0B,EAAG,CAAC,EAC9BA,EAA0BX,EAAe,EAAG,CAAC,EAC7CW,EAA0B,EAAGX,EAAe,CAAC,EAC7CY,EAA2B,EAC3BC,EAAmB,EACnBC,EAAcT,EAAMC,CAAW,EAE3BV,GAAe,GACjBmB,EAAgBV,CAAI,EAGlBJ,GAAc,OAChBA,EAAae,GAAWpB,EAAaC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AAY,SAASD,EAAK,MAAM,CAAC,CAAC,GAAIC,CAAK,CAC9F,CACA,SAAS,gBAAgB,MAAM,YAAY,cAAeF,EAAK,UAAU,CAC3E,MAAQ,CAER,CACF,CCJAG,GAAW,CACT,QAAS,IAAM,CAACC,EAAE,IAAK,CAAE,MAAO,iBAAkB,KAAM,QAAS,EAAGA,EAAE,OAAQ,CAAE,MAAO,SAAU,CAAC,EAAG,eAAU,CAAC,EAChH,KAAMC,GACN,OAAQC,GACR,KAAMC,GACN,QAASC,GACT,QAASC,GACT,KAAMC,EACR,CAAC,EAEDC,GAAe,EACfC,EAAO,EACFC,GAAU",
|
|
6
|
+
"names": ["require_qrcode", "__commonJSMin", "exports", "module", "qrcode", "typeNumber", "errorCorrectionLevel", "PAD0", "PAD1", "_typeNumber", "_errorCorrectionLevel", "QRErrorCorrectionLevel", "_modules", "_moduleCount", "_dataCache", "_dataList", "_this", "makeImpl", "test", "maskPattern", "moduleCount", "modules", "row", "col", "setupPositionProbePattern", "setupPositionAdjustPattern", "setupTimingPattern", "setupTypeInfo", "setupTypeNumber", "createData", "mapData", "r", "c", "getBestMaskPattern", "minLostPoint", "pattern", "i", "lostPoint", "QRUtil", "pos", "j", "bits", "mod", "data", "inc", "bitIndex", "byteIndex", "maskFunc", "dark", "mask", "createBytes", "buffer", "rsBlocks", "offset", "maxDcCount", "maxEcCount", "dcdata", "ecdata", "dcCount", "ecCount", "rsPoly", "rawPoly", "qrPolynomial", "modPoly", "modIndex", "totalCodeCount", "index", "dataList", "QRRSBlock", "qrBitBuffer", "totalDataCount", "mode", "newData", "qrNumber", "qrAlphaNum", "qr8BitByte", "qrKanji", "cellSize", "margin", "qrHtml", "alt", "title", "opts", "size", "mc", "mr", "qrSvg", "rect", "escapeXml", "min", "max", "createDataURL", "x", "y", "img", "s", "escaped", "_createHalfASCII", "r1", "r2", "p", "blocks", "blocksLastLineNoMargin", "ascii", "white", "black", "line", "context", "length", "bytes", "unicodeData", "numChars", "unicodeMap", "bin", "base64DecodeInputStream", "read", "b", "count", "b0", "b1", "b2", "b3", "k", "v", "unknownChar", "QRMode", "QRMaskPattern", "PATTERN_POSITION_TABLE", "G15", "G18", "G15_MASK", "getBCHDigit", "digit", "d", "errorCorrectLength", "a", "QRMath", "type", "sameCount", "darkCount", "ratio", "EXP_TABLE", "LOG_TABLE", "n", "num", "shift", "_num", "e", "RS_BLOCK_TABLE", "qrRSBlock", "totalCount", "dataCount", "getRsBlockTable", "rsBlock", "list", "_buffer", "_length", "bufIndex", "bit", "_mode", "_data", "strToNum", "chatToNum", "getCode", "_bytes", "stringToBytes", "code", "byteArrayOutputStream", "off", "len", "base64EncodeOutputStream", "_buflen", "_base64", "writeEncoded", "encode", "padlen", "str", "_str", "_pos", "decode", "gifImage", "width", "height", "_width", "_height", "pixel", "out", "lzwMinCodeSize", "raster", "getLZWRaster", "bitOutputStream", "_out", "_bitLength", "_bitBuffer", "clearCode", "endCode", "bitLength", "table", "lzwTable", "byteOut", "bitOut", "dataIndex", "_map", "_size", "key", "getPixel", "gif", "base64", "toUTF8Array", "utf8", "charcode", "factory", "dataCenterNames", "lanVersions", "meterFeatureId", "api", "route", "body", "method", "path", "init", "response", "reply", "view", "currentDraft", "draftLabel", "draft", "deviceLabel", "device", "productName", "product", "maxNameLength", "hasSameModel", "left", "right", "isFields", "names", "name", "value", "pickExposure", "source", "mainFeatureId", "features", "hasMeter", "outlet", "fitExposure", "exposure", "main", "shown", "feature", "id", "added", "uniqueName", "base", "taken", "trimmed", "count", "suffix", "draftsFromDevices", "devices", "view", "device", "listed", "draftFromStored", "screens", "setScreens", "all", "render", "root", "form", "view", "currentDraft", "isSameForm", "active", "activeId", "caret", "typed", "input", "child", "id", "value", "focused", "busy", "text", "task", "view", "render", "loadState", "reply", "api", "setSetup", "startSignIn", "search", "syncState", "connectingRefreshInMs", "connectingRefresh", "state", "device", "followConnecting", "hasChanged", "refreshState", "goHome", "stopQrPolling", "account", "qrPollIntervalInMs", "qrPoll", "requestQrCode", "userCode", "pollQrLogin", "login", "takeLogin", "afterSignIn", "cancelQrCode", "signInDeveloper", "accessId", "accessSecret", "dataCenter", "signOut", "startQueue", "drafts", "enterConnect", "openOptions", "draftFromStored", "reconnectDevice", "draft", "currentDraft", "check", "draftLabel", "result", "hasSameModel", "fitExposure", "pickExposure", "skipDraft", "skipped", "saveDraft", "name", "problem", "checkName", "checkHost", "hasHost", "saved", "reloadNote", "restartNote", "removeDevice", "h", "tag", "props", "children", "element", "key", "value", "child", "button", "label", "onclick", "kind", "disabled", "h", "view", "notice", "unitStrip", "current", "currentDraft", "doing", "unit", "draft", "index", "draftLabel", "unitHeader", "text", "steps", "names", "name", "state", "statusPanel", "draft", "status", "label", "message", "h", "button", "startSignIn", "connectScreen", "currentDraft", "notice", "canRetry", "view", "isOneOfMany", "steps", "unitStrip", "unitHeader", "deviceLabel", "check", "skipDraft", "goHome", "doneScreen", "names", "view", "needsRestart", "device", "h", "restartNote", "reloadNote", "button", "goHome", "isSelectable", "device", "notesOf", "notes", "deviceRow", "isAvailable", "id", "checkbox", "h", "view", "render", "note", "findScreen", "chosen", "continueLabel", "steps", "notice", "button", "search", "goHome", "startQueue", "draftsFromDevices", "isShowingColor", "light", "values", "getBrightness", "isColor", "getTemperatureUnit", "values", "feature", "unit", "read", "values", "ref", "describeSensor", "feature", "value", "unit", "getTemperatureUnit", "isDetected", "describeReadings", "features", "parts", "light", "name", "brightness", "getBrightness", "isShowingColor", "level", "percent", "isSingleOutlet", "outlet", "sensor", "meter", "reading", "joinList", "parts", "describeExposure", "device", "features", "main", "mainFeatureId", "isShown", "id", "lights", "light", "outlets", "outlet", "sensors", "sensor", "settings", "setting", "first", "hasMeter", "meterFeatureId", "isSeveral", "routeNames", "routeLine", "h", "deviceRow", "statusText", "isConfirming", "view", "product", "readings", "describeReadings", "button", "removeDevice", "render", "startQueue", "draftFromStored", "openOptions", "reconnectDevice", "accountPanel", "account", "startSignIn", "signedIn", "dataCenterNames", "actions", "signOut", "discoveryNotice", "problem", "homeScreen", "devices", "canAdd", "search", "notice", "loadState", "sensorKindNames", "toggle", "id", "isOn", "title", "text", "onpick", "input", "h", "radio", "group", "value", "current", "placement", "draft", "label", "setShown", "list", "isShown", "without", "candidate", "nameSection", "event", "render", "cloudName", "cloudText", "featureSection", "features", "main", "mainFeatureId", "mainFeature", "feature", "items", "light", "outlet", "meter", "hasMeter", "measures", "name", "meterFeatureId", "sensor", "setting", "mainText", "composedSection", "isComposed", "hostFields", "host", "version", "lanVersions", "connectionSection", "pick", "probeRoute", "routeNote", "optionsScreen", "currentDraft", "notice", "readings", "describeReadings", "steps", "unitStrip", "unitHeader", "deviceLabel", "button", "goHome", "saveDraft", "import_qrcode_generator", "qrCodeElement", "text", "code", "qrcode", "h", "methodChoice", "method", "title", "text", "id", "input", "h", "view", "render", "methodSection", "userCodeForm", "submit", "userCode", "requestQrCode", "event", "button", "goHome", "qrPanel", "qrCode", "qrCodeElement", "cancelQrCode", "smartLifeForm", "login", "problem", "developerForm", "accessId", "accessSecret", "dataCenter", "dataCenterNames", "code", "signInDeveloper", "signInScreen", "isAgain", "isWaiting", "notice", "adoptHostTheme", "host", "name", "value", "setScreens", "h", "homeScreen", "signInScreen", "findScreen", "connectScreen", "optionsScreen", "doneScreen", "adoptHostTheme", "render", "loadState"]
|
|
7
7
|
}
|