touch-coop 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Slaney Electronic Entertainment
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # TouchCoop
2
+
3
+ A TypeScript library that enables couch co-op gaming on the web, using mobile devices as controllers.
4
+
5
+ <img src="./media/logo.png" alt="Example" width="300">
6
+
7
+ ## Purpose
8
+
9
+ TouchCoop is designed to allow up to four players to connect to a game server using their mobile devices as controllers. Each player can use touch controls on their device to send input events to the game.
10
+
11
+ TouchCoop is intended for playing games on a TV or monitor, while players use their phones or tablets as controllers.
12
+
13
+ TouchCoop is ideal for casual multiplayer games, such as platformers, puzzle games, or party games. TouchCoop is not intended for games that require low-latency input, such as first-person shooters.
14
+
15
+ TouchCoop does not require servers or user accounts. All communication is done using WebRTC, which allows for peer-to-peer connections between the players' devices.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install touch-coop
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ The library expects your game to use the `Match` and `Player` classes. Your game will require a minimum of two pages with unique URLs:
26
+
27
+ ### 1. Match URL
28
+
29
+ The main game page hosts the game and creates a `Match` instance. This page uses `requestNewPlayerToJoin()` to generate a QR code for each player to join the game.
30
+
31
+ ```ts
32
+ import { Match, PlayerEvent } from "touch-coop";
33
+
34
+ const gamePadURL = "http://localhost:8080/demos/gamepad";
35
+
36
+ function handlePlayerEvent(event: PlayerEvent) {
37
+ switch (event.action) {
38
+ case "JOIN":
39
+ console.log(
40
+ `Player ${event.playerId} joined the game.`
41
+ );
42
+ break;
43
+ case "LEAVE":
44
+ console.log(
45
+ `Player ${event.playerId} left the game.`
46
+ );
47
+ break;
48
+ case "MOVE":
49
+ console.log(
50
+ `Player ${event.playerId} pressed ${event.button}`
51
+ );
52
+ break;
53
+ }
54
+ }
55
+
56
+
57
+ const match = new Match(
58
+ gamePadURL,
59
+ handlePlayerEvent
60
+ );
61
+ ```
62
+
63
+ ### 2. GamePad URL
64
+
65
+ Each player scans a QR code to join the game. The QR code contains a unique URL that opens a web page with touch controls. This page uses the `Player` class to connect to the game match with `player.joinMatch()` and send input events with `player.sendMove("X")`.
66
+
67
+ ```ts
68
+ import React from "react";
69
+ import { Player } from "touch-coop";
70
+
71
+ const player = new Player();
72
+
73
+ export default function GamePad() {
74
+ const [loading, setLoading] = React.useState(true);
75
+
76
+ React.useEffect(() => {
77
+ (async () => {
78
+ await player.joinMatch();
79
+ setLoading(false);
80
+ })();
81
+ }, []);
82
+
83
+ if (loading) {
84
+ return <div>Loading…</div>;
85
+ }
86
+
87
+ return (
88
+ <div>
89
+ <button onClick={() => player.sendMove("up")}>
90
+ Up
91
+ </button>
92
+ <button onClick={() => player.sendMove("down")}>
93
+ Down
94
+ </button>
95
+ <button onClick={() => player.sendMove("left")}>
96
+ Left
97
+ </button>
98
+ <button onClick={() => player.sendMove("right")}>
99
+ Right
100
+ </button>
101
+ <button onClick={() => player.sendMove("A")}>
102
+ A
103
+ </button>
104
+ <button onClick={() => player.sendMove("B")}>
105
+ B
106
+ </button>
107
+ <button onClick={() => player.sendMove("X")}>
108
+ X
109
+ </button>
110
+ <button onClick={() => player.sendMove("Y")}>
111
+ Y
112
+ </button>
113
+ </div>
114
+ );
115
+ }
116
+ ```
117
+
118
+ ## Live Demo
119
+
120
+ You can try a live demo of TouchCoop at [https://SlaneyEE.github.io/touch-coop/demos/match.html](https://SlaneyEE.github.io/touch-coop/demos/match.html).
121
+
122
+ ![](./media/demo.png)
123
+
124
+ The demo contains a simple game where players can join by scaning a QR Code and use their mobile devices as controllers. Each player can use the on-screen buttons to send input events to the game.
125
+
126
+ The game page is [./demos/match.html](./demos/match.html). The QR code redirects players to [./demos/gamepad/index.html](./demos/gamepad/index.html).
127
+
128
+ You need to run a local server to host the demo files. You can use a simple HTTP server like `http-server` or `live-server` to serve the files from the `root` directory and then access `http://localhost:8080/demos/match.html` in your browser.
package/biome.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3
+ "files": {
4
+ "ignore": [
5
+ "build/**",
6
+ "dist/**",
7
+ "dist-electron/**",
8
+ "node_modules/**",
9
+ "public/font/**"
10
+ ]
11
+ },
12
+ "organizeImports": {
13
+ "enabled": true
14
+ },
15
+ "linter": {
16
+ "enabled": true,
17
+ "rules": {
18
+ "recommended": true
19
+ }
20
+ },
21
+ "formatter": {
22
+ "enabled": true,
23
+ "indentStyle": "space",
24
+ "indentWidth": 2
25
+ },
26
+ "javascript": {
27
+ "formatter": {
28
+ "quoteStyle": "double",
29
+ "semicolons": "always"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Gamepad Demo</title>
6
+ <style>
7
+ body { background-color: black; color: white; font-family: sans-serif; display: flex; flex-direction: column; align-items: center; margin-top: 40px; }
8
+ .gamepad { display: grid; grid-template-columns: repeat(3, 60px); grid-gap: 16px; margin-top: 32px; }
9
+ .buttons { display: grid; grid-template-columns: repeat(2, 60px); grid-gap: 16px; margin-top: 32px; }
10
+ button { font-size: 1.2em; padding: 16px; border-radius: 8px; border: 1px solid #888; background: #eee; cursor: pointer; }
11
+ button:active { background: #ccc; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Gamepad Controller</h1>
16
+ <div style="display: flex; flex-direction: row; gap: 80px; margin-top: 32px;">
17
+ <div class="gamepad" style="grid-template-columns: 60px 60px 60px;">
18
+ <div></div>
19
+ <button id="up">&#8593;</button>
20
+ <div></div>
21
+ <button id="left">&#8592;</button>
22
+ <div></div>
23
+ <button id="right">&#8594;</button>
24
+ <div></div>
25
+ <button id="down">&#8595;</button>
26
+ <div></div>
27
+ </div>
28
+ <div class="buttons" style="grid-template-columns: 60px 60px;">
29
+ <button id="x">X</button>
30
+ <button id="y">Y</button>
31
+ <button id="a">A</button>
32
+ <button id="b">B</button>
33
+ </div>
34
+ </div>
35
+ <script src="../../dist/index.global.js"></script>
36
+ <script>
37
+ const player = new TouchCoop.Player();
38
+ window.player = player;
39
+
40
+ (async () => {
41
+ await player.joinMatch();
42
+ function sendButtonEvent(btn) {
43
+ player.sendMove(btn);
44
+ }
45
+
46
+ document.getElementById("up").onclick = () => sendButtonEvent("up");
47
+ document.getElementById("down").onclick = () => sendButtonEvent("down");
48
+ document.getElementById("left").onclick = () => sendButtonEvent("left");
49
+ document.getElementById("right").onclick = () => sendButtonEvent("right");
50
+ document.getElementById("a").onclick = () => sendButtonEvent("A");
51
+ document.getElementById("b").onclick = () => sendButtonEvent("B");
52
+ document.getElementById("x").onclick = () => sendButtonEvent("X");
53
+ document.getElementById("y").onclick = () => sendButtonEvent("Y");
54
+ })();
55
+ </script>
56
+ </body>
57
+ </html>
@@ -0,0 +1,155 @@
1
+ <!DOCTYPE html>
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Touch Coop Game Demo</title>
8
+ <style>
9
+ body { background-color: black; color: white; }
10
+ table { border-collapse: collapse; width: 100%; }
11
+ th, td { border: 1px solid #ccc; padding: 16px; text-align: center; width: 25%; }
12
+ button { padding: 8px 16px; font-size: 16px; }
13
+ img.qr { width: 100%; }
14
+ textarea { width: 100%; resize: vertical; height: 50vh; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <image src="../media/logo.png" alt="Touch Coop Logo" style="width:200px; display:block; margin:auto;" />
19
+ <h1>Touch Coop Game Demo</h1>
20
+ <table id="players-table">
21
+ <tr>
22
+ <th>Player 1</th>
23
+ <th>Player 2</th>
24
+ <th>Player 3</th>
25
+ <th>Player 4</th>
26
+ </tr>
27
+ <tr>
28
+ <td id="cell-0">
29
+ <div id="player-id-0" style="min-height:1.5em;"></div>
30
+ <div id="qr-0"><button onclick="joinPlayer(0)">Join</button></div>
31
+ <div id="area-0" style="display:none; margin-top:12px;">
32
+ <label for="messages-0">Player 1 Messages:</label><br />
33
+ <textarea id="messages-0" rows="6" cols="30" readonly style="resize:vertical;"></textarea>
34
+ </div>
35
+ </td>
36
+ <td id="cell-1">
37
+ <div id="player-id-1" style="min-height:1.5em;"></div>
38
+ <div id="qr-1"><button onclick="joinPlayer(1)">Join</button></div>
39
+ <div id="area-1" style="display:none; margin-top:12px;">
40
+ <label for="messages-1">Player 2 Messages:</label><br />
41
+ <textarea id="messages-1" rows="6" cols="30" readonly style="resize:vertical;"></textarea>
42
+ </div>
43
+ </td>
44
+ <td id="cell-2">
45
+ <div id="player-id-2" style="min-height:1.5em;"></div>
46
+ <div id="qr-2"><button onclick="joinPlayer(2)">Join</button></div>
47
+ <div id="area-2" style="display:none; margin-top:12px;">
48
+ <label for="messages-2">Player 3 Messages:</label><br />
49
+ <textarea id="messages-2" rows="6" cols="30" readonly style="resize:vertical;"></textarea>
50
+ </div>
51
+ </td>
52
+ <td id="cell-3">
53
+ <div id="player-id-3" style="min-height:1.5em;"></div>
54
+ <div id="qr-3"><button onclick="joinPlayer(3)">Join</button></div>
55
+ <div id="area-3" style="display:none; margin-top:12px;">
56
+ <label for="messages-3">Player 4 Messages:</label><br />
57
+ <textarea id="messages-3" rows="6" cols="30" readonly style="resize:vertical;"></textarea>
58
+ </div>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ <script src="../dist/index.global.js"></script>
63
+ <script>
64
+
65
+ function updatePlayerIdDisplay(idx, playerId) {
66
+ const playerIdDiv = document.getElementById(`player-id-${idx}`);
67
+ if (playerId) {
68
+ playerIdDiv.textContent = `Player ID: ${playerId}`;
69
+ } else {
70
+ playerIdDiv.textContent = '';
71
+ }
72
+ }
73
+
74
+ function handlePlayerEvent(event) {
75
+ // Find the player slot idx
76
+ let idx = -1;
77
+ for (let i = 0; i < 4; i++) {
78
+ const div = document.getElementById(`qr-${i}`);
79
+ if (div.dataset.playerId === event.playerId) {
80
+ idx = i;
81
+ break;
82
+ }
83
+ }
84
+ // If not found and this is a JOIN, assign to first available
85
+ if (idx === -1 && event.action === "JOIN") {
86
+ for (let i = 0; i < 4; i++) {
87
+ const div = document.getElementById(`qr-${i}`);
88
+ if (!div.dataset.playerId) {
89
+ div.dataset.playerId = event.playerId;
90
+ idx = i;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ if (idx === -1) return;
96
+ const qrDiv = document.getElementById(`qr-${idx}`);
97
+ const areaDiv = document.getElementById(`area-${idx}`);
98
+ const area = document.getElementById(`messages-${idx}`);
99
+ switch (event.action) {
100
+ case "JOIN": {
101
+ qrDiv.dataset.playerId = event.playerId;
102
+ const joinBtn = qrDiv.querySelector('button');
103
+ if (joinBtn) joinBtn.style.display = 'none';
104
+ const qrImg = qrDiv.querySelector('img.qr');
105
+ if (qrImg) qrImg.remove();
106
+ areaDiv.style.display = '';
107
+ area.value += 'Player joined!\n';
108
+ updatePlayerIdDisplay(idx, event.playerId);
109
+ break;
110
+ }
111
+ case "LEAVE": {
112
+ const joinBtn2 = qrDiv.querySelector('button');
113
+ if (joinBtn2) joinBtn2.style.display = '';
114
+ areaDiv.style.display = 'none';
115
+ area.value += 'Player left!\n';
116
+ updatePlayerIdDisplay(idx, '');
117
+ delete qrDiv.dataset.playerId;
118
+ qrDiv.innerHTML = '<button onclick="joinPlayer(' + idx + ')">Join</button>';
119
+ break;
120
+ }
121
+ case "MOVE":
122
+ area.value += `Player ${event.playerId} pressed ${event.button}\n`;
123
+ break;
124
+ default:
125
+ area.value += JSON.stringify(event) + '\n';
126
+ break;
127
+ }
128
+ area.scrollTop = area.scrollHeight;
129
+ }
130
+
131
+ const match = new TouchCoop.Match(
132
+ "http://localhost:8080/demos/gamepad",
133
+ handlePlayerEvent
134
+ );
135
+
136
+ window.joinPlayer = async function(idx) {
137
+ const qrDiv = document.getElementById(`qr-${idx}`);
138
+ const playerIdDiv = document.getElementById(`player-id-${idx}`);
139
+ qrDiv.innerHTML = 'Loading...';
140
+ playerIdDiv.textContent = '';
141
+ try {
142
+ const { dataUrl, playerId, shareURL } = await match.requestNewPlayerToJoin();
143
+ qrDiv.dataset.playerId = playerId || '';
144
+ qrDiv.innerHTML = `
145
+ <img class='qr' src='${dataUrl}' alt='QR Code' /></br>
146
+ <a href='${shareURL}' target='_blank'>Connect</a>
147
+ `;
148
+ updatePlayerIdDisplay(idx, playerId);
149
+ } catch (err) {
150
+ qrDiv.innerHTML = `<span style='color:red;'>Error</span>`;
151
+ }
152
+ };
153
+ </script>
154
+ </body>
155
+ </html>
@@ -0,0 +1,3 @@
1
+ export declare function compressOfferData(originalText: string): Promise<string>;
2
+ export declare function decompressOfferData(base64Input: string): Promise<string>;
3
+ //# sourceMappingURL=encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,mBA0B3D;AAED,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
package/dist/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function ne(o){const r=new TextEncoder,i=r.encode(o);console.log("Original text size (bytes):",i.length);const n=new CompressionStream("gzip"),t=n.writable.getWriter();t.write(r.encode(o)),t.close();const e=n.readable.getReader(),s=[];for(;;){const{done:h,value:f}=await e.read();if(h)break;s.push(f)}const a=new Uint8Array(await new Blob(s).arrayBuffer()),c=btoa(String.fromCharCode(...a)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=new TextEncoder().encode(c).length;return console.log("SafeBase64 size (bytes):",l),c}async function re(o){let r=(o||"").trim();r=r.replace(/\s+/g,""),r=r.replace(/-/g,"+").replace(/_/g,"/");const i=r.length%4;i===2?r+="==":i===3&&(r+="=");const n=atob(r),t=Uint8Array.from(n,a=>a.charCodeAt(0)),e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));return await new Response(e).text()}class oe{constructor(){this._playerId=null,this._dataChannel=null,this._pc=new RTCPeerConnection,this._pc.ondatachannel=r=>{this._dataChannel=r.channel,this._dataChannel.onopen=()=>{if(this._playerId&&this._dataChannel){const i={playerId:this._playerId,action:"JOIN",timestamp:Date.now()};this._dataChannel.send(JSON.stringify(i))}}},window.addEventListener("beforeunload",()=>{if(this._dataChannel&&this._dataChannel.readyState==="open"&&this._playerId){const r={playerId:this._playerId,action:"LEAVE",button:"",timestamp:Date.now()};try{this._dataChannel.send(JSON.stringify(r))}catch{}}})}async joinMatch(){const i=new URLSearchParams(window.location.search).get("remoteSDP");if(!i)throw new Error("No remoteSDP found in URL parameters.");const n=await re(i),t=JSON.parse(n);this._playerId=t.playerId;const e=t.sdp;if(await this._pc.setRemoteDescription(e),e.type==="offer"){const s=await this._pc.createAnswer();await this._pc.setLocalDescription(s),await new Promise(f=>{this._pc.onicecandidate=d=>{d.candidate||f(void 0)}});const a={playerId:this._playerId,sdp:this._pc.localDescription},u=JSON.stringify(a),c=btoa(u),l=new BroadcastChannel("touch-coop-signaling"),h={type:"answer",playerId:this._playerId,base64Answer:c};l.postMessage(h),l.close()}}async sendMove(r){if(this._dataChannel&&this._dataChannel.readyState==="open"){if(!this._playerId)throw new Error("Player ID is not set. Cannot send data.");const i={playerId:this._playerId,action:"MOVE",button:r,timestamp:Date.now()},n=JSON.stringify(i);this._dataChannel.send(n)}else console.warn("Data channel is not open. Cannot send data.")}}function ie(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var O={},G,Bt;function se(){return Bt||(Bt=1,G=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),G}var Q={},U={},It;function q(){if(It)return U;It=1;let o;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return U.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},U.getSymbolTotalCodewords=function(n){return r[n]},U.getBCHDigit=function(i){let n=0;for(;i!==0;)n++,i>>>=1;return n},U.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');o=n},U.isKanjiModeEnabled=function(){return typeof o<"u"},U.toSJIS=function(n){return o(n)},U}var W={},At;function pt(){return At||(At=1,(function(o){o.L={bit:1},o.M={bit:0},o.Q={bit:3},o.H={bit:2};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return o.L;case"m":case"medium":return o.M;case"q":case"quartile":return o.Q;case"h":case"high":return o.H;default:throw new Error("Unknown EC Level: "+i)}}o.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},o.from=function(n,t){if(o.isValid(n))return n;try{return r(n)}catch{return t}}})(W)),W}var Z,Rt;function ae(){if(Rt)return Z;Rt=1;function o(){this.buffer=[],this.length=0}return o.prototype={get:function(r){const i=Math.floor(r/8);return(this.buffer[i]>>>7-r%8&1)===1},put:function(r,i){for(let n=0;n<i;n++)this.putBit((r>>>i-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),r&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Z=o,Z}var X,St;function ue(){if(St)return X;St=1;function o(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return o.prototype.set=function(r,i,n,t){const e=r*this.size+i;this.data[e]=n,t&&(this.reservedBit[e]=!0)},o.prototype.get=function(r,i){return this.data[r*this.size+i]},o.prototype.xor=function(r,i,n){this.data[r*this.size+i]^=n},o.prototype.isReserved=function(r,i){return this.reservedBit[r*this.size+i]},X=o,X}var $={},Pt;function ce(){return Pt||(Pt=1,(function(o){const r=q().getSymbolSize;o.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,e=r(n),s=e===145?26:Math.ceil((e-13)/(2*t-2))*2,a=[e-7];for(let u=1;u<t-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},o.getPositions=function(n){const t=[],e=o.getRowColCoords(n),s=e.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||t.push([e[a],e[u]]);return t}})($)),$}var tt={},bt;function le(){if(bt)return tt;bt=1;const o=q().getSymbolSize,r=7;return tt.getPositions=function(n){const t=o(n);return[[0,0],[t-r,0],[0,t-r]]},tt}var et={},Nt;function fe(){return Nt||(Nt=1,(function(o){o.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};o.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},o.from=function(t){return o.isValid(t)?parseInt(t,10):void 0},o.getPenaltyN1=function(t){const e=t.size;let s=0,a=0,u=0,c=null,l=null;for(let h=0;h<e;h++){a=u=0,c=l=null;for(let f=0;f<e;f++){let d=t.get(h,f);d===c?a++:(a>=5&&(s+=r.N1+(a-5)),c=d,a=1),d=t.get(f,h),d===l?u++:(u>=5&&(s+=r.N1+(u-5)),l=d,u=1)}a>=5&&(s+=r.N1+(a-5)),u>=5&&(s+=r.N1+(u-5))}return s},o.getPenaltyN2=function(t){const e=t.size;let s=0;for(let a=0;a<e-1;a++)for(let u=0;u<e-1;u++){const c=t.get(a,u)+t.get(a,u+1)+t.get(a+1,u)+t.get(a+1,u+1);(c===4||c===0)&&s++}return s*r.N2},o.getPenaltyN3=function(t){const e=t.size;let s=0,a=0,u=0;for(let c=0;c<e;c++){a=u=0;for(let l=0;l<e;l++)a=a<<1&2047|t.get(c,l),l>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|t.get(l,c),l>=10&&(u===1488||u===93)&&s++}return s*r.N3},o.getPenaltyN4=function(t){let e=0;const s=t.data.length;for(let u=0;u<s;u++)e+=t.data[u];return Math.abs(Math.ceil(e*100/s/5)-10)*r.N4};function i(n,t,e){switch(n){case o.Patterns.PATTERN000:return(t+e)%2===0;case o.Patterns.PATTERN001:return t%2===0;case o.Patterns.PATTERN010:return e%3===0;case o.Patterns.PATTERN011:return(t+e)%3===0;case o.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(e/3))%2===0;case o.Patterns.PATTERN101:return t*e%2+t*e%3===0;case o.Patterns.PATTERN110:return(t*e%2+t*e%3)%2===0;case o.Patterns.PATTERN111:return(t*e%3+(t+e)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}o.applyMask=function(t,e){const s=e.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)e.isReserved(u,a)||e.xor(u,a,i(t,u,a))},o.getBestMask=function(t,e){const s=Object.keys(o.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){e(c),o.applyMask(c,t);const l=o.getPenaltyN1(t)+o.getPenaltyN2(t)+o.getPenaltyN3(t)+o.getPenaltyN4(t);o.applyMask(c,t),l<u&&(u=l,a=c)}return a}})(et)),et}var j={},Mt;function Qt(){if(Mt)return j;Mt=1;const o=pt(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return j.getBlocksCount=function(t,e){switch(e){case o.L:return r[(t-1)*4+0];case o.M:return r[(t-1)*4+1];case o.Q:return r[(t-1)*4+2];case o.H:return r[(t-1)*4+3];default:return}},j.getTotalCodewordsCount=function(t,e){switch(e){case o.L:return i[(t-1)*4+0];case o.M:return i[(t-1)*4+1];case o.Q:return i[(t-1)*4+2];case o.H:return i[(t-1)*4+3];default:return}},j}var nt={},J={},Tt;function de(){if(Tt)return J;Tt=1;const o=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)o[t]=n,r[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)o[t]=o[t-255]})(),J.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},J.exp=function(n){return o[n]},J.mul=function(n,t){return n===0||t===0?0:o[r[n]+r[t]]},J}var _t;function he(){return _t||(_t=1,(function(o){const r=de();o.mul=function(n,t){const e=new Uint8Array(n.length+t.length-1);for(let s=0;s<n.length;s++)for(let a=0;a<t.length;a++)e[s+a]^=r.mul(n[s],t[a]);return e},o.mod=function(n,t){let e=new Uint8Array(n);for(;e.length-t.length>=0;){const s=e[0];for(let u=0;u<t.length;u++)e[u]^=r.mul(t[u],s);let a=0;for(;a<e.length&&e[a]===0;)a++;e=e.slice(a)}return e},o.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let e=0;e<n;e++)t=o.mul(t,new Uint8Array([1,r.exp(e)]));return t}})(nt)),nt}var rt,Dt;function ge(){if(Dt)return rt;Dt=1;const o=he();function r(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=o.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const e=o.mod(t,this.genPoly),s=this.degree-e.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(e,s),a}return e},rt=r,rt}var ot={},it={},st={},vt;function Wt(){return vt||(vt=1,st.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),st}var _={},Lt;function Zt(){if(Lt)return _;Lt=1;const o="[0-9]+",r="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
2
+ ]))+`;_.KANJI=new RegExp(i,"g"),_.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),_.BYTE=new RegExp(n,"g"),_.NUMERIC=new RegExp(o,"g"),_.ALPHANUMERIC=new RegExp(r,"g");const t=new RegExp("^"+i+"$"),e=new RegExp("^"+o+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return _.testKanji=function(u){return t.test(u)},_.testNumeric=function(u){return e.test(u)},_.testAlphanumeric=function(u){return s.test(u)},_}var Ut;function F(){return Ut||(Ut=1,(function(o){const r=Wt(),i=Zt();o.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},o.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},o.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},o.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},o.MIXED={bit:-1},o.getCharCountIndicator=function(e,s){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!r.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?e.ccBits[0]:s<27?e.ccBits[1]:e.ccBits[2]},o.getBestModeForData=function(e){return i.testNumeric(e)?o.NUMERIC:i.testAlphanumeric(e)?o.ALPHANUMERIC:i.testKanji(e)?o.KANJI:o.BYTE},o.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},o.isValid=function(e){return e&&e.bit&&e.ccBits};function n(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return o.NUMERIC;case"alphanumeric":return o.ALPHANUMERIC;case"kanji":return o.KANJI;case"byte":return o.BYTE;default:throw new Error("Unknown mode: "+t)}}o.from=function(e,s){if(o.isValid(e))return e;try{return n(e)}catch{return s}}})(it)),it}var qt;function we(){return qt||(qt=1,(function(o){const r=q(),i=Qt(),n=pt(),t=F(),e=Wt(),s=7973,a=r.getBCHDigit(s);function u(f,d,P){for(let b=1;b<=40;b++)if(d<=o.getCapacity(b,P,f))return b}function c(f,d){return t.getCharCountIndicator(f,d)+4}function l(f,d){let P=0;return f.forEach(function(b){const M=c(b.mode,d);P+=M+b.getBitsLength()}),P}function h(f,d){for(let P=1;P<=40;P++)if(l(f,P)<=o.getCapacity(P,d,t.MIXED))return P}o.from=function(d,P){return e.isValid(d)?parseInt(d,10):P},o.getCapacity=function(d,P,b){if(!e.isValid(d))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=t.BYTE);const M=r.getSymbolTotalCodewords(d),A=i.getTotalCodewordsCount(d,P),N=(M-A)*8;if(b===t.MIXED)return N;const R=N-c(b,d);switch(b){case t.NUMERIC:return Math.floor(R/10*3);case t.ALPHANUMERIC:return Math.floor(R/11*2);case t.KANJI:return Math.floor(R/13);case t.BYTE:default:return Math.floor(R/8)}},o.getBestVersionForData=function(d,P){let b;const M=n.from(P,n.M);if(Array.isArray(d)){if(d.length>1)return h(d,M);if(d.length===0)return 1;b=d[0]}else b=d;return u(b.mode,b.getLength(),M)},o.getEncodedBits=function(d){if(!e.isValid(d)||d<7)throw new Error("Invalid QR Code version");let P=d<<12;for(;r.getBCHDigit(P)-a>=0;)P^=s<<r.getBCHDigit(P)-a;return d<<12|P}})(ot)),ot}var at={},Ft;function me(){if(Ft)return at;Ft=1;const o=q(),r=1335,i=21522,n=o.getBCHDigit(r);return at.getEncodedBits=function(e,s){const a=e.bit<<3|s;let u=a<<10;for(;o.getBCHDigit(u)-n>=0;)u^=r<<o.getBCHDigit(u)-n;return(a<<10|u)^i},at}var ut={},ct,kt;function pe(){if(kt)return ct;kt=1;const o=F();function r(i){this.mode=o.NUMERIC,this.data=i.toString()}return r.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let t,e,s;for(t=0;t+3<=this.data.length;t+=3)e=this.data.substr(t,3),s=parseInt(e,10),n.put(s,10);const a=this.data.length-t;a>0&&(e=this.data.substr(t),s=parseInt(e,10),n.put(s,a*3+1))},ct=r,ct}var lt,Ot;function ye(){if(Ot)return lt;Ot=1;const o=F(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(n){this.mode=o.ALPHANUMERIC,this.data=n}return i.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let s=r.indexOf(this.data[e])*45;s+=r.indexOf(this.data[e+1]),t.put(s,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},lt=i,lt}var ft,zt;function Ce(){if(zt)return ft;zt=1;const o=F();function r(i){this.mode=o.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return r.getBitsLength=function(n){return n*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(i){for(let n=0,t=this.data.length;n<t;n++)i.put(this.data[n],8)},ft=r,ft}var dt,Jt;function Ee(){if(Jt)return dt;Jt=1;const o=F(),r=q();function i(n){this.mode=o.KANJI,this.data=n}return i.getBitsLength=function(t){return t*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(n){let t;for(t=0;t<this.data.length;t++){let e=r.toSJIS(this.data[t]);if(e>=33088&&e<=40956)e-=33088;else if(e>=57408&&e<=60351)e-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
3
+ Make sure your charset is UTF-8`);e=(e>>>8&255)*192+(e&255),n.put(e,13)}},dt=i,dt}var ht={exports:{}},Vt;function Be(){return Vt||(Vt=1,(function(o){var r={single_source_shortest_paths:function(i,n,t){var e={},s={};s[n]=0;var a=r.PriorityQueue.make();a.push(n,0);for(var u,c,l,h,f,d,P,b,M;!a.empty();){u=a.pop(),c=u.value,h=u.cost,f=i[c]||{};for(l in f)f.hasOwnProperty(l)&&(d=f[l],P=h+d,b=s[l],M=typeof s[l]>"u",(M||b>P)&&(s[l]=P,a.push(l,P),e[l]=c))}if(typeof t<"u"&&typeof s[t]>"u"){var A=["Could not find a path from ",n," to ",t,"."].join("");throw new Error(A)}return e},extract_shortest_path_from_predecessor_list:function(i,n){for(var t=[],e=n;e;)t.push(e),i[e],e=i[e];return t.reverse(),t},find_path:function(i,n,t){var e=r.single_source_shortest_paths(i,n,t);return r.extract_shortest_path_from_predecessor_list(e,t)},PriorityQueue:{make:function(i){var n=r.PriorityQueue,t={},e;i=i||{};for(e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t.queue=[],t.sorter=i.sorter||n.default_sorter,t},default_sorter:function(i,n){return i.cost-n.cost},push:function(i,n){var t={value:i,cost:n};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};o.exports=r})(ht)),ht.exports}var jt;function Ie(){return jt||(jt=1,(function(o){const r=F(),i=pe(),n=ye(),t=Ce(),e=Ee(),s=Zt(),a=q(),u=Be();function c(A){return unescape(encodeURIComponent(A)).length}function l(A,N,R){const B=[];let T;for(;(T=A.exec(R))!==null;)B.push({data:T[0],index:T.index,mode:N,length:T[0].length});return B}function h(A){const N=l(s.NUMERIC,r.NUMERIC,A),R=l(s.ALPHANUMERIC,r.ALPHANUMERIC,A);let B,T;return a.isKanjiModeEnabled()?(B=l(s.BYTE,r.BYTE,A),T=l(s.KANJI,r.KANJI,A)):(B=l(s.BYTE_KANJI,r.BYTE,A),T=[]),N.concat(R,B,T).sort(function(C,y){return C.index-y.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function f(A,N){switch(N){case r.NUMERIC:return i.getBitsLength(A);case r.ALPHANUMERIC:return n.getBitsLength(A);case r.KANJI:return e.getBitsLength(A);case r.BYTE:return t.getBitsLength(A)}}function d(A){return A.reduce(function(N,R){const B=N.length-1>=0?N[N.length-1]:null;return B&&B.mode===R.mode?(N[N.length-1].data+=R.data,N):(N.push(R),N)},[])}function P(A){const N=[];for(let R=0;R<A.length;R++){const B=A[R];switch(B.mode){case r.NUMERIC:N.push([B,{data:B.data,mode:r.ALPHANUMERIC,length:B.length},{data:B.data,mode:r.BYTE,length:B.length}]);break;case r.ALPHANUMERIC:N.push([B,{data:B.data,mode:r.BYTE,length:B.length}]);break;case r.KANJI:N.push([B,{data:B.data,mode:r.BYTE,length:c(B.data)}]);break;case r.BYTE:N.push([{data:B.data,mode:r.BYTE,length:c(B.data)}])}}return N}function b(A,N){const R={},B={start:{}};let T=["start"];for(let w=0;w<A.length;w++){const C=A[w],y=[];for(let g=0;g<C.length;g++){const I=C[g],m=""+w+g;y.push(m),R[m]={node:I,lastCount:0},B[m]={};for(let E=0;E<T.length;E++){const p=T[E];R[p]&&R[p].node.mode===I.mode?(B[p][m]=f(R[p].lastCount+I.length,I.mode)-f(R[p].lastCount,I.mode),R[p].lastCount+=I.length):(R[p]&&(R[p].lastCount=I.length),B[p][m]=f(I.length,I.mode)+4+r.getCharCountIndicator(I.mode,N))}}T=y}for(let w=0;w<T.length;w++)B[T[w]].end=0;return{map:B,table:R}}function M(A,N){let R;const B=r.getBestModeForData(A);if(R=r.from(N,B),R!==r.BYTE&&R.bit<B.bit)throw new Error('"'+A+'" cannot be encoded with mode '+r.toString(R)+`.
4
+ Suggested mode is: `+r.toString(B));switch(R===r.KANJI&&!a.isKanjiModeEnabled()&&(R=r.BYTE),R){case r.NUMERIC:return new i(A);case r.ALPHANUMERIC:return new n(A);case r.KANJI:return new e(A);case r.BYTE:return new t(A)}}o.fromArray=function(N){return N.reduce(function(R,B){return typeof B=="string"?R.push(M(B,null)):B.data&&R.push(M(B.data,B.mode)),R},[])},o.fromString=function(N,R){const B=h(N,a.isKanjiModeEnabled()),T=P(B),w=b(T,R),C=u.find_path(w.map,"start","end"),y=[];for(let g=1;g<C.length-1;g++)y.push(w.table[C[g]].node);return o.fromArray(d(y))},o.rawSplit=function(N){return o.fromArray(h(N,a.isKanjiModeEnabled()))}})(ut)),ut}var Kt;function Ae(){if(Kt)return Q;Kt=1;const o=q(),r=pt(),i=ae(),n=ue(),t=ce(),e=le(),s=fe(),a=Qt(),u=ge(),c=we(),l=me(),h=F(),f=Ie();function d(w,C){const y=w.size,g=e.getPositions(C);for(let I=0;I<g.length;I++){const m=g[I][0],E=g[I][1];for(let p=-1;p<=7;p++)if(!(m+p<=-1||y<=m+p))for(let S=-1;S<=7;S++)E+S<=-1||y<=E+S||(p>=0&&p<=6&&(S===0||S===6)||S>=0&&S<=6&&(p===0||p===6)||p>=2&&p<=4&&S>=2&&S<=4?w.set(m+p,E+S,!0,!0):w.set(m+p,E+S,!1,!0))}}function P(w){const C=w.size;for(let y=8;y<C-8;y++){const g=y%2===0;w.set(y,6,g,!0),w.set(6,y,g,!0)}}function b(w,C){const y=t.getPositions(C);for(let g=0;g<y.length;g++){const I=y[g][0],m=y[g][1];for(let E=-2;E<=2;E++)for(let p=-2;p<=2;p++)E===-2||E===2||p===-2||p===2||E===0&&p===0?w.set(I+E,m+p,!0,!0):w.set(I+E,m+p,!1,!0)}}function M(w,C){const y=w.size,g=c.getEncodedBits(C);let I,m,E;for(let p=0;p<18;p++)I=Math.floor(p/3),m=p%3+y-8-3,E=(g>>p&1)===1,w.set(I,m,E,!0),w.set(m,I,E,!0)}function A(w,C,y){const g=w.size,I=l.getEncodedBits(C,y);let m,E;for(m=0;m<15;m++)E=(I>>m&1)===1,m<6?w.set(m,8,E,!0):m<8?w.set(m+1,8,E,!0):w.set(g-15+m,8,E,!0),m<8?w.set(8,g-m-1,E,!0):m<9?w.set(8,15-m-1+1,E,!0):w.set(8,15-m-1,E,!0);w.set(g-8,8,1,!0)}function N(w,C){const y=w.size;let g=-1,I=y-1,m=7,E=0;for(let p=y-1;p>0;p-=2)for(p===6&&p--;;){for(let S=0;S<2;S++)if(!w.isReserved(I,p-S)){let L=!1;E<C.length&&(L=(C[E]>>>m&1)===1),w.set(I,p-S,L),m--,m===-1&&(E++,m=7)}if(I+=g,I<0||y<=I){I-=g,g=-g;break}}}function R(w,C,y){const g=new i;y.forEach(function(S){g.put(S.mode.bit,4),g.put(S.getLength(),h.getCharCountIndicator(S.mode,w)),S.write(g)});const I=o.getSymbolTotalCodewords(w),m=a.getTotalCodewordsCount(w,C),E=(I-m)*8;for(g.getLengthInBits()+4<=E&&g.put(0,4);g.getLengthInBits()%8!==0;)g.putBit(0);const p=(E-g.getLengthInBits())/8;for(let S=0;S<p;S++)g.put(S%2?17:236,8);return B(g,w,C)}function B(w,C,y){const g=o.getSymbolTotalCodewords(C),I=a.getTotalCodewordsCount(C,y),m=g-I,E=a.getBlocksCount(C,y),p=g%E,S=E-p,L=Math.floor(g/E),z=Math.floor(m/E),$t=z+1,yt=L-z,te=new u(yt);let K=0;const V=new Array(E),Ct=new Array(E);let H=0;const ee=new Uint8Array(w.buffer);for(let k=0;k<E;k++){const x=k<S?z:$t;V[k]=ee.slice(K,K+x),Ct[k]=te.encode(V[k]),K+=x,H=Math.max(H,x)}const Y=new Uint8Array(g);let Et=0,D,v;for(D=0;D<H;D++)for(v=0;v<E;v++)D<V[v].length&&(Y[Et++]=V[v][D]);for(D=0;D<yt;D++)for(v=0;v<E;v++)Y[Et++]=Ct[v][D];return Y}function T(w,C,y,g){let I;if(Array.isArray(w))I=f.fromArray(w);else if(typeof w=="string"){let L=C;if(!L){const z=f.rawSplit(w);L=c.getBestVersionForData(z,y)}I=f.fromString(w,L||40)}else throw new Error("Invalid data");const m=c.getBestVersionForData(I,y);if(!m)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=m;else if(C<m)throw new Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+m+`.
7
+ `);const E=R(C,y,I),p=o.getSymbolSize(C),S=new n(p);return d(S,C),P(S),b(S,C),A(S,y,0),C>=7&&M(S,C),N(S,E),isNaN(g)&&(g=s.getBestMask(S,A.bind(null,S,y))),s.applyMask(g,S),A(S,y,g),{modules:S,version:C,errorCorrectionLevel:y,maskPattern:g,segments:I}}return Q.create=function(C,y){if(typeof C>"u"||C==="")throw new Error("No input text");let g=r.M,I,m;return typeof y<"u"&&(g=r.from(y.errorCorrectionLevel,r.M),I=c.from(y.version),m=s.from(y.maskPattern),y.toSJISFunc&&o.setToSJISFunction(y.toSJISFunc)),T(C,I,g,m)},Q}var gt={},wt={},Ht;function Xt(){return Ht||(Ht=1,(function(o){function r(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let n=i.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+i);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(e){return[e,e]}))),n.length===6&&n.push("F","F");const t=parseInt(n.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+n.slice(0,6).join("")}}o.getOptions=function(n){n||(n={}),n.color||(n.color={});const t=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,e=n.width&&n.width>=21?n.width:void 0,s=n.scale||4;return{width:e,scale:e?4:s,margin:t,color:{dark:r(n.color.dark||"#000000ff"),light:r(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},o.getScale=function(n,t){return t.width&&t.width>=n+t.margin*2?t.width/(n+t.margin*2):t.scale},o.getImageWidth=function(n,t){const e=o.getScale(n,t);return Math.floor((n+t.margin*2)*e)},o.qrToImageData=function(n,t,e){const s=t.modules.size,a=t.modules.data,u=o.getScale(s,e),c=Math.floor((s+e.margin*2)*u),l=e.margin*u,h=[e.color.light,e.color.dark];for(let f=0;f<c;f++)for(let d=0;d<c;d++){let P=(f*c+d)*4,b=e.color.light;if(f>=l&&d>=l&&f<c-l&&d<c-l){const M=Math.floor((f-l)/u),A=Math.floor((d-l)/u);b=h[a[M*s+A]?1:0]}n[P++]=b.r,n[P++]=b.g,n[P++]=b.b,n[P]=b.a}}})(wt)),wt}var Yt;function Re(){return Yt||(Yt=1,(function(o){const r=Xt();function i(t,e,s){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=s,e.width=s,e.style.height=s+"px",e.style.width=s+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}o.render=function(e,s,a){let u=a,c=s;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),s||(c=n()),u=r.getOptions(u);const l=r.getImageWidth(e.modules.size,u),h=c.getContext("2d"),f=h.createImageData(l,l);return r.qrToImageData(f.data,e,u),i(h,c,l),h.putImageData(f,0,0),c},o.renderToDataURL=function(e,s,a){let u=a;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),u||(u={});const c=o.render(e,s,u),l=u.type||"image/png",h=u.rendererOpts||{};return c.toDataURL(l,h.quality)}})(gt)),gt}var mt={},xt;function Se(){if(xt)return mt;xt=1;const o=Xt();function r(t,e){const s=t.a/255,a=e+'="'+t.hex+'"';return s<1?a+" "+e+'-opacity="'+s.toFixed(2).slice(1)+'"':a}function i(t,e,s){let a=t+e;return typeof s<"u"&&(a+=" "+s),a}function n(t,e,s){let a="",u=0,c=!1,l=0;for(let h=0;h<t.length;h++){const f=Math.floor(h%e),d=Math.floor(h/e);!f&&!c&&(c=!0),t[h]?(l++,h>0&&f>0&&t[h-1]||(a+=c?i("M",f+s,.5+d+s):i("m",u,0),u=0,c=!1),f+1<e&&t[h+1]||(a+=i("h",l),l=0)):u++}return a}return mt.render=function(e,s,a){const u=o.getOptions(s),c=e.modules.size,l=e.modules.data,h=c+u.margin*2,f=u.color.light.a?"<path "+r(u.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",d="<path "+r(u.color.dark,"stroke")+' d="'+n(l,c,u.margin)+'"/>',P='viewBox="0 0 '+h+" "+h+'"',M='<svg xmlns="http://www.w3.org/2000/svg" '+(u.width?'width="'+u.width+'" height="'+u.width+'" ':"")+P+' shape-rendering="crispEdges">'+f+d+`</svg>
8
+ `;return typeof a=="function"&&a(null,M),M},mt}var Gt;function Pe(){if(Gt)return O;Gt=1;const o=se(),r=Ae(),i=Re(),n=Se();function t(e,s,a,u,c){const l=[].slice.call(arguments,1),h=l.length,f=typeof l[h-1]=="function";if(!f&&!o())throw new Error("Callback required as last argument");if(f){if(h<2)throw new Error("Too few arguments provided");h===2?(c=a,a=s,s=u=void 0):h===3&&(s.getContext&&typeof c>"u"?(c=u,u=void 0):(c=u,u=a,a=s,s=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(a=s,s=u=void 0):h===2&&!s.getContext&&(u=a,a=s,s=void 0),new Promise(function(d,P){try{const b=r.create(a,u);d(e(b,s,u))}catch(b){P(b)}})}try{const d=r.create(a,u);c(null,e(d,s,u))}catch(d){c(d)}}return O.create=r.create,O.toCanvas=t.bind(null,i.render),O.toDataURL=t.bind(null,i.renderToDataURL),O.toString=t.bind(null,function(e,s,a){return n.render(e,a)}),O}var be=Pe();const Ne=ie(be);class Me{constructor(r,i){this._playerConnections=new Map,this._playerChannels=new Map,this._invitationAccepted=new Map,this._onPlayerEvent=null,this._onPlayerEvent=i,this._gamepadUiUrl=r;const n=new BroadcastChannel("touch-coop-signaling");n.onmessage=async t=>{const e=t.data;if(e&&e.type==="answer"&&e.playerId&&e.base64Answer)try{const s=this._playerConnections.get(e.playerId);if(!s)throw new Error(`No peer connection for player: ${e.playerId}`);const a=JSON.parse(atob(e.base64Answer));await s.setRemoteDescription(a.sdp),this._invitationAccepted.set(e.playerId,!0)}catch{}}}_UUIID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=Math.random()*16|0;return(r==="x"?i:i&3|8).toString(16)})}async requestNewPlayerToJoin(){return new Promise((r,i)=>{(async()=>{const n=this._UUIID(),t=new RTCPeerConnection,e=t.createDataChannel("player");this._playerConnections.set(n,t),this._playerChannels.set(n,e),this._invitationAccepted.set(n,!1),e.onmessage=h=>{if(this._onPlayerEvent){let f=h.data;f=JSON.parse(h.data),this._onPlayerEvent(f)}};const s=await t.createOffer();await t.setLocalDescription(s),await new Promise(h=>{t.onicecandidate=f=>{f.candidate||h(void 0)}});const a={playerId:n,sdp:t.localDescription},u=JSON.stringify(a),c=await ne(u),l=`${this._gamepadUiUrl}?remoteSDP=${c}`;Ne.toDataURL(l,{errorCorrectionLevel:"M"},(h,f)=>{if(h)return i(h);r({dataUrl:f,shareURL:l,playerId:n})})})()})}getInvitationStatus(r){return this._invitationAccepted.get(r)}async acceptPlayerAnswer(r,i){}}exports.Match=Me;exports.Player=oe;
@@ -0,0 +1,3 @@
1
+ export * from "./player";
2
+ export * from "./match";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ var TouchCoop=(function(V){"use strict";async function te(o){const r=new TextEncoder,i=r.encode(o);console.log("Original text size (bytes):",i.length);const n=new CompressionStream("gzip"),t=n.writable.getWriter();t.write(r.encode(o)),t.close();const e=n.readable.getReader(),s=[];for(;;){const{done:h,value:f}=await e.read();if(h)break;s.push(f)}const a=new Uint8Array(await new Blob(s).arrayBuffer()),c=btoa(String.fromCharCode(...a)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),l=new TextEncoder().encode(c).length;return console.log("SafeBase64 size (bytes):",l),c}async function ee(o){let r=(o||"").trim();r=r.replace(/\s+/g,""),r=r.replace(/-/g,"+").replace(/_/g,"/");const i=r.length%4;i===2?r+="==":i===3&&(r+="=");const n=atob(r),t=Uint8Array.from(n,a=>a.charCodeAt(0)),e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));return await new Response(e).text()}class ne{constructor(){this._playerId=null,this._dataChannel=null,this._pc=new RTCPeerConnection,this._pc.ondatachannel=r=>{this._dataChannel=r.channel,this._dataChannel.onopen=()=>{if(this._playerId&&this._dataChannel){const i={playerId:this._playerId,action:"JOIN",timestamp:Date.now()};this._dataChannel.send(JSON.stringify(i))}}},window.addEventListener("beforeunload",()=>{if(this._dataChannel&&this._dataChannel.readyState==="open"&&this._playerId){const r={playerId:this._playerId,action:"LEAVE",button:"",timestamp:Date.now()};try{this._dataChannel.send(JSON.stringify(r))}catch{}}})}async joinMatch(){const i=new URLSearchParams(window.location.search).get("remoteSDP");if(!i)throw new Error("No remoteSDP found in URL parameters.");const n=await ee(i),t=JSON.parse(n);this._playerId=t.playerId;const e=t.sdp;if(await this._pc.setRemoteDescription(e),e.type==="offer"){const s=await this._pc.createAnswer();await this._pc.setLocalDescription(s),await new Promise(f=>{this._pc.onicecandidate=d=>{d.candidate||f(void 0)}});const a={playerId:this._playerId,sdp:this._pc.localDescription},u=JSON.stringify(a),c=btoa(u),l=new BroadcastChannel("touch-coop-signaling"),h={type:"answer",playerId:this._playerId,base64Answer:c};l.postMessage(h),l.close()}}async sendMove(r){if(this._dataChannel&&this._dataChannel.readyState==="open"){if(!this._playerId)throw new Error("Player ID is not set. Cannot send data.");const i={playerId:this._playerId,action:"MOVE",button:r,timestamp:Date.now()},n=JSON.stringify(i);this._dataChannel.send(n)}else console.warn("Data channel is not open. Cannot send data.")}}function re(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var k={},H,Ct;function oe(){return Ct||(Ct=1,H=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),H}var Y={},L={},Et;function q(){if(Et)return L;Et=1;let o;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return L.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},L.getSymbolTotalCodewords=function(n){return r[n]},L.getBCHDigit=function(i){let n=0;for(;i!==0;)n++,i>>>=1;return n},L.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');o=n},L.isKanjiModeEnabled=function(){return typeof o<"u"},L.toSJIS=function(n){return o(n)},L}var x={},Bt;function G(){return Bt||(Bt=1,(function(o){o.L={bit:1},o.M={bit:0},o.Q={bit:3},o.H={bit:2};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return o.L;case"m":case"medium":return o.M;case"q":case"quartile":return o.Q;case"h":case"high":return o.H;default:throw new Error("Unknown EC Level: "+i)}}o.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},o.from=function(n,t){if(o.isValid(n))return n;try{return r(n)}catch{return t}}})(x)),x}var Q,It;function ie(){if(It)return Q;It=1;function o(){this.buffer=[],this.length=0}return o.prototype={get:function(r){const i=Math.floor(r/8);return(this.buffer[i]>>>7-r%8&1)===1},put:function(r,i){for(let n=0;n<i;n++)this.putBit((r>>>i-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),r&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Q=o,Q}var W,At;function se(){if(At)return W;At=1;function o(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return o.prototype.set=function(r,i,n,t){const e=r*this.size+i;this.data[e]=n,t&&(this.reservedBit[e]=!0)},o.prototype.get=function(r,i){return this.data[r*this.size+i]},o.prototype.xor=function(r,i,n){this.data[r*this.size+i]^=n},o.prototype.isReserved=function(r,i){return this.reservedBit[r*this.size+i]},W=o,W}var Z={},Rt;function ae(){return Rt||(Rt=1,(function(o){const r=q().getSymbolSize;o.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,e=r(n),s=e===145?26:Math.ceil((e-13)/(2*t-2))*2,a=[e-7];for(let u=1;u<t-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},o.getPositions=function(n){const t=[],e=o.getRowColCoords(n),s=e.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||t.push([e[a],e[u]]);return t}})(Z)),Z}var X={},St;function ue(){if(St)return X;St=1;const o=q().getSymbolSize,r=7;return X.getPositions=function(n){const t=o(n);return[[0,0],[t-r,0],[0,t-r]]},X}var $={},Pt;function ce(){return Pt||(Pt=1,(function(o){o.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};o.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},o.from=function(t){return o.isValid(t)?parseInt(t,10):void 0},o.getPenaltyN1=function(t){const e=t.size;let s=0,a=0,u=0,c=null,l=null;for(let h=0;h<e;h++){a=u=0,c=l=null;for(let f=0;f<e;f++){let d=t.get(h,f);d===c?a++:(a>=5&&(s+=r.N1+(a-5)),c=d,a=1),d=t.get(f,h),d===l?u++:(u>=5&&(s+=r.N1+(u-5)),l=d,u=1)}a>=5&&(s+=r.N1+(a-5)),u>=5&&(s+=r.N1+(u-5))}return s},o.getPenaltyN2=function(t){const e=t.size;let s=0;for(let a=0;a<e-1;a++)for(let u=0;u<e-1;u++){const c=t.get(a,u)+t.get(a,u+1)+t.get(a+1,u)+t.get(a+1,u+1);(c===4||c===0)&&s++}return s*r.N2},o.getPenaltyN3=function(t){const e=t.size;let s=0,a=0,u=0;for(let c=0;c<e;c++){a=u=0;for(let l=0;l<e;l++)a=a<<1&2047|t.get(c,l),l>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|t.get(l,c),l>=10&&(u===1488||u===93)&&s++}return s*r.N3},o.getPenaltyN4=function(t){let e=0;const s=t.data.length;for(let u=0;u<s;u++)e+=t.data[u];return Math.abs(Math.ceil(e*100/s/5)-10)*r.N4};function i(n,t,e){switch(n){case o.Patterns.PATTERN000:return(t+e)%2===0;case o.Patterns.PATTERN001:return t%2===0;case o.Patterns.PATTERN010:return e%3===0;case o.Patterns.PATTERN011:return(t+e)%3===0;case o.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(e/3))%2===0;case o.Patterns.PATTERN101:return t*e%2+t*e%3===0;case o.Patterns.PATTERN110:return(t*e%2+t*e%3)%2===0;case o.Patterns.PATTERN111:return(t*e%3+(t+e)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}o.applyMask=function(t,e){const s=e.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)e.isReserved(u,a)||e.xor(u,a,i(t,u,a))},o.getBestMask=function(t,e){const s=Object.keys(o.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){e(c),o.applyMask(c,t);const l=o.getPenaltyN1(t)+o.getPenaltyN2(t)+o.getPenaltyN3(t)+o.getPenaltyN4(t);o.applyMask(c,t),l<u&&(u=l,a=c)}return a}})($)),$}var j={},bt;function Nt(){if(bt)return j;bt=1;const o=G(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return j.getBlocksCount=function(t,e){switch(e){case o.L:return r[(t-1)*4+0];case o.M:return r[(t-1)*4+1];case o.Q:return r[(t-1)*4+2];case o.H:return r[(t-1)*4+3];default:return}},j.getTotalCodewordsCount=function(t,e){switch(e){case o.L:return i[(t-1)*4+0];case o.M:return i[(t-1)*4+1];case o.Q:return i[(t-1)*4+2];case o.H:return i[(t-1)*4+3];default:return}},j}var tt={},z={},Mt;function le(){if(Mt)return z;Mt=1;const o=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)o[t]=n,r[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)o[t]=o[t-255]})(),z.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},z.exp=function(n){return o[n]},z.mul=function(n,t){return n===0||t===0?0:o[r[n]+r[t]]},z}var Tt;function fe(){return Tt||(Tt=1,(function(o){const r=le();o.mul=function(n,t){const e=new Uint8Array(n.length+t.length-1);for(let s=0;s<n.length;s++)for(let a=0;a<t.length;a++)e[s+a]^=r.mul(n[s],t[a]);return e},o.mod=function(n,t){let e=new Uint8Array(n);for(;e.length-t.length>=0;){const s=e[0];for(let u=0;u<t.length;u++)e[u]^=r.mul(t[u],s);let a=0;for(;a<e.length&&e[a]===0;)a++;e=e.slice(a)}return e},o.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let e=0;e<n;e++)t=o.mul(t,new Uint8Array([1,r.exp(e)]));return t}})(tt)),tt}var et,_t;function de(){if(_t)return et;_t=1;const o=fe();function r(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=o.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const e=o.mod(t,this.genPoly),s=this.degree-e.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(e,s),a}return e},et=r,et}var nt={},rt={},ot={},Dt;function vt(){return Dt||(Dt=1,ot.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),ot}var _={},Lt;function Ut(){if(Lt)return _;Lt=1;const o="[0-9]+",r="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
2
+ ]))+`;_.KANJI=new RegExp(i,"g"),_.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),_.BYTE=new RegExp(n,"g"),_.NUMERIC=new RegExp(o,"g"),_.ALPHANUMERIC=new RegExp(r,"g");const t=new RegExp("^"+i+"$"),e=new RegExp("^"+o+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return _.testKanji=function(u){return t.test(u)},_.testNumeric=function(u){return e.test(u)},_.testAlphanumeric=function(u){return s.test(u)},_}var qt;function F(){return qt||(qt=1,(function(o){const r=vt(),i=Ut();o.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},o.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},o.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},o.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},o.MIXED={bit:-1},o.getCharCountIndicator=function(e,s){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!r.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?e.ccBits[0]:s<27?e.ccBits[1]:e.ccBits[2]},o.getBestModeForData=function(e){return i.testNumeric(e)?o.NUMERIC:i.testAlphanumeric(e)?o.ALPHANUMERIC:i.testKanji(e)?o.KANJI:o.BYTE},o.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},o.isValid=function(e){return e&&e.bit&&e.ccBits};function n(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return o.NUMERIC;case"alphanumeric":return o.ALPHANUMERIC;case"kanji":return o.KANJI;case"byte":return o.BYTE;default:throw new Error("Unknown mode: "+t)}}o.from=function(e,s){if(o.isValid(e))return e;try{return n(e)}catch{return s}}})(rt)),rt}var Ft;function he(){return Ft||(Ft=1,(function(o){const r=q(),i=Nt(),n=G(),t=F(),e=vt(),s=7973,a=r.getBCHDigit(s);function u(f,d,P){for(let b=1;b<=40;b++)if(d<=o.getCapacity(b,P,f))return b}function c(f,d){return t.getCharCountIndicator(f,d)+4}function l(f,d){let P=0;return f.forEach(function(b){const M=c(b.mode,d);P+=M+b.getBitsLength()}),P}function h(f,d){for(let P=1;P<=40;P++)if(l(f,P)<=o.getCapacity(P,d,t.MIXED))return P}o.from=function(d,P){return e.isValid(d)?parseInt(d,10):P},o.getCapacity=function(d,P,b){if(!e.isValid(d))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=t.BYTE);const M=r.getSymbolTotalCodewords(d),A=i.getTotalCodewordsCount(d,P),N=(M-A)*8;if(b===t.MIXED)return N;const R=N-c(b,d);switch(b){case t.NUMERIC:return Math.floor(R/10*3);case t.ALPHANUMERIC:return Math.floor(R/11*2);case t.KANJI:return Math.floor(R/13);case t.BYTE:default:return Math.floor(R/8)}},o.getBestVersionForData=function(d,P){let b;const M=n.from(P,n.M);if(Array.isArray(d)){if(d.length>1)return h(d,M);if(d.length===0)return 1;b=d[0]}else b=d;return u(b.mode,b.getLength(),M)},o.getEncodedBits=function(d){if(!e.isValid(d)||d<7)throw new Error("Invalid QR Code version");let P=d<<12;for(;r.getBCHDigit(P)-a>=0;)P^=s<<r.getBCHDigit(P)-a;return d<<12|P}})(nt)),nt}var it={},kt;function ge(){if(kt)return it;kt=1;const o=q(),r=1335,i=21522,n=o.getBCHDigit(r);return it.getEncodedBits=function(e,s){const a=e.bit<<3|s;let u=a<<10;for(;o.getBCHDigit(u)-n>=0;)u^=r<<o.getBCHDigit(u)-n;return(a<<10|u)^i},it}var st={},at,Ot;function we(){if(Ot)return at;Ot=1;const o=F();function r(i){this.mode=o.NUMERIC,this.data=i.toString()}return r.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let t,e,s;for(t=0;t+3<=this.data.length;t+=3)e=this.data.substr(t,3),s=parseInt(e,10),n.put(s,10);const a=this.data.length-t;a>0&&(e=this.data.substr(t),s=parseInt(e,10),n.put(s,a*3+1))},at=r,at}var ut,zt;function me(){if(zt)return ut;zt=1;const o=F(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(n){this.mode=o.ALPHANUMERIC,this.data=n}return i.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let s=r.indexOf(this.data[e])*45;s+=r.indexOf(this.data[e+1]),t.put(s,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},ut=i,ut}var ct,Jt;function ye(){if(Jt)return ct;Jt=1;const o=F();function r(i){this.mode=o.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return r.getBitsLength=function(n){return n*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(i){for(let n=0,t=this.data.length;n<t;n++)i.put(this.data[n],8)},ct=r,ct}var lt,Vt;function pe(){if(Vt)return lt;Vt=1;const o=F(),r=q();function i(n){this.mode=o.KANJI,this.data=n}return i.getBitsLength=function(t){return t*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(n){let t;for(t=0;t<this.data.length;t++){let e=r.toSJIS(this.data[t]);if(e>=33088&&e<=40956)e-=33088;else if(e>=57408&&e<=60351)e-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
3
+ Make sure your charset is UTF-8`);e=(e>>>8&255)*192+(e&255),n.put(e,13)}},lt=i,lt}var ft={exports:{}},jt;function Ce(){return jt||(jt=1,(function(o){var r={single_source_shortest_paths:function(i,n,t){var e={},s={};s[n]=0;var a=r.PriorityQueue.make();a.push(n,0);for(var u,c,l,h,f,d,P,b,M;!a.empty();){u=a.pop(),c=u.value,h=u.cost,f=i[c]||{};for(l in f)f.hasOwnProperty(l)&&(d=f[l],P=h+d,b=s[l],M=typeof s[l]>"u",(M||b>P)&&(s[l]=P,a.push(l,P),e[l]=c))}if(typeof t<"u"&&typeof s[t]>"u"){var A=["Could not find a path from ",n," to ",t,"."].join("");throw new Error(A)}return e},extract_shortest_path_from_predecessor_list:function(i,n){for(var t=[],e=n;e;)t.push(e),i[e],e=i[e];return t.reverse(),t},find_path:function(i,n,t){var e=r.single_source_shortest_paths(i,n,t);return r.extract_shortest_path_from_predecessor_list(e,t)},PriorityQueue:{make:function(i){var n=r.PriorityQueue,t={},e;i=i||{};for(e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t.queue=[],t.sorter=i.sorter||n.default_sorter,t},default_sorter:function(i,n){return i.cost-n.cost},push:function(i,n){var t={value:i,cost:n};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};o.exports=r})(ft)),ft.exports}var Kt;function Ee(){return Kt||(Kt=1,(function(o){const r=F(),i=we(),n=me(),t=ye(),e=pe(),s=Ut(),a=q(),u=Ce();function c(A){return unescape(encodeURIComponent(A)).length}function l(A,N,R){const B=[];let T;for(;(T=A.exec(R))!==null;)B.push({data:T[0],index:T.index,mode:N,length:T[0].length});return B}function h(A){const N=l(s.NUMERIC,r.NUMERIC,A),R=l(s.ALPHANUMERIC,r.ALPHANUMERIC,A);let B,T;return a.isKanjiModeEnabled()?(B=l(s.BYTE,r.BYTE,A),T=l(s.KANJI,r.KANJI,A)):(B=l(s.BYTE_KANJI,r.BYTE,A),T=[]),N.concat(R,B,T).sort(function(C,p){return C.index-p.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function f(A,N){switch(N){case r.NUMERIC:return i.getBitsLength(A);case r.ALPHANUMERIC:return n.getBitsLength(A);case r.KANJI:return e.getBitsLength(A);case r.BYTE:return t.getBitsLength(A)}}function d(A){return A.reduce(function(N,R){const B=N.length-1>=0?N[N.length-1]:null;return B&&B.mode===R.mode?(N[N.length-1].data+=R.data,N):(N.push(R),N)},[])}function P(A){const N=[];for(let R=0;R<A.length;R++){const B=A[R];switch(B.mode){case r.NUMERIC:N.push([B,{data:B.data,mode:r.ALPHANUMERIC,length:B.length},{data:B.data,mode:r.BYTE,length:B.length}]);break;case r.ALPHANUMERIC:N.push([B,{data:B.data,mode:r.BYTE,length:B.length}]);break;case r.KANJI:N.push([B,{data:B.data,mode:r.BYTE,length:c(B.data)}]);break;case r.BYTE:N.push([{data:B.data,mode:r.BYTE,length:c(B.data)}])}}return N}function b(A,N){const R={},B={start:{}};let T=["start"];for(let w=0;w<A.length;w++){const C=A[w],p=[];for(let g=0;g<C.length;g++){const I=C[g],m=""+w+g;p.push(m),R[m]={node:I,lastCount:0},B[m]={};for(let E=0;E<T.length;E++){const y=T[E];R[y]&&R[y].node.mode===I.mode?(B[y][m]=f(R[y].lastCount+I.length,I.mode)-f(R[y].lastCount,I.mode),R[y].lastCount+=I.length):(R[y]&&(R[y].lastCount=I.length),B[y][m]=f(I.length,I.mode)+4+r.getCharCountIndicator(I.mode,N))}}T=p}for(let w=0;w<T.length;w++)B[T[w]].end=0;return{map:B,table:R}}function M(A,N){let R;const B=r.getBestModeForData(A);if(R=r.from(N,B),R!==r.BYTE&&R.bit<B.bit)throw new Error('"'+A+'" cannot be encoded with mode '+r.toString(R)+`.
4
+ Suggested mode is: `+r.toString(B));switch(R===r.KANJI&&!a.isKanjiModeEnabled()&&(R=r.BYTE),R){case r.NUMERIC:return new i(A);case r.ALPHANUMERIC:return new n(A);case r.KANJI:return new e(A);case r.BYTE:return new t(A)}}o.fromArray=function(N){return N.reduce(function(R,B){return typeof B=="string"?R.push(M(B,null)):B.data&&R.push(M(B.data,B.mode)),R},[])},o.fromString=function(N,R){const B=h(N,a.isKanjiModeEnabled()),T=P(B),w=b(T,R),C=u.find_path(w.map,"start","end"),p=[];for(let g=1;g<C.length-1;g++)p.push(w.table[C[g]].node);return o.fromArray(d(p))},o.rawSplit=function(N){return o.fromArray(h(N,a.isKanjiModeEnabled()))}})(st)),st}var Ht;function Be(){if(Ht)return Y;Ht=1;const o=q(),r=G(),i=ie(),n=se(),t=ae(),e=ue(),s=ce(),a=Nt(),u=de(),c=he(),l=ge(),h=F(),f=Ee();function d(w,C){const p=w.size,g=e.getPositions(C);for(let I=0;I<g.length;I++){const m=g[I][0],E=g[I][1];for(let y=-1;y<=7;y++)if(!(m+y<=-1||p<=m+y))for(let S=-1;S<=7;S++)E+S<=-1||p<=E+S||(y>=0&&y<=6&&(S===0||S===6)||S>=0&&S<=6&&(y===0||y===6)||y>=2&&y<=4&&S>=2&&S<=4?w.set(m+y,E+S,!0,!0):w.set(m+y,E+S,!1,!0))}}function P(w){const C=w.size;for(let p=8;p<C-8;p++){const g=p%2===0;w.set(p,6,g,!0),w.set(6,p,g,!0)}}function b(w,C){const p=t.getPositions(C);for(let g=0;g<p.length;g++){const I=p[g][0],m=p[g][1];for(let E=-2;E<=2;E++)for(let y=-2;y<=2;y++)E===-2||E===2||y===-2||y===2||E===0&&y===0?w.set(I+E,m+y,!0,!0):w.set(I+E,m+y,!1,!0)}}function M(w,C){const p=w.size,g=c.getEncodedBits(C);let I,m,E;for(let y=0;y<18;y++)I=Math.floor(y/3),m=y%3+p-8-3,E=(g>>y&1)===1,w.set(I,m,E,!0),w.set(m,I,E,!0)}function A(w,C,p){const g=w.size,I=l.getEncodedBits(C,p);let m,E;for(m=0;m<15;m++)E=(I>>m&1)===1,m<6?w.set(m,8,E,!0):m<8?w.set(m+1,8,E,!0):w.set(g-15+m,8,E,!0),m<8?w.set(8,g-m-1,E,!0):m<9?w.set(8,15-m-1+1,E,!0):w.set(8,15-m-1,E,!0);w.set(g-8,8,1,!0)}function N(w,C){const p=w.size;let g=-1,I=p-1,m=7,E=0;for(let y=p-1;y>0;y-=2)for(y===6&&y--;;){for(let S=0;S<2;S++)if(!w.isReserved(I,y-S)){let U=!1;E<C.length&&(U=(C[E]>>>m&1)===1),w.set(I,y-S,U),m--,m===-1&&(E++,m=7)}if(I+=g,I<0||p<=I){I-=g,g=-g;break}}}function R(w,C,p){const g=new i;p.forEach(function(S){g.put(S.mode.bit,4),g.put(S.getLength(),h.getCharCountIndicator(S.mode,w)),S.write(g)});const I=o.getSymbolTotalCodewords(w),m=a.getTotalCodewordsCount(w,C),E=(I-m)*8;for(g.getLengthInBits()+4<=E&&g.put(0,4);g.getLengthInBits()%8!==0;)g.putBit(0);const y=(E-g.getLengthInBits())/8;for(let S=0;S<y;S++)g.put(S%2?17:236,8);return B(g,w,C)}function B(w,C,p){const g=o.getSymbolTotalCodewords(C),I=a.getTotalCodewordsCount(C,p),m=g-I,E=a.getBlocksCount(C,p),y=g%E,S=E-y,U=Math.floor(g/E),J=Math.floor(m/E),Ne=J+1,Zt=U-J,Me=new u(Zt);let wt=0;const K=new Array(E),Xt=new Array(E);let mt=0;const Te=new Uint8Array(w.buffer);for(let O=0;O<E;O++){const pt=O<S?J:Ne;K[O]=Te.slice(wt,wt+pt),Xt[O]=Me.encode(K[O]),wt+=pt,mt=Math.max(mt,pt)}const yt=new Uint8Array(g);let $t=0,D,v;for(D=0;D<mt;D++)for(v=0;v<E;v++)D<K[v].length&&(yt[$t++]=K[v][D]);for(D=0;D<Zt;D++)for(v=0;v<E;v++)yt[$t++]=Xt[v][D];return yt}function T(w,C,p,g){let I;if(Array.isArray(w))I=f.fromArray(w);else if(typeof w=="string"){let U=C;if(!U){const J=f.rawSplit(w);U=c.getBestVersionForData(J,p)}I=f.fromString(w,U||40)}else throw new Error("Invalid data");const m=c.getBestVersionForData(I,p);if(!m)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=m;else if(C<m)throw new Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+m+`.
7
+ `);const E=R(C,p,I),y=o.getSymbolSize(C),S=new n(y);return d(S,C),P(S),b(S,C),A(S,p,0),C>=7&&M(S,C),N(S,E),isNaN(g)&&(g=s.getBestMask(S,A.bind(null,S,p))),s.applyMask(g,S),A(S,p,g),{modules:S,version:C,errorCorrectionLevel:p,maskPattern:g,segments:I}}return Y.create=function(C,p){if(typeof C>"u"||C==="")throw new Error("No input text");let g=r.M,I,m;return typeof p<"u"&&(g=r.from(p.errorCorrectionLevel,r.M),I=c.from(p.version),m=s.from(p.maskPattern),p.toSJISFunc&&o.setToSJISFunction(p.toSJISFunc)),T(C,I,g,m)},Y}var dt={},ht={},Yt;function xt(){return Yt||(Yt=1,(function(o){function r(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let n=i.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+i);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(e){return[e,e]}))),n.length===6&&n.push("F","F");const t=parseInt(n.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+n.slice(0,6).join("")}}o.getOptions=function(n){n||(n={}),n.color||(n.color={});const t=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,e=n.width&&n.width>=21?n.width:void 0,s=n.scale||4;return{width:e,scale:e?4:s,margin:t,color:{dark:r(n.color.dark||"#000000ff"),light:r(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},o.getScale=function(n,t){return t.width&&t.width>=n+t.margin*2?t.width/(n+t.margin*2):t.scale},o.getImageWidth=function(n,t){const e=o.getScale(n,t);return Math.floor((n+t.margin*2)*e)},o.qrToImageData=function(n,t,e){const s=t.modules.size,a=t.modules.data,u=o.getScale(s,e),c=Math.floor((s+e.margin*2)*u),l=e.margin*u,h=[e.color.light,e.color.dark];for(let f=0;f<c;f++)for(let d=0;d<c;d++){let P=(f*c+d)*4,b=e.color.light;if(f>=l&&d>=l&&f<c-l&&d<c-l){const M=Math.floor((f-l)/u),A=Math.floor((d-l)/u);b=h[a[M*s+A]?1:0]}n[P++]=b.r,n[P++]=b.g,n[P++]=b.b,n[P]=b.a}}})(ht)),ht}var Gt;function Ie(){return Gt||(Gt=1,(function(o){const r=xt();function i(t,e,s){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=s,e.width=s,e.style.height=s+"px",e.style.width=s+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}o.render=function(e,s,a){let u=a,c=s;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),s||(c=n()),u=r.getOptions(u);const l=r.getImageWidth(e.modules.size,u),h=c.getContext("2d"),f=h.createImageData(l,l);return r.qrToImageData(f.data,e,u),i(h,c,l),h.putImageData(f,0,0),c},o.renderToDataURL=function(e,s,a){let u=a;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),u||(u={});const c=o.render(e,s,u),l=u.type||"image/png",h=u.rendererOpts||{};return c.toDataURL(l,h.quality)}})(dt)),dt}var gt={},Qt;function Ae(){if(Qt)return gt;Qt=1;const o=xt();function r(t,e){const s=t.a/255,a=e+'="'+t.hex+'"';return s<1?a+" "+e+'-opacity="'+s.toFixed(2).slice(1)+'"':a}function i(t,e,s){let a=t+e;return typeof s<"u"&&(a+=" "+s),a}function n(t,e,s){let a="",u=0,c=!1,l=0;for(let h=0;h<t.length;h++){const f=Math.floor(h%e),d=Math.floor(h/e);!f&&!c&&(c=!0),t[h]?(l++,h>0&&f>0&&t[h-1]||(a+=c?i("M",f+s,.5+d+s):i("m",u,0),u=0,c=!1),f+1<e&&t[h+1]||(a+=i("h",l),l=0)):u++}return a}return gt.render=function(e,s,a){const u=o.getOptions(s),c=e.modules.size,l=e.modules.data,h=c+u.margin*2,f=u.color.light.a?"<path "+r(u.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",d="<path "+r(u.color.dark,"stroke")+' d="'+n(l,c,u.margin)+'"/>',P='viewBox="0 0 '+h+" "+h+'"',M='<svg xmlns="http://www.w3.org/2000/svg" '+(u.width?'width="'+u.width+'" height="'+u.width+'" ':"")+P+' shape-rendering="crispEdges">'+f+d+`</svg>
8
+ `;return typeof a=="function"&&a(null,M),M},gt}var Wt;function Re(){if(Wt)return k;Wt=1;const o=oe(),r=Be(),i=Ie(),n=Ae();function t(e,s,a,u,c){const l=[].slice.call(arguments,1),h=l.length,f=typeof l[h-1]=="function";if(!f&&!o())throw new Error("Callback required as last argument");if(f){if(h<2)throw new Error("Too few arguments provided");h===2?(c=a,a=s,s=u=void 0):h===3&&(s.getContext&&typeof c>"u"?(c=u,u=void 0):(c=u,u=a,a=s,s=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(a=s,s=u=void 0):h===2&&!s.getContext&&(u=a,a=s,s=void 0),new Promise(function(d,P){try{const b=r.create(a,u);d(e(b,s,u))}catch(b){P(b)}})}try{const d=r.create(a,u);c(null,e(d,s,u))}catch(d){c(d)}}return k.create=r.create,k.toCanvas=t.bind(null,i.render),k.toDataURL=t.bind(null,i.renderToDataURL),k.toString=t.bind(null,function(e,s,a){return n.render(e,a)}),k}var Se=Re();const Pe=re(Se);class be{constructor(r,i){this._playerConnections=new Map,this._playerChannels=new Map,this._invitationAccepted=new Map,this._onPlayerEvent=null,this._onPlayerEvent=i,this._gamepadUiUrl=r;const n=new BroadcastChannel("touch-coop-signaling");n.onmessage=async t=>{const e=t.data;if(e&&e.type==="answer"&&e.playerId&&e.base64Answer)try{const s=this._playerConnections.get(e.playerId);if(!s)throw new Error(`No peer connection for player: ${e.playerId}`);const a=JSON.parse(atob(e.base64Answer));await s.setRemoteDescription(a.sdp),this._invitationAccepted.set(e.playerId,!0)}catch{}}}_UUIID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=Math.random()*16|0;return(r==="x"?i:i&3|8).toString(16)})}async requestNewPlayerToJoin(){return new Promise((r,i)=>{(async()=>{const n=this._UUIID(),t=new RTCPeerConnection,e=t.createDataChannel("player");this._playerConnections.set(n,t),this._playerChannels.set(n,e),this._invitationAccepted.set(n,!1),e.onmessage=h=>{if(this._onPlayerEvent){let f=h.data;f=JSON.parse(h.data),this._onPlayerEvent(f)}};const s=await t.createOffer();await t.setLocalDescription(s),await new Promise(h=>{t.onicecandidate=f=>{f.candidate||h(void 0)}});const a={playerId:n,sdp:t.localDescription},u=JSON.stringify(a),c=await te(u),l=`${this._gamepadUiUrl}?remoteSDP=${c}`;Pe.toDataURL(l,{errorCorrectionLevel:"M"},(h,f)=>{if(h)return i(h);r({dataUrl:f,shareURL:l,playerId:n})})})()})}getInvitationStatus(r){return this._invitationAccepted.get(r)}async acceptPlayerAnswer(r,i){}}return V.Match=be,V.Player=ne,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),V})({});