strc 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -25,27 +25,26 @@ SOFTWARE.
25
25
  */
26
26
 
27
27
  /*
28
- _______________
29
- __ / / __/ __/ ___/
30
- / // /\ \_\ \/ /__
31
- \___/___/___/\___/
32
-
33
- JavaScript String Compressor
34
- https://jssc.js.org/
28
+ __ _______________ __
29
+ \ \ __ / / __/ __/ ___/ / /
30
+ > > / // /\ \_\ \/ /__ < <
31
+ /_/ \___/___/___/\___/ \_\
32
+
33
+ JavaScript String Compressor
34
+ https://jssc.js.org/
35
+
36
+ npm i strc
35
37
 
36
38
  */
37
39
 
38
- (function (root, factory) {
39
- if (typeof define === 'function' && define.amd) {
40
- define(['justc'], factory); /* amd */
41
- } else if (typeof module === 'object' && module.exports) {
42
- const exports = factory(require('justc')); /* node */
43
- module.exports = {...exports, default: exports};
44
- } else {
45
- root.JSSC = factory(root.JUSTC); /* browsers */
46
- Object.freeze(root.JSSC);
47
- }
48
- }(typeof self !== 'undefined' ? self : this, function (JUSTC) {
40
+ (function (global, factory) {
41
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
42
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
43
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSSC = {}));
44
+ })(this, (function (exports) { 'use strict';
45
+
46
+ const JUSTC = require('justc');
47
+
49
48
  const name__ = 'JSSC';
50
49
  const prefix = name__+': ';
51
50
  if ((String.fromCharCode(65536).charCodeAt(0) === 65536) || !(String.fromCharCode(256).charCodeAt(0) === 256)) {
@@ -67,14 +66,6 @@ SOFTWARE.
67
66
  return {max, output, maxCharCode, min};
68
67
  }
69
68
 
70
- function codesString(cds) {
71
- let output = '';
72
- cds.forEach(code => {
73
- output += String.fromCharCode(code);
74
- });
75
- return output
76
- }
77
-
78
69
  function charCode(num) {
79
70
  return String.fromCharCode(num + 32);
80
71
  }
@@ -85,7 +76,7 @@ SOFTWARE.
85
76
  function stringChunks(str, num) {
86
77
  const output = [];
87
78
  for (let i = 0; i < str.length; i += num) {
88
- output.push(str.slice(i, i + num))
79
+ output.push(str.slice(i, i + num));
89
80
  }
90
81
  return output
91
82
  }
@@ -304,7 +295,7 @@ SOFTWARE.
304
295
  for (const char of _JSSC._BASE.concat(_JSSC._Ind)) {
305
296
  chrsBase[i++] = _JSSC._char(char);
306
297
  if (i === 91) {
307
- i = 97
298
+ i = 97;
308
299
  }
309
300
  }
310
301
  return chrsBase
@@ -315,7 +306,7 @@ SOFTWARE.
315
306
  _JSSC._BN = function(baseOrLatin) {
316
307
  const chrsBase = baseOrLatin();
317
308
  for (let i = 2432; i < 2559; i++) {
318
- chrsBase[i - 2304] = _JSSC._char(i) /* Unicode 0980 - 09FF */
309
+ chrsBase[i - 2304] = _JSSC._char(i); /* Unicode 0980 - 09FF */
319
310
  }
320
311
  chrsBase[255] = _JSSC._char(2404);
321
312
  return chrsBase;
@@ -326,7 +317,7 @@ SOFTWARE.
326
317
  for (const char of _JSSC._BASE.concat(_JSSC._Ind)) {
327
318
  chrsBase[i++] = _JSSC._char(char);
328
319
  if (i === 91) {
329
- i = 97
320
+ i = 97;
330
321
  }
331
322
  }
332
323
  return chrsBase;
@@ -424,7 +415,7 @@ SOFTWARE.
424
415
  chrsBase[i - 1536] = _JSSC._char(i);
425
416
  }
426
417
  return chrsBase;
427
- }
418
+ };
428
419
  _JSSC.use = class {
429
420
  constructor() {
430
421
  let output = {};
@@ -477,21 +468,21 @@ SOFTWARE.
477
468
  return binToDec(sixteenBits);
478
469
  }
479
470
  }
480
- /* Code 1 usage table */
481
- /* ------------------ */
482
- /* 00: No compression */
483
- /* 01: CharCode.len=2 */
484
- /* 02: ASCII in UTF16 */ /* Yeah ik thats not actually matches ASCII */
485
- /* 03: Integers (Any) */
486
- /* 04: Build Alphabet */
487
- /* 05: Char Encodings */
488
- /* 06: Integers (>15) */
489
- /* 07: Frequency Map */
490
- /* 08: URL to binary */
491
- /* 09: Segmt compress */
492
- /* 10: Repeating strs */
493
- /* 11 - 30: Reserved */
494
- /* 31: Rcrsv compress */
471
+ /* Code 1 usage table */
472
+ /* ------------------------------------ */
473
+ /* 00: No Compression */
474
+ /* 01: Two-Digit CharCode Concatenation */
475
+ /* 02: Two-Byte CharCode Concatenation */
476
+ /* 03: Decimal Integer Packing */
477
+ /* 04: Alphabet Encoding */
478
+ /* 05: Character Encoding */
479
+ /* 06: Inline Integer Encoding */
480
+ /* 07: Frequency Map */
481
+ /* 08: URL */
482
+ /* 09: Segmentation */
483
+ /* 10: String Repetition */
484
+ /* 11 - 30: Reserved */
485
+ /* 31: Recursive Compression */
495
486
 
496
487
  const SEQUENCE_MARKER = '\uDBFF'; /* Private Use Area */
497
488
 
@@ -621,9 +612,9 @@ SOFTWARE.
621
612
 
622
613
  if (i + length > str.length) {
623
614
  result += SEQUENCE_MARKER +
624
- String.fromCharCode(length + 32) +
625
- String.fromCharCode(count + 32) +
626
- str.slice(i);
615
+ String.fromCharCode(length + 32) +
616
+ String.fromCharCode(count + 32) +
617
+ str.slice(i);
627
618
  break;
628
619
  }
629
620
 
@@ -745,7 +736,7 @@ SOFTWARE.
745
736
  }
746
737
  }
747
738
  };
748
-
739
+
749
740
  const freqMapSplitters = [
750
741
  " \u200B","\u0000",
751
742
  "\u001F", "\u0001",
@@ -868,8 +859,7 @@ SOFTWARE.
868
859
  str = str.slice(begin.length);
869
860
  break;
870
861
  }
871
- };
872
-
862
+ }
873
863
  let code3 = -1;
874
864
  async function toJUSTC(obj) {
875
865
  try {
@@ -971,7 +961,7 @@ SOFTWARE.
971
961
  const candidates = [];
972
962
 
973
963
  if (/^\d+$/.test(str)) {
974
- /* Integers ( < 15 ) */
964
+ /* Inline Integer Encoding */
975
965
  candidates.push(async () => {
976
966
  const out = await (async () => {
977
967
  const num = parseInt(str);
@@ -986,7 +976,7 @@ SOFTWARE.
986
976
  if (!(await validate(out))) return null;
987
977
  return out;
988
978
  });
989
- /* Integers (any) */
979
+ /* Decimal Integer Packing */
990
980
  candidates.push(async () => {
991
981
  const convertNums = {
992
982
  'A': 10,
@@ -1008,8 +998,7 @@ SOFTWARE.
1008
998
  } else {
1009
999
  binOut.push(decToBin(convertNums[character], 4));
1010
1000
  }
1011
- };
1012
- let [output, RLE, sequences] = ['', false, false];
1001
+ } let [output, RLE, sequences] = ['', false, false];
1013
1002
  function binPadStart(bin) {
1014
1003
  if (bin.length < 16) {
1015
1004
  const numm = 4 - stringChunks(bin, 4).length;
@@ -1026,6 +1015,7 @@ SOFTWARE.
1026
1015
  });
1027
1016
  }
1028
1017
 
1018
+ /* Two-Digit CharCode Concatenation */
1029
1019
  candidates.push(async () => {
1030
1020
  const strdata = stringCodes(str);
1031
1021
  if (!(strdata.max === 2 && strdata.min === 2)) return null;
@@ -1046,19 +1036,19 @@ SOFTWARE.
1046
1036
  for (const char of chars) {
1047
1037
  addChar(char);
1048
1038
  }
1049
- sliceChars(chars.length)
1039
+ sliceChars(chars.length);
1050
1040
  } else {
1051
1041
  const a1 = parseInt(String(chars[0]) + String(chars[1]) + String(chars[2]));
1052
1042
  const a2 = parseInt(String(chars[0]) + String(chars[1]));
1053
1043
  if (checkChar(a1)) {
1054
1044
  addChar(a1);
1055
- sliceChars(3)
1045
+ sliceChars(3);
1056
1046
  } else if (checkChar(a2)) {
1057
1047
  addChar(a2);
1058
- sliceChars(2)
1048
+ sliceChars(2);
1059
1049
  } else {
1060
1050
  addChar(chars[0]);
1061
- sliceChars(1)
1051
+ sliceChars(1);
1062
1052
  }
1063
1053
  }
1064
1054
  }
@@ -1068,7 +1058,7 @@ SOFTWARE.
1068
1058
  return res;
1069
1059
  });
1070
1060
 
1071
- /* ASCII in UTF-16 */
1061
+ /* Two-Byte CharCode Concatenation */
1072
1062
  candidates.push(async () => {
1073
1063
  const strdata = stringCodes(str);
1074
1064
  if (strdata.maxCharCode >= 256) return null;
@@ -1086,7 +1076,7 @@ SOFTWARE.
1086
1076
  return res;
1087
1077
  });
1088
1078
 
1089
- /* Character encodings */
1079
+ /* Character Encoding */
1090
1080
  candidates.push(async () => {
1091
1081
  const characterEncodings = new _JSSC.use();
1092
1082
  const stringArray = str.split('');
@@ -1126,7 +1116,7 @@ SOFTWARE.
1126
1116
  }
1127
1117
  let [outputStr, repeatAfter, seq] = ['', false, false];
1128
1118
  for (const characterCode of convertCharCodes) {
1129
- outputStr += String.fromCharCode(binToDec(characterCode))
1119
+ outputStr += String.fromCharCode(binToDec(characterCode));
1130
1120
  }
1131
1121
 
1132
1122
  [outputStr, repeatAfter, seq] = processOutput(outputStr);
@@ -1136,7 +1126,7 @@ SOFTWARE.
1136
1126
  return null;
1137
1127
  });
1138
1128
 
1139
- /* Build alphabet */
1129
+ /* Alphabet Encoding */
1140
1130
  candidates.push(async () => {
1141
1131
  const uniq = [...new Set(str.split('').map(c => c.charCodeAt(0)))];
1142
1132
  if (uniq.length >= 16) return null;
@@ -1165,7 +1155,7 @@ SOFTWARE.
1165
1155
  return res;
1166
1156
  });
1167
1157
 
1168
- /* Frequency map */
1158
+ /* Frequency Map */
1169
1159
  candidates.push(async () => {
1170
1160
  for (const splitter of freqMapSplitters) {
1171
1161
  const test = freqMap.test(str, splitter);
@@ -1272,7 +1262,7 @@ SOFTWARE.
1272
1262
  const segOpts = {
1273
1263
  ...opts,
1274
1264
  segmentation: false
1275
- }
1265
+ };
1276
1266
  const compressed = await compress(seg, segOpts);
1277
1267
 
1278
1268
  out += String.fromCharCode(seg.length);
@@ -1297,7 +1287,7 @@ SOFTWARE.
1297
1287
  return res;
1298
1288
  });
1299
1289
 
1300
- /* Repeating string */
1290
+ /* String Repetition */
1301
1291
  const rcheck = str.match(/^(.{1,7}?)(?:\1)+$/);
1302
1292
  if (rcheck) candidates.push(async () => {
1303
1293
  const main = rcheck[1];
@@ -1346,15 +1336,14 @@ SOFTWARE.
1346
1336
  best = rc;
1347
1337
  }
1348
1338
  }
1349
- } catch (_){};
1350
-
1339
+ } catch (_){}
1351
1340
  return best;
1352
1341
  }
1353
1342
 
1354
1343
  function characterEncodings(id, realstr) {
1355
1344
  const strcode2charencoding = {};
1356
1345
  for (const [name, code] of Object.entries(_JSSC._IDs)) {
1357
- strcode2charencoding[code] = name
1346
+ strcode2charencoding[code] = name;
1358
1347
  }
1359
1348
  const possibleCharEncoding = strcode2charencoding[id];
1360
1349
  if (possibleCharEncoding) {
@@ -1417,7 +1406,9 @@ SOFTWARE.
1417
1406
  */
1418
1407
  async function decompress(str, stringify = false) {
1419
1408
  if (typeof str != 'string') throw new Error(prefix+'Invalid input.');
1420
- const strcodes = cryptCharCode(str.charCodeAt(0) - 32, true);
1409
+ const strcodes = cryptCharCode((
1410
+ (str.charCodeAt(0) - 32 + 65535) % 65535
1411
+ ), true);
1421
1412
  const strcode = strcodes.code;
1422
1413
 
1423
1414
  function repeatChars(txt) {
@@ -1613,7 +1604,7 @@ SOFTWARE.
1613
1604
  }
1614
1605
  }
1615
1606
 
1616
- return {
1607
+ var index = {
1617
1608
  compress,
1618
1609
  decompress,
1619
1610
  get [Symbol.toStringTag]() {
@@ -1621,4 +1612,10 @@ SOFTWARE.
1621
1612
  }
1622
1613
  };
1623
1614
 
1615
+ exports.compress = compress;
1616
+ exports.decompress = decompress;
1617
+ exports.default = index;
1618
+
1619
+ Object.defineProperty(exports, '__esModule', { value: true });
1620
+
1624
1621
  }));
package/index.min.js CHANGED
@@ -25,14 +25,16 @@ SOFTWARE.
25
25
  */
26
26
 
27
27
  /*
28
- _______________
29
- __ / / __/ __/ ___/
30
- / // /\ \_\ \/ /__
31
- \___/___/___/\___/
32
-
33
- JavaScript String Compressor
34
- https://jssc.js.org/
28
+ __ _______________ __
29
+ \ \ __ / / __/ __/ ___/ / /
30
+ > > / // /\ \_\ \/ /__ < <
31
+ /_/ \___/___/___/\___/ \_\
32
+
33
+ JavaScript String Compressor
34
+ https://jssc.js.org/
35
+
36
+ npm i strc
35
37
 
36
38
  */
37
39
 
38
- ((e,r)=>{var t;"function"==typeof define&&define.amd?define(["justc"],r):"object"==typeof module&&module.exports?(t=r(require("justc")),module.exports={...t,default:t}):(e.JSSC=r(e.JUSTC),Object.freeze(e.JSSC))})("undefined"!=typeof self?self:this,function(U){let x="JSSC",J=x+": ";if(65536===String.fromCharCode(65536).charCodeAt(0)||256!==String.fromCharCode(256).charCodeAt(0))throw new Error(J+"Supported UTF-16 only!");function _(e){let r=[],t=0,n=0,o=1/0;return String(e).split("").forEach(e=>{e=e.charCodeAt();r.push(e),t=Math.max(t,e.toString().length),n=Math.max(n,e),o=Math.min(o,e.toString().length)}),{max:t,output:r,maxCharCode:n,min:o}}function b(e){return String.fromCharCode(e+32)}function E(e){return e%65535===e}function q(r,t){var n=[];for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function I(r,t){var n=[];for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function H(e,r){return e.toString(2).padStart(r,"0")}function k(e){return parseInt(e,2)}function o(){let r={};function t(e){r[e]=String.fromCharCode(e)}for(let e=0;e<65;e++)t(e);for(let e=91;e<97;e++)t(e);for(let e=123;e<128;e++)t(e);return r}function n(){var r={};for(let e=0;e<128;e++)r[e]=String.fromCharCode(e);return r}let P={};function L(e,r=!1,t=!1,n=!1,o=-1,a=0,i=!1,f=-1){var s,c,l;return r?(s=(r=H(e,16)).slice(8,11).split(""),c=k(r.slice(11)),l=k(r.slice(5,8)),{code:c,repeatBefore:"1"===s[0],repeatAfter:"1"===s[1],beginId:"1"===s[2]?l:-1,code2:k(r.slice(0,4)),sequences:"1"===r.slice(4,5),code3:"0"===s[2]?l:-1,bin:r}):k(H(a,4)+(i?"1":"0")+H(0<=o?o:f<0?0:f,3)+(t?"1":"0")+(n?"1":"0")+(0<=o?"1":"0")+H(e,5))}P._char=e=>String.fromCharCode(e),P._IDs={BASE:0,RU:1,ENRU:2,ENKK:3,HI:4,ENHI:5,BN:6,ENBN:7,HIBN:8,JA:9,Telu:10,MR:11,B:12,E:13,AR:14},P.BASE=function(){var e,r=o(),t=[215,247,8722,11800,174,169,171,10003,182,9834,183,10005,177,181,8960,8211,8212,8228,8229,8230,8240,8241,8249,8250,8252,8253,8263,8264,8267,8270,8274,8451,8457,8470,8471,8482,402,1423,1547,65020,2547,2553,2555,2801,3065,3647,6107,8499,2546,8304,185,178,179,8585,8319,8305,8709,8730,8734];for(let e=161;e<168;e++)t.push(e);for(let e=187;e<192;e++)t.push(e);for(let e=8308;e<8317;e++)t.push(e);for(let e=8528;e<8576;e++)t.push(e);for(let e=8352;e<8385;e++)t.push(e);for(let e=8320;e<8333;e++)t.push(e);for(let e=8712;e<8718;e++)t.push(e);let n=65;for(e of t)r[n++]=P._char(e),91===n?n=97:123===n&&(n=128);return r},P._BASE=[167,8722,8451,169,8211,215,247,8457,174,8470,8482,8471,8249,8250,171,187,8242,8245,8216,8217,8218,8219,8243,8246,8220,8221,8222,8223,8226,182,8267,8270,8240,8241,9834,183,8228,8229,8230,161,191,8252,8264],P._MATH=[8544,8547,8550,8553,8556,8572,8545,8548,8551,8554,8557,8573,8546,8549,8552,8555,8558,8574,8560,8563,8566,8569,8559,8575,8561,8564,8567,8570,8562,8565,8568,8571,8712,8715,8713,8716,8730,8721,8734,8804,8805],P._CURR=[165,3647,8363,8361,1423,8364,8377,8362,8378,8353,8358,163,8381,8354,8369,2547,8370,8366,8376,8382,8357,6107,8360,8372,8373,8365,1547,2801,162,65020,8355,8383,8380,3065,164,8384,8379,402,8359,2546,8371,8367,8356,8375,2553,8368,8352,8499,8374,2555],P._RU=function(e){var r=e();let t=0;for(let e=1040;e<1104;e++){var n=e-912;r[n]=P._char(e),t=Math.max(t,n)}return r[t+1]=P._char(1025),r[t+2]=P._char(1105),r},P.RU=function(){var e,r=P._RU(o);let t=65;for(e of P._BASE.concat(P._MATH,[105,239,1028,1030,1031,1108,1110,1111,1118,1038,1241,1181,1171,1199,1201,1179,1257,1211,1240,1186,1170,1198,1200,1178,1256,1210,8381,8364,165,8376,8372]))r[t++]=P._char(e),91===t?t=97:123===t&&(t=193);return r[110]="i",r[111]="I",r},P.ENRU=function(){var e,r=P._RU(n);let t=194;for(e of P._BASE.concat([105,239,1028,1030,1031,1108,1110,1111,1118,1038,8381,8364,165,8376,8372,163,8380],[215,247]))r[t++]=P._char(e);return r},P.ENKK=function(){var e,r=P._RU(n);let t=194;for(e of P._BASE.concat([1241,1181,1171,1199,1201,1179,1257,1211,1240,1186,1170,1198,1200,1178,1256,1210,8381,163,8376]))r[t++]=P._char(e);return r},P._HI=function(e){var r=e();for(let e=2304;e<2432;e++)r[e-2176]=P._char(e);return r},P._Ind=[8377,8360,78,2547,2404,215,247],P.HI=function(){var e,r=P._HI(o);let t=65;for(e of P._BASE.concat(P._Ind))r[t++]=P._char(e),91===t&&(t=97);return r},P.ENHI=function(){return P._HI(n)},P._BN=function(e){var r=e();for(let e=2432;e<2559;e++)r[e-2304]=P._char(e);return r[255]=P._char(2404),r},P.BN=function(){var e,r=P._BN(o);let t=65;for(e of P._BASE.concat(P._Ind))r[t++]=P._char(e),91===t&&(t=97);return r},P.ENBN=function(){return P._BN(n)},P.HIBN=function(){var r={};for(let e=2304;e<2559;e++)r[e-2176-128]=P._char(e);return r[255]=" ",r},P._JA=[[65371,65373,65288,65289,65339,65341,12304,12305,12289,65292,12290,12349,12300,12301,12302,12303,12288,12316,65306,65281,65311,12445,12541,183],[8230,8229,165]],P.JA=function(){var e,r=n();let t=128;for(e of P._JA[0].concat(Array.from({length:46},(e,r)=>r+12352),Array.from({length:46},(e,r)=>r+12448),P._JA[1],[19968,20108,19977,22235,20116,20845,19971,20843,20061]))r[t++]=P._char(e);return r[17]=P._char(21313),r[18]=P._char(30334),r[19]=P._char(21315),r[20]=P._char(19975),r},P.Telu=function(){var e,r=n();for(let e=3073;e<3184;e++)r[e-2945]=P._char(e);let t=239;for(e of P._Ind.concat([8364,163,162,165,167,169,174,8482,8240,8241]))r[t++]=P._char(e);return r},P.MR=function(){var r=n();for(let e=2304;e<2432;e++)r[e-2176]=P._char(e);return r},P.B=function(){var r=n();for(let e=256;e<383;e++)r[e-128]=P._char(e);return r[255]=P._char(383),r},P.E=function(){var r=n();for(let e=128;e<255;e++)r[e]=P._char(e);return r[255]=P._char(383),r},P.AR=function(){var r={};for(let e=1536;e<1791;e++)r[e-1536]=P._char(e);return r},P.use=class{constructor(){var e,r,t={};for([e,r]of Object.entries(P))"function"!=typeof r||e.startsWith("_")||"use"==e||(t[x+e]=r);return Object.freeze(t),t}},P._begin=["https://","http://","file://","mailto:","ftp://","data:","tel:","sms:"],Object.freeze(P.use);let D="\udbff";function j(e){if(e.length<20)return{compressed:e,sequences:!1};if(e.includes(D))return{compressed:e,sequences:!1};var r=((o,e,a)=>{var i=[],f=o.length;for(let n=0;n<f-e*a+1;n++)for(let t=2;t<=Math.min(30,Math.floor((f-n)/a));t++){var s=o.substr(n,t);if(!s.includes(D)){let r=1;for(let e=n+t;e<=f-t&&o.substr(e,t)===s;e+=t)r++;if(r>=a){var c,l=n+t*r;let e=!1;for(c of i)if(n<c.end&&l>c.start){e=!0;break}if(!e){i.push({start:n,end:l,length:t,pattern:s,count:r,saved:t*r-(t+3)}),n=l-1;break}}}}return i.sort((e,r)=>r.saved-e.saved)})(e,2,3);if(0===r.length)return{compressed:e,sequences:!1};var t,n,o=[],a=new Array(e.length).fill(!1);for(t of r){let r=!0;for(let e=t.start;e<t.end;e++)if(a[e]){r=!1;break}if(r&&0<t.saved){o.push(t);for(let e=t.start;e<t.end;e++)a[e]=!0}}if(0===o.length)return{compressed:e,sequences:!1};let i="",f=0;for(n of o){f<n.start&&(i+=e.slice(f,n.start));var s=String.fromCharCode(Math.min(n.length,30)+32),c=String.fromCharCode(Math.min(n.count,65535)+32);i+=D+s+c+n.pattern,f=n.end}return f<e.length&&(i+=e.slice(f)),i.length<.9*e.length?{compressed:i,sequences:!0}:{compressed:e,sequences:!1}}let F={ESCAPE_BYTE:255,TOP_COUNT:254,SPLITTER:" ​",compress(e,r=this.SPLITTER){var t,n={};for(t of e)n[t]=(n[t]||0)+1;var o,a,i=Object.entries(n).sort((e,r)=>r[1]-e[1]).slice(0,this.TOP_COUNT).map(e=>e[0]),f=new Map(i.map((e,r)=>[e,r])),i=String.fromCharCode(i.length)+i.join(""),s=[];for(o of e)f.has(o)?s.push(f.get(o)):(s.push(this.ESCAPE_BYTE),a=o.charCodeAt(0),s.push(a>>8&255),s.push(255&a));let c="";for(let e=0;e<s.length;e+=2){var l=s[e],u=e+1<s.length?s[e+1]:0;c+=String.fromCharCode(l<<8|u)}return i+r+c},decompress(e,r=this.SPLITTER){e=e.split(r);if(e.length<2)throw new Error(J+"Invalid freqMap data: splitter not found");var t=e[0],n=e.slice(1).join(r),o=t.charCodeAt(0),a=t.substring(1,o+1),i=[];for(let e=0;e<n.length;e++){var f=n.charCodeAt(e);i.push(f>>8&255),i.push(255&f)}let s="";for(let e=0;e<i.length;e++){var c,l=i[e];l===this.ESCAPE_BYTE?(c=i[e+1]<<8|i[e+2],s+=String.fromCharCode(c),e+=2):l<o&&(s+=a[l])}return s},test(e,r=this.SPLITTER){try{var t,n;return e.includes(r)?0:(t=this.compress(e,r),n=this.decompress(t,r),t.length<e.length?n==e?[1,t.length,r,t]:n.slice(0,-1)==e?[2,t.length,r,t]:0:0)}catch(e){return 0}}},z=[" ​","\0","","","�","•","|§|","\ufeff"];async function compress(e,r){if("string"!=typeof e&&"object"!=typeof e&&"number"!=typeof e)throw new Error(J+"Invalid input.");let o={segmentation:!0,recursivecompression:!0,justc:!!U};if(r){if("object"!=typeof r)throw new Error(J+"Invalid options input.");for(var[t,n]of Object.entries(r))if(void 0!==n){if("boolean"!=typeof n)throw new Error(J+"Invalid options input.");t.toLowerCase()in o?o[t.toLowerCase()]=n:console.warn(J+`Unknown option: "${t}".`)}}let a=e,g=e,c=!1;if("number"==typeof g&&(c=!0,(g=g.toString()).includes(".")))throw new Error(J+"Invalid input.");let v=!1;function i(e){return e.replace(/(.)\1+/g,(e,r)=>r+e.length)}let C=-1;if("string"==typeof g)for(var f of P._begin)if(g.startsWith(f)){C=P._begin.indexOf(f),g=g.slice(f.length);break}let m=-1;async function s(r){try{var e=await U.stringify(r);return e&&"function"==typeof e.then?await e:e}catch(e){return await U.initialize(),U.stringify(r)}}if(-1==C)if("object"==typeof g&&Array.isArray(g))g=JSON.stringify(g).slice(1,-1),m=4;else if("object"==typeof g)try{m=o.justc?(p=await s(g),g=p,2):(g=JSON.stringify(g),6)}catch(e){r=new Error(J+"Invalid input.");throw new AggregateError([r,e],r.message)}else try{var l=JSON.parse(g);m=Array.isArray(l)?(g=g.slice(1,-1),3):(h=!!o.justc&&await s(l))&&h.length<g.length&&g==JSON.stringify(l)?(g=h,1):(g=g.slice(1,-1),5)}catch(e){}function S(e,r=!1){let t=!1,n=!1;if(/\d/.test(e)||(t=!0,e=i(e)),!r){r=j(e);if(r.sequences)return n=!0,[r.compressed,t,n]}return[e,t,n]}/\d/.test(g)||(g=i(g),v=!0);let y=async e=>{try{return await decompress(e,!0)===String(a)}catch{return!1}};e=[];/^\d+$/.test(g)&&(e.push(async()=>{var e=await((e=parseInt(g))<15?b(L(c?6:0,!1,!1,!1,-1,e+1,!1,m)):null);return e&&await y(e)?e:null}),e.push(async()=>{var e,r,t,n,o={A:10,B:11,C:12,D:13,E:14},a=[];for(e of g.replaceAll("10","A").replaceAll("11","B").replaceAll("12","C").replaceAll("13","D").replaceAll("14","E").split(""))/\d/.test(e)?a.push(H(parseInt(e),4)):a.push(H(o[e],4));let[i,f,s]=["",!1,!1];for(r of I(a,4))i+=String.fromCharCode(k((t=r.join(""),n=void 0,t.length<16?(n=4-q(t,4).length,H(15,4).repeat(n)+t):t)));return[i,f,s]=S(i),i=b(L(3,!1,c,f,-1,0,s,m))+i,await y(i)?i:null})),e.push(async()=>{var e=_(g);if(2!==e.max||2!==e.min)return null;let r=e.output,[t,n,o]=["",!1,!1];function a(e){t+=String.fromCharCode(e)}function i(e){r=r.slice(e)}for(;0<r.length;)if(1===r.length)a(r[0]),i(1);else if(r.length<3){for(var f of r)a(f);i(r.length)}else{var s=parseInt(String(r[0])+String(r[1])+String(r[2])),c=parseInt(String(r[0])+String(r[1]));E(s)?(a(s),i(3)):E(c)?(a(c),i(2)):(a(r[0]),i(1))}[t,n,o]=S(out);e=b(L(1,!1,v,n,C,0,o,m))+t;return await y(e)?e:null}),e.push(async()=>{var r;if(256<=_(g).maxCharCode)return null;let[t,e,n]=["",!1,!1];for(r of q(g,2)){let e="";for(var o of r)e+=H(o.charCodeAt(0),8);t+=String.fromCharCode(k(e))}[t,e,n]=S(t);var a=b(L(2,!1,v,e,C,0,n,m))+t;return await y(a)?a:null}),e.push(async()=>{var r,t,e=new P.use,n=g.split("");let o,a=NaN;for([r,t]of Object.entries(e)){var i,f=t(),s=(f.length=256,Array.from(f));let e=!0;for(i of n)if(!s.includes(i)){e=!1;break}if(e){o=t(),a=P._IDs[r.slice(4)];break}}if(o){var c={};for(let[e,r]of Object.entries(o))c[r]=e;var l,u,h,p=[],d=[];for(l of n)p.push(H(parseInt(c[l]),8));for(u of I(p,2))d.push(u.join("").padStart(16,"0"));let[e,r,t]=["",!1,!1];for(h of d)e+=String.fromCharCode(k(h));if([e,r,t]=S(e),e=b(L(5,!1,v,r,C,a,t,m))+e,await y(e))return e}return null}),e.push(async()=>{var e=[...new Set(g.split("").map(e=>e.charCodeAt(0)))];if(16<=e.length)return null;let r=e.map(e=>String.fromCharCode(e)).join(""),t=[];var n,[o,a]=[!1,!1];for(n of g)t.push(e.indexOf(n.charCodeAt(0))),4===t.length&&(r+=String.fromCharCode(k(t.map(e=>H(e,4)).join(""))),t=[]);t.length&&(r+=String.fromCharCode(k(t.map(e=>H(e,4)).join("").padStart(16,"1")))),[r,o,a]=S(r);o=b(L(4,!1,v,o,C,e.length,a,m))+r;return await y(o)?o:null}),e.push(async()=>{for(var e of z){e=F.test(g,e);if(Array.isArray(e)){var[,,r,t]=e,e=b(L(7,!1,!1,!1,-1,k((e[0]-1).toString()+H(z.indexOf(r),3))))+t;if(await y(e))return e}}return null}),e.push(async()=>{if("string"!=typeof g)return null;let e;try{e=new URL(P._begin[C]+g)}catch{return null}var r=e.href,t=/%[0-9A-Fa-f]{2}/.test(r),n=e.hostname.includes("xn--"),o=!!e.search,a=!!e.hash;let i=r.slice(P._begin[C].length);n&&"undefined"!=typeof punycode&&(e.hostname=punycode.toUnicode(e.hostname),i=e.href.slice(P._begin[C].length));var f=[];for(let e=0;e<i.length;e++){if("%"===i[e]&&e+2<i.length){var s=i.slice(e+1,e+3);if(/^[0-9A-Fa-f]{2}$/.test(s)){f.push(parseInt(s,16)),e+=2;continue}}f.push(i.charCodeAt(e))}r=1&f.length;r&&f.push(0);let c="";for(let e=0;e<f.length;e+=2)c+=String.fromCharCode(f[e]<<8|(f[e+1]??0));t=(t?1:0)|(n?2:0)|(o?4:0)|(a?8:0),n=!1,[c,n]=S(c,!0),o=b(L(8,!1,v,n,C,t,r,m))+c;return await y(o)?o:null}),o.segmentation&&e.push(async()=>{var e,r=(r=>{if("string"!=typeof r||0===r.length)return[];var t=[];let n=r[0];for(let e=1;e<r.length;e++){var o=r.charCodeAt(e-1),a=r.charCodeAt(e);128<Math.abs(a-o)?(t.push(n),n=r[e]):n+=r[e]}return n&&t.push(n),t})(g);if(r.length<2)return null;let t=r.length-2<15?"":String.fromCharCode(r.length-2);for(e of r){var n={...o,segmentation:!1},n=await compress(e,n);t=t+String.fromCharCode(e.length)+n}r=b(L(9,!1,v,o.justc,C,Math.min(r.length-2,15),o.recursivecompression,m))+t;return await y(r)?r:null});let u=g.match(/^(.{1,7}?)(?:\1)+$/);u&&e.push(async()=>{var e,r,t,n=u[1],o=g.length/n.length;return!(Math.floor(o)!=o||o<1||65550<o)&&([e,r,t]=["",!1,!1],[e,r,t]=S(n),n=b(L(10,!1,v,r,C,Math.min(o-1,15),t,m))+(14<o-1?String.fromCharCode(o-15):"")+e,await y(n))?n:null});var h,p=(await Promise.all(e.map(e=>(async e=>{try{return await e()}catch{return null}})(e)))).filter(e=>"string"==typeof e&&e.length<=String(g).length);let d;if(d=p.length?p.reduce((e,r)=>r.length<e.length?r:e):([r,l]=[!1,!1],[g,r,l]=S(h=g),await y(g)?b(L(0,!1,v,r,C,0,l,m))+g:b(L(0,!1,v,!1,C,0,!1,m))+h),o.recursivecompression)try{for(var A of p){var w=await(async(e,r)=>{if(!r.recursivecompression)return e;let t=e,n=0;for(;n<15;){n++;var o=await compress(t,{...r,recursivecompression:!1});if(o.length>=t.length)break;if(await decompress(o,!0)!==t)break;t=o}return 0===n?null:b(L(31,!1,!1,!1,-1,n,!1,-1))+t})(A,o);w&&w.length<=d.length&&await y(w)&&(d=w)}}catch(e){}return d}async function decompress(e,t=!1){if("string"!=typeof e)throw new Error(J+"Invalid input.");let n=L(e.charCodeAt(0)-32,!0),o=n.code;function a(e){return e.replace(/(\D)(\d+)/g,(e,r,t)=>r.repeat(t))}let i=e.slice(1);async function f(e){var r;return 0<=n.beginId?P._begin[n.beginId]+e:1==n.code3||2==n.code3?(r=await(async r=>{try{var e=U.parse(r);return e&&"function"==typeof e.then?await e:e}catch(e){if("undefined"!=typeof window)try{await U.initialize();var t=U.parse(r);return t&&"function"==typeof t.then?await t:t}catch{}return null}})(e))&&"function"==typeof r.then?JSON.stringify(await r):JSON.stringify(r):e}async function s(e){let r=e;return r=n.repeatBefore&&3!=o?a(await f(e)):await f(e),n.repeatBefore&&3==o||30==o?r=parseInt(r):(3==n.code3||4==n.code3?r="["+r+"]":5==n.code3&&(r="{"+r+"}"),2!=n.code3&&4!=n.code3&&6!=n.code3||(r=JSON.parse(r))),t&&("object"==typeof r?r=JSON.stringify(r):"number"==typeof r&&(r=r.toString())),r}n.sequences&&8!=o&&9!=o&&(i=(e=>{let r="",t=0;for(;t<e.length;)if(56319===e.charCodeAt(t))if(++t+2>=e.length)r+=D;else{var n=e.charCodeAt(t)-32,o=e.charCodeAt(t+1)-32;if((t+=2)+n>e.length){r+=D+String.fromCharCode(32+n)+String.fromCharCode(32+o)+e.slice(t);break}var a=e.substr(t,n);t+=n;for(let e=0;e<o;e++)r+=a}else r+=e.charAt(t),t++;return r})(i)),n.repeatAfter&&9!=o&&(i=a(i));let r="";switch(o){case 0:case 6:return 0<n.code2?s(String(n.code2-1)):s(i);case 1:function c(e){r+=String.fromCharCode(e)}for(var l of i.split("")){var u,h=String(l.charCodeAt(0));if(2<h.length)for(u of q(h,2))c(parseInt(u));else c(l.charCodeAt(0))}return s(r);case 2:function p(e){return String.fromCharCode(k(e))}for(var d of i.split("")){var g,v=H(d.charCodeAt(0),16);8<H(d.charCodeAt(0),0).length?([v,g]=q(v,8),r+=p(v)+p(g)):(v=H(d.charCodeAt(0),8),r+=p(v))}return s(r);case 3:for(var C of i.split("")){var m;for(m of q(H(C.charCodeAt(0),16),4)){var S=k(m);15!=S&&(r+=S.toString(10))}}return s(r);case 4:var y,A,w,_,b=[];for(y of i.slice(0,n.code2).split(""))b.push(y);for(A of i.slice(n.code2).split(""))for(w of q(H(A.charCodeAt(0),16),4))"1111"!=w&&(_=k(w),r+=b[_]);return s(r);case 5:var E=((t,n)=>{var e,r,o,a={};for([e,r]of Object.entries(P._IDs))a[r]=e;if(t=a[t]){let r=(new P.use)[x+t](),e="";for(o of n.split("")){var i,f,s=o.charCodeAt();function c(e){return String(r[String(k(e))])}8<H(s,0).length?([f,i]=q(H(s,16),8),e+=c(f)+c(i)):(f=H(s,8),e+=c(f))}return e}})(n.code2,i);if(E)return s(E);throw new Error(J+"Invalid compressed string");case 7:E=z[k(H(n.code2).slice(1))];return r=F.decompress(i,E),s(r=1==parseInt(H(n.code2).slice(0,1))?r.slice(0,-1):r);case 8:{var I,j,N=[];for(I of i){var B=I.charCodeAt(0);N.push(B>>8&255,255&B)}n.sequences&&N.pop();let e="";for(j of N)e+=String.fromCharCode(j);return 1&n.code2&&(e=e.replace(/[\x00-\x20\x7F-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16).padStart(2,"0").toUpperCase())),2&n.code2&&"undefined"!=typeof punycode&&((E=new URL(e)).hostname=punycode.toASCII(E.hostname),e=E.href),s(e)}case 9:{let r=0;var O=n.code2<15?n.code2+2:i.charCodeAt(r++)+2;let t="";for(let e=0;e<O;e++){var T=i.charCodeAt(r++),T=(await decompress(i.slice(r),!0)).slice(0,T);t+=T,r+=(await compress(T,{segmentation:!1,justc:n.repeatAfter,recursivecompression:n.sequences})).length}return s(t)}case 10:var E=15==n.code2,R=E?i.charCodeAt(0)+15:n.code2;return s((i=E?i.slice(1):i).repeat(R));case 31:{let r=i;var M=n.code2;for(let e=0;e<M;e++){if(31===L(r.charCodeAt(0)-32,!0).code)throw new Error(J+"Attempt to nested recursive compression");r=await decompress(r,!0)}return r}default:throw new Error(J+"Invalid compressed string")}}return{compress:compress,decompress:decompress,get[Symbol.toStringTag](){return x}}});
40
+ ((e,r)=>{"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).JSSC={})})(this,function(e){let x=require("justc"),U="JSSC",J=U+": ";if(65536===String.fromCharCode(65536).charCodeAt(0)||256!==String.fromCharCode(256).charCodeAt(0))throw new Error(J+"Supported UTF-16 only!");function _(e){let r=[],t=0,n=0,o=1/0;return String(e).split("").forEach(e=>{e=e.charCodeAt();r.push(e),t=Math.max(t,e.toString().length),n=Math.max(n,e),o=Math.min(o,e.toString().length)}),{max:t,output:r,maxCharCode:n,min:o}}function b(e){return String.fromCharCode(e+32)}function E(e){return e%65535===e}function q(r,t){var n=[];for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function I(r,t){var n=[];for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function H(e,r){return e.toString(2).padStart(r,"0")}function P(e){return parseInt(e,2)}function o(){let r={};function t(e){r[e]=String.fromCharCode(e)}for(let e=0;e<65;e++)t(e);for(let e=91;e<97;e++)t(e);for(let e=123;e<128;e++)t(e);return r}function n(){var r={};for(let e=0;e<128;e++)r[e]=String.fromCharCode(e);return r}let k={};function L(e,r=!1,t=!1,n=!1,o=-1,a=0,i=!1,s=-1){var f,c,l;return r?(f=(r=H(e,16)).slice(8,11).split(""),c=P(r.slice(11)),l=P(r.slice(5,8)),{code:c,repeatBefore:"1"===f[0],repeatAfter:"1"===f[1],beginId:"1"===f[2]?l:-1,code2:P(r.slice(0,4)),sequences:"1"===r.slice(4,5),code3:"0"===f[2]?l:-1,bin:r}):P(H(a,4)+(i?"1":"0")+H(0<=o?o:s<0?0:s,3)+(t?"1":"0")+(n?"1":"0")+(0<=o?"1":"0")+H(e,5))}k._char=e=>String.fromCharCode(e),k._IDs={BASE:0,RU:1,ENRU:2,ENKK:3,HI:4,ENHI:5,BN:6,ENBN:7,HIBN:8,JA:9,Telu:10,MR:11,B:12,E:13,AR:14},k.BASE=function(){var e,r=o(),t=[215,247,8722,11800,174,169,171,10003,182,9834,183,10005,177,181,8960,8211,8212,8228,8229,8230,8240,8241,8249,8250,8252,8253,8263,8264,8267,8270,8274,8451,8457,8470,8471,8482,402,1423,1547,65020,2547,2553,2555,2801,3065,3647,6107,8499,2546,8304,185,178,179,8585,8319,8305,8709,8730,8734];for(let e=161;e<168;e++)t.push(e);for(let e=187;e<192;e++)t.push(e);for(let e=8308;e<8317;e++)t.push(e);for(let e=8528;e<8576;e++)t.push(e);for(let e=8352;e<8385;e++)t.push(e);for(let e=8320;e<8333;e++)t.push(e);for(let e=8712;e<8718;e++)t.push(e);let n=65;for(e of t)r[n++]=k._char(e),91===n?n=97:123===n&&(n=128);return r},k._BASE=[167,8722,8451,169,8211,215,247,8457,174,8470,8482,8471,8249,8250,171,187,8242,8245,8216,8217,8218,8219,8243,8246,8220,8221,8222,8223,8226,182,8267,8270,8240,8241,9834,183,8228,8229,8230,161,191,8252,8264],k._MATH=[8544,8547,8550,8553,8556,8572,8545,8548,8551,8554,8557,8573,8546,8549,8552,8555,8558,8574,8560,8563,8566,8569,8559,8575,8561,8564,8567,8570,8562,8565,8568,8571,8712,8715,8713,8716,8730,8721,8734,8804,8805],k._CURR=[165,3647,8363,8361,1423,8364,8377,8362,8378,8353,8358,163,8381,8354,8369,2547,8370,8366,8376,8382,8357,6107,8360,8372,8373,8365,1547,2801,162,65020,8355,8383,8380,3065,164,8384,8379,402,8359,2546,8371,8367,8356,8375,2553,8368,8352,8499,8374,2555],k._RU=function(e){var r=e();let t=0;for(let e=1040;e<1104;e++){var n=e-912;r[n]=k._char(e),t=Math.max(t,n)}return r[t+1]=k._char(1025),r[t+2]=k._char(1105),r},k.RU=function(){var e,r=k._RU(o);let t=65;for(e of k._BASE.concat(k._MATH,[105,239,1028,1030,1031,1108,1110,1111,1118,1038,1241,1181,1171,1199,1201,1179,1257,1211,1240,1186,1170,1198,1200,1178,1256,1210,8381,8364,165,8376,8372]))r[t++]=k._char(e),91===t?t=97:123===t&&(t=193);return r[110]="i",r[111]="I",r},k.ENRU=function(){var e,r=k._RU(n);let t=194;for(e of k._BASE.concat([105,239,1028,1030,1031,1108,1110,1111,1118,1038,8381,8364,165,8376,8372,163,8380],[215,247]))r[t++]=k._char(e);return r},k.ENKK=function(){var e,r=k._RU(n);let t=194;for(e of k._BASE.concat([1241,1181,1171,1199,1201,1179,1257,1211,1240,1186,1170,1198,1200,1178,1256,1210,8381,163,8376]))r[t++]=k._char(e);return r},k._HI=function(e){var r=e();for(let e=2304;e<2432;e++)r[e-2176]=k._char(e);return r},k._Ind=[8377,8360,78,2547,2404,215,247],k.HI=function(){var e,r=k._HI(o);let t=65;for(e of k._BASE.concat(k._Ind))r[t++]=k._char(e),91===t&&(t=97);return r},k.ENHI=function(){return k._HI(n)},k._BN=function(e){var r=e();for(let e=2432;e<2559;e++)r[e-2304]=k._char(e);return r[255]=k._char(2404),r},k.BN=function(){var e,r=k._BN(o);let t=65;for(e of k._BASE.concat(k._Ind))r[t++]=k._char(e),91===t&&(t=97);return r},k.ENBN=function(){return k._BN(n)},k.HIBN=function(){var r={};for(let e=2304;e<2559;e++)r[e-2176-128]=k._char(e);return r[255]=" ",r},k._JA=[[65371,65373,65288,65289,65339,65341,12304,12305,12289,65292,12290,12349,12300,12301,12302,12303,12288,12316,65306,65281,65311,12445,12541,183],[8230,8229,165]],k.JA=function(){var e,r=n();let t=128;for(e of k._JA[0].concat(Array.from({length:46},(e,r)=>r+12352),Array.from({length:46},(e,r)=>r+12448),k._JA[1],[19968,20108,19977,22235,20116,20845,19971,20843,20061]))r[t++]=k._char(e);return r[17]=k._char(21313),r[18]=k._char(30334),r[19]=k._char(21315),r[20]=k._char(19975),r},k.Telu=function(){var e,r=n();for(let e=3073;e<3184;e++)r[e-2945]=k._char(e);let t=239;for(e of k._Ind.concat([8364,163,162,165,167,169,174,8482,8240,8241]))r[t++]=k._char(e);return r},k.MR=function(){var r=n();for(let e=2304;e<2432;e++)r[e-2176]=k._char(e);return r},k.B=function(){var r=n();for(let e=256;e<383;e++)r[e-128]=k._char(e);return r[255]=k._char(383),r},k.E=function(){var r=n();for(let e=128;e<255;e++)r[e]=k._char(e);return r[255]=k._char(383),r},k.AR=function(){var r={};for(let e=1536;e<1791;e++)r[e-1536]=k._char(e);return r},k.use=class{constructor(){var e,r,t={};for([e,r]of Object.entries(k))"function"!=typeof r||e.startsWith("_")||"use"==e||(t[U+e]=r);return Object.freeze(t),t}},k._begin=["https://","http://","file://","mailto:","ftp://","data:","tel:","sms:"],Object.freeze(k.use);let D="\udbff";function N(e){if(e.length<20)return{compressed:e,sequences:!1};if(e.includes(D))return{compressed:e,sequences:!1};var r=((o,e,a)=>{var i=[],s=o.length;for(let n=0;n<s-e*a+1;n++)for(let t=2;t<=Math.min(30,Math.floor((s-n)/a));t++){var f=o.substr(n,t);if(!f.includes(D)){let r=1;for(let e=n+t;e<=s-t&&o.substr(e,t)===f;e+=t)r++;if(r>=a){var c,l=n+t*r;let e=!1;for(c of i)if(n<c.end&&l>c.start){e=!0;break}if(!e){i.push({start:n,end:l,length:t,pattern:f,count:r,saved:t*r-(t+3)}),n=l-1;break}}}}return i.sort((e,r)=>r.saved-e.saved)})(e,2,3);if(0===r.length)return{compressed:e,sequences:!1};var t,n,o=[],a=new Array(e.length).fill(!1);for(t of r){let r=!0;for(let e=t.start;e<t.end;e++)if(a[e]){r=!1;break}if(r&&0<t.saved){o.push(t);for(let e=t.start;e<t.end;e++)a[e]=!0}}if(0===o.length)return{compressed:e,sequences:!1};let i="",s=0;for(n of o){s<n.start&&(i+=e.slice(s,n.start));var f=String.fromCharCode(Math.min(n.length,30)+32),c=String.fromCharCode(Math.min(n.count,65535)+32);i+=D+f+c+n.pattern,s=n.end}return s<e.length&&(i+=e.slice(s)),i.length<.9*e.length?{compressed:i,sequences:!0}:{compressed:e,sequences:!1}}let F={ESCAPE_BYTE:255,TOP_COUNT:254,SPLITTER:" ​",compress(e,r=this.SPLITTER){var t,n={};for(t of e)n[t]=(n[t]||0)+1;var o,a,i=Object.entries(n).sort((e,r)=>r[1]-e[1]).slice(0,this.TOP_COUNT).map(e=>e[0]),s=new Map(i.map((e,r)=>[e,r])),i=String.fromCharCode(i.length)+i.join(""),f=[];for(o of e)s.has(o)?f.push(s.get(o)):(f.push(this.ESCAPE_BYTE),a=o.charCodeAt(0),f.push(a>>8&255),f.push(255&a));let c="";for(let e=0;e<f.length;e+=2){var l=f[e],u=e+1<f.length?f[e+1]:0;c+=String.fromCharCode(l<<8|u)}return i+r+c},decompress(e,r=this.SPLITTER){e=e.split(r);if(e.length<2)throw new Error(J+"Invalid freqMap data: splitter not found");var t=e[0],n=e.slice(1).join(r),o=t.charCodeAt(0),a=t.substring(1,o+1),i=[];for(let e=0;e<n.length;e++){var s=n.charCodeAt(e);i.push(s>>8&255),i.push(255&s)}let f="";for(let e=0;e<i.length;e++){var c,l=i[e];l===this.ESCAPE_BYTE?(c=i[e+1]<<8|i[e+2],f+=String.fromCharCode(c),e+=2):l<o&&(f+=a[l])}return f},test(e,r=this.SPLITTER){try{var t,n;return e.includes(r)?0:(t=this.compress(e,r),n=this.decompress(t,r),t.length<e.length?n==e?[1,t.length,r,t]:n.slice(0,-1)==e?[2,t.length,r,t]:0:0)}catch(e){return 0}}},z=[" ​","\0","","","�","•","|§|","\ufeff"];async function compress(e,r){if("string"!=typeof e&&"object"!=typeof e&&"number"!=typeof e)throw new Error(J+"Invalid input.");let o={segmentation:!0,recursivecompression:!0,justc:!!x};if(r){if("object"!=typeof r)throw new Error(J+"Invalid options input.");for(var[t,n]of Object.entries(r))if(void 0!==n){if("boolean"!=typeof n)throw new Error(J+"Invalid options input.");t.toLowerCase()in o?o[t.toLowerCase()]=n:console.warn(J+`Unknown option: "${t}".`)}}let a=e,g=e,c=!1;if("number"==typeof g&&(c=!0,(g=g.toString()).includes(".")))throw new Error(J+"Invalid input.");let v=!1;function i(e){return e.replace(/(.)\1+/g,(e,r)=>r+e.length)}let C=-1;if("string"==typeof g)for(var s of k._begin)if(g.startsWith(s)){C=k._begin.indexOf(s),g=g.slice(s.length);break}let m=-1;async function f(r){try{var e=await x.stringify(r);return e&&"function"==typeof e.then?await e:e}catch(e){return await x.initialize(),x.stringify(r)}}if(-1==C)if("object"==typeof g&&Array.isArray(g))g=JSON.stringify(g).slice(1,-1),m=4;else if("object"==typeof g)try{m=o.justc?(p=await f(g),g=p,2):(g=JSON.stringify(g),6)}catch(e){r=new Error(J+"Invalid input.");throw new AggregateError([r,e],r.message)}else try{var l=JSON.parse(g);m=Array.isArray(l)?(g=g.slice(1,-1),3):(h=!!o.justc&&await f(l))&&h.length<g.length&&g==JSON.stringify(l)?(g=h,1):(g=g.slice(1,-1),5)}catch(e){}function S(e,r=!1){let t=!1,n=!1;if(/\d/.test(e)||(t=!0,e=i(e)),!r){r=N(e);if(r.sequences)return n=!0,[r.compressed,t,n]}return[e,t,n]}/\d/.test(g)||(g=i(g),v=!0);let y=async e=>{try{return await decompress(e,!0)===String(a)}catch{return!1}};e=[];/^\d+$/.test(g)&&(e.push(async()=>{var e=await((e=parseInt(g))<15?b(L(c?6:0,!1,!1,!1,-1,e+1,!1,m)):null);return e&&await y(e)?e:null}),e.push(async()=>{var e,r,t,n,o={A:10,B:11,C:12,D:13,E:14},a=[];for(e of g.replaceAll("10","A").replaceAll("11","B").replaceAll("12","C").replaceAll("13","D").replaceAll("14","E").split(""))/\d/.test(e)?a.push(H(parseInt(e),4)):a.push(H(o[e],4));let[i,s,f]=["",!1,!1];for(r of I(a,4))i+=String.fromCharCode(P((t=r.join(""),n=void 0,t.length<16?(n=4-q(t,4).length,H(15,4).repeat(n)+t):t)));return[i,s,f]=S(i),i=b(L(3,!1,c,s,-1,0,f,m))+i,await y(i)?i:null})),e.push(async()=>{var e=_(g);if(2!==e.max||2!==e.min)return null;let r=e.output,[t,n,o]=["",!1,!1];function a(e){t+=String.fromCharCode(e)}function i(e){r=r.slice(e)}for(;0<r.length;)if(1===r.length)a(r[0]),i(1);else if(r.length<3){for(var s of r)a(s);i(r.length)}else{var f=parseInt(String(r[0])+String(r[1])+String(r[2])),c=parseInt(String(r[0])+String(r[1]));E(f)?(a(f),i(3)):E(c)?(a(c),i(2)):(a(r[0]),i(1))}[t,n,o]=S(out);e=b(L(1,!1,v,n,C,0,o,m))+t;return await y(e)?e:null}),e.push(async()=>{var r;if(256<=_(g).maxCharCode)return null;let[t,e,n]=["",!1,!1];for(r of q(g,2)){let e="";for(var o of r)e+=H(o.charCodeAt(0),8);t+=String.fromCharCode(P(e))}[t,e,n]=S(t);var a=b(L(2,!1,v,e,C,0,n,m))+t;return await y(a)?a:null}),e.push(async()=>{var r,t,e=new k.use,n=g.split("");let o,a=NaN;for([r,t]of Object.entries(e)){var i,s=t(),f=(s.length=256,Array.from(s));let e=!0;for(i of n)if(!f.includes(i)){e=!1;break}if(e){o=t(),a=k._IDs[r.slice(4)];break}}if(o){var c={};for(let[e,r]of Object.entries(o))c[r]=e;var l,u,h,p=[],d=[];for(l of n)p.push(H(parseInt(c[l]),8));for(u of I(p,2))d.push(u.join("").padStart(16,"0"));let[e,r,t]=["",!1,!1];for(h of d)e+=String.fromCharCode(P(h));if([e,r,t]=S(e),e=b(L(5,!1,v,r,C,a,t,m))+e,await y(e))return e}return null}),e.push(async()=>{var e=[...new Set(g.split("").map(e=>e.charCodeAt(0)))];if(16<=e.length)return null;let r=e.map(e=>String.fromCharCode(e)).join(""),t=[];var n,[o,a]=[!1,!1];for(n of g)t.push(e.indexOf(n.charCodeAt(0))),4===t.length&&(r+=String.fromCharCode(P(t.map(e=>H(e,4)).join(""))),t=[]);t.length&&(r+=String.fromCharCode(P(t.map(e=>H(e,4)).join("").padStart(16,"1")))),[r,o,a]=S(r);o=b(L(4,!1,v,o,C,e.length,a,m))+r;return await y(o)?o:null}),e.push(async()=>{for(var e of z){e=F.test(g,e);if(Array.isArray(e)){var[,,r,t]=e,e=b(L(7,!1,!1,!1,-1,P((e[0]-1).toString()+H(z.indexOf(r),3))))+t;if(await y(e))return e}}return null}),e.push(async()=>{if("string"!=typeof g)return null;let e;try{e=new URL(k._begin[C]+g)}catch{return null}var r=e.href,t=/%[0-9A-Fa-f]{2}/.test(r),n=e.hostname.includes("xn--"),o=!!e.search,a=!!e.hash;let i=r.slice(k._begin[C].length);n&&"undefined"!=typeof punycode&&(e.hostname=punycode.toUnicode(e.hostname),i=e.href.slice(k._begin[C].length));var s=[];for(let e=0;e<i.length;e++){if("%"===i[e]&&e+2<i.length){var f=i.slice(e+1,e+3);if(/^[0-9A-Fa-f]{2}$/.test(f)){s.push(parseInt(f,16)),e+=2;continue}}s.push(i.charCodeAt(e))}r=1&s.length;r&&s.push(0);let c="";for(let e=0;e<s.length;e+=2)c+=String.fromCharCode(s[e]<<8|(s[e+1]??0));t=(t?1:0)|(n?2:0)|(o?4:0)|(a?8:0),n=!1,[c,n]=S(c,!0),o=b(L(8,!1,v,n,C,t,r,m))+c;return await y(o)?o:null}),o.segmentation&&e.push(async()=>{var e,r=(r=>{if("string"!=typeof r||0===r.length)return[];var t=[];let n=r[0];for(let e=1;e<r.length;e++){var o=r.charCodeAt(e-1),a=r.charCodeAt(e);128<Math.abs(a-o)?(t.push(n),n=r[e]):n+=r[e]}return n&&t.push(n),t})(g);if(r.length<2)return null;let t=r.length-2<15?"":String.fromCharCode(r.length-2);for(e of r){var n={...o,segmentation:!1},n=await compress(e,n);t=t+String.fromCharCode(e.length)+n}r=b(L(9,!1,v,o.justc,C,Math.min(r.length-2,15),o.recursivecompression,m))+t;return await y(r)?r:null});let u=g.match(/^(.{1,7}?)(?:\1)+$/);u&&e.push(async()=>{var e,r,t,n=u[1],o=g.length/n.length;return!(Math.floor(o)!=o||o<1||65550<o)&&([e,r,t]=["",!1,!1],[e,r,t]=S(n),n=b(L(10,!1,v,r,C,Math.min(o-1,15),t,m))+(14<o-1?String.fromCharCode(o-15):"")+e,await y(n))?n:null});var h,p=(await Promise.all(e.map(e=>(async e=>{try{return await e()}catch{return null}})(e)))).filter(e=>"string"==typeof e&&e.length<=String(g).length);let d;if(d=p.length?p.reduce((e,r)=>r.length<e.length?r:e):([r,l]=[!1,!1],[g,r,l]=S(h=g),await y(g)?b(L(0,!1,v,r,C,0,l,m))+g:b(L(0,!1,v,!1,C,0,!1,m))+h),o.recursivecompression)try{for(var A of p){var w=await(async(e,r)=>{if(!r.recursivecompression)return e;let t=e,n=0;for(;n<15;){n++;var o=await compress(t,{...r,recursivecompression:!1});if(o.length>=t.length)break;if(await decompress(o,!0)!==t)break;t=o}return 0===n?null:b(L(31,!1,!1,!1,-1,n,!1,-1))+t})(A,o);w&&w.length<=d.length&&await y(w)&&(d=w)}}catch(e){}return d}async function decompress(e,t=!1){if("string"!=typeof e)throw new Error(J+"Invalid input.");let n=L((e.charCodeAt(0)-32+65535)%65535,!0),o=n.code;function a(e){return e.replace(/(\D)(\d+)/g,(e,r,t)=>r.repeat(t))}let i=e.slice(1);async function s(e){var r;return 0<=n.beginId?k._begin[n.beginId]+e:1==n.code3||2==n.code3?(r=await(async r=>{try{var e=x.parse(r);return e&&"function"==typeof e.then?await e:e}catch(e){if("undefined"!=typeof window)try{await x.initialize();var t=x.parse(r);return t&&"function"==typeof t.then?await t:t}catch{}return null}})(e))&&"function"==typeof r.then?JSON.stringify(await r):JSON.stringify(r):e}async function f(e){let r=e;return r=n.repeatBefore&&3!=o?a(await s(e)):await s(e),n.repeatBefore&&3==o||30==o?r=parseInt(r):(3==n.code3||4==n.code3?r="["+r+"]":5==n.code3&&(r="{"+r+"}"),2!=n.code3&&4!=n.code3&&6!=n.code3||(r=JSON.parse(r))),t&&("object"==typeof r?r=JSON.stringify(r):"number"==typeof r&&(r=r.toString())),r}n.sequences&&8!=o&&9!=o&&(i=(e=>{let r="",t=0;for(;t<e.length;)if(56319===e.charCodeAt(t))if(++t+2>=e.length)r+=D;else{var n=e.charCodeAt(t)-32,o=e.charCodeAt(t+1)-32;if((t+=2)+n>e.length){r+=D+String.fromCharCode(32+n)+String.fromCharCode(32+o)+e.slice(t);break}var a=e.substr(t,n);t+=n;for(let e=0;e<o;e++)r+=a}else r+=e.charAt(t),t++;return r})(i)),n.repeatAfter&&9!=o&&(i=a(i));let r="";switch(o){case 0:case 6:return 0<n.code2?f(String(n.code2-1)):f(i);case 1:function c(e){r+=String.fromCharCode(e)}for(var l of i.split("")){var u,h=String(l.charCodeAt(0));if(2<h.length)for(u of q(h,2))c(parseInt(u));else c(l.charCodeAt(0))}return f(r);case 2:function p(e){return String.fromCharCode(P(e))}for(var d of i.split("")){var g,v=H(d.charCodeAt(0),16);8<H(d.charCodeAt(0),0).length?([v,g]=q(v,8),r+=p(v)+p(g)):(v=H(d.charCodeAt(0),8),r+=p(v))}return f(r);case 3:for(var C of i.split("")){var m;for(m of q(H(C.charCodeAt(0),16),4)){var S=P(m);15!=S&&(r+=S.toString(10))}}return f(r);case 4:var y,A,w,_,b=[];for(y of i.slice(0,n.code2).split(""))b.push(y);for(A of i.slice(n.code2).split(""))for(w of q(H(A.charCodeAt(0),16),4))"1111"!=w&&(_=P(w),r+=b[_]);return f(r);case 5:var E=((t,n)=>{var e,r,o,a={};for([e,r]of Object.entries(k._IDs))a[r]=e;if(t=a[t]){let r=(new k.use)[U+t](),e="";for(o of n.split("")){var i,s,f=o.charCodeAt();function c(e){return String(r[String(P(e))])}8<H(f,0).length?([s,i]=q(H(f,16),8),e+=c(s)+c(i)):(s=H(f,8),e+=c(s))}return e}})(n.code2,i);if(E)return f(E);throw new Error(J+"Invalid compressed string");case 7:E=z[P(H(n.code2).slice(1))];return r=F.decompress(i,E),f(r=1==parseInt(H(n.code2).slice(0,1))?r.slice(0,-1):r);case 8:{var I,N,j=[];for(I of i){var B=I.charCodeAt(0);j.push(B>>8&255,255&B)}n.sequences&&j.pop();let e="";for(N of j)e+=String.fromCharCode(N);return 1&n.code2&&(e=e.replace(/[\x00-\x20\x7F-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16).padStart(2,"0").toUpperCase())),2&n.code2&&"undefined"!=typeof punycode&&((E=new URL(e)).hostname=punycode.toASCII(E.hostname),e=E.href),f(e)}case 9:{let r=0;var O=n.code2<15?n.code2+2:i.charCodeAt(r++)+2;let t="";for(let e=0;e<O;e++){var T=i.charCodeAt(r++),T=(await decompress(i.slice(r),!0)).slice(0,T);t+=T,r+=(await compress(T,{segmentation:!1,justc:n.repeatAfter,recursivecompression:n.sequences})).length}return f(t)}case 10:var E=15==n.code2,R=E?i.charCodeAt(0)+15:n.code2;return f((i=E?i.slice(1):i).repeat(R));case 31:{let r=i;var M=n.code2;for(let e=0;e<M;e++){if(31===L(r.charCodeAt(0)-32,!0).code)throw new Error(J+"Attempt to nested recursive compression");r=await decompress(r,!0)}return r}default:throw new Error(J+"Invalid compressed string")}}var r={compress:compress,decompress:decompress,get[Symbol.toStringTag](){return U}};e.compress=compress,e.decompress=decompress,e.default=r,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strc",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "JavaScript String Compressor - lossless string compression algorithm",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -18,32 +18,97 @@
18
18
  "homepage": "https://jssc.js.org/",
19
19
  "files": [
20
20
  "index.js",
21
- "index.d.ts",
21
+ "src/index.d.ts",
22
22
  "README.md",
23
23
  "LICENSE",
24
24
  "index.min.js",
25
- "test/index.js"
25
+ "test/index.js",
26
+ "dist/jssc.js",
27
+ "dist/jssc.mjs",
28
+ "dist/jssc.cjs"
26
29
  ],
27
30
  "dependencies": {
28
31
  "justc": "^0.1.0"
29
32
  },
30
- "unpkg": "./index.min.js",
31
33
  "keywords": [
32
- "compressor", "compress", "compression",
33
- "decompress", "decompressor", "decompression",
34
- "string", "text", "data",
35
- "javascript", "typescript", "js", "ts", "deno", "jsx", "tsx",
36
- "jssc", "strc",
34
+ "compressor",
35
+ "compress",
36
+ "compression",
37
+ "decompress",
38
+ "decompressor",
39
+ "decompression",
40
+ "string",
41
+ "text",
42
+ "data",
43
+ "javascript",
44
+ "typescript",
45
+ "js",
46
+ "ts",
47
+ "deno",
48
+ "jsx",
49
+ "tsx",
50
+ "jssc",
51
+ "strc",
37
52
  "lossless",
38
- "high", "ratio", "ratios",
39
- "multilingual", "character", "encoding", "encodings",
40
- "json", "object",
41
- "english", "spanish", "portuguese", "french", "german", "russian", "ukrainian", "belarusian", "kazakh", "hindi", "bengali", "japanese", "hiragana", "katakana", "telugu", "marathi",
42
- "unicode", "ascii",
43
- "umd", "module", "open-source", "open", "source", "node", "amd", "browsers", "browser", "client-side", "client", "side", "server-side", "server", "frontend", "backend", "fullstack", "rle",
44
- "2025", "2026"
53
+ "high",
54
+ "ratio",
55
+ "ratios",
56
+ "multilingual",
57
+ "character",
58
+ "encoding",
59
+ "encodings",
60
+ "json",
61
+ "object",
62
+ "english",
63
+ "spanish",
64
+ "portuguese",
65
+ "french",
66
+ "german",
67
+ "russian",
68
+ "ukrainian",
69
+ "belarusian",
70
+ "kazakh",
71
+ "hindi",
72
+ "bengali",
73
+ "japanese",
74
+ "hiragana",
75
+ "katakana",
76
+ "telugu",
77
+ "marathi",
78
+ "unicode",
79
+ "ascii",
80
+ "umd",
81
+ "module",
82
+ "open-source",
83
+ "open",
84
+ "source",
85
+ "node",
86
+ "amd",
87
+ "browsers",
88
+ "browser",
89
+ "client-side",
90
+ "client",
91
+ "side",
92
+ "server-side",
93
+ "server",
94
+ "frontend",
95
+ "backend",
96
+ "fullstack",
97
+ "rle",
98
+ "2025",
99
+ "2026",
100
+ "justc"
45
101
  ],
46
102
  "scripts": {
47
103
  "test": "node test"
48
- }
104
+ },
105
+ "devDependencies": {
106
+ "@rollup/plugin-node-resolve": "^16.0.3",
107
+ "rollup": "^4.57.1",
108
+ "uglify-js": "^3.19.3"
109
+ },
110
+ "module": "dist/jssc.mjs",
111
+ "browser": "dist/jssc.js",
112
+ "types": "src/index.d.ts",
113
+ "unpkg": "./index.min.js"
49
114
  }