afp.js 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626
  1. 'use strict'
  2. const WASM_BINARY_PLACEHOLDER = 'WASM_BINARY_PLACEHOLDER';
  3. // See https://github.com/Distributive-Network/PythonMonkey/issues/266
  4. if (typeof globalThis.setInterval != 'function'){
  5. globalThis.setInterval = function pm$$setInterval(fn, timeout) {
  6. const timerHnd = { cancel: false };
  7. function fnWrapper()
  8. {
  9. if (timerHnd.cancel)
  10. return;
  11. setTimeout(fnWrapper, timeout);
  12. fn();
  13. }
  14. timerHnd.id = setTimeout(fnWrapper, timeout);
  15. return timerHnd;
  16. }
  17. globalThis.clearInterval = function pm$$clearInterval(timerHnd) {
  18. timerHnd.clear = true;
  19. clearTimeout(timerHnd.id);
  20. }
  21. }
  22. globalThis.b64decode = function b64decode(data) {
  23. return Uint8Array.from(atob(data), c => c.charCodeAt(0));
  24. }
  25. globalThis.b64encode = function b64encode(data) {
  26. return btoa(String.fromCharCode(...data));
  27. }
  28. // https://fn.music.163.com/g/chrome-extension-home-page-beta/
  29. let AudioFingerprintRuntime = (() => {
  30. var n, o = void 0 !== o ? o : {},i = {};
  31. for (n in o)
  32. o.hasOwnProperty(n) && (i[n] = o[n]);
  33. var read_, readSync, readBinary, c, f, l = [],
  34. p = "./this.program",
  35. readSync = function(t, e, r) {
  36. switch (t) {
  37. case WASM_BINARY_PLACEHOLDER:
  38. if (typeof WASM_BINARY == 'undefined') {
  39. const { WASM_BINARY } = require('./afp.wasm.js');
  40. e(globalThis.b64decode(WASM_BINARY));
  41. } else {
  42. e(globalThis.b64decode(WASM_BINARY));
  43. }
  44. default:
  45. throw "Reading " + t + " is not supported";
  46. break;
  47. }
  48. }
  49. var v = o.print || console.log.bind(console),
  50. g = o.printErr || console.warn.bind(console);
  51. for (n in i)
  52. i.hasOwnProperty(n) && (o[n] = i[n]);
  53. i = null,
  54. o.arguments && (l = o.arguments),
  55. o.thisProgram && (p = o.thisProgram),
  56. o.quit && o.quit;
  57. var w;
  58. o.wasmBinary && (w = o.wasmBinary);
  59. var b, _ = o.noExitRuntime || !0;
  60. "object" != typeof WebAssembly && abort("no native wasm support detected");
  61. var C = !1;
  62. function T(t, e) {
  63. t || abort("Assertion failed: " + e)
  64. }
  65. var UTF8Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0;
  66. function UTF8ArrayToString(heap, idx, maxBytesToRead) {
  67. var endIdx = idx + maxBytesToRead;
  68. var endPtr = idx;
  69. while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  70. if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
  71. return UTF8Decoder.decode(heap.subarray(idx, endPtr))
  72. } else {
  73. var str = "";
  74. while (idx < endPtr) {
  75. var u0 = heap[idx++];
  76. if (!(u0 & 128)) {
  77. str += String.fromCharCode(u0);
  78. continue
  79. }
  80. var u1 = heap[idx++] & 63;
  81. if ((u0 & 224) == 192) {
  82. str += String.fromCharCode((u0 & 31) << 6 | u1);
  83. continue
  84. }
  85. var u2 = heap[idx++] & 63;
  86. if ((u0 & 240) == 224) {
  87. u0 = (u0 & 15) << 12 | u1 << 6 | u2
  88. } else {
  89. u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heap[idx++] & 63
  90. }
  91. if (u0 < 65536) {
  92. str += String.fromCharCode(u0)
  93. } else {
  94. var ch = u0 - 65536;
  95. str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023)
  96. }
  97. }
  98. }
  99. return str
  100. }
  101. function UTF8ToString(ptr, maxBytesToRead) {
  102. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""
  103. }
  104. function UTF8ToString(t, e) {
  105. return t ? UTF8ArrayToString(O, t, e) : ""
  106. }
  107. function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
  108. if (!(maxBytesToWrite > 0)) return 0;
  109. var startIdx = outIdx;
  110. var endIdx = outIdx + maxBytesToWrite - 1;
  111. for (var i = 0; i < str.length; ++i) {
  112. var u = str.charCodeAt(i);
  113. if (u >= 55296 && u <= 57343) {
  114. var u1 = str.charCodeAt(++i);
  115. u = 65536 + ((u & 1023) << 10) | u1 & 1023
  116. }
  117. if (u <= 127) {
  118. if (outIdx >= endIdx) break;
  119. heap[outIdx++] = u
  120. } else if (u <= 2047) {
  121. if (outIdx + 1 >= endIdx) break;
  122. heap[outIdx++] = 192 | u >> 6;
  123. heap[outIdx++] = 128 | u & 63
  124. } else if (u <= 65535) {
  125. if (outIdx + 2 >= endIdx) break;
  126. heap[outIdx++] = 224 | u >> 12;
  127. heap[outIdx++] = 128 | u >> 6 & 63;
  128. heap[outIdx++] = 128 | u & 63
  129. } else {
  130. if (outIdx + 3 >= endIdx) break;
  131. heap[outIdx++] = 240 | u >> 18;
  132. heap[outIdx++] = 128 | u >> 12 & 63;
  133. heap[outIdx++] = 128 | u >> 6 & 63;
  134. heap[outIdx++] = 128 | u & 63
  135. }
  136. }
  137. heap[outIdx] = 0;
  138. return outIdx - startIdx
  139. }
  140. function UTF8CharCount(t) {
  141. for (var e = 0, r = 0; r < t.length; ++r) {
  142. var n = t.charCodeAt(r);
  143. n >= 55296 && n <= 57343 && (n = 65536 + ((1023 & n) << 10) | 1023 & t.charCodeAt(++r)),
  144. n <= 127 ? ++e : e += n <= 2047 ? 2 : n <= 65535 ? 3 : 4
  145. }
  146. return e
  147. }
  148. var E, S, O, k, W, j, R, M, I, UTF16Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf-16le") : void 0;
  149. function UTF16ArrayToString(t, e) {
  150. for (var r = t, n = r >> 1, o = n + e / 2; !(n >= o) && W[n];)
  151. ++n;
  152. if ((r = n << 1) - t > 32 && UTF16Decoder)
  153. return UTF16Decoder.decode(O.subarray(t, r));
  154. for (var i = "", a = 0; !(a >= e / 2); ++a) {
  155. var u = k[t + 2 * a >> 1];
  156. if (0 == u)
  157. break;
  158. i += String.fromCharCode(u)
  159. }
  160. return i
  161. }
  162. function H(t, e, r) {
  163. if (void 0 === r && (r = 2147483647),
  164. r < 2)
  165. return 0;
  166. for (var n = e, o = (r -= 2) < 2 * t.length ? r / 2 : t.length, i = 0; i < o; ++i) {
  167. var a = t.charCodeAt(i);
  168. k[e >> 1] = a,
  169. e += 2
  170. }
  171. return k[e >> 1] = 0,
  172. e - n
  173. }
  174. function Y(t) {
  175. return 2 * t.length
  176. }
  177. function V(t, e) {
  178. for (var r = 0, n = ""; !(r >= e / 4);) {
  179. var o = j[t + 4 * r >> 2];
  180. if (0 == o)
  181. break;
  182. if (++r,
  183. o >= 65536) {
  184. var i = o - 65536;
  185. n += String.fromCharCode(55296 | i >> 10, 56320 | 1023 & i)
  186. } else
  187. n += String.fromCharCode(o)
  188. }
  189. return n
  190. }
  191. function z(t, e, r) {
  192. if (void 0 === r && (r = 2147483647),
  193. r < 4)
  194. return 0;
  195. for (var n = e, o = n + r - 4, i = 0; i < t.length; ++i) {
  196. var a = t.charCodeAt(i);
  197. if (a >= 55296 && a <= 57343)
  198. a = 65536 + ((1023 & a) << 10) | 1023 & t.charCodeAt(++i);
  199. if (j[e >> 2] = a,
  200. (e += 4) + 4 > o)
  201. break
  202. }
  203. return j[e >> 2] = 0,
  204. e - n
  205. }
  206. function B(t) {
  207. for (var e = 0, r = 0; r < t.length; ++r) {
  208. var n = t.charCodeAt(r);
  209. n >= 55296 && n <= 57343 && ++r,
  210. e += 4
  211. }
  212. return e
  213. }
  214. o.INITIAL_MEMORY;
  215. var L, G = [],
  216. N = [],
  217. q = [];
  218. var J = 0,
  219. X = null,
  220. Z = null;
  221. function abort(what) {
  222. throw o.onAbort && o.onAbort(what),
  223. g(what = "Aborted(" + what + ")"),
  224. C = !0,
  225. 1,
  226. what += ". Build with -s ASSERTIONS=1 for more info.",
  227. new WebAssembly.RuntimeError(what)
  228. }
  229. o.preloadedImages = {},
  230. o.preloadedAudios = {};
  231. var Q;
  232. function isDataURI(t) {
  233. return t.startsWith("data:application/octet-stream;base64,")
  234. }
  235. function isFileURI(t) {
  236. return t.startsWith("file://")
  237. }
  238. function getBinary(file) {
  239. try {
  240. if (file == Q && w)
  241. return new Uint8Array(w);
  242. if (readBinary)
  243. return readBinary(file);
  244. throw "both async and sync fetching of the wasm failed"
  245. } catch (t) {
  246. abort(t)
  247. }
  248. }
  249. function callRuntimeCallbacks(cb) {
  250. for (; cb.length > 0;) {
  251. var func = cb.shift();
  252. if ("function" != typeof func) {
  253. var r = func.func;
  254. "number" == typeof r ? void 0 === func.arg ? it(r)() : it(r)(func.arg) : r(void 0 === func.arg ? null : func.arg)
  255. } else
  256. func(o)
  257. }
  258. }
  259. var wasmBinaryFile = WASM_BINARY_PLACEHOLDER;
  260. isDataURI(wasmBinaryFile) || (Q = function(t) {
  261. return wasmBinaryFile
  262. }(Q));
  263. var ot = [];
  264. function it(t) {
  265. var e = ot[t];
  266. return e || (t >= ot.length && (ot.length = t + 1),
  267. ot[t] = e = L.get(t)),
  268. e
  269. }
  270. function ExceptionInfo(excPtr) {
  271. this.excPtr = excPtr,
  272. this.ptr = excPtr - 16,
  273. this.set_type = function(t) {
  274. j[this.ptr + 4 >> 2] = t
  275. },
  276. this.get_type = function() {
  277. return j[this.ptr + 4 >> 2]
  278. },
  279. this.set_destructor = function(t) {
  280. j[this.ptr + 8 >> 2] = t
  281. },
  282. this.get_destructor = function() {
  283. return j[this.ptr + 8 >> 2]
  284. },
  285. this.set_refcount = function(t) {
  286. j[this.ptr >> 2] = t
  287. },
  288. this.set_caught = function(t) {
  289. t = t ? 1 : 0,
  290. S[this.ptr + 12 >> 0] = t
  291. },
  292. this.get_caught = function() {
  293. return 0 != S[this.ptr + 12 >> 0]
  294. },
  295. this.set_rethrown = function(t) {
  296. t = t ? 1 : 0,
  297. S[this.ptr + 13 >> 0] = t
  298. },
  299. this.get_rethrown = function() {
  300. return 0 != S[this.ptr + 13 >> 0]
  301. },
  302. this.init = function(t, e) {
  303. this.set_type(t),
  304. this.set_destructor(e),
  305. this.set_refcount(0),
  306. this.set_caught(!1),
  307. this.set_rethrown(!1)
  308. },
  309. this.add_ref = function() {
  310. var t = j[this.ptr >> 2];
  311. j[this.ptr >> 2] = t + 1
  312. },
  313. this.release_ref = function() {
  314. var t = j[this.ptr >> 2];
  315. return j[this.ptr >> 2] = t - 1,
  316. 1 === t
  317. }
  318. }
  319. function ut(t) {
  320. switch (t) {
  321. case 1:
  322. return 0;
  323. case 2:
  324. return 1;
  325. case 4:
  326. return 2;
  327. case 8:
  328. return 3;
  329. default:
  330. throw new TypeError("Unknown type size: " + t)
  331. }
  332. }
  333. var st = void 0;
  334. function ct(t) {
  335. for (var e = "", r = t; O[r];)
  336. e += st[O[r++]];
  337. return e
  338. }
  339. var ft = {},
  340. lt = {},
  341. pt = {};
  342. function dt(t) {
  343. if (void 0 === t)
  344. return "_unknown";
  345. var e = (t = t.replace(/[^a-zA-Z0-9_]/g, "$")).charCodeAt(0);
  346. return e >= 48 && e <= 57 ? "_" + t : t
  347. }
  348. function ht(t, e) {
  349. return t = dt(t),
  350. new Function("body", "return function " + t + '() {\n "use strict"; return body.apply(this, arguments);\n};\n')(e)
  351. }
  352. function yt(t, e) {
  353. var r = ht(e, (function(t) {
  354. this.name = e,
  355. this.message = t;
  356. var r = new Error(t).stack;
  357. void 0 !== r && (this.stack = this.toString() + "\n" + r.replace(/^Error(:[^\n]*)?\n/, ""))
  358. }));
  359. return r.prototype = Object.create(t.prototype),
  360. r.prototype.constructor = r,
  361. r.prototype.toString = function() {
  362. return void 0 === this.message ? this.name : this.name + ": " + this.message
  363. },
  364. r
  365. }
  366. var mt = void 0;
  367. function vt(t) {
  368. throw new mt(t)
  369. }
  370. var gt = void 0;
  371. function wt(t) {
  372. throw new gt(t)
  373. }
  374. function bt(t, e, r) {
  375. function n(e) {
  376. var n = r(e);
  377. n.length !== t.length && wt("Mismatched type converter count");
  378. for (var o = 0; o < t.length; ++o)
  379. _t(t[o], n[o])
  380. }
  381. t.forEach((function(t) {
  382. pt[t] = e
  383. }));
  384. var o = new Array(e.length),
  385. i = [],
  386. a = 0;
  387. e.forEach((function(t, e) {
  388. lt.hasOwnProperty(t) ? o[e] = lt[t] : (i.push(t),
  389. ft.hasOwnProperty(t) || (ft[t] = []),
  390. ft[t].push((function() {
  391. o[e] = lt[t],
  392. ++a === i.length && n(o)
  393. })))
  394. })),
  395. 0 === i.length && n(o)
  396. }
  397. function _t(t, e, r) {
  398. if (r = r || {},
  399. !("argPackAdvance" in e))
  400. throw new TypeError("registerType registeredInstance requires argPackAdvance");
  401. var n = e.name;
  402. if (t || vt('type "' + n + '" must have a positive integer typeid pointer'),
  403. lt.hasOwnProperty(t)) {
  404. if (r.ignoreDuplicateRegistrations)
  405. return;
  406. vt("Cannot register type '" + n + "' twice")
  407. }
  408. if (lt[t] = e,
  409. delete pt[t],
  410. ft.hasOwnProperty(t)) {
  411. var o = ft[t];
  412. delete ft[t],
  413. o.forEach((function(t) {
  414. t()
  415. }))
  416. }
  417. }
  418. function Ct(t) {
  419. if (!(this instanceof Rt))
  420. return !1;
  421. if (!(t instanceof Rt))
  422. return !1;
  423. for (var e = this.$$.ptrType.registeredClass, r = this.$$.ptr, n = t.$$.ptrType.registeredClass, o = t.$$.ptr; e.baseClass;)
  424. r = e.upcast(r),
  425. e = e.baseClass;
  426. for (; n.baseClass;)
  427. o = n.upcast(o),
  428. n = n.baseClass;
  429. return e === n && r === o
  430. }
  431. function Tt(t) {
  432. vt(t.$$.ptrType.registeredClass.name + " instance already deleted")
  433. }
  434. var $t = !1;
  435. function Pt(t) {}
  436. function At(t) {
  437. t.count.value -= 1,
  438. 0 === t.count.value && function(t) {
  439. t.smartPtr ? t.smartPtrType.rawDestructor(t.smartPtr) : t.ptrType.registeredClass.rawDestructor(t.ptr)
  440. }(t)
  441. }
  442. function Dt(t) {
  443. return "undefined" == typeof FinalizationRegistry ? (Dt = function(t) {
  444. return t
  445. },
  446. t) : ($t = new FinalizationRegistry((function(t) {
  447. At(t.$$)
  448. })),
  449. Dt = function(t) {
  450. var e = {
  451. $$: t.$$
  452. };
  453. return $t.register(t, e, t),
  454. t
  455. },
  456. Pt = function(t) {
  457. $t.unregister(t)
  458. },
  459. Dt(t))
  460. }
  461. function Ft() {
  462. if (this.$$.ptr || Tt(this),
  463. this.$$.preservePointerOnDelete)
  464. return this.$$.count.value += 1,
  465. this;
  466. var t, e = Dt(Object.create(Object.getPrototypeOf(this), {
  467. $$: {
  468. value: (t = this.$$, {
  469. count: t.count,
  470. deleteScheduled: t.deleteScheduled,
  471. preservePointerOnDelete: t.preservePointerOnDelete,
  472. ptr: t.ptr,
  473. ptrType: t.ptrType,
  474. smartPtr: t.smartPtr,
  475. smartPtrType: t.smartPtrType
  476. })
  477. }
  478. }));
  479. return e.$$.count.value += 1,
  480. e.$$.deleteScheduled = !1,
  481. e
  482. }
  483. function Et() {
  484. this.$$.ptr || Tt(this),
  485. this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && vt("Object already scheduled for deletion"),
  486. Pt(this),
  487. At(this.$$),
  488. this.$$.preservePointerOnDelete || (this.$$.smartPtr = void 0,
  489. this.$$.ptr = void 0)
  490. }
  491. function St() {
  492. return !this.$$.ptr
  493. }
  494. var Ot = void 0,
  495. kt = [];
  496. function Wt() {
  497. for (; kt.length;) {
  498. var t = kt.pop();
  499. t.$$.deleteScheduled = !1,
  500. t.delete()
  501. }
  502. }
  503. function jt() {
  504. return this.$$.ptr || Tt(this),
  505. this.$$.deleteScheduled && !this.$$.preservePointerOnDelete && vt("Object already scheduled for deletion"),
  506. kt.push(this),
  507. 1 === kt.length && Ot && Ot(Wt),
  508. this.$$.deleteScheduled = !0,
  509. this
  510. }
  511. function Rt() {}
  512. var Mt = {};
  513. function It(t, e, r) {
  514. if (void 0 === t[e].overloadTable) {
  515. var n = t[e];
  516. t[e] = function() {
  517. return t[e].overloadTable.hasOwnProperty(arguments.length) || vt("Function '" + r + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + t[e].overloadTable + ")!"),
  518. t[e].overloadTable[arguments.length].apply(this, arguments)
  519. },
  520. t[e].overloadTable = [],
  521. t[e].overloadTable[n.argCount] = n
  522. }
  523. }
  524. function xt(t, e, r) {
  525. o.hasOwnProperty(t) ? ((void 0 === r || void 0 !== o[t].overloadTable && void 0 !== o[t].overloadTable[r]) && vt("Cannot register public name '" + t + "' twice"),
  526. It(o, t, t),
  527. o.hasOwnProperty(r) && vt("Cannot register multiple overloads of a function with the same number of arguments (" + r + ")!"),
  528. o[t].overloadTable[r] = e) : (o[t] = e,
  529. void 0 !== r && (o[t].numArguments = r))
  530. }
  531. function Ut(t, e, r, n, o, i, a, u) {
  532. this.name = t,
  533. this.constructor = e,
  534. this.instancePrototype = r,
  535. this.rawDestructor = n,
  536. this.baseClass = o,
  537. this.getActualType = i,
  538. this.upcast = a,
  539. this.downcast = u,
  540. this.pureVirtualFunctions = []
  541. }
  542. function Ht(t, e, r) {
  543. for (; e !== r;)
  544. e.upcast || vt("Expected null or instance of " + r.name + ", got an instance of " + e.name),
  545. t = e.upcast(t),
  546. e = e.baseClass;
  547. return t
  548. }
  549. function Yt(t, e) {
  550. if (null === e)
  551. return this.isReference && vt("null is not a valid " + this.name),
  552. 0;
  553. e.$$ || vt('Cannot pass "' + ge(e) + '" as a ' + this.name),
  554. e.$$.ptr || vt("Cannot pass deleted object as a pointer of type " + this.name);
  555. var r = e.$$.ptrType.registeredClass;
  556. return Ht(e.$$.ptr, r, this.registeredClass)
  557. }
  558. function Vt(t, e) {
  559. var r;
  560. if (null === e)
  561. return this.isReference && vt("null is not a valid " + this.name),
  562. this.isSmartPointer ? (r = this.rawConstructor(),
  563. null !== t && t.push(this.rawDestructor, r),
  564. r) : 0;
  565. e.$$ || vt('Cannot pass "' + ge(e) + '" as a ' + this.name),
  566. e.$$.ptr || vt("Cannot pass deleted object as a pointer of type " + this.name),
  567. !this.isConst && e.$$.ptrType.isConst && vt("Cannot convert argument of type " + (e.$$.smartPtrType ? e.$$.smartPtrType.name : e.$$.ptrType.name) + " to parameter type " + this.name);
  568. var n = e.$$.ptrType.registeredClass;
  569. if (r = Ht(e.$$.ptr, n, this.registeredClass),
  570. this.isSmartPointer)
  571. switch (void 0 === e.$$.smartPtr && vt("Passing raw pointer to smart pointer is illegal"),
  572. this.sharingPolicy) {
  573. case 0:
  574. e.$$.smartPtrType === this ? r = e.$$.smartPtr : vt("Cannot convert argument of type " + (e.$$.smartPtrType ? e.$$.smartPtrType.name : e.$$.ptrType.name) + " to parameter type " + this.name);
  575. break;
  576. case 1:
  577. r = e.$$.smartPtr;
  578. break;
  579. case 2:
  580. if (e.$$.smartPtrType === this)
  581. r = e.$$.smartPtr;
  582. else {
  583. var o = e.clone();
  584. r = this.rawShare(r, ve.toHandle((function() {
  585. o.delete()
  586. }))),
  587. null !== t && t.push(this.rawDestructor, r)
  588. }
  589. break;
  590. default:
  591. vt("Unsupporting sharing policy")
  592. }
  593. return r
  594. }
  595. function zt(t, e) {
  596. if (null === e)
  597. return this.isReference && vt("null is not a valid " + this.name),
  598. 0;
  599. e.$$ || vt('Cannot pass "' + ge(e) + '" as a ' + this.name),
  600. e.$$.ptr || vt("Cannot pass deleted object as a pointer of type " + this.name),
  601. e.$$.ptrType.isConst && vt("Cannot convert argument of type " + e.$$.ptrType.name + " to parameter type " + this.name);
  602. var r = e.$$.ptrType.registeredClass;
  603. return Ht(e.$$.ptr, r, this.registeredClass)
  604. }
  605. function Bt(t) {
  606. return this.fromWireType(R[t >> 2])
  607. }
  608. function Lt(t) {
  609. return this.rawGetPointee && (t = this.rawGetPointee(t)),
  610. t
  611. }
  612. function Gt(t) {
  613. this.rawDestructor && this.rawDestructor(t)
  614. }
  615. function Nt(t) {
  616. null !== t && t.delete()
  617. }
  618. function qt(t, e, r) {
  619. if (e === r)
  620. return t;
  621. if (void 0 === r.baseClass)
  622. return null;
  623. var n = qt(t, e, r.baseClass);
  624. return null === n ? null : r.downcast(n)
  625. }
  626. function Jt() {
  627. return Object.keys(Kt).length
  628. }
  629. function Xt() {
  630. var t = [];
  631. for (var e in Kt)
  632. Kt.hasOwnProperty(e) && t.push(Kt[e]);
  633. return t
  634. }
  635. function Zt(t) {
  636. Ot = t,
  637. kt.length && Ot && Ot(Wt)
  638. }
  639. var Kt = {};
  640. function Qt(t, e) {
  641. return e = function(t, e) {
  642. for (void 0 === e && vt("ptr should not be undefined"); t.baseClass;)
  643. e = t.upcast(e),
  644. t = t.baseClass;
  645. return e
  646. }(t, e),
  647. Kt[e]
  648. }
  649. function te(t, e) {
  650. return e.ptrType && e.ptr || wt("makeClassHandle requires ptr and ptrType"),
  651. !!e.smartPtrType !== !!e.smartPtr && wt("Both smartPtrType and smartPtr must be specified"),
  652. e.count = {
  653. value: 1
  654. },
  655. Dt(Object.create(t, {
  656. $$: {
  657. value: e
  658. }
  659. }))
  660. }
  661. function ee(t) {
  662. var e = this.getPointee(t);
  663. if (!e)
  664. return this.destructor(t),
  665. null;
  666. var r = Qt(this.registeredClass, e);
  667. if (void 0 !== r) {
  668. if (0 === r.$$.count.value)
  669. return r.$$.ptr = e,
  670. r.$$.smartPtr = t,
  671. r.clone();
  672. var n = r.clone();
  673. return this.destructor(t),
  674. n
  675. }
  676. function o() {
  677. return this.isSmartPointer ? te(this.registeredClass.instancePrototype, {
  678. ptrType: this.pointeeType,
  679. ptr: e,
  680. smartPtrType: this,
  681. smartPtr: t
  682. }) : te(this.registeredClass.instancePrototype, {
  683. ptrType: this,
  684. ptr: t
  685. })
  686. }
  687. var i, a = this.registeredClass.getActualType(e),
  688. u = Mt[a];
  689. if (!u)
  690. return o.call(this);
  691. i = this.isConst ? u.constPointerType : u.pointerType;
  692. var s = qt(e, this.registeredClass, i.registeredClass);
  693. return null === s ? o.call(this) : this.isSmartPointer ? te(i.registeredClass.instancePrototype, {
  694. ptrType: i,
  695. ptr: s,
  696. smartPtrType: this,
  697. smartPtr: t
  698. }) : te(i.registeredClass.instancePrototype, {
  699. ptrType: i,
  700. ptr: s
  701. })
  702. }
  703. function re(t, e, r, n, o, i, a, u, s, c, f) {
  704. this.name = t,
  705. this.registeredClass = e,
  706. this.isReference = r,
  707. this.isConst = n,
  708. this.isSmartPointer = o,
  709. this.pointeeType = i,
  710. this.sharingPolicy = a,
  711. this.rawGetPointee = u,
  712. this.rawConstructor = s,
  713. this.rawShare = c,
  714. this.rawDestructor = f,
  715. o || void 0 !== e.baseClass ? this.toWireType = Vt : n ? (this.toWireType = Yt,
  716. this.destructorFunction = null) : (this.toWireType = zt,
  717. this.destructorFunction = null)
  718. }
  719. function ne(t, e, r) {
  720. o.hasOwnProperty(t) || wt("Replacing nonexistant public symbol"),
  721. void 0 !== o[t].overloadTable && void 0 !== r ? o[t].overloadTable[r] = e : (o[t] = e,
  722. o[t].argCount = r)
  723. }
  724. function oe(t, e, r) {
  725. return t.includes("j") ? function(t, e, r) {
  726. var n = o["dynCall_" + t];
  727. return r && r.length ? n.apply(null, [e].concat(r)) : n.call(null, e)
  728. }(t, e, r) : it(e).apply(null, r)
  729. }
  730. function ie(t, e) {
  731. var r, n, o, i = (t = ct(t)).includes("j") ? (r = t,
  732. n = e,
  733. o = [],
  734. function() {
  735. o.length = arguments.length;
  736. for (var t = 0; t < arguments.length; t++)
  737. o[t] = arguments[t];
  738. return oe(r, n, o)
  739. }
  740. ) : it(e);
  741. return "function" != typeof i && vt("unknown function pointer with signature " + t + ": " + e),
  742. i
  743. }
  744. var ae = void 0;
  745. function ue(t) {
  746. var e = je(t),
  747. r = ct(e);
  748. return We(e),
  749. r
  750. }
  751. function se(t, e) {
  752. var r = [],
  753. n = {};
  754. throw e.forEach((function t(e) {
  755. n[e] || lt[e] || (pt[e] ? pt[e].forEach(t) : (r.push(e),
  756. n[e] = !0))
  757. })),
  758. new ae(t + ": " + r.map(ue).join([", "]))
  759. }
  760. function ce(t, e) {
  761. for (var r = [], n = 0; n < t; n++)
  762. r.push(j[(e >> 2) + n]);
  763. return r
  764. }
  765. function fe(t) {
  766. for (; t.length;) {
  767. var e = t.pop();
  768. t.pop()(e)
  769. }
  770. }
  771. function le(t, e, r, n, o) {
  772. var i = e.length;
  773. i < 2 && vt("argTypes array size mismatch! Must at least get return value and 'this' types!");
  774. for (var a = null !== e[1] && null !== r, u = !1, s = 1; s < e.length; ++s)
  775. if (null !== e[s] && void 0 === e[s].destructorFunction) {
  776. u = !0;
  777. break
  778. }
  779. var c = "void" !== e[0].name,
  780. f = "",
  781. l = "";
  782. for (s = 0; s < i - 2; ++s)
  783. f += (0 !== s ? ", " : "") + "arg" + s,
  784. l += (0 !== s ? ", " : "") + "arg" + s + "Wired";
  785. var p = "return function " + dt(t) + "(" + f + ") {\nif (arguments.length !== " + (i - 2) + ") {\nthrowBindingError('function " + t + " called with ' + arguments.length + ' arguments, expected " + (i - 2) + " args!');\n}\n";
  786. u && (p += "var destructors = [];\n");
  787. var d = u ? "destructors" : "null",
  788. h = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"],
  789. y = [vt, n, o, fe, e[0], e[1]];
  790. a && (p += "var thisWired = classParam.toWireType(" + d + ", this);\n");
  791. for (s = 0; s < i - 2; ++s)
  792. p += "var arg" + s + "Wired = argType" + s + ".toWireType(" + d + ", arg" + s + "); // " + e[s + 2].name + "\n",
  793. h.push("argType" + s),
  794. y.push(e[s + 2]);
  795. if (a && (l = "thisWired" + (l.length > 0 ? ", " : "") + l),
  796. p += (c ? "var rv = " : "") + "invoker(fn" + (l.length > 0 ? ", " : "") + l + ");\n",
  797. u)
  798. p += "runDestructors(destructors);\n";
  799. else
  800. for (s = a ? 1 : 2; s < e.length; ++s) {
  801. var m = 1 === s ? "thisWired" : "arg" + (s - 2) + "Wired";
  802. null !== e[s].destructorFunction && (p += m + "_dtor(" + m + "); // " + e[s].name + "\n",
  803. h.push(m + "_dtor"),
  804. y.push(e[s].destructorFunction))
  805. }
  806. return c && (p += "var ret = retType.fromWireType(rv);\nreturn ret;\n"),
  807. p += "}\n",
  808. h.push(p),
  809. function(t, e) {
  810. if (!(t instanceof Function))
  811. throw new TypeError("new_ called with constructor type " + typeof t + " which is not a function");
  812. var r = ht(t.name || "unknownFunctionName", (function() {}));
  813. r.prototype = t.prototype;
  814. var n = new r,
  815. o = t.apply(n, e);
  816. return o instanceof Object ? o : n
  817. }(Function, h).apply(null, y)
  818. }
  819. var pe = [],
  820. de = [{}, {
  821. value: void 0
  822. }, {
  823. value: null
  824. }, {
  825. value: !0
  826. }, {
  827. value: !1
  828. }];
  829. function he(t) {
  830. t > 4 && 0 == --de[t].refcount && (de[t] = void 0,
  831. pe.push(t))
  832. }
  833. function ye() {
  834. for (var t = 0, e = 5; e < de.length; ++e)
  835. void 0 !== de[e] && ++t;
  836. return t
  837. }
  838. function me() {
  839. for (var t = 5; t < de.length; ++t)
  840. if (void 0 !== de[t])
  841. return de[t];
  842. return null
  843. }
  844. var ve = {
  845. toValue: function(t) {
  846. return t || vt("Cannot use deleted val. handle = " + t),
  847. de[t].value
  848. },
  849. toHandle: function(t) {
  850. switch (t) {
  851. case void 0:
  852. return 1;
  853. case null:
  854. return 2;
  855. case !0:
  856. return 3;
  857. case !1:
  858. return 4;
  859. default:
  860. var e = pe.length ? pe.pop() : de.length;
  861. return de[e] = {
  862. refcount: 1,
  863. value: t
  864. },
  865. e
  866. }
  867. }
  868. };
  869. function ge(t) {
  870. if (null === t)
  871. return "null";
  872. var e = typeof t;
  873. return "object" === e || "array" === e || "function" === e ? t.toString() : "" + t
  874. }
  875. function we(t, e) {
  876. switch (e) {
  877. case 2:
  878. return function(t) {
  879. return this.fromWireType(M[t >> 2])
  880. };
  881. case 3:
  882. return function(t) {
  883. return this.fromWireType(I[t >> 3])
  884. };
  885. default:
  886. throw new TypeError("Unknown float type: " + t)
  887. }
  888. }
  889. function be(t, e, r) {
  890. switch (e) {
  891. case 0:
  892. return r ? function(t) {
  893. return S[t]
  894. } :
  895. function(t) {
  896. return O[t]
  897. };
  898. case 1:
  899. return r ? function(t) {
  900. return k[t >> 1]
  901. } :
  902. function(t) {
  903. return W[t >> 1]
  904. };
  905. case 2:
  906. return r ? function(t) {
  907. return j[t >> 2]
  908. } :
  909. function(t) {
  910. return R[t >> 2]
  911. };
  912. default:
  913. throw new TypeError("Unknown integer type: " + t)
  914. }
  915. }
  916. var Te = {
  917. mappings: {},
  918. buffers: [null, [],
  919. []
  920. ],
  921. printChar: function(t, e) {
  922. var r = Te.buffers[t];
  923. 0 === e || 10 === e ? ((1 === t ? v : g)(UTF8ArrayToString(r, 0)),
  924. r.length = 0) : r.push(e)
  925. },
  926. varargs: void 0,
  927. get: function() {
  928. return Te.varargs += 4,
  929. j[Te.varargs - 4 >> 2]
  930. },
  931. getStr: function(t) {
  932. return UTF8ToString(t)
  933. },
  934. get64: function(t, e) {
  935. return t
  936. }
  937. };
  938. function $e(t) {
  939. return t % 4 == 0 && (t % 100 != 0 || t % 400 == 0)
  940. }
  941. function Pe(t, e) {
  942. for (var r = 0, n = 0; n <= e; r += t[n++])
  943. ;
  944. return r
  945. }
  946. var Ae = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  947. De = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  948. function Fe(t, e) {
  949. for (var r = new Date(t.getTime()); e > 0;) {
  950. var n = $e(r.getFullYear()),
  951. o = r.getMonth(),
  952. i = (n ? Ae : De)[o];
  953. if (!(e > i - r.getDate()))
  954. return r.setDate(r.getDate() + e),
  955. r;
  956. e -= i - r.getDate() + 1,
  957. r.setDate(1),
  958. o < 11 ? r.setMonth(o + 1) : (r.setMonth(0),
  959. r.setFullYear(r.getFullYear() + 1))
  960. }
  961. return r
  962. }
  963. for (var t = new Array(256), e = 0; e < 256; ++e)
  964. t[e] = String.fromCharCode(e);
  965. st = t
  966. mt = o.BindingError = yt(Error, "BindingError"),
  967. gt = o.InternalError = yt(Error, "InternalError"),
  968. Rt.prototype.isAliasOf = Ct,
  969. Rt.prototype.clone = Ft,
  970. Rt.prototype.delete = Et,
  971. Rt.prototype.isDeleted = St,
  972. Rt.prototype.deleteLater = jt,
  973. re.prototype.getPointee = Lt,
  974. re.prototype.destructor = Gt,
  975. re.prototype.argPackAdvance = 8,
  976. re.prototype.readValueFromPointer = Bt,
  977. re.prototype.deleteObject = Nt,
  978. re.prototype.fromWireType = ee,
  979. o.getInheritedInstanceCount = Jt,
  980. o.getLiveInheritedInstances = Xt,
  981. o.flushPendingDeletes = Wt,
  982. o.setDelayFunction = Zt,
  983. ae = o.UnboundTypeError = yt(Error, "UnboundTypeError"),
  984. o.count_emval_handles = ye,
  985. o.get_first_emval = me;
  986. var Se, import_table_impl = {
  987. d: function(t, e, r, n) {
  988. abort("Assertion failed: " + UTF8ToString(t) + ", at: " + [e ? UTF8ToString(e) : "unknown filename", r, n ? UTF8ToString(n) : "unknown function"])
  989. },
  990. g: function(t) {
  991. return ke(t + 16) + 16
  992. },
  993. f: function(t, e, r) {
  994. throw new ExceptionInfo(t).init(e, r),t,t
  995. },
  996. p: function(t, e, r, n, o) {},
  997. y: function(t, e, r, n, o) {
  998. var i = ut(r);
  999. _t(t, {
  1000. name: e = ct(e),
  1001. fromWireType: function(t) {
  1002. return !!t
  1003. },
  1004. toWireType: function(t, e) {
  1005. return e ? n : o
  1006. },
  1007. argPackAdvance: 8,
  1008. readValueFromPointer: function(t) {
  1009. var n;
  1010. if (1 === r)
  1011. n = S;
  1012. else if (2 === r)
  1013. n = k;
  1014. else {
  1015. if (4 !== r)
  1016. throw new TypeError("Unknown boolean type size: " + e);
  1017. n = j
  1018. }
  1019. return this.fromWireType(n[t >> i])
  1020. },
  1021. destructorFunction: null
  1022. })
  1023. },
  1024. A: function(t, e, r, n, o, i, a, u, s, c, f, l, p) {
  1025. f = ct(f),
  1026. i = ie(o, i),
  1027. u && (u = ie(a, u)),
  1028. c && (c = ie(s, c)),
  1029. p = ie(l, p);
  1030. var d = dt(f);
  1031. xt(d, (function() {
  1032. se("Cannot construct " + f + " due to unbound types", [n])
  1033. })),
  1034. bt([t, e, r], n ? [n] : [], (function(e) {
  1035. var r, o;
  1036. e = e[0],
  1037. o = n ? (r = e.registeredClass).instancePrototype : Rt.prototype;
  1038. var a = ht(d, (function() {
  1039. if (Object.getPrototypeOf(this) !== s)
  1040. throw new mt("Use 'new' to construct " + f);
  1041. if (void 0 === l.constructor_body)
  1042. throw new mt(f + " has no accessible constructor");
  1043. var t = l.constructor_body[arguments.length];
  1044. if (void 0 === t)
  1045. throw new mt("Tried to invoke ctor of " + f + " with invalid number of parameters (" + arguments.length + ") - expected (" + Object.keys(l.constructor_body).toString() + ") parameters instead!");
  1046. return t.apply(this, arguments)
  1047. })),
  1048. s = Object.create(o, {
  1049. constructor: {
  1050. value: a
  1051. }
  1052. });
  1053. a.prototype = s;
  1054. var l = new Ut(f, a, s, p, r, i, u, c),
  1055. h = new re(f, l, !0, !1, !1),
  1056. y = new re(f + "*", l, !1, !1, !1),
  1057. m = new re(f + " const*", l, !1, !0, !1);
  1058. return Mt[t] = {
  1059. pointerType: y,
  1060. constPointerType: m
  1061. },
  1062. ne(d, a),
  1063. [h, y, m]
  1064. }))
  1065. },
  1066. w: function(t, e, r, n, o, i) {
  1067. T(e > 0);
  1068. var a = ce(e, r);
  1069. o = ie(n, o),
  1070. bt([], [t], (function(t) {
  1071. var r = "constructor " + (t = t[0]).name;
  1072. if (void 0 === t.registeredClass.constructor_body && (t.registeredClass.constructor_body = []),
  1073. void 0 !== t.registeredClass.constructor_body[e - 1])
  1074. throw new mt("Cannot register multiple constructors with identical number of parameters (" + (e - 1) + ") for class '" + t.name + "'! Overload resolution is currently only performed using the parameter count, not actual type info!");
  1075. return t.registeredClass.constructor_body[e - 1] = function() {
  1076. se("Cannot construct " + t.name + " due to unbound types", a)
  1077. },
  1078. bt([], a, (function(n) {
  1079. return n.splice(1, 0, null),
  1080. t.registeredClass.constructor_body[e - 1] = le(r, n, null, o, i),
  1081. []
  1082. })),
  1083. []
  1084. }))
  1085. },
  1086. c: function(t, e, r, n, o, i, a, u) {
  1087. var s = ce(r, n);
  1088. e = ct(e),
  1089. i = ie(o, i),
  1090. bt([], [t], (function(t) {
  1091. var n = (t = t[0]).name + "." + e;
  1092. function o() {
  1093. se("Cannot call " + n + " due to unbound types", s)
  1094. }
  1095. e.startsWith("@@") && (e = Symbol[e.substring(2)]),
  1096. u && t.registeredClass.pureVirtualFunctions.push(e);
  1097. var c = t.registeredClass.instancePrototype,
  1098. f = c[e];
  1099. return void 0 === f || void 0 === f.overloadTable && f.className !== t.name && f.argCount === r - 2 ? (o.argCount = r - 2,
  1100. o.className = t.name,
  1101. c[e] = o) : (It(c, e, n),
  1102. c[e].overloadTable[r - 2] = o),
  1103. bt([], s, (function(o) {
  1104. var u = le(n, o, t, i, a);
  1105. return void 0 === c[e].overloadTable ? (u.argCount = r - 2,
  1106. c[e] = u) : c[e].overloadTable[r - 2] = u,
  1107. []
  1108. })),
  1109. []
  1110. }))
  1111. },
  1112. x: function(t, e) {
  1113. _t(t, {
  1114. name: e = ct(e),
  1115. fromWireType: function(t) {
  1116. var e = ve.toValue(t);
  1117. return he(t),
  1118. e
  1119. },
  1120. toWireType: function(t, e) {
  1121. return ve.toHandle(e)
  1122. },
  1123. argPackAdvance: 8,
  1124. readValueFromPointer: Bt,
  1125. destructorFunction: null
  1126. })
  1127. },
  1128. j: function(t, e, r) {
  1129. var n = ut(r);
  1130. _t(t, {
  1131. name: e = ct(e),
  1132. fromWireType: function(t) {
  1133. return t
  1134. },
  1135. toWireType: function(t, e) {
  1136. if ("number" != typeof e && "boolean" != typeof e)
  1137. throw new TypeError('Cannot convert "' + ge(e) + '" to ' + this.name);
  1138. return e
  1139. },
  1140. argPackAdvance: 8,
  1141. readValueFromPointer: we(e, n),
  1142. destructorFunction: null
  1143. })
  1144. },
  1145. l: function(t, e, r, n, o, i) {
  1146. // Registering functions from constructor (;204;)
  1147. var a = ce(e, r);
  1148. t = ct(t),
  1149. o = ie(n, o),
  1150. xt(t, (function() {
  1151. se("Cannot call " + t + " due to unbound types", a)
  1152. }), e - 1),
  1153. bt([], a, (function(r) {
  1154. var n = [r[0], null].concat(r.slice(1));
  1155. return ne(t, le(t, n, null, o, i), e - 1),
  1156. []
  1157. }))
  1158. },
  1159. b: function(t, e, r, n, o) {
  1160. e = ct(e),
  1161. -1 === o && (o = 4294967295);
  1162. var i = ut(r),
  1163. a = function(t) {
  1164. return t
  1165. };
  1166. if (0 === n) {
  1167. var u = 32 - 8 * r;
  1168. a = function(t) {
  1169. return t << u >>> u
  1170. }
  1171. }
  1172. var s = e.includes("unsigned");
  1173. _t(t, {
  1174. name: e,
  1175. fromWireType: a,
  1176. toWireType: function(t, r) {
  1177. if ("number" != typeof r && "boolean" != typeof r)
  1178. throw new TypeError('Cannot convert "' + ge(r) + '" to ' + this.name);
  1179. if (r < n || r > o)
  1180. throw new TypeError('Passing a number "' + ge(r) + '" from JS side to C/C++ side to an argument of type "' + e + '", which is outside the valid range [' + n + ", " + o + "]!");
  1181. return s ? r >>> 0 : 0 | r
  1182. },
  1183. argPackAdvance: 8,
  1184. readValueFromPointer: be(e, i, 0 !== n),
  1185. destructorFunction: null
  1186. })
  1187. },
  1188. a: function(t, e, r) {
  1189. var n = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array][e];
  1190. function o(t) {
  1191. var e = R,
  1192. r = e[t >>= 2],
  1193. o = e[t + 1];
  1194. return new n(E, o, r)
  1195. }
  1196. _t(t, {
  1197. name: r = ct(r),
  1198. fromWireType: o,
  1199. argPackAdvance: 8,
  1200. readValueFromPointer: o
  1201. }, {
  1202. ignoreDuplicateRegistrations: !0
  1203. })
  1204. },
  1205. k: function(t, e) {
  1206. var r = "std::string" === (e = ct(e));
  1207. _t(t, {
  1208. name: e,
  1209. fromWireType: function(t) {
  1210. var e, n = R[t >> 2];
  1211. if (r)
  1212. for (var o = t + 4, i = 0; i <= n; ++i) {
  1213. var a = t + 4 + i;
  1214. if (i == n || 0 == O[a]) {
  1215. var u = UTF8ToString(o, a - o);
  1216. void 0 === e ? e = u : (e += String.fromCharCode(0),
  1217. e += u),
  1218. o = a + 1
  1219. }
  1220. }
  1221. else {
  1222. var s = new Array(n);
  1223. for (i = 0; i < n; ++i)
  1224. s[i] = String.fromCharCode(O[t + 4 + i]);
  1225. e = s.join("")
  1226. }
  1227. return We(t),
  1228. e
  1229. },
  1230. toWireType: function(t, e) {
  1231. e instanceof ArrayBuffer && (e = new Uint8Array(e));
  1232. var n = "string" == typeof e;
  1233. n || e instanceof Uint8Array || e instanceof Uint8ClampedArray || e instanceof Int8Array || vt("Cannot pass non-string to std::string");
  1234. var o = (r && n ? function() {
  1235. return UTF8CharCount(e)
  1236. } :
  1237. function() {
  1238. return e.length
  1239. }
  1240. )(),
  1241. i = ke(4 + o + 1);
  1242. if (R[i >> 2] = o,
  1243. r && n)
  1244. stringToUTF8Array(e, O, i + 4, o + 1);
  1245. else if (n)
  1246. for (var a = 0; a < o; ++a) {
  1247. var u = e.charCodeAt(a);
  1248. u > 255 && (We(i),
  1249. vt("String has UTF-16 code units that do not fit in 8 bits")),
  1250. O[i + 4 + a] = u
  1251. }
  1252. else
  1253. for (a = 0; a < o; ++a)
  1254. O[i + 4 + a] = e[a];
  1255. return null !== t && t.push(We, i),
  1256. i
  1257. },
  1258. argPackAdvance: 8,
  1259. readValueFromPointer: Bt,
  1260. destructorFunction: function(t) {
  1261. We(t)
  1262. }
  1263. })
  1264. },
  1265. e: function(t, e, r) {
  1266. var n, o, i, a, u;
  1267. r = ct(r),
  1268. 2 === e ? (n = UTF16ArrayToString,
  1269. o = H,
  1270. a = Y,
  1271. i = function() {
  1272. return W
  1273. },
  1274. u = 1) : 4 === e && (n = V,
  1275. o = z,
  1276. a = B,
  1277. i = function() {
  1278. return R
  1279. },
  1280. u = 2),
  1281. _t(t, {
  1282. name: r,
  1283. fromWireType: function(t) {
  1284. for (var r, o = R[t >> 2], a = i(), s = t + 4, c = 0; c <= o; ++c) {
  1285. var f = t + 4 + c * e;
  1286. if (c == o || 0 == a[f >> u]) {
  1287. var l = n(s, f - s);
  1288. void 0 === r ? r = l : (r += String.fromCharCode(0),
  1289. r += l),
  1290. s = f + e
  1291. }
  1292. }
  1293. return We(t),
  1294. r
  1295. },
  1296. toWireType: function(t, n) {
  1297. "string" != typeof n && vt("Cannot pass non-string to C++ string type " + r);
  1298. var i = a(n),
  1299. s = ke(4 + i + e);
  1300. return R[s >> 2] = i >> u,
  1301. o(n, s + 4, i + e),
  1302. null !== t && t.push(We, s),
  1303. s
  1304. },
  1305. argPackAdvance: 8,
  1306. readValueFromPointer: Bt,
  1307. destructorFunction: function(t) {
  1308. We(t)
  1309. }
  1310. })
  1311. },
  1312. z: function(t, e) {
  1313. _t(t, {
  1314. isVoid: !0,
  1315. name: e = ct(e),
  1316. argPackAdvance: 0,
  1317. fromWireType: function() {},
  1318. toWireType: function(t, e) {}
  1319. })
  1320. },
  1321. m: he,
  1322. n: function(t) {
  1323. t > 4 && (de[t].refcount += 1)
  1324. },
  1325. o: function(t, e) {
  1326. var r, n, o;
  1327. n = "_emval_take_value",
  1328. void 0 === (o = lt[r = t]) && vt(n + " has unknown type " + ue(r));
  1329. var i = (t = o).readValueFromPointer(e);
  1330. return ve.toHandle(i)
  1331. },
  1332. h: function() {
  1333. abort("")
  1334. },
  1335. r: function(t, e, r) {
  1336. O.copyWithin(t, e, e + r)
  1337. },
  1338. s: function(t) {
  1339. O.length,
  1340. abort("OOM")
  1341. },
  1342. u: function(t, e) {},
  1343. v: function(t, e) {},
  1344. i: function(t, e, r, n) {
  1345. for (var o = 0, i = 0; i < r; i++) {
  1346. var a = j[e >> 2],
  1347. u = j[e + 4 >> 2];
  1348. e += 8;
  1349. for (var s = 0; s < u; s++)
  1350. Te.printChar(t, O[a + s]);
  1351. o += u
  1352. }
  1353. return j[n >> 2] = o,
  1354. 0
  1355. },
  1356. q: function(t) {
  1357. t
  1358. },
  1359. t: function(t, e, r, n) {
  1360. return Ee(t, e, r, n)
  1361. }
  1362. },
  1363. ke = (function() {
  1364. var import_table = {
  1365. a: import_table_impl
  1366. };
  1367. function updateGlobalBufferAndViews(t, e) {
  1368. var r, n, exports = t.exports;
  1369. o.asm = exports;
  1370. b = o.asm.B; // Mem
  1371. r = b.buffer
  1372. E = r
  1373. o.HEAP8 = S = new Int8Array(r),
  1374. o.HEAP16 = k = new Int16Array(r),
  1375. o.HEAP32 = j = new Int32Array(r),
  1376. o.HEAPU8 = O = new Uint8Array(r),
  1377. o.HEAPU16 = W = new Uint16Array(r),
  1378. o.HEAPU32 = R = new Uint32Array(r),
  1379. o.HEAPF32 = M = new Float32Array(r),
  1380. o.HEAPF64 = I = new Float64Array(r),
  1381. L = o.asm.D // Table
  1382. n = o.asm.C // ctor
  1383. N.unshift(n),
  1384. function(t) {
  1385. if (J--,
  1386. o.monitorRunDependencies && o.monitorRunDependencies(J),
  1387. 0 == J && (null !== X && (clearInterval(X),
  1388. X = null),
  1389. Z)) {
  1390. var e = Z;
  1391. Z = null,
  1392. e()
  1393. }
  1394. }()
  1395. }
  1396. function load_wasm(t) {
  1397. updateGlobalBufferAndViews(t.instance)
  1398. }
  1399. function getBinaryPromise(e) {
  1400. return function() {
  1401. if (!w) {
  1402. if (readSync)
  1403. return new Promise((function(t, e) {
  1404. readSync(Q, (function(e) {
  1405. t(new Uint8Array(e))
  1406. }), e)
  1407. }))
  1408. }
  1409. return Promise.resolve().then((function() {
  1410. return getBinary(Q)
  1411. }))
  1412. }().then((function(e) {
  1413. return WebAssembly.instantiate(e, import_table)
  1414. })).then((function(t) {
  1415. return t
  1416. })).then(e, (function(t) {
  1417. g("failed to asynchronously prepare wasm: " + t,Q),
  1418. abort(t)
  1419. }))
  1420. }
  1421. if (J++,
  1422. o.monitorRunDependencies && o.monitorRunDependencies(J),
  1423. o.instantiateWasm)
  1424. try {
  1425. return o.instantiateWasm(import_table, updateGlobalBufferAndViews)
  1426. } catch (t) {
  1427. return g("Module.instantiateWasm callback failed with error: " + t),
  1428. !1
  1429. }
  1430. w || "function" != typeof WebAssembly.instantiate || isDataURI(Q) || isFileURI(Q) || getBinaryPromise(load_wasm)
  1431. }(),
  1432. o.___wasm_call_ctors = function() {
  1433. return (o.___wasm_call_ctors = o.asm.C).apply(null, arguments)
  1434. },
  1435. o._malloc = function() {
  1436. return (ke = o._malloc = o.asm.E).apply(null, arguments)
  1437. }
  1438. ),
  1439. We = o._free = function() {
  1440. return (We = o._free = o.asm.F).apply(null, arguments)
  1441. },
  1442. je = o.___getTypeName = function() {
  1443. return (je = o.___getTypeName = o.asm.G).apply(null, arguments)
  1444. };
  1445. o.___embind_register_native_and_builtin_types = function() {
  1446. return (o.___embind_register_native_and_builtin_types = o.asm.H).apply(null, arguments)
  1447. },
  1448. o.dynCall_jiji = function() {
  1449. return (o.dynCall_jiji = o.asm.I).apply(null, arguments)
  1450. },
  1451. o.dynCall_iiiiij = function() {
  1452. return (o.dynCall_iiiiij = o.asm.J).apply(null, arguments)
  1453. },
  1454. o.dynCall_iiiiijj = function() {
  1455. return (o.dynCall_iiiiijj = o.asm.K).apply(null, arguments)
  1456. },
  1457. o.dynCall_iiiiiijj = function() {
  1458. return (o.dynCall_iiiiiijj = o.asm.L).apply(null, arguments)
  1459. },
  1460. o.dynCall_viijii = function() {
  1461. return (o.dynCall_viijii = o.asm.M).apply(null, arguments)
  1462. };
  1463. function ExitStatus(t) {
  1464. this.name = "ExitStatus",
  1465. this.message = "Program terminated with exit(" + t + ")",
  1466. this.status = t
  1467. }
  1468. function doRun(t) {
  1469. function postRun() {
  1470. Se || (Se = !0,o.calledRun = !0,C || (!0,
  1471. callRuntimeCallbacks(N),
  1472. o.onRuntimeInitialized && o.onRuntimeInitialized(),
  1473. function() {
  1474. if (o.postRun)
  1475. for ("function" == typeof o.postRun && (o.postRun = [o.postRun]); o.postRun.length;)
  1476. t = o.postRun.shift(),
  1477. q.unshift(t);
  1478. var t;
  1479. callRuntimeCallbacks(q)
  1480. }()))
  1481. }
  1482. t = t || l
  1483. J > 0 || (! function preRun() {
  1484. if (o.preRun)
  1485. for ("function" == typeof o.preRun && (o.preRun = [o.preRun]); o.preRun.length;)
  1486. t = o.preRun.shift(),
  1487. G.unshift(t);
  1488. var t;
  1489. callRuntimeCallbacks(G)
  1490. }(),
  1491. J > 0 || (o.setStatus ? (o.setStatus("Running..."),
  1492. setTimeout((function() {
  1493. setTimeout((function() {
  1494. o.setStatus("")
  1495. }), 1),
  1496. postRun()
  1497. }), 1)) : postRun()))
  1498. }
  1499. if (Z = function t() {
  1500. Se || doRun(),
  1501. Se || (Z = t)
  1502. },
  1503. o.run = doRun,
  1504. o.preInit)
  1505. for ("function" == typeof o.preInit && (o.preInit = [o.preInit]); o.preInit.length > 0;)
  1506. o.preInit.pop()();
  1507. doRun();
  1508. return o;
  1509. })
  1510. // XXX: With PythonMonkey, the required module
  1511. // is destructed(?) once the function is called
  1512. // This is probably not what actaully happened, but
  1513. // for now, everytime an FP is generated, the entire
  1514. // WASM module is reloaded as a workaround
  1515. function instantiateRuntime(){
  1516. return new Promise((resolve, reject) => {
  1517. var fpRuntime = AudioFingerprintRuntime()
  1518. var monitor = setInterval(() => {
  1519. if (typeof fpRuntime.ExtractQueryFP == "function")
  1520. clearInterval(monitor) || resolve(fpRuntime)
  1521. })
  1522. })
  1523. }
  1524. function GenerateFP(floatArray) {
  1525. let PCMBuffer = Float32Array.from(floatArray)
  1526. console.log('[afp] input samples n=', PCMBuffer.length)
  1527. return instantiateRuntime().then((fpRuntime) => {
  1528. console.log('[afp] begin fingerprinting')
  1529. let fp_vector = fpRuntime.ExtractQueryFP(PCMBuffer.buffer)
  1530. let result_buf = new Uint8Array(fp_vector.size());
  1531. for (let t = 0; t < fp_vector.size(); t++)
  1532. result_buf[t] = fp_vector.get(t);
  1533. return globalThis.b64encode(result_buf)
  1534. });
  1535. }
  1536. if (typeof exports != 'undefined') /* Node, PythonMonkey */
  1537. exports.GenerateFP = GenerateFP;