@linxin666/dsh-remote-bridge 0.4.21 → 0.4.23

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/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["React","Modal","css","Button","IconCloseOutlineRegular","IconWarningOutlineRegular","IconCheckOutlineRegular","IconCopyOutlineRegular","IconRefreshOutlineRegular","css","css","writeClipboard"],"sources":["../../../node_modules/.pnpm/qrcode.react@4.2.0_react@18.3.1/node_modules/qrcode.react/lib/esm/index.js","../../../packages/dsh-remote-bridge/src/core/pair-address.ts","../../../packages/dsh-remote-bridge/src/client/semantic.ts","../../../packages/dsh-remote-bridge/src/client/PairPanel.tsx","../../../packages/dsh-remote-bridge/src/client/icons.tsx","../../../packages/dsh-remote-bridge/src/client/PairEntry.tsx","../../../packages/dsh-remote-bridge/src/core/protocol.ts","../../../packages/dsh-remote-bridge/src/client/pair-token.ts","../../../packages/dsh-remote-bridge/src/core/ui.ts","../../../packages/dsh-remote-bridge/src/client/ui-card.ts","../../../packages/dsh-remote-bridge/src/client/UiPresentRow.tsx","../../../packages/dsh-remote-bridge/src/client/toolview-slot.ts","../../../packages/dsh-remote-bridge/src/client/locales.ts","../../../packages/dsh-remote-bridge/src/client/index.ts"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b)) {\n if (__propIsEnum.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n }\n return a;\n};\nvar __objRest = (source, exclude) => {\n var target = {};\n for (var prop in source)\n if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)\n target[prop] = source[prop];\n if (source != null && __getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(source)) {\n if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))\n target[prop] = source[prop];\n }\n return target;\n};\n\n// src/index.tsx\nimport React from \"react\";\n\n// src/third-party/qrcodegen/index.ts\n/**\n * @license QR Code generator library (TypeScript)\n * Copyright (c) Project Nayuki.\n * SPDX-License-Identifier: MIT\n */\nvar qrcodegen;\n((qrcodegen2) => {\n const _QrCode = class _QrCode {\n /*-- Constructor (low level) and fields --*/\n // Creates a new QR Code with the given version number,\n // error correction level, data codeword bytes, and mask number.\n // This is a low-level API that most users should not use directly.\n // A mid-level API is the encodeSegments() function.\n constructor(version, errorCorrectionLevel, dataCodewords, msk) {\n this.version = version;\n this.errorCorrectionLevel = errorCorrectionLevel;\n // The modules of this QR Code (false = light, true = dark).\n // Immutable after constructor finishes. Accessed through getModule().\n this.modules = [];\n // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.\n this.isFunction = [];\n if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION)\n throw new RangeError(\"Version value out of range\");\n if (msk < -1 || msk > 7)\n throw new RangeError(\"Mask value out of range\");\n this.size = version * 4 + 17;\n let row = [];\n for (let i = 0; i < this.size; i++)\n row.push(false);\n for (let i = 0; i < this.size; i++) {\n this.modules.push(row.slice());\n this.isFunction.push(row.slice());\n }\n this.drawFunctionPatterns();\n const allCodewords = this.addEccAndInterleave(dataCodewords);\n this.drawCodewords(allCodewords);\n if (msk == -1) {\n let minPenalty = 1e9;\n for (let i = 0; i < 8; i++) {\n this.applyMask(i);\n this.drawFormatBits(i);\n const penalty = this.getPenaltyScore();\n if (penalty < minPenalty) {\n msk = i;\n minPenalty = penalty;\n }\n this.applyMask(i);\n }\n }\n assert(0 <= msk && msk <= 7);\n this.mask = msk;\n this.applyMask(msk);\n this.drawFormatBits(msk);\n this.isFunction = [];\n }\n /*-- Static factory functions (high level) --*/\n // Returns a QR Code representing the given Unicode text string at the given error correction level.\n // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer\n // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible\n // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the\n // ecl argument if it can be done without increasing the version.\n static encodeText(text, ecl) {\n const segs = qrcodegen2.QrSegment.makeSegments(text);\n return _QrCode.encodeSegments(segs, ecl);\n }\n // Returns a QR Code representing the given binary data at the given error correction level.\n // This function always encodes using the binary segment mode, not any text mode. The maximum number of\n // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.\n // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.\n static encodeBinary(data, ecl) {\n const seg = qrcodegen2.QrSegment.makeBytes(data);\n return _QrCode.encodeSegments([seg], ecl);\n }\n /*-- Static factory functions (mid level) --*/\n // Returns a QR Code representing the given segments with the given encoding parameters.\n // The smallest possible QR Code version within the given range is automatically\n // chosen for the output. Iff boostEcl is true, then the ECC level of the result\n // may be higher than the ecl argument if it can be done without increasing the\n // version. The mask number is either between 0 to 7 (inclusive) to force that\n // mask, or -1 to automatically choose an appropriate mask (which may be slow).\n // This function allows the user to create a custom sequence of segments that switches\n // between modes (such as alphanumeric and byte) to encode text in less space.\n // This is a mid-level API; the high-level API is encodeText() and encodeBinary().\n static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {\n if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7)\n throw new RangeError(\"Invalid value\");\n let version;\n let dataUsedBits;\n for (version = minVersion; ; version++) {\n const dataCapacityBits2 = _QrCode.getNumDataCodewords(version, ecl) * 8;\n const usedBits = QrSegment.getTotalBits(segs, version);\n if (usedBits <= dataCapacityBits2) {\n dataUsedBits = usedBits;\n break;\n }\n if (version >= maxVersion)\n throw new RangeError(\"Data too long\");\n }\n for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) {\n if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version, newEcl) * 8)\n ecl = newEcl;\n }\n let bb = [];\n for (const seg of segs) {\n appendBits(seg.mode.modeBits, 4, bb);\n appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);\n for (const b of seg.getData())\n bb.push(b);\n }\n assert(bb.length == dataUsedBits);\n const dataCapacityBits = _QrCode.getNumDataCodewords(version, ecl) * 8;\n assert(bb.length <= dataCapacityBits);\n appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);\n appendBits(0, (8 - bb.length % 8) % 8, bb);\n assert(bb.length % 8 == 0);\n for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)\n appendBits(padByte, 8, bb);\n let dataCodewords = [];\n while (dataCodewords.length * 8 < bb.length)\n dataCodewords.push(0);\n bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));\n return new _QrCode(version, ecl, dataCodewords, mask);\n }\n /*-- Accessor methods --*/\n // Returns the color of the module (pixel) at the given coordinates, which is false\n // for light or true for dark. The top left corner has the coordinates (x=0, y=0).\n // If the given coordinates are out of bounds, then false (light) is returned.\n getModule(x, y) {\n return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];\n }\n // Modified to expose modules for easy access\n getModules() {\n return this.modules;\n }\n /*-- Private helper methods for constructor: Drawing function modules --*/\n // Reads this object's version field, and draws and marks all function modules.\n drawFunctionPatterns() {\n for (let i = 0; i < this.size; i++) {\n this.setFunctionModule(6, i, i % 2 == 0);\n this.setFunctionModule(i, 6, i % 2 == 0);\n }\n this.drawFinderPattern(3, 3);\n this.drawFinderPattern(this.size - 4, 3);\n this.drawFinderPattern(3, this.size - 4);\n const alignPatPos = this.getAlignmentPatternPositions();\n const numAlign = alignPatPos.length;\n for (let i = 0; i < numAlign; i++) {\n for (let j = 0; j < numAlign; j++) {\n if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))\n this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);\n }\n }\n this.drawFormatBits(0);\n this.drawVersion();\n }\n // Draws two copies of the format bits (with its own error correction code)\n // based on the given mask and this object's error correction level field.\n drawFormatBits(mask) {\n const data = this.errorCorrectionLevel.formatBits << 3 | mask;\n let rem = data;\n for (let i = 0; i < 10; i++)\n rem = rem << 1 ^ (rem >>> 9) * 1335;\n const bits = (data << 10 | rem) ^ 21522;\n assert(bits >>> 15 == 0);\n for (let i = 0; i <= 5; i++)\n this.setFunctionModule(8, i, getBit(bits, i));\n this.setFunctionModule(8, 7, getBit(bits, 6));\n this.setFunctionModule(8, 8, getBit(bits, 7));\n this.setFunctionModule(7, 8, getBit(bits, 8));\n for (let i = 9; i < 15; i++)\n this.setFunctionModule(14 - i, 8, getBit(bits, i));\n for (let i = 0; i < 8; i++)\n this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));\n for (let i = 8; i < 15; i++)\n this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));\n this.setFunctionModule(8, this.size - 8, true);\n }\n // Draws two copies of the version bits (with its own error correction code),\n // based on this object's version field, iff 7 <= version <= 40.\n drawVersion() {\n if (this.version < 7)\n return;\n let rem = this.version;\n for (let i = 0; i < 12; i++)\n rem = rem << 1 ^ (rem >>> 11) * 7973;\n const bits = this.version << 12 | rem;\n assert(bits >>> 18 == 0);\n for (let i = 0; i < 18; i++) {\n const color = getBit(bits, i);\n const a = this.size - 11 + i % 3;\n const b = Math.floor(i / 3);\n this.setFunctionModule(a, b, color);\n this.setFunctionModule(b, a, color);\n }\n }\n // Draws a 9*9 finder pattern including the border separator,\n // with the center module at (x, y). Modules can be out of bounds.\n drawFinderPattern(x, y) {\n for (let dy = -4; dy <= 4; dy++) {\n for (let dx = -4; dx <= 4; dx++) {\n const dist = Math.max(Math.abs(dx), Math.abs(dy));\n const xx = x + dx;\n const yy = y + dy;\n if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)\n this.setFunctionModule(xx, yy, dist != 2 && dist != 4);\n }\n }\n }\n // Draws a 5*5 alignment pattern, with the center module\n // at (x, y). All modules must be in bounds.\n drawAlignmentPattern(x, y) {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++)\n this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);\n }\n }\n // Sets the color of a module and marks it as a function module.\n // Only used by the constructor. Coordinates must be in bounds.\n setFunctionModule(x, y, isDark) {\n this.modules[y][x] = isDark;\n this.isFunction[y][x] = true;\n }\n /*-- Private helper methods for constructor: Codewords and masking --*/\n // Returns a new byte string representing the given data with the appropriate error correction\n // codewords appended to it, based on this object's version and error correction level.\n addEccAndInterleave(data) {\n const ver = this.version;\n const ecl = this.errorCorrectionLevel;\n if (data.length != _QrCode.getNumDataCodewords(ver, ecl))\n throw new RangeError(\"Invalid argument\");\n const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];\n const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];\n const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8);\n const numShortBlocks = numBlocks - rawCodewords % numBlocks;\n const shortBlockLen = Math.floor(rawCodewords / numBlocks);\n let blocks = [];\n const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen);\n for (let i = 0, k = 0; i < numBlocks; i++) {\n let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));\n k += dat.length;\n const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv);\n if (i < numShortBlocks)\n dat.push(0);\n blocks.push(dat.concat(ecc));\n }\n let result = [];\n for (let i = 0; i < blocks[0].length; i++) {\n blocks.forEach((block, j) => {\n if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)\n result.push(block[i]);\n });\n }\n assert(result.length == rawCodewords);\n return result;\n }\n // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire\n // data area of this QR Code. Function modules need to be marked off before this is called.\n drawCodewords(data) {\n if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8))\n throw new RangeError(\"Invalid argument\");\n let i = 0;\n for (let right = this.size - 1; right >= 1; right -= 2) {\n if (right == 6)\n right = 5;\n for (let vert = 0; vert < this.size; vert++) {\n for (let j = 0; j < 2; j++) {\n const x = right - j;\n const upward = (right + 1 & 2) == 0;\n const y = upward ? this.size - 1 - vert : vert;\n if (!this.isFunction[y][x] && i < data.length * 8) {\n this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));\n i++;\n }\n }\n }\n }\n assert(i == data.length * 8);\n }\n // XORs the codeword modules in this QR Code with the given mask pattern.\n // The function modules must be marked and the codeword bits must be drawn\n // before masking. Due to the arithmetic of XOR, calling applyMask() with\n // the same mask value a second time will undo the mask. A final well-formed\n // QR Code needs exactly one (not zero, two, etc.) mask applied.\n applyMask(mask) {\n if (mask < 0 || mask > 7)\n throw new RangeError(\"Mask value out of range\");\n for (let y = 0; y < this.size; y++) {\n for (let x = 0; x < this.size; x++) {\n let invert;\n switch (mask) {\n case 0:\n invert = (x + y) % 2 == 0;\n break;\n case 1:\n invert = y % 2 == 0;\n break;\n case 2:\n invert = x % 3 == 0;\n break;\n case 3:\n invert = (x + y) % 3 == 0;\n break;\n case 4:\n invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;\n break;\n case 5:\n invert = x * y % 2 + x * y % 3 == 0;\n break;\n case 6:\n invert = (x * y % 2 + x * y % 3) % 2 == 0;\n break;\n case 7:\n invert = ((x + y) % 2 + x * y % 3) % 2 == 0;\n break;\n default:\n throw new Error(\"Unreachable\");\n }\n if (!this.isFunction[y][x] && invert)\n this.modules[y][x] = !this.modules[y][x];\n }\n }\n }\n // Calculates and returns the penalty score based on state of this QR Code's current modules.\n // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.\n getPenaltyScore() {\n let result = 0;\n for (let y = 0; y < this.size; y++) {\n let runColor = false;\n let runX = 0;\n let runHistory = [0, 0, 0, 0, 0, 0, 0];\n for (let x = 0; x < this.size; x++) {\n if (this.modules[y][x] == runColor) {\n runX++;\n if (runX == 5)\n result += _QrCode.PENALTY_N1;\n else if (runX > 5)\n result++;\n } else {\n this.finderPenaltyAddHistory(runX, runHistory);\n if (!runColor)\n result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;\n runColor = this.modules[y][x];\n runX = 1;\n }\n }\n result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3;\n }\n for (let x = 0; x < this.size; x++) {\n let runColor = false;\n let runY = 0;\n let runHistory = [0, 0, 0, 0, 0, 0, 0];\n for (let y = 0; y < this.size; y++) {\n if (this.modules[y][x] == runColor) {\n runY++;\n if (runY == 5)\n result += _QrCode.PENALTY_N1;\n else if (runY > 5)\n result++;\n } else {\n this.finderPenaltyAddHistory(runY, runHistory);\n if (!runColor)\n result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;\n runColor = this.modules[y][x];\n runY = 1;\n }\n }\n result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode.PENALTY_N3;\n }\n for (let y = 0; y < this.size - 1; y++) {\n for (let x = 0; x < this.size - 1; x++) {\n const color = this.modules[y][x];\n if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])\n result += _QrCode.PENALTY_N2;\n }\n }\n let dark = 0;\n for (const row of this.modules)\n dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);\n const total = this.size * this.size;\n const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;\n assert(0 <= k && k <= 9);\n result += k * _QrCode.PENALTY_N4;\n assert(0 <= result && result <= 2568888);\n return result;\n }\n /*-- Private helper functions --*/\n // Returns an ascending list of positions of alignment patterns for this version number.\n // Each position is in the range [0,177), and are used on both the x and y axes.\n // This could be implemented as lookup table of 40 variable-length lists of integers.\n getAlignmentPatternPositions() {\n if (this.version == 1)\n return [];\n else {\n const numAlign = Math.floor(this.version / 7) + 2;\n const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;\n let result = [6];\n for (let pos = this.size - 7; result.length < numAlign; pos -= step)\n result.splice(1, 0, pos);\n return result;\n }\n }\n // Returns the number of data bits that can be stored in a QR Code of the given version number, after\n // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.\n // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.\n static getNumRawDataModules(ver) {\n if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION)\n throw new RangeError(\"Version number out of range\");\n let result = (16 * ver + 128) * ver + 64;\n if (ver >= 2) {\n const numAlign = Math.floor(ver / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (ver >= 7)\n result -= 36;\n }\n assert(208 <= result && result <= 29648);\n return result;\n }\n // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any\n // QR Code of the given version number and error correction level, with remainder bits discarded.\n // This stateless pure function could be implemented as a (40*4)-cell lookup table.\n static getNumDataCodewords(ver, ecl) {\n return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];\n }\n // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be\n // implemented as a lookup table over all possible parameter values, instead of as an algorithm.\n static reedSolomonComputeDivisor(degree) {\n if (degree < 1 || degree > 255)\n throw new RangeError(\"Degree out of range\");\n let result = [];\n for (let i = 0; i < degree - 1; i++)\n result.push(0);\n result.push(1);\n let root = 1;\n for (let i = 0; i < degree; i++) {\n for (let j = 0; j < result.length; j++) {\n result[j] = _QrCode.reedSolomonMultiply(result[j], root);\n if (j + 1 < result.length)\n result[j] ^= result[j + 1];\n }\n root = _QrCode.reedSolomonMultiply(root, 2);\n }\n return result;\n }\n // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.\n static reedSolomonComputeRemainder(data, divisor) {\n let result = divisor.map((_) => 0);\n for (const b of data) {\n const factor = b ^ result.shift();\n result.push(0);\n divisor.forEach((coef, i) => result[i] ^= _QrCode.reedSolomonMultiply(coef, factor));\n }\n return result;\n }\n // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result\n // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.\n static reedSolomonMultiply(x, y) {\n if (x >>> 8 != 0 || y >>> 8 != 0)\n throw new RangeError(\"Byte out of range\");\n let z = 0;\n for (let i = 7; i >= 0; i--) {\n z = z << 1 ^ (z >>> 7) * 285;\n z ^= (y >>> i & 1) * x;\n }\n assert(z >>> 8 == 0);\n return z;\n }\n // Can only be called immediately after a light run is added, and\n // returns either 0, 1, or 2. A helper function for getPenaltyScore().\n finderPenaltyCountPatterns(runHistory) {\n const n = runHistory[1];\n assert(n <= this.size * 3);\n const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;\n return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);\n }\n // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().\n finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {\n if (currentRunColor) {\n this.finderPenaltyAddHistory(currentRunLength, runHistory);\n currentRunLength = 0;\n }\n currentRunLength += this.size;\n this.finderPenaltyAddHistory(currentRunLength, runHistory);\n return this.finderPenaltyCountPatterns(runHistory);\n }\n // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().\n finderPenaltyAddHistory(currentRunLength, runHistory) {\n if (runHistory[0] == 0)\n currentRunLength += this.size;\n runHistory.pop();\n runHistory.unshift(currentRunLength);\n }\n };\n /*-- Constants and tables --*/\n // The minimum version number supported in the QR Code Model 2 standard.\n _QrCode.MIN_VERSION = 1;\n // The maximum version number supported in the QR Code Model 2 standard.\n _QrCode.MAX_VERSION = 40;\n // For use in getPenaltyScore(), when evaluating which mask is best.\n _QrCode.PENALTY_N1 = 3;\n _QrCode.PENALTY_N2 = 3;\n _QrCode.PENALTY_N3 = 40;\n _QrCode.PENALTY_N4 = 10;\n _QrCode.ECC_CODEWORDS_PER_BLOCK = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level\n [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],\n // Low\n [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],\n // Medium\n [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],\n // Quartile\n [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n // High\n ];\n _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level\n [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],\n // Low\n [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],\n // Medium\n [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],\n // Quartile\n [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]\n // High\n ];\n let QrCode = _QrCode;\n qrcodegen2.QrCode = _QrCode;\n function appendBits(val, len, bb) {\n if (len < 0 || len > 31 || val >>> len != 0)\n throw new RangeError(\"Value out of range\");\n for (let i = len - 1; i >= 0; i--)\n bb.push(val >>> i & 1);\n }\n function getBit(x, i) {\n return (x >>> i & 1) != 0;\n }\n function assert(cond) {\n if (!cond)\n throw new Error(\"Assertion error\");\n }\n const _QrSegment = class _QrSegment {\n /*-- Constructor (low level) and fields --*/\n // Creates a new QR Code segment with the given attributes and data.\n // The character count (numChars) must agree with the mode and the bit buffer length,\n // but the constraint isn't checked. The given bit buffer is cloned and stored.\n constructor(mode, numChars, bitData) {\n this.mode = mode;\n this.numChars = numChars;\n this.bitData = bitData;\n if (numChars < 0)\n throw new RangeError(\"Invalid argument\");\n this.bitData = bitData.slice();\n }\n /*-- Static factory functions (mid level) --*/\n // Returns a segment representing the given binary data encoded in\n // byte mode. All input byte arrays are acceptable. Any text string\n // can be converted to UTF-8 bytes and encoded as a byte mode segment.\n static makeBytes(data) {\n let bb = [];\n for (const b of data)\n appendBits(b, 8, bb);\n return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);\n }\n // Returns a segment representing the given string of decimal digits encoded in numeric mode.\n static makeNumeric(digits) {\n if (!_QrSegment.isNumeric(digits))\n throw new RangeError(\"String contains non-numeric characters\");\n let bb = [];\n for (let i = 0; i < digits.length; ) {\n const n = Math.min(digits.length - i, 3);\n appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);\n i += n;\n }\n return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);\n }\n // Returns a segment representing the given text string encoded in alphanumeric mode.\n // The characters allowed are: 0 to 9, A to Z (uppercase only), space,\n // dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n static makeAlphanumeric(text) {\n if (!_QrSegment.isAlphanumeric(text))\n throw new RangeError(\"String contains unencodable characters in alphanumeric mode\");\n let bb = [];\n let i;\n for (i = 0; i + 2 <= text.length; i += 2) {\n let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;\n temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));\n appendBits(temp, 11, bb);\n }\n if (i < text.length)\n appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);\n return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);\n }\n // Returns a new mutable list of zero or more segments to represent the given Unicode text string.\n // The result may use various segment modes and switch modes to optimize the length of the bit stream.\n static makeSegments(text) {\n if (text == \"\")\n return [];\n else if (_QrSegment.isNumeric(text))\n return [_QrSegment.makeNumeric(text)];\n else if (_QrSegment.isAlphanumeric(text))\n return [_QrSegment.makeAlphanumeric(text)];\n else\n return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))];\n }\n // Returns a segment representing an Extended Channel Interpretation\n // (ECI) designator with the given assignment value.\n static makeEci(assignVal) {\n let bb = [];\n if (assignVal < 0)\n throw new RangeError(\"ECI assignment value out of range\");\n else if (assignVal < 1 << 7)\n appendBits(assignVal, 8, bb);\n else if (assignVal < 1 << 14) {\n appendBits(2, 2, bb);\n appendBits(assignVal, 14, bb);\n } else if (assignVal < 1e6) {\n appendBits(6, 3, bb);\n appendBits(assignVal, 21, bb);\n } else\n throw new RangeError(\"ECI assignment value out of range\");\n return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);\n }\n // Tests whether the given string can be encoded as a segment in numeric mode.\n // A string is encodable iff each character is in the range 0 to 9.\n static isNumeric(text) {\n return _QrSegment.NUMERIC_REGEX.test(text);\n }\n // Tests whether the given string can be encoded as a segment in alphanumeric mode.\n // A string is encodable iff each character is in the following set: 0 to 9, A to Z\n // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n static isAlphanumeric(text) {\n return _QrSegment.ALPHANUMERIC_REGEX.test(text);\n }\n /*-- Methods --*/\n // Returns a new copy of the data bits of this segment.\n getData() {\n return this.bitData.slice();\n }\n // (Package-private) Calculates and returns the number of bits needed to encode the given segments at\n // the given version. The result is infinity if a segment has too many characters to fit its length field.\n static getTotalBits(segs, version) {\n let result = 0;\n for (const seg of segs) {\n const ccbits = seg.mode.numCharCountBits(version);\n if (seg.numChars >= 1 << ccbits)\n return Infinity;\n result += 4 + ccbits + seg.bitData.length;\n }\n return result;\n }\n // Returns a new array of bytes representing the given string encoded in UTF-8.\n static toUtf8ByteArray(str) {\n str = encodeURI(str);\n let result = [];\n for (let i = 0; i < str.length; i++) {\n if (str.charAt(i) != \"%\")\n result.push(str.charCodeAt(i));\n else {\n result.push(parseInt(str.substring(i + 1, i + 3), 16));\n i += 2;\n }\n }\n return result;\n }\n };\n /*-- Constants --*/\n // Describes precisely all strings that are encodable in numeric mode.\n _QrSegment.NUMERIC_REGEX = /^[0-9]*$/;\n // Describes precisely all strings that are encodable in alphanumeric mode.\n _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\\/:-]*$/;\n // The set of all legal characters in alphanumeric mode,\n // where each character value maps to the index in the string.\n _QrSegment.ALPHANUMERIC_CHARSET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:\";\n let QrSegment = _QrSegment;\n qrcodegen2.QrSegment = _QrSegment;\n})(qrcodegen || (qrcodegen = {}));\n((qrcodegen2) => {\n let QrCode;\n ((QrCode2) => {\n const _Ecc = class _Ecc {\n // The QR Code can tolerate about 30% erroneous codewords\n /*-- Constructor and fields --*/\n constructor(ordinal, formatBits) {\n this.ordinal = ordinal;\n this.formatBits = formatBits;\n }\n };\n /*-- Constants --*/\n _Ecc.LOW = new _Ecc(0, 1);\n // The QR Code can tolerate about 7% erroneous codewords\n _Ecc.MEDIUM = new _Ecc(1, 0);\n // The QR Code can tolerate about 15% erroneous codewords\n _Ecc.QUARTILE = new _Ecc(2, 3);\n // The QR Code can tolerate about 25% erroneous codewords\n _Ecc.HIGH = new _Ecc(3, 2);\n let Ecc = _Ecc;\n QrCode2.Ecc = _Ecc;\n })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));\n})(qrcodegen || (qrcodegen = {}));\n((qrcodegen2) => {\n let QrSegment;\n ((QrSegment2) => {\n const _Mode = class _Mode {\n /*-- Constructor and fields --*/\n constructor(modeBits, numBitsCharCount) {\n this.modeBits = modeBits;\n this.numBitsCharCount = numBitsCharCount;\n }\n /*-- Method --*/\n // (Package-private) Returns the bit width of the character count field for a segment in\n // this mode in a QR Code at the given version number. The result is in the range [0, 16].\n numCharCountBits(ver) {\n return this.numBitsCharCount[Math.floor((ver + 7) / 17)];\n }\n };\n /*-- Constants --*/\n _Mode.NUMERIC = new _Mode(1, [10, 12, 14]);\n _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);\n _Mode.BYTE = new _Mode(4, [8, 16, 16]);\n _Mode.KANJI = new _Mode(8, [8, 10, 12]);\n _Mode.ECI = new _Mode(7, [0, 0, 0]);\n let Mode = _Mode;\n QrSegment2.Mode = _Mode;\n })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));\n})(qrcodegen || (qrcodegen = {}));\nvar qrcodegen_default = qrcodegen;\n\n// src/index.tsx\n/**\n * @license qrcode.react\n * Copyright (c) Paul O'Shannessy\n * SPDX-License-Identifier: ISC\n */\nvar ERROR_LEVEL_MAP = {\n L: qrcodegen_default.QrCode.Ecc.LOW,\n M: qrcodegen_default.QrCode.Ecc.MEDIUM,\n Q: qrcodegen_default.QrCode.Ecc.QUARTILE,\n H: qrcodegen_default.QrCode.Ecc.HIGH\n};\nvar DEFAULT_SIZE = 128;\nvar DEFAULT_LEVEL = \"L\";\nvar DEFAULT_BGCOLOR = \"#FFFFFF\";\nvar DEFAULT_FGCOLOR = \"#000000\";\nvar DEFAULT_INCLUDEMARGIN = false;\nvar DEFAULT_MINVERSION = 1;\nvar SPEC_MARGIN_SIZE = 4;\nvar DEFAULT_MARGIN_SIZE = 0;\nvar DEFAULT_IMG_SCALE = 0.1;\nfunction generatePath(modules, margin = 0) {\n const ops = [];\n modules.forEach(function(row, y) {\n let start = null;\n row.forEach(function(cell, x) {\n if (!cell && start !== null) {\n ops.push(\n `M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`\n );\n start = null;\n return;\n }\n if (x === row.length - 1) {\n if (!cell) {\n return;\n }\n if (start === null) {\n ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);\n } else {\n ops.push(\n `M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`\n );\n }\n return;\n }\n if (cell && start === null) {\n start = x;\n }\n });\n });\n return ops.join(\"\");\n}\nfunction excavateModules(modules, excavation) {\n return modules.slice().map((row, y) => {\n if (y < excavation.y || y >= excavation.y + excavation.h) {\n return row;\n }\n return row.map((cell, x) => {\n if (x < excavation.x || x >= excavation.x + excavation.w) {\n return cell;\n }\n return false;\n });\n });\n}\nfunction getImageSettings(cells, size, margin, imageSettings) {\n if (imageSettings == null) {\n return null;\n }\n const numCells = cells.length + margin * 2;\n const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);\n const scale = numCells / size;\n const w = (imageSettings.width || defaultSize) * scale;\n const h = (imageSettings.height || defaultSize) * scale;\n const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;\n const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;\n const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;\n let excavation = null;\n if (imageSettings.excavate) {\n let floorX = Math.floor(x);\n let floorY = Math.floor(y);\n let ceilW = Math.ceil(w + x - floorX);\n let ceilH = Math.ceil(h + y - floorY);\n excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };\n }\n const crossOrigin = imageSettings.crossOrigin;\n return { x, y, h, w, excavation, opacity, crossOrigin };\n}\nfunction getMarginSize(includeMargin, marginSize) {\n if (marginSize != null) {\n return Math.max(Math.floor(marginSize), 0);\n }\n return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;\n}\nfunction useQRCode({\n value,\n level,\n minVersion,\n includeMargin,\n marginSize,\n imageSettings,\n size,\n boostLevel\n}) {\n let qrcode = React.useMemo(() => {\n const values = Array.isArray(value) ? value : [value];\n const segments = values.reduce((accum, v) => {\n accum.push(...qrcodegen_default.QrSegment.makeSegments(v));\n return accum;\n }, []);\n return qrcodegen_default.QrCode.encodeSegments(\n segments,\n ERROR_LEVEL_MAP[level],\n minVersion,\n void 0,\n void 0,\n boostLevel\n );\n }, [value, level, minVersion, boostLevel]);\n const { cells, margin, numCells, calculatedImageSettings } = React.useMemo(() => {\n let cells2 = qrcode.getModules();\n const margin2 = getMarginSize(includeMargin, marginSize);\n const numCells2 = cells2.length + margin2 * 2;\n const calculatedImageSettings2 = getImageSettings(\n cells2,\n size,\n margin2,\n imageSettings\n );\n return {\n cells: cells2,\n margin: margin2,\n numCells: numCells2,\n calculatedImageSettings: calculatedImageSettings2\n };\n }, [qrcode, size, imageSettings, includeMargin, marginSize]);\n return {\n qrcode,\n margin,\n cells,\n numCells,\n calculatedImageSettings\n };\n}\nvar SUPPORTS_PATH2D = function() {\n try {\n new Path2D().addPath(new Path2D());\n } catch (e) {\n return false;\n }\n return true;\n}();\nvar QRCodeCanvas = React.forwardRef(\n function QRCodeCanvas2(props, forwardedRef) {\n const _a = props, {\n value,\n size = DEFAULT_SIZE,\n level = DEFAULT_LEVEL,\n bgColor = DEFAULT_BGCOLOR,\n fgColor = DEFAULT_FGCOLOR,\n includeMargin = DEFAULT_INCLUDEMARGIN,\n minVersion = DEFAULT_MINVERSION,\n boostLevel,\n marginSize,\n imageSettings\n } = _a, extraProps = __objRest(_a, [\n \"value\",\n \"size\",\n \"level\",\n \"bgColor\",\n \"fgColor\",\n \"includeMargin\",\n \"minVersion\",\n \"boostLevel\",\n \"marginSize\",\n \"imageSettings\"\n ]);\n const _b = extraProps, { style } = _b, otherProps = __objRest(_b, [\"style\"]);\n const imgSrc = imageSettings == null ? void 0 : imageSettings.src;\n const _canvas = React.useRef(null);\n const _image = React.useRef(null);\n const setCanvasRef = React.useCallback(\n (node) => {\n _canvas.current = node;\n if (typeof forwardedRef === \"function\") {\n forwardedRef(node);\n } else if (forwardedRef) {\n forwardedRef.current = node;\n }\n },\n [forwardedRef]\n );\n const [isImgLoaded, setIsImageLoaded] = React.useState(false);\n const { margin, cells, numCells, calculatedImageSettings } = useQRCode({\n value,\n level,\n minVersion,\n boostLevel,\n includeMargin,\n marginSize,\n imageSettings,\n size\n });\n React.useEffect(() => {\n if (_canvas.current != null) {\n const canvas = _canvas.current;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n return;\n }\n let cellsToDraw = cells;\n const image = _image.current;\n const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;\n if (haveImageToRender) {\n if (calculatedImageSettings.excavation != null) {\n cellsToDraw = excavateModules(\n cells,\n calculatedImageSettings.excavation\n );\n }\n }\n const pixelRatio = window.devicePixelRatio || 1;\n canvas.height = canvas.width = size * pixelRatio;\n const scale = size / numCells * pixelRatio;\n ctx.scale(scale, scale);\n ctx.fillStyle = bgColor;\n ctx.fillRect(0, 0, numCells, numCells);\n ctx.fillStyle = fgColor;\n if (SUPPORTS_PATH2D) {\n ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));\n } else {\n cells.forEach(function(row, rdx) {\n row.forEach(function(cell, cdx) {\n if (cell) {\n ctx.fillRect(cdx + margin, rdx + margin, 1, 1);\n }\n });\n });\n }\n if (calculatedImageSettings) {\n ctx.globalAlpha = calculatedImageSettings.opacity;\n }\n if (haveImageToRender) {\n ctx.drawImage(\n image,\n calculatedImageSettings.x + margin,\n calculatedImageSettings.y + margin,\n calculatedImageSettings.w,\n calculatedImageSettings.h\n );\n }\n }\n });\n React.useEffect(() => {\n setIsImageLoaded(false);\n }, [imgSrc]);\n const canvasStyle = __spreadValues({ height: size, width: size }, style);\n let img = null;\n if (imgSrc != null) {\n img = /* @__PURE__ */ React.createElement(\n \"img\",\n {\n src: imgSrc,\n key: imgSrc,\n style: { display: \"none\" },\n onLoad: () => {\n setIsImageLoaded(true);\n },\n ref: _image,\n crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin\n }\n );\n }\n return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(\n \"canvas\",\n __spreadValues({\n style: canvasStyle,\n height: size,\n width: size,\n ref: setCanvasRef,\n role: \"img\"\n }, otherProps)\n ), img);\n }\n);\nQRCodeCanvas.displayName = \"QRCodeCanvas\";\nvar QRCodeSVG = React.forwardRef(\n function QRCodeSVG2(props, forwardedRef) {\n const _a = props, {\n value,\n size = DEFAULT_SIZE,\n level = DEFAULT_LEVEL,\n bgColor = DEFAULT_BGCOLOR,\n fgColor = DEFAULT_FGCOLOR,\n includeMargin = DEFAULT_INCLUDEMARGIN,\n minVersion = DEFAULT_MINVERSION,\n boostLevel,\n title,\n marginSize,\n imageSettings\n } = _a, otherProps = __objRest(_a, [\n \"value\",\n \"size\",\n \"level\",\n \"bgColor\",\n \"fgColor\",\n \"includeMargin\",\n \"minVersion\",\n \"boostLevel\",\n \"title\",\n \"marginSize\",\n \"imageSettings\"\n ]);\n const { margin, cells, numCells, calculatedImageSettings } = useQRCode({\n value,\n level,\n minVersion,\n boostLevel,\n includeMargin,\n marginSize,\n imageSettings,\n size\n });\n let cellsToDraw = cells;\n let image = null;\n if (imageSettings != null && calculatedImageSettings != null) {\n if (calculatedImageSettings.excavation != null) {\n cellsToDraw = excavateModules(\n cells,\n calculatedImageSettings.excavation\n );\n }\n image = /* @__PURE__ */ React.createElement(\n \"image\",\n {\n href: imageSettings.src,\n height: calculatedImageSettings.h,\n width: calculatedImageSettings.w,\n x: calculatedImageSettings.x + margin,\n y: calculatedImageSettings.y + margin,\n preserveAspectRatio: \"none\",\n opacity: calculatedImageSettings.opacity,\n crossOrigin: calculatedImageSettings.crossOrigin\n }\n );\n }\n const fgPath = generatePath(cellsToDraw, margin);\n return /* @__PURE__ */ React.createElement(\n \"svg\",\n __spreadValues({\n height: size,\n width: size,\n viewBox: `0 0 ${numCells} ${numCells}`,\n ref: forwardedRef,\n role: \"img\"\n }, otherProps),\n !!title && /* @__PURE__ */ React.createElement(\"title\", null, title),\n /* @__PURE__ */ React.createElement(\n \"path\",\n {\n fill: bgColor,\n d: `M0,0 h${numCells}v${numCells}H0z`,\n shapeRendering: \"crispEdges\"\n }\n ),\n /* @__PURE__ */ React.createElement(\"path\", { fill: fgColor, d: fgPath, shapeRendering: \"crispEdges\" }),\n image\n );\n }\n);\nQRCodeSVG.displayName = \"QRCodeSVG\";\nexport {\n QRCodeCanvas,\n QRCodeSVG\n};\n","/**\n * Which kind of address a located pairing origin is, decided in one place\n * because two halves answer with the same word: the panel states the kind to the\n * operator, and the Host log names it beside the machine-local link.\n *\n * The host's own answer comes first, and the literal decides when it did not: a\n * configured base can name a private address — the package README calls\n * `DSH_REMOTE_PUBLIC_BASE_URL` a public or LAN origin — and a surface that\n * called such an address public would promise a phone something it cannot reach\n * from outside. The pattern is anchored to the whole hostname on purpose: a\n * public name that merely starts like a private literal (`10.example.com`) is\n * not one, and printing it is the one thing the address line must never do.\n * Every value this module cannot place reads as public, which is the direction\n * that prints nothing.\n * @module dsh-remote-bridge/core/pair-address\n */\n\n/** Where the host's own answer says a located origin came from. */\nexport type PairOriginSource = 'realtime' | 'env' | 'lan'\n\n/**\n * Hosts a phone can only reach from the same network: the private IPv4 ranges,\n * the unspecified address, and the IPv6 loopback, unique-local and link-local\n * prefixes. IPv4-mapped IPv6 and anything else this does not place stays public,\n * because the failure this predicate may never have is printing a name the host\n * did not vouch for.\n */\nconst LAN_HOST_RE = /^(?:localhost|0\\.0\\.0\\.0|(?:(?:10|127)(?:\\.\\d{1,3}){3}|192\\.168(?:\\.\\d{1,3}){2}|172\\.(?:1[6-9]|2\\d|3[01])(?:\\.\\d{1,3}){2}|169\\.254(?:\\.\\d{1,3}){2})|\\[(?:::1|f[cd][0-9a-f]{2}:|fe[89ab][0-9a-f]:)[0-9a-f:]*\\])$/i\n\n/** The hostname a URL carries, or null when the value is not a URL at all. */\nfunction hostnameOf(origin: string): string | null {\n try {\n return new URL(origin).hostname\n } catch {\n return null\n }\n}\n\n/**\n * Whether a located origin answers only inside this network.\n * @param origin - the located origin, or null when there is none.\n * @param source - where the host said that origin came from.\n * @returns true when a phone must be on the same network to dial it.\n */\nexport function isLanOrigin(origin: string | null, source: PairOriginSource | null): boolean {\n if (source === 'lan') return true\n if (origin === null) return false\n const host = hostnameOf(origin)\n return host !== null && LAN_HOST_RE.test(host)\n}\n","/**\n * Semantic attribute values for the protocol v1 pairing panel (contract:\n * skins/skin-center/contracts/semantic-attrs-v1.md). Root containers carry\n * `data-dsh-plugin`; parts carry bare `data-dsh-part` values owned by that\n * plugin attribute.\n */\n\n/** Plugin short name stamped on the footer trigger and the modal root. */\nexport const PLUGIN_ATTR = 'remote-bridge'\n\n/** The sidebar footer seat trigger. */\nexport const PART_ENTRY = 'entry'\n\n/** The modal panel root. */\nexport const PART_PANEL = 'panel'\n\n/** The QR symbol's box — it also mirrors the encoded string. */\nexport const PART_QR = 'qr'\n\n/** A refusal the host raised. */\nexport const PART_NOTICE = 'notice'\n\n/** The mint-again button. */\nexport const PART_REFRESH = 'refresh'\n\n/** The copy-the-code button. */\nexport const PART_COPY = 'copy'\n\n/**\n * Attribute carrying the exact string the QR symbol encodes, so the operator\n * (and a UI check) can compare it against the host route's answer without\n * decoding the symbol. It is the only machine trace the panel renders.\n */\nexport const QR_VALUE_ATTR = 'data-dsh-qr-value'\n\n/**\n * Marks the QR part of a code that has run out of time. Expiry is state on the\n * existing part, not a new part value: the cross-repository part enum is frozen\n * and a plugin may not extend it for one visual state.\n */\nexport const EXPIRED_ATTR = 'data-expired'\n","/**\n * The protocol v1 pairing panel: the QR symbol, the countdown with its expiry\n * state, the line that says which kind of address the code carries, and the two\n * actions that keep a fresh code on screen.\n *\n * The shell is the official headless `Modal` and every action is the official\n * `Button`, so the overlay, the mask, the card, the focus trap, the Escape\n * command and the interaction states belong to the library. This file owns the\n * information order and the state presentation only: every state and action\n * arrives through props, and the clock is a prop, so the expiry flip is\n * deterministic instead of read from `Date.now()` here.\n */\nimport { memo, useLayoutEffect, useRef } from 'react'\nimport { QRCodeSVG } from 'qrcode.react'\nimport {\n Button, IconCheckOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,\n IconRefreshOutlineRegular, IconWarningOutlineRegular, Modal,\n} from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport { isLanOrigin, type PairOriginSource } from '../core/pair-address.ts'\nimport {\n EXPIRED_ATTR, PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PLUGIN_ATTR, QR_VALUE_ATTR,\n} from './semantic.ts'\nimport css from './panel.module.css'\n\n/** The custom property carrying the dialog's own enter keyframe name. */\nconst EXIT_NAME_VAR = '--pair-exit-name'\n\n/**\n * Where a reader of the beta build can reach the people running it. The URL is\n * code, not copy: the dictionaries carry the sentence, this constant carries the\n * destination, so a translation cannot retarget the link and a check can assert\n * the real one.\n */\nexport const COMMUNITY_INVITE_URL = 'https://discord.gg/nBy28kjun'\n\n/** What the panel is currently showing. */\nexport type PairPanelState =\n /** A read is in flight. */\n | { kind: 'reading' }\n /**\n * A live one-shot secret. `pairingUrl`, when the host could name its own\n * public origin, is what the QR encodes: a `{token, url}` document the iOS\n * client parses into both halves of its configuration, so one scan sets the\n * address AND the token. With no origin the QR carries the bare token and the\n * panel says the address has to be set on the phone by hand. `originSource`\n * and the literal itself decide which of the two located lines renders: a\n * public origin is stated as a kind and never printed, while a LAN literal is\n * named because it answers only inside the network this page is already on.\n */\n | {\n kind: 'ready'\n token: string\n issuedAt: number\n expiresAt: number\n origin: string | null\n originSource: PairOriginSource | null\n pairingUrl: string | null\n }\n /** 403 from the loopback gate: this page is not open on the machine itself. */\n | { kind: 'forbidden' }\n /** The host route answered with an unexpected status or shape. */\n | { kind: 'failed'; status: number }\n /** The request never reached the host. */\n | { kind: 'unreachable' }\n\n/** How the last copy attempt went. */\nexport type PairCopyState = 'idle' | 'copied' | 'failed'\n\nexport interface PairPanelProps {\n t: PropsLocale<'remote-bridge'>['t']\n state: PairPanelState\n /** The current wall clock; the entry supplies it from a one-second ticker. */\n now: number\n /** This page's own `host:port`, named in the origin warning. */\n host: string\n copy: PairCopyState\n /** Whether the modal is mounted at all (the entry keeps it for the leave leg). */\n showing: boolean\n /** Whether the leave leg is running; the card stays mounted until it ends. */\n closing: boolean\n /** The panel element's id, so the seat trigger can name what it expands. */\n id: string\n onClose(): void\n /** The leave leg reported completion: the entry may unmount the modal now. */\n onExited(): void\n onRefresh(): void\n onCopy(payload: string): void\n}\n\n/**\n * The QR symbol, memoized on the secret: the countdown re-renders the panel\n * every second, and qrcode.react rebuilds the whole module path on each render.\n * The encoded value is the host's own `pairingUrl` verbatim when there is one —\n * a `{token, url}` document whose `url` names THIS instance's public relay, so\n * the phone adopts an origin that actually reaches this host. The bare-token\n * fallback means the phone keeps whatever origin it already has.\n */\nconst PairQrCode = memo(function PairQrCode({ value, label }: { value: string; label: string }) {\n return <QRCodeSVG value={value} size={184} level=\"M\" marginSize={1} aria-label={label} />\n})\n\n/** The one string the panel hands out: what the symbol encodes, what copy copies. */\nfunction payloadOf(state: PairPanelState): string {\n return state.kind === 'ready' ? (state.pairingUrl ?? state.token) : ''\n}\n\n/**\n * Render the pairing panel.\n * @param props - locale seat, view state, clock, page host and actions.\n * @returns the panel element tree.\n */\nexport function PairPanel({\n t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy,\n}: PairPanelProps) {\n const panel = useRef<HTMLDivElement | null>(null)\n const ready = state.kind === 'ready'\n const remainingMs = ready ? Math.max(0, state.expiresAt - now) : 0\n const expired = ready && remainingMs <= 0\n const seconds = Math.ceil(remainingMs / 1000)\n const windowMs = ready ? Math.max(1, state.expiresAt - state.issuedAt) : 1\n const percent = Math.min(100, Math.max(0, Math.round((remainingMs / windowMs) * 100)))\n const payload = payloadOf(state)\n // Only a live code can be handed out. An expired one is still on screen, so\n // its button stays put and reports that it is switched off.\n const canCopy = !expired && payload !== ''\n // A refusal the host raised is retried; a live or expired code is minted again.\n const primaryLabel = state.kind === 'failed' || state.kind === 'unreachable' ? t('action.retry') : t('pair.refresh')\n const located = ready && state.pairingUrl !== null\n // A located origin answers only inside this network when the host said so or\n // the literal itself is a private one; anything else counts as public, because\n // the one thing this line must never do is print a hostname the host did not\n // vouch for.\n const onLan = located && isLanOrigin(state.origin, state.originSource)\n\n // The library owns the enter animation and the bundler scopes its keyframe\n // name, so the leave leg cannot name it in CSS. Read the mounted dialog's own\n // animation at the moment closing starts and hand it to the card: the exit\n // then plays that exact keyframe backwards (M2, same path reversed). Clearing\n // it on reopen is what lets the same card come back to full opacity.\n useLayoutEffect(() => {\n const element = panel.current\n if (element === null) return\n if (!closing) {\n element.style.removeProperty(EXIT_NAME_VAR)\n return\n }\n const dialog = element.parentElement\n const enter = dialog === null ? '' : window.getComputedStyle(dialog).animationName\n if (enter !== '' && enter !== 'none') element.style.setProperty(EXIT_NAME_VAR, enter)\n }, [closing])\n\n return (\n <Modal open={showing} onClose={onClose} title={t('title')} headless className={css.dialog}>\n <div\n ref={panel}\n id={id}\n className={css.panel}\n data-dsh-plugin={PLUGIN_ATTR}\n data-dsh-part={PART_PANEL}\n data-closing={closing || undefined}\n onAnimationEnd={(event) => {\n if (closing && event.target === event.currentTarget) onExited()\n }}\n onTransitionEnd={(event) => {\n if (closing && event.target === event.currentTarget && event.propertyName === 'opacity') onExited()\n }}\n >\n <header className={css.header}>\n <div className={css.heading}>\n <h2 className={css.title}>{t('title')}</h2>\n <p className={css.subtitle}>{t('subtitle')}</p>\n </div>\n <Button\n className={css.close}\n variant=\"ghost\"\n size=\"sm\"\n aria-label={t('action.close')}\n icon={<IconCloseOutlineRegular />}\n onClick={onClose}\n />\n </header>\n\n <div className={css.body}>\n {(state.kind === 'forbidden' || state.kind === 'failed' || state.kind === 'unreachable') && (\n <div className={css.notice} data-dsh-part={PART_NOTICE} data-tone=\"alert\" role=\"alert\">\n <span className={css.noticeIcon} aria-hidden=\"true\"><IconWarningOutlineRegular /></span>\n <div className={css.noticeCopy}>\n <p className={css.noticeTitle}>\n {state.kind === 'forbidden' && t('forbidden.title')}\n {state.kind === 'failed' && t('failed.title')}\n {state.kind === 'unreachable' && t('unreachable.title')}\n </p>\n <p className={css.noticeText}>\n {state.kind === 'forbidden' && t('forbidden.body')}\n {state.kind === 'failed' && t('failed.body', { status: String(state.status) })}\n {state.kind === 'unreachable' && t('unreachable.body')}\n </p>\n </div>\n </div>\n )}\n\n {(state.kind === 'reading' || ready) && (\n <>\n <div className={css.qrCard}>\n <div\n className={css.qrSlot}\n data-dsh-part={PART_QR}\n {...{ [QR_VALUE_ATTR]: payload }}\n {...{ [EXPIRED_ATTR]: expired || undefined }}\n >\n {ready ? (\n <PairQrCode value={payload} label={t('pair.qrLabel')} />\n ) : (\n <span className={css.skeleton} aria-hidden=\"true\" />\n )}\n </div>\n <div className={css.status}>\n {!ready && <p className={css.statusText}>{t('state.reading')}</p>}\n {ready && expired && <p className={css.statusText} role=\"status\">{t('pair.expired')}</p>}\n {ready && !expired && (\n <>\n <p className={css.statusText}>{t('pair.countdown', { s: String(seconds) })}</p>\n <span className={css.bar} aria-hidden=\"true\">\n <span className={css.barFill} style={{ width: `${String(percent)}%` }} />\n </span>\n </>\n )}\n </div>\n </div>\n\n <p className={css.address} data-tone={located ? 'plain' : 'warning'}>\n {ready && located && !onLan && t('origin.public')}\n {ready && onLan && t('origin.lan', { origin: state.origin ?? '' })}\n {ready && !located && t('origin.missing', { host })}\n </p>\n <p className={css.hint}>{t('pair.usedHint')}</p>\n </>\n )}\n\n {/* The one way out of a beta, offered in every state including a\n refusal: a reader who cannot pair is exactly the one with a\n question. It closes the body, so the last thing on the card is the\n way to ask rather than the code they already have. */}\n <a\n className={css.invite}\n href={COMMUNITY_INVITE_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {t('community.invite')}\n </a>\n </div>\n\n {/* The row exists only while it holds an action: a refusal offers\n nothing to press, and copy itself needs a code to hand out. An\n actionless row would still spend the panel's own gap. */}\n {state.kind !== 'forbidden' && (\n <footer className={css.actions}>\n {ready && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n data-dsh-part={PART_COPY}\n disabled={!canCopy}\n icon={copy === 'copied' ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}\n onClick={() => { onCopy(payload) }}\n >\n <span className={css.labels}>\n <span className={css.label} data-visible={copy === 'idle'} aria-hidden={copy !== 'idle'}>\n {t('action.copy')}\n </span>\n <span className={css.label} data-visible={copy === 'copied'} aria-hidden={copy !== 'copied'}>\n {t('action.copied')}\n </span>\n <span className={css.label} data-visible={copy === 'failed'} aria-hidden={copy !== 'failed'}>\n {t('action.copyFailed')}\n </span>\n </span>\n </Button>\n )}\n <Button\n variant=\"primary\"\n size=\"sm\"\n data-dsh-part={PART_REFRESH}\n disabled={state.kind === 'reading'}\n icon={<IconRefreshOutlineRegular />}\n onClick={onRefresh}\n >\n {primaryLabel}\n </Button>\n </footer>\n )}\n\n {/* Renaming the button under the pointer is not announced: a control's\n label is reported when focus lands on it, not when it changes. The\n outcome is said once from this region instead, and said as nothing\n while there is no outcome to report. */}\n <div className={css.announce} role=\"status\">\n {copy === 'copied' && t('action.copied')}\n {copy === 'failed' && t('action.copyFailed')}\n </div>\n </div>\n </Modal>\n )\n}\n","/**\n * The pairing seat's QR glyph. It is the one icon this package draws itself\n * (I4 exception, recorded here): the official icon set in\n * `@deepseek-ai/dsh-client-ui-primitives` ships no QR or scan metaphor, and a\n * text or emoji stand-in is not an icon (I1). Every other glyph this panel\n * needs — close, copy, check, refresh, warning — comes from that set.\n */\nimport type { SVGProps } from 'react'\n\n/** A QR-symbol glyph: three finder squares plus a payload dot. */\nexport function QrIcon(props: SVGProps<SVGSVGElement>) {\n return (\n <svg\n width={16}\n height={16}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n {...props}\n >\n <path d=\"M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z\" />\n <path d=\"M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z\" />\n </svg>\n )\n}\n","/**\n * Sidebar footer entry for the protocol v1 pairing panel: the icon-only trigger\n * beside the sidebar settings seat (wide row / rail circle) that opens the\n * panel. Registered into the official `sidebar.footer.action` list slot\n * (declared by ui-sidebar — the same seat dsh-remote-web-ui and dsh-update\n * share).\n *\n * This component owns the panel's presence and behavior: one read per open, one\n * clock tick while a live code is on screen, the mint-again action, the copy\n * action, and the leave leg that keeps the modal mounted until its exit reports\n * completion. The wire call and the clipboard are injected (see the plugin\n * entry), so the rendered tree carries no closure-factory bundle import and both\n * can be driven by a test without patching a module.\n */\nimport { useCallback, useEffect, useId, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport { PairPanel, type PairCopyState, type PairPanelState } from './PairPanel.tsx'\nimport type { PairTokenOutcome } from './pair-token.ts'\nimport { PART_ENTRY, PLUGIN_ATTR } from './semantic.ts'\nimport { QrIcon } from './icons.tsx'\nimport css from './panel.module.css'\n\n/** How long the transient \"copied\" / \"copy failed\" label stays up. */\nconst COPY_FEEDBACK_MS = 1_500\n/** The countdown's tick; one second is the resolution the panel shows. */\nconst TICK_MS = 1_000\n/**\n * Upper bound on the leave leg. The card reports its own animation end, and the\n * reduced-motion fade reports a transition end; this only ends the presence of a\n * browser that reports neither, just past var(--ds-transition-duration).\n */\nconst EXIT_TIMEOUT_MS = 260\n\n/**\n * The modal's presence. `closing` is a state of its own: the card stays mounted\n * for its reverse exit and unmounts only when that exit reports completion,\n * instead of disappearing on the same tick as the click.\n */\ntype Presence = 'closed' | 'open' | 'closing'\n\nexport type PairEntryProps = PropsLocale<'remote-bridge'> & {\n /** Whether the sidebar renders wide content (false = 56px rail). */\n wide: boolean\n /** Reads a fresh one-shot token from this package's own Host route. */\n read: () => Promise<PairTokenOutcome>\n /** Puts the token on the OS clipboard; false means the write was refused. */\n copy: (text: string) => Promise<boolean>\n}\n\n/** Map a read outcome onto the panel's view state. */\nfunction panelStateOf(outcome: PairTokenOutcome, issuedAt: number): PairPanelState {\n switch (outcome.kind) {\n case 'ok':\n return {\n kind: 'ready',\n token: outcome.token,\n issuedAt,\n expiresAt: outcome.expiresAt,\n origin: outcome.origin,\n originSource: outcome.originSource,\n pairingUrl: outcome.pairingUrl,\n }\n case 'forbidden': return { kind: 'forbidden' }\n case 'unreachable': return { kind: 'unreachable' }\n case 'failed': return { kind: 'failed', status: outcome.status }\n }\n}\n\n/**\n * Render the pairing seat trigger and, while it is open or leaving, the panel.\n * @param props - the footer seat's column state, the injected actions and the locale seat.\n * @returns the trigger and, when present, the official Modal holding the panel.\n */\nexport function PairEntry({ wide, read, copy, t }: PairEntryProps) {\n const [presence, setPresence] = useState<Presence>('closed')\n const [state, setState] = useState<PairPanelState>({ kind: 'reading' })\n const [copyState, setCopyState] = useState<PairCopyState>('idle')\n const [now, setNow] = useState<number>(() => Date.now())\n const panelId = useId()\n // Generation counter: closing (or minting again) invalidates a read that is\n // still in flight, so an answer that lands after the panel closed cannot\n // resurrect a code nobody asked for.\n const generation = useRef(0)\n\n const mint = useCallback((): void => {\n const request = ++generation.current\n setState({ kind: 'reading' })\n void read().then((outcome) => {\n if (request !== generation.current) return\n const issuedAt = Date.now()\n setNow(issuedAt)\n setState(panelStateOf(outcome, issuedAt))\n })\n }, [read])\n\n const openPanel = useCallback((): void => {\n setPresence('open')\n setCopyState('idle')\n mint()\n }, [mint])\n\n // Escape, the mask click, the focus trap and focus restoration belong to the\n // official Modal; this only decides what closing means for the presence, and\n // it invalidates a read that is still in flight.\n const requestClose = useCallback((): void => {\n generation.current += 1\n setPresence((current) => (current === 'closed' ? 'closed' : 'closing'))\n }, [])\n\n const finishClose = useCallback((): void => {\n setPresence((current) => (current === 'closing' ? 'closed' : current))\n }, [])\n\n const closing = presence === 'closing'\n const showing = presence !== 'closed'\n\n // Safety net for the leave leg: the card normally reports its own animation or\n // transition end, and this bound covers the case where neither arrives.\n useEffect(() => {\n if (!closing) return\n const timer = window.setTimeout(() => { finishClose() }, EXIT_TIMEOUT_MS)\n return () => { window.clearTimeout(timer) }\n }, [closing, finishClose])\n\n // One ticker per live code; it clears itself at the deadline, so a panel left\n // open on an expired code stops re-rendering instead of ticking forever.\n useEffect(() => {\n if (presence !== 'open' || state.kind !== 'ready') return\n const deadline = state.expiresAt\n const timer = window.setInterval(() => {\n const current = Date.now()\n setNow(current)\n if (current >= deadline) window.clearInterval(timer)\n }, TICK_MS)\n return () => { window.clearInterval(timer) }\n }, [presence, state])\n\n const handleCopy = useCallback((payload: string): void => {\n void copy(payload).then((ok) => {\n setCopyState(ok ? 'copied' : 'failed')\n window.setTimeout(() => { setCopyState('idle') }, COPY_FEEDBACK_MS)\n })\n }, [copy])\n\n return (\n <>\n <button\n type=\"button\"\n className={css.trigger}\n data-dsh-plugin={PLUGIN_ATTR}\n data-dsh-part={PART_ENTRY}\n data-wide={wide ? 'wide' : 'rail'}\n aria-label={t('entry.label')}\n aria-expanded={showing}\n aria-controls={showing ? panelId : undefined}\n title={t('entry.label')}\n onClick={openPanel}\n >\n <QrIcon />\n </button>\n {showing && (\n <PairPanel\n id={panelId}\n t={t}\n state={state}\n now={now}\n host={window.location.host}\n copy={copyState}\n showing={showing}\n closing={closing}\n onClose={requestClose}\n onExited={finishClose}\n onRefresh={mint}\n onCopy={handleCopy}\n />\n )}\n </>\n )\n}\n","/**\n * The frozen protocol surface: method names, topic names, refusal codes, and\n * the one authorization rule the dispatcher enforces before any method runs.\n * @module dsh-remote-bridge/core/protocol\n */\n\n/** Client-callable methods of protocol v1. */\nexport const METHOD_HELLO = 'hello'\nexport const METHOD_SESSION_LIST = 'session.list'\nexport const METHOD_SESSION_TITLES = 'session.titles'\nexport const METHOD_SESSION_SNAPSHOT = 'session.snapshot'\nexport const METHOD_SESSION_HISTORY = 'session.history'\nexport const METHOD_SESSION_HISTORY_DEEP = 'session.history.deep'\nexport const METHOD_SESSION_PROMPT = 'session.prompt'\nexport const METHOD_SESSION_INTERRUPT = 'session.interrupt'\nexport const METHOD_SESSION_ATTACHMENT = 'session.attachment'\nexport const METHOD_SESSION_ATTACHMENT_PATH = 'session.attachment.path'\nexport const METHOD_SESSION_PERMISSIONS = 'session.permissions'\nexport const METHOD_SESSION_SET_PERMISSION = 'session.setPermission'\nexport const METHOD_SESSION_MODELS = 'session.models'\nexport const METHOD_SESSION_SET_MODEL = 'session.setModel'\n/** Remember one model's reasoning level, without switching the session's model. */\nexport const METHOD_SESSION_SET_EFFORT = 'session.setEffort'\nexport const METHOD_SESSION_CREATE = 'session.create'\nexport const METHOD_SESSION_FORK = 'session.fork'\nexport const METHOD_SESSION_COMMANDS = 'session.commands'\nexport const METHOD_SESSION_COMMAND = 'session.command'\nexport const METHOD_SESSION_RENAME = 'session.rename'\nexport const METHOD_SESSION_PIN = 'session.pin'\nexport const METHOD_SESSION_UNPIN = 'session.unpin'\nexport const METHOD_SESSION_ARCHIVE = 'session.archive'\nexport const METHOD_SESSION_UNARCHIVE = 'session.unarchive'\nexport const METHOD_WORKSPACE_LIST = 'workspace.list'\nexport const METHOD_PRESETS_LIST = 'presets.list'\nexport const METHOD_PAIR_BEGIN = 'pair.begin'\nexport const METHOD_PAIR_FINISH = 'pair.finish'\nexport const METHOD_APPROVAL_RESOLVE = 'approval.resolve'\nexport const METHOD_QUESTION_ANSWER = 'question.answer'\nexport const METHOD_QUESTION_LIST = 'question.list'\nexport const METHOD_JOBS_LIST = 'jobs.list'\nexport const METHOD_SQUADS_STATE = 'squads.state'\nexport const METHOD_SQUADS_LIST = 'squads.list'\nexport const METHOD_SQUADS_RUNS = 'squads.runs'\nexport const METHOD_SQUADS_RUN_MEMBER = 'squads.runMember'\nexport const METHOD_SQUADS_RUN_SQUAD = 'squads.runSquad'\nexport const METHOD_PUSH_REGISTER = 'push.register'\nexport const METHOD_USAGE_SESSION = 'usage.session'\nexport const METHOD_USAGE_BALANCE = 'usage.balance'\nexport const METHOD_USAGE_STATS = 'usage.stats'\n// 协议 §35 追加的两个方法:一条卡上的动作回来,以及一张全局卡表的对账读。\nexport const METHOD_UI_EVENT = 'ui.event'\nexport const METHOD_UI_LIST = 'ui.list'\n/**\n * 一条配对连接把手机从账号服务换到的中继授权交给宿主。\n *\n * 它是这条通道唯一的写动作:授权落进那台设备自己的名册行,随后宿主拿它去第二\n * 会合点申领租约。宿主不认识账号——它只会看到「准了」或「不准」,绝不会从这一帧\n * 里读出用户是谁。只在配了第二会合点的宿主上是这个方法(见 {@link CAP_RELAY_TIER})。\n */\nexport const METHOD_RELAY_GRANT = 'relay.grant'\n\n/** Server-pushed topics of protocol v1. */\nexport const TOPIC_SESSION_DELTA = 'session.delta'\nexport const TOPIC_APPROVAL_REQUEST = 'approval.request'\nexport const TOPIC_QUESTION_REQUEST = 'question.request'\nexport const TOPIC_JOBS_CHANGED = 'jobs.changed'\n// §35.2 追加的主题:一块整页自包含文档,以及它自己的结算通知。\nexport const TOPIC_UI_REQUEST = 'ui.request'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to ask for a trimmed\n * `session.snapshot` baseline. A client that does not declare it — including\n * every client written before this capability existed — is served exactly the\n * baseline protocol v1 always served.\n */\nexport const CAP_SESSION_SNAPSHOT_TRIM = 'session.snapshot.trim.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to have\n * `session.snapshot` answer with one bounded page instead of the whole opening\n * window. Declaring it is what makes an opening screen cost one page rather\n * than a whole session; a client that does not declare it — including every\n * client written before this capability existed — receives byte for byte the\n * snapshot protocol v1 always served.\n */\nexport const CAP_SESSION_SNAPSHOT_PAGE = 'session.snapshot.page.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to have\n * `session.snapshot` answer a reconnect with only what it missed.\n *\n * The declaration and the request's `sinceSeq` are what it takes together: a\n * snapshot that carries no `sinceSeq` is answered, byte for byte, the body\n * protocol v1 always served, whether or not the client declared this. Behind\n * both, the client names the durable `lastSeq` of a snapshot it already holds\n * and the answer is either that same reply in an incremental form —\n * `{turns, lastSeq, mode:\"since\", reset:false}` carrying only the entries above\n * that watermark — or a full baseline with `mode:\"full\"` and `reset:true`,\n * which is the one answer that tells a client to throw its copy away. The\n * estimate is only served when the bridge can PROVE nothing was lost: the\n * current follow window's oldest entry must sit at or below `sinceSeq + 1`, so a\n * window that has already scrolled past the watermark answers the baseline\n * instead of a delta with a hole in it. It exists because a reconnect on the\n * phone re-paid 0.86-1.06 s of baseline five times in one measured run.\n */\nexport const CAP_SESSION_SNAPSHOT_SINCE = 'session.snapshot.since.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be shown the\n * host's pending user questions and to answer them with `question.answer`.\n *\n * Declaring it is what makes `question.request` reachable and what makes the\n * method part of that client's protocol at all: a client that does not declare\n * it — including every client written before this channel existed — receives no\n * such event, and its `question.answer` is refused as an unknown method,\n * exactly as that frame was refused before.\n */\nexport const CAP_QUESTIONS = 'questions.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to learn that this\n * bridge can list the user questions it is still holding.\n *\n * An announcement rather than a switch, the same shape as\n * {@link CAP_SESSION_DEEP_HISTORY}: `question.list` is reachable from every\n * client that declared {@link CAP_QUESTIONS}, exactly as `question.answer` is,\n * so a client written before this name existed loses nothing by declaring it\n * and nothing by never calling the method. What the name buys is a way to tell\n * a bridge that serves the method from one that does not: a host built before\n * it answers `unknown-method`, so a client that does not find this name in\n * `hello`'s `capabilities` keeps the retirement rule it had — a card is over\n * when `question.request` says `settled` — instead of reaping cards on an\n * answer it cannot trust.\n */\nexport const CAP_QUESTION_LIST = 'questions.list.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be handed the\n * approval questions this bridge is already holding for it.\n *\n * Unlike every channel capability beside it, this one gates a second delivery\n * rather than the channel: `approval.request` still reaches every paired\n * connection the moment a tool asks, exactly as it did before this name\n * existed, because gating the first broadcast would take approvals away from\n * every client written before the capability. What the declaration buys is the\n * replay — after a reconnect, or on a session screen opened late, the client is\n * handed the questions that are still waiting instead of a card it never saw.\n * Only a live claim is replayed: a question that was answered, that the bridge\n * timed out, or that was withdrawn with the last phone is gone from the claim\n * registry before the replay reads it.\n *\n * It is deliberately absent from {@link SERVED_CAPABILITIES}: that list is what\n * `hello` advertises as served, advertising a capability is a minor-version\n * addition (see {@link MINOR}), and this channel changes nothing a client can\n * observe in the handshake — no answer, no field and no method behind it. The\n * declaration is the whole switch, and the name reaches a client through this\n * bridge's own protocol documentation.\n */\nexport const CAP_APPROVALS = 'approvals.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told where a\n * message came from and that an agent spawned a child session.\n *\n * Declaring it is what makes the `subagent` delta part of that client's\n * protocol: a client that does not declare it — including every client written\n * before this channel existed — receives no such event, exactly as that frame\n * was dropped before. The `actor` of a `user-message` is not gated: it is an\n * additive field a client that does not read it ignores.\n */\nexport const CAP_SUBAGENT_THREAD = 'subagent.thread.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to see the host's\n * background jobs and to be told when the set changes.\n *\n * Declaring it is what makes `jobs.list` reachable, and `jobs.list` is the only\n * thing that opens a roster: a connection that declares this capability but\n * never asks for a scope receives no `jobs.changed` at all. A client that does\n * not declare it — including every client written before this channel existed —\n * receives no such event, and its `jobs.list` is refused as an unknown method,\n * exactly as that frame was refused before.\n */\nexport const CAP_JOBS = 'jobs.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * Agent presets and to instantiate one as a session.\n *\n * Declaring it is what makes `presets.list` and `session.create` part of that\n * client's protocol at all: a client that does not declare it — including every\n * client written before this channel existed — is refused both as unknown\n * methods, exactly as those frames were refused before. Neither method is\n * called on a connection's behalf either, so a client that never asks sends the\n * host no request.\n */\nexport const CAP_AGENTS = 'agents.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * agent squads and to drive them.\n *\n * Declaring it is what makes `squads.state`, `squads.list`, `squads.runs`,\n * `squads.runMember` and `squads.runSquad` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused each as an unknown method, exactly as those\n * frames were refused before. No command is called on a connection's behalf\n * either, so a client that never asks sends the host no request.\n *\n * The channel is additive beside {@link CAP_AGENTS} rather than a replacement:\n * a phone that predates the squad model keeps the preset roster and session\n * creation it was written against, and a phone that reads this name reads the\n * squad domain instead of deriving agents from anything else.\n */\nexport const CAP_SQUADS = 'squads.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to register the APNs\n * token this device wants to be notified on.\n *\n * Declaring it is what makes `push.register` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused that frame as an unknown method, and no\n * device row is written on its behalf.\n *\n * The name announces that this bridge can REMEMBER a token, not that it will\n * send anything. Whether a notification ever leaves the process is a deployment\n * fact (is an APNs signing key configured?) that the wire deliberately cannot\n * express: a bridge with no key answers `ok:true` exactly like one with a key,\n * because a client has no second code path to keep for the difference. Every\n * notification this channel produces is an outbound APNs request and nothing\n * else — no topic, no frame and no state is added to `/ios/v1` (see the\n * protocol's §28).\n */\nexport const CAP_PUSH = 'push.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要读本桥自己的用量读数。\n *\n * 宣告它是 `usage.session` 与 `usage.balance` 进入这个客户端协议的唯一前提:\n * 不宣告的客户端——包括这个通道出现之前写下的每一个客户端——收到的是与从前\n * 逐字一样的 `unknown-method`,本桥也不会替它读一条会话、更不会替它打一次\n * 上游余额端点。\n *\n * 一个能力名带两个方法,因为它们读的是同一件事的两面:一条会话下一次请求由\n * 什么组成(上下文窗口取宿主自己广播的值,组成由本桥按文本长度估算并恒标\n * `estimated: true`),以及某条 provider 路由背后账户的余额(DeepSeek 官方\n * 口径,只在路由确实指向 `api.deepseek.com` 且凭据拿得到时才查官方端点,宿主\n * 侧同一 provider + 凭据 60 秒最多一次上游请求)。\n */\nexport const CAP_USAGE = 'usage.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要读宿主自己的用量台账聚合。\n *\n * 与 {@link CAP_USAGE} 平级、独立声明:宣告它是 `usage.stats` 进入这个客户端\n * 协议的唯一前提,不宣告的客户端——包括 `usage.v1` 出现之后、这个能力出现之前\n * 写下的每一个客户端——收到的仍是 `unknown-method`,本桥也不会替它去读宿主\n * 上 `dsh-usage` 插件的任何一条路由。\n *\n * 拆成独立能力而不是塞进 `usage.v1`,是因为它读的是另一件事:那两半读的是本\n * 进程自己的事实(一个会话、一条路由的账户),这一半读的是另一个插件挂在这个\n * 宿主上的 HTTP 路由,而那个插件可能根本没装。老客户端忽略这个未知名字即可,\n * 它看到的能力表里多一项、别的什么都没有变。\n */\nexport const CAP_USAGE_STATS = 'usage.stats.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要渲染整页卡并回答它(协议 §35)。\n *\n * 宣告它是 `ui.request` 与 `ui.event` 进入这个客户端协议的唯一前提:不宣告的\n * 客户端——包括这个通道出现之前写下的每一个客户端——收不到任何一帧整页卡,它的\n * `ui.event` 回 `unknown-method`,其余逐字节不变。它是**公告不是协商**(§13.1、\n * §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,\n * 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。\n *\n * 宿主半区只有真实现了 `ui_present` 这一半的桥才把自己列进\n * {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`\n * 会出现、`ui.event` 会被接受。\n */\nexport const CAP_UI = 'ui.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要按 §24.3 的四条件对账自己手上的整页卡\n * (协议 §35.4)。\n *\n * 与 {@link CAP_QUESTION_LIST} 同一形状:`ui.list` 本身是只读的、对每条配对连接\n * 都开放,这个名字买到的是「这条连接会不会被答」之外的另一种确定性——一条老桥\n * 回 `unknown-method`,于是没有这个名字的客户端就保留它原有的退休规则(卡片只在\n * `ui.request` 说 `settled` 时结束),而不是按一次它信不过的应答清卡。\n */\nexport const CAP_UI_LIST = 'ui.list.v1'\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that this\n * bridge can hand it the bytes of an image a session already offloaded.\n *\n * An announcement and nothing more, the same shape as\n * {@link CAP_SESSION_DEEP_HISTORY}: `session.attachment.path` is open to every\n * paired connection, because it is a pure read of one session's own durable\n * transcript that costs no other client anything. Declaring the capability is how\n * a client learns the method exists, and a client that does not declare it loses\n * only that knowledge — it never sees a frame from this channel, because it never\n * asks for one.\n */\nexport const CAP_SESSION_ATTACHMENT_PATH = 'session.attachment.path.v1'\n\n/**\n * 宿主配了第二会合点时,在 `hello` 的 `capabilities` 里公告的能力名。\n *\n * 它是这条通道的全部门槛,而且门槛落在宿主这一侧:一个配了第二会合点的宿主才\n * 公告这个名字、才收 {@link METHOD_RELAY_GRANT},客户端读到它之后才把授权发过来。\n * 不配第二会合点的宿主——也就是缺省配置的每一台——公告表里没有这个名字,\n * `relay.grant` 对它仍是 `unknown-method`,名册里也不会因此多出一个块:缺省\n * 宿主的握手与名册与这条通道出现之前逐字相同。\n *\n * 正因为它是**条件**公告,{@link MINOR} 不随它抬格:minor 描述的是这个协议本身,\n * 而缺省宿主在线路上读不到任何新东西(设计冻结在 21)。客户端因此按名字判断而不是\n * 按 minor 判断:读不到这个名字就什么都不发。\n */\nexport const CAP_RELAY_TIER = 'relay.tier.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be answered with\n * byte-level increments instead of the whole roster or the whole board.\n *\n * Behind it, `session.list` and `board.snapshot` (the latter through the board\n * plugin, §15) accept an opaque `since` token and answer either the whole set\n * (`mode:\"reset\"`) or only what changed since the set that token names. A\n * client that does not declare it — including every client written before this\n * channel existed — is answered today's body plus the ignorable `mode` and\n * `token` keys, with `mode` always `\"reset\"`.\n */\nexport const CAP_DELTA = 'delta.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that an\n * archived session is not in the roster at all.\n *\n * Unlike every capability beside it this one negotiates nothing: the bridge\n * never transfers an archived session, whether or not a client declares it, so\n * an older client simply receives the shorter roster it would have hidden\n * anyway. The name is an announcement of that fact, so a client can stop\n * filtering for itself: behind it, no `session.list` row is a session the\n * host's archive set names, a row that does survive still carries\n * `archived: false` under the same schema, and a live child of an archived\n * parent still crosses with its `parentSessionId` — the parent id, not the\n * parent row.\n */\nexport const CAP_ROSTER_OMITS_ARCHIVED = 'session.list.omit-archived.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be answered a\n * compact roster it can page.\n *\n * The declaration alone changes nothing: a listing that carries none of the\n * compact parameters (`cwd`, `maxRows`, `after`) is answered exactly the body\n * protocol v1 always served, so a client can opt into the name before it\n * relies on any of it. Behind the parameters, a row drops its absolute `cwd`\n * unless the request asks for it, drops its `updatedAt` when this connection\n * already sent that id the same value, and a `maxRows`/`after` pair cuts the\n * roster into pages ordered most recent first. The roster is the most repeated\n * large reply on the link, so this is what lets a reconnect pay for the newest\n * screenful plus a cursor instead of the whole list again.\n */\nexport const CAP_ROSTER_COMPACT = 'session.list.compact.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that this\n * bridge can page a session's durable history down to its oldest entry.\n *\n * The capability is an announcement and nothing more. `session.history.deep` is\n * open to every paired connection, exactly as `session.history` is, because it\n * is a pure read of the session store that costs no other client anything;\n * declaring the capability is how a client learns the method exists, and a\n * client that does not declare it loses only that knowledge.\n */\nexport const CAP_SESSION_DEEP_HISTORY = 'session.deep-history.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to fork a session.\n *\n * Declaring it is what makes `session.fork` part of that client's protocol at\n * all: a client that does not declare it — including every client written\n * before this channel existed — is refused `unknown-method`, and no fork is\n * asked of the host on its behalf. Behind the name the bridge forwards one\n * `SessionForkRequest` to the host's `session/fork` and hands back the host's\n * own `SessionForkValue`, so what a fork point means stays the host's: an\n * `atSeq` is the source event seq the fork includes, an omitted one is the\n * newest finished turn, and a cut the host opens itself is closed by the host's\n * own synthetic finishing event. Nothing about a fork is modelled or\n * re-derived here.\n */\nexport const CAP_SESSION_FORK = 'session.fork.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to list a session's\n * slash commands and skills and to run one of them.\n *\n * Declaring it is what makes `session.commands` and `session.command` part of\n * that client's protocol at all: a client that does not declare it — including\n * every client written before this channel existed — is refused both as unknown\n * methods, exactly as those frames were refused before. Neither method is called\n * on a connection's behalf either, so a client that never asks costs the host no\n * registry read and no skill catalog read.\n *\n * The channel holds no events and no cache: a directory is read live on every\n * call, so a command a plugin registered a moment ago and a skill withdrawn from\n * one Agent preset are both reflected in the answer that follows.\n */\nexport const CAP_COMMANDS = 'commands.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * workspaces and its two registry-global session sets.\n *\n * Declaring it is what makes `workspace.list` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused that frame as an unknown method, and no\n * registry is read on its behalf. Behind the name the answer is the host's own\n * synchronous projection: one row per registered workspace in registry order,\n * plus the complete archive and pin sets.\n *\n * The method is a read and nothing is cached, so a pin or an archive followed by\n * another list reads the set the write left behind. That pair of calls is the\n * whole refresh story of the session-admin channel: see {@link CAP_SESSION_ADMIN}.\n */\nexport const CAP_WORKSPACE = 'workspace.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to rename, pin,\n * unpin, archive and unarchive a session.\n *\n * Declaring it is what makes those five methods part of that client's protocol\n * at all: a client that does not declare it — including every client written\n * before this channel existed — is refused each as an unknown method, and no\n * write is asked of the host on its behalf.\n *\n * Every one of the five is forwarded one-to-one to the endpoint that already\n * owns the semantics, so nothing about a title, a pin or an archive is modelled\n * or re-derived here: a rename reaches `session/rename` — the endpoint that\n * restores a cold session before it writes, which is why a client needs no\n * resume path of its own — and the four set mutations reach\n * `workspace/pinSession`, `workspace/unpinSession`, `workspace/archiveSession`\n * and `workspace/unarchiveSession`. A host refusal crosses with its own code\n * and text, `workspace/session-active` included.\n *\n * The channel publishes no event, because the host announces none of these\n * writes as a cordis event a connection could fold into a delta: a rename\n * appends one `session/title` log record and nothing else. A client re-reads\n * after a write instead — the pin set through {@link CAP_WORKSPACE}, the roster\n * through `session.list` — which is why one branch serves both capabilities.\n */\nexport const CAP_SESSION_ADMIN = 'session.admin.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be sent frames\n * compressed instead of as plain text.\n *\n * Declaring it is what allows the host to compress at all: a frame whose JSON\n * text is at least 1024 UTF-8 bytes crosses as one WebSocket binary frame\n * carrying raw DEFLATE (RFC 1951) of exactly that text, and a frame that does\n * not get smaller still crosses as the text frame it always was. A client that\n * does not declare it — including every client written before this capability\n * existed — receives byte for byte the text frames protocol v1 always wrote.\n *\n * The direction is one way: a client still sends text frames only, and the\n * 10 MiB frame cap stays measured on the text, before inflation.\n */\nexport const CAP_FRAME_DEFLATE = 'frame.deflate.v1'\n\n/**\n * Methods an unpaired connection may still call: the handshake itself and the\n * two pairing steps. Everything else answers `unpaired` — a caller can pair\n * without a device token, but cannot touch a session without one.\n */\nexport const UNPAIRED_METHODS: ReadonlySet<string> = new Set([\n METHOD_HELLO,\n METHOD_PAIR_BEGIN,\n METHOD_PAIR_FINISH,\n])\n\n/** Every method this protocol version serves. */\nexport const KNOWN_METHODS: ReadonlySet<string> = new Set([\n METHOD_HELLO,\n METHOD_SESSION_LIST,\n METHOD_SESSION_TITLES,\n METHOD_SESSION_SNAPSHOT,\n METHOD_SESSION_HISTORY,\n METHOD_SESSION_HISTORY_DEEP,\n METHOD_SESSION_PROMPT,\n METHOD_SESSION_INTERRUPT,\n METHOD_SESSION_ATTACHMENT,\n METHOD_SESSION_ATTACHMENT_PATH,\n METHOD_SESSION_PERMISSIONS,\n METHOD_SESSION_SET_PERMISSION,\n METHOD_SESSION_MODELS,\n METHOD_SESSION_SET_MODEL,\n METHOD_SESSION_SET_EFFORT,\n METHOD_PAIR_BEGIN,\n METHOD_PAIR_FINISH,\n METHOD_APPROVAL_RESOLVE,\n METHOD_QUESTION_ANSWER,\n METHOD_QUESTION_LIST,\n METHOD_JOBS_LIST,\n METHOD_PRESETS_LIST,\n METHOD_SESSION_CREATE,\n METHOD_SESSION_FORK,\n METHOD_SESSION_COMMANDS,\n METHOD_SESSION_COMMAND,\n METHOD_SESSION_RENAME,\n METHOD_SESSION_PIN,\n METHOD_SESSION_UNPIN,\n METHOD_SESSION_ARCHIVE,\n METHOD_SESSION_UNARCHIVE,\n METHOD_WORKSPACE_LIST,\n METHOD_SQUADS_STATE,\n METHOD_SQUADS_LIST,\n METHOD_SQUADS_RUNS,\n METHOD_SQUADS_RUN_MEMBER,\n METHOD_SQUADS_RUN_SQUAD,\n METHOD_PUSH_REGISTER,\n METHOD_USAGE_SESSION,\n METHOD_USAGE_BALANCE,\n METHOD_USAGE_STATS,\n METHOD_UI_EVENT,\n METHOD_UI_LIST,\n METHOD_RELAY_GRANT,\n])\n\n/** Refusal codes the bridge itself raises (DSH failures cross as their own code). */\nexport const CODE_UNPAIRED = 'unpaired'\nexport const CODE_UNKNOWN_METHOD = 'unknown-method'\nexport const CODE_INVALID_ARGS = 'invalid-args'\n/**\n * `usage.session` 点名的会话在这个宿主上不存在:宿主自己的会话名册里没有它,\n * 活会话存储里没有它,本进程也从未观察过它的任何事件。它与「会话存在但两项\n * 读数都取不到」是两个答案,后者回的是空对象——一条刚刚开始、还什么都没广播\n * 的会话,以及一条在桥重载前就存在的会话,都在那个状态里:存在而没读数,不是\n * 不存在。\n */\nexport const CODE_UNKNOWN_SESSION = 'unknown-session'\nexport const CODE_PROTO_UNSUPPORTED = 'proto-unsupported'\nexport const CODE_TOKEN_INVALID = 'token-invalid'\nexport const CODE_NONCE_INVALID = 'nonce-invalid'\nexport const CODE_SIGNATURE_INVALID = 'signature-invalid'\nexport const CODE_APPROVAL_UNKNOWN = 'approval-unknown'\n/**\n * The bridge does not hold the named question: it never claimed that call id, it\n * already answered it, or the host no longer holds it as answerable. Host\n * failures crossing this method keep their own codes instead.\n */\nexport const CODE_QUESTION_UNKNOWN = 'question-unknown'\n/**\n * The bridge could not read the questions it is holding, so it cannot say which\n * ones are still live. The answer is deliberately not an empty list: a client\n * retires every card a COMPLETE list does not carry, and a read that failed is\n * not a complete one — it is a bridge that cannot answer this question today.\n */\nexport const CODE_QUESTION_LIST_UNAVAILABLE = 'question-list-unavailable'\n/**\n * 本桥不认领这个 `callId`:它从没呈现过这张卡,或者这张卡已被别处结算(宽限窗口\n * 到期、回合被取消、桥卸载)。客户端码表保持开放:除本码之外的未知码不得被读成\n * 「卡已消失」(§11.3 同一句)。\n */\nexport const CODE_UI_UNKNOWN = 'ui-unknown'\n/**\n * 这张卡已经被用户自己的第一条动作结算过(§35.3)。它与 {@link CODE_UI_UNKNOWN}\n * 是两个答案:重复的一次点击是「已经做完了」,不是「这张卡不存在」。\n */\nexport const CODE_UI_SETTLED = 'ui-settled'\n/**\n * 本桥读不出自己持有的卡,所以它说不了哪些还活着。答案故意不是一张空表:客户端\n * 只会按 COMPLETE 的列表退休卡片,一次失败的读不是一张完整的空表,而是这台桥今天\n * 答不了这一问(与 {@link CODE_QUESTION_LIST_UNAVAILABLE} 同一句)。\n */\nexport const CODE_UI_LIST_UNAVAILABLE = 'ui-list-unavailable'\n/**\n * The named session is a delegated child whose durable parent is not a session\n * this connection may read. The bridge follows an addressable child and refuses\n * an unaddressable one, rather than reading it blind.\n */\nexport const CODE_SESSION_NOT_FOLLOWABLE = 'session-not-followable'\n/**\n * 该路径不在这次会话自己的持久 transcript 里:白名单只有两处来源,客户端自选的路径\n * 一律不在其中。该名字本身是个链接时也回这一码——它已被换成指向别处的一层门面,就\n * 不再是这次会话点过的那个文件。判据看的是条目自身(`lstat`),不比较 `realpath()`\n * 的解析结果:同一个文件的两种写法(Windows 8.3 短名、macOS `/var` 前缀)不等于换目标。\n */\nexport const CODE_PATH_NOT_IN_SESSION = 'path-not-in-session'\n/**\n * 白名单里有这个路径,但它已经不是一个常规文件:文件被删了,或被换成了目录、设备或\n * fifo。它与 {@link CODE_PATH_NOT_IN_SESSION} 是两个答案——「这次会话没点过它」与\n * 「点过的那个文件不在了」。\n */\nexport const CODE_ATTACHMENT_NOT_FOUND = 'not-found'\n/**\n * 文件确实在,但它的文件头魔数不是 png/jpeg/webp/gif 四种之一。扩展名不作数:`.png`\n * 里装的不是 PNG 就回这一码,而一个叫 `.txt` 的 PNG 照常服务。\n */\nexport const CODE_NOT_AN_IMAGE = 'not-an-image'\nexport const CODE_SNAPSHOT_UNAVAILABLE = 'snapshot-unavailable'\n/**\n * This host composes no job registry, so it has no background jobs to publish.\n * The capability stays advertised — it is a fact about this bridge, not about\n * what a particular host mounts — and only a call that needs the registry fails.\n */\nexport const CODE_JOBS_UNAVAILABLE = 'jobs-unavailable'\n/**\n * This host serves no endpoint behind the command channel: no `commands/list`,\n * no `commands/execute` or no `skills/list`, which the gateway itself reports\n * as an endpoint nothing exports. The capability stays advertised — it is a fact\n * about this bridge, not about what a particular host mounts — and only a call\n * that needs those endpoints fails.\n */\nexport const CODE_COMMANDS_UNAVAILABLE = 'commands-unavailable'\n/**\n * This host serves no squad domain this bridge can reach: no answer to the\n * plugin's state route over loopback, no readable ledger beside it, or a body\n * this build cannot read as one squad domain. The capability stays advertised —\n * it is a fact about this bridge, not about what a particular host mounts — and\n * only a call that needs the domain fails. A refusal the `dsh-agents` plugin\n * itself raised crosses with the plugin's own code instead (`team-not-found`,\n * `member-not-found`, `preset-unknown`, `workspace-unavailable` and their\n * neighbours).\n */\nexport const CODE_SQUADS_UNAVAILABLE = 'squads-unavailable'\n/**\n * The definitions are readable but the two run commands cannot be served: this\n * host answered no run route over loopback, and the read-only ledger fallback\n * cannot launch anything. Failing closed is the point — a client is told the\n * capability is not served here rather than shown a run that never started.\n */\nexport const CODE_SQUADS_RUN_UNAVAILABLE = 'squads-run-unavailable'\nexport const CODE_SNAPSHOT_TOO_LARGE = 'snapshot-too-large'\nexport const CODE_INTERNAL = 'internal'\n\n/** Protocol version this package speaks. */\nexport const PROTO = 1\n/**\n * Minor version this package speaks.\n *\n * 22 当按路径取图落地(与协议 §18 的 `session.history.deep` 同例的一条读通道):\n * 新增 {@link CAP_SESSION_ATTACHMENT_PATH} 一个能力名与\n * {@link METHOD_SESSION_ATTACHMENT_PATH} 一个方法,客户端因此从线路上读到一种新的\n * 应答体,所以 minor 抬一格。这个方法对每一条已配对连接都开放,能力名只公告:它决定\n * 的是客户端要不要露出取图能力,不决定桥放不放行,理由与 {@link CAP_SESSION_DEEP_HISTORY}\n * 逐字相同。`proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状;不声明这个\n * 名字的客户端一帧都不发,两边互不知情时线路逐字节不变。\n * 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}\n * 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与\n * {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui_present`。客户端\n * 因此从线路上读到两项新能力名、一种新主题与两种新应答体,所以 minor 抬一格;\n * `proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状。工具结果是**新增**的:\n * 老会话、老 prompt、老回合都不受影响,工具名进入宿主工具表之后只有新回合才可能\n * 被调用。\n * 20 when the usage stats channel shipped: behind {@link CAP_USAGE_STATS} a\n * client may call {@link METHOD_USAGE_STATS} and read the host's own usage\n * ledger — today, this month and one row per local day — and behind the same\n * {@link CAP_USAGE} this bridge now also answers `usage.session` with a\n * `modelContextWindow` when the model catalog of the session's route declares\n * one, so a client reads one new reply body and one new optional key off the\n * wire and has to read the name before it asks. The stats half is independent\n * of {@link CAP_USAGE} on purpose: it reads another plugin's HTTP routes, which\n * a host may not mount at all, so a client written before this name existed\n * keeps the two readings it had and the bridge reads no route on its behalf.\n * No frame, no topic, no existing method and no existing key changes shape.\n * 19 when the usage channel shipped: behind {@link CAP_USAGE} a client may call\n * {@link METHOD_USAGE_SESSION} and read one session's context window and its\n * request's estimated composition, and {@link METHOD_USAGE_BALANCE} and read the\n * account behind one provider route, so it reads two new reply bodies off the\n * wire and has to read the name before it asks — a bridge below this one answers\n * `unknown-method` for both. No frame, no topic and no existing method changes\n * shape.\n * 18 when one card learned to lay out several sessions (§30 of\n * `docs/protocol-v1.md` in the iphone_remote_use_dsh repository): `content-state`\n * gains the optional `rows` key, so a phone reads up to three sessions off one\n * lock-screen card instead of having to hold one card per session. It is a pure\n * addition — no new method, no new capability name, no existing key or topic\n * changes shape — so the minor counts the key alone, and a client that reads 18\n * knows the order of the rows it is handed is the bridge's rather than one it\n * has to derive.\n * 17 when the live-activity channel shipped (§29.2): this bridge now sends the\n * lock-screen card a suspended app cannot update itself, addressed to the\n * per-card APNs tokens {@link METHOD_PUSH_REGISTER} already carries and projected\n * per session rather than per bridge. It is a pure addition — no new method, no\n * new capability name, and no existing frame, field or topic changes shape — so\n * the minor counts it alone: a client that wants a card has to read 17 before it\n * registers one, because a bridge below this one has no sending path at all and\n * would answer `ok:true` to a registration it can never use.\n * 16 when the push channel shipped: behind {@link CAP_PUSH} a client may call\n * {@link METHOD_PUSH_REGISTER} and have the device table remember an APNs token,\n * so a phone learns a turn ended — or that a question is waiting — while its\n * socket is not open. No frame, no topic and no existing method changes shape;\n * the minor is raised because a new reply body and a new announcement appear on\n * the wire, and because a client has to read the name before it registers.\n * 15 when the squads channel shipped: behind {@link CAP_SQUADS} a client may\n * call {@link METHOD_SQUADS_STATE}, {@link METHOD_SQUADS_LIST},\n * {@link METHOD_SQUADS_RUNS}, {@link METHOD_SQUADS_RUN_MEMBER} and\n * {@link METHOD_SQUADS_RUN_SQUAD}, so it reads five new reply bodies off the wire\n * and drives the squad domain instead of deriving its agents from anything else.\n * 14 when the session-admin channel shipped: behind {@link CAP_WORKSPACE} a\n * client may call {@link METHOD_WORKSPACE_LIST} and read the host's workspaces\n * with both registry-global session sets, and behind {@link CAP_SESSION_ADMIN}\n * it may call {@link METHOD_SESSION_RENAME}, {@link METHOD_SESSION_PIN},\n * {@link METHOD_SESSION_UNPIN}, {@link METHOD_SESSION_ARCHIVE} and\n * {@link METHOD_SESSION_UNARCHIVE}, so a phone long-presses a roster row for the\n * same five actions the desktop offers it.\n * 13 when the question list shipped: behind {@link CAP_QUESTION_LIST} a client\n * may call {@link METHOD_QUESTION_LIST} and be answered the questions this\n * bridge is still holding, so it reads a new reply body off the wire and the\n * number rises with it. It is what lets a phone stop trusting a card it holds:\n * the one retirement signal before it was `question.request` with\n * `state: \"settled\"`, which a phone that was disconnected when the last client\n * left never receives.\n * 12 when the command channel shipped: behind {@link CAP_COMMANDS} a client may\n * call {@link METHOD_SESSION_COMMANDS} and {@link METHOD_SESSION_COMMAND}, so it\n * reads a new reply body off the wire and the number rises with it.\n * 11 when the fork channel shipped: behind {@link CAP_SESSION_FORK} a client may\n * call {@link METHOD_SESSION_FORK} and receive the host's own fork answer, so a\n * phone branches a session that inherits the context of the one it forked. This\n * is the second of two appends cut from 9 — the snapshot-`since` channel took\n * 10 on the integration branch first — so the number steps over the one already\n * on `dev`: the minor counts additions to this protocol, and a later landing\n * steps over the earlier one instead of reusing its number.\n * 10 when the snapshot became incremental on request: behind\n * {@link CAP_SESSION_SNAPSHOT_SINCE} a `session.snapshot` that names `sinceSeq`\n * is answered either the entries above that watermark or a full baseline\n * carrying `mode` and `reset`, so a client reads a new reply shape off the\n * wire and the number rises with it.\n * 9 when the compact roster shipped: behind {@link CAP_ROSTER_COMPACT} a\n * `session.list` that names one of the compact parameters is answered a\n * shorter row and may be cut into pages, so a client reads a new row schema\n * off the wire and the number rises with it.\n * 8 when the outbound frame form became a capability: behind\n * {@link CAP_FRAME_DEFLATE} a declaring client may be answered in binary\n * frames carrying raw DEFLATE of the text, so the minor is raised for a change\n * a client reads off the wire rather than for a name alone.\n * 7 when the two channels met: the agent channel and the durable history\n * channel each raised 5 to 6 on its own branch, so the protocol that carries\n * both is 7. 6 when the agent channel shipped: behind {@link CAP_AGENTS}\n * `presets.list` forwards the host's Agent-preset roster and `session.create`\n * hands the host one creation request, both verbatim. 6 was also the durable\n * history channel on its own: behind {@link CAP_SESSION_DEEP_HISTORY} a client\n * may call {@link METHOD_SESSION_HISTORY_DEEP} and walk a session's store back\n * to its oldest entry, below the follow window `session.history` slices. 5 when\n * the roster stopped carrying archived sessions: behind\n * {@link CAP_ROSTER_OMITS_ARCHIVED} `session.list` names no session the host's\n * archive set holds, so a session archived between two listings arrives as a\n * removal and one restored as a change. 4 when byte-level increments shipped:\n * behind {@link CAP_DELTA} `session.list` and `board.snapshot` answer a reset\n * or a delta against a `since` token. 3 was\n * the background-job channel — behind {@link CAP_JOBS} a client may call\n * `jobs.list` and receive `jobs.changed`. 2 was the subagent thread —\n * a `user-message` delta may carry an `actor` and a `subagent` delta exists\n * behind {@link CAP_SUBAGENT_THREAD}. 1 was the extension seam — a mounted\n * plugin may answer methods outside {@link KNOWN_METHODS} once the client\n * declares the capability that plugin requires. No addition changed the major\n * version, a frozen field, or an existing method or topic name.\n */\nexport const MINOR = 22\n\n/**\n * The capabilities this bridge itself serves, and the opening half of what\n * `hello` advertises.\n *\n * A capability a mounted plugin adds is not listed here — the bridge is not its\n * author and names none of them — but `hello` advertises it all the same: the\n * answer is this list plus every capability the extension registry currently\n * requires a client to declare (`RemoteBridgeRegistry.capabilities`), computed\n * on each greeting so a plugin mounted after this bridge was built is visible\n * to the next phone. A name both halves carry is listed once, and this list\n * keeps its order at the front, so a bridge with no extension mounted answers\n * byte for byte the list it always did. Extension names never move\n * {@link MINOR}: that number describes this protocol, and a plugin's own names\n * are the plugin's.\n *\n * A capability whose whole switch is a declaration — no method, no answer, no\n * field behind it, such as {@link CAP_APPROVALS} — stays out of this list for\n * the reason it always did: advertising it would claim a handshake change\n * without one.\n */\nexport const SERVED_CAPABILITIES: readonly string[] = [\n CAP_SESSION_SNAPSHOT_TRIM,\n CAP_SESSION_SNAPSHOT_PAGE,\n CAP_QUESTIONS,\n CAP_QUESTION_LIST,\n CAP_SUBAGENT_THREAD,\n CAP_JOBS,\n CAP_AGENTS,\n CAP_DELTA,\n CAP_ROSTER_OMITS_ARCHIVED,\n CAP_SESSION_DEEP_HISTORY,\n CAP_FRAME_DEFLATE,\n CAP_ROSTER_COMPACT,\n CAP_SESSION_SNAPSHOT_SINCE,\n CAP_SESSION_FORK,\n CAP_COMMANDS,\n CAP_WORKSPACE,\n CAP_SESSION_ADMIN,\n CAP_SQUADS,\n CAP_PUSH,\n CAP_USAGE,\n CAP_USAGE_STATS,\n CAP_UI,\n CAP_UI_LIST,\n CAP_SESSION_ATTACHMENT_PATH,\n]\n/** `server` field of the hello response. */\nexport const SERVER_ID = 'dsh-remote-bridge'\n\n/** Exact route path of the bridge's WebSocket endpoint. */\nexport const WS_PATH = '/ios/v1'\n/** Exact route path of the loopback-only bootstrap token endpoint. */\nexport const PAIR_TOKEN_PATH = '/remote-bridge/pair/token'\n","/**\n * The panel's one wire call: read the one-shot bootstrap token from this\n * package's own Host route.\n *\n * The route is same-origin and document-relative (the GUI is served with\n * `<base href=\"./\">`, so a sub-path deployment resolves it against its entry\n * directory instead of escaping to the origin root — the same rule\n * `dsh-remote-web-ui`'s pair API follows). It is NOT consumed here: the panel\n * only displays the secret, and the phone spends it in `pair.begin`, so a\n * mis-click on \"new code\" voids a token without ever pairing a device.\n *\n * `403` is a fact, not an error: the loopback gate in `core/loopback.ts`\n * refuses any page whose socket or `Host` is not this machine, which is exactly\n * the case the panel must name out loud.\n *\n * The origin's own source crosses too, and it is not decoration: it is what lets\n * the panel say which kind of address the code carries without printing a\n * public hostname, while still naming a LAN literal that answers only inside the\n * network the page is already on.\n * @module dsh-remote-bridge/client/pair-token\n */\n\nimport type { PairOriginSource } from '../core/pair-address.ts'\nimport { PAIR_TOKEN_PATH } from '../core/protocol.ts'\n\n/** Document-relative form of the Host route, for a page served under any base. */\nexport const PAIR_TOKEN_URL = PAIR_TOKEN_PATH.replace(/^\\/+/, '')\n\n/** The outcome of one token read. */\nexport type PairTokenOutcome =\n /**\n * A live one-shot token and the instant it stops being accepted, plus the\n * address half when this machine can name its own public origin. `pairingUrl`\n * is the code a QR should carry: a `{token, url}` document the phone parses\n * into both halves of its configuration.\n */\n | {\n kind: 'ok'\n token: string\n expiresAt: number\n origin: string | null\n originSource: PairOriginSource | null\n pairingUrl: string | null\n }\n /** 403: the page is not open on the machine itself, so the loopback gate refused it. */\n | { kind: 'forbidden' }\n /** The route answered with a status the panel does not know, or with a body that is not a token. */\n | { kind: 'failed'; status: number }\n /** The request never reached the host (offline, host stopped, connection reset). */\n | { kind: 'unreachable' }\n\n/** The minimal response surface the reader uses, so a test can inject its own. */\nexport interface PairTokenResponse {\n readonly ok: boolean\n readonly status: number\n json(): Promise<unknown>\n}\n\n/** The minimal fetch surface the reader uses, so a test can inject its own. */\nexport type PairTokenFetch = (url: string, init: { signal?: AbortSignal; cache: string }) => Promise<PairTokenResponse>\n\nexport interface ReadPairTokenOptions {\n /** Injected transport; defaults to the global fetch. */\n readonly fetchImpl?: PairTokenFetch\n /** Aborts an in-flight read (the panel closed, the entry unmounted). */\n readonly signal?: AbortSignal\n}\n\n/** Read a string field, treating a missing, mistyped or empty value as absent. */\nfunction stringOrNull(value: unknown): string | null {\n return typeof value === 'string' && value !== '' ? value : null\n}\n\n/**\n * Read one bootstrap token.\n *\n * Never throws: every failure is one of the outcome arms, because the panel has\n * to render each of them. A `200` whose body is not `{token, expiresAt}` is\n * reported as a failure rather than shown as an empty QR.\n * @param options - injected transport and abort signal.\n * @returns the read outcome.\n */\nexport async function readPairToken(options: ReadPairTokenOptions = {}): Promise<PairTokenOutcome> {\n const send = options.fetchImpl ?? (globalThis.fetch as unknown as PairTokenFetch | undefined)\n if (send === undefined) return { kind: 'unreachable' }\n let response: PairTokenResponse\n try {\n response = await send(PAIR_TOKEN_URL, {\n cache: 'no-store',\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n })\n } catch {\n // A network failure and an aborted read are indistinguishable here, and\n // both mean \"no token arrived\" — the panel says so instead of guessing.\n return { kind: 'unreachable' }\n }\n if (response.status === 403) return { kind: 'forbidden' }\n if (!response.ok) return { kind: 'failed', status: response.status }\n let body: unknown\n try {\n body = await response.json()\n } catch {\n return { kind: 'failed', status: response.status }\n }\n if (typeof body !== 'object' || body === null) return { kind: 'failed', status: response.status }\n const token = (body as { token?: unknown }).token\n const expiresAt = (body as { expiresAt?: unknown }).expiresAt\n if (typeof token !== 'string' || token === '') return { kind: 'failed', status: response.status }\n if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return { kind: 'failed', status: response.status }\n // Additive fields: a host that predates origin discovery answers without\n // them, and the panel then falls back to the bare-token code instead of\n // refusing to show anything.\n const origin = stringOrNull((body as { origin?: unknown }).origin)\n const candidate = stringOrNull((body as { pairingUrl?: unknown }).pairingUrl)\n const pairingUrl = candidate !== null && /^wss?:\\/\\/\\S+$/.test(candidate) ? candidate : null\n const source = (body as { originSource?: unknown }).originSource\n const originSource = source === 'realtime' || source === 'env' || source === 'lan' ? source : null\n return { kind: 'ok', token, expiresAt, origin, originSource, pairingUrl }\n}\n","/**\n * The bridge's claims on `ui.request` (§35): which self-contained pages a phone\n * or the desktop may show, and the one path a user's action travels back into the\n * tool call that presented it.\n *\n * A card belongs to exactly one tool call and ends at the user's FIRST action:\n * the first `ui.event` settles it and becomes that call's result, so a card that\n * should keep taking actions is a second presentation rather than a second event\n * (§35.3, §35.8). Every claim is one record keyed by the call id published on the\n * wire, so an event that arrives late still lands, and one naming a call id this\n * bridge never claimed is refused instead of being handed to a tool that is not\n * waiting for it.\n *\n * The bridge invents no deadline: the tool schema declares no `timeout`, so a\n * card carries no `expiresAt` and stays open until the user acts, the agent's own\n * turn is cancelled, or the last paired device has been gone long enough for the\n * hub's grace window (§35.5). It also fabricates no event: a card nobody answered\n * is released as a refusal, never as a decision the operator did not make.\n *\n * Both caps are enforced on this side rather than the client's (§35.2, §35.3): a\n * client that refused an oversized page would leave the agent waiting for a card\n * that never comes, so the call is refused as `invalid-args` before any frame is\n * written.\n * @module dsh-remote-bridge/core/ui\n */\n\nimport { CODE_UI_SETTLED, CODE_UI_UNKNOWN } from './protocol.ts'\n\n/** Upper bound of one card's document, in UTF-8 bytes (§35.2). */\nexport const UI_HTML_MAX_BYTES = 262_144\n\n/** Upper bound of one `ui.event` payload, in UTF-8 bytes (§35.3). */\nexport const UI_PAYLOAD_MAX_BYTES = 8192\n\n/**\n * How many settled call ids this bridge remembers, so a repeated tap is answered\n * `ui-settled` instead of `ui-unknown` (§35.3).\n *\n * The promise is already settled and the card is already gone by then; the only\n * reason to remember the id is that a client which tapped twice must be able to\n * tell \"already done\" from \"never mine\". A phone holds no more live cards than it\n * rendered, so the bound costs one short string per presentation and never grows\n * with the process's uptime.\n */\nexport const UI_SETTLED_MEMORY = 256\n\n/** Whether a card still holds the tool call, or is only a notice now. */\nexport type UiState = 'open' | 'settled'\n\n/** One lossless JSON value, as the wire carries it inside an event payload. */\nexport type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }\n\n/** The action a user took inside one card, in the presenter's own closed set. */\nexport interface UiEvent {\n readonly type: string\n readonly payload?: JsonValue\n}\n\n/**\n * The `ui.request` payload for one claim, and the `payload` of every `ui.list`\n * entry.\n *\n * One function for both so the card a client was handed and the card it reads back\n * out of a list cannot drift apart: an absent `title` or `height` is an absent key\n * rather than an empty or null one, exactly as §35.2 froze it. `expiresAt` is never\n * written: a presentation whose tool schema declares no `timeout` has no deadline\n * to publish, and a published one would be a promise this bridge does not keep.\n * @param state - whether the card still holds the tool call.\n * @param card - the claim being published.\n * @returns the frozen payload body.\n */\nexport function uiPayload(state: UiState, card: UiCardView): UiRequestPayload {\n return {\n sessionId: card.sessionId,\n callId: card.callId,\n state,\n ...(card.title === undefined ? {} : { title: card.title }),\n html: card.html,\n ...(card.height === undefined ? {} : { height: card.height }),\n }\n}\n\n/**\n * The identity a client knows one card by (`\"<sessionId>/<callId>\"`, §35.4).\n *\n * The same pair a `ui.list` row carries, so the card a tool presented and the row\n * a client reconciles it against are compared as one name instead of two fields\n * that could be recombined differently on each side.\n * @param sessionId - the session whose agent presented the card.\n * @param callId - the tool call id it is held under.\n * @returns the card key.\n */\nexport function uiKey(sessionId: string, callId: string): string {\n return sessionId + '/' + callId\n}\n\n/** @returns the UTF-8 byte length of one string. */\nfunction utf8Bytes(text: string): number {\n return new TextEncoder().encode(text).length\n}\n\n/** @returns whether one card document is within {@link UI_HTML_MAX_BYTES}. */\nexport function uiHtmlFits(html: string): boolean {\n return utf8Bytes(html) <= UI_HTML_MAX_BYTES\n}\n\n/**\n * Read one `ui.event` body out of a decoded frame.\n *\n * The event's `type` is the presenter's own closed set: this bridge carries it and\n * never interprets the value, so the only shape it enforces is the one the frame\n * declares (§35.3). An absent and an explicit `null` payload are different\n * things — the payload key is kept exactly when the client sent one.\n * @param raw - the `event` field as it crossed the wire.\n * @returns the event, or undefined when the frame is not one.\n */\nexport function uiEventOf(raw: unknown): UiEvent | undefined {\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined\n const record = raw as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string' || type === '') return undefined\n return record.payload === undefined ? { type } : { type, payload: record.payload as JsonValue }\n}\n\n/** @returns whether one event's payload is within {@link UI_PAYLOAD_MAX_BYTES}. */\nexport function uiEventFits(event: UiEvent): boolean {\n return event.payload === undefined || utf8Bytes(JSON.stringify(event.payload)) <= UI_PAYLOAD_MAX_BYTES\n}\n\n/** One card this bridge still holds, as `ui.list` publishes it (§35.4). */\nexport interface ListedCard {\n /** {@link uiKey}: the identity the client holds it under. */\n readonly key: string\n readonly sessionId: string\n /** `open` or `settled`; a settled card is not held and never listed. */\n readonly state: UiState\n /** The `ui.request` payload, byte for byte the shape §35.2 froze. */\n readonly payload: UiRequestPayload\n}\n\n/**\n * The body of one `ui.list` answer.\n *\n * `complete` is what a client is allowed to act on: only a COMPLETE list may\n * retire a card it does not carry (§35.5, §24.3), so a bridge that could answer\n * only part of the set must say `false` rather than let the difference read as\n * \"the card is over\".\n */\nexport interface UiListPayload {\n readonly cards: readonly ListedCard[]\n readonly complete: boolean\n}\n\n/** `ui.request`'s payload, as §35.2 froze it. */\nexport interface UiRequestPayload {\n readonly sessionId: string\n readonly callId: string\n readonly state: UiState\n /** One header line; absent when the presenter named none. */\n readonly title?: string\n /** A whole self-contained document, `<!doctype html>` first, within {@link UI_HTML_MAX_BYTES}. */\n readonly html: string\n /** The presenter's suggested initial height in points; the client still measures. */\n readonly height?: number\n /**\n * Epoch milliseconds of this bridge's own deadline for the card; absent, always,\n * for a presentation whose tool schema declares no `timeout` (§35.2).\n */\n readonly expiresAt?: number\n}\n\n/** The identity and content of one claim, as the hub publishes it. */\nexport interface UiCardView {\n readonly sessionId: string\n readonly callId: string\n readonly html: string\n readonly title?: string\n readonly height?: number\n}\n\n/** Why one presentation ended without a user action, in the wire's own vocabulary. */\nexport type UiRefusalReason = 'unavailable' | 'invalid-args' | 'timeout' | 'cancelled'\n\n/** What one presentation ended as: the user's action, or the refusal to wait for one. */\nexport type UiPresentOutcome =\n | { readonly ok: true; readonly type: string; readonly payload?: JsonValue }\n | { readonly ok: false; readonly reason: UiRefusalReason }\n\n/** What one `ui.event` produced: acknowledgement, or the refusal to accept it. */\nexport type UiEventReply = { readonly ok: true } | { readonly ok: false; readonly code: string; readonly msg: string }\n\nexport interface OpenCardInput {\n readonly sessionId: string\n /** The id published on the wire, which is the host's own `ToolCallId`. */\n readonly callId: string\n readonly html: string\n readonly title?: string\n readonly height?: number\n /** The agent's own cancellation lifetime for this call. */\n readonly signal?: AbortSignal\n /**\n * Called when the card leaves this bridge — the user's event, the grace window,\n * a cancelled turn, the bridge unloading. The client still holds a card for it\n * and has to be told, or it keeps showing a page whose actions go nowhere.\n */\n readonly onSettled?: (card: UiCardView) => void\n}\n\n/** The presentation one `ui_present` call is waiting on, as the hub publishes it. */\nexport interface ClaimedCard extends UiCardView {\n /** The user's action, or the refusal that ended the card. Never rejects. */\n readonly outcome: Promise<UiPresentOutcome>\n}\n\n/** One live claim, with every path that ends it. */\ninterface Claim {\n readonly sessionId: string\n readonly callId: string\n readonly html: string\n readonly title: string | undefined\n readonly height: number | undefined\n readonly finish: (outcome: UiPresentOutcome) => void\n readonly detach: () => void\n /** Tells the client its card is over; set from the input's `onSettled`. */\n readonly notifySettled: () => void\n}\n\n/**\n * The publishable view of one claim.\n * @param record - the live claim.\n * @returns the card's fields as the hub publishes them.\n */\nfunction viewOf(record: Claim): UiCardView {\n return {\n sessionId: record.sessionId,\n callId: record.callId,\n html: record.html,\n ...(record.title === undefined ? {} : { title: record.title }),\n ...(record.height === undefined ? {} : { height: record.height }),\n }\n}\n\n/**\n * Pending cards of one bridge process.\n *\n * One record per call id published on the wire and one settle for every path\n * (the user's event, the agent's cancellation, the grace window, bridge unload),\n * so a card can never be settled twice and a released claim leaves no abort\n * listener behind.\n */\nexport class UiCards {\n readonly #cards = new Map<string, Claim>()\n /** Call ids a user's own event settled, oldest first, bounded by {@link UI_SETTLED_MEMORY}. */\n readonly #settled = new Set<string>()\n\n /** @returns how many cards this bridge currently holds. */\n get size(): number {\n return this.#cards.size\n }\n\n /**\n * @param callId - one wire call id.\n * @returns `open` while it holds a tool call, `settled` once a user's event\n * settled it, and undefined when this bridge never claimed it — which is how a\n * listener tells `ui-settled` from `ui-unknown` (§35.3).\n */\n stateOf(callId: string): UiState | undefined {\n if (this.#cards.has(callId)) return 'open'\n return this.#settled.has(callId) ? 'settled' : undefined\n }\n\n /**\n * Claim one card.\n * @param input - session identity, wire call id, the page, and the host's lifetime.\n * @returns the claim the hub publishes, or undefined when there is nothing to publish.\n */\n open(input: OpenCardInput): ClaimedCard | undefined {\n // A call whose own lifetime already ended has no card to publish: announcing one\n // would hand the client a page that can never be settled.\n if (input.signal?.aborted === true) return undefined\n if (this.#cards.has(input.callId) || this.#settled.has(input.callId)) return undefined\n let finish: (outcome: UiPresentOutcome) => void = () => undefined\n const outcome = new Promise<UiPresentOutcome>((resolve) => { finish = resolve })\n const signal = input.signal\n const onAbort = (): void => { this.#cancel(input.callId) }\n const record: Claim = {\n sessionId: input.sessionId,\n callId: input.callId,\n html: input.html,\n title: input.title,\n height: input.height,\n finish,\n detach: (): void => { signal?.removeEventListener('abort', onAbort) },\n notifySettled: (): void => { input.onSettled?.(viewOf(record)) },\n }\n this.#cards.set(input.callId, record)\n signal?.addEventListener('abort', onAbort, { once: true })\n return { ...viewOf(record), outcome }\n }\n\n /**\n * Settle one card from the client's first event (§35.3).\n *\n * The event is the tool call's result and its only result: the card leaves the\n * held table in the same step, so a second event finds it settled rather than\n * settling the call twice.\n * @param sessionId - the session the client believes owns the card.\n * @param callId - the wire call id the client was shown.\n * @param event - the user's action, carried verbatim.\n */\n settle(sessionId: string, callId: string, event: UiEvent): UiEventReply {\n const record = this.#cards.get(callId)\n if (record === undefined) {\n return this.#settled.has(callId)\n ? { ok: false, code: CODE_UI_SETTLED, msg: 'this card is already settled' }\n : { ok: false, code: CODE_UI_UNKNOWN, msg: 'the card is unknown or was settled elsewhere' }\n }\n if (record.sessionId !== sessionId) {\n return { ok: false, code: CODE_UI_UNKNOWN, msg: 'the card is unknown or was settled elsewhere' }\n }\n this.#cards.delete(callId)\n this.#remember(callId)\n record.detach()\n record.notifySettled()\n record.finish(event.payload === undefined ? { ok: true, type: event.type } : { ok: true, type: event.type, payload: event.payload })\n return { ok: true }\n }\n\n /**\n * Every card this bridge still holds, as `ui.list` publishes it (§35.4).\n *\n * The claim registry IS the answer: a card leaves it the moment the user settles\n * it, the grace window releases it, or the bridge unloads, so a card missing from\n * this list is one no action can reach any more. Only `open` is ever listed —\n * `settled` is the one-way notice, never a held row.\n * @returns one entry per held card, in claim order.\n */\n listed(): readonly ListedCard[] {\n return [...this.#cards.values()].map(record => ({\n key: uiKey(record.sessionId, record.callId),\n sessionId: record.sessionId,\n state: 'open',\n payload: uiPayload('open', viewOf(record)),\n }))\n }\n\n /**\n * Withdraw the named cards, ending each tool call with a refusal.\n * @param callIds - the cards to release.\n * @param reason - why; carried into the tool result as it stands.\n * @returns how many were still open and therefore released.\n */\n withdraw(callIds: readonly string[], reason: UiRefusalReason = 'timeout'): number {\n let withdrawn = 0\n for (const callId of callIds) {\n const record = this.#cards.get(callId)\n if (record === undefined) continue\n this.#cards.delete(callId)\n record.detach()\n record.notifySettled()\n record.finish({ ok: false, reason })\n withdrawn += 1\n }\n return withdrawn\n }\n\n /**\n * Withdraw every claim.\n * @param reason - why; carried into every released tool call.\n * @returns how many cards were still open.\n */\n withdrawAll(reason: UiRefusalReason = 'timeout'): number {\n return this.withdraw([...this.#cards.keys()], reason)\n }\n\n /**\n * End one card from the agent's own cancellation lifetime.\n *\n * The tool call is going away, so nothing can settle it later: the promise is\n * resolved with the refusal instead of being left pending, and the client is told\n * its page is over rather than left with a card whose actions go nowhere.\n */\n #cancel(callId: string): void {\n this.withdraw([callId], 'cancelled')\n }\n\n /**\n * Remember one call id a user's event settled, dropping the oldest once the bound\n * is reached — a repeated tap is answered `ui-settled` while the id is here, and\n * `ui-unknown` afterwards.\n */\n #remember(callId: string): void {\n this.#settled.add(callId)\n if (this.#settled.size <= UI_SETTLED_MEMORY) return\n const oldest = this.#settled.values().next().value\n if (oldest !== undefined) this.#settled.delete(oldest)\n }\n}\n","/**\n * The transcript reading of one `ui_present` call (protocol §35.10, §35.11):\n * what the desktop row draws, decided without touching the DOM.\n *\n * A card has two sources and neither may be dropped. While the call is still\n * running the arguments are the only material on the wire, so the page comes out\n * of `args` and the header says the operator has not acted yet. Once the result\n * lands, the presentation payload `meta.ui` is the card's own record — its\n * `state`, its `title` and the very document that crossed — and the arguments\n * are only the fallback for a result that carries no payload.\n *\n * The argument view is read by shape rather than by import: a toolview receives a\n * lazy `PartialArguments` when the call arrived as argument text and a plain\n * payload when the call was dispatched as an object, and §35.10 fixes neither. A\n * field reader therefore answers from all three shapes it can meet (lazy view,\n * JSON text, parsed object) so a page is never lost to a shape this row did not\n * anticipate.\n *\n * Two rules live here rather than in the renderer. A document above 256 KiB is\n * never handed to a frame (§35.2 caps it on this side too), and a frame message is\n * read by shape alone: the sandboxed document has an opaque origin, so identity\n * comes from the frame element the row owns, never from what the message claims.\n * Nothing read here is forwarded anywhere — the desktop renders and does not\n * answer (§35.11).\n * @module dsh-remote-bridge/client/ui-card\n */\n\nimport { UI_HTML_MAX_BYTES, type UiState } from '../core/ui.ts'\n\n/**\n * The Tool slot's stage literals, as the composing contract publishes them\n * (`ToolCallPhaseProps`). `result` is the settled arm; every other stage still\n * has the call's arguments only.\n */\nexport type PresentPhase = 'preparing' | 'start' | 'result'\n\n/** One card as a row draws it, whichever source it came from. */\nexport interface PresentCard {\n /** The whole self-contained document, `<!doctype html>` first. */\n readonly html: string\n /** Whether the card still holds the call (`open`) or is only a notice. */\n readonly state: UiState\n /** One header line; absent when the presenter named none. */\n readonly title?: string\n /** The presenter's suggested first height in points; the measurement wins. */\n readonly height?: number\n /** `\"<sessionId>/<callId>\"`, when the payload carries the card identity. */\n readonly key?: string\n}\n\n/** What one row read produced. */\nexport type PresentRead =\n | { readonly kind: 'card'; readonly card: PresentCard }\n /** A page over {@link UI_HTML_MAX_BYTES}: refused visibly, never rendered. */\n | { readonly kind: 'oversize' }\n /** No page in either source: the row keeps a neutral line instead of a card. */\n | { readonly kind: 'empty' }\n\n/** The call material one row can read at its stage. */\ninterface PresentBlock {\n /** The lazy argument view (`ToolArgs`), or a parsed payload. */\n readonly args?: unknown\n /** Finished argument text, for a stage that publishes it beside the view. */\n readonly argsRaw?: unknown\n /** `ToolResultNode.meta`, carried verbatim by the protocol. */\n readonly meta?: unknown\n}\n\n/** One theme token as it is handed to a card's document. */\nexport type ThemeToken = readonly [name: string, value: string]\n\n/**\n * The theme tokens a card inherits from the GUI's own root element.\n *\n * Four roles and no more: the page needs a text colour it can trust, a quieter\n * one, a surface and a border. A token the running theme does not define is\n * simply not injected — the page then falls back to its own CSS, which is why an\n * unreadable theme is a degraded look rather than a broken card.\n */\nexport const CARD_THEME_TOKENS = [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-border-l2',\n] as const\n\n/** The one sandbox value a card frame is allowed (§35.7, §35.11). */\nexport const FRAME_SANDBOX = 'allow-scripts'\n\n/**\n * The permissions a card frame is explicitly denied.\n *\n * §35.7 refuses camera, microphone, location and clipboard reads on both ends.\n * A sandboxed document already has an opaque origin, and this policy states the\n * denial where the browser enforces it rather than leaving it to the default.\n */\nexport const FRAME_PERMISSIONS = [\n \"camera 'none'\",\n \"microphone 'none'\",\n \"geolocation 'none'\",\n \"clipboard-read 'none'\",\n].join('; ')\n\n/** The message type the injected reporter uses to publish the content height. */\nexport const FRAME_HEIGHT_CHANNEL = 'dsh-ui-card-height'\n\n/** The first height of a card whose presenter suggested none. */\nexport const CARD_DEFAULT_HEIGHT = 320\n\n/** The smallest and largest heights a measured card may take, in CSS pixels. */\nexport const CARD_MIN_HEIGHT = 96\nexport const CARD_MAX_HEIGHT = 720\n\n/**\n * Read one field as text out of every argument shape a toolview can receive.\n * @param args - the lazy view, finished JSON text, or a parsed payload.\n * @param name - the top-level field name.\n * @returns the field's decoded string, or undefined when absent or not a string.\n */\nfunction fieldText(args: unknown, name: string): string | undefined {\n if (typeof args === 'string') {\n const parsed = parseJson(args)\n return parsed === undefined ? undefined : fieldText(parsed, name)\n }\n if (typeof args !== 'object' || args === null) return undefined\n const view = args as Record<string, unknown> & { text?: unknown }\n if (typeof view.text === 'function') {\n const read: unknown = (view.text as (key: string) => unknown).call(args, name)\n return typeof read === 'string' ? read : undefined\n }\n const direct = view[name]\n return typeof direct === 'string' ? direct : undefined\n}\n\n/**\n * Read one field as any completed value out of the same three shapes.\n * @param args - the lazy view, finished JSON text, or a parsed payload.\n * @param name - the top-level field name.\n * @returns the value, or undefined when absent.\n */\nfunction fieldValue(args: unknown, name: string): unknown {\n if (typeof args === 'string') {\n const parsed = parseJson(args)\n return parsed === undefined ? undefined : fieldValue(parsed, name)\n }\n if (typeof args !== 'object' || args === null) return undefined\n const view = args as Record<string, unknown> & { value?: unknown }\n if (typeof view.value === 'function') return (view.value as (key: string) => unknown).call(args, name)\n return view[name]\n}\n\n/** @returns the parsed payload, or undefined when the text is not one object. */\nfunction parseJson(text: string): unknown {\n try {\n return JSON.parse(text) as unknown\n } catch {\n return undefined\n }\n}\n\n/** @returns one suggested height as a whole number of CSS pixels, when usable. */\nfunction heightOf(raw: unknown): number | undefined {\n if (typeof raw !== 'number' || !Number.isFinite(raw) || raw <= 0) return undefined\n return Math.ceil(raw)\n}\n\n/**\n * Read the presentation payload a settled call carries (§35.10).\n *\n * The payload is the card's own record, so it is read only when it is one: a\n * `html` that is not a string is no card at all, which keeps a malformed payload\n * from becoming an empty frame. `state` outside the frozen pair reads as\n * `settled` — a result-phase payload is a finished card by definition, and the\n * `open` arm exists for a presenter that answers before its first event.\n * @param meta - the result's `meta` value, carried verbatim.\n * @returns the card, or undefined when this result carries no presentation.\n */\nexport function readPresentation(meta: unknown): PresentCard | undefined {\n if (typeof meta !== 'object' || meta === null) return undefined\n const ui = (meta as { ui?: unknown }).ui\n if (typeof ui !== 'object' || ui === null) return undefined\n const record = ui as Record<string, unknown>\n const html = record.html\n if (typeof html !== 'string') return undefined\n const title = record.title\n const key = record.key\n const height = heightOf(record.height)\n return {\n html,\n state: record.state === 'open' ? 'open' : 'settled',\n ...(typeof title === 'string' ? { title } : {}),\n ...(height === undefined ? {} : { height }),\n ...(typeof key === 'string' ? { key } : {}),\n }\n}\n\n/**\n * Build the card a running call shows from its own arguments.\n * @param block - the call material of the current stage.\n * @returns the card, or undefined when the arguments carry no page.\n */\nfunction argumentCard(block: PresentBlock): PresentCard | undefined {\n const html = fieldText(block.args, 'html') ?? fieldText(block.argsRaw, 'html')\n if (html === undefined) return undefined\n const title = fieldText(block.args, 'title') ?? fieldText(block.argsRaw, 'title')\n const height = heightOf(fieldValue(block.args, 'height') ?? fieldValue(block.argsRaw, 'height'))\n return {\n html,\n state: 'open',\n ...(title === undefined ? {} : { title }),\n ...(height === undefined ? {} : { height }),\n }\n}\n\n/** @returns whether one document is within {@link UI_HTML_MAX_BYTES}. */\nexport function cardHtmlFits(html: string): boolean {\n return new TextEncoder().encode(html).length <= UI_HTML_MAX_BYTES\n}\n\n/**\n * Decide what the row draws at one stage of the call.\n *\n * The settled stage prefers `meta.ui`, because that payload is the presentation\n * the host published and carries its ending. A result without the payload falls\n * back to the arguments — and then the card is still over, so it reads\n * `settled`: the stage decides that, not a field that is absent.\n * @param phase - the stage the Tool slot published.\n * @param block - the call material of that stage.\n * @returns a card, a refusal, or the neutral line.\n */\nexport function presentReadOf(phase: unknown, block: unknown): PresentRead {\n if (typeof block !== 'object' || block === null) return { kind: 'empty' }\n const material = block as PresentBlock\n const card = phase === 'result'\n ? readPresentation(material.meta) ?? settledFromArguments(material)\n : argumentCard(material)\n if (card === undefined) return { kind: 'empty' }\n return cardHtmlFits(card.html) ? { kind: 'card', card } : { kind: 'oversize' }\n}\n\n/** @returns the argument page of a settled call, as a finished card. */\nfunction settledFromArguments(material: PresentBlock): PresentCard | undefined {\n const card = argumentCard(material)\n return card === undefined ? undefined : { ...card, state: 'settled' }\n}\n\n/**\n * Read the theme tokens off a computed style, skipping the ones it does not carry.\n * @param style - the GUI root element's computed style.\n * @returns the tokens, in {@link CARD_THEME_TOKENS} order.\n */\nexport function cardThemeTokens(style: { getPropertyValue(name: string): string }): readonly ThemeToken[] {\n const tokens: ThemeToken[] = []\n for (const name of CARD_THEME_TOKENS) {\n let value = ''\n try {\n value = style.getPropertyValue(name)\n } catch {\n value = ''\n }\n const trimmed = value.trim()\n if (trimmed !== '') tokens.push([name, trimmed])\n }\n return tokens\n}\n\n/** @returns the `<style>` handing the theme tokens to a card's document. */\nfunction themeStyle(tokens: readonly ThemeToken[]): string {\n if (tokens.length === 0) return ''\n const body = tokens.map(([name, value]) => `${name}:${value}`).join(';')\n return `<style data-dsh-card-theme>:root{${body}}</style>`\n}\n\n/**\n * The reporter a card's document runs to publish its own content height.\n *\n * The frame cannot be measured from the outside — the document is opaque and\n * cross-origin — so the measurement has to be pushed out. It is deliberately the\n * only code this row adds to a page: it reads a height and posts a number, and a\n * page that removes it only loses the measurement, never the card.\n * @param channel - the message type the parent listens for.\n * @returns one script element as text.\n */\nfunction heightReporter(channel: string): string {\n const parts = [\n '<script data-dsh-card-frame>(function(){',\n 'function post(){try{',\n 'var d=document.documentElement,b=document.body;',\n 'var h=Math.max(d?d.scrollHeight:0,b?b.scrollHeight:0);',\n 'if(h>0){parent.postMessage({type:' + JSON.stringify(channel) + ',height:h},\"*\")}',\n '}catch(e){}}',\n 'window.addEventListener(\"load\",post);',\n 'document.addEventListener(\"DOMContentLoaded\",post);',\n 'try{if(typeof ResizeObserver===\"function\"){var ro=new ResizeObserver(post);',\n 'if(document.documentElement)ro.observe(document.documentElement);',\n 'if(document.body)ro.observe(document.body)}}catch(e){}',\n 'post()})()</script>',\n ]\n return parts.join('')\n}\n\n/**\n * Put one snippet inside an existing element rather than before the document.\n * @param html - the card document.\n * @param closingTag - the tag to insert ahead of, lower case.\n * @param snippet - the markup to insert.\n * @returns the document with the snippet inside it.\n */\nfunction injectBefore(html: string, closingTag: string, snippet: string): string {\n if (snippet === '') return html\n const at = html.toLowerCase().lastIndexOf(closingTag)\n return at < 0 ? html + snippet : html.slice(0, at) + snippet + html.slice(at)\n}\n\n/**\n * Build the document handed to a card's frame.\n *\n * The agent's page stays byte for byte what crossed; this only adds the theme\n * variables its CSS may use and the height reporter. Insertion happens ahead of\n * the closing tags rather than at the start of the string, because a snippet\n * placed before `<!doctype html>` would put the document into quirks mode.\n * @param html - the card document as the presenter wrote it.\n * @param tokens - the theme tokens to hand the page.\n * @param channel - the message type the reporter publishes on.\n * @returns the frame document; the original page when it takes no injection.\n */\nexport function frameDocument(html: string, tokens: readonly ThemeToken[], channel: string = FRAME_HEIGHT_CHANNEL): string {\n const style = themeStyle(tokens)\n const withTheme = style === '' ? html : injectBefore(html, '</head>', style)\n return injectBefore(withTheme, '</body>', heightReporter(channel))\n}\n\n/** One message a card's frame sent the parent. */\nexport type FrameEvent =\n | { readonly kind: 'height'; readonly height: number }\n /** Anything else the page posted: an action this desktop never answers. */\n | { readonly kind: 'interaction' }\n\n/**\n * Read one message a card's frame posted.\n *\n * Only the shape is read. The frame's origin is opaque, so the parent identifies\n * the sender by the frame element it owns; what is left to decide here is what\n * the payload means, and a page's own `{type, payload}` action means nothing\n * beyond \"the operator tried to act here\".\n * @param data - the message payload.\n * @returns the event, or undefined when the message is not one this row reads.\n */\nexport function frameEventOf(data: unknown): FrameEvent | undefined {\n if (typeof data !== 'object' || data === null || Array.isArray(data)) return undefined\n const record = data as Record<string, unknown>\n if (record.type === FRAME_HEIGHT_CHANNEL) {\n const height = record.height\n if (typeof height !== 'number' || !Number.isFinite(height) || height <= 0) return undefined\n return { kind: 'height', height: Math.ceil(height) }\n }\n return typeof record.type === 'string' && record.type !== '' ? { kind: 'interaction' } : undefined\n}\n\n/**\n * Hold a measured height inside the range a card may occupy.\n * @param height - the content height the frame reported, in CSS pixels.\n * @returns the height the card takes.\n */\nexport function clampCardHeight(height: number): number {\n if (!Number.isFinite(height)) return CARD_DEFAULT_HEIGHT\n return Math.min(CARD_MAX_HEIGHT, Math.max(CARD_MIN_HEIGHT, Math.ceil(height)))\n}\n","/**\n * The transcript row of one `ui_present` call: the whole page an agent handed\n * into the session, drawn in a controlled frame (protocol §35.11).\n *\n * The row renders and does not answer. The frame carries `srcdoc` and the one\n * sandbox value §35.7 allows — never `allow-same-origin`, which is what turns a\n * sandboxed document back into a same-origin one and would hand an agent page the\n * GUI's own storage and cookies. There is no host request on any path here: an\n * action the page posts arrives as one visible sentence telling the operator to\n * answer on the phone, and nothing is forwarded, stored or sent.\n *\n * Height is measured from the inside because the frame is opaque from the\n * outside: the injected reporter posts the document's own content height, the\n * presenter's suggested `height` carries the first frame, and the measurement\n * replaces it as soon as one arrives. The theme is handed in as variables read\n * off the GUI root, so a card follows the running theme without importing one;\n * a theme that cannot be read costs the injected variables, never the card.\n */\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport {\n CARD_DEFAULT_HEIGHT,\n FRAME_HEIGHT_CHANNEL,\n FRAME_PERMISSIONS,\n FRAME_SANDBOX,\n cardThemeTokens,\n clampCardHeight,\n frameDocument,\n frameEventOf,\n presentReadOf,\n type ThemeToken,\n} from './ui-card.ts'\nimport { PLUGIN_ATTR } from './semantic.ts'\nimport css from './ui-present.module.css'\n\nexport type UiPresentRowProps = PropsLocale<'remote-bridge'> & {\n /** The stage the Tool slot published (`preparing`, `start` or `result`). */\n readonly phase?: unknown\n /** The call material of that stage: the argument view, argument text, meta. */\n readonly block?: unknown\n}\n\n/** @returns the GUI root's theme tokens, or none when the theme cannot be read. */\nfunction readThemeTokens(): readonly ThemeToken[] {\n try {\n return cardThemeTokens(getComputedStyle(document.documentElement))\n } catch {\n return []\n }\n}\n\n/**\n * Render one card, or the neutral line of a call that carries no page.\n * @param props - the stage, the call material and the locale seat.\n * @returns the card body placed inside the official tool row.\n */\nexport function UiPresentRow({ phase, block, t }: UiPresentRowProps) {\n const read = useMemo(() => presentReadOf(phase, block), [phase, block])\n const card = read.kind === 'card' ? read.card : undefined\n const frame = useRef<HTMLIFrameElement | null>(null)\n // Read once, before the first paint: a token list that arrived after mount\n // would be a second document load for a card that already showed one.\n const [tokens, setTokens] = useState<readonly ThemeToken[]>(readThemeTokens)\n const [measured, setMeasured] = useState<number | undefined>(undefined)\n const [interacted, setInteracted] = useState(false)\n\n // The GUI switches between light and dark while a card is on screen; the\n // document is rebuilt from the tokens of whichever theme is now in force.\n useEffect(() => {\n let media: MediaQueryList | undefined\n try {\n media = window.matchMedia('(prefers-color-scheme: dark)')\n } catch {\n return\n }\n const sync = (): void => { setTokens(readThemeTokens()) }\n if (typeof media.addEventListener === 'function') {\n media.addEventListener('change', sync)\n return () => { media.removeEventListener('change', sync) }\n }\n media.addListener(sync)\n return () => { media.removeListener(sync) }\n }, [])\n\n // A new page is a new measurement and a new notice: carrying either across\n // would size the next card to the previous one's content.\n const html = card?.html\n useEffect(() => {\n setMeasured(undefined)\n setInteracted(false)\n }, [html])\n\n useEffect(() => {\n const onMessage = (event: MessageEvent): void => {\n const element = frame.current\n // Identity is the frame element, not the origin: a sandboxed document has\n // an opaque origin and can assert nothing about itself.\n if (element === null || element.contentWindow === null || event.source !== element.contentWindow) return\n const frameEvent = frameEventOf(event.data)\n if (frameEvent === undefined) return\n if (frameEvent.kind === 'height') {\n setMeasured(clampCardHeight(frameEvent.height))\n return\n }\n // The page asked the desktop for an answer. Nothing leaves this row; the\n // operator is told where answering actually happens.\n setInteracted(true)\n }\n window.addEventListener('message', onMessage)\n return () => { window.removeEventListener('message', onMessage) }\n }, [])\n\n const srcdoc = useMemo(\n () => (card === undefined ? '' : frameDocument(card.html, tokens, FRAME_HEIGHT_CHANNEL)),\n [card, tokens],\n )\n\n if (card === undefined) {\n return (\n <div className={css.row} data-dsh-plugin={PLUGIN_ATTR} data-tone={read.kind}>\n <p className={css.notice} role=\"status\">{read.kind === 'oversize' ? t('card.oversize') : t('card.empty')}</p>\n </div>\n )\n }\n\n const height = measured ?? clampCardHeight(card.height ?? CARD_DEFAULT_HEIGHT)\n\n return (\n <section className={css.card} data-dsh-plugin={PLUGIN_ATTR} data-state={card.state}>\n <header className={css.head}>\n {card.title !== undefined && <span className={css.title}>{card.title}</span>}\n <span className={css.badge}>{card.state === 'open' ? t('card.waiting') : t('card.settled')}</span>\n </header>\n <iframe\n ref={frame}\n className={css.frame}\n style={{ height: `${height}px` }}\n title={card.title ?? t('card.frameLabel')}\n srcDoc={srcdoc}\n sandbox={FRAME_SANDBOX}\n allow={FRAME_PERMISSIONS}\n referrerPolicy=\"no-referrer\"\n />\n <p className={css.notice} role=\"status\">\n {interacted ? t('card.interacted') : t('card.answerOnPhone')}\n </p>\n </section>\n )\n}\n","/**\n * The one seam through which this package registers its keyed Tool view.\n *\n * `tool.call.toolview` is declared by `@deepseek-ai/dsh-client-ui-tool`\n * (`lib/types/client/contract/slots.d.ts`). That package is not installed in this\n * workspace, so its types cannot be imported — a type-only import would itself be\n * a new dependency, and a local `declare module` extension of the SDK's `SlotMap`\n * would duplicate a contract another package owns and collide with the real\n * declaration wherever both are loaded. This module therefore narrows\n * `ctx.slots` to the two members the registration needs and states the slot's own\n * shape locally:\n *\n * - the slot is keyed and session-scoped, and its key is the wire Tool name\n * (`ui_present`), which is what makes one registration draw the card's body\n * without shadowing the official `tool-call` renderer;\n * - the owner publishes the call identity plus a stage union, mirrored here from\n * the upstream `ToolCallPhaseProps`: `preparing`, `start` and `result`. The\n * row reads the arguments at every stage but `result`, which is the only arm\n * that carries the result node.\n *\n * Upstream changing that shape is a change to this file: the phase names, the\n * keyed dispatch and the `locale` seat are the three facts the mirror carries.\n *\n * Technical debt, recorded rather than hidden: when this package next takes a\n * dependency pass, adding `@deepseek-ai/dsh-client-ui-tool` as a devDependency\n * lets this seam be replaced by `PropsRuntime<'tool.call.toolview'>` and by the\n * typed `ctx.slots.register` overload directly.\n * @module dsh-remote-bridge/client/toolview-slot\n */\n\nimport type { ComponentType } from 'react'\nimport { UiPresentRow, type UiPresentRowProps } from './UiPresentRow.tsx'\n\n/** The keyed Tool view slot the official row dispatches into. */\nexport const TOOLVIEW_SLOT = 'tool.call.toolview'\n\n/** The wire Tool name this package renders: the keyed cell it claims. */\nexport const PRESENT_TOOL = 'ui_present'\n\n/** The registration options this seam needs. */\nexport interface ToolviewRegistration {\n /** Exact SlotMap key. */\n readonly name: 'tool.call.toolview'\n /** Keyed cell: the wire Tool name the owner dispatches by. */\n readonly key: string\n /** Dictionary namespace the render machinery synthesizes `t` from. */\n readonly locale: string\n}\n\n/** The narrowed face of `ctx.slots` this package uses. */\nexport interface ToolviewSlotPort {\n /** Run `seats` once the slot is declared; drop them if the declarer leaves. */\n inject(name: string, seats: () => (() => void) | Iterable<() => void>): void\n /** Contribute one view to one keyed cell; the answer is its disposer. */\n register(options: ToolviewRegistration, view: ComponentType<UiPresentRowProps>): () => void\n}\n\n/** The host this seam needs: the client Context, structurally. */\nexport interface ToolviewSlotHost {\n readonly slots: unknown\n}\n\n/**\n * Contribute the `ui_present` card into the Tool row.\n *\n * The contribution is declaration-aware: `inject` waits for the official slot\n * declaration, so a GUI composed without a Tool layer has no keyed cell and thus\n * no card — that is the capability being absent, not an error to report. A\n * registration refused by the registry (an occupied cell at the same priority)\n * is swallowed the same way it is for this package's other seat, so one occupied\n * slot never takes the sidebar entry down with it.\n * @param host - the client Context.\n * @param locale - the dictionary namespace this package registered.\n */\nexport function registerPresentToolview(host: ToolviewSlotHost, locale: string): void {\n const slots = host.slots as unknown as ToolviewSlotPort\n slots.inject(TOOLVIEW_SLOT, () => {\n try {\n return slots.register({ name: TOOLVIEW_SLOT, key: PRESENT_TOOL, locale }, UiPresentRow)\n } catch {\n return () => {}\n }\n })\n}\n","/**\n * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy and\n * the header of an interactive card (§35.11).\n *\n * The panel has one job — put the live one-shot code in front of the operator as\n * a QR symbol — so its copy carries what to do with the symbol, how long it\n * lives, what kind of address the phone will dial, why the code is single-use,\n * and that the app is still in testing: the reader is told what they are joining\n * and where to ask about it. No key renders the public origin: the symbol\n * already carries it, and a durable public hostname printed as text would\n * outlive every screenshot it appears in. A LAN literal is not that fact — it\n * answers only inside the network this page is already on — so the LAN line\n * keeps naming it. No key states how the host finds either address, and no key\n * names the wire protocol: both are implementation facts the reader cannot act\n * on.\n *\n * The card's keys say only what the transcript row can act on: whether the page\n * is still waiting for the operator, that it is over, that this desktop renders\n * without answering, and that a page carrying nothing or too much draws a\n * sentence instead of a frame.\n */\n\n/** Simplified Chinese dictionary (the key-set source of truth). */\nexport const zh = {\n 'entry.label': '配对 iPhone',\n 'title': 'iOS App 配对',\n 'subtitle': '用 iOS App(内测)扫描二维码,把 iPhone 连到这台电脑上。配对码只在本机显示。',\n 'state.reading': '正在取配对码…',\n 'pair.qrLabel': '配对二维码',\n 'pair.countdown': '剩余 {s} 秒',\n 'pair.expired': '配对码已过期',\n 'pair.refresh': '重新取码',\n 'pair.usedHint': '配对码一次性有效:iPhone 一开始配对就作废,重新取码也会作废上一张。',\n 'origin.public': '二维码已包含公网地址,扫码后 iPhone 自动连上这台电脑',\n 'origin.lan': '二维码指向局域网地址 {origin},iPhone 需与本机在同一网络',\n 'origin.missing': '没有找到公网地址:先在 App 里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。',\n 'community.invite': 'iOS App 还在内测,欢迎来 Discord 交流',\n 'forbidden.title': '这个页面不是从本机打开的',\n 'forbidden.body': '配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。',\n 'failed.title': '取配对码失败',\n 'failed.body': '宿主返回了 HTTP {status},请刷新页面后重试。',\n 'unreachable.title': '无法连接本机宿主',\n 'unreachable.body': '请求没有到达宿主,请确认 dsh web 仍在运行后重试。',\n 'action.close': '关闭',\n 'action.copy': '复制配对码',\n 'action.copied': '已复制',\n 'action.copyFailed': '复制失败',\n 'action.retry': '重试',\n 'card.waiting': '等你操作',\n 'card.settled': '已结算',\n 'card.answerOnPhone': '在手机上作答',\n 'card.interacted': '已收到页面上的操作,但桌面端不作答:在手机上作答',\n 'card.frameLabel': '整页卡片',\n 'card.empty': '这次调用没有可渲染的页面',\n 'card.oversize': '页面超出大小上限,未渲染',\n} as const\n\n/** English dictionary, key-for-key with the zh source. */\nexport const en: Record<RemoteBridgeKey, string> = {\n 'entry.label': 'Pair an iPhone',\n 'title': 'iOS app pairing',\n 'subtitle': 'Scan the QR code with the iOS app (beta) to connect an iPhone to this computer. The code is shown only on this machine.',\n 'state.reading': 'Requesting a pairing code…',\n 'pair.qrLabel': 'Pairing QR code',\n 'pair.countdown': '{s} s left',\n 'pair.expired': 'The pairing code expired',\n 'pair.refresh': 'New code',\n 'pair.usedHint': 'The code is single-use: pairing spends it, and a new code voids the previous one.',\n 'origin.public': 'The QR code carries the public address: the iPhone connects to this computer as soon as it scans',\n 'origin.lan': 'The QR code points at the LAN address {origin}: the iPhone must be on the same network',\n 'origin.missing': 'No public address found: set the connection address in the app to your public relay first, then scan. {host} (this page) is reachable only from this machine.',\n 'community.invite': 'The iOS app is in beta. Come talk to us on Discord',\n 'forbidden.title': 'This page is not open on this machine',\n 'forbidden.body': 'Pairing codes can only be read from the machine itself. Open http://127.0.0.1:<port> in a browser on this machine and retry.',\n 'failed.title': 'Could not read a pairing code',\n 'failed.body': 'The host answered HTTP {status}. Reload the page and retry.',\n 'unreachable.title': 'Cannot reach the local host',\n 'unreachable.body': 'The request never reached the host. Check that dsh web is still running and retry.',\n 'action.close': 'Close',\n 'action.copy': 'Copy pairing code',\n 'action.copied': 'Copied',\n 'action.copyFailed': 'Copy failed',\n 'action.retry': 'Retry',\n 'card.waiting': 'Waiting for you',\n 'card.settled': 'Settled',\n 'card.answerOnPhone': 'Answer on the phone',\n 'card.interacted': 'The page sent an action, but this desktop does not answer: answer on the phone',\n 'card.frameLabel': 'Page card',\n 'card.empty': 'This call carried no page to render',\n 'card.oversize': 'The page is over the size limit and was not rendered',\n}\n\n/** Every key the `remote-bridge` namespace carries. */\nexport type RemoteBridgeKey = keyof typeof zh\n","/**\n * Protocol v1 pairing panel — browser half. Registers the `remote-bridge`\n * dictionary and the sidebar-foot trigger (into the ui-sidebar-declared\n * `sidebar.footer.action` list slot) that opens the panel showing this\n * package's own one-shot bootstrap token as a QR symbol plus its plaintext.\n *\n * The panel is display-only for the native path: it reads the same loopback-only\n * `GET /remote-bridge/pair/token` route an operator would curl, and never spends\n * the token (`pair.begin` stays the phone's call). The browser half therefore\n * adds no wire surface — the envelope, the method names, the topic names and\n * the events are untouched — and it does not touch `dsh-remote-web-ui`'s pairing\n * service, its roster, or its browser cookie path.\n *\n * The half also draws the transcript side of §35.11: one keyed `tool.call.toolview`\n * entry renders a `ui_present` call's whole page in a controlled frame, while the\n * phone stays the only place an action can be answered.\n *\n * Export discipline (packages/AGENTS.md): the /client surface carries only what\n * cordis loading needs plus types.\n */\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale) and its\n// LocaleNamespaceMap merge table.\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the ctx.slots merge (the renderer owns the slot registry).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\n// Type-only: pulls the ui-sidebar SlotMap merge (the 'sidebar.footer.action' hole).\nimport type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'\nimport { writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { PairEntry } from './PairEntry.tsx'\nimport { readPairToken } from './pair-token.ts'\nimport { registerPresentToolview } from './toolview-slot.ts'\nimport { en, zh, type RemoteBridgeKey } from './locales.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Protocol v1 pairing panel copy. */\n 'remote-bridge': RemoteBridgeKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nconst NS = 'remote-bridge'\n\n/** Unique occupant id inside the shared footer.action list slot. */\nconst ENTRY_ID = 'remote-bridge'\n\n/** Services required by this plugin. */\nexport const inject = ['slots', 'locale']\n\n/**\n * Register the protocol v1 pairing surface.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'remote-bridge: dictionaries')\n\n // Sidebar foot entry. The shell declares 'sidebar.footer.action' (list kind:\n // multiple occupants may share the seat) and registration is\n // declaration-aware via slots.inject. Read and clipboard arrive as an\n // injected face rather than a module import, which keeps the trigger's\n // rendered tree free of closure-factory bundles.\n ctx.slots.inject('sidebar.footer.action', () => {\n try {\n return ctx.slots.register({\n name: 'sidebar.footer.action',\n id: ENTRY_ID,\n locale: NS,\n inject: () => ({ read: readPairToken, copy: writeClipboard }),\n }, PairEntry)\n } catch {\n return () => {}\n }\n })\n\n // The transcript card of an interactive presentation (§35.11): one keyed\n // registration under the wire Tool name draws the body of a `ui_present` call,\n // so the official Tool row keeps everything else — identity, timing and the\n // dispatch tree — and no Chat Node renderer is shadowed.\n registerPresentToolview(ctx, NS)\n}\n\nexport type { PairEntryProps } from './PairEntry.tsx'\nexport type { PairCopyState, PairPanelProps, PairPanelState } from './PairPanel.tsx'\nexport type { PairTokenFetch, PairTokenOutcome, PairTokenResponse, ReadPairTokenOptions } from './pair-token.ts'\nexport type { RemoteBridgeKey } from './locales.ts'\n"],"x_google_ignoreList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oBAAoB;GACpB,gBAAgB;GAChB,eAAe;GACf,iBAAiB;GACjB,qBAAqB;GACrB,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,sBAAsB;GACtB,mBAAmB;GACnB,mBAAmB;GACnB,cAAc;GACd,iBAAiB;EACnB;;;;EChDA,MAAM,KAAK;;EAGX,MAAM,WAAW;;EAGjB,MAAa,SAAS,CAAC,SAAS,QAAQ;;;;;EAMxC,SAAgB,MAAM,KAA0B;GAC9C,IAAI,aAAa;IACf,IAAI;KACF,OAAO,IAAI,OAAO,SAAS,IAAI;MAAE;MAAI;KAAG,CAAC;IAC3C,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,6BAA6B;GAOhC,IAAI,MAAM,OAAO,+BAA+B;IAC9C,IAAI;KACF,OAAO,IAAI,MAAM,SAAS;MACxB,MAAM;MACN,IAAI;MACJ,QAAQ;MACR,eAAe;OAAE,MAAM;OAAe,MAAMC,sCAAAA;MAAe;KAC7D,GAAG,SAAS;IACd,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,CAAC;GAMD,wBAAwB,KAAK,EAAE;EACjC"}
1
+ {"version":3,"file":"client.js","names":["React","Modal","css","Button","IconCloseOutlineRegular","IconWarningOutlineRegular","IconCheckOutlineRegular","IconCopyOutlineRegular","IconRefreshOutlineRegular","COPY_FEEDBACK_MS","TICK_MS","EXIT_TIMEOUT_MS","panelStateOf","css","css","Button","css","writeClipboard"],"sources":["../../../node_modules/.pnpm/qrcode.react@4.2.0_react@19.3.1/node_modules/qrcode.react/lib/esm/index.js","../../../packages/dsh-remote-bridge/src/core/pair-address.ts","../../../packages/dsh-remote-bridge/src/client/semantic.ts","../../../packages/dsh-remote-bridge/src/client/PairPanel.tsx","../../../packages/dsh-remote-bridge/src/client/icons.tsx","../../../packages/dsh-remote-bridge/src/client/PairEntry.tsx","../../../packages/dsh-remote-bridge/src/client/RemoteConnectionExtension.tsx","../../../packages/dsh-remote-bridge/src/core/protocol.ts","../../../packages/dsh-remote-bridge/src/client/pair-token.ts","../../../packages/dsh-remote-bridge/src/core/ui.ts","../../../packages/dsh-remote-bridge/src/client/ui-card.ts","../../../packages/dsh-remote-bridge/src/client/UiPresentRow.tsx","../../../packages/dsh-remote-bridge/src/client/toolview-slot.ts","../../../packages/dsh-remote-bridge/src/client/locales.ts","../../../packages/dsh-remote-bridge/src/client/index.ts"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b)) {\n if (__propIsEnum.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n }\n return a;\n};\nvar __objRest = (source, exclude) => {\n var target = {};\n for (var prop in source)\n if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)\n target[prop] = source[prop];\n if (source != null && __getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(source)) {\n if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))\n target[prop] = source[prop];\n }\n return target;\n};\n\n// src/index.tsx\nimport React from \"react\";\n\n// src/third-party/qrcodegen/index.ts\n/**\n * @license QR Code generator library (TypeScript)\n * Copyright (c) Project Nayuki.\n * SPDX-License-Identifier: MIT\n */\nvar qrcodegen;\n((qrcodegen2) => {\n const _QrCode = class _QrCode {\n /*-- Constructor (low level) and fields --*/\n // Creates a new QR Code with the given version number,\n // error correction level, data codeword bytes, and mask number.\n // This is a low-level API that most users should not use directly.\n // A mid-level API is the encodeSegments() function.\n constructor(version, errorCorrectionLevel, dataCodewords, msk) {\n this.version = version;\n this.errorCorrectionLevel = errorCorrectionLevel;\n // The modules of this QR Code (false = light, true = dark).\n // Immutable after constructor finishes. Accessed through getModule().\n this.modules = [];\n // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.\n this.isFunction = [];\n if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION)\n throw new RangeError(\"Version value out of range\");\n if (msk < -1 || msk > 7)\n throw new RangeError(\"Mask value out of range\");\n this.size = version * 4 + 17;\n let row = [];\n for (let i = 0; i < this.size; i++)\n row.push(false);\n for (let i = 0; i < this.size; i++) {\n this.modules.push(row.slice());\n this.isFunction.push(row.slice());\n }\n this.drawFunctionPatterns();\n const allCodewords = this.addEccAndInterleave(dataCodewords);\n this.drawCodewords(allCodewords);\n if (msk == -1) {\n let minPenalty = 1e9;\n for (let i = 0; i < 8; i++) {\n this.applyMask(i);\n this.drawFormatBits(i);\n const penalty = this.getPenaltyScore();\n if (penalty < minPenalty) {\n msk = i;\n minPenalty = penalty;\n }\n this.applyMask(i);\n }\n }\n assert(0 <= msk && msk <= 7);\n this.mask = msk;\n this.applyMask(msk);\n this.drawFormatBits(msk);\n this.isFunction = [];\n }\n /*-- Static factory functions (high level) --*/\n // Returns a QR Code representing the given Unicode text string at the given error correction level.\n // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer\n // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible\n // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the\n // ecl argument if it can be done without increasing the version.\n static encodeText(text, ecl) {\n const segs = qrcodegen2.QrSegment.makeSegments(text);\n return _QrCode.encodeSegments(segs, ecl);\n }\n // Returns a QR Code representing the given binary data at the given error correction level.\n // This function always encodes using the binary segment mode, not any text mode. The maximum number of\n // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.\n // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.\n static encodeBinary(data, ecl) {\n const seg = qrcodegen2.QrSegment.makeBytes(data);\n return _QrCode.encodeSegments([seg], ecl);\n }\n /*-- Static factory functions (mid level) --*/\n // Returns a QR Code representing the given segments with the given encoding parameters.\n // The smallest possible QR Code version within the given range is automatically\n // chosen for the output. Iff boostEcl is true, then the ECC level of the result\n // may be higher than the ecl argument if it can be done without increasing the\n // version. The mask number is either between 0 to 7 (inclusive) to force that\n // mask, or -1 to automatically choose an appropriate mask (which may be slow).\n // This function allows the user to create a custom sequence of segments that switches\n // between modes (such as alphanumeric and byte) to encode text in less space.\n // This is a mid-level API; the high-level API is encodeText() and encodeBinary().\n static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {\n if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7)\n throw new RangeError(\"Invalid value\");\n let version;\n let dataUsedBits;\n for (version = minVersion; ; version++) {\n const dataCapacityBits2 = _QrCode.getNumDataCodewords(version, ecl) * 8;\n const usedBits = QrSegment.getTotalBits(segs, version);\n if (usedBits <= dataCapacityBits2) {\n dataUsedBits = usedBits;\n break;\n }\n if (version >= maxVersion)\n throw new RangeError(\"Data too long\");\n }\n for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) {\n if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version, newEcl) * 8)\n ecl = newEcl;\n }\n let bb = [];\n for (const seg of segs) {\n appendBits(seg.mode.modeBits, 4, bb);\n appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);\n for (const b of seg.getData())\n bb.push(b);\n }\n assert(bb.length == dataUsedBits);\n const dataCapacityBits = _QrCode.getNumDataCodewords(version, ecl) * 8;\n assert(bb.length <= dataCapacityBits);\n appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);\n appendBits(0, (8 - bb.length % 8) % 8, bb);\n assert(bb.length % 8 == 0);\n for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)\n appendBits(padByte, 8, bb);\n let dataCodewords = [];\n while (dataCodewords.length * 8 < bb.length)\n dataCodewords.push(0);\n bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));\n return new _QrCode(version, ecl, dataCodewords, mask);\n }\n /*-- Accessor methods --*/\n // Returns the color of the module (pixel) at the given coordinates, which is false\n // for light or true for dark. The top left corner has the coordinates (x=0, y=0).\n // If the given coordinates are out of bounds, then false (light) is returned.\n getModule(x, y) {\n return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];\n }\n // Modified to expose modules for easy access\n getModules() {\n return this.modules;\n }\n /*-- Private helper methods for constructor: Drawing function modules --*/\n // Reads this object's version field, and draws and marks all function modules.\n drawFunctionPatterns() {\n for (let i = 0; i < this.size; i++) {\n this.setFunctionModule(6, i, i % 2 == 0);\n this.setFunctionModule(i, 6, i % 2 == 0);\n }\n this.drawFinderPattern(3, 3);\n this.drawFinderPattern(this.size - 4, 3);\n this.drawFinderPattern(3, this.size - 4);\n const alignPatPos = this.getAlignmentPatternPositions();\n const numAlign = alignPatPos.length;\n for (let i = 0; i < numAlign; i++) {\n for (let j = 0; j < numAlign; j++) {\n if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))\n this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);\n }\n }\n this.drawFormatBits(0);\n this.drawVersion();\n }\n // Draws two copies of the format bits (with its own error correction code)\n // based on the given mask and this object's error correction level field.\n drawFormatBits(mask) {\n const data = this.errorCorrectionLevel.formatBits << 3 | mask;\n let rem = data;\n for (let i = 0; i < 10; i++)\n rem = rem << 1 ^ (rem >>> 9) * 1335;\n const bits = (data << 10 | rem) ^ 21522;\n assert(bits >>> 15 == 0);\n for (let i = 0; i <= 5; i++)\n this.setFunctionModule(8, i, getBit(bits, i));\n this.setFunctionModule(8, 7, getBit(bits, 6));\n this.setFunctionModule(8, 8, getBit(bits, 7));\n this.setFunctionModule(7, 8, getBit(bits, 8));\n for (let i = 9; i < 15; i++)\n this.setFunctionModule(14 - i, 8, getBit(bits, i));\n for (let i = 0; i < 8; i++)\n this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));\n for (let i = 8; i < 15; i++)\n this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));\n this.setFunctionModule(8, this.size - 8, true);\n }\n // Draws two copies of the version bits (with its own error correction code),\n // based on this object's version field, iff 7 <= version <= 40.\n drawVersion() {\n if (this.version < 7)\n return;\n let rem = this.version;\n for (let i = 0; i < 12; i++)\n rem = rem << 1 ^ (rem >>> 11) * 7973;\n const bits = this.version << 12 | rem;\n assert(bits >>> 18 == 0);\n for (let i = 0; i < 18; i++) {\n const color = getBit(bits, i);\n const a = this.size - 11 + i % 3;\n const b = Math.floor(i / 3);\n this.setFunctionModule(a, b, color);\n this.setFunctionModule(b, a, color);\n }\n }\n // Draws a 9*9 finder pattern including the border separator,\n // with the center module at (x, y). Modules can be out of bounds.\n drawFinderPattern(x, y) {\n for (let dy = -4; dy <= 4; dy++) {\n for (let dx = -4; dx <= 4; dx++) {\n const dist = Math.max(Math.abs(dx), Math.abs(dy));\n const xx = x + dx;\n const yy = y + dy;\n if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)\n this.setFunctionModule(xx, yy, dist != 2 && dist != 4);\n }\n }\n }\n // Draws a 5*5 alignment pattern, with the center module\n // at (x, y). All modules must be in bounds.\n drawAlignmentPattern(x, y) {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++)\n this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);\n }\n }\n // Sets the color of a module and marks it as a function module.\n // Only used by the constructor. Coordinates must be in bounds.\n setFunctionModule(x, y, isDark) {\n this.modules[y][x] = isDark;\n this.isFunction[y][x] = true;\n }\n /*-- Private helper methods for constructor: Codewords and masking --*/\n // Returns a new byte string representing the given data with the appropriate error correction\n // codewords appended to it, based on this object's version and error correction level.\n addEccAndInterleave(data) {\n const ver = this.version;\n const ecl = this.errorCorrectionLevel;\n if (data.length != _QrCode.getNumDataCodewords(ver, ecl))\n throw new RangeError(\"Invalid argument\");\n const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];\n const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];\n const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8);\n const numShortBlocks = numBlocks - rawCodewords % numBlocks;\n const shortBlockLen = Math.floor(rawCodewords / numBlocks);\n let blocks = [];\n const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen);\n for (let i = 0, k = 0; i < numBlocks; i++) {\n let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));\n k += dat.length;\n const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv);\n if (i < numShortBlocks)\n dat.push(0);\n blocks.push(dat.concat(ecc));\n }\n let result = [];\n for (let i = 0; i < blocks[0].length; i++) {\n blocks.forEach((block, j) => {\n if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)\n result.push(block[i]);\n });\n }\n assert(result.length == rawCodewords);\n return result;\n }\n // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire\n // data area of this QR Code. Function modules need to be marked off before this is called.\n drawCodewords(data) {\n if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8))\n throw new RangeError(\"Invalid argument\");\n let i = 0;\n for (let right = this.size - 1; right >= 1; right -= 2) {\n if (right == 6)\n right = 5;\n for (let vert = 0; vert < this.size; vert++) {\n for (let j = 0; j < 2; j++) {\n const x = right - j;\n const upward = (right + 1 & 2) == 0;\n const y = upward ? this.size - 1 - vert : vert;\n if (!this.isFunction[y][x] && i < data.length * 8) {\n this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));\n i++;\n }\n }\n }\n }\n assert(i == data.length * 8);\n }\n // XORs the codeword modules in this QR Code with the given mask pattern.\n // The function modules must be marked and the codeword bits must be drawn\n // before masking. Due to the arithmetic of XOR, calling applyMask() with\n // the same mask value a second time will undo the mask. A final well-formed\n // QR Code needs exactly one (not zero, two, etc.) mask applied.\n applyMask(mask) {\n if (mask < 0 || mask > 7)\n throw new RangeError(\"Mask value out of range\");\n for (let y = 0; y < this.size; y++) {\n for (let x = 0; x < this.size; x++) {\n let invert;\n switch (mask) {\n case 0:\n invert = (x + y) % 2 == 0;\n break;\n case 1:\n invert = y % 2 == 0;\n break;\n case 2:\n invert = x % 3 == 0;\n break;\n case 3:\n invert = (x + y) % 3 == 0;\n break;\n case 4:\n invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;\n break;\n case 5:\n invert = x * y % 2 + x * y % 3 == 0;\n break;\n case 6:\n invert = (x * y % 2 + x * y % 3) % 2 == 0;\n break;\n case 7:\n invert = ((x + y) % 2 + x * y % 3) % 2 == 0;\n break;\n default:\n throw new Error(\"Unreachable\");\n }\n if (!this.isFunction[y][x] && invert)\n this.modules[y][x] = !this.modules[y][x];\n }\n }\n }\n // Calculates and returns the penalty score based on state of this QR Code's current modules.\n // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.\n getPenaltyScore() {\n let result = 0;\n for (let y = 0; y < this.size; y++) {\n let runColor = false;\n let runX = 0;\n let runHistory = [0, 0, 0, 0, 0, 0, 0];\n for (let x = 0; x < this.size; x++) {\n if (this.modules[y][x] == runColor) {\n runX++;\n if (runX == 5)\n result += _QrCode.PENALTY_N1;\n else if (runX > 5)\n result++;\n } else {\n this.finderPenaltyAddHistory(runX, runHistory);\n if (!runColor)\n result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;\n runColor = this.modules[y][x];\n runX = 1;\n }\n }\n result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3;\n }\n for (let x = 0; x < this.size; x++) {\n let runColor = false;\n let runY = 0;\n let runHistory = [0, 0, 0, 0, 0, 0, 0];\n for (let y = 0; y < this.size; y++) {\n if (this.modules[y][x] == runColor) {\n runY++;\n if (runY == 5)\n result += _QrCode.PENALTY_N1;\n else if (runY > 5)\n result++;\n } else {\n this.finderPenaltyAddHistory(runY, runHistory);\n if (!runColor)\n result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;\n runColor = this.modules[y][x];\n runY = 1;\n }\n }\n result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode.PENALTY_N3;\n }\n for (let y = 0; y < this.size - 1; y++) {\n for (let x = 0; x < this.size - 1; x++) {\n const color = this.modules[y][x];\n if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])\n result += _QrCode.PENALTY_N2;\n }\n }\n let dark = 0;\n for (const row of this.modules)\n dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);\n const total = this.size * this.size;\n const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;\n assert(0 <= k && k <= 9);\n result += k * _QrCode.PENALTY_N4;\n assert(0 <= result && result <= 2568888);\n return result;\n }\n /*-- Private helper functions --*/\n // Returns an ascending list of positions of alignment patterns for this version number.\n // Each position is in the range [0,177), and are used on both the x and y axes.\n // This could be implemented as lookup table of 40 variable-length lists of integers.\n getAlignmentPatternPositions() {\n if (this.version == 1)\n return [];\n else {\n const numAlign = Math.floor(this.version / 7) + 2;\n const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;\n let result = [6];\n for (let pos = this.size - 7; result.length < numAlign; pos -= step)\n result.splice(1, 0, pos);\n return result;\n }\n }\n // Returns the number of data bits that can be stored in a QR Code of the given version number, after\n // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.\n // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.\n static getNumRawDataModules(ver) {\n if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION)\n throw new RangeError(\"Version number out of range\");\n let result = (16 * ver + 128) * ver + 64;\n if (ver >= 2) {\n const numAlign = Math.floor(ver / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (ver >= 7)\n result -= 36;\n }\n assert(208 <= result && result <= 29648);\n return result;\n }\n // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any\n // QR Code of the given version number and error correction level, with remainder bits discarded.\n // This stateless pure function could be implemented as a (40*4)-cell lookup table.\n static getNumDataCodewords(ver, ecl) {\n return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];\n }\n // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be\n // implemented as a lookup table over all possible parameter values, instead of as an algorithm.\n static reedSolomonComputeDivisor(degree) {\n if (degree < 1 || degree > 255)\n throw new RangeError(\"Degree out of range\");\n let result = [];\n for (let i = 0; i < degree - 1; i++)\n result.push(0);\n result.push(1);\n let root = 1;\n for (let i = 0; i < degree; i++) {\n for (let j = 0; j < result.length; j++) {\n result[j] = _QrCode.reedSolomonMultiply(result[j], root);\n if (j + 1 < result.length)\n result[j] ^= result[j + 1];\n }\n root = _QrCode.reedSolomonMultiply(root, 2);\n }\n return result;\n }\n // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.\n static reedSolomonComputeRemainder(data, divisor) {\n let result = divisor.map((_) => 0);\n for (const b of data) {\n const factor = b ^ result.shift();\n result.push(0);\n divisor.forEach((coef, i) => result[i] ^= _QrCode.reedSolomonMultiply(coef, factor));\n }\n return result;\n }\n // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result\n // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.\n static reedSolomonMultiply(x, y) {\n if (x >>> 8 != 0 || y >>> 8 != 0)\n throw new RangeError(\"Byte out of range\");\n let z = 0;\n for (let i = 7; i >= 0; i--) {\n z = z << 1 ^ (z >>> 7) * 285;\n z ^= (y >>> i & 1) * x;\n }\n assert(z >>> 8 == 0);\n return z;\n }\n // Can only be called immediately after a light run is added, and\n // returns either 0, 1, or 2. A helper function for getPenaltyScore().\n finderPenaltyCountPatterns(runHistory) {\n const n = runHistory[1];\n assert(n <= this.size * 3);\n const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;\n return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);\n }\n // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().\n finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {\n if (currentRunColor) {\n this.finderPenaltyAddHistory(currentRunLength, runHistory);\n currentRunLength = 0;\n }\n currentRunLength += this.size;\n this.finderPenaltyAddHistory(currentRunLength, runHistory);\n return this.finderPenaltyCountPatterns(runHistory);\n }\n // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().\n finderPenaltyAddHistory(currentRunLength, runHistory) {\n if (runHistory[0] == 0)\n currentRunLength += this.size;\n runHistory.pop();\n runHistory.unshift(currentRunLength);\n }\n };\n /*-- Constants and tables --*/\n // The minimum version number supported in the QR Code Model 2 standard.\n _QrCode.MIN_VERSION = 1;\n // The maximum version number supported in the QR Code Model 2 standard.\n _QrCode.MAX_VERSION = 40;\n // For use in getPenaltyScore(), when evaluating which mask is best.\n _QrCode.PENALTY_N1 = 3;\n _QrCode.PENALTY_N2 = 3;\n _QrCode.PENALTY_N3 = 40;\n _QrCode.PENALTY_N4 = 10;\n _QrCode.ECC_CODEWORDS_PER_BLOCK = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level\n [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],\n // Low\n [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],\n // Medium\n [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],\n // Quartile\n [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]\n // High\n ];\n _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level\n [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],\n // Low\n [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],\n // Medium\n [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],\n // Quartile\n [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]\n // High\n ];\n let QrCode = _QrCode;\n qrcodegen2.QrCode = _QrCode;\n function appendBits(val, len, bb) {\n if (len < 0 || len > 31 || val >>> len != 0)\n throw new RangeError(\"Value out of range\");\n for (let i = len - 1; i >= 0; i--)\n bb.push(val >>> i & 1);\n }\n function getBit(x, i) {\n return (x >>> i & 1) != 0;\n }\n function assert(cond) {\n if (!cond)\n throw new Error(\"Assertion error\");\n }\n const _QrSegment = class _QrSegment {\n /*-- Constructor (low level) and fields --*/\n // Creates a new QR Code segment with the given attributes and data.\n // The character count (numChars) must agree with the mode and the bit buffer length,\n // but the constraint isn't checked. The given bit buffer is cloned and stored.\n constructor(mode, numChars, bitData) {\n this.mode = mode;\n this.numChars = numChars;\n this.bitData = bitData;\n if (numChars < 0)\n throw new RangeError(\"Invalid argument\");\n this.bitData = bitData.slice();\n }\n /*-- Static factory functions (mid level) --*/\n // Returns a segment representing the given binary data encoded in\n // byte mode. All input byte arrays are acceptable. Any text string\n // can be converted to UTF-8 bytes and encoded as a byte mode segment.\n static makeBytes(data) {\n let bb = [];\n for (const b of data)\n appendBits(b, 8, bb);\n return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);\n }\n // Returns a segment representing the given string of decimal digits encoded in numeric mode.\n static makeNumeric(digits) {\n if (!_QrSegment.isNumeric(digits))\n throw new RangeError(\"String contains non-numeric characters\");\n let bb = [];\n for (let i = 0; i < digits.length; ) {\n const n = Math.min(digits.length - i, 3);\n appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);\n i += n;\n }\n return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);\n }\n // Returns a segment representing the given text string encoded in alphanumeric mode.\n // The characters allowed are: 0 to 9, A to Z (uppercase only), space,\n // dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n static makeAlphanumeric(text) {\n if (!_QrSegment.isAlphanumeric(text))\n throw new RangeError(\"String contains unencodable characters in alphanumeric mode\");\n let bb = [];\n let i;\n for (i = 0; i + 2 <= text.length; i += 2) {\n let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;\n temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));\n appendBits(temp, 11, bb);\n }\n if (i < text.length)\n appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);\n return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);\n }\n // Returns a new mutable list of zero or more segments to represent the given Unicode text string.\n // The result may use various segment modes and switch modes to optimize the length of the bit stream.\n static makeSegments(text) {\n if (text == \"\")\n return [];\n else if (_QrSegment.isNumeric(text))\n return [_QrSegment.makeNumeric(text)];\n else if (_QrSegment.isAlphanumeric(text))\n return [_QrSegment.makeAlphanumeric(text)];\n else\n return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))];\n }\n // Returns a segment representing an Extended Channel Interpretation\n // (ECI) designator with the given assignment value.\n static makeEci(assignVal) {\n let bb = [];\n if (assignVal < 0)\n throw new RangeError(\"ECI assignment value out of range\");\n else if (assignVal < 1 << 7)\n appendBits(assignVal, 8, bb);\n else if (assignVal < 1 << 14) {\n appendBits(2, 2, bb);\n appendBits(assignVal, 14, bb);\n } else if (assignVal < 1e6) {\n appendBits(6, 3, bb);\n appendBits(assignVal, 21, bb);\n } else\n throw new RangeError(\"ECI assignment value out of range\");\n return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);\n }\n // Tests whether the given string can be encoded as a segment in numeric mode.\n // A string is encodable iff each character is in the range 0 to 9.\n static isNumeric(text) {\n return _QrSegment.NUMERIC_REGEX.test(text);\n }\n // Tests whether the given string can be encoded as a segment in alphanumeric mode.\n // A string is encodable iff each character is in the following set: 0 to 9, A to Z\n // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n static isAlphanumeric(text) {\n return _QrSegment.ALPHANUMERIC_REGEX.test(text);\n }\n /*-- Methods --*/\n // Returns a new copy of the data bits of this segment.\n getData() {\n return this.bitData.slice();\n }\n // (Package-private) Calculates and returns the number of bits needed to encode the given segments at\n // the given version. The result is infinity if a segment has too many characters to fit its length field.\n static getTotalBits(segs, version) {\n let result = 0;\n for (const seg of segs) {\n const ccbits = seg.mode.numCharCountBits(version);\n if (seg.numChars >= 1 << ccbits)\n return Infinity;\n result += 4 + ccbits + seg.bitData.length;\n }\n return result;\n }\n // Returns a new array of bytes representing the given string encoded in UTF-8.\n static toUtf8ByteArray(str) {\n str = encodeURI(str);\n let result = [];\n for (let i = 0; i < str.length; i++) {\n if (str.charAt(i) != \"%\")\n result.push(str.charCodeAt(i));\n else {\n result.push(parseInt(str.substring(i + 1, i + 3), 16));\n i += 2;\n }\n }\n return result;\n }\n };\n /*-- Constants --*/\n // Describes precisely all strings that are encodable in numeric mode.\n _QrSegment.NUMERIC_REGEX = /^[0-9]*$/;\n // Describes precisely all strings that are encodable in alphanumeric mode.\n _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\\/:-]*$/;\n // The set of all legal characters in alphanumeric mode,\n // where each character value maps to the index in the string.\n _QrSegment.ALPHANUMERIC_CHARSET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:\";\n let QrSegment = _QrSegment;\n qrcodegen2.QrSegment = _QrSegment;\n})(qrcodegen || (qrcodegen = {}));\n((qrcodegen2) => {\n let QrCode;\n ((QrCode2) => {\n const _Ecc = class _Ecc {\n // The QR Code can tolerate about 30% erroneous codewords\n /*-- Constructor and fields --*/\n constructor(ordinal, formatBits) {\n this.ordinal = ordinal;\n this.formatBits = formatBits;\n }\n };\n /*-- Constants --*/\n _Ecc.LOW = new _Ecc(0, 1);\n // The QR Code can tolerate about 7% erroneous codewords\n _Ecc.MEDIUM = new _Ecc(1, 0);\n // The QR Code can tolerate about 15% erroneous codewords\n _Ecc.QUARTILE = new _Ecc(2, 3);\n // The QR Code can tolerate about 25% erroneous codewords\n _Ecc.HIGH = new _Ecc(3, 2);\n let Ecc = _Ecc;\n QrCode2.Ecc = _Ecc;\n })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));\n})(qrcodegen || (qrcodegen = {}));\n((qrcodegen2) => {\n let QrSegment;\n ((QrSegment2) => {\n const _Mode = class _Mode {\n /*-- Constructor and fields --*/\n constructor(modeBits, numBitsCharCount) {\n this.modeBits = modeBits;\n this.numBitsCharCount = numBitsCharCount;\n }\n /*-- Method --*/\n // (Package-private) Returns the bit width of the character count field for a segment in\n // this mode in a QR Code at the given version number. The result is in the range [0, 16].\n numCharCountBits(ver) {\n return this.numBitsCharCount[Math.floor((ver + 7) / 17)];\n }\n };\n /*-- Constants --*/\n _Mode.NUMERIC = new _Mode(1, [10, 12, 14]);\n _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);\n _Mode.BYTE = new _Mode(4, [8, 16, 16]);\n _Mode.KANJI = new _Mode(8, [8, 10, 12]);\n _Mode.ECI = new _Mode(7, [0, 0, 0]);\n let Mode = _Mode;\n QrSegment2.Mode = _Mode;\n })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));\n})(qrcodegen || (qrcodegen = {}));\nvar qrcodegen_default = qrcodegen;\n\n// src/index.tsx\n/**\n * @license qrcode.react\n * Copyright (c) Paul O'Shannessy\n * SPDX-License-Identifier: ISC\n */\nvar ERROR_LEVEL_MAP = {\n L: qrcodegen_default.QrCode.Ecc.LOW,\n M: qrcodegen_default.QrCode.Ecc.MEDIUM,\n Q: qrcodegen_default.QrCode.Ecc.QUARTILE,\n H: qrcodegen_default.QrCode.Ecc.HIGH\n};\nvar DEFAULT_SIZE = 128;\nvar DEFAULT_LEVEL = \"L\";\nvar DEFAULT_BGCOLOR = \"#FFFFFF\";\nvar DEFAULT_FGCOLOR = \"#000000\";\nvar DEFAULT_INCLUDEMARGIN = false;\nvar DEFAULT_MINVERSION = 1;\nvar SPEC_MARGIN_SIZE = 4;\nvar DEFAULT_MARGIN_SIZE = 0;\nvar DEFAULT_IMG_SCALE = 0.1;\nfunction generatePath(modules, margin = 0) {\n const ops = [];\n modules.forEach(function(row, y) {\n let start = null;\n row.forEach(function(cell, x) {\n if (!cell && start !== null) {\n ops.push(\n `M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`\n );\n start = null;\n return;\n }\n if (x === row.length - 1) {\n if (!cell) {\n return;\n }\n if (start === null) {\n ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);\n } else {\n ops.push(\n `M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`\n );\n }\n return;\n }\n if (cell && start === null) {\n start = x;\n }\n });\n });\n return ops.join(\"\");\n}\nfunction excavateModules(modules, excavation) {\n return modules.slice().map((row, y) => {\n if (y < excavation.y || y >= excavation.y + excavation.h) {\n return row;\n }\n return row.map((cell, x) => {\n if (x < excavation.x || x >= excavation.x + excavation.w) {\n return cell;\n }\n return false;\n });\n });\n}\nfunction getImageSettings(cells, size, margin, imageSettings) {\n if (imageSettings == null) {\n return null;\n }\n const numCells = cells.length + margin * 2;\n const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);\n const scale = numCells / size;\n const w = (imageSettings.width || defaultSize) * scale;\n const h = (imageSettings.height || defaultSize) * scale;\n const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;\n const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;\n const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;\n let excavation = null;\n if (imageSettings.excavate) {\n let floorX = Math.floor(x);\n let floorY = Math.floor(y);\n let ceilW = Math.ceil(w + x - floorX);\n let ceilH = Math.ceil(h + y - floorY);\n excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };\n }\n const crossOrigin = imageSettings.crossOrigin;\n return { x, y, h, w, excavation, opacity, crossOrigin };\n}\nfunction getMarginSize(includeMargin, marginSize) {\n if (marginSize != null) {\n return Math.max(Math.floor(marginSize), 0);\n }\n return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;\n}\nfunction useQRCode({\n value,\n level,\n minVersion,\n includeMargin,\n marginSize,\n imageSettings,\n size,\n boostLevel\n}) {\n let qrcode = React.useMemo(() => {\n const values = Array.isArray(value) ? value : [value];\n const segments = values.reduce((accum, v) => {\n accum.push(...qrcodegen_default.QrSegment.makeSegments(v));\n return accum;\n }, []);\n return qrcodegen_default.QrCode.encodeSegments(\n segments,\n ERROR_LEVEL_MAP[level],\n minVersion,\n void 0,\n void 0,\n boostLevel\n );\n }, [value, level, minVersion, boostLevel]);\n const { cells, margin, numCells, calculatedImageSettings } = React.useMemo(() => {\n let cells2 = qrcode.getModules();\n const margin2 = getMarginSize(includeMargin, marginSize);\n const numCells2 = cells2.length + margin2 * 2;\n const calculatedImageSettings2 = getImageSettings(\n cells2,\n size,\n margin2,\n imageSettings\n );\n return {\n cells: cells2,\n margin: margin2,\n numCells: numCells2,\n calculatedImageSettings: calculatedImageSettings2\n };\n }, [qrcode, size, imageSettings, includeMargin, marginSize]);\n return {\n qrcode,\n margin,\n cells,\n numCells,\n calculatedImageSettings\n };\n}\nvar SUPPORTS_PATH2D = function() {\n try {\n new Path2D().addPath(new Path2D());\n } catch (e) {\n return false;\n }\n return true;\n}();\nvar QRCodeCanvas = React.forwardRef(\n function QRCodeCanvas2(props, forwardedRef) {\n const _a = props, {\n value,\n size = DEFAULT_SIZE,\n level = DEFAULT_LEVEL,\n bgColor = DEFAULT_BGCOLOR,\n fgColor = DEFAULT_FGCOLOR,\n includeMargin = DEFAULT_INCLUDEMARGIN,\n minVersion = DEFAULT_MINVERSION,\n boostLevel,\n marginSize,\n imageSettings\n } = _a, extraProps = __objRest(_a, [\n \"value\",\n \"size\",\n \"level\",\n \"bgColor\",\n \"fgColor\",\n \"includeMargin\",\n \"minVersion\",\n \"boostLevel\",\n \"marginSize\",\n \"imageSettings\"\n ]);\n const _b = extraProps, { style } = _b, otherProps = __objRest(_b, [\"style\"]);\n const imgSrc = imageSettings == null ? void 0 : imageSettings.src;\n const _canvas = React.useRef(null);\n const _image = React.useRef(null);\n const setCanvasRef = React.useCallback(\n (node) => {\n _canvas.current = node;\n if (typeof forwardedRef === \"function\") {\n forwardedRef(node);\n } else if (forwardedRef) {\n forwardedRef.current = node;\n }\n },\n [forwardedRef]\n );\n const [isImgLoaded, setIsImageLoaded] = React.useState(false);\n const { margin, cells, numCells, calculatedImageSettings } = useQRCode({\n value,\n level,\n minVersion,\n boostLevel,\n includeMargin,\n marginSize,\n imageSettings,\n size\n });\n React.useEffect(() => {\n if (_canvas.current != null) {\n const canvas = _canvas.current;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n return;\n }\n let cellsToDraw = cells;\n const image = _image.current;\n const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;\n if (haveImageToRender) {\n if (calculatedImageSettings.excavation != null) {\n cellsToDraw = excavateModules(\n cells,\n calculatedImageSettings.excavation\n );\n }\n }\n const pixelRatio = window.devicePixelRatio || 1;\n canvas.height = canvas.width = size * pixelRatio;\n const scale = size / numCells * pixelRatio;\n ctx.scale(scale, scale);\n ctx.fillStyle = bgColor;\n ctx.fillRect(0, 0, numCells, numCells);\n ctx.fillStyle = fgColor;\n if (SUPPORTS_PATH2D) {\n ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));\n } else {\n cells.forEach(function(row, rdx) {\n row.forEach(function(cell, cdx) {\n if (cell) {\n ctx.fillRect(cdx + margin, rdx + margin, 1, 1);\n }\n });\n });\n }\n if (calculatedImageSettings) {\n ctx.globalAlpha = calculatedImageSettings.opacity;\n }\n if (haveImageToRender) {\n ctx.drawImage(\n image,\n calculatedImageSettings.x + margin,\n calculatedImageSettings.y + margin,\n calculatedImageSettings.w,\n calculatedImageSettings.h\n );\n }\n }\n });\n React.useEffect(() => {\n setIsImageLoaded(false);\n }, [imgSrc]);\n const canvasStyle = __spreadValues({ height: size, width: size }, style);\n let img = null;\n if (imgSrc != null) {\n img = /* @__PURE__ */ React.createElement(\n \"img\",\n {\n src: imgSrc,\n key: imgSrc,\n style: { display: \"none\" },\n onLoad: () => {\n setIsImageLoaded(true);\n },\n ref: _image,\n crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin\n }\n );\n }\n return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(\n \"canvas\",\n __spreadValues({\n style: canvasStyle,\n height: size,\n width: size,\n ref: setCanvasRef,\n role: \"img\"\n }, otherProps)\n ), img);\n }\n);\nQRCodeCanvas.displayName = \"QRCodeCanvas\";\nvar QRCodeSVG = React.forwardRef(\n function QRCodeSVG2(props, forwardedRef) {\n const _a = props, {\n value,\n size = DEFAULT_SIZE,\n level = DEFAULT_LEVEL,\n bgColor = DEFAULT_BGCOLOR,\n fgColor = DEFAULT_FGCOLOR,\n includeMargin = DEFAULT_INCLUDEMARGIN,\n minVersion = DEFAULT_MINVERSION,\n boostLevel,\n title,\n marginSize,\n imageSettings\n } = _a, otherProps = __objRest(_a, [\n \"value\",\n \"size\",\n \"level\",\n \"bgColor\",\n \"fgColor\",\n \"includeMargin\",\n \"minVersion\",\n \"boostLevel\",\n \"title\",\n \"marginSize\",\n \"imageSettings\"\n ]);\n const { margin, cells, numCells, calculatedImageSettings } = useQRCode({\n value,\n level,\n minVersion,\n boostLevel,\n includeMargin,\n marginSize,\n imageSettings,\n size\n });\n let cellsToDraw = cells;\n let image = null;\n if (imageSettings != null && calculatedImageSettings != null) {\n if (calculatedImageSettings.excavation != null) {\n cellsToDraw = excavateModules(\n cells,\n calculatedImageSettings.excavation\n );\n }\n image = /* @__PURE__ */ React.createElement(\n \"image\",\n {\n href: imageSettings.src,\n height: calculatedImageSettings.h,\n width: calculatedImageSettings.w,\n x: calculatedImageSettings.x + margin,\n y: calculatedImageSettings.y + margin,\n preserveAspectRatio: \"none\",\n opacity: calculatedImageSettings.opacity,\n crossOrigin: calculatedImageSettings.crossOrigin\n }\n );\n }\n const fgPath = generatePath(cellsToDraw, margin);\n return /* @__PURE__ */ React.createElement(\n \"svg\",\n __spreadValues({\n height: size,\n width: size,\n viewBox: `0 0 ${numCells} ${numCells}`,\n ref: forwardedRef,\n role: \"img\"\n }, otherProps),\n !!title && /* @__PURE__ */ React.createElement(\"title\", null, title),\n /* @__PURE__ */ React.createElement(\n \"path\",\n {\n fill: bgColor,\n d: `M0,0 h${numCells}v${numCells}H0z`,\n shapeRendering: \"crispEdges\"\n }\n ),\n /* @__PURE__ */ React.createElement(\"path\", { fill: fgColor, d: fgPath, shapeRendering: \"crispEdges\" }),\n image\n );\n }\n);\nQRCodeSVG.displayName = \"QRCodeSVG\";\nexport {\n QRCodeCanvas,\n QRCodeSVG\n};\n","/**\n * Which kind of address a located pairing origin is, decided in one place\n * because two halves answer with the same word: the panel states the kind to the\n * operator, and the Host log names it beside the machine-local link.\n *\n * The host's own answer comes first, and the literal decides when it did not: a\n * configured base can name a private address — the package README calls\n * `DSH_REMOTE_PUBLIC_BASE_URL` a public or LAN origin — and a surface that\n * called such an address public would promise a phone something it cannot reach\n * from outside. The pattern is anchored to the whole hostname on purpose: a\n * public name that merely starts like a private literal (`10.example.com`) is\n * not one, and printing it is the one thing the address line must never do.\n * Every value this module cannot place reads as public, which is the direction\n * that prints nothing.\n * @module dsh-remote-bridge/core/pair-address\n */\n\n/** Where the host's own answer says a located origin came from. */\nexport type PairOriginSource = 'realtime' | 'env' | 'lan'\n\n/**\n * Hosts a phone can only reach from the same network: the private IPv4 ranges,\n * the unspecified address, and the IPv6 loopback, unique-local and link-local\n * prefixes. IPv4-mapped IPv6 and anything else this does not place stays public,\n * because the failure this predicate may never have is printing a name the host\n * did not vouch for.\n */\nconst LAN_HOST_RE = /^(?:localhost|0\\.0\\.0\\.0|(?:(?:10|127)(?:\\.\\d{1,3}){3}|192\\.168(?:\\.\\d{1,3}){2}|172\\.(?:1[6-9]|2\\d|3[01])(?:\\.\\d{1,3}){2}|169\\.254(?:\\.\\d{1,3}){2})|\\[(?:::1|f[cd][0-9a-f]{2}:|fe[89ab][0-9a-f]:)[0-9a-f:]*\\])$/i\n\n/** The hostname a URL carries, or null when the value is not a URL at all. */\nfunction hostnameOf(origin: string): string | null {\n try {\n return new URL(origin).hostname\n } catch {\n return null\n }\n}\n\n/**\n * Whether a located origin answers only inside this network.\n * @param origin - the located origin, or null when there is none.\n * @param source - where the host said that origin came from.\n * @returns true when a phone must be on the same network to dial it.\n */\nexport function isLanOrigin(origin: string | null, source: PairOriginSource | null): boolean {\n if (source === 'lan') return true\n if (origin === null) return false\n const host = hostnameOf(origin)\n return host !== null && LAN_HOST_RE.test(host)\n}\n","/**\n * Semantic attribute values for the protocol v1 pairing panel (contract:\n * skins/skin-center/contracts/semantic-attrs-v1.md). Root containers carry\n * `data-dsh-plugin`; parts carry bare `data-dsh-part` values owned by that\n * plugin attribute.\n */\n\n/** Plugin short name stamped on the footer trigger and the modal root. */\nexport const PLUGIN_ATTR = 'remote-bridge'\n\n/** The sidebar footer seat trigger. */\nexport const PART_ENTRY = 'entry'\n\n/** The modal panel root. */\nexport const PART_PANEL = 'panel'\n\n/** The QR symbol's box — it also mirrors the encoded string. */\nexport const PART_QR = 'qr'\n\n/** A refusal the host raised. */\nexport const PART_NOTICE = 'notice'\n\n/** The mint-again button. */\nexport const PART_REFRESH = 'refresh'\n\n/** The copy-the-code button. */\nexport const PART_COPY = 'copy'\n\n/**\n * Attribute carrying the exact string the QR symbol encodes, so the operator\n * (and a UI check) can compare it against the host route's answer without\n * decoding the symbol. It is the only machine trace the panel renders.\n */\nexport const QR_VALUE_ATTR = 'data-dsh-qr-value'\n\n/**\n * Marks the QR part of a code that has run out of time. Expiry is state on the\n * existing part, not a new part value: the cross-repository part enum is frozen\n * and a plugin may not extend it for one visual state.\n */\nexport const EXPIRED_ATTR = 'data-expired'\n","/**\n * The protocol v1 pairing panel: the QR symbol, the countdown with its expiry\n * state, the line that says which kind of address the code carries, and the two\n * actions that keep a fresh code on screen.\n *\n * The shell is the official headless `Modal` and every action is the official\n * `Button`, so the overlay, the mask, the card, the focus trap, the Escape\n * command and the interaction states belong to the library. This file owns the\n * information order and the state presentation only: every state and action\n * arrives through props, and the clock is a prop, so the expiry flip is\n * deterministic instead of read from `Date.now()` here.\n */\nimport { memo, useLayoutEffect, useRef } from 'react'\nimport { QRCodeSVG } from 'qrcode.react'\nimport {\n Button, IconCheckOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,\n IconRefreshOutlineRegular, IconWarningOutlineRegular, Modal,\n} from '@deepseek-ai/dsh-client-ui-primitives/client'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'\nimport { isLanOrigin, type PairOriginSource } from '../core/pair-address.ts'\nimport {\n EXPIRED_ATTR, PART_COPY, PART_NOTICE, PART_PANEL, PART_QR, PART_REFRESH, PLUGIN_ATTR, QR_VALUE_ATTR,\n} from './semantic.ts'\nimport css from './panel.module.css'\n\n/** The custom property carrying the dialog's own enter keyframe name. */\nconst EXIT_NAME_VAR = '--pair-exit-name'\n\n/**\n * Where a reader of the beta build can reach the people running it. The URL is\n * code, not copy: the dictionaries carry the sentence, this constant carries the\n * destination, so a translation cannot retarget the link and a check can assert\n * the real one.\n */\nexport const COMMUNITY_INVITE_URL = 'https://discord.gg/JdKTTdpUH'\n\n/** What the panel is currently showing. */\nexport type PairPanelState =\n /** A read is in flight. */\n | { kind: 'reading' }\n /**\n * A live one-shot secret. `pairingUrl`, when the host could name its own\n * public origin, is what the QR encodes: a `{token, url}` document the iOS\n * client parses into both halves of its configuration, so one scan sets the\n * address AND the token. With no origin the QR carries the bare token and the\n * panel says the address has to be set on the phone by hand. `originSource`\n * and the literal itself decide which of the two located lines renders: a\n * public origin is stated as a kind and never printed, while a LAN literal is\n * named because it answers only inside the network this page is already on.\n */\n | {\n kind: 'ready'\n token: string\n issuedAt: number\n expiresAt: number\n origin: string | null\n originSource: PairOriginSource | null\n pairingUrl: string | null\n }\n /** 403 from the loopback gate: this page is not open on the machine itself. */\n | { kind: 'forbidden' }\n /** The host route answered with an unexpected status or shape. */\n | { kind: 'failed'; status: number }\n /** The request never reached the host. */\n | { kind: 'unreachable' }\n\n/** How the last copy attempt went. */\nexport type PairCopyState = 'idle' | 'copied' | 'failed'\n\nexport interface PairPanelProps {\n t: PropsLocale<'remote-bridge'>['t']\n state: PairPanelState\n /** The current wall clock; the entry supplies it from a one-second ticker. */\n now: number\n /** This page's own `host:port`, named in the origin warning. */\n host: string\n copy: PairCopyState\n /** Whether the modal is mounted at all (the entry keeps it for the leave leg). */\n showing: boolean\n /** Whether the leave leg is running; the card stays mounted until it ends. */\n closing: boolean\n /** The panel element's id, so the seat trigger can name what it expands. */\n id: string\n onClose(): void\n /** The leave leg reported completion: the entry may unmount the modal now. */\n onExited(): void\n onRefresh(): void\n onCopy(payload: string): void\n}\n\n/**\n * The QR symbol, memoized on the secret: the countdown re-renders the panel\n * every second, and qrcode.react rebuilds the whole module path on each render.\n * The encoded value is the host's own `pairingUrl` verbatim when there is one —\n * a `{token, url}` document whose `url` names THIS instance's public relay, so\n * the phone adopts an origin that actually reaches this host. The bare-token\n * fallback means the phone keeps whatever origin it already has.\n */\nconst PairQrCode = memo(function PairQrCode({ value, label }: { value: string; label: string }) {\n return <QRCodeSVG value={value} size={184} level=\"M\" marginSize={1} aria-label={label} />\n})\n\n/** The one string the panel hands out: what the symbol encodes, what copy copies. */\nfunction payloadOf(state: PairPanelState): string {\n return state.kind === 'ready' ? (state.pairingUrl ?? state.token) : ''\n}\n\n/**\n * Render the pairing panel.\n * @param props - locale seat, view state, clock, page host and actions.\n * @returns the panel element tree.\n */\nexport function PairPanel({\n t, state, now, host, copy, showing, closing, id, onClose, onExited, onRefresh, onCopy,\n}: PairPanelProps) {\n const panel = useRef<HTMLDivElement | null>(null)\n const ready = state.kind === 'ready'\n const remainingMs = ready ? Math.max(0, state.expiresAt - now) : 0\n const expired = ready && remainingMs <= 0\n const seconds = Math.ceil(remainingMs / 1000)\n const windowMs = ready ? Math.max(1, state.expiresAt - state.issuedAt) : 1\n const percent = Math.min(100, Math.max(0, Math.round((remainingMs / windowMs) * 100)))\n const payload = payloadOf(state)\n // Only a live code can be handed out. An expired one is still on screen, so\n // its button stays put and reports that it is switched off.\n const canCopy = !expired && payload !== ''\n // A refusal the host raised is retried; a live or expired code is minted again.\n const primaryLabel = state.kind === 'failed' || state.kind === 'unreachable' ? t('action.retry') : t('pair.refresh')\n const located = ready && state.pairingUrl !== null\n // A located origin answers only inside this network when the host said so or\n // the literal itself is a private one; anything else counts as public, because\n // the one thing this line must never do is print a hostname the host did not\n // vouch for.\n const onLan = located && isLanOrigin(state.origin, state.originSource)\n\n // The library owns the enter animation and the bundler scopes its keyframe\n // name, so the leave leg cannot name it in CSS. Read the mounted dialog's own\n // animation at the moment closing starts and hand it to the card: the exit\n // then plays that exact keyframe backwards (M2, same path reversed). Clearing\n // it on reopen is what lets the same card come back to full opacity.\n useLayoutEffect(() => {\n const element = panel.current\n if (element === null) return\n if (!closing) {\n element.style.removeProperty(EXIT_NAME_VAR)\n return\n }\n const dialog = element.parentElement\n const enter = dialog === null ? '' : window.getComputedStyle(dialog).animationName\n if (enter !== '' && enter !== 'none') element.style.setProperty(EXIT_NAME_VAR, enter)\n }, [closing])\n\n return (\n <Modal open={showing} onClose={onClose} title={t('title')} headless className={css.dialog}>\n <div\n ref={panel}\n id={id}\n className={css.panel}\n data-dsh-plugin={PLUGIN_ATTR}\n data-dsh-part={PART_PANEL}\n data-closing={closing || undefined}\n onAnimationEnd={(event) => {\n if (closing && event.target === event.currentTarget) onExited()\n }}\n onTransitionEnd={(event) => {\n if (closing && event.target === event.currentTarget && event.propertyName === 'opacity') onExited()\n }}\n >\n <header className={css.header}>\n <div className={css.heading}>\n <h2 className={css.title}>{t('title')}</h2>\n <p className={css.subtitle}>{t('subtitle')}</p>\n </div>\n <Button\n className={css.close}\n variant=\"ghost\"\n size=\"sm\"\n aria-label={t('action.close')}\n icon={<IconCloseOutlineRegular />}\n onClick={onClose}\n />\n </header>\n\n <div className={css.body}>\n {(state.kind === 'forbidden' || state.kind === 'failed' || state.kind === 'unreachable') && (\n <div className={css.notice} data-dsh-part={PART_NOTICE} data-tone=\"alert\" role=\"alert\">\n <span className={css.noticeIcon} aria-hidden=\"true\"><IconWarningOutlineRegular /></span>\n <div className={css.noticeCopy}>\n <p className={css.noticeTitle}>\n {state.kind === 'forbidden' && t('forbidden.title')}\n {state.kind === 'failed' && t('failed.title')}\n {state.kind === 'unreachable' && t('unreachable.title')}\n </p>\n <p className={css.noticeText}>\n {state.kind === 'forbidden' && t('forbidden.body')}\n {state.kind === 'failed' && t('failed.body', { status: String(state.status) })}\n {state.kind === 'unreachable' && t('unreachable.body')}\n </p>\n </div>\n </div>\n )}\n\n {(state.kind === 'reading' || ready) && (\n <>\n <div className={css.qrCard}>\n <div\n className={css.qrSlot}\n data-dsh-part={PART_QR}\n {...{ [QR_VALUE_ATTR]: payload }}\n {...{ [EXPIRED_ATTR]: expired || undefined }}\n >\n {ready ? (\n <PairQrCode value={payload} label={t('pair.qrLabel')} />\n ) : (\n <span className={css.skeleton} aria-hidden=\"true\" />\n )}\n </div>\n <div className={css.status}>\n {!ready && <p className={css.statusText}>{t('state.reading')}</p>}\n {ready && expired && <p className={css.statusText} role=\"status\">{t('pair.expired')}</p>}\n {ready && !expired && (\n <>\n <p className={css.statusText}>{t('pair.countdown', { s: String(seconds) })}</p>\n <span className={css.bar} aria-hidden=\"true\">\n <span className={css.barFill} style={{ width: `${String(percent)}%` }} />\n </span>\n </>\n )}\n </div>\n </div>\n\n <p className={css.address} data-tone={located ? 'plain' : 'warning'}>\n {ready && located && !onLan && t('origin.public')}\n {ready && onLan && t('origin.lan', { origin: state.origin ?? '' })}\n {ready && !located && t('origin.missing', { host })}\n </p>\n <p className={css.hint}>{t('pair.usedHint')}</p>\n </>\n )}\n\n {/* The one way out of a beta, offered in every state including a\n refusal: a reader who cannot pair is exactly the one with a\n question. It closes the body, so the last thing on the card is the\n way to ask rather than the code they already have. */}\n <a\n className={css.invite}\n href={COMMUNITY_INVITE_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {t('community.invite')}\n </a>\n </div>\n\n {/* The row exists only while it holds an action: a refusal offers\n nothing to press, and copy itself needs a code to hand out. An\n actionless row would still spend the panel's own gap. */}\n {state.kind !== 'forbidden' && (\n <footer className={css.actions}>\n {ready && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n data-dsh-part={PART_COPY}\n disabled={!canCopy}\n icon={copy === 'copied' ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}\n onClick={() => { onCopy(payload) }}\n >\n <span className={css.labels}>\n <span className={css.label} data-visible={copy === 'idle'} aria-hidden={copy !== 'idle'}>\n {t('action.copy')}\n </span>\n <span className={css.label} data-visible={copy === 'copied'} aria-hidden={copy !== 'copied'}>\n {t('action.copied')}\n </span>\n <span className={css.label} data-visible={copy === 'failed'} aria-hidden={copy !== 'failed'}>\n {t('action.copyFailed')}\n </span>\n </span>\n </Button>\n )}\n <Button\n variant=\"primary\"\n size=\"sm\"\n data-dsh-part={PART_REFRESH}\n disabled={state.kind === 'reading'}\n icon={<IconRefreshOutlineRegular />}\n onClick={onRefresh}\n >\n {primaryLabel}\n </Button>\n </footer>\n )}\n\n {/* Renaming the button under the pointer is not announced: a control's\n label is reported when focus lands on it, not when it changes. The\n outcome is said once from this region instead, and said as nothing\n while there is no outcome to report. */}\n <div className={css.announce} role=\"status\">\n {copy === 'copied' && t('action.copied')}\n {copy === 'failed' && t('action.copyFailed')}\n </div>\n </div>\n </Modal>\n )\n}\n","/**\n * The pairing seat's QR glyph. It is the one icon this package draws itself\n * (I4 exception, recorded here): the official icon set in\n * `@deepseek-ai/dsh-client-ui-primitives` ships no QR or scan metaphor, and a\n * text or emoji stand-in is not an icon (I1). Every other glyph this panel\n * needs — close, copy, check, refresh, warning — comes from that set.\n */\nimport type { SVGProps } from 'react'\n\n/** A QR-symbol glyph: three finder squares plus a payload dot. */\nexport function QrIcon(props: SVGProps<SVGSVGElement>) {\n return (\n <svg\n width={16}\n height={16}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n {...props}\n >\n <path d=\"M2.5 2.5h4v4h-4zM9.5 2.5h4v4h-4zM2.5 9.5h4v4h-4z\" />\n <path d=\"M9.5 9.5h1.6v1.6H9.5zM12.4 9.5h1.1M9.5 12.4v1.1M12 13.5h1.5v-1.5h-1.5z\" />\n </svg>\n )\n}\n","/**\n * Sidebar footer entry for the protocol v1 pairing panel: the icon-only trigger\n * beside the sidebar settings seat (wide row / rail circle) that opens the\n * panel. Registered into the official `sidebar.footer.action` list slot\n * (declared by ui-sidebar — the same seat dsh-remote-web-ui and dsh-update\n * share).\n *\n * This component owns the panel's presence and behavior: one read per open, one\n * clock tick while a live code is on screen, the mint-again action, the copy\n * action, and the leave leg that keeps the modal mounted until its exit reports\n * completion. The wire call and the clipboard are injected (see the plugin\n * entry), so the rendered tree carries no closure-factory bundle import and both\n * can be driven by a test without patching a module.\n */\nimport { useCallback, useEffect, useId, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'\nimport { PairPanel, type PairCopyState, type PairPanelState } from './PairPanel.tsx'\nimport type { PairTokenOutcome } from './pair-token.ts'\nimport { PART_ENTRY, PLUGIN_ATTR } from './semantic.ts'\nimport { QrIcon } from './icons.tsx'\nimport css from './panel.module.css'\n\n/** How long the transient \"copied\" / \"copy failed\" label stays up. */\nconst COPY_FEEDBACK_MS = 1_500\n/** The countdown's tick; one second is the resolution the panel shows. */\nconst TICK_MS = 1_000\n/**\n * Upper bound on the leave leg. The card reports its own animation end, and the\n * reduced-motion fade reports a transition end; this only ends the presence of a\n * browser that reports neither, just past var(--ds-transition-duration).\n */\nconst EXIT_TIMEOUT_MS = 260\n\n/**\n * The modal's presence. `closing` is a state of its own: the card stays mounted\n * for its reverse exit and unmounts only when that exit reports completion,\n * instead of disappearing on the same tick as the click.\n */\ntype Presence = 'closed' | 'open' | 'closing'\n\nexport type PairEntryProps = PropsLocale<'remote-bridge'> & {\n /** Whether the sidebar renders wide content (false = 56px rail). */\n wide: boolean\n /** Reads a fresh one-shot token from this package's own Host route. */\n read: () => Promise<PairTokenOutcome>\n /** Puts the token on the OS clipboard; false means the write was refused. */\n copy: (text: string) => Promise<boolean>\n}\n\n/** Map a read outcome onto the panel's view state. */\nfunction panelStateOf(outcome: PairTokenOutcome, issuedAt: number): PairPanelState {\n switch (outcome.kind) {\n case 'ok':\n return {\n kind: 'ready',\n token: outcome.token,\n issuedAt,\n expiresAt: outcome.expiresAt,\n origin: outcome.origin,\n originSource: outcome.originSource,\n pairingUrl: outcome.pairingUrl,\n }\n case 'forbidden': return { kind: 'forbidden' }\n case 'unreachable': return { kind: 'unreachable' }\n case 'failed': return { kind: 'failed', status: outcome.status }\n }\n}\n\n/**\n * Render the pairing seat trigger and, while it is open or leaving, the panel.\n * @param props - the footer seat's column state, the injected actions and the locale seat.\n * @returns the trigger and, when present, the official Modal holding the panel.\n */\nexport function PairEntry({ wide, read, copy, t }: PairEntryProps) {\n const [presence, setPresence] = useState<Presence>('closed')\n const [state, setState] = useState<PairPanelState>({ kind: 'reading' })\n const [copyState, setCopyState] = useState<PairCopyState>('idle')\n const [now, setNow] = useState<number>(() => Date.now())\n const panelId = useId()\n // Generation counter: closing (or minting again) invalidates a read that is\n // still in flight, so an answer that lands after the panel closed cannot\n // resurrect a code nobody asked for.\n const generation = useRef(0)\n\n const mint = useCallback((): void => {\n const request = ++generation.current\n setState({ kind: 'reading' })\n void read().then((outcome) => {\n if (request !== generation.current) return\n const issuedAt = Date.now()\n setNow(issuedAt)\n setState(panelStateOf(outcome, issuedAt))\n })\n }, [read])\n\n const openPanel = useCallback((): void => {\n setPresence('open')\n setCopyState('idle')\n mint()\n }, [mint])\n\n // Escape, the mask click, the focus trap and focus restoration belong to the\n // official Modal; this only decides what closing means for the presence, and\n // it invalidates a read that is still in flight.\n const requestClose = useCallback((): void => {\n generation.current += 1\n setPresence((current) => (current === 'closed' ? 'closed' : 'closing'))\n }, [])\n\n const finishClose = useCallback((): void => {\n setPresence((current) => (current === 'closing' ? 'closed' : current))\n }, [])\n\n const closing = presence === 'closing'\n const showing = presence !== 'closed'\n\n // Safety net for the leave leg: the card normally reports its own animation or\n // transition end, and this bound covers the case where neither arrives.\n useEffect(() => {\n if (!closing) return\n const timer = window.setTimeout(() => { finishClose() }, EXIT_TIMEOUT_MS)\n return () => { window.clearTimeout(timer) }\n }, [closing, finishClose])\n\n // One ticker per live code; it clears itself at the deadline, so a panel left\n // open on an expired code stops re-rendering instead of ticking forever.\n useEffect(() => {\n if (presence !== 'open' || state.kind !== 'ready') return\n const deadline = state.expiresAt\n const timer = window.setInterval(() => {\n const current = Date.now()\n setNow(current)\n if (current >= deadline) window.clearInterval(timer)\n }, TICK_MS)\n return () => { window.clearInterval(timer) }\n }, [presence, state])\n\n const handleCopy = useCallback((payload: string): void => {\n void copy(payload).then((ok) => {\n setCopyState(ok ? 'copied' : 'failed')\n window.setTimeout(() => { setCopyState('idle') }, COPY_FEEDBACK_MS)\n })\n }, [copy])\n\n return (\n <>\n <button\n type=\"button\"\n className={css.trigger}\n data-dsh-plugin={PLUGIN_ATTR}\n data-dsh-part={PART_ENTRY}\n data-wide={wide ? 'wide' : 'rail'}\n aria-label={t('entry.label')}\n aria-expanded={showing}\n aria-controls={showing ? panelId : undefined}\n title={t('entry.label')}\n onClick={openPanel}\n >\n <QrIcon />\n </button>\n {showing && (\n <PairPanel\n id={panelId}\n t={t}\n state={state}\n now={now}\n host={window.location.host}\n copy={copyState}\n showing={showing}\n closing={closing}\n onClose={requestClose}\n onExited={finishClose}\n onRefresh={mint}\n onCopy={handleCopy}\n />\n )}\n </>\n )\n}\n","/**\n * Official `settings.remoteConnection.extensions` extension card for protocol\n * v1 (iOS App) pairing.\n *\n * Renders beneath the official Remote Connection settings panel so operators\n * discover mobile-app pairing alongside official browser remote access, while\n * reusing the same loopback-only pair-token modal (`PairPanel`) and existing\n * localized copy.\n * @module @linxin666/dsh-remote-bridge/client/RemoteConnectionExtension\n */\nimport { useCallback, useEffect, useId, useRef, useState } from 'react'\nimport type {} from '@deepseek-ai/dsh-client-remote-connection/client'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'\nimport { Button } from '@deepseek-ai/dsh-client-ui-primitives/client'\nimport { PairPanel, type PairCopyState, type PairPanelState } from './PairPanel.tsx'\nimport type { PairTokenOutcome } from './pair-token.ts'\nimport { PLUGIN_ATTR } from './semantic.ts'\nimport { QrIcon } from './icons.tsx'\nimport css from './panel.module.css'\n\nconst COPY_FEEDBACK_MS = 1_500\nconst TICK_MS = 1_000\nconst EXIT_TIMEOUT_MS = 260\n\ntype Presence = 'closed' | 'open' | 'closing'\n\nexport type RemoteConnectionExtensionCardProps =\n & Partial<PropsRuntime<'settings.remoteConnection.extensions'>>\n & PropsLocale<'remote-bridge'>\n & {\n /** Reads a fresh one-shot token from this package's own Host route. */\n read: () => Promise<PairTokenOutcome>\n /** Puts the token on the OS clipboard; false means the write was refused. */\n copy: (text: string) => Promise<boolean>\n }\n\nfunction panelStateOf(outcome: PairTokenOutcome, issuedAt: number): PairPanelState {\n switch (outcome.kind) {\n case 'ok':\n return {\n kind: 'ready',\n token: outcome.token,\n issuedAt,\n expiresAt: outcome.expiresAt,\n origin: outcome.origin,\n originSource: outcome.originSource,\n pairingUrl: outcome.pairingUrl,\n }\n case 'forbidden': return { kind: 'forbidden' }\n case 'unreachable': return { kind: 'unreachable' }\n case 'failed': return { kind: 'failed', status: outcome.status }\n }\n}\n\n/**\n * Extension card registered into `settings.remoteConnection.extensions`.\n */\nexport function RemoteConnectionExtension({ read, copy, t }: RemoteConnectionExtensionCardProps) {\n const [presence, setPresence] = useState<Presence>('closed')\n const [state, setState] = useState<PairPanelState>({ kind: 'reading' })\n const [copyState, setCopyState] = useState<PairCopyState>('idle')\n const [now, setNow] = useState<number>(() => Date.now())\n const panelId = useId()\n const generation = useRef(0)\n\n const mint = useCallback((): void => {\n const request = ++generation.current\n setState({ kind: 'reading' })\n void read().then((outcome) => {\n if (request !== generation.current) return\n const issuedAt = Date.now()\n setNow(issuedAt)\n setState(panelStateOf(outcome, issuedAt))\n })\n }, [read])\n\n const openPanel = useCallback((): void => {\n setPresence('open')\n setCopyState('idle')\n mint()\n }, [mint])\n\n const requestClose = useCallback((): void => {\n generation.current += 1\n setPresence((current) => (current === 'closed' ? 'closed' : 'closing'))\n }, [])\n\n const finishClose = useCallback((): void => {\n setPresence((current) => (current === 'closing' ? 'closed' : current))\n }, [])\n\n const closing = presence === 'closing'\n const showing = presence !== 'closed'\n\n useEffect(() => {\n if (!closing) return\n const timer = window.setTimeout(() => { finishClose() }, EXIT_TIMEOUT_MS)\n return () => { window.clearTimeout(timer) }\n }, [closing, finishClose])\n\n useEffect(() => {\n if (presence !== 'open' || state.kind !== 'ready') return\n const deadline = state.expiresAt\n const timer = window.setInterval(() => {\n const current = Date.now()\n setNow(current)\n if (current >= deadline) window.clearInterval(timer)\n }, TICK_MS)\n return () => { window.clearInterval(timer) }\n }, [presence, state])\n\n const handleCopy = useCallback((payload: string): void => {\n void copy(payload).then((ok) => {\n setCopyState(ok ? 'copied' : 'failed')\n window.setTimeout(() => { setCopyState('idle') }, COPY_FEEDBACK_MS)\n })\n }, [copy])\n\n return (\n <section\n className={css.extensionCard}\n data-dsh-plugin={PLUGIN_ATTR}\n data-dsh-part=\"remote-connection-extension\"\n >\n <div className={css.extensionBody}>\n <div className={css.extensionHeader}>\n <span className={css.extensionIcon} aria-hidden=\"true\"><QrIcon /></span>\n <h4 className={css.extensionTitle}>{t('title')}</h4>\n </div>\n <p className={css.extensionSubtitle}>{t('subtitle')}</p>\n </div>\n <div className={css.extensionActions}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n aria-expanded={showing}\n aria-controls={showing ? panelId : undefined}\n onClick={openPanel}\n >\n {t('entry.label')}\n </Button>\n </div>\n {showing && (\n <PairPanel\n id={panelId}\n t={t}\n state={state}\n now={now}\n host={window.location.host}\n copy={copyState}\n showing={showing}\n closing={closing}\n onClose={requestClose}\n onExited={finishClose}\n onRefresh={mint}\n onCopy={handleCopy}\n />\n )}\n </section>\n )\n}\n","/**\n * The frozen protocol surface: method names, topic names, refusal codes, and\n * the one authorization rule the dispatcher enforces before any method runs.\n * @module dsh-remote-bridge/core/protocol\n */\n\n/** Client-callable methods of protocol v1. */\nexport const METHOD_HELLO = 'hello'\nexport const METHOD_SESSION_LIST = 'session.list'\nexport const METHOD_SESSION_TITLES = 'session.titles'\nexport const METHOD_SESSION_SNAPSHOT = 'session.snapshot'\nexport const METHOD_SESSION_HISTORY = 'session.history'\nexport const METHOD_SESSION_HISTORY_DEEP = 'session.history.deep'\nexport const METHOD_SESSION_PROMPT = 'session.prompt'\nexport const METHOD_SESSION_INTERRUPT = 'session.interrupt'\nexport const METHOD_SESSION_ATTACHMENT = 'session.attachment'\nexport const METHOD_SESSION_ATTACHMENT_PATH = 'session.attachment.path'\nexport const METHOD_SESSION_PERMISSIONS = 'session.permissions'\nexport const METHOD_SESSION_SET_PERMISSION = 'session.setPermission'\nexport const METHOD_SESSION_MODELS = 'session.models'\nexport const METHOD_SESSION_SET_MODEL = 'session.setModel'\n/** Remember one model's reasoning level, without switching the session's model. */\nexport const METHOD_SESSION_SET_EFFORT = 'session.setEffort'\nexport const METHOD_SESSION_CREATE = 'session.create'\nexport const METHOD_SESSION_FORK = 'session.fork'\nexport const METHOD_SESSION_COMMANDS = 'session.commands'\nexport const METHOD_SESSION_COMMAND = 'session.command'\nexport const METHOD_SESSION_RENAME = 'session.rename'\nexport const METHOD_SESSION_PIN = 'session.pin'\nexport const METHOD_SESSION_UNPIN = 'session.unpin'\nexport const METHOD_SESSION_ARCHIVE = 'session.archive'\nexport const METHOD_SESSION_UNARCHIVE = 'session.unarchive'\nexport const METHOD_WORKSPACE_LIST = 'workspace.list'\nexport const METHOD_PRESETS_LIST = 'presets.list'\nexport const METHOD_PAIR_BEGIN = 'pair.begin'\nexport const METHOD_PAIR_FINISH = 'pair.finish'\nexport const METHOD_APPROVAL_RESOLVE = 'approval.resolve'\nexport const METHOD_QUESTION_ANSWER = 'question.answer'\nexport const METHOD_QUESTION_LIST = 'question.list'\nexport const METHOD_JOBS_LIST = 'jobs.list'\nexport const METHOD_SQUADS_STATE = 'squads.state'\nexport const METHOD_SQUADS_LIST = 'squads.list'\nexport const METHOD_SQUADS_RUNS = 'squads.runs'\nexport const METHOD_SQUADS_RUN_MEMBER = 'squads.runMember'\nexport const METHOD_SQUADS_RUN_SQUAD = 'squads.runSquad'\nexport const METHOD_PUSH_REGISTER = 'push.register'\nexport const METHOD_USAGE_SESSION = 'usage.session'\nexport const METHOD_USAGE_BALANCE = 'usage.balance'\nexport const METHOD_USAGE_STATS = 'usage.stats'\n// 协议 §35 追加的两个方法:一条卡上的动作回来,以及一张全局卡表的对账读。\nexport const METHOD_UI_EVENT = 'ui.event'\nexport const METHOD_UI_LIST = 'ui.list'\n/**\n * 一条配对连接把手机从账号服务换到的中继授权交给宿主。\n *\n * 它是这条通道唯一的写动作:授权落进那台设备自己的名册行,随后宿主拿它去第二\n * 会合点申领租约。宿主不认识账号——它只会看到「准了」或「不准」,绝不会从这一帧\n * 里读出用户是谁。只在配了第二会合点的宿主上是这个方法(见 {@link CAP_RELAY_TIER})。\n */\nexport const METHOD_RELAY_GRANT = 'relay.grant'\n\n/** Server-pushed topics of protocol v1. */\nexport const TOPIC_SESSION_DELTA = 'session.delta'\nexport const TOPIC_APPROVAL_REQUEST = 'approval.request'\nexport const TOPIC_QUESTION_REQUEST = 'question.request'\nexport const TOPIC_JOBS_CHANGED = 'jobs.changed'\n// §35.2 追加的主题:一块整页自包含文档,以及它自己的结算通知。\nexport const TOPIC_UI_REQUEST = 'ui.request'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to ask for a trimmed\n * `session.snapshot` baseline. A client that does not declare it — including\n * every client written before this capability existed — is served exactly the\n * baseline protocol v1 always served.\n */\nexport const CAP_SESSION_SNAPSHOT_TRIM = 'session.snapshot.trim.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to have\n * `session.snapshot` answer with one bounded page instead of the whole opening\n * window. Declaring it is what makes an opening screen cost one page rather\n * than a whole session; a client that does not declare it — including every\n * client written before this capability existed — receives byte for byte the\n * snapshot protocol v1 always served.\n */\nexport const CAP_SESSION_SNAPSHOT_PAGE = 'session.snapshot.page.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to have\n * `session.snapshot` answer a reconnect with only what it missed.\n *\n * The declaration and the request's `sinceSeq` are what it takes together: a\n * snapshot that carries no `sinceSeq` is answered, byte for byte, the body\n * protocol v1 always served, whether or not the client declared this. Behind\n * both, the client names the durable `lastSeq` of a snapshot it already holds\n * and the answer is either that same reply in an incremental form —\n * `{turns, lastSeq, mode:\"since\", reset:false}` carrying only the entries above\n * that watermark — or a full baseline with `mode:\"full\"` and `reset:true`,\n * which is the one answer that tells a client to throw its copy away. The\n * estimate is only served when the bridge can PROVE nothing was lost: the\n * current follow window's oldest entry must sit at or below `sinceSeq + 1`, so a\n * window that has already scrolled past the watermark answers the baseline\n * instead of a delta with a hole in it. It exists because a reconnect on the\n * phone re-paid 0.86-1.06 s of baseline five times in one measured run.\n */\nexport const CAP_SESSION_SNAPSHOT_SINCE = 'session.snapshot.since.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be shown the\n * host's pending user questions and to answer them with `question.answer`.\n *\n * Declaring it is what makes `question.request` reachable and what makes the\n * method part of that client's protocol at all: a client that does not declare\n * it — including every client written before this channel existed — receives no\n * such event, and its `question.answer` is refused as an unknown method,\n * exactly as that frame was refused before.\n */\nexport const CAP_QUESTIONS = 'questions.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to learn that this\n * bridge can list the user questions it is still holding.\n *\n * An announcement rather than a switch, the same shape as\n * {@link CAP_SESSION_DEEP_HISTORY}: `question.list` is reachable from every\n * client that declared {@link CAP_QUESTIONS}, exactly as `question.answer` is,\n * so a client written before this name existed loses nothing by declaring it\n * and nothing by never calling the method. What the name buys is a way to tell\n * a bridge that serves the method from one that does not: a host built before\n * it answers `unknown-method`, so a client that does not find this name in\n * `hello`'s `capabilities` keeps the retirement rule it had — a card is over\n * when `question.request` says `settled` — instead of reaping cards on an\n * answer it cannot trust.\n */\nexport const CAP_QUESTION_LIST = 'questions.list.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be handed the\n * approval questions this bridge is already holding for it.\n *\n * Unlike every channel capability beside it, this one gates a second delivery\n * rather than the channel: `approval.request` still reaches every paired\n * connection the moment a tool asks, exactly as it did before this name\n * existed, because gating the first broadcast would take approvals away from\n * every client written before the capability. What the declaration buys is the\n * replay — after a reconnect, or on a session screen opened late, the client is\n * handed the questions that are still waiting instead of a card it never saw.\n * Only a live claim is replayed: a question that was answered, that the bridge\n * timed out, or that was withdrawn with the last phone is gone from the claim\n * registry before the replay reads it.\n *\n * It is deliberately absent from {@link SERVED_CAPABILITIES}: that list is what\n * `hello` advertises as served, advertising a capability is a minor-version\n * addition (see {@link MINOR}), and this channel changes nothing a client can\n * observe in the handshake — no answer, no field and no method behind it. The\n * declaration is the whole switch, and the name reaches a client through this\n * bridge's own protocol documentation.\n */\nexport const CAP_APPROVALS = 'approvals.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told where a\n * message came from and that an agent spawned a child session.\n *\n * Declaring it is what makes the `subagent` delta part of that client's\n * protocol: a client that does not declare it — including every client written\n * before this channel existed — receives no such event, exactly as that frame\n * was dropped before. The `actor` of a `user-message` is not gated: it is an\n * additive field a client that does not read it ignores.\n */\nexport const CAP_SUBAGENT_THREAD = 'subagent.thread.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to see the host's\n * background jobs and to be told when the set changes.\n *\n * Declaring it is what makes `jobs.list` reachable, and `jobs.list` is the only\n * thing that opens a roster: a connection that declares this capability but\n * never asks for a scope receives no `jobs.changed` at all. A client that does\n * not declare it — including every client written before this channel existed —\n * receives no such event, and its `jobs.list` is refused as an unknown method,\n * exactly as that frame was refused before.\n */\nexport const CAP_JOBS = 'jobs.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * Agent presets and to instantiate one as a session.\n *\n * Declaring it is what makes `presets.list` and `session.create` part of that\n * client's protocol at all: a client that does not declare it — including every\n * client written before this channel existed — is refused both as unknown\n * methods, exactly as those frames were refused before. Neither method is\n * called on a connection's behalf either, so a client that never asks sends the\n * host no request.\n */\nexport const CAP_AGENTS = 'agents.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * agent squads and to drive them.\n *\n * Declaring it is what makes `squads.state`, `squads.list`, `squads.runs`,\n * `squads.runMember` and `squads.runSquad` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused each as an unknown method, exactly as those\n * frames were refused before. No command is called on a connection's behalf\n * either, so a client that never asks sends the host no request.\n *\n * The channel is additive beside {@link CAP_AGENTS} rather than a replacement:\n * a phone that predates the squad model keeps the preset roster and session\n * creation it was written against, and a phone that reads this name reads the\n * squad domain instead of deriving agents from anything else.\n */\nexport const CAP_SQUADS = 'squads.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to register the APNs\n * token this device wants to be notified on.\n *\n * Declaring it is what makes `push.register` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused that frame as an unknown method, and no\n * device row is written on its behalf.\n *\n * The name announces that this bridge can REMEMBER a token, not that it will\n * send anything. Whether a notification ever leaves the process is a deployment\n * fact (is an APNs signing key configured?) that the wire deliberately cannot\n * express: a bridge with no key answers `ok:true` exactly like one with a key,\n * because a client has no second code path to keep for the difference. Every\n * notification this channel produces is an outbound APNs request and nothing\n * else — no topic, no frame and no state is added to `/ios/v1` (see the\n * protocol's §28).\n */\nexport const CAP_PUSH = 'push.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要读本桥自己的用量读数。\n *\n * 宣告它是 `usage.session` 与 `usage.balance` 进入这个客户端协议的唯一前提:\n * 不宣告的客户端——包括这个通道出现之前写下的每一个客户端——收到的是与从前\n * 逐字一样的 `unknown-method`,本桥也不会替它读一条会话、更不会替它打一次\n * 上游余额端点。\n *\n * 一个能力名带两个方法,因为它们读的是同一件事的两面:一条会话下一次请求由\n * 什么组成(上下文窗口取宿主自己广播的值,组成由本桥按文本长度估算并恒标\n * `estimated: true`),以及某条 provider 路由背后账户的余额(DeepSeek 官方\n * 口径,只在路由确实指向 `api.deepseek.com` 且凭据拿得到时才查官方端点,宿主\n * 侧同一 provider + 凭据 60 秒最多一次上游请求)。\n */\nexport const CAP_USAGE = 'usage.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要读宿主自己的用量台账聚合。\n *\n * 与 {@link CAP_USAGE} 平级、独立声明:宣告它是 `usage.stats` 进入这个客户端\n * 协议的唯一前提,不宣告的客户端——包括 `usage.v1` 出现之后、这个能力出现之前\n * 写下的每一个客户端——收到的仍是 `unknown-method`,本桥也不会替它去读宿主\n * 上 `dsh-usage` 插件的任何一条路由。\n *\n * 拆成独立能力而不是塞进 `usage.v1`,是因为它读的是另一件事:那两半读的是本\n * 进程自己的事实(一个会话、一条路由的账户),这一半读的是另一个插件挂在这个\n * 宿主上的 HTTP 路由,而那个插件可能根本没装。老客户端忽略这个未知名字即可,\n * 它看到的能力表里多一项、别的什么都没有变。\n */\nexport const CAP_USAGE_STATS = 'usage.stats.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要渲染整页卡并回答它(协议 §35)。\n *\n * 宣告它是 `ui.request` 与 `ui.event` 进入这个客户端协议的唯一前提:不宣告的\n * 客户端——包括这个通道出现之前写下的每一个客户端——收不到任何一帧整页卡,它的\n * `ui.event` 回 `unknown-method`,其余逐字节不变。它是**公告不是协商**(§13.1、\n * §24.1 同一判据):宿主公告同名项、客户端声明,双向缺一即当作这个能力不存在,\n * 且不得把「宿主没这个能力」渲染成「这张卡不存在」或任何错误态。\n *\n * 宿主半区只有真实现了 `ui_present` 这一半的桥才把自己列进\n * {@link SERVED_CAPABILITIES},所以一个客户端读到这个名字,就能断定 `ui.request`\n * 会出现、`ui.event` 会被接受。\n */\nexport const CAP_UI = 'ui.v1'\n\n/**\n * 客户端在 `hello` 的 `cap` 数组里宣告它要按 §24.3 的四条件对账自己手上的整页卡\n * (协议 §35.4)。\n *\n * 与 {@link CAP_QUESTION_LIST} 同一形状:`ui.list` 本身是只读的、对每条配对连接\n * 都开放,这个名字买到的是「这条连接会不会被答」之外的另一种确定性——一条老桥\n * 回 `unknown-method`,于是没有这个名字的客户端就保留它原有的退休规则(卡片只在\n * `ui.request` 说 `settled` 时结束),而不是按一次它信不过的应答清卡。\n */\nexport const CAP_UI_LIST = 'ui.list.v1'\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that this\n * bridge can hand it the bytes of an image a session already offloaded.\n *\n * An announcement and nothing more, the same shape as\n * {@link CAP_SESSION_DEEP_HISTORY}: `session.attachment.path` is open to every\n * paired connection, because it is a pure read of one session's own durable\n * transcript that costs no other client anything. Declaring the capability is how\n * a client learns the method exists, and a client that does not declare it loses\n * only that knowledge — it never sees a frame from this channel, because it never\n * asks for one.\n */\nexport const CAP_SESSION_ATTACHMENT_PATH = 'session.attachment.path.v1'\n\n/**\n * 宿主配了第二会合点时,在 `hello` 的 `capabilities` 里公告的能力名。\n *\n * 它是这条通道的全部门槛,而且门槛落在宿主这一侧:一个配了第二会合点的宿主才\n * 公告这个名字、才收 {@link METHOD_RELAY_GRANT},客户端读到它之后才把授权发过来。\n * 不配第二会合点的宿主——也就是缺省配置的每一台——公告表里没有这个名字,\n * `relay.grant` 对它仍是 `unknown-method`,名册里也不会因此多出一个块:缺省\n * 宿主的握手与名册与这条通道出现之前逐字相同。\n *\n * 正因为它是**条件**公告,{@link MINOR} 不随它抬格:minor 描述的是这个协议本身,\n * 而缺省宿主在线路上读不到任何新东西(设计冻结在 21)。客户端因此按名字判断而不是\n * 按 minor 判断:读不到这个名字就什么都不发。\n */\nexport const CAP_RELAY_TIER = 'relay.tier.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be answered with\n * byte-level increments instead of the whole roster or the whole board.\n *\n * Behind it, `session.list` and `board.snapshot` (the latter through the board\n * plugin, §15) accept an opaque `since` token and answer either the whole set\n * (`mode:\"reset\"`) or only what changed since the set that token names. A\n * client that does not declare it — including every client written before this\n * channel existed — is answered today's body plus the ignorable `mode` and\n * `token` keys, with `mode` always `\"reset\"`.\n */\nexport const CAP_DELTA = 'delta.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that an\n * archived session is not in the roster at all.\n *\n * Unlike every capability beside it this one negotiates nothing: the bridge\n * never transfers an archived session, whether or not a client declares it, so\n * an older client simply receives the shorter roster it would have hidden\n * anyway. The name is an announcement of that fact, so a client can stop\n * filtering for itself: behind it, no `session.list` row is a session the\n * host's archive set names, a row that does survive still carries\n * `archived: false` under the same schema, and a live child of an archived\n * parent still crosses with its `parentSessionId` — the parent id, not the\n * parent row.\n */\nexport const CAP_ROSTER_OMITS_ARCHIVED = 'session.list.omit-archived.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be answered a\n * compact roster it can page.\n *\n * The declaration alone changes nothing: a listing that carries none of the\n * compact parameters (`cwd`, `maxRows`, `after`) is answered exactly the body\n * protocol v1 always served, so a client can opt into the name before it\n * relies on any of it. Behind the parameters, a row drops its absolute `cwd`\n * unless the request asks for it, drops its `updatedAt` when this connection\n * already sent that id the same value, and a `maxRows`/`after` pair cuts the\n * roster into pages ordered most recent first. The roster is the most repeated\n * large reply on the link, so this is what lets a reconnect pay for the newest\n * screenful plus a cursor instead of the whole list again.\n */\nexport const CAP_ROSTER_COMPACT = 'session.list.compact.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be told that this\n * bridge can page a session's durable history down to its oldest entry.\n *\n * The capability is an announcement and nothing more. `session.history.deep` is\n * open to every paired connection, exactly as `session.history` is, because it\n * is a pure read of the session store that costs no other client anything;\n * declaring the capability is how a client learns the method exists, and a\n * client that does not declare it loses only that knowledge.\n */\nexport const CAP_SESSION_DEEP_HISTORY = 'session.deep-history.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to fork a session.\n *\n * Declaring it is what makes `session.fork` part of that client's protocol at\n * all: a client that does not declare it — including every client written\n * before this channel existed — is refused `unknown-method`, and no fork is\n * asked of the host on its behalf. Behind the name the bridge forwards one\n * `SessionForkRequest` to the host's `session/fork` and hands back the host's\n * own `SessionForkValue`, so what a fork point means stays the host's: an\n * `atSeq` is the source event seq the fork includes, an omitted one is the\n * newest finished turn, and a cut the host opens itself is closed by the host's\n * own synthetic finishing event. Nothing about a fork is modelled or\n * re-derived here.\n */\nexport const CAP_SESSION_FORK = 'session.fork.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to list a session's\n * slash commands and skills and to run one of them.\n *\n * Declaring it is what makes `session.commands` and `session.command` part of\n * that client's protocol at all: a client that does not declare it — including\n * every client written before this channel existed — is refused both as unknown\n * methods, exactly as those frames were refused before. Neither method is called\n * on a connection's behalf either, so a client that never asks costs the host no\n * registry read and no skill catalog read.\n *\n * The channel holds no events and no cache: a directory is read live on every\n * call, so a command a plugin registered a moment ago and a skill withdrawn from\n * one Agent preset are both reflected in the answer that follows.\n */\nexport const CAP_COMMANDS = 'commands.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to read the host's\n * workspaces and its two registry-global session sets.\n *\n * Declaring it is what makes `workspace.list` part of that client's protocol at\n * all: a client that does not declare it — including every client written before\n * this channel existed — is refused that frame as an unknown method, and no\n * registry is read on its behalf. Behind the name the answer is the host's own\n * synchronous projection: one row per registered workspace in registry order,\n * plus the complete archive and pin sets.\n *\n * The method is a read and nothing is cached, so a pin or an archive followed by\n * another list reads the set the write left behind. That pair of calls is the\n * whole refresh story of the session-admin channel: see {@link CAP_SESSION_ADMIN}.\n */\nexport const CAP_WORKSPACE = 'workspace.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to rename, pin,\n * unpin, archive and unarchive a session.\n *\n * Declaring it is what makes those five methods part of that client's protocol\n * at all: a client that does not declare it — including every client written\n * before this channel existed — is refused each as an unknown method, and no\n * write is asked of the host on its behalf.\n *\n * Every one of the five is forwarded one-to-one to the endpoint that already\n * owns the semantics, so nothing about a title, a pin or an archive is modelled\n * or re-derived here: a rename reaches `session/rename` — the endpoint that\n * restores a cold session before it writes, which is why a client needs no\n * resume path of its own — and the four set mutations reach\n * `workspace/pinSession`, `workspace/unpinSession`, `workspace/archiveSession`\n * and `workspace/unarchiveSession`. A host refusal crosses with its own code\n * and text, `workspace/session-active` included.\n *\n * The channel publishes no event, because the host announces none of these\n * writes as a cordis event a connection could fold into a delta: a rename\n * appends one `session/title` log record and nothing else. A client re-reads\n * after a write instead — the pin set through {@link CAP_WORKSPACE}, the roster\n * through `session.list` — which is why one branch serves both capabilities.\n */\nexport const CAP_SESSION_ADMIN = 'session.admin.v1'\n\n/**\n * Capability a client declares in `hello`'s `cap` array to be sent frames\n * compressed instead of as plain text.\n *\n * Declaring it is what allows the host to compress at all: a frame whose JSON\n * text is at least 1024 UTF-8 bytes crosses as one WebSocket binary frame\n * carrying raw DEFLATE (RFC 1951) of exactly that text, and a frame that does\n * not get smaller still crosses as the text frame it always was. A client that\n * does not declare it — including every client written before this capability\n * existed — receives byte for byte the text frames protocol v1 always wrote.\n *\n * The direction is one way: a client still sends text frames only, and the\n * 10 MiB frame cap stays measured on the text, before inflation.\n */\nexport const CAP_FRAME_DEFLATE = 'frame.deflate.v1'\n\n/**\n * Methods an unpaired connection may still call: the handshake itself and the\n * two pairing steps. Everything else answers `unpaired` — a caller can pair\n * without a device token, but cannot touch a session without one.\n */\nexport const UNPAIRED_METHODS: ReadonlySet<string> = new Set([\n METHOD_HELLO,\n METHOD_PAIR_BEGIN,\n METHOD_PAIR_FINISH,\n])\n\n/** Every method this protocol version serves. */\nexport const KNOWN_METHODS: ReadonlySet<string> = new Set([\n METHOD_HELLO,\n METHOD_SESSION_LIST,\n METHOD_SESSION_TITLES,\n METHOD_SESSION_SNAPSHOT,\n METHOD_SESSION_HISTORY,\n METHOD_SESSION_HISTORY_DEEP,\n METHOD_SESSION_PROMPT,\n METHOD_SESSION_INTERRUPT,\n METHOD_SESSION_ATTACHMENT,\n METHOD_SESSION_ATTACHMENT_PATH,\n METHOD_SESSION_PERMISSIONS,\n METHOD_SESSION_SET_PERMISSION,\n METHOD_SESSION_MODELS,\n METHOD_SESSION_SET_MODEL,\n METHOD_SESSION_SET_EFFORT,\n METHOD_PAIR_BEGIN,\n METHOD_PAIR_FINISH,\n METHOD_APPROVAL_RESOLVE,\n METHOD_QUESTION_ANSWER,\n METHOD_QUESTION_LIST,\n METHOD_JOBS_LIST,\n METHOD_PRESETS_LIST,\n METHOD_SESSION_CREATE,\n METHOD_SESSION_FORK,\n METHOD_SESSION_COMMANDS,\n METHOD_SESSION_COMMAND,\n METHOD_SESSION_RENAME,\n METHOD_SESSION_PIN,\n METHOD_SESSION_UNPIN,\n METHOD_SESSION_ARCHIVE,\n METHOD_SESSION_UNARCHIVE,\n METHOD_WORKSPACE_LIST,\n METHOD_SQUADS_STATE,\n METHOD_SQUADS_LIST,\n METHOD_SQUADS_RUNS,\n METHOD_SQUADS_RUN_MEMBER,\n METHOD_SQUADS_RUN_SQUAD,\n METHOD_PUSH_REGISTER,\n METHOD_USAGE_SESSION,\n METHOD_USAGE_BALANCE,\n METHOD_USAGE_STATS,\n METHOD_UI_EVENT,\n METHOD_UI_LIST,\n METHOD_RELAY_GRANT,\n])\n\n/** Refusal codes the bridge itself raises (DSH failures cross as their own code). */\nexport const CODE_UNPAIRED = 'unpaired'\nexport const CODE_UNKNOWN_METHOD = 'unknown-method'\nexport const CODE_INVALID_ARGS = 'invalid-args'\n/**\n * `usage.session` 点名的会话在这个宿主上不存在:宿主自己的会话名册里没有它,\n * 活会话存储里没有它,本进程也从未观察过它的任何事件。它与「会话存在但两项\n * 读数都取不到」是两个答案,后者回的是空对象——一条刚刚开始、还什么都没广播\n * 的会话,以及一条在桥重载前就存在的会话,都在那个状态里:存在而没读数,不是\n * 不存在。\n */\nexport const CODE_UNKNOWN_SESSION = 'unknown-session'\nexport const CODE_PROTO_UNSUPPORTED = 'proto-unsupported'\nexport const CODE_TOKEN_INVALID = 'token-invalid'\nexport const CODE_NONCE_INVALID = 'nonce-invalid'\nexport const CODE_SIGNATURE_INVALID = 'signature-invalid'\nexport const CODE_APPROVAL_UNKNOWN = 'approval-unknown'\n/**\n * The bridge does not hold the named question: it never claimed that call id, it\n * already answered it, or the host no longer holds it as answerable. Host\n * failures crossing this method keep their own codes instead.\n */\nexport const CODE_QUESTION_UNKNOWN = 'question-unknown'\n/**\n * The bridge could not read the questions it is holding, so it cannot say which\n * ones are still live. The answer is deliberately not an empty list: a client\n * retires every card a COMPLETE list does not carry, and a read that failed is\n * not a complete one — it is a bridge that cannot answer this question today.\n */\nexport const CODE_QUESTION_LIST_UNAVAILABLE = 'question-list-unavailable'\n/**\n * 本桥不认领这个 `callId`:它从没呈现过这张卡,或者这张卡已被别处结算(宽限窗口\n * 到期、回合被取消、桥卸载)。客户端码表保持开放:除本码之外的未知码不得被读成\n * 「卡已消失」(§11.3 同一句)。\n */\nexport const CODE_UI_UNKNOWN = 'ui-unknown'\n/**\n * 这张卡已经被用户自己的第一条动作结算过(§35.3)。它与 {@link CODE_UI_UNKNOWN}\n * 是两个答案:重复的一次点击是「已经做完了」,不是「这张卡不存在」。\n */\nexport const CODE_UI_SETTLED = 'ui-settled'\n/**\n * 本桥读不出自己持有的卡,所以它说不了哪些还活着。答案故意不是一张空表:客户端\n * 只会按 COMPLETE 的列表退休卡片,一次失败的读不是一张完整的空表,而是这台桥今天\n * 答不了这一问(与 {@link CODE_QUESTION_LIST_UNAVAILABLE} 同一句)。\n */\nexport const CODE_UI_LIST_UNAVAILABLE = 'ui-list-unavailable'\n/**\n * The named session is a delegated child whose durable parent is not a session\n * this connection may read. The bridge follows an addressable child and refuses\n * an unaddressable one, rather than reading it blind.\n */\nexport const CODE_SESSION_NOT_FOLLOWABLE = 'session-not-followable'\n/**\n * 该路径不在这次会话自己的持久 transcript 里:白名单只有两处来源,客户端自选的路径\n * 一律不在其中。该名字本身是个链接时也回这一码——它已被换成指向别处的一层门面,就\n * 不再是这次会话点过的那个文件。判据看的是条目自身(`lstat`),不比较 `realpath()`\n * 的解析结果:同一个文件的两种写法(Windows 8.3 短名、macOS `/var` 前缀)不等于换目标。\n */\nexport const CODE_PATH_NOT_IN_SESSION = 'path-not-in-session'\n/**\n * 白名单里有这个路径,但它已经不是一个常规文件:文件被删了,或被换成了目录、设备或\n * fifo。它与 {@link CODE_PATH_NOT_IN_SESSION} 是两个答案——「这次会话没点过它」与\n * 「点过的那个文件不在了」。\n */\nexport const CODE_ATTACHMENT_NOT_FOUND = 'not-found'\n/**\n * 文件确实在,但它的文件头魔数不是 png/jpeg/webp/gif 四种之一。扩展名不作数:`.png`\n * 里装的不是 PNG 就回这一码,而一个叫 `.txt` 的 PNG 照常服务。\n */\nexport const CODE_NOT_AN_IMAGE = 'not-an-image'\nexport const CODE_SNAPSHOT_UNAVAILABLE = 'snapshot-unavailable'\n/**\n * This host composes no job registry, so it has no background jobs to publish.\n * The capability stays advertised — it is a fact about this bridge, not about\n * what a particular host mounts — and only a call that needs the registry fails.\n */\nexport const CODE_JOBS_UNAVAILABLE = 'jobs-unavailable'\n/**\n * This host serves no endpoint behind the command channel: no `commands/list`,\n * no `commands/execute` or no `skills/list`, which the gateway itself reports\n * as an endpoint nothing exports. The capability stays advertised — it is a fact\n * about this bridge, not about what a particular host mounts — and only a call\n * that needs those endpoints fails.\n */\nexport const CODE_COMMANDS_UNAVAILABLE = 'commands-unavailable'\n/**\n * This host serves no squad domain this bridge can reach: no answer to the\n * plugin's state route over loopback, no readable ledger beside it, or a body\n * this build cannot read as one squad domain. The capability stays advertised —\n * it is a fact about this bridge, not about what a particular host mounts — and\n * only a call that needs the domain fails. A refusal the `dsh-agents` plugin\n * itself raised crosses with the plugin's own code instead (`team-not-found`,\n * `member-not-found`, `preset-unknown`, `workspace-unavailable` and their\n * neighbours).\n */\nexport const CODE_SQUADS_UNAVAILABLE = 'squads-unavailable'\n/**\n * The definitions are readable but the two run commands cannot be served: this\n * host answered no run route over loopback, and the read-only ledger fallback\n * cannot launch anything. Failing closed is the point — a client is told the\n * capability is not served here rather than shown a run that never started.\n */\nexport const CODE_SQUADS_RUN_UNAVAILABLE = 'squads-run-unavailable'\nexport const CODE_SNAPSHOT_TOO_LARGE = 'snapshot-too-large'\nexport const CODE_INTERNAL = 'internal'\n\n/** Protocol version this package speaks. */\nexport const PROTO = 1\n/**\n * Minor version this package speaks.\n *\n * 22 当按路径取图落地(与协议 §18 的 `session.history.deep` 同例的一条读通道):\n * 新增 {@link CAP_SESSION_ATTACHMENT_PATH} 一个能力名与\n * {@link METHOD_SESSION_ATTACHMENT_PATH} 一个方法,客户端因此从线路上读到一种新的\n * 应答体,所以 minor 抬一格。这个方法对每一条已配对连接都开放,能力名只公告:它决定\n * 的是客户端要不要露出取图能力,不决定桥放不放行,理由与 {@link CAP_SESSION_DEEP_HISTORY}\n * 逐字相同。`proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状;不声明这个\n * 名字的客户端一帧都不发,两边互不知情时线路逐字节不变。\n * 21 当可交互回复(协议 §35)落地:新增 {@link CAP_UI} 与 {@link CAP_UI_LIST}\n * 两个能力名、{@link TOPIC_UI_REQUEST} 一个主题、{@link METHOD_UI_EVENT} 与\n * {@link METHOD_UI_LIST} 两个方法,宿主半区还多一个模型工具 `ui_present`。客户端\n * 因此从线路上读到两项新能力名、一种新主题与两种新应答体,所以 minor 抬一格;\n * `proto` 仍为 1,没有任何既有帧、既有方法或既有键改形状。工具结果是**新增**的:\n * 老会话、老 prompt、老回合都不受影响,工具名进入宿主工具表之后只有新回合才可能\n * 被调用。\n * 20 when the usage stats channel shipped: behind {@link CAP_USAGE_STATS} a\n * client may call {@link METHOD_USAGE_STATS} and read the host's own usage\n * ledger — today, this month and one row per local day — and behind the same\n * {@link CAP_USAGE} this bridge now also answers `usage.session` with a\n * `modelContextWindow` when the model catalog of the session's route declares\n * one, so a client reads one new reply body and one new optional key off the\n * wire and has to read the name before it asks. The stats half is independent\n * of {@link CAP_USAGE} on purpose: it reads another plugin's HTTP routes, which\n * a host may not mount at all, so a client written before this name existed\n * keeps the two readings it had and the bridge reads no route on its behalf.\n * No frame, no topic, no existing method and no existing key changes shape.\n * 19 when the usage channel shipped: behind {@link CAP_USAGE} a client may call\n * {@link METHOD_USAGE_SESSION} and read one session's context window and its\n * request's estimated composition, and {@link METHOD_USAGE_BALANCE} and read the\n * account behind one provider route, so it reads two new reply bodies off the\n * wire and has to read the name before it asks — a bridge below this one answers\n * `unknown-method` for both. No frame, no topic and no existing method changes\n * shape.\n * 18 when one card learned to lay out several sessions (§30 of\n * `docs/protocol-v1.md` in the iphone_remote_use_dsh repository): `content-state`\n * gains the optional `rows` key, so a phone reads up to three sessions off one\n * lock-screen card instead of having to hold one card per session. It is a pure\n * addition — no new method, no new capability name, no existing key or topic\n * changes shape — so the minor counts the key alone, and a client that reads 18\n * knows the order of the rows it is handed is the bridge's rather than one it\n * has to derive.\n * 17 when the live-activity channel shipped (§29.2): this bridge now sends the\n * lock-screen card a suspended app cannot update itself, addressed to the\n * per-card APNs tokens {@link METHOD_PUSH_REGISTER} already carries and projected\n * per session rather than per bridge. It is a pure addition — no new method, no\n * new capability name, and no existing frame, field or topic changes shape — so\n * the minor counts it alone: a client that wants a card has to read 17 before it\n * registers one, because a bridge below this one has no sending path at all and\n * would answer `ok:true` to a registration it can never use.\n * 16 when the push channel shipped: behind {@link CAP_PUSH} a client may call\n * {@link METHOD_PUSH_REGISTER} and have the device table remember an APNs token,\n * so a phone learns a turn ended — or that a question is waiting — while its\n * socket is not open. No frame, no topic and no existing method changes shape;\n * the minor is raised because a new reply body and a new announcement appear on\n * the wire, and because a client has to read the name before it registers.\n * 15 when the squads channel shipped: behind {@link CAP_SQUADS} a client may\n * call {@link METHOD_SQUADS_STATE}, {@link METHOD_SQUADS_LIST},\n * {@link METHOD_SQUADS_RUNS}, {@link METHOD_SQUADS_RUN_MEMBER} and\n * {@link METHOD_SQUADS_RUN_SQUAD}, so it reads five new reply bodies off the wire\n * and drives the squad domain instead of deriving its agents from anything else.\n * 14 when the session-admin channel shipped: behind {@link CAP_WORKSPACE} a\n * client may call {@link METHOD_WORKSPACE_LIST} and read the host's workspaces\n * with both registry-global session sets, and behind {@link CAP_SESSION_ADMIN}\n * it may call {@link METHOD_SESSION_RENAME}, {@link METHOD_SESSION_PIN},\n * {@link METHOD_SESSION_UNPIN}, {@link METHOD_SESSION_ARCHIVE} and\n * {@link METHOD_SESSION_UNARCHIVE}, so a phone long-presses a roster row for the\n * same five actions the desktop offers it.\n * 13 when the question list shipped: behind {@link CAP_QUESTION_LIST} a client\n * may call {@link METHOD_QUESTION_LIST} and be answered the questions this\n * bridge is still holding, so it reads a new reply body off the wire and the\n * number rises with it. It is what lets a phone stop trusting a card it holds:\n * the one retirement signal before it was `question.request` with\n * `state: \"settled\"`, which a phone that was disconnected when the last client\n * left never receives.\n * 12 when the command channel shipped: behind {@link CAP_COMMANDS} a client may\n * call {@link METHOD_SESSION_COMMANDS} and {@link METHOD_SESSION_COMMAND}, so it\n * reads a new reply body off the wire and the number rises with it.\n * 11 when the fork channel shipped: behind {@link CAP_SESSION_FORK} a client may\n * call {@link METHOD_SESSION_FORK} and receive the host's own fork answer, so a\n * phone branches a session that inherits the context of the one it forked. This\n * is the second of two appends cut from 9 — the snapshot-`since` channel took\n * 10 on the integration branch first — so the number steps over the one already\n * on `dev`: the minor counts additions to this protocol, and a later landing\n * steps over the earlier one instead of reusing its number.\n * 10 when the snapshot became incremental on request: behind\n * {@link CAP_SESSION_SNAPSHOT_SINCE} a `session.snapshot` that names `sinceSeq`\n * is answered either the entries above that watermark or a full baseline\n * carrying `mode` and `reset`, so a client reads a new reply shape off the\n * wire and the number rises with it.\n * 9 when the compact roster shipped: behind {@link CAP_ROSTER_COMPACT} a\n * `session.list` that names one of the compact parameters is answered a\n * shorter row and may be cut into pages, so a client reads a new row schema\n * off the wire and the number rises with it.\n * 8 when the outbound frame form became a capability: behind\n * {@link CAP_FRAME_DEFLATE} a declaring client may be answered in binary\n * frames carrying raw DEFLATE of the text, so the minor is raised for a change\n * a client reads off the wire rather than for a name alone.\n * 7 when the two channels met: the agent channel and the durable history\n * channel each raised 5 to 6 on its own branch, so the protocol that carries\n * both is 7. 6 when the agent channel shipped: behind {@link CAP_AGENTS}\n * `presets.list` forwards the host's Agent-preset roster and `session.create`\n * hands the host one creation request, both verbatim. 6 was also the durable\n * history channel on its own: behind {@link CAP_SESSION_DEEP_HISTORY} a client\n * may call {@link METHOD_SESSION_HISTORY_DEEP} and walk a session's store back\n * to its oldest entry, below the follow window `session.history` slices. 5 when\n * the roster stopped carrying archived sessions: behind\n * {@link CAP_ROSTER_OMITS_ARCHIVED} `session.list` names no session the host's\n * archive set holds, so a session archived between two listings arrives as a\n * removal and one restored as a change. 4 when byte-level increments shipped:\n * behind {@link CAP_DELTA} `session.list` and `board.snapshot` answer a reset\n * or a delta against a `since` token. 3 was\n * the background-job channel — behind {@link CAP_JOBS} a client may call\n * `jobs.list` and receive `jobs.changed`. 2 was the subagent thread —\n * a `user-message` delta may carry an `actor` and a `subagent` delta exists\n * behind {@link CAP_SUBAGENT_THREAD}. 1 was the extension seam — a mounted\n * plugin may answer methods outside {@link KNOWN_METHODS} once the client\n * declares the capability that plugin requires. No addition changed the major\n * version, a frozen field, or an existing method or topic name.\n */\nexport const MINOR = 22\n\n/**\n * The capabilities this bridge itself serves, and the opening half of what\n * `hello` advertises.\n *\n * A capability a mounted plugin adds is not listed here — the bridge is not its\n * author and names none of them — but `hello` advertises it all the same: the\n * answer is this list plus every capability the extension registry currently\n * requires a client to declare (`RemoteBridgeRegistry.capabilities`), computed\n * on each greeting so a plugin mounted after this bridge was built is visible\n * to the next phone. A name both halves carry is listed once, and this list\n * keeps its order at the front, so a bridge with no extension mounted answers\n * byte for byte the list it always did. Extension names never move\n * {@link MINOR}: that number describes this protocol, and a plugin's own names\n * are the plugin's.\n *\n * A capability whose whole switch is a declaration — no method, no answer, no\n * field behind it, such as {@link CAP_APPROVALS} — stays out of this list for\n * the reason it always did: advertising it would claim a handshake change\n * without one.\n */\nexport const SERVED_CAPABILITIES: readonly string[] = [\n CAP_SESSION_SNAPSHOT_TRIM,\n CAP_SESSION_SNAPSHOT_PAGE,\n CAP_QUESTIONS,\n CAP_QUESTION_LIST,\n CAP_SUBAGENT_THREAD,\n CAP_JOBS,\n CAP_AGENTS,\n CAP_DELTA,\n CAP_ROSTER_OMITS_ARCHIVED,\n CAP_SESSION_DEEP_HISTORY,\n CAP_FRAME_DEFLATE,\n CAP_ROSTER_COMPACT,\n CAP_SESSION_SNAPSHOT_SINCE,\n CAP_SESSION_FORK,\n CAP_COMMANDS,\n CAP_WORKSPACE,\n CAP_SESSION_ADMIN,\n CAP_SQUADS,\n CAP_PUSH,\n CAP_USAGE,\n CAP_USAGE_STATS,\n CAP_UI,\n CAP_UI_LIST,\n CAP_SESSION_ATTACHMENT_PATH,\n]\n/** `server` field of the hello response. */\nexport const SERVER_ID = 'dsh-remote-bridge'\n\n/** Exact route path of the bridge's WebSocket endpoint. */\nexport const WS_PATH = '/ios/v1'\n/** Exact route path of the loopback-only bootstrap token endpoint. */\nexport const PAIR_TOKEN_PATH = '/remote-bridge/pair/token'\n","/**\n * The panel's one wire call: read the one-shot bootstrap token from this\n * package's own Host route.\n *\n * The route is same-origin and document-relative (the GUI is served with\n * `<base href=\"./\">`, so a sub-path deployment resolves it against its entry\n * directory instead of escaping to the origin root — the same rule\n * `dsh-remote-web-ui`'s pair API follows). It is NOT consumed here: the panel\n * only displays the secret, and the phone spends it in `pair.begin`, so a\n * mis-click on \"new code\" voids a token without ever pairing a device.\n *\n * `403` is a fact, not an error: the loopback gate in `core/loopback.ts`\n * refuses any page whose socket or `Host` is not this machine, which is exactly\n * the case the panel must name out loud.\n *\n * The origin's own source crosses too, and it is not decoration: it is what lets\n * the panel say which kind of address the code carries without printing a\n * public hostname, while still naming a LAN literal that answers only inside the\n * network the page is already on.\n * @module dsh-remote-bridge/client/pair-token\n */\n\nimport type { PairOriginSource } from '../core/pair-address.ts'\nimport { PAIR_TOKEN_PATH } from '../core/protocol.ts'\n\n/** Document-relative form of the Host route, for a page served under any base. */\nexport const PAIR_TOKEN_URL = PAIR_TOKEN_PATH.replace(/^\\/+/, '')\n\n/** The outcome of one token read. */\nexport type PairTokenOutcome =\n /**\n * A live one-shot token and the instant it stops being accepted, plus the\n * address half when this machine can name its own public origin. `pairingUrl`\n * is the code a QR should carry: a `{token, url}` document the phone parses\n * into both halves of its configuration.\n */\n | {\n kind: 'ok'\n token: string\n expiresAt: number\n origin: string | null\n originSource: PairOriginSource | null\n pairingUrl: string | null\n }\n /** 403: the page is not open on the machine itself, so the loopback gate refused it. */\n | { kind: 'forbidden' }\n /** The route answered with a status the panel does not know, or with a body that is not a token. */\n | { kind: 'failed'; status: number }\n /** The request never reached the host (offline, host stopped, connection reset). */\n | { kind: 'unreachable' }\n\n/** The minimal response surface the reader uses, so a test can inject its own. */\nexport interface PairTokenResponse {\n readonly ok: boolean\n readonly status: number\n json(): Promise<unknown>\n}\n\n/** The minimal fetch surface the reader uses, so a test can inject its own. */\nexport type PairTokenFetch = (url: string, init: { signal?: AbortSignal; cache: string }) => Promise<PairTokenResponse>\n\nexport interface ReadPairTokenOptions {\n /** Injected transport; defaults to the global fetch. */\n readonly fetchImpl?: PairTokenFetch\n /** Aborts an in-flight read (the panel closed, the entry unmounted). */\n readonly signal?: AbortSignal\n}\n\n/** Read a string field, treating a missing, mistyped or empty value as absent. */\nfunction stringOrNull(value: unknown): string | null {\n return typeof value === 'string' && value !== '' ? value : null\n}\n\n/**\n * Read one bootstrap token.\n *\n * Never throws: every failure is one of the outcome arms, because the panel has\n * to render each of them. A `200` whose body is not `{token, expiresAt}` is\n * reported as a failure rather than shown as an empty QR.\n * @param options - injected transport and abort signal.\n * @returns the read outcome.\n */\nexport async function readPairToken(options: ReadPairTokenOptions = {}): Promise<PairTokenOutcome> {\n const send = options.fetchImpl ?? (globalThis.fetch as unknown as PairTokenFetch | undefined)\n if (send === undefined) return { kind: 'unreachable' }\n let response: PairTokenResponse\n try {\n response = await send(PAIR_TOKEN_URL, {\n cache: 'no-store',\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n })\n } catch {\n // A network failure and an aborted read are indistinguishable here, and\n // both mean \"no token arrived\" — the panel says so instead of guessing.\n return { kind: 'unreachable' }\n }\n if (response.status === 403) return { kind: 'forbidden' }\n if (!response.ok) return { kind: 'failed', status: response.status }\n let body: unknown\n try {\n body = await response.json()\n } catch {\n return { kind: 'failed', status: response.status }\n }\n if (typeof body !== 'object' || body === null) return { kind: 'failed', status: response.status }\n const token = (body as { token?: unknown }).token\n const expiresAt = (body as { expiresAt?: unknown }).expiresAt\n if (typeof token !== 'string' || token === '') return { kind: 'failed', status: response.status }\n if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return { kind: 'failed', status: response.status }\n // Additive fields: a host that predates origin discovery answers without\n // them, and the panel then falls back to the bare-token code instead of\n // refusing to show anything.\n const origin = stringOrNull((body as { origin?: unknown }).origin)\n const candidate = stringOrNull((body as { pairingUrl?: unknown }).pairingUrl)\n const pairingUrl = candidate !== null && /^wss?:\\/\\/\\S+$/.test(candidate) ? candidate : null\n const source = (body as { originSource?: unknown }).originSource\n const originSource = source === 'realtime' || source === 'env' || source === 'lan' ? source : null\n return { kind: 'ok', token, expiresAt, origin, originSource, pairingUrl }\n}\n","/**\n * The bridge's claims on `ui.request` (§35): which self-contained pages a phone\n * or the desktop may show, and the one path a user's action travels back into the\n * tool call that presented it.\n *\n * A card belongs to exactly one tool call and ends at the user's FIRST action:\n * the first `ui.event` settles it and becomes that call's result, so a card that\n * should keep taking actions is a second presentation rather than a second event\n * (§35.3, §35.8). Every claim is one record keyed by the call id published on the\n * wire, so an event that arrives late still lands, and one naming a call id this\n * bridge never claimed is refused instead of being handed to a tool that is not\n * waiting for it.\n *\n * The bridge invents no deadline: the tool schema declares no `timeout`, so a\n * card carries no `expiresAt` and stays open until the user acts, the agent's own\n * turn is cancelled, or the last paired device has been gone long enough for the\n * hub's grace window (§35.5). It also fabricates no event: a card nobody answered\n * is released as a refusal, never as a decision the operator did not make.\n *\n * Both caps are enforced on this side rather than the client's (§35.2, §35.3): a\n * client that refused an oversized page would leave the agent waiting for a card\n * that never comes, so the call is refused as `invalid-args` before any frame is\n * written.\n * @module dsh-remote-bridge/core/ui\n */\n\nimport { CODE_UI_SETTLED, CODE_UI_UNKNOWN } from './protocol.ts'\n\n/** Upper bound of one card's document, in UTF-8 bytes (§35.2). */\nexport const UI_HTML_MAX_BYTES = 262_144\n\n/** Upper bound of one `ui.event` payload, in UTF-8 bytes (§35.3). */\nexport const UI_PAYLOAD_MAX_BYTES = 8192\n\n/**\n * How many settled call ids this bridge remembers, so a repeated tap is answered\n * `ui-settled` instead of `ui-unknown` (§35.3).\n *\n * The promise is already settled and the card is already gone by then; the only\n * reason to remember the id is that a client which tapped twice must be able to\n * tell \"already done\" from \"never mine\". A phone holds no more live cards than it\n * rendered, so the bound costs one short string per presentation and never grows\n * with the process's uptime.\n */\nexport const UI_SETTLED_MEMORY = 256\n\n/** Whether a card still holds the tool call, or is only a notice now. */\nexport type UiState = 'open' | 'settled'\n\n/** One lossless JSON value, as the wire carries it inside an event payload. */\nexport type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }\n\n/** The action a user took inside one card, in the presenter's own closed set. */\nexport interface UiEvent {\n readonly type: string\n readonly payload?: JsonValue\n}\n\n/**\n * The `ui.request` payload for one claim, and the `payload` of every `ui.list`\n * entry.\n *\n * One function for both so the card a client was handed and the card it reads back\n * out of a list cannot drift apart: an absent `title` or `height` is an absent key\n * rather than an empty or null one, exactly as §35.2 froze it. `expiresAt` is never\n * written: a presentation whose tool schema declares no `timeout` has no deadline\n * to publish, and a published one would be a promise this bridge does not keep.\n * @param state - whether the card still holds the tool call.\n * @param card - the claim being published.\n * @returns the frozen payload body.\n */\nexport function uiPayload(state: UiState, card: UiCardView): UiRequestPayload {\n return {\n sessionId: card.sessionId,\n callId: card.callId,\n state,\n ...(card.title === undefined ? {} : { title: card.title }),\n html: card.html,\n ...(card.height === undefined ? {} : { height: card.height }),\n }\n}\n\n/**\n * The identity a client knows one card by (`\"<sessionId>/<callId>\"`, §35.4).\n *\n * The same pair a `ui.list` row carries, so the card a tool presented and the row\n * a client reconciles it against are compared as one name instead of two fields\n * that could be recombined differently on each side.\n * @param sessionId - the session whose agent presented the card.\n * @param callId - the tool call id it is held under.\n * @returns the card key.\n */\nexport function uiKey(sessionId: string, callId: string): string {\n return sessionId + '/' + callId\n}\n\n/** @returns the UTF-8 byte length of one string. */\nfunction utf8Bytes(text: string): number {\n return new TextEncoder().encode(text).length\n}\n\n/** @returns whether one card document is within {@link UI_HTML_MAX_BYTES}. */\nexport function uiHtmlFits(html: string): boolean {\n return utf8Bytes(html) <= UI_HTML_MAX_BYTES\n}\n\n/**\n * Read one `ui.event` body out of a decoded frame.\n *\n * The event's `type` is the presenter's own closed set: this bridge carries it and\n * never interprets the value, so the only shape it enforces is the one the frame\n * declares (§35.3). An absent and an explicit `null` payload are different\n * things — the payload key is kept exactly when the client sent one.\n * @param raw - the `event` field as it crossed the wire.\n * @returns the event, or undefined when the frame is not one.\n */\nexport function uiEventOf(raw: unknown): UiEvent | undefined {\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined\n const record = raw as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string' || type === '') return undefined\n return record.payload === undefined ? { type } : { type, payload: record.payload as JsonValue }\n}\n\n/** @returns whether one event's payload is within {@link UI_PAYLOAD_MAX_BYTES}. */\nexport function uiEventFits(event: UiEvent): boolean {\n return event.payload === undefined || utf8Bytes(JSON.stringify(event.payload)) <= UI_PAYLOAD_MAX_BYTES\n}\n\n/** One card this bridge still holds, as `ui.list` publishes it (§35.4). */\nexport interface ListedCard {\n /** {@link uiKey}: the identity the client holds it under. */\n readonly key: string\n readonly sessionId: string\n /** `open` or `settled`; a settled card is not held and never listed. */\n readonly state: UiState\n /** The `ui.request` payload, byte for byte the shape §35.2 froze. */\n readonly payload: UiRequestPayload\n}\n\n/**\n * The body of one `ui.list` answer.\n *\n * `complete` is what a client is allowed to act on: only a COMPLETE list may\n * retire a card it does not carry (§35.5, §24.3), so a bridge that could answer\n * only part of the set must say `false` rather than let the difference read as\n * \"the card is over\".\n */\nexport interface UiListPayload {\n readonly cards: readonly ListedCard[]\n readonly complete: boolean\n}\n\n/** `ui.request`'s payload, as §35.2 froze it. */\nexport interface UiRequestPayload {\n readonly sessionId: string\n readonly callId: string\n readonly state: UiState\n /** One header line; absent when the presenter named none. */\n readonly title?: string\n /** A whole self-contained document, `<!doctype html>` first, within {@link UI_HTML_MAX_BYTES}. */\n readonly html: string\n /** The presenter's suggested initial height in points; the client still measures. */\n readonly height?: number\n /**\n * Epoch milliseconds of this bridge's own deadline for the card; absent, always,\n * for a presentation whose tool schema declares no `timeout` (§35.2).\n */\n readonly expiresAt?: number\n}\n\n/** The identity and content of one claim, as the hub publishes it. */\nexport interface UiCardView {\n readonly sessionId: string\n readonly callId: string\n readonly html: string\n readonly title?: string\n readonly height?: number\n}\n\n/** Why one presentation ended without a user action, in the wire's own vocabulary. */\nexport type UiRefusalReason = 'unavailable' | 'invalid-args' | 'timeout' | 'cancelled'\n\n/** What one presentation ended as: the user's action, or the refusal to wait for one. */\nexport type UiPresentOutcome =\n | { readonly ok: true; readonly type: string; readonly payload?: JsonValue }\n | { readonly ok: false; readonly reason: UiRefusalReason }\n\n/** What one `ui.event` produced: acknowledgement, or the refusal to accept it. */\nexport type UiEventReply = { readonly ok: true } | { readonly ok: false; readonly code: string; readonly msg: string }\n\nexport interface OpenCardInput {\n readonly sessionId: string\n /** The id published on the wire, which is the host's own `ToolCallId`. */\n readonly callId: string\n readonly html: string\n readonly title?: string\n readonly height?: number\n /** The agent's own cancellation lifetime for this call. */\n readonly signal?: AbortSignal\n /**\n * Called when the card leaves this bridge — the user's event, the grace window,\n * a cancelled turn, the bridge unloading. The client still holds a card for it\n * and has to be told, or it keeps showing a page whose actions go nowhere.\n */\n readonly onSettled?: (card: UiCardView) => void\n}\n\n/** The presentation one `ui_present` call is waiting on, as the hub publishes it. */\nexport interface ClaimedCard extends UiCardView {\n /** The user's action, or the refusal that ended the card. Never rejects. */\n readonly outcome: Promise<UiPresentOutcome>\n}\n\n/** One live claim, with every path that ends it. */\ninterface Claim {\n readonly sessionId: string\n readonly callId: string\n readonly html: string\n readonly title: string | undefined\n readonly height: number | undefined\n readonly finish: (outcome: UiPresentOutcome) => void\n readonly detach: () => void\n /** Tells the client its card is over; set from the input's `onSettled`. */\n readonly notifySettled: () => void\n}\n\n/**\n * The publishable view of one claim.\n * @param record - the live claim.\n * @returns the card's fields as the hub publishes them.\n */\nfunction viewOf(record: Claim): UiCardView {\n return {\n sessionId: record.sessionId,\n callId: record.callId,\n html: record.html,\n ...(record.title === undefined ? {} : { title: record.title }),\n ...(record.height === undefined ? {} : { height: record.height }),\n }\n}\n\n/**\n * Pending cards of one bridge process.\n *\n * One record per call id published on the wire and one settle for every path\n * (the user's event, the agent's cancellation, the grace window, bridge unload),\n * so a card can never be settled twice and a released claim leaves no abort\n * listener behind.\n */\nexport class UiCards {\n readonly #cards = new Map<string, Claim>()\n /** Call ids a user's own event settled, oldest first, bounded by {@link UI_SETTLED_MEMORY}. */\n readonly #settled = new Set<string>()\n\n /** @returns how many cards this bridge currently holds. */\n get size(): number {\n return this.#cards.size\n }\n\n /**\n * @param callId - one wire call id.\n * @returns `open` while it holds a tool call, `settled` once a user's event\n * settled it, and undefined when this bridge never claimed it — which is how a\n * listener tells `ui-settled` from `ui-unknown` (§35.3).\n */\n stateOf(callId: string): UiState | undefined {\n if (this.#cards.has(callId)) return 'open'\n return this.#settled.has(callId) ? 'settled' : undefined\n }\n\n /**\n * Claim one card.\n * @param input - session identity, wire call id, the page, and the host's lifetime.\n * @returns the claim the hub publishes, or undefined when there is nothing to publish.\n */\n open(input: OpenCardInput): ClaimedCard | undefined {\n // A call whose own lifetime already ended has no card to publish: announcing one\n // would hand the client a page that can never be settled.\n if (input.signal?.aborted === true) return undefined\n if (this.#cards.has(input.callId) || this.#settled.has(input.callId)) return undefined\n let finish: (outcome: UiPresentOutcome) => void = () => undefined\n const outcome = new Promise<UiPresentOutcome>((resolve) => { finish = resolve })\n const signal = input.signal\n const onAbort = (): void => { this.#cancel(input.callId) }\n const record: Claim = {\n sessionId: input.sessionId,\n callId: input.callId,\n html: input.html,\n title: input.title,\n height: input.height,\n finish,\n detach: (): void => { signal?.removeEventListener('abort', onAbort) },\n notifySettled: (): void => { input.onSettled?.(viewOf(record)) },\n }\n this.#cards.set(input.callId, record)\n signal?.addEventListener('abort', onAbort, { once: true })\n return { ...viewOf(record), outcome }\n }\n\n /**\n * Settle one card from the client's first event (§35.3).\n *\n * The event is the tool call's result and its only result: the card leaves the\n * held table in the same step, so a second event finds it settled rather than\n * settling the call twice.\n * @param sessionId - the session the client believes owns the card.\n * @param callId - the wire call id the client was shown.\n * @param event - the user's action, carried verbatim.\n */\n settle(sessionId: string, callId: string, event: UiEvent): UiEventReply {\n const record = this.#cards.get(callId)\n if (record === undefined) {\n return this.#settled.has(callId)\n ? { ok: false, code: CODE_UI_SETTLED, msg: 'this card is already settled' }\n : { ok: false, code: CODE_UI_UNKNOWN, msg: 'the card is unknown or was settled elsewhere' }\n }\n if (record.sessionId !== sessionId) {\n return { ok: false, code: CODE_UI_UNKNOWN, msg: 'the card is unknown or was settled elsewhere' }\n }\n this.#cards.delete(callId)\n this.#remember(callId)\n record.detach()\n record.notifySettled()\n record.finish(event.payload === undefined ? { ok: true, type: event.type } : { ok: true, type: event.type, payload: event.payload })\n return { ok: true }\n }\n\n /**\n * Every card this bridge still holds, as `ui.list` publishes it (§35.4).\n *\n * The claim registry IS the answer: a card leaves it the moment the user settles\n * it, the grace window releases it, or the bridge unloads, so a card missing from\n * this list is one no action can reach any more. Only `open` is ever listed —\n * `settled` is the one-way notice, never a held row.\n * @returns one entry per held card, in claim order.\n */\n listed(): readonly ListedCard[] {\n return [...this.#cards.values()].map(record => ({\n key: uiKey(record.sessionId, record.callId),\n sessionId: record.sessionId,\n state: 'open',\n payload: uiPayload('open', viewOf(record)),\n }))\n }\n\n /**\n * Withdraw the named cards, ending each tool call with a refusal.\n * @param callIds - the cards to release.\n * @param reason - why; carried into the tool result as it stands.\n * @returns how many were still open and therefore released.\n */\n withdraw(callIds: readonly string[], reason: UiRefusalReason = 'timeout'): number {\n let withdrawn = 0\n for (const callId of callIds) {\n const record = this.#cards.get(callId)\n if (record === undefined) continue\n this.#cards.delete(callId)\n record.detach()\n record.notifySettled()\n record.finish({ ok: false, reason })\n withdrawn += 1\n }\n return withdrawn\n }\n\n /**\n * Withdraw every claim.\n * @param reason - why; carried into every released tool call.\n * @returns how many cards were still open.\n */\n withdrawAll(reason: UiRefusalReason = 'timeout'): number {\n return this.withdraw([...this.#cards.keys()], reason)\n }\n\n /**\n * End one card from the agent's own cancellation lifetime.\n *\n * The tool call is going away, so nothing can settle it later: the promise is\n * resolved with the refusal instead of being left pending, and the client is told\n * its page is over rather than left with a card whose actions go nowhere.\n */\n #cancel(callId: string): void {\n this.withdraw([callId], 'cancelled')\n }\n\n /**\n * Remember one call id a user's event settled, dropping the oldest once the bound\n * is reached — a repeated tap is answered `ui-settled` while the id is here, and\n * `ui-unknown` afterwards.\n */\n #remember(callId: string): void {\n this.#settled.add(callId)\n if (this.#settled.size <= UI_SETTLED_MEMORY) return\n const oldest = this.#settled.values().next().value\n if (oldest !== undefined) this.#settled.delete(oldest)\n }\n}\n","/**\n * The transcript reading of one `ui_present` call (protocol §35.10, §35.11):\n * what the desktop row draws, decided without touching the DOM.\n *\n * A card has two sources and neither may be dropped. While the call is still\n * running the arguments are the only material on the wire, so the page comes out\n * of `args` and the header says the operator has not acted yet. Once the result\n * lands, the presentation payload `meta.ui` is the card's own record — its\n * `state`, its `title` and the very document that crossed — and the arguments\n * are only the fallback for a result that carries no payload.\n *\n * The argument view is read by shape rather than by import: a toolview receives a\n * lazy `PartialArguments` when the call arrived as argument text and a plain\n * payload when the call was dispatched as an object, and §35.10 fixes neither. A\n * field reader therefore answers from all three shapes it can meet (lazy view,\n * JSON text, parsed object) so a page is never lost to a shape this row did not\n * anticipate.\n *\n * Two rules live here rather than in the renderer. A document above 256 KiB is\n * never handed to a frame (§35.2 caps it on this side too), and a frame message is\n * read by shape alone: the sandboxed document has an opaque origin, so identity\n * comes from the frame element the row owns, never from what the message claims.\n * Nothing read here is forwarded anywhere — the desktop renders and does not\n * answer (§35.11).\n * @module dsh-remote-bridge/client/ui-card\n */\n\nimport { UI_HTML_MAX_BYTES, type UiState } from '../core/ui.ts'\n\n/**\n * The Tool slot's stage literals, as the composing contract publishes them\n * (`ToolCallPhaseProps`). `result` is the settled arm; every other stage still\n * has the call's arguments only.\n */\nexport type PresentPhase = 'preparing' | 'start' | 'result'\n\n/** One card as a row draws it, whichever source it came from. */\nexport interface PresentCard {\n /** The whole self-contained document, `<!doctype html>` first. */\n readonly html: string\n /** Whether the card still holds the call (`open`) or is only a notice. */\n readonly state: UiState\n /** One header line; absent when the presenter named none. */\n readonly title?: string\n /** The presenter's suggested first height in points; the measurement wins. */\n readonly height?: number\n /** `\"<sessionId>/<callId>\"`, when the payload carries the card identity. */\n readonly key?: string\n}\n\n/** What one row read produced. */\nexport type PresentRead =\n | { readonly kind: 'card'; readonly card: PresentCard }\n /** A page over {@link UI_HTML_MAX_BYTES}: refused visibly, never rendered. */\n | { readonly kind: 'oversize' }\n /** No page in either source: the row keeps a neutral line instead of a card. */\n | { readonly kind: 'empty' }\n\n/** The call material one row can read at its stage. */\ninterface PresentBlock {\n /** The lazy argument view (`ToolArgs`), or a parsed payload. */\n readonly args?: unknown\n /** Finished argument text, for a stage that publishes it beside the view. */\n readonly argsRaw?: unknown\n /** `ToolResultNode.meta`, carried verbatim by the protocol. */\n readonly meta?: unknown\n}\n\n/** One theme token as it is handed to a card's document. */\nexport type ThemeToken = readonly [name: string, value: string]\n\n/**\n * The theme tokens a card inherits from the GUI's own root element.\n *\n * Four roles and no more: the page needs a text colour it can trust, a quieter\n * one, a surface and a border. A token the running theme does not define is\n * simply not injected — the page then falls back to its own CSS, which is why an\n * unreadable theme is a degraded look rather than a broken card.\n */\nexport const CARD_THEME_TOKENS = [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-border-l2',\n] as const\n\n/** The one sandbox value a card frame is allowed (§35.7, §35.11). */\nexport const FRAME_SANDBOX = 'allow-scripts'\n\n/**\n * The permissions a card frame is explicitly denied.\n *\n * §35.7 refuses camera, microphone, location and clipboard reads on both ends.\n * A sandboxed document already has an opaque origin, and this policy states the\n * denial where the browser enforces it rather than leaving it to the default.\n */\nexport const FRAME_PERMISSIONS = [\n \"camera 'none'\",\n \"microphone 'none'\",\n \"geolocation 'none'\",\n \"clipboard-read 'none'\",\n].join('; ')\n\n/** The message type the injected reporter uses to publish the content height. */\nexport const FRAME_HEIGHT_CHANNEL = 'dsh-ui-card-height'\n\n/** The first height of a card whose presenter suggested none. */\nexport const CARD_DEFAULT_HEIGHT = 320\n\n/** The smallest and largest heights a measured card may take, in CSS pixels. */\nexport const CARD_MIN_HEIGHT = 96\nexport const CARD_MAX_HEIGHT = 720\n\n/**\n * Read one field as text out of every argument shape a toolview can receive.\n * @param args - the lazy view, finished JSON text, or a parsed payload.\n * @param name - the top-level field name.\n * @returns the field's decoded string, or undefined when absent or not a string.\n */\nfunction fieldText(args: unknown, name: string): string | undefined {\n if (typeof args === 'string') {\n const parsed = parseJson(args)\n return parsed === undefined ? undefined : fieldText(parsed, name)\n }\n if (typeof args !== 'object' || args === null) return undefined\n const view = args as Record<string, unknown> & { text?: unknown }\n if (typeof view.text === 'function') {\n const read: unknown = (view.text as (key: string) => unknown).call(args, name)\n return typeof read === 'string' ? read : undefined\n }\n const direct = view[name]\n return typeof direct === 'string' ? direct : undefined\n}\n\n/**\n * Read one field as any completed value out of the same three shapes.\n * @param args - the lazy view, finished JSON text, or a parsed payload.\n * @param name - the top-level field name.\n * @returns the value, or undefined when absent.\n */\nfunction fieldValue(args: unknown, name: string): unknown {\n if (typeof args === 'string') {\n const parsed = parseJson(args)\n return parsed === undefined ? undefined : fieldValue(parsed, name)\n }\n if (typeof args !== 'object' || args === null) return undefined\n const view = args as Record<string, unknown> & { value?: unknown }\n if (typeof view.value === 'function') return (view.value as (key: string) => unknown).call(args, name)\n return view[name]\n}\n\n/** @returns the parsed payload, or undefined when the text is not one object. */\nfunction parseJson(text: string): unknown {\n try {\n return JSON.parse(text) as unknown\n } catch {\n return undefined\n }\n}\n\n/** @returns one suggested height as a whole number of CSS pixels, when usable. */\nfunction heightOf(raw: unknown): number | undefined {\n if (typeof raw !== 'number' || !Number.isFinite(raw) || raw <= 0) return undefined\n return Math.ceil(raw)\n}\n\n/**\n * Read the presentation payload a settled call carries (§35.10).\n *\n * The payload is the card's own record, so it is read only when it is one: a\n * `html` that is not a string is no card at all, which keeps a malformed payload\n * from becoming an empty frame. `state` outside the frozen pair reads as\n * `settled` — a result-phase payload is a finished card by definition, and the\n * `open` arm exists for a presenter that answers before its first event.\n * @param meta - the result's `meta` value, carried verbatim.\n * @returns the card, or undefined when this result carries no presentation.\n */\nexport function readPresentation(meta: unknown): PresentCard | undefined {\n if (typeof meta !== 'object' || meta === null) return undefined\n const ui = (meta as { ui?: unknown }).ui\n if (typeof ui !== 'object' || ui === null) return undefined\n const record = ui as Record<string, unknown>\n const html = record.html\n if (typeof html !== 'string') return undefined\n const title = record.title\n const key = record.key\n const height = heightOf(record.height)\n return {\n html,\n state: record.state === 'open' ? 'open' : 'settled',\n ...(typeof title === 'string' ? { title } : {}),\n ...(height === undefined ? {} : { height }),\n ...(typeof key === 'string' ? { key } : {}),\n }\n}\n\n/**\n * Build the card a running call shows from its own arguments.\n * @param block - the call material of the current stage.\n * @returns the card, or undefined when the arguments carry no page.\n */\nfunction argumentCard(block: PresentBlock): PresentCard | undefined {\n const html = fieldText(block.args, 'html') ?? fieldText(block.argsRaw, 'html')\n if (html === undefined) return undefined\n const title = fieldText(block.args, 'title') ?? fieldText(block.argsRaw, 'title')\n const height = heightOf(fieldValue(block.args, 'height') ?? fieldValue(block.argsRaw, 'height'))\n return {\n html,\n state: 'open',\n ...(title === undefined ? {} : { title }),\n ...(height === undefined ? {} : { height }),\n }\n}\n\n/** @returns whether one document is within {@link UI_HTML_MAX_BYTES}. */\nexport function cardHtmlFits(html: string): boolean {\n return new TextEncoder().encode(html).length <= UI_HTML_MAX_BYTES\n}\n\n/**\n * Decide what the row draws at one stage of the call.\n *\n * The settled stage prefers `meta.ui`, because that payload is the presentation\n * the host published and carries its ending. A result without the payload falls\n * back to the arguments — and then the card is still over, so it reads\n * `settled`: the stage decides that, not a field that is absent.\n * @param phase - the stage the Tool slot published.\n * @param block - the call material of that stage.\n * @returns a card, a refusal, or the neutral line.\n */\nexport function presentReadOf(phase: unknown, block: unknown): PresentRead {\n if (typeof block !== 'object' || block === null) return { kind: 'empty' }\n const material = block as PresentBlock\n const card = phase === 'result'\n ? readPresentation(material.meta) ?? settledFromArguments(material)\n : argumentCard(material)\n if (card === undefined) return { kind: 'empty' }\n return cardHtmlFits(card.html) ? { kind: 'card', card } : { kind: 'oversize' }\n}\n\n/** @returns the argument page of a settled call, as a finished card. */\nfunction settledFromArguments(material: PresentBlock): PresentCard | undefined {\n const card = argumentCard(material)\n return card === undefined ? undefined : { ...card, state: 'settled' }\n}\n\n/**\n * Read the theme tokens off a computed style, skipping the ones it does not carry.\n * @param style - the GUI root element's computed style.\n * @returns the tokens, in {@link CARD_THEME_TOKENS} order.\n */\nexport function cardThemeTokens(style: { getPropertyValue(name: string): string }): readonly ThemeToken[] {\n const tokens: ThemeToken[] = []\n for (const name of CARD_THEME_TOKENS) {\n let value = ''\n try {\n value = style.getPropertyValue(name)\n } catch {\n value = ''\n }\n const trimmed = value.trim()\n if (trimmed !== '') tokens.push([name, trimmed])\n }\n return tokens\n}\n\n/** @returns the `<style>` handing the theme tokens to a card's document. */\nfunction themeStyle(tokens: readonly ThemeToken[]): string {\n if (tokens.length === 0) return ''\n const body = tokens.map(([name, value]) => `${name}:${value}`).join(';')\n return `<style data-dsh-card-theme>:root{${body}}</style>`\n}\n\n/**\n * The reporter a card's document runs to publish its own content height.\n *\n * The frame cannot be measured from the outside — the document is opaque and\n * cross-origin — so the measurement has to be pushed out. It is deliberately the\n * only code this row adds to a page: it reads a height and posts a number, and a\n * page that removes it only loses the measurement, never the card.\n * @param channel - the message type the parent listens for.\n * @returns one script element as text.\n */\nfunction heightReporter(channel: string): string {\n const parts = [\n '<script data-dsh-card-frame>(function(){',\n 'function post(){try{',\n 'var d=document.documentElement,b=document.body;',\n 'var h=Math.max(d?d.scrollHeight:0,b?b.scrollHeight:0);',\n 'if(h>0){parent.postMessage({type:' + JSON.stringify(channel) + ',height:h},\"*\")}',\n '}catch(e){}}',\n 'window.addEventListener(\"load\",post);',\n 'document.addEventListener(\"DOMContentLoaded\",post);',\n 'try{if(typeof ResizeObserver===\"function\"){var ro=new ResizeObserver(post);',\n 'if(document.documentElement)ro.observe(document.documentElement);',\n 'if(document.body)ro.observe(document.body)}}catch(e){}',\n 'post()})()</script>',\n ]\n return parts.join('')\n}\n\n/**\n * Put one snippet inside an existing element rather than before the document.\n * @param html - the card document.\n * @param closingTag - the tag to insert ahead of, lower case.\n * @param snippet - the markup to insert.\n * @returns the document with the snippet inside it.\n */\nfunction injectBefore(html: string, closingTag: string, snippet: string): string {\n if (snippet === '') return html\n const at = html.toLowerCase().lastIndexOf(closingTag)\n return at < 0 ? html + snippet : html.slice(0, at) + snippet + html.slice(at)\n}\n\n/**\n * Build the document handed to a card's frame.\n *\n * The agent's page stays byte for byte what crossed; this only adds the theme\n * variables its CSS may use and the height reporter. Insertion happens ahead of\n * the closing tags rather than at the start of the string, because a snippet\n * placed before `<!doctype html>` would put the document into quirks mode.\n * @param html - the card document as the presenter wrote it.\n * @param tokens - the theme tokens to hand the page.\n * @param channel - the message type the reporter publishes on.\n * @returns the frame document; the original page when it takes no injection.\n */\nexport function frameDocument(html: string, tokens: readonly ThemeToken[], channel: string = FRAME_HEIGHT_CHANNEL): string {\n const style = themeStyle(tokens)\n const withTheme = style === '' ? html : injectBefore(html, '</head>', style)\n return injectBefore(withTheme, '</body>', heightReporter(channel))\n}\n\n/** One message a card's frame sent the parent. */\nexport type FrameEvent =\n | { readonly kind: 'height'; readonly height: number }\n /** Anything else the page posted: an action this desktop never answers. */\n | { readonly kind: 'interaction' }\n\n/**\n * Read one message a card's frame posted.\n *\n * Only the shape is read. The frame's origin is opaque, so the parent identifies\n * the sender by the frame element it owns; what is left to decide here is what\n * the payload means, and a page's own `{type, payload}` action means nothing\n * beyond \"the operator tried to act here\".\n * @param data - the message payload.\n * @returns the event, or undefined when the message is not one this row reads.\n */\nexport function frameEventOf(data: unknown): FrameEvent | undefined {\n if (typeof data !== 'object' || data === null || Array.isArray(data)) return undefined\n const record = data as Record<string, unknown>\n if (record.type === FRAME_HEIGHT_CHANNEL) {\n const height = record.height\n if (typeof height !== 'number' || !Number.isFinite(height) || height <= 0) return undefined\n return { kind: 'height', height: Math.ceil(height) }\n }\n return typeof record.type === 'string' && record.type !== '' ? { kind: 'interaction' } : undefined\n}\n\n/**\n * Hold a measured height inside the range a card may occupy.\n * @param height - the content height the frame reported, in CSS pixels.\n * @returns the height the card takes.\n */\nexport function clampCardHeight(height: number): number {\n if (!Number.isFinite(height)) return CARD_DEFAULT_HEIGHT\n return Math.min(CARD_MAX_HEIGHT, Math.max(CARD_MIN_HEIGHT, Math.ceil(height)))\n}\n","/**\n * The transcript row of one `ui_present` call: the whole page an agent handed\n * into the session, drawn in a controlled frame (protocol §35.11).\n *\n * The row renders and does not answer. The frame carries `srcdoc` and the one\n * sandbox value §35.7 allows — never `allow-same-origin`, which is what turns a\n * sandboxed document back into a same-origin one and would hand an agent page the\n * GUI's own storage and cookies. There is no host request on any path here: an\n * action the page posts arrives as one visible sentence telling the operator to\n * answer on the phone, and nothing is forwarded, stored or sent.\n *\n * Height is measured from the inside because the frame is opaque from the\n * outside: the injected reporter posts the document's own content height, the\n * presenter's suggested `height` carries the first frame, and the measurement\n * replaces it as soon as one arrives. The theme is handed in as variables read\n * off the GUI root, so a card follows the running theme without importing one;\n * a theme that cannot be read costs the injected variables, never the card.\n */\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'\nimport {\n CARD_DEFAULT_HEIGHT,\n FRAME_HEIGHT_CHANNEL,\n FRAME_PERMISSIONS,\n FRAME_SANDBOX,\n cardThemeTokens,\n clampCardHeight,\n frameDocument,\n frameEventOf,\n presentReadOf,\n type ThemeToken,\n} from './ui-card.ts'\nimport { PLUGIN_ATTR } from './semantic.ts'\nimport css from './ui-present.module.css'\n\nexport type UiPresentRowProps = PropsLocale<'remote-bridge'> & {\n /** The stage the Tool slot published (`preparing`, `start` or `result`). */\n readonly phase?: unknown\n /** The call material of that stage: the argument view, argument text, meta. */\n readonly block?: unknown\n}\n\n/** @returns the GUI root's theme tokens, or none when the theme cannot be read. */\nfunction readThemeTokens(): readonly ThemeToken[] {\n try {\n return cardThemeTokens(getComputedStyle(document.documentElement))\n } catch {\n return []\n }\n}\n\n/**\n * Render one card, or the neutral line of a call that carries no page.\n * @param props - the stage, the call material and the locale seat.\n * @returns the card body placed inside the official tool row.\n */\nexport function UiPresentRow({ phase, block, t }: UiPresentRowProps) {\n const read = useMemo(() => presentReadOf(phase, block), [phase, block])\n const card = read.kind === 'card' ? read.card : undefined\n const frame = useRef<HTMLIFrameElement | null>(null)\n // Read once, before the first paint: a token list that arrived after mount\n // would be a second document load for a card that already showed one.\n const [tokens, setTokens] = useState<readonly ThemeToken[]>(readThemeTokens)\n const [measured, setMeasured] = useState<number | undefined>(undefined)\n const [interacted, setInteracted] = useState(false)\n\n // The GUI switches between light and dark while a card is on screen; the\n // document is rebuilt from the tokens of whichever theme is now in force.\n useEffect(() => {\n let media: MediaQueryList | undefined\n try {\n media = window.matchMedia('(prefers-color-scheme: dark)')\n } catch {\n return\n }\n const sync = (): void => { setTokens(readThemeTokens()) }\n if (typeof media.addEventListener === 'function') {\n media.addEventListener('change', sync)\n return () => { media.removeEventListener('change', sync) }\n }\n media.addListener(sync)\n return () => { media.removeListener(sync) }\n }, [])\n\n // A new page is a new measurement and a new notice: carrying either across\n // would size the next card to the previous one's content.\n const html = card?.html\n useEffect(() => {\n setMeasured(undefined)\n setInteracted(false)\n }, [html])\n\n useEffect(() => {\n const onMessage = (event: MessageEvent): void => {\n const element = frame.current\n // Identity is the frame element, not the origin: a sandboxed document has\n // an opaque origin and can assert nothing about itself.\n if (element === null || element.contentWindow === null || event.source !== element.contentWindow) return\n const frameEvent = frameEventOf(event.data)\n if (frameEvent === undefined) return\n if (frameEvent.kind === 'height') {\n setMeasured(clampCardHeight(frameEvent.height))\n return\n }\n // The page asked the desktop for an answer. Nothing leaves this row; the\n // operator is told where answering actually happens.\n setInteracted(true)\n }\n window.addEventListener('message', onMessage)\n return () => { window.removeEventListener('message', onMessage) }\n }, [])\n\n const srcdoc = useMemo(\n () => (card === undefined ? '' : frameDocument(card.html, tokens, FRAME_HEIGHT_CHANNEL)),\n [card, tokens],\n )\n\n if (card === undefined) {\n return (\n <div className={css.row} data-dsh-plugin={PLUGIN_ATTR} data-tone={read.kind}>\n <p className={css.notice} role=\"status\">{read.kind === 'oversize' ? t('card.oversize') : t('card.empty')}</p>\n </div>\n )\n }\n\n const height = measured ?? clampCardHeight(card.height ?? CARD_DEFAULT_HEIGHT)\n\n return (\n <section className={css.card} data-dsh-plugin={PLUGIN_ATTR} data-state={card.state}>\n <header className={css.head}>\n {card.title !== undefined && <span className={css.title}>{card.title}</span>}\n <span className={css.badge}>{card.state === 'open' ? t('card.waiting') : t('card.settled')}</span>\n </header>\n <iframe\n ref={frame}\n className={css.frame}\n style={{ height: `${height}px` }}\n title={card.title ?? t('card.frameLabel')}\n srcDoc={srcdoc}\n sandbox={FRAME_SANDBOX}\n allow={FRAME_PERMISSIONS}\n referrerPolicy=\"no-referrer\"\n />\n <p className={css.notice} role=\"status\">\n {interacted ? t('card.interacted') : t('card.answerOnPhone')}\n </p>\n </section>\n )\n}\n","/**\n * The one seam through which this package registers its keyed Tool view.\n *\n * `tool.call.toolview` is declared by `@deepseek-ai/dsh-client-ui-tool`\n * (`lib/types/client/contract/slots.d.ts`). That package is not installed in this\n * workspace, so its types cannot be imported — a type-only import would itself be\n * a new dependency, and a local `declare module` extension of the SDK's `SlotMap`\n * would duplicate a contract another package owns and collide with the real\n * declaration wherever both are loaded. This module therefore narrows\n * `ctx.slots` to the two members the registration needs and states the slot's own\n * shape locally:\n *\n * - the slot is keyed and session-scoped, and its key is the wire Tool name\n * (`ui_present`), which is what makes one registration draw the card's body\n * without shadowing the official `tool-call` renderer;\n * - the owner publishes the call identity plus a stage union, mirrored here from\n * the upstream `ToolCallPhaseProps`: `preparing`, `start` and `result`. The\n * row reads the arguments at every stage but `result`, which is the only arm\n * that carries the result node.\n *\n * Upstream changing that shape is a change to this file: the phase names, the\n * keyed dispatch and the `locale` seat are the three facts the mirror carries.\n *\n * Technical debt, recorded rather than hidden: when this package next takes a\n * dependency pass, adding `@deepseek-ai/dsh-client-ui-tool` as a devDependency\n * lets this seam be replaced by `PropsRuntime<'tool.call.toolview'>` and by the\n * typed `ctx.slots.register` overload directly.\n * @module dsh-remote-bridge/client/toolview-slot\n */\n\nimport type { ComponentType } from 'react'\nimport { UiPresentRow, type UiPresentRowProps } from './UiPresentRow.tsx'\n\n/** The keyed Tool view slot the official row dispatches into. */\nexport const TOOLVIEW_SLOT = 'tool.call.toolview'\n\n/** The wire Tool name this package renders: the keyed cell it claims. */\nexport const PRESENT_TOOL = 'ui_present'\n\n/** The registration options this seam needs. */\nexport interface ToolviewRegistration {\n /** Exact SlotMap key. */\n readonly name: 'tool.call.toolview'\n /** Keyed cell: the wire Tool name the owner dispatches by. */\n readonly key: string\n /** Dictionary namespace the render machinery synthesizes `t` from. */\n readonly locale: string\n}\n\n/** The narrowed face of `ctx.slots` this package uses. */\nexport interface ToolviewSlotPort {\n /** Run `seats` once the slot is declared; drop them if the declarer leaves. */\n inject(name: string, seats: () => (() => void) | Iterable<() => void>): void\n /** Contribute one view to one keyed cell; the answer is its disposer. */\n register(options: ToolviewRegistration, view: ComponentType<UiPresentRowProps>): () => void\n}\n\n/** The host this seam needs: the client Context, structurally. */\nexport interface ToolviewSlotHost {\n readonly slots: unknown\n}\n\n/**\n * Contribute the `ui_present` card into the Tool row.\n *\n * The contribution is declaration-aware: `inject` waits for the official slot\n * declaration, so a GUI composed without a Tool layer has no keyed cell and thus\n * no card — that is the capability being absent, not an error to report. A\n * registration refused by the registry (an occupied cell at the same priority)\n * is swallowed the same way it is for this package's other seat, so one occupied\n * slot never takes the sidebar entry down with it.\n * @param host - the client Context.\n * @param locale - the dictionary namespace this package registered.\n */\nexport function registerPresentToolview(host: ToolviewSlotHost, locale: string): void {\n const slots = host.slots as unknown as ToolviewSlotPort\n slots.inject(TOOLVIEW_SLOT, () => {\n try {\n return slots.register({ name: TOOLVIEW_SLOT, key: PRESENT_TOOL, locale }, UiPresentRow)\n } catch {\n return () => {}\n }\n })\n}\n","/**\n * `remote-bridge` namespace dictionaries: the protocol v1 pairing panel copy and\n * the header of an interactive card (§35.11).\n *\n * The panel has one job — put the live one-shot code in front of the operator as\n * a QR symbol — so its copy carries what to do with the symbol, how long it\n * lives, what kind of address the phone will dial, why the code is single-use,\n * and that the app is still in testing: the reader is told what they are joining\n * and where to ask about it. No key renders the public origin: the symbol\n * already carries it, and a durable public hostname printed as text would\n * outlive every screenshot it appears in. A LAN literal is not that fact — it\n * answers only inside the network this page is already on — so the LAN line\n * keeps naming it. No key states how the host finds either address, and no key\n * names the wire protocol: both are implementation facts the reader cannot act\n * on.\n *\n * The card's keys say only what the transcript row can act on: whether the page\n * is still waiting for the operator, that it is over, that this desktop renders\n * without answering, and that a page carrying nothing or too much draws a\n * sentence instead of a frame.\n */\n\n/** Simplified Chinese dictionary (the key-set source of truth). */\nexport const zh = {\n 'entry.label': '配对 iPhone',\n 'title': 'iOS App 配对',\n 'subtitle': '用 iOS App(内测)扫描二维码,把 iPhone 连到这台电脑上。配对码只在本机显示。',\n 'state.reading': '正在取配对码…',\n 'pair.qrLabel': '配对二维码',\n 'pair.countdown': '剩余 {s} 秒',\n 'pair.expired': '配对码已过期',\n 'pair.refresh': '重新取码',\n 'pair.usedHint': '配对码一次性有效:iPhone 一开始配对就作废,重新取码也会作废上一张。',\n 'origin.public': '二维码已包含公网地址,扫码后 iPhone 自动连上这台电脑',\n 'origin.lan': '二维码指向局域网地址 {origin},iPhone 需与本机在同一网络',\n 'origin.missing': '没有找到公网地址:先在 App 里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。',\n 'community.invite': 'iOS App 还在内测,欢迎来 Discord 交流',\n 'forbidden.title': '这个页面不是从本机打开的',\n 'forbidden.body': '配对码只能在本机 Web UI 上取。请在本机浏览器打开 http://127.0.0.1:<端口> 后重试。',\n 'failed.title': '取配对码失败',\n 'failed.body': '宿主返回了 HTTP {status},请刷新页面后重试。',\n 'unreachable.title': '无法连接本机宿主',\n 'unreachable.body': '请求没有到达宿主,请确认 dsh web 仍在运行后重试。',\n 'action.close': '关闭',\n 'action.copy': '复制配对码',\n 'action.copied': '已复制',\n 'action.copyFailed': '复制失败',\n 'action.retry': '重试',\n 'card.waiting': '等你操作',\n 'card.settled': '已结算',\n 'card.answerOnPhone': '在手机上作答',\n 'card.interacted': '已收到页面上的操作,但桌面端不作答:在手机上作答',\n 'card.frameLabel': '整页卡片',\n 'card.empty': '这次调用没有可渲染的页面',\n 'card.oversize': '页面超出大小上限,未渲染',\n} as const\n\n/** English dictionary, key-for-key with the zh source. */\nexport const en: Record<RemoteBridgeKey, string> = {\n 'entry.label': 'Pair an iPhone',\n 'title': 'iOS app pairing',\n 'subtitle': 'Scan the QR code with the iOS app (beta) to connect an iPhone to this computer. The code is shown only on this machine.',\n 'state.reading': 'Requesting a pairing code…',\n 'pair.qrLabel': 'Pairing QR code',\n 'pair.countdown': '{s} s left',\n 'pair.expired': 'The pairing code expired',\n 'pair.refresh': 'New code',\n 'pair.usedHint': 'The code is single-use: pairing spends it, and a new code voids the previous one.',\n 'origin.public': 'The QR code carries the public address: the iPhone connects to this computer as soon as it scans',\n 'origin.lan': 'The QR code points at the LAN address {origin}: the iPhone must be on the same network',\n 'origin.missing': 'No public address found: set the connection address in the app to your public relay first, then scan. {host} (this page) is reachable only from this machine.',\n 'community.invite': 'The iOS app is in beta. Come talk to us on Discord',\n 'forbidden.title': 'This page is not open on this machine',\n 'forbidden.body': 'Pairing codes can only be read from the machine itself. Open http://127.0.0.1:<port> in a browser on this machine and retry.',\n 'failed.title': 'Could not read a pairing code',\n 'failed.body': 'The host answered HTTP {status}. Reload the page and retry.',\n 'unreachable.title': 'Cannot reach the local host',\n 'unreachable.body': 'The request never reached the host. Check that dsh web is still running and retry.',\n 'action.close': 'Close',\n 'action.copy': 'Copy pairing code',\n 'action.copied': 'Copied',\n 'action.copyFailed': 'Copy failed',\n 'action.retry': 'Retry',\n 'card.waiting': 'Waiting for you',\n 'card.settled': 'Settled',\n 'card.answerOnPhone': 'Answer on the phone',\n 'card.interacted': 'The page sent an action, but this desktop does not answer: answer on the phone',\n 'card.frameLabel': 'Page card',\n 'card.empty': 'This call carried no page to render',\n 'card.oversize': 'The page is over the size limit and was not rendered',\n}\n\n/** Every key the `remote-bridge` namespace carries. */\nexport type RemoteBridgeKey = keyof typeof zh\n","/**\n * Protocol v1 pairing panel — browser half. Registers the `remote-bridge`\n * dictionary and the sidebar-foot trigger (into the ui-sidebar-declared\n * `sidebar.footer.action` list slot) that opens the panel showing this\n * package's own one-shot bootstrap token as a QR symbol plus its plaintext.\n *\n * The panel is display-only for the native path: it reads the same loopback-only\n * `GET /remote-bridge/pair/token` route an operator would curl, and never spends\n * the token (`pair.begin` stays the phone's call). The browser half therefore\n * adds no wire surface — the envelope, the method names, the topic names and\n * the events are untouched — and it does not touch `dsh-remote-web-ui`'s pairing\n * service, its roster, or its browser cookie path.\n *\n * The half also draws the transcript side of §35.11: one keyed `tool.call.toolview`\n * entry renders a `ui_present` call's whole page in a controlled frame, while the\n * phone stays the only place an action can be answered.\n *\n * Export discipline (packages/AGENTS.md): the /client surface carries only what\n * cordis loading needs plus types.\n */\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale) and its\n// LocaleNamespaceMap merge table.\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the ctx.slots merge (the renderer owns the slot registry).\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\n// Type-only: pulls the ui-sidebar SlotMap merge (the 'sidebar.footer.action' hole).\nimport type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'\n// Type-only: pulls the official remote-connection SlotMap merge ('settings.remoteConnection.extensions').\nimport type {} from '@deepseek-ai/dsh-client-remote-connection/client'\nimport { writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives/client'\nimport { PairEntry } from './PairEntry.tsx'\nimport { RemoteConnectionExtension } from './RemoteConnectionExtension.tsx'\nimport { readPairToken } from './pair-token.ts'\nimport { registerPresentToolview } from './toolview-slot.ts'\nimport { en, zh, type RemoteBridgeKey } from './locales.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots/client' {\n interface LocaleNamespaceMap {\n /** Protocol v1 pairing panel copy. */\n 'remote-bridge': RemoteBridgeKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nconst NS = 'remote-bridge'\n\n/** Unique occupant id inside the shared footer.action list slot. */\nconst ENTRY_ID = 'remote-bridge'\n\n/** Services required by this plugin. */\nexport const inject = ['slots', 'locale']\n\n/**\n * Register the protocol v1 pairing surface.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'remote-bridge: dictionaries')\n\n // Sidebar foot entry. The shell declares 'sidebar.footer.action' (list kind:\n // multiple occupants may share the seat) and registration is\n // declaration-aware via slots.inject. Read and clipboard arrive as an\n // injected face rather than a module import, which keeps the trigger's\n // rendered tree free of closure-factory bundles.\n ctx.slots.inject('sidebar.footer.action', () => {\n try {\n return ctx.slots.register({\n name: 'sidebar.footer.action',\n id: ENTRY_ID,\n locale: NS,\n inject: () => ({ read: readPairToken, copy: writeClipboard }),\n }, PairEntry)\n } catch {\n return () => {}\n }\n })\n\n // Official Settings -> Remote Connection extension seat (DSH 0.2.3-alpha.2+):\n // surface native iOS App pairing beneath the official browser remote access cards.\n ctx.slots.inject('settings.remoteConnection.extensions', () => {\n try {\n return ctx.slots.register({\n name: 'settings.remoteConnection.extensions',\n id: `${ENTRY_ID}-ios`,\n order: 20,\n locale: NS,\n inject: () => ({ read: readPairToken, copy: writeClipboard }),\n }, RemoteConnectionExtension)\n } catch {\n return () => {}\n }\n })\n\n // The transcript card of an interactive presentation (§35.11): one keyed\n // registration under the wire Tool name draws the body of a `ui_present` call,\n // so the official Tool row keeps everything else — identity, timing and the\n // dispatch tree — and no Chat Node renderer is shadowed.\n registerPresentToolview(ctx, NS)\n}\n\nexport type { PairEntryProps } from './PairEntry.tsx'\nexport type { RemoteConnectionExtensionCardProps } from './RemoteConnectionExtension.tsx'\nexport type { PairCopyState, PairPanelProps, PairPanelState } from './PairPanel.tsx'\nexport type { PairTokenFetch, PairTokenOutcome, PairTokenResponse, ReadPairTokenOptions } from './pair-token.ts'\nexport type { RemoteBridgeKey } from './locales.ts'\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,IAAI,YAAY,OAAO;EACvB,IAAI,sBAAsB,OAAO;EACjC,IAAI,eAAe,OAAO,UAAU;EACpC,IAAI,eAAe,OAAO,UAAU;EACpC,IAAI,mBAAmB,KAAK,KAAK,UAAU,OAAO,MAAM,UAAU,KAAK,KAAK;GAAE,YAAY;GAAM,cAAc;GAAM,UAAU;GAAM;EAAM,CAAC,IAAI,IAAI,OAAO;EAC1J,IAAI,kBAAkB,GAAG,MAAM;GAC7B,KAAK,IAAI,QAAQ,MAAM,IAAI,CAAC,IAC1B,IAAI,aAAa,KAAK,GAAG,IAAI,GAC3B,gBAAgB,GAAG,MAAM,EAAE,KAAK;GACpC,IAAI;SACG,IAAI,QAAQ,oBAAoB,CAAC,GACpC,IAAI,aAAa,KAAK,GAAG,IAAI,GAC3B,gBAAgB,GAAG,MAAM,EAAE,KAAK;GAAA;GAEtC,OAAO;EACT;EACA,IAAI,aAAa,QAAQ,YAAY;GACnC,IAAI,SAAS,CAAC;GACd,KAAK,IAAI,QAAQ,QACf,IAAI,aAAa,KAAK,QAAQ,IAAI,KAAK,QAAQ,QAAQ,IAAI,IAAI,GAC7D,OAAO,QAAQ,OAAO;GAC1B,IAAI,UAAU,QAAQ;SACf,IAAI,QAAQ,oBAAoB,MAAM,GACzC,IAAI,QAAQ,QAAQ,IAAI,IAAI,KAAK,aAAa,KAAK,QAAQ,IAAI,GAC7D,OAAO,QAAQ,OAAO;GAAA;GAE5B,OAAO;EACT;;;;;;EAWA,IAAI;IACF,eAAe;GACf,MAAM,UAAU,MAAM,QAAQ;IAM5B,YAAY,SAAS,sBAAsB,eAA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