@dsh-teamwork/dsh-teamwork 0.4.0 → 0.5.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/lib/web/client.js CHANGED
@@ -340,6 +340,7 @@ var PATHS = {
340
340
  session: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",
341
341
  settings: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z",
342
342
  shield: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",
343
+ smartphone: "M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM12 18h.01",
343
344
  sync: "M17 1l4 4-4 4M3 11V9a4 4 0 0 1 4-4h14M7 23l-4-4 4-4M21 13v2a4 4 0 0 1-4 4H3"
344
345
  };
345
346
  function Icon({ name, size = 16, label }) {
@@ -513,6 +514,1640 @@ function Toast({ tone = "neutral", children }) {
513
514
  ] });
514
515
  }
515
516
 
517
+ // node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs
518
+ var qrcode = function(typeNumber, errorCorrectionLevel) {
519
+ const PAD0 = 236;
520
+ const PAD1 = 17;
521
+ let _typeNumber = typeNumber;
522
+ const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
523
+ let _modules = null;
524
+ let _moduleCount = 0;
525
+ let _dataCache = null;
526
+ const _dataList = [];
527
+ const _this = {};
528
+ const makeImpl = function(test, maskPattern) {
529
+ _moduleCount = _typeNumber * 4 + 17;
530
+ _modules = (function(moduleCount) {
531
+ const modules = new Array(moduleCount);
532
+ for (let row = 0; row < moduleCount; row += 1) {
533
+ modules[row] = new Array(moduleCount);
534
+ for (let col = 0; col < moduleCount; col += 1) {
535
+ modules[row][col] = null;
536
+ }
537
+ }
538
+ return modules;
539
+ })(_moduleCount);
540
+ setupPositionProbePattern(0, 0);
541
+ setupPositionProbePattern(_moduleCount - 7, 0);
542
+ setupPositionProbePattern(0, _moduleCount - 7);
543
+ setupPositionAdjustPattern();
544
+ setupTimingPattern();
545
+ setupTypeInfo(test, maskPattern);
546
+ if (_typeNumber >= 7) {
547
+ setupTypeNumber(test);
548
+ }
549
+ if (_dataCache == null) {
550
+ _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
551
+ }
552
+ mapData(_dataCache, maskPattern);
553
+ };
554
+ const setupPositionProbePattern = function(row, col) {
555
+ for (let r = -1; r <= 7; r += 1) {
556
+ if (row + r <= -1 || _moduleCount <= row + r) continue;
557
+ for (let c = -1; c <= 7; c += 1) {
558
+ if (col + c <= -1 || _moduleCount <= col + c) continue;
559
+ if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
560
+ _modules[row + r][col + c] = true;
561
+ } else {
562
+ _modules[row + r][col + c] = false;
563
+ }
564
+ }
565
+ }
566
+ };
567
+ const getBestMaskPattern = function() {
568
+ let minLostPoint = 0;
569
+ let pattern = 0;
570
+ for (let i = 0; i < 8; i += 1) {
571
+ makeImpl(true, i);
572
+ const lostPoint = QRUtil.getLostPoint(_this);
573
+ if (i == 0 || minLostPoint > lostPoint) {
574
+ minLostPoint = lostPoint;
575
+ pattern = i;
576
+ }
577
+ }
578
+ return pattern;
579
+ };
580
+ const setupTimingPattern = function() {
581
+ for (let r = 8; r < _moduleCount - 8; r += 1) {
582
+ if (_modules[r][6] != null) {
583
+ continue;
584
+ }
585
+ _modules[r][6] = r % 2 == 0;
586
+ }
587
+ for (let c = 8; c < _moduleCount - 8; c += 1) {
588
+ if (_modules[6][c] != null) {
589
+ continue;
590
+ }
591
+ _modules[6][c] = c % 2 == 0;
592
+ }
593
+ };
594
+ const setupPositionAdjustPattern = function() {
595
+ const pos = QRUtil.getPatternPosition(_typeNumber);
596
+ for (let i = 0; i < pos.length; i += 1) {
597
+ for (let j = 0; j < pos.length; j += 1) {
598
+ const row = pos[i];
599
+ const col = pos[j];
600
+ if (_modules[row][col] != null) {
601
+ continue;
602
+ }
603
+ for (let r = -2; r <= 2; r += 1) {
604
+ for (let c = -2; c <= 2; c += 1) {
605
+ if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
606
+ _modules[row + r][col + c] = true;
607
+ } else {
608
+ _modules[row + r][col + c] = false;
609
+ }
610
+ }
611
+ }
612
+ }
613
+ }
614
+ };
615
+ const setupTypeNumber = function(test) {
616
+ const bits = QRUtil.getBCHTypeNumber(_typeNumber);
617
+ for (let i = 0; i < 18; i += 1) {
618
+ const mod = !test && (bits >> i & 1) == 1;
619
+ _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
620
+ }
621
+ for (let i = 0; i < 18; i += 1) {
622
+ const mod = !test && (bits >> i & 1) == 1;
623
+ _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
624
+ }
625
+ };
626
+ const setupTypeInfo = function(test, maskPattern) {
627
+ const data = _errorCorrectionLevel << 3 | maskPattern;
628
+ const bits = QRUtil.getBCHTypeInfo(data);
629
+ for (let i = 0; i < 15; i += 1) {
630
+ const mod = !test && (bits >> i & 1) == 1;
631
+ if (i < 6) {
632
+ _modules[i][8] = mod;
633
+ } else if (i < 8) {
634
+ _modules[i + 1][8] = mod;
635
+ } else {
636
+ _modules[_moduleCount - 15 + i][8] = mod;
637
+ }
638
+ }
639
+ for (let i = 0; i < 15; i += 1) {
640
+ const mod = !test && (bits >> i & 1) == 1;
641
+ if (i < 8) {
642
+ _modules[8][_moduleCount - i - 1] = mod;
643
+ } else if (i < 9) {
644
+ _modules[8][15 - i - 1 + 1] = mod;
645
+ } else {
646
+ _modules[8][15 - i - 1] = mod;
647
+ }
648
+ }
649
+ _modules[_moduleCount - 8][8] = !test;
650
+ };
651
+ const mapData = function(data, maskPattern) {
652
+ let inc = -1;
653
+ let row = _moduleCount - 1;
654
+ let bitIndex = 7;
655
+ let byteIndex = 0;
656
+ const maskFunc = QRUtil.getMaskFunction(maskPattern);
657
+ for (let col = _moduleCount - 1; col > 0; col -= 2) {
658
+ if (col == 6) col -= 1;
659
+ while (true) {
660
+ for (let c = 0; c < 2; c += 1) {
661
+ if (_modules[row][col - c] == null) {
662
+ let dark = false;
663
+ if (byteIndex < data.length) {
664
+ dark = (data[byteIndex] >>> bitIndex & 1) == 1;
665
+ }
666
+ const mask = maskFunc(row, col - c);
667
+ if (mask) {
668
+ dark = !dark;
669
+ }
670
+ _modules[row][col - c] = dark;
671
+ bitIndex -= 1;
672
+ if (bitIndex == -1) {
673
+ byteIndex += 1;
674
+ bitIndex = 7;
675
+ }
676
+ }
677
+ }
678
+ row += inc;
679
+ if (row < 0 || _moduleCount <= row) {
680
+ row -= inc;
681
+ inc = -inc;
682
+ break;
683
+ }
684
+ }
685
+ }
686
+ };
687
+ const createBytes = function(buffer, rsBlocks) {
688
+ let offset = 0;
689
+ let maxDcCount = 0;
690
+ let maxEcCount = 0;
691
+ const dcdata = new Array(rsBlocks.length);
692
+ const ecdata = new Array(rsBlocks.length);
693
+ for (let r = 0; r < rsBlocks.length; r += 1) {
694
+ const dcCount = rsBlocks[r].dataCount;
695
+ const ecCount = rsBlocks[r].totalCount - dcCount;
696
+ maxDcCount = Math.max(maxDcCount, dcCount);
697
+ maxEcCount = Math.max(maxEcCount, ecCount);
698
+ dcdata[r] = new Array(dcCount);
699
+ for (let i = 0; i < dcdata[r].length; i += 1) {
700
+ dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
701
+ }
702
+ offset += dcCount;
703
+ const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
704
+ const rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
705
+ const modPoly = rawPoly.mod(rsPoly);
706
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
707
+ for (let i = 0; i < ecdata[r].length; i += 1) {
708
+ const modIndex = i + modPoly.getLength() - ecdata[r].length;
709
+ ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
710
+ }
711
+ }
712
+ let totalCodeCount = 0;
713
+ for (let i = 0; i < rsBlocks.length; i += 1) {
714
+ totalCodeCount += rsBlocks[i].totalCount;
715
+ }
716
+ const data = new Array(totalCodeCount);
717
+ let index = 0;
718
+ for (let i = 0; i < maxDcCount; i += 1) {
719
+ for (let r = 0; r < rsBlocks.length; r += 1) {
720
+ if (i < dcdata[r].length) {
721
+ data[index] = dcdata[r][i];
722
+ index += 1;
723
+ }
724
+ }
725
+ }
726
+ for (let i = 0; i < maxEcCount; i += 1) {
727
+ for (let r = 0; r < rsBlocks.length; r += 1) {
728
+ if (i < ecdata[r].length) {
729
+ data[index] = ecdata[r][i];
730
+ index += 1;
731
+ }
732
+ }
733
+ }
734
+ return data;
735
+ };
736
+ const createData = function(typeNumber2, errorCorrectionLevel2, dataList) {
737
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
738
+ const buffer = qrBitBuffer();
739
+ for (let i = 0; i < dataList.length; i += 1) {
740
+ const data = dataList[i];
741
+ buffer.put(data.getMode(), 4);
742
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
743
+ data.write(buffer);
744
+ }
745
+ let totalDataCount = 0;
746
+ for (let i = 0; i < rsBlocks.length; i += 1) {
747
+ totalDataCount += rsBlocks[i].dataCount;
748
+ }
749
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
750
+ throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
751
+ }
752
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
753
+ buffer.put(0, 4);
754
+ }
755
+ while (buffer.getLengthInBits() % 8 != 0) {
756
+ buffer.putBit(false);
757
+ }
758
+ while (true) {
759
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
760
+ break;
761
+ }
762
+ buffer.put(PAD0, 8);
763
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
764
+ break;
765
+ }
766
+ buffer.put(PAD1, 8);
767
+ }
768
+ return createBytes(buffer, rsBlocks);
769
+ };
770
+ _this.addData = function(data, mode) {
771
+ mode = mode || "Byte";
772
+ let newData = null;
773
+ switch (mode) {
774
+ case "Numeric":
775
+ newData = qrNumber(data);
776
+ break;
777
+ case "Alphanumeric":
778
+ newData = qrAlphaNum(data);
779
+ break;
780
+ case "Byte":
781
+ newData = qr8BitByte(data);
782
+ break;
783
+ case "Kanji":
784
+ newData = qrKanji(data);
785
+ break;
786
+ default:
787
+ throw "mode:" + mode;
788
+ }
789
+ _dataList.push(newData);
790
+ _dataCache = null;
791
+ };
792
+ _this.isDark = function(row, col) {
793
+ if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
794
+ throw row + "," + col;
795
+ }
796
+ return _modules[row][col];
797
+ };
798
+ _this.getModuleCount = function() {
799
+ return _moduleCount;
800
+ };
801
+ _this.make = function() {
802
+ if (_typeNumber < 1) {
803
+ let typeNumber2 = 1;
804
+ for (; typeNumber2 < 40; typeNumber2++) {
805
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
806
+ const buffer = qrBitBuffer();
807
+ for (let i = 0; i < _dataList.length; i++) {
808
+ const data = _dataList[i];
809
+ buffer.put(data.getMode(), 4);
810
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
811
+ data.write(buffer);
812
+ }
813
+ let totalDataCount = 0;
814
+ for (let i = 0; i < rsBlocks.length; i++) {
815
+ totalDataCount += rsBlocks[i].dataCount;
816
+ }
817
+ if (buffer.getLengthInBits() <= totalDataCount * 8) {
818
+ break;
819
+ }
820
+ }
821
+ _typeNumber = typeNumber2;
822
+ }
823
+ makeImpl(false, getBestMaskPattern());
824
+ };
825
+ _this.createTableTag = function(cellSize, margin) {
826
+ cellSize = cellSize || 2;
827
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
828
+ let qrHtml = "";
829
+ qrHtml += '<table style="';
830
+ qrHtml += " border-width: 0px; border-style: none;";
831
+ qrHtml += " border-collapse: collapse;";
832
+ qrHtml += " padding: 0px; margin: " + margin + "px;";
833
+ qrHtml += '">';
834
+ qrHtml += "<tbody>";
835
+ for (let r = 0; r < _this.getModuleCount(); r += 1) {
836
+ qrHtml += "<tr>";
837
+ for (let c = 0; c < _this.getModuleCount(); c += 1) {
838
+ qrHtml += '<td style="';
839
+ qrHtml += " border-width: 0px; border-style: none;";
840
+ qrHtml += " border-collapse: collapse;";
841
+ qrHtml += " padding: 0px; margin: 0px;";
842
+ qrHtml += " width: " + cellSize + "px;";
843
+ qrHtml += " height: " + cellSize + "px;";
844
+ qrHtml += " background-color: ";
845
+ qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
846
+ qrHtml += ";";
847
+ qrHtml += '"/>';
848
+ }
849
+ qrHtml += "</tr>";
850
+ }
851
+ qrHtml += "</tbody>";
852
+ qrHtml += "</table>";
853
+ return qrHtml;
854
+ };
855
+ _this.createSvgTag = function(cellSize, margin, alt, title) {
856
+ let opts = {};
857
+ if (typeof arguments[0] == "object") {
858
+ opts = arguments[0];
859
+ cellSize = opts.cellSize;
860
+ margin = opts.margin;
861
+ alt = opts.alt;
862
+ title = opts.title;
863
+ }
864
+ cellSize = cellSize || 2;
865
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
866
+ alt = typeof alt === "string" ? { text: alt } : alt || {};
867
+ alt.text = alt.text || null;
868
+ alt.id = alt.text ? alt.id || "qrcode-description" : null;
869
+ title = typeof title === "string" ? { text: title } : title || {};
870
+ title.text = title.text || null;
871
+ title.id = title.text ? title.id || "qrcode-title" : null;
872
+ const size = _this.getModuleCount() * cellSize + margin * 2;
873
+ let c, mc, r, mr, qrSvg = "", rect;
874
+ rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
875
+ qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
876
+ qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
877
+ qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
878
+ qrSvg += ' preserveAspectRatio="xMinYMin meet"';
879
+ qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
880
+ qrSvg += ">";
881
+ qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
882
+ qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
883
+ qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
884
+ qrSvg += '<path d="';
885
+ for (r = 0; r < _this.getModuleCount(); r += 1) {
886
+ mr = r * cellSize + margin;
887
+ for (c = 0; c < _this.getModuleCount(); c += 1) {
888
+ if (_this.isDark(r, c)) {
889
+ mc = c * cellSize + margin;
890
+ qrSvg += "M" + mc + "," + mr + rect;
891
+ }
892
+ }
893
+ }
894
+ qrSvg += '" stroke="transparent" fill="black"/>';
895
+ qrSvg += "</svg>";
896
+ return qrSvg;
897
+ };
898
+ _this.createDataURL = function(cellSize, margin) {
899
+ cellSize = cellSize || 2;
900
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
901
+ const size = _this.getModuleCount() * cellSize + margin * 2;
902
+ const min = margin;
903
+ const max = size - margin;
904
+ return createDataURL(size, size, function(x, y) {
905
+ if (min <= x && x < max && min <= y && y < max) {
906
+ const c = Math.floor((x - min) / cellSize);
907
+ const r = Math.floor((y - min) / cellSize);
908
+ return _this.isDark(r, c) ? 0 : 1;
909
+ } else {
910
+ return 1;
911
+ }
912
+ });
913
+ };
914
+ _this.createImgTag = function(cellSize, margin, alt) {
915
+ cellSize = cellSize || 2;
916
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
917
+ const size = _this.getModuleCount() * cellSize + margin * 2;
918
+ let img = "";
919
+ img += "<img";
920
+ img += ' src="';
921
+ img += _this.createDataURL(cellSize, margin);
922
+ img += '"';
923
+ img += ' width="';
924
+ img += size;
925
+ img += '"';
926
+ img += ' height="';
927
+ img += size;
928
+ img += '"';
929
+ if (alt) {
930
+ img += ' alt="';
931
+ img += escapeXml(alt);
932
+ img += '"';
933
+ }
934
+ img += "/>";
935
+ return img;
936
+ };
937
+ const escapeXml = function(s) {
938
+ let escaped = "";
939
+ for (let i = 0; i < s.length; i += 1) {
940
+ const c = s.charAt(i);
941
+ switch (c) {
942
+ case "<":
943
+ escaped += "&lt;";
944
+ break;
945
+ case ">":
946
+ escaped += "&gt;";
947
+ break;
948
+ case "&":
949
+ escaped += "&amp;";
950
+ break;
951
+ case '"':
952
+ escaped += "&quot;";
953
+ break;
954
+ default:
955
+ escaped += c;
956
+ break;
957
+ }
958
+ }
959
+ return escaped;
960
+ };
961
+ const _createHalfASCII = function(margin) {
962
+ const cellSize = 1;
963
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
964
+ const size = _this.getModuleCount() * cellSize + margin * 2;
965
+ const min = margin;
966
+ const max = size - margin;
967
+ let y, x, r1, r2, p;
968
+ const blocks = {
969
+ "██": "█",
970
+ "█ ": "▀",
971
+ " █": "▄",
972
+ " ": " "
973
+ };
974
+ const blocksLastLineNoMargin = {
975
+ "██": "▀",
976
+ "█ ": "▀",
977
+ " █": " ",
978
+ " ": " "
979
+ };
980
+ let ascii = "";
981
+ for (y = 0; y < size; y += 2) {
982
+ r1 = Math.floor((y - min) / cellSize);
983
+ r2 = Math.floor((y + 1 - min) / cellSize);
984
+ for (x = 0; x < size; x += 1) {
985
+ p = "█";
986
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
987
+ p = " ";
988
+ }
989
+ if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
990
+ p += " ";
991
+ } else {
992
+ p += "█";
993
+ }
994
+ ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
995
+ }
996
+ ascii += "\n";
997
+ }
998
+ if (size % 2 && margin > 0) {
999
+ return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("▀");
1000
+ }
1001
+ return ascii.substring(0, ascii.length - 1);
1002
+ };
1003
+ _this.createASCII = function(cellSize, margin) {
1004
+ cellSize = cellSize || 1;
1005
+ if (cellSize < 2) {
1006
+ return _createHalfASCII(margin);
1007
+ }
1008
+ cellSize -= 1;
1009
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
1010
+ const size = _this.getModuleCount() * cellSize + margin * 2;
1011
+ const min = margin;
1012
+ const max = size - margin;
1013
+ let y, x, r, p;
1014
+ const white = Array(cellSize + 1).join("██");
1015
+ const black = Array(cellSize + 1).join(" ");
1016
+ let ascii = "";
1017
+ let line = "";
1018
+ for (y = 0; y < size; y += 1) {
1019
+ r = Math.floor((y - min) / cellSize);
1020
+ line = "";
1021
+ for (x = 0; x < size; x += 1) {
1022
+ p = 1;
1023
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
1024
+ p = 0;
1025
+ }
1026
+ line += p ? white : black;
1027
+ }
1028
+ for (r = 0; r < cellSize; r += 1) {
1029
+ ascii += line + "\n";
1030
+ }
1031
+ }
1032
+ return ascii.substring(0, ascii.length - 1);
1033
+ };
1034
+ _this.renderTo2dContext = function(context, cellSize) {
1035
+ cellSize = cellSize || 2;
1036
+ const length = _this.getModuleCount();
1037
+ for (let row = 0; row < length; row++) {
1038
+ for (let col = 0; col < length; col++) {
1039
+ context.fillStyle = _this.isDark(row, col) ? "black" : "white";
1040
+ context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
1041
+ }
1042
+ }
1043
+ };
1044
+ return _this;
1045
+ };
1046
+ qrcode.stringToBytes = function(s) {
1047
+ const bytes = [];
1048
+ for (let i = 0; i < s.length; i += 1) {
1049
+ const c = s.charCodeAt(i);
1050
+ bytes.push(c & 255);
1051
+ }
1052
+ return bytes;
1053
+ };
1054
+ qrcode.createStringToBytes = function(unicodeData, numChars) {
1055
+ const unicodeMap = (function() {
1056
+ const bin = base64DecodeInputStream(unicodeData);
1057
+ const read = function() {
1058
+ const b = bin.read();
1059
+ if (b == -1) throw "eof";
1060
+ return b;
1061
+ };
1062
+ let count = 0;
1063
+ const unicodeMap2 = {};
1064
+ while (true) {
1065
+ const b0 = bin.read();
1066
+ if (b0 == -1) break;
1067
+ const b1 = read();
1068
+ const b2 = read();
1069
+ const b3 = read();
1070
+ const k = String.fromCharCode(b0 << 8 | b1);
1071
+ const v = b2 << 8 | b3;
1072
+ unicodeMap2[k] = v;
1073
+ count += 1;
1074
+ }
1075
+ if (count != numChars) {
1076
+ throw count + " != " + numChars;
1077
+ }
1078
+ return unicodeMap2;
1079
+ })();
1080
+ const unknownChar = "?".charCodeAt(0);
1081
+ return function(s) {
1082
+ const bytes = [];
1083
+ for (let i = 0; i < s.length; i += 1) {
1084
+ const c = s.charCodeAt(i);
1085
+ if (c < 128) {
1086
+ bytes.push(c);
1087
+ } else {
1088
+ const b = unicodeMap[s.charAt(i)];
1089
+ if (typeof b == "number") {
1090
+ if ((b & 255) == b) {
1091
+ bytes.push(b);
1092
+ } else {
1093
+ bytes.push(b >>> 8);
1094
+ bytes.push(b & 255);
1095
+ }
1096
+ } else {
1097
+ bytes.push(unknownChar);
1098
+ }
1099
+ }
1100
+ }
1101
+ return bytes;
1102
+ };
1103
+ };
1104
+ var QRMode = {
1105
+ MODE_NUMBER: 1 << 0,
1106
+ MODE_ALPHA_NUM: 1 << 1,
1107
+ MODE_8BIT_BYTE: 1 << 2,
1108
+ MODE_KANJI: 1 << 3
1109
+ };
1110
+ var QRErrorCorrectionLevel = {
1111
+ L: 1,
1112
+ M: 0,
1113
+ Q: 3,
1114
+ H: 2
1115
+ };
1116
+ var QRMaskPattern = {
1117
+ PATTERN000: 0,
1118
+ PATTERN001: 1,
1119
+ PATTERN010: 2,
1120
+ PATTERN011: 3,
1121
+ PATTERN100: 4,
1122
+ PATTERN101: 5,
1123
+ PATTERN110: 6,
1124
+ PATTERN111: 7
1125
+ };
1126
+ var QRUtil = (function() {
1127
+ const PATTERN_POSITION_TABLE = [
1128
+ [],
1129
+ [6, 18],
1130
+ [6, 22],
1131
+ [6, 26],
1132
+ [6, 30],
1133
+ [6, 34],
1134
+ [6, 22, 38],
1135
+ [6, 24, 42],
1136
+ [6, 26, 46],
1137
+ [6, 28, 50],
1138
+ [6, 30, 54],
1139
+ [6, 32, 58],
1140
+ [6, 34, 62],
1141
+ [6, 26, 46, 66],
1142
+ [6, 26, 48, 70],
1143
+ [6, 26, 50, 74],
1144
+ [6, 30, 54, 78],
1145
+ [6, 30, 56, 82],
1146
+ [6, 30, 58, 86],
1147
+ [6, 34, 62, 90],
1148
+ [6, 28, 50, 72, 94],
1149
+ [6, 26, 50, 74, 98],
1150
+ [6, 30, 54, 78, 102],
1151
+ [6, 28, 54, 80, 106],
1152
+ [6, 32, 58, 84, 110],
1153
+ [6, 30, 58, 86, 114],
1154
+ [6, 34, 62, 90, 118],
1155
+ [6, 26, 50, 74, 98, 122],
1156
+ [6, 30, 54, 78, 102, 126],
1157
+ [6, 26, 52, 78, 104, 130],
1158
+ [6, 30, 56, 82, 108, 134],
1159
+ [6, 34, 60, 86, 112, 138],
1160
+ [6, 30, 58, 86, 114, 142],
1161
+ [6, 34, 62, 90, 118, 146],
1162
+ [6, 30, 54, 78, 102, 126, 150],
1163
+ [6, 24, 50, 76, 102, 128, 154],
1164
+ [6, 28, 54, 80, 106, 132, 158],
1165
+ [6, 32, 58, 84, 110, 136, 162],
1166
+ [6, 26, 54, 82, 110, 138, 166],
1167
+ [6, 30, 58, 86, 114, 142, 170]
1168
+ ];
1169
+ const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
1170
+ const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
1171
+ const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
1172
+ const _this = {};
1173
+ const getBCHDigit = function(data) {
1174
+ let digit = 0;
1175
+ while (data != 0) {
1176
+ digit += 1;
1177
+ data >>>= 1;
1178
+ }
1179
+ return digit;
1180
+ };
1181
+ _this.getBCHTypeInfo = function(data) {
1182
+ let d = data << 10;
1183
+ while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
1184
+ d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
1185
+ }
1186
+ return (data << 10 | d) ^ G15_MASK;
1187
+ };
1188
+ _this.getBCHTypeNumber = function(data) {
1189
+ let d = data << 12;
1190
+ while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
1191
+ d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
1192
+ }
1193
+ return data << 12 | d;
1194
+ };
1195
+ _this.getPatternPosition = function(typeNumber) {
1196
+ return PATTERN_POSITION_TABLE[typeNumber - 1];
1197
+ };
1198
+ _this.getMaskFunction = function(maskPattern) {
1199
+ switch (maskPattern) {
1200
+ case QRMaskPattern.PATTERN000:
1201
+ return function(i, j) {
1202
+ return (i + j) % 2 == 0;
1203
+ };
1204
+ case QRMaskPattern.PATTERN001:
1205
+ return function(i, j) {
1206
+ return i % 2 == 0;
1207
+ };
1208
+ case QRMaskPattern.PATTERN010:
1209
+ return function(i, j) {
1210
+ return j % 3 == 0;
1211
+ };
1212
+ case QRMaskPattern.PATTERN011:
1213
+ return function(i, j) {
1214
+ return (i + j) % 3 == 0;
1215
+ };
1216
+ case QRMaskPattern.PATTERN100:
1217
+ return function(i, j) {
1218
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
1219
+ };
1220
+ case QRMaskPattern.PATTERN101:
1221
+ return function(i, j) {
1222
+ return i * j % 2 + i * j % 3 == 0;
1223
+ };
1224
+ case QRMaskPattern.PATTERN110:
1225
+ return function(i, j) {
1226
+ return (i * j % 2 + i * j % 3) % 2 == 0;
1227
+ };
1228
+ case QRMaskPattern.PATTERN111:
1229
+ return function(i, j) {
1230
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
1231
+ };
1232
+ default:
1233
+ throw "bad maskPattern:" + maskPattern;
1234
+ }
1235
+ };
1236
+ _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
1237
+ let a = qrPolynomial([1], 0);
1238
+ for (let i = 0; i < errorCorrectLength; i += 1) {
1239
+ a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
1240
+ }
1241
+ return a;
1242
+ };
1243
+ _this.getLengthInBits = function(mode, type) {
1244
+ if (1 <= type && type < 10) {
1245
+ switch (mode) {
1246
+ case QRMode.MODE_NUMBER:
1247
+ return 10;
1248
+ case QRMode.MODE_ALPHA_NUM:
1249
+ return 9;
1250
+ case QRMode.MODE_8BIT_BYTE:
1251
+ return 8;
1252
+ case QRMode.MODE_KANJI:
1253
+ return 8;
1254
+ default:
1255
+ throw "mode:" + mode;
1256
+ }
1257
+ } else if (type < 27) {
1258
+ switch (mode) {
1259
+ case QRMode.MODE_NUMBER:
1260
+ return 12;
1261
+ case QRMode.MODE_ALPHA_NUM:
1262
+ return 11;
1263
+ case QRMode.MODE_8BIT_BYTE:
1264
+ return 16;
1265
+ case QRMode.MODE_KANJI:
1266
+ return 10;
1267
+ default:
1268
+ throw "mode:" + mode;
1269
+ }
1270
+ } else if (type < 41) {
1271
+ switch (mode) {
1272
+ case QRMode.MODE_NUMBER:
1273
+ return 14;
1274
+ case QRMode.MODE_ALPHA_NUM:
1275
+ return 13;
1276
+ case QRMode.MODE_8BIT_BYTE:
1277
+ return 16;
1278
+ case QRMode.MODE_KANJI:
1279
+ return 12;
1280
+ default:
1281
+ throw "mode:" + mode;
1282
+ }
1283
+ } else {
1284
+ throw "type:" + type;
1285
+ }
1286
+ };
1287
+ _this.getLostPoint = function(qrcode2) {
1288
+ const moduleCount = qrcode2.getModuleCount();
1289
+ let lostPoint = 0;
1290
+ for (let row = 0; row < moduleCount; row += 1) {
1291
+ for (let col = 0; col < moduleCount; col += 1) {
1292
+ let sameCount = 0;
1293
+ const dark = qrcode2.isDark(row, col);
1294
+ for (let r = -1; r <= 1; r += 1) {
1295
+ if (row + r < 0 || moduleCount <= row + r) {
1296
+ continue;
1297
+ }
1298
+ for (let c = -1; c <= 1; c += 1) {
1299
+ if (col + c < 0 || moduleCount <= col + c) {
1300
+ continue;
1301
+ }
1302
+ if (r == 0 && c == 0) {
1303
+ continue;
1304
+ }
1305
+ if (dark == qrcode2.isDark(row + r, col + c)) {
1306
+ sameCount += 1;
1307
+ }
1308
+ }
1309
+ }
1310
+ if (sameCount > 5) {
1311
+ lostPoint += 3 + sameCount - 5;
1312
+ }
1313
+ }
1314
+ }
1315
+ ;
1316
+ for (let row = 0; row < moduleCount - 1; row += 1) {
1317
+ for (let col = 0; col < moduleCount - 1; col += 1) {
1318
+ let count = 0;
1319
+ if (qrcode2.isDark(row, col)) count += 1;
1320
+ if (qrcode2.isDark(row + 1, col)) count += 1;
1321
+ if (qrcode2.isDark(row, col + 1)) count += 1;
1322
+ if (qrcode2.isDark(row + 1, col + 1)) count += 1;
1323
+ if (count == 0 || count == 4) {
1324
+ lostPoint += 3;
1325
+ }
1326
+ }
1327
+ }
1328
+ for (let row = 0; row < moduleCount; row += 1) {
1329
+ for (let col = 0; col < moduleCount - 6; col += 1) {
1330
+ if (qrcode2.isDark(row, col) && !qrcode2.isDark(row, col + 1) && qrcode2.isDark(row, col + 2) && qrcode2.isDark(row, col + 3) && qrcode2.isDark(row, col + 4) && !qrcode2.isDark(row, col + 5) && qrcode2.isDark(row, col + 6)) {
1331
+ lostPoint += 40;
1332
+ }
1333
+ }
1334
+ }
1335
+ for (let col = 0; col < moduleCount; col += 1) {
1336
+ for (let row = 0; row < moduleCount - 6; row += 1) {
1337
+ if (qrcode2.isDark(row, col) && !qrcode2.isDark(row + 1, col) && qrcode2.isDark(row + 2, col) && qrcode2.isDark(row + 3, col) && qrcode2.isDark(row + 4, col) && !qrcode2.isDark(row + 5, col) && qrcode2.isDark(row + 6, col)) {
1338
+ lostPoint += 40;
1339
+ }
1340
+ }
1341
+ }
1342
+ let darkCount = 0;
1343
+ for (let col = 0; col < moduleCount; col += 1) {
1344
+ for (let row = 0; row < moduleCount; row += 1) {
1345
+ if (qrcode2.isDark(row, col)) {
1346
+ darkCount += 1;
1347
+ }
1348
+ }
1349
+ }
1350
+ const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
1351
+ lostPoint += ratio * 10;
1352
+ return lostPoint;
1353
+ };
1354
+ return _this;
1355
+ })();
1356
+ var QRMath = (function() {
1357
+ const EXP_TABLE = new Array(256);
1358
+ const LOG_TABLE = new Array(256);
1359
+ for (let i = 0; i < 8; i += 1) {
1360
+ EXP_TABLE[i] = 1 << i;
1361
+ }
1362
+ for (let i = 8; i < 256; i += 1) {
1363
+ EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
1364
+ }
1365
+ for (let i = 0; i < 255; i += 1) {
1366
+ LOG_TABLE[EXP_TABLE[i]] = i;
1367
+ }
1368
+ const _this = {};
1369
+ _this.glog = function(n) {
1370
+ if (n < 1) {
1371
+ throw "glog(" + n + ")";
1372
+ }
1373
+ return LOG_TABLE[n];
1374
+ };
1375
+ _this.gexp = function(n) {
1376
+ while (n < 0) {
1377
+ n += 255;
1378
+ }
1379
+ while (n >= 256) {
1380
+ n -= 255;
1381
+ }
1382
+ return EXP_TABLE[n];
1383
+ };
1384
+ return _this;
1385
+ })();
1386
+ var qrPolynomial = function(num, shift) {
1387
+ if (typeof num.length == "undefined") {
1388
+ throw num.length + "/" + shift;
1389
+ }
1390
+ const _num = (function() {
1391
+ let offset = 0;
1392
+ while (offset < num.length && num[offset] == 0) {
1393
+ offset += 1;
1394
+ }
1395
+ const _num2 = new Array(num.length - offset + shift);
1396
+ for (let i = 0; i < num.length - offset; i += 1) {
1397
+ _num2[i] = num[i + offset];
1398
+ }
1399
+ return _num2;
1400
+ })();
1401
+ const _this = {};
1402
+ _this.getAt = function(index) {
1403
+ return _num[index];
1404
+ };
1405
+ _this.getLength = function() {
1406
+ return _num.length;
1407
+ };
1408
+ _this.multiply = function(e) {
1409
+ const num2 = new Array(_this.getLength() + e.getLength() - 1);
1410
+ for (let i = 0; i < _this.getLength(); i += 1) {
1411
+ for (let j = 0; j < e.getLength(); j += 1) {
1412
+ num2[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
1413
+ }
1414
+ }
1415
+ return qrPolynomial(num2, 0);
1416
+ };
1417
+ _this.mod = function(e) {
1418
+ if (_this.getLength() - e.getLength() < 0) {
1419
+ return _this;
1420
+ }
1421
+ const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
1422
+ const num2 = new Array(_this.getLength());
1423
+ for (let i = 0; i < _this.getLength(); i += 1) {
1424
+ num2[i] = _this.getAt(i);
1425
+ }
1426
+ for (let i = 0; i < e.getLength(); i += 1) {
1427
+ num2[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
1428
+ }
1429
+ return qrPolynomial(num2, 0).mod(e);
1430
+ };
1431
+ return _this;
1432
+ };
1433
+ var QRRSBlock = (function() {
1434
+ const RS_BLOCK_TABLE = [
1435
+ // L
1436
+ // M
1437
+ // Q
1438
+ // H
1439
+ // 1
1440
+ [1, 26, 19],
1441
+ [1, 26, 16],
1442
+ [1, 26, 13],
1443
+ [1, 26, 9],
1444
+ // 2
1445
+ [1, 44, 34],
1446
+ [1, 44, 28],
1447
+ [1, 44, 22],
1448
+ [1, 44, 16],
1449
+ // 3
1450
+ [1, 70, 55],
1451
+ [1, 70, 44],
1452
+ [2, 35, 17],
1453
+ [2, 35, 13],
1454
+ // 4
1455
+ [1, 100, 80],
1456
+ [2, 50, 32],
1457
+ [2, 50, 24],
1458
+ [4, 25, 9],
1459
+ // 5
1460
+ [1, 134, 108],
1461
+ [2, 67, 43],
1462
+ [2, 33, 15, 2, 34, 16],
1463
+ [2, 33, 11, 2, 34, 12],
1464
+ // 6
1465
+ [2, 86, 68],
1466
+ [4, 43, 27],
1467
+ [4, 43, 19],
1468
+ [4, 43, 15],
1469
+ // 7
1470
+ [2, 98, 78],
1471
+ [4, 49, 31],
1472
+ [2, 32, 14, 4, 33, 15],
1473
+ [4, 39, 13, 1, 40, 14],
1474
+ // 8
1475
+ [2, 121, 97],
1476
+ [2, 60, 38, 2, 61, 39],
1477
+ [4, 40, 18, 2, 41, 19],
1478
+ [4, 40, 14, 2, 41, 15],
1479
+ // 9
1480
+ [2, 146, 116],
1481
+ [3, 58, 36, 2, 59, 37],
1482
+ [4, 36, 16, 4, 37, 17],
1483
+ [4, 36, 12, 4, 37, 13],
1484
+ // 10
1485
+ [2, 86, 68, 2, 87, 69],
1486
+ [4, 69, 43, 1, 70, 44],
1487
+ [6, 43, 19, 2, 44, 20],
1488
+ [6, 43, 15, 2, 44, 16],
1489
+ // 11
1490
+ [4, 101, 81],
1491
+ [1, 80, 50, 4, 81, 51],
1492
+ [4, 50, 22, 4, 51, 23],
1493
+ [3, 36, 12, 8, 37, 13],
1494
+ // 12
1495
+ [2, 116, 92, 2, 117, 93],
1496
+ [6, 58, 36, 2, 59, 37],
1497
+ [4, 46, 20, 6, 47, 21],
1498
+ [7, 42, 14, 4, 43, 15],
1499
+ // 13
1500
+ [4, 133, 107],
1501
+ [8, 59, 37, 1, 60, 38],
1502
+ [8, 44, 20, 4, 45, 21],
1503
+ [12, 33, 11, 4, 34, 12],
1504
+ // 14
1505
+ [3, 145, 115, 1, 146, 116],
1506
+ [4, 64, 40, 5, 65, 41],
1507
+ [11, 36, 16, 5, 37, 17],
1508
+ [11, 36, 12, 5, 37, 13],
1509
+ // 15
1510
+ [5, 109, 87, 1, 110, 88],
1511
+ [5, 65, 41, 5, 66, 42],
1512
+ [5, 54, 24, 7, 55, 25],
1513
+ [11, 36, 12, 7, 37, 13],
1514
+ // 16
1515
+ [5, 122, 98, 1, 123, 99],
1516
+ [7, 73, 45, 3, 74, 46],
1517
+ [15, 43, 19, 2, 44, 20],
1518
+ [3, 45, 15, 13, 46, 16],
1519
+ // 17
1520
+ [1, 135, 107, 5, 136, 108],
1521
+ [10, 74, 46, 1, 75, 47],
1522
+ [1, 50, 22, 15, 51, 23],
1523
+ [2, 42, 14, 17, 43, 15],
1524
+ // 18
1525
+ [5, 150, 120, 1, 151, 121],
1526
+ [9, 69, 43, 4, 70, 44],
1527
+ [17, 50, 22, 1, 51, 23],
1528
+ [2, 42, 14, 19, 43, 15],
1529
+ // 19
1530
+ [3, 141, 113, 4, 142, 114],
1531
+ [3, 70, 44, 11, 71, 45],
1532
+ [17, 47, 21, 4, 48, 22],
1533
+ [9, 39, 13, 16, 40, 14],
1534
+ // 20
1535
+ [3, 135, 107, 5, 136, 108],
1536
+ [3, 67, 41, 13, 68, 42],
1537
+ [15, 54, 24, 5, 55, 25],
1538
+ [15, 43, 15, 10, 44, 16],
1539
+ // 21
1540
+ [4, 144, 116, 4, 145, 117],
1541
+ [17, 68, 42],
1542
+ [17, 50, 22, 6, 51, 23],
1543
+ [19, 46, 16, 6, 47, 17],
1544
+ // 22
1545
+ [2, 139, 111, 7, 140, 112],
1546
+ [17, 74, 46],
1547
+ [7, 54, 24, 16, 55, 25],
1548
+ [34, 37, 13],
1549
+ // 23
1550
+ [4, 151, 121, 5, 152, 122],
1551
+ [4, 75, 47, 14, 76, 48],
1552
+ [11, 54, 24, 14, 55, 25],
1553
+ [16, 45, 15, 14, 46, 16],
1554
+ // 24
1555
+ [6, 147, 117, 4, 148, 118],
1556
+ [6, 73, 45, 14, 74, 46],
1557
+ [11, 54, 24, 16, 55, 25],
1558
+ [30, 46, 16, 2, 47, 17],
1559
+ // 25
1560
+ [8, 132, 106, 4, 133, 107],
1561
+ [8, 75, 47, 13, 76, 48],
1562
+ [7, 54, 24, 22, 55, 25],
1563
+ [22, 45, 15, 13, 46, 16],
1564
+ // 26
1565
+ [10, 142, 114, 2, 143, 115],
1566
+ [19, 74, 46, 4, 75, 47],
1567
+ [28, 50, 22, 6, 51, 23],
1568
+ [33, 46, 16, 4, 47, 17],
1569
+ // 27
1570
+ [8, 152, 122, 4, 153, 123],
1571
+ [22, 73, 45, 3, 74, 46],
1572
+ [8, 53, 23, 26, 54, 24],
1573
+ [12, 45, 15, 28, 46, 16],
1574
+ // 28
1575
+ [3, 147, 117, 10, 148, 118],
1576
+ [3, 73, 45, 23, 74, 46],
1577
+ [4, 54, 24, 31, 55, 25],
1578
+ [11, 45, 15, 31, 46, 16],
1579
+ // 29
1580
+ [7, 146, 116, 7, 147, 117],
1581
+ [21, 73, 45, 7, 74, 46],
1582
+ [1, 53, 23, 37, 54, 24],
1583
+ [19, 45, 15, 26, 46, 16],
1584
+ // 30
1585
+ [5, 145, 115, 10, 146, 116],
1586
+ [19, 75, 47, 10, 76, 48],
1587
+ [15, 54, 24, 25, 55, 25],
1588
+ [23, 45, 15, 25, 46, 16],
1589
+ // 31
1590
+ [13, 145, 115, 3, 146, 116],
1591
+ [2, 74, 46, 29, 75, 47],
1592
+ [42, 54, 24, 1, 55, 25],
1593
+ [23, 45, 15, 28, 46, 16],
1594
+ // 32
1595
+ [17, 145, 115],
1596
+ [10, 74, 46, 23, 75, 47],
1597
+ [10, 54, 24, 35, 55, 25],
1598
+ [19, 45, 15, 35, 46, 16],
1599
+ // 33
1600
+ [17, 145, 115, 1, 146, 116],
1601
+ [14, 74, 46, 21, 75, 47],
1602
+ [29, 54, 24, 19, 55, 25],
1603
+ [11, 45, 15, 46, 46, 16],
1604
+ // 34
1605
+ [13, 145, 115, 6, 146, 116],
1606
+ [14, 74, 46, 23, 75, 47],
1607
+ [44, 54, 24, 7, 55, 25],
1608
+ [59, 46, 16, 1, 47, 17],
1609
+ // 35
1610
+ [12, 151, 121, 7, 152, 122],
1611
+ [12, 75, 47, 26, 76, 48],
1612
+ [39, 54, 24, 14, 55, 25],
1613
+ [22, 45, 15, 41, 46, 16],
1614
+ // 36
1615
+ [6, 151, 121, 14, 152, 122],
1616
+ [6, 75, 47, 34, 76, 48],
1617
+ [46, 54, 24, 10, 55, 25],
1618
+ [2, 45, 15, 64, 46, 16],
1619
+ // 37
1620
+ [17, 152, 122, 4, 153, 123],
1621
+ [29, 74, 46, 14, 75, 47],
1622
+ [49, 54, 24, 10, 55, 25],
1623
+ [24, 45, 15, 46, 46, 16],
1624
+ // 38
1625
+ [4, 152, 122, 18, 153, 123],
1626
+ [13, 74, 46, 32, 75, 47],
1627
+ [48, 54, 24, 14, 55, 25],
1628
+ [42, 45, 15, 32, 46, 16],
1629
+ // 39
1630
+ [20, 147, 117, 4, 148, 118],
1631
+ [40, 75, 47, 7, 76, 48],
1632
+ [43, 54, 24, 22, 55, 25],
1633
+ [10, 45, 15, 67, 46, 16],
1634
+ // 40
1635
+ [19, 148, 118, 6, 149, 119],
1636
+ [18, 75, 47, 31, 76, 48],
1637
+ [34, 54, 24, 34, 55, 25],
1638
+ [20, 45, 15, 61, 46, 16]
1639
+ ];
1640
+ const qrRSBlock = function(totalCount, dataCount) {
1641
+ const _this2 = {};
1642
+ _this2.totalCount = totalCount;
1643
+ _this2.dataCount = dataCount;
1644
+ return _this2;
1645
+ };
1646
+ const _this = {};
1647
+ const getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
1648
+ switch (errorCorrectionLevel) {
1649
+ case QRErrorCorrectionLevel.L:
1650
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1651
+ case QRErrorCorrectionLevel.M:
1652
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1653
+ case QRErrorCorrectionLevel.Q:
1654
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1655
+ case QRErrorCorrectionLevel.H:
1656
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1657
+ default:
1658
+ return void 0;
1659
+ }
1660
+ };
1661
+ _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
1662
+ const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
1663
+ if (typeof rsBlock == "undefined") {
1664
+ throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
1665
+ }
1666
+ const length = rsBlock.length / 3;
1667
+ const list = [];
1668
+ for (let i = 0; i < length; i += 1) {
1669
+ const count = rsBlock[i * 3 + 0];
1670
+ const totalCount = rsBlock[i * 3 + 1];
1671
+ const dataCount = rsBlock[i * 3 + 2];
1672
+ for (let j = 0; j < count; j += 1) {
1673
+ list.push(qrRSBlock(totalCount, dataCount));
1674
+ }
1675
+ }
1676
+ return list;
1677
+ };
1678
+ return _this;
1679
+ })();
1680
+ var qrBitBuffer = function() {
1681
+ const _buffer = [];
1682
+ let _length = 0;
1683
+ const _this = {};
1684
+ _this.getBuffer = function() {
1685
+ return _buffer;
1686
+ };
1687
+ _this.getAt = function(index) {
1688
+ const bufIndex = Math.floor(index / 8);
1689
+ return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
1690
+ };
1691
+ _this.put = function(num, length) {
1692
+ for (let i = 0; i < length; i += 1) {
1693
+ _this.putBit((num >>> length - i - 1 & 1) == 1);
1694
+ }
1695
+ };
1696
+ _this.getLengthInBits = function() {
1697
+ return _length;
1698
+ };
1699
+ _this.putBit = function(bit) {
1700
+ const bufIndex = Math.floor(_length / 8);
1701
+ if (_buffer.length <= bufIndex) {
1702
+ _buffer.push(0);
1703
+ }
1704
+ if (bit) {
1705
+ _buffer[bufIndex] |= 128 >>> _length % 8;
1706
+ }
1707
+ _length += 1;
1708
+ };
1709
+ return _this;
1710
+ };
1711
+ var qrNumber = function(data) {
1712
+ const _mode = QRMode.MODE_NUMBER;
1713
+ const _data = data;
1714
+ const _this = {};
1715
+ _this.getMode = function() {
1716
+ return _mode;
1717
+ };
1718
+ _this.getLength = function(buffer) {
1719
+ return _data.length;
1720
+ };
1721
+ _this.write = function(buffer) {
1722
+ const data2 = _data;
1723
+ let i = 0;
1724
+ while (i + 2 < data2.length) {
1725
+ buffer.put(strToNum(data2.substring(i, i + 3)), 10);
1726
+ i += 3;
1727
+ }
1728
+ if (i < data2.length) {
1729
+ if (data2.length - i == 1) {
1730
+ buffer.put(strToNum(data2.substring(i, i + 1)), 4);
1731
+ } else if (data2.length - i == 2) {
1732
+ buffer.put(strToNum(data2.substring(i, i + 2)), 7);
1733
+ }
1734
+ }
1735
+ };
1736
+ const strToNum = function(s) {
1737
+ let num = 0;
1738
+ for (let i = 0; i < s.length; i += 1) {
1739
+ num = num * 10 + chatToNum(s.charAt(i));
1740
+ }
1741
+ return num;
1742
+ };
1743
+ const chatToNum = function(c) {
1744
+ if ("0" <= c && c <= "9") {
1745
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1746
+ }
1747
+ throw "illegal char :" + c;
1748
+ };
1749
+ return _this;
1750
+ };
1751
+ var qrAlphaNum = function(data) {
1752
+ const _mode = QRMode.MODE_ALPHA_NUM;
1753
+ const _data = data;
1754
+ const _this = {};
1755
+ _this.getMode = function() {
1756
+ return _mode;
1757
+ };
1758
+ _this.getLength = function(buffer) {
1759
+ return _data.length;
1760
+ };
1761
+ _this.write = function(buffer) {
1762
+ const s = _data;
1763
+ let i = 0;
1764
+ while (i + 1 < s.length) {
1765
+ buffer.put(
1766
+ getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)),
1767
+ 11
1768
+ );
1769
+ i += 2;
1770
+ }
1771
+ if (i < s.length) {
1772
+ buffer.put(getCode(s.charAt(i)), 6);
1773
+ }
1774
+ };
1775
+ const getCode = function(c) {
1776
+ if ("0" <= c && c <= "9") {
1777
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1778
+ } else if ("A" <= c && c <= "Z") {
1779
+ return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
1780
+ } else {
1781
+ switch (c) {
1782
+ case " ":
1783
+ return 36;
1784
+ case "$":
1785
+ return 37;
1786
+ case "%":
1787
+ return 38;
1788
+ case "*":
1789
+ return 39;
1790
+ case "+":
1791
+ return 40;
1792
+ case "-":
1793
+ return 41;
1794
+ case ".":
1795
+ return 42;
1796
+ case "/":
1797
+ return 43;
1798
+ case ":":
1799
+ return 44;
1800
+ default:
1801
+ throw "illegal char :" + c;
1802
+ }
1803
+ }
1804
+ };
1805
+ return _this;
1806
+ };
1807
+ var qr8BitByte = function(data) {
1808
+ const _mode = QRMode.MODE_8BIT_BYTE;
1809
+ const _data = data;
1810
+ const _bytes = qrcode.stringToBytes(data);
1811
+ const _this = {};
1812
+ _this.getMode = function() {
1813
+ return _mode;
1814
+ };
1815
+ _this.getLength = function(buffer) {
1816
+ return _bytes.length;
1817
+ };
1818
+ _this.write = function(buffer) {
1819
+ for (let i = 0; i < _bytes.length; i += 1) {
1820
+ buffer.put(_bytes[i], 8);
1821
+ }
1822
+ };
1823
+ return _this;
1824
+ };
1825
+ var qrKanji = function(data) {
1826
+ const _mode = QRMode.MODE_KANJI;
1827
+ const _data = data;
1828
+ const stringToBytes2 = qrcode.stringToBytes;
1829
+ !(function(c, code) {
1830
+ const test = stringToBytes2(c);
1831
+ if (test.length != 2 || (test[0] << 8 | test[1]) != code) {
1832
+ throw "sjis not supported.";
1833
+ }
1834
+ })("友", 38726);
1835
+ const _bytes = stringToBytes2(data);
1836
+ const _this = {};
1837
+ _this.getMode = function() {
1838
+ return _mode;
1839
+ };
1840
+ _this.getLength = function(buffer) {
1841
+ return ~~(_bytes.length / 2);
1842
+ };
1843
+ _this.write = function(buffer) {
1844
+ const data2 = _bytes;
1845
+ let i = 0;
1846
+ while (i + 1 < data2.length) {
1847
+ let c = (255 & data2[i]) << 8 | 255 & data2[i + 1];
1848
+ if (33088 <= c && c <= 40956) {
1849
+ c -= 33088;
1850
+ } else if (57408 <= c && c <= 60351) {
1851
+ c -= 49472;
1852
+ } else {
1853
+ throw "illegal char at " + (i + 1) + "/" + c;
1854
+ }
1855
+ c = (c >>> 8 & 255) * 192 + (c & 255);
1856
+ buffer.put(c, 13);
1857
+ i += 2;
1858
+ }
1859
+ if (i < data2.length) {
1860
+ throw "illegal char at " + (i + 1);
1861
+ }
1862
+ };
1863
+ return _this;
1864
+ };
1865
+ var byteArrayOutputStream = function() {
1866
+ const _bytes = [];
1867
+ const _this = {};
1868
+ _this.writeByte = function(b) {
1869
+ _bytes.push(b & 255);
1870
+ };
1871
+ _this.writeShort = function(i) {
1872
+ _this.writeByte(i);
1873
+ _this.writeByte(i >>> 8);
1874
+ };
1875
+ _this.writeBytes = function(b, off, len) {
1876
+ off = off || 0;
1877
+ len = len || b.length;
1878
+ for (let i = 0; i < len; i += 1) {
1879
+ _this.writeByte(b[i + off]);
1880
+ }
1881
+ };
1882
+ _this.writeString = function(s) {
1883
+ for (let i = 0; i < s.length; i += 1) {
1884
+ _this.writeByte(s.charCodeAt(i));
1885
+ }
1886
+ };
1887
+ _this.toByteArray = function() {
1888
+ return _bytes;
1889
+ };
1890
+ _this.toString = function() {
1891
+ let s = "";
1892
+ s += "[";
1893
+ for (let i = 0; i < _bytes.length; i += 1) {
1894
+ if (i > 0) {
1895
+ s += ",";
1896
+ }
1897
+ s += _bytes[i];
1898
+ }
1899
+ s += "]";
1900
+ return s;
1901
+ };
1902
+ return _this;
1903
+ };
1904
+ var base64EncodeOutputStream = function() {
1905
+ let _buffer = 0;
1906
+ let _buflen = 0;
1907
+ let _length = 0;
1908
+ let _base64 = "";
1909
+ const _this = {};
1910
+ const writeEncoded = function(b) {
1911
+ _base64 += String.fromCharCode(encode(b & 63));
1912
+ };
1913
+ const encode = function(n) {
1914
+ if (n < 0) {
1915
+ throw "n:" + n;
1916
+ } else if (n < 26) {
1917
+ return 65 + n;
1918
+ } else if (n < 52) {
1919
+ return 97 + (n - 26);
1920
+ } else if (n < 62) {
1921
+ return 48 + (n - 52);
1922
+ } else if (n == 62) {
1923
+ return 43;
1924
+ } else if (n == 63) {
1925
+ return 47;
1926
+ } else {
1927
+ throw "n:" + n;
1928
+ }
1929
+ };
1930
+ _this.writeByte = function(n) {
1931
+ _buffer = _buffer << 8 | n & 255;
1932
+ _buflen += 8;
1933
+ _length += 1;
1934
+ while (_buflen >= 6) {
1935
+ writeEncoded(_buffer >>> _buflen - 6);
1936
+ _buflen -= 6;
1937
+ }
1938
+ };
1939
+ _this.flush = function() {
1940
+ if (_buflen > 0) {
1941
+ writeEncoded(_buffer << 6 - _buflen);
1942
+ _buffer = 0;
1943
+ _buflen = 0;
1944
+ }
1945
+ if (_length % 3 != 0) {
1946
+ const padlen = 3 - _length % 3;
1947
+ for (let i = 0; i < padlen; i += 1) {
1948
+ _base64 += "=";
1949
+ }
1950
+ }
1951
+ };
1952
+ _this.toString = function() {
1953
+ return _base64;
1954
+ };
1955
+ return _this;
1956
+ };
1957
+ var base64DecodeInputStream = function(str) {
1958
+ const _str = str;
1959
+ let _pos = 0;
1960
+ let _buffer = 0;
1961
+ let _buflen = 0;
1962
+ const _this = {};
1963
+ _this.read = function() {
1964
+ while (_buflen < 8) {
1965
+ if (_pos >= _str.length) {
1966
+ if (_buflen == 0) {
1967
+ return -1;
1968
+ }
1969
+ throw "unexpected end of file./" + _buflen;
1970
+ }
1971
+ const c = _str.charAt(_pos);
1972
+ _pos += 1;
1973
+ if (c == "=") {
1974
+ _buflen = 0;
1975
+ return -1;
1976
+ } else if (c.match(/^\s$/)) {
1977
+ continue;
1978
+ }
1979
+ _buffer = _buffer << 6 | decode(c.charCodeAt(0));
1980
+ _buflen += 6;
1981
+ }
1982
+ const n = _buffer >>> _buflen - 8 & 255;
1983
+ _buflen -= 8;
1984
+ return n;
1985
+ };
1986
+ const decode = function(c) {
1987
+ if (65 <= c && c <= 90) {
1988
+ return c - 65;
1989
+ } else if (97 <= c && c <= 122) {
1990
+ return c - 97 + 26;
1991
+ } else if (48 <= c && c <= 57) {
1992
+ return c - 48 + 52;
1993
+ } else if (c == 43) {
1994
+ return 62;
1995
+ } else if (c == 47) {
1996
+ return 63;
1997
+ } else {
1998
+ throw "c:" + c;
1999
+ }
2000
+ };
2001
+ return _this;
2002
+ };
2003
+ var gifImage = function(width, height) {
2004
+ const _width = width;
2005
+ const _height = height;
2006
+ const _data = new Array(width * height);
2007
+ const _this = {};
2008
+ _this.setPixel = function(x, y, pixel) {
2009
+ _data[y * _width + x] = pixel;
2010
+ };
2011
+ _this.write = function(out) {
2012
+ out.writeString("GIF87a");
2013
+ out.writeShort(_width);
2014
+ out.writeShort(_height);
2015
+ out.writeByte(128);
2016
+ out.writeByte(0);
2017
+ out.writeByte(0);
2018
+ out.writeByte(0);
2019
+ out.writeByte(0);
2020
+ out.writeByte(0);
2021
+ out.writeByte(255);
2022
+ out.writeByte(255);
2023
+ out.writeByte(255);
2024
+ out.writeString(",");
2025
+ out.writeShort(0);
2026
+ out.writeShort(0);
2027
+ out.writeShort(_width);
2028
+ out.writeShort(_height);
2029
+ out.writeByte(0);
2030
+ const lzwMinCodeSize = 2;
2031
+ const raster = getLZWRaster(lzwMinCodeSize);
2032
+ out.writeByte(lzwMinCodeSize);
2033
+ let offset = 0;
2034
+ while (raster.length - offset > 255) {
2035
+ out.writeByte(255);
2036
+ out.writeBytes(raster, offset, 255);
2037
+ offset += 255;
2038
+ }
2039
+ out.writeByte(raster.length - offset);
2040
+ out.writeBytes(raster, offset, raster.length - offset);
2041
+ out.writeByte(0);
2042
+ out.writeString(";");
2043
+ };
2044
+ const bitOutputStream = function(out) {
2045
+ const _out = out;
2046
+ let _bitLength = 0;
2047
+ let _bitBuffer = 0;
2048
+ const _this2 = {};
2049
+ _this2.write = function(data, length) {
2050
+ if (data >>> length != 0) {
2051
+ throw "length over";
2052
+ }
2053
+ while (_bitLength + length >= 8) {
2054
+ _out.writeByte(255 & (data << _bitLength | _bitBuffer));
2055
+ length -= 8 - _bitLength;
2056
+ data >>>= 8 - _bitLength;
2057
+ _bitBuffer = 0;
2058
+ _bitLength = 0;
2059
+ }
2060
+ _bitBuffer = data << _bitLength | _bitBuffer;
2061
+ _bitLength = _bitLength + length;
2062
+ };
2063
+ _this2.flush = function() {
2064
+ if (_bitLength > 0) {
2065
+ _out.writeByte(_bitBuffer);
2066
+ }
2067
+ };
2068
+ return _this2;
2069
+ };
2070
+ const getLZWRaster = function(lzwMinCodeSize) {
2071
+ const clearCode = 1 << lzwMinCodeSize;
2072
+ const endCode = (1 << lzwMinCodeSize) + 1;
2073
+ let bitLength = lzwMinCodeSize + 1;
2074
+ const table = lzwTable();
2075
+ for (let i = 0; i < clearCode; i += 1) {
2076
+ table.add(String.fromCharCode(i));
2077
+ }
2078
+ table.add(String.fromCharCode(clearCode));
2079
+ table.add(String.fromCharCode(endCode));
2080
+ const byteOut = byteArrayOutputStream();
2081
+ const bitOut = bitOutputStream(byteOut);
2082
+ bitOut.write(clearCode, bitLength);
2083
+ let dataIndex = 0;
2084
+ let s = String.fromCharCode(_data[dataIndex]);
2085
+ dataIndex += 1;
2086
+ while (dataIndex < _data.length) {
2087
+ const c = String.fromCharCode(_data[dataIndex]);
2088
+ dataIndex += 1;
2089
+ if (table.contains(s + c)) {
2090
+ s = s + c;
2091
+ } else {
2092
+ bitOut.write(table.indexOf(s), bitLength);
2093
+ if (table.size() < 4095) {
2094
+ if (table.size() == 1 << bitLength) {
2095
+ bitLength += 1;
2096
+ }
2097
+ table.add(s + c);
2098
+ }
2099
+ s = c;
2100
+ }
2101
+ }
2102
+ bitOut.write(table.indexOf(s), bitLength);
2103
+ bitOut.write(endCode, bitLength);
2104
+ bitOut.flush();
2105
+ return byteOut.toByteArray();
2106
+ };
2107
+ const lzwTable = function() {
2108
+ const _map = {};
2109
+ let _size = 0;
2110
+ const _this2 = {};
2111
+ _this2.add = function(key) {
2112
+ if (_this2.contains(key)) {
2113
+ throw "dup key:" + key;
2114
+ }
2115
+ _map[key] = _size;
2116
+ _size += 1;
2117
+ };
2118
+ _this2.size = function() {
2119
+ return _size;
2120
+ };
2121
+ _this2.indexOf = function(key) {
2122
+ return _map[key];
2123
+ };
2124
+ _this2.contains = function(key) {
2125
+ return typeof _map[key] != "undefined";
2126
+ };
2127
+ return _this2;
2128
+ };
2129
+ return _this;
2130
+ };
2131
+ var createDataURL = function(width, height, getPixel) {
2132
+ const gif = gifImage(width, height);
2133
+ for (let y = 0; y < height; y += 1) {
2134
+ for (let x = 0; x < width; x += 1) {
2135
+ gif.setPixel(x, y, getPixel(x, y));
2136
+ }
2137
+ }
2138
+ const b = byteArrayOutputStream();
2139
+ gif.write(b);
2140
+ const base64 = base64EncodeOutputStream();
2141
+ const bytes = b.toByteArray();
2142
+ for (let i = 0; i < bytes.length; i += 1) {
2143
+ base64.writeByte(bytes[i]);
2144
+ }
2145
+ base64.flush();
2146
+ return "data:image/gif;base64," + base64;
2147
+ };
2148
+ var qrcode_default = qrcode;
2149
+ var stringToBytes = qrcode.stringToBytes;
2150
+
516
2151
  // src/panel.ts
517
2152
  var ROUTE_PREFIX = "/api/teamwork";
518
2153
 
@@ -545,7 +2180,10 @@ var api = {
545
2180
  logout: () => call("logout"),
546
2181
  setServer: (server) => call("server", { server }),
547
2182
  use: (sessionId, id) => call("use", { sessionId, id }),
548
- install: (id, version) => call("install", { id, version })
2183
+ install: (id, version) => call("install", { id, version }),
2184
+ pairPhone: () => call("pair-phone", {}),
2185
+ decidePhone: (id, accept) => call("decide-phone", { id, accept }),
2186
+ revokePhone: (id) => call("revoke-phone", { id })
549
2187
  };
550
2188
 
551
2189
  // src/web/TeamworkPanel.tsx
@@ -630,7 +2268,8 @@ function TeamworkPanel({ host: dsh }) {
630
2268
  const tabs = [
631
2269
  { id: "presets", label: "预设", count: state.presets.length },
632
2270
  { id: "models", label: "团队模型", count: state.models.length },
633
- { id: "plugins", label: "团队插件", count: state.plugins.length }
2271
+ { id: "plugins", label: "团队插件", count: state.plugins.length },
2272
+ { id: "phones", label: "手机", count: state.phones.length }
634
2273
  ];
635
2274
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Panel, { label: "Teamwork", header: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Header, { state, run }), nav: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tabs, { label: "团队配置", items: tabs, value: tab, onChange: setTab }), children: [
636
2275
  loadError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Banner, { tone: "danger", title: "状态没有刷新", action: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", icon: "refresh", onClick: () => void refresh(), children: "重试" }), children: loadError }),
@@ -639,6 +2278,7 @@ function TeamworkPanel({ host: dsh }) {
639
2278
  tab === "presets" && (state.presets.length ? state.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PresetItem, { preset: p, state, dsh, run, onInstall: () => setTab("plugins") }, p.id)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyState, { icon: "layers", title: "团队还没有发布预设", children: "管理员在网页控制台发布预设后,下次同步就会出现在这里。" }) })),
640
2279
  tab === "models" && (state.models.length ? state.models.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModelItem, { model: m, state, run }, m.id)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyState, { icon: "cpu", title: "团队还没有发布模型", children: "团队模型由服务器代为调用,provider 密钥不会下发到这台电脑。" }) })),
641
2280
  tab === "plugins" && (state.plugins.length ? state.plugins.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PluginItem, { plugin: p, run }, p.id)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyState, { icon: "puzzle", title: "团队没有固定插件版本", children: "固定的插件版本会出现在这里,由你确认后安装。" }) })),
2281
+ tab === "phones" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Phones, { state, run }),
642
2282
  toastNode
643
2283
  ] });
644
2284
  }
@@ -1003,6 +2643,122 @@ function ListSkeleton() {
1003
2643
  ] })
1004
2644
  ] }, i)) });
1005
2645
  }
2646
+ var relayText = {
2647
+ off: ["服务器没有开启手机接入", "只有提供中转服务的服务器(如官方服务 www.dshteamwork.com)才能让手机连到这台电脑。"],
2648
+ connecting: ["正在连接中转服务…", "连上之后就可以在这里配对手机。"],
2649
+ refused: ["中转服务拒绝了这台电脑", "登录可能已失效,或另一个 DSH 正以这台电脑的身份连接。退出后重新登录即可重试。"]
2650
+ };
2651
+ var shortTime = (iso) => new Date(iso).toLocaleString("zh-CN", { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" });
2652
+ function Phones({ state, run }) {
2653
+ const [offer, setOffer] = (0, import_react3.useState)();
2654
+ const [revoking, setRevoking] = (0, import_react3.useState)();
2655
+ const pending = state.phones.filter((p) => p.status === "pending");
2656
+ const paired = state.phones.filter((p) => p.status === "confirmed");
2657
+ const seen = (0, import_react3.useRef)(pending.length);
2658
+ (0, import_react3.useEffect)(() => {
2659
+ if (pending.length > seen.current) setOffer(void 0);
2660
+ seen.current = pending.length;
2661
+ }, [pending.length]);
2662
+ if (state.relay !== "connected") {
2663
+ const [title, body] = relayText[state.relay];
2664
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyState, { icon: "smartphone", title, children: body }) });
2665
+ }
2666
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2667
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Card, { children: offer ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PairingCode, { offer, onDone: () => setOffer(void 0) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2668
+ EmptyState,
2669
+ {
2670
+ icon: "smartphone",
2671
+ title: "在手机上操作这台电脑的 DSH",
2672
+ action: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { icon: "plus", onClick: () => run(async () => setOffer(await api.pairPhone())), children: "配对新手机" }),
2673
+ children: "用 DSH Teamwork App 扫描这里显示的二维码,再在这台电脑上确认,手机就能查看会话、发送消息和处理审批。"
2674
+ }
2675
+ ) }),
2676
+ pending.map((phone) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2677
+ Item,
2678
+ {
2679
+ icon: "smartphone",
2680
+ title: phone.deviceName,
2681
+ subtitle: `${shortTime(phone.createdAt)} 申请配对`,
2682
+ tags: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "warning", dot: true, children: "等待你确认" }),
2683
+ description: "确认后,这台手机可以查看这台电脑上的会话、发送消息、回答 Agent 的提问和处理审批。不是你本人的手机请拒绝。",
2684
+ actions: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2685
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", variant: "ghost", onClick: () => run(() => api.decidePhone(phone.id, false), "已拒绝"), children: "拒绝" }),
2686
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", onClick: () => run(() => api.decidePhone(phone.id, true), `${phone.deviceName} 已配对`), children: "确认配对" })
2687
+ ] })
2688
+ },
2689
+ phone.id
2690
+ )),
2691
+ paired.map((phone) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2692
+ Item,
2693
+ {
2694
+ icon: "smartphone",
2695
+ title: phone.deviceName,
2696
+ subtitle: phone.lastUsedAt ? `最近使用 ${shortTime(phone.lastUsedAt)}` : `配对于 ${shortTime(phone.createdAt)}`,
2697
+ tags: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "success", dot: true, children: "已配对" }),
2698
+ actions: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", variant: "ghost", onClick: () => setRevoking(phone), children: "解除配对" })
2699
+ },
2700
+ phone.id
2701
+ )),
2702
+ revoking && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2703
+ Confirm,
2704
+ {
2705
+ title: `解除与 ${revoking.deviceName} 的配对?`,
2706
+ description: "这台手机会立即断开,之后需要重新扫码配对才能再连到这台电脑。",
2707
+ confirmLabel: "解除配对",
2708
+ cancelLabel: "取消",
2709
+ onCancel: () => setRevoking(void 0),
2710
+ onConfirm: () => {
2711
+ const phone = revoking;
2712
+ setRevoking(void 0);
2713
+ void run(() => api.revokePhone(phone.id), "已解除配对");
2714
+ }
2715
+ }
2716
+ )
2717
+ ] });
2718
+ }
2719
+ function PairingCode({ offer, onDone }) {
2720
+ const [now, setNow] = (0, import_react3.useState)(Date.now());
2721
+ (0, import_react3.useEffect)(() => {
2722
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
2723
+ return () => clearInterval(timer);
2724
+ }, []);
2725
+ const left = Math.max(0, Math.round((Date.parse(offer.expiresAt) - now) / 1e3));
2726
+ (0, import_react3.useEffect)(() => {
2727
+ if (left === 0) onDone();
2728
+ }, [left, onDone]);
2729
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", gap: 20, alignItems: "center", flexWrap: "wrap" }, children: [
2730
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(QrCode, { value: offer.link, size: 168 }),
2731
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gap: 8, minWidth: 200, flex: "1 1 200px" }, children: [
2732
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { style: { fontSize: 15, fontWeight: 650 }, children: "用 DSH Teamwork App 扫码" }),
2733
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "twui-subtle", children: "也可以在 App 里手动输入配对码:" }),
2734
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "twui-mono", style: { fontSize: 20, letterSpacing: "0.12em" }, children: [
2735
+ offer.code.slice(0, 4),
2736
+ " ",
2737
+ offer.code.slice(4)
2738
+ ] }),
2739
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "twui-subtle", children: [
2740
+ Math.floor(left / 60),
2741
+ ":",
2742
+ String(left % 60).padStart(2, "0"),
2743
+ " 后失效,只能使用一次。扫码后请回到这里确认。"
2744
+ ] }),
2745
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", variant: "ghost", onClick: onDone, children: "取消" }) })
2746
+ ] })
2747
+ ] });
2748
+ }
2749
+ function QrCode({ value, size }) {
2750
+ const qr = qrcode_default(0, "M");
2751
+ qr.addData(value);
2752
+ qr.make();
2753
+ const count = qr.getModuleCount();
2754
+ let d = "";
2755
+ for (let row = 0; row < count; row++) for (let col = 0; col < count; col++) if (qr.isDark(row, col)) d += `M${col + 4} ${row + 4}h1v1h-1z`;
2756
+ const extent = count + 8;
2757
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("svg", { role: "img", "aria-label": "配对二维码", width: size, height: size, viewBox: `0 0 ${extent} ${extent}`, shapeRendering: "crispEdges", style: { borderRadius: 8, flex: "none" }, children: [
2758
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("rect", { width: extent, height: extent, fill: "#ffffff" }),
2759
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d, fill: "#000000" })
2760
+ ] });
2761
+ }
1006
2762
 
1007
2763
  // src/web/index.tsx
1008
2764
  var import_jsx_runtime7 = require("react/jsx-runtime");