@authme/util 2.8.41 → 2.8.44

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.
Files changed (42) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.js +34950 -0
  3. package/index.esm.d.ts +1 -0
  4. package/index.esm.js +34891 -0
  5. package/package.json +6 -13
  6. package/src/index.d.ts +5 -5
  7. package/src/lib/authme-error.d.ts +33 -33
  8. package/src/lib/authme-log.d.ts +47 -47
  9. package/src/lib/background-request-process.d.ts +1 -1
  10. package/src/lib/common/client-info.service.d.ts +2 -2
  11. package/src/lib/common/index.d.ts +13 -13
  12. package/src/lib/common/jwt-decode.service.d.ts +19 -19
  13. package/src/lib/common/state.service.d.ts +4 -4
  14. package/src/lib/const.d.ts +1 -1
  15. package/src/lib/enum/deviceType.enum.d.ts +5 -5
  16. package/src/lib/enum/index.d.ts +2 -2
  17. package/src/lib/enum/timeUnit.enum.d.ts +5 -5
  18. package/src/lib/file-saver.d.ts +11 -11
  19. package/src/lib/shared-util.d.ts +5 -5
  20. package/src/lib/storage/index.d.ts +1 -1
  21. package/src/lib/storage/storage.d.ts +18 -18
  22. package/src/lib/version.d.ts +1 -1
  23. package/src/ui/camera.d.ts +49 -49
  24. package/src/ui/canvas/clear-canvas.d.ts +1 -1
  25. package/src/ui/canvas/get-canvas-size.d.ts +19 -19
  26. package/src/ui/canvas/index.d.ts +3 -3
  27. package/src/ui/canvas/video-to-image.d.ts +14 -14
  28. package/src/ui/cssToJs.d.ts +5 -5
  29. package/src/ui/dropMenu.d.ts +1 -1
  30. package/src/ui/element-style.d.ts +2 -2
  31. package/src/ui/error-message.d.ts +15 -15
  32. package/src/ui/icon.d.ts +4 -4
  33. package/src/ui/index.d.ts +12 -12
  34. package/src/ui/popup.d.ts +3 -3
  35. package/src/ui/sdk-loading.d.ts +2 -2
  36. package/src/ui/spinner.d.ts +6 -6
  37. package/src/ui/ui-lottie/index.d.ts +1 -1
  38. package/src/ui/ui-lottie/sdk_loading.d.ts +239 -239
  39. package/src/ui/uiThemeStyle.d.ts +6 -6
  40. package/src/ui/uploadModal.d.ts +14 -14
  41. package/index.cjs +0 -3442
  42. package/index.js +0 -3375
package/index.cjs DELETED
@@ -1,3442 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/es.array.iterator.js');
6
- require('core-js/modules/es.array-buffer.slice.js');
7
- require('core-js/modules/es.typed-array.uint8-array.js');
8
- require('core-js/modules/es.typed-array.fill.js');
9
- require('core-js/modules/es.typed-array.set.js');
10
- require('core-js/modules/es.typed-array.sort.js');
11
- require('core-js/modules/es.typed-array.to-locale-string.js');
12
- require('core-js/modules/es.promise.js');
13
- require('core-js/modules/es.regexp.exec.js');
14
- require('core-js/modules/es.string.match.js');
15
- require('core-js/modules/es.string.replace.js');
16
- require('core-js/modules/es.regexp.to-string.js');
17
- require('core-js/modules/web.dom-collections.iterator.js');
18
- require('core-js/modules/es.object.assign.js');
19
- require('core-js/modules/es.number.parse-int.js');
20
- var jwt_decode = require('jwt-decode');
21
- require('core-js/modules/web.url-search-params.js');
22
- require('core-js/modules/es.string.search.js');
23
- require('core-js/modules/es.typed-array.uint32-array.js');
24
- require('core-js/modules/es.array.includes.js');
25
- require('core-js/modules/es.string.includes.js');
26
- var fileSaver = require('file-saver');
27
- var JSZip = require('jszip');
28
- require('core-js/modules/es.parse-int.js');
29
- var Lottie = require('lottie-web');
30
- require('core-js/modules/es.number.to-fixed.js');
31
- require('core-js/modules/es.array.sort.js');
32
- require('core-js/modules/esnext.global-this.js');
33
- require('core-js/modules/es.string.trim.js');
34
- require('core-js/modules/es.string.starts-with.js');
35
- require('core-js/modules/es.symbol.description.js');
36
-
37
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
38
-
39
- var jwt_decode__default = /*#__PURE__*/_interopDefaultLegacy(jwt_decode);
40
- var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
41
- var Lottie__default = /*#__PURE__*/_interopDefaultLegacy(Lottie);
42
-
43
- const GLOBAL_KEY = '_AuthmeConfig';
44
- const _storage = {};
45
- exports.STORAGE_KEY = void 0;
46
- (function (STORAGE_KEY) {
47
- STORAGE_KEY["LOADING_LOTTIE"] = "loadingLottie";
48
- STORAGE_KEY["OCR_IDCARD_RESULT_FORMAT"] = "ocrIdcardResultFormat";
49
- STORAGE_KEY["ENABLE_EVENT_TRACKING"] = "enableEventTracking";
50
- STORAGE_KEY["EVENT_TRACK_URL"] = "eventTrackUrl";
51
- STORAGE_KEY["API_BASE_URL"] = "apiBaseUrl";
52
- })(exports.STORAGE_KEY || (exports.STORAGE_KEY = {}));
53
- function getItem(key) {
54
- return _storage[GLOBAL_KEY][key];
55
- }
56
- function setItem(key, val) {
57
- if (!_storage[GLOBAL_KEY]) {
58
- _storage[GLOBAL_KEY] = {};
59
- }
60
- return _storage[GLOBAL_KEY][key] = val;
61
- }
62
- function removeItem(key) {
63
- return delete _storage[GLOBAL_KEY][key];
64
- }
65
- function clear() {
66
- _storage[GLOBAL_KEY] = {};
67
- }
68
- const Storage = {
69
- getItem,
70
- setItem,
71
- removeItem,
72
- clear
73
- };
74
-
75
- /******************************************************************************
76
- Copyright (c) Microsoft Corporation.
77
-
78
- Permission to use, copy, modify, and/or distribute this software for any
79
- purpose with or without fee is hereby granted.
80
-
81
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
82
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
83
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
84
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
85
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
86
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
87
- PERFORMANCE OF THIS SOFTWARE.
88
- ***************************************************************************** */
89
-
90
- function __rest(s, e) {
91
- var t = {};
92
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
93
- t[p] = s[p];
94
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
95
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
96
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
97
- t[p[i]] = s[p[i]];
98
- }
99
- return t;
100
- }
101
-
102
- function __awaiter(thisArg, _arguments, P, generator) {
103
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
104
- return new (P || (P = Promise))(function (resolve, reject) {
105
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
106
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
107
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
108
- step((generator = generator.apply(thisArg, _arguments || [])).next());
109
- });
110
- }
111
-
112
- function __values(o) {
113
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
114
- if (m) return m.call(o);
115
- if (o && typeof o.length === "number") return {
116
- next: function () {
117
- if (o && i >= o.length) o = void 0;
118
- return { value: o && o[i++], done: !o };
119
- }
120
- };
121
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
122
- }
123
-
124
- function __await(v) {
125
- return this instanceof __await ? (this.v = v, this) : new __await(v);
126
- }
127
-
128
- function __asyncGenerator(thisArg, _arguments, generator) {
129
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
130
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
131
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
132
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
133
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
134
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
135
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
136
- function fulfill(value) { resume("next", value); }
137
- function reject(value) { resume("throw", value); }
138
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
139
- }
140
-
141
- function __asyncValues(o) {
142
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
143
- var m = o[Symbol.asyncIterator], i;
144
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
145
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
146
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
147
- }
148
-
149
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
150
- var e = new Error(message);
151
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
152
- };
153
-
154
- class AuthmeError {
155
- constructor(code, cause = null) {
156
- this._cause = null;
157
- this._code = null;
158
- this._code = code;
159
- this._cause = cause;
160
- }
161
- get message() {
162
- return '[Authme SDK Error] Code: ' + this.code;
163
- }
164
- setCode(code) {
165
- this._code = code;
166
- }
167
- get code() {
168
- return this._code;
169
- }
170
- get cause() {
171
- return this._cause;
172
- }
173
- }
174
- exports.ErrorCode = void 0;
175
- (function (ErrorCode) {
176
- // 1XX for engine
177
- ErrorCode[ErrorCode["BROWSER_NOT_SUPPORT"] = 100] = "BROWSER_NOT_SUPPORT";
178
- ErrorCode[ErrorCode["ENGINE_INIT_ERROR"] = 101] = "ENGINE_INIT_ERROR";
179
- ErrorCode[ErrorCode["ENGINE_MODULE_IS_INITIALIZING"] = 102] = "ENGINE_MODULE_IS_INITIALIZING";
180
- ErrorCode[ErrorCode["ENGINE_MODULE_INIT_ERROR"] = 103] = "ENGINE_MODULE_INIT_ERROR";
181
- ErrorCode[ErrorCode["RECOGNITION_NOT_AVAILABLE"] = 104] = "RECOGNITION_NOT_AVAILABLE";
182
- ErrorCode[ErrorCode["RECOGNITION_ERROR"] = 105] = "RECOGNITION_ERROR";
183
- ErrorCode[ErrorCode["INVALID_AUTH_ERROR"] = 106] = "INVALID_AUTH_ERROR";
184
- ErrorCode[ErrorCode["SCREEN_RESOLUTION_TOO_LOW"] = 107] = "SCREEN_RESOLUTION_TOO_LOW";
185
- ErrorCode[ErrorCode["SCREEN_SIZE_CHANGED"] = 108] = "SCREEN_SIZE_CHANGED";
186
- // 2 for LIVENESS
187
- ErrorCode[ErrorCode["LIVENESS_NOT_PASSED"] = 201] = "LIVENESS_NOT_PASSED";
188
- // 3 for ID-Recognition
189
- ErrorCode[ErrorCode["ID_RECOGNITION_CONFIRM_INFO_ERROR"] = 301] = "ID_RECOGNITION_CONFIRM_INFO_ERROR";
190
- ErrorCode[ErrorCode["ID_RECOGNITION_TIMEOUT"] = 302] = "ID_RECOGNITION_TIMEOUT";
191
- // 4 for Anti-fraud
192
- ErrorCode[ErrorCode["ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED"] = 401] = "ID_RECOGNITION_ANTI_FRAUD_NOT_PASSED";
193
- // 9 for common
194
- ErrorCode[ErrorCode["SDK_INTERNAL_ERROR"] = 900] = "SDK_INTERNAL_ERROR";
195
- ErrorCode[ErrorCode["NETWORK_ERROR"] = 901] = "NETWORK_ERROR";
196
- ErrorCode[ErrorCode["HTTP_ERROR_RESPONSE"] = 902] = "HTTP_ERROR_RESPONSE";
197
- ErrorCode[ErrorCode["USER_CANCEL"] = 903] = "USER_CANCEL";
198
- ErrorCode[ErrorCode["CAMERA_NOT_SUPPORT"] = 904] = "CAMERA_NOT_SUPPORT";
199
- ErrorCode[ErrorCode["SERVER_ERROR"] = 905] = "SERVER_ERROR";
200
- ErrorCode[ErrorCode["EVENT_NAME_WRONG"] = 906] = "EVENT_NAME_WRONG";
201
- ErrorCode[ErrorCode["ERROR_USER_CANCEL"] = 907] = "ERROR_USER_CANCEL";
202
- })(exports.ErrorCode || (exports.ErrorCode = {}));
203
- const verificationErrorMessages = code => {
204
- const errorMessage = '';
205
- switch (code) {
206
- case 'IDT004':
207
- return '活體檢測信心度過低:系統審核活體檢測信心度小於身分驗證條件(KYC Option)配置的通過門檻,請用戶重新進行活體檢測。';
208
- case 'IDT005':
209
- return '人證比對信心度過低:系統審核人證比對信心度小於身分驗證條件(KYC Option)配置的通過門檻,請用戶重新上傳證件及重新進行活體檢測。';
210
- case 'IDT113':
211
- return '證件防偽辨識失敗:比對由前端防偽引擎提供的防偽數據發現異常,請用戶重新上傳證件。';
212
- case 'IDT115':
213
- return '證件資訊驗證失敗:透過台灣內政部領補換證件 API 驗證失敗,請用戶重新上傳最新證件。';
214
- case 'IDT116':
215
- return '證件資訊驗證次數已達上限:透過台灣內政部領補換證件 API 驗證時超過存取次數上限,請用戶隔日再重新上傳最新證件。';
216
- case 'IDT117':
217
- return '證件掛失中:透過台灣內政部領補換證件 API 驗證時發現該證件掛失中,請用戶辦理新證件或取消掛失狀態。';
218
- case 'IDT118':
219
- return '身分證號碼已停止使用:透過台灣內政部領補換證件 API 驗證時發現該身分證號碼已停用,請用戶重新上傳可用證件。';
220
- case 'IDT119':
221
- return '身分證號碼已暫停使用者權限:透過台灣內政部領補換證件 API 驗證時發現該身分證號碼已暫停使用者權限,請用戶重新上傳可用證件或洽詢相關單位。';
222
- case 'IDT120':
223
- return '未通過同證件比對:用戶在驗證證件正反面的過程中更換了證件,請用戶使用相同證件重新操作。';
224
- case 'IDT121':
225
- return '證件資料不完整:用戶上傳證件的 OCR 文字辨識結果缺少必要欄位,請用戶重新上傳證件。';
226
- case 'IDT124':
227
- return '未通過單證件欄位比對';
228
- case 'IDT200':
229
- return '活體檢測失敗:未能取得前端活體辨識引擎提供的活體檢測信心度,請用戶重新進行活體檢測。';
230
- case 'IDT300':
231
- return '人臉比對失敗:未能取得後端人臉特徵比對引擎提供的人證比對信心度,請用戶重新上傳證件及重新進行活體檢測。';
232
- case 'IDT330':
233
- return '人臉比對來源的圖像無法辨識出人臉特徵';
234
- case 'IDT331':
235
- return '找不到人臉比對目標之身分驗證條件';
236
- case 'IDT332':
237
- return '找不到人臉比對目標之已審核活體事件';
238
- case 'IDT333':
239
- return '人臉比對目標的圖像無法辨識出人臉特徵';
240
- case 'IDP100':
241
- return '強制待審核:身分驗證條件(KYC Option)要求證件上傳需要人工審核。';
242
- case 'IDP101':
243
- return '證件內容異動:使用者在確認證件 OCR 文件辨識結果時有修改欄位值。';
244
- case 'IDP102':
245
- return '證件比對發生錯誤:身分驗證條件(KYC Option)啟用了證件防偽辨識,比對防偽證件與 OCR 證件是否為相同證件時發現不相符。';
246
- case 'IDP103':
247
- return '證件資訊驗證發生錯誤:身分驗證條件(KYC Option)啟用了證件資訊驗證,但是在嘗試透過台灣內政部領補換證件 API 驗證證件資訊時發生錯誤。';
248
- case 'IDP104':
249
- return '防偽辨識發生錯誤:身分驗證條件(KYC Option)啟用了證件防偽辨識,但是在驗證證件防偽資訊時發生錯誤。';
250
- case 'IDP106':
251
- return '相片完整性比對發生錯誤:比對證件照片的色彩解析度及是否為支援的證件類型時發現不符合完整性要求。';
252
- case 'IDP107':
253
- return '數位影像真實性比對發生錯誤:比對證件照片發現有被數位修改跡或沒有人臉特徵。';
254
- case 'IDP108':
255
- return '證件相片 OCR 文字辨識發生錯誤:無法透過 OCR 引擎辨識證件相片中的文字欄位或辨識階段發生錯誤。';
256
- case 'IDP200':
257
- return '未通過單證件欄位比對:身分驗證條件(KYC Option)啟用了單證件欄位比對,在比對證件正面身分證號與背面條碼時發現不相符。';
258
- default:
259
- return errorMessage;
260
- }
261
- };
262
-
263
- function decodeToken(token) {
264
- const decoded = jwt_decode__default["default"](token);
265
- const {
266
- exp,
267
- iat
268
- } = decoded;
269
- return {
270
- payload: decoded,
271
- exp: typeof exp === 'number' ? exp : 0,
272
- iat: typeof iat === 'number' ? iat : 0
273
- };
274
- }
275
-
276
- function getDeviceInfo() {
277
- const userAgent = window.navigator.userAgent;
278
- const deviceType = getDeviceType(userAgent);
279
- const browserType = getBrowserType(userAgent);
280
- return `${deviceType} (${browserType})`;
281
- }
282
- function getDeviceType(userAgent) {
283
- if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
284
- return 'iPad/iPhone';
285
- } else if (userAgent.match(/Android/i)) {
286
- return 'Android';
287
- } else if (userAgent.match(/Windows Phone/i)) {
288
- return 'Windows Phone';
289
- } else if (userAgent.match(/Windows NT/i)) {
290
- return 'Windows PC';
291
- } else if (userAgent.match(/Mac OS/i)) {
292
- return 'Mac';
293
- } else if (userAgent.match(/Linux/i)) {
294
- return 'Linux';
295
- } else {
296
- return 'Unknown Device';
297
- }
298
- }
299
- function getBrowserType(userAgent) {
300
- if (userAgent.match(/Chrome/i)) {
301
- return 'Chrome';
302
- } else if (userAgent.match(/Firefox/i)) {
303
- return 'Firefox';
304
- } else if (userAgent.match(/Edge/i)) {
305
- return 'Edge';
306
- } else if (userAgent.match(/Safari/i)) {
307
- return 'Safari';
308
- } else if (userAgent.match(/MSIE/i) || userAgent.match(/Trident/i)) {
309
- return 'IE';
310
- } else {
311
- return 'Unknown Browser';
312
- }
313
- }
314
- function getSystemInfo() {
315
- const userAgent = window.navigator.userAgent;
316
- const os = getOs(userAgent);
317
- const osVersion = getOsVersion(userAgent);
318
- return `${os} (${osVersion})`;
319
- }
320
- function getOs(userAgent) {
321
- if (userAgent.match(/Windows NT 10/i)) {
322
- return 'Windows 10';
323
- } else if (userAgent.match(/Windows NT 6.3/i)) {
324
- return 'Windows 8.1';
325
- } else if (userAgent.match(/Windows NT 6.2/i)) {
326
- return 'Windows 8';
327
- } else if (userAgent.match(/Windows NT 6.1/i)) {
328
- return 'Windows 7';
329
- } else if (userAgent.match(/Windows NT 6.0/i)) {
330
- return 'Windows Vista';
331
- } else if (userAgent.match(/Windows NT 5.1/i)) {
332
- return 'Windows XP';
333
- } else if (userAgent.match(/Windows NT 5.0/i)) {
334
- return 'Windows 2000';
335
- } else if (userAgent.match(/Mac/i)) {
336
- return 'Mac OS';
337
- } else if (userAgent.match(/Linux/i)) {
338
- return 'Linux';
339
- } else {
340
- return 'Unknown OS';
341
- }
342
- }
343
- function getOsVersion(userAgent) {
344
- if (userAgent.match(/Windows NT/i)) {
345
- const matches = userAgent.match(/Windows NT ([\d\\.]+)/i);
346
- if (matches) {
347
- return matches[1];
348
- } else {
349
- return '';
350
- }
351
- }
352
- if (userAgent.match(/Mac/i)) {
353
- const matches = userAgent.match(/Mac OS X ([\d_.]+)/i);
354
- if (matches) {
355
- return matches[1].replace(/_/g, '.');
356
- } else {
357
- return '';
358
- }
359
- } else if (userAgent.match(/Android/i)) {
360
- const matches = userAgent.match(/Android ([\d.]+)/i);
361
- if (matches) {
362
- return matches[1];
363
- } else {
364
- return '';
365
- }
366
- } else {
367
- return '';
368
- }
369
- }
370
-
371
- class State {
372
- constructor(initialValue = null) {
373
- this._effects = [];
374
- this._value = initialValue;
375
- }
376
- getValue() {
377
- return this._value;
378
- }
379
- setValue(newValue) {
380
- this._value = newValue;
381
- this._runEffects(newValue);
382
- }
383
- addEffect(effect) {
384
- this._effects.push(effect);
385
- }
386
- _runEffects(value) {
387
- for (const effect of this._effects) {
388
- effect(value);
389
- }
390
- }
391
- }
392
- function useState(initialValue = null, subscription, effects = []) {
393
- const state = new State(initialValue);
394
- for (const effect of effects) {
395
- state.addEffect(effect);
396
- }
397
- function getValue() {
398
- return state.getValue();
399
- }
400
- function setValue(newValue) {
401
- if (subscription && newValue !== state.getValue()) {
402
- subscription.next(newValue);
403
- }
404
- state.setValue(newValue);
405
- }
406
- return [getValue, setValue];
407
- }
408
-
409
- function dataURItoBlob(dataURI) {
410
- // convert base64/URLEncoded data component to raw binary data held in a string
411
- const byteString = atob(dataURI.split(',')[1]);
412
- // separate out the mime component
413
- const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
414
- // write the bytes of the string to a typed array
415
- const ia = new Uint8Array(byteString.length);
416
- for (let i = 0; i < byteString.length; i++) {
417
- ia[i] = byteString.charCodeAt(i);
418
- }
419
- const blob = new Blob([ia], {
420
- type: mimeString
421
- });
422
- return blob;
423
- }
424
- function UintArrayToBlob(width, height, data, canvasEle, imageFormat) {
425
- if (document) {
426
- if (!canvasEle) {
427
- canvasEle = document.createElement('canvas');
428
- }
429
- const ctx = canvasEle.getContext('2d');
430
- canvasEle.height = height;
431
- canvasEle.width = width;
432
- if (ctx) {
433
- const imageData = ctx.createImageData(canvasEle.width, canvasEle.height);
434
- imageData.data.set(data);
435
- ctx.putImageData(imageData, 0, 0);
436
- if (imageFormat === 'png') {
437
- return dataURItoBlob(canvasEle.toDataURL('image/png'));
438
- } else {
439
- return dataURItoBlob(canvasEle.toDataURL('image/jpeg', 0.85));
440
- }
441
- }
442
- throw '[UintArrayToBlob] not running in browser.';
443
- } else {
444
- throw '[UintArrayToBlob] not running in browser.';
445
- }
446
- }
447
- function waitTime(ms) {
448
- return new Promise(res => {
449
- setTimeout(() => {
450
- res();
451
- }, ms);
452
- });
453
- }
454
- function retryPromiseWithCondition(promiseFactory, conditionFactory) {
455
- return __awaiter(this, void 0, void 0, function* () {
456
- try {
457
- const res = yield promiseFactory();
458
- return res;
459
- } catch (e) {
460
- if ((e === null || e === void 0 ? void 0 : e._code) === exports.ErrorCode.SERVER_ERROR) {
461
- throw e;
462
- }
463
- const retry = yield conditionFactory(e);
464
- if (retry) {
465
- return retryPromiseWithCondition(promiseFactory, conditionFactory);
466
- } else {
467
- throw e;
468
- }
469
- }
470
- });
471
- }
472
- function isMobileOrTablet() {
473
- return function (a) {
474
- return !!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4)) || /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || navigator.maxTouchPoints && navigator.maxTouchPoints > 2);
475
- }(navigator.userAgent || navigator.vendor || window.opera);
476
- }
477
- function isMobile() {
478
- return function (a) {
479
- return !!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4)) || /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
480
- }(navigator.userAgent || navigator.vendor || window.opera);
481
- }
482
- function osVersion() {
483
- let version = '';
484
- const android = navigator.userAgent.match(/Android\s+([\d\\.]+)/i);
485
- if (android) {
486
- version = android[0];
487
- }
488
- const ios = navigator.userAgent.match(/OS\s+([\d\\_]+)/i);
489
- if (ios) {
490
- version = ios[0].replace('OS ', 'iOS');
491
- }
492
- const win = navigator.userAgent.match(/Windows NT (\d+\.\d+)/);
493
- if (win) {
494
- version = win[0];
495
- }
496
- if (!version) {
497
- version = navigator.platform;
498
- }
499
- return version;
500
- }
501
- function splitResult(result) {
502
- if (result.address) {
503
- const originAddress = result.address;
504
- const address1Index = checkCity(originAddress);
505
- result.address1 = address1Index === -1 ? '' : originAddress.slice(0, 3);
506
- const address2 = address1Index === -1 ? originAddress : originAddress.slice(3);
507
- const address2Index = checkZone(address2);
508
- result.address2 = address2Index === -1 ? '' : address2.slice(0, address2Index + 1);
509
- result.address3 = address2Index === -1 ? address2 : address2.slice(address2Index + 1);
510
- }
511
- if (result.dateOfBirth) {
512
- const splitDateOfBirth = result.dateOfBirth.split('-');
513
- const dateOfBirthY = (+splitDateOfBirth[0] - 1911).toString();
514
- result.dateOfBirthY = dateOfBirthY.length < 3 ? '0' + dateOfBirthY : dateOfBirthY;
515
- result.dateOfBirthM = splitDateOfBirth[1];
516
- result.dateOfBirthD = splitDateOfBirth[2];
517
- }
518
- if (result.dateOfIssue) {
519
- const splitDateOfIssue = result.dateOfIssue.split('-');
520
- const dateOfIssueY = (+splitDateOfIssue[0] - 1911).toString();
521
- result.dateOfIssueY = dateOfIssueY.length < 3 ? '0' + dateOfIssueY : dateOfIssueY;
522
- result.dateOfIssueM = splitDateOfIssue[1];
523
- result.dateOfIssueD = splitDateOfIssue[2];
524
- }
525
- return result;
526
- }
527
- function checkCity(address) {
528
- const citys = ['臺北市', '臺中市', '基隆市', '臺南市', '高雄市', '新北市', '宜蘭縣', '桃園市', '嘉義市', '新竹縣', '苗栗縣', '南投縣', '彰化縣', '新竹市', '雲林縣', '嘉義縣', '屏東縣', '花蓮縣', '臺東縣', '金門縣', '澎湖縣', '連江縣', '臺中縣', '臺南縣', '高雄縣'];
529
- for (const city of citys) {
530
- if (address.indexOf(city) !== -1) {
531
- return address.indexOf(city);
532
- }
533
- }
534
- return -1;
535
- }
536
- function checkZone(address) {
537
- const zones = ['鄉', '鎮', '市', '區'];
538
- for (const zone of zones) {
539
- if (address.indexOf(zone) !== -1) {
540
- return address.indexOf(zone);
541
- }
542
- }
543
- return -1;
544
- }
545
- function notEmpty(value) {
546
- return typeof value !== 'undefined' && value !== null && value !== '';
547
- }
548
- function combineResult(result) {
549
- const {
550
- address1,
551
- address2,
552
- address3,
553
- dateOfBirthY,
554
- dateOfBirthM,
555
- dateOfBirthD,
556
- dateOfIssueY,
557
- dateOfIssueM,
558
- dateOfIssueD
559
- } = result,
560
- others = __rest(result, ["address1", "address2", "address3", "dateOfBirthY", "dateOfBirthM", "dateOfBirthD", "dateOfIssueY", "dateOfIssueM", "dateOfIssueD"]);
561
- // 由於呼叫函數的情境包含 confirmOCRResult,
562
- // confirmOCRResult 並不會知道目前是什麼卡片類型,
563
- // 所以會以分割出的欄位來判斷是否進行欄位合併與覆寫。
564
- const newResult = Object.assign({}, others);
565
- if ([address1, address2, address3].every(notEmpty)) {
566
- newResult.address = `${address1}${address2}${address3}`;
567
- }
568
- if ([dateOfBirthY, dateOfBirthM, dateOfBirthD].every(notEmpty)) {
569
- newResult.dateOfBirth = `${1911 + Number.parseInt(dateOfBirthY || '0')}-${dateOfBirthM}-${dateOfBirthD}`;
570
- }
571
- if ([dateOfIssueY, dateOfIssueM, dateOfIssueD].every(notEmpty)) {
572
- newResult.dateOfIssue = `${1911 + Number.parseInt(dateOfIssueY || '0')}-${dateOfIssueM}-${dateOfIssueD}`;
573
- }
574
- return newResult;
575
- }
576
- const isIphone14proOrProMax = () => {
577
- const isIphone = () => {
578
- return /iPhone|iPad|iPod/i.test(navigator.userAgent);
579
- };
580
- return isIphone() && (screen.width === 430 && screen.height === 932 || screen.width === 393 && screen.height === 852);
581
- };
582
-
583
- function fileSaverService() {
584
- const filesQueue = [];
585
- function pushFile(file) {
586
- filesQueue.push(file);
587
- }
588
- function popAllFiles() {
589
- filesQueue.splice(0, filesQueue.length);
590
- }
591
- function saveFiles(fileName, json) {
592
- return __awaiter(this, void 0, void 0, function* () {
593
- const zip = new JSZip__default["default"]();
594
- filesQueue.forEach(fileItem => {
595
- zip.file(fileItem.name, fileItem.file);
596
- });
597
- if (json) zip.file('data.json', JSON.stringify(json));
598
- const content = yield zip.generateAsync({
599
- type: 'blob'
600
- });
601
- fileSaver.saveAs(content, `${fileName}.zip`);
602
- popAllFiles();
603
- });
604
- }
605
- return {
606
- pushFile,
607
- saveFiles
608
- };
609
- }
610
-
611
- const {
612
- saveFiles,
613
- pushFile
614
- } = fileSaverService();
615
- exports.RUN_FUNCTION_NAME = void 0;
616
- (function (RUN_FUNCTION_NAME) {
617
- RUN_FUNCTION_NAME["RECOGNITION"] = "service.recognition";
618
- RUN_FUNCTION_NAME["ANTI_FARUD_RECOGNITION"] = "antiFraudInstance.recognition";
619
- RUN_FUNCTION_NAME["API_REQUEST"] = "api.request";
620
- })(exports.RUN_FUNCTION_NAME || (exports.RUN_FUNCTION_NAME = {}));
621
- function debugLog(message, ...others) {
622
- if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
623
- console.log(message, ...others);
624
- }
625
- }
626
- function generateUniqueId(length = 32) {
627
- if (length <= 0) {
628
- throw new Error('Length should be a positive integer.');
629
- }
630
- // 定義可能的字元
631
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
632
- const charactersLength = characters.length;
633
- const randomValues = new Uint32Array(length);
634
- // 使用window.crypto.getRandomValues取得真正的隨機值
635
- window.crypto.getRandomValues(randomValues);
636
- let result = '';
637
- for (let i = 0; i < length; i++) {
638
- result += characters[randomValues[i] % charactersLength];
639
- }
640
- return result;
641
- }
642
- function debugTools() {
643
- const debugMode = new URLSearchParams(location.search).get('authme-debug') === 'true';
644
- const debugModeUI = new URLSearchParams(location.search).get('authme-debug-info') === 'true';
645
- const shouldGetDebugImage = new URLSearchParams(location.search).get('authme-debug-get-image') === 'true';
646
- const debugLogs = [];
647
- const logInfo = {
648
- userAgent: navigator.userAgent,
649
- token: '',
650
- message: ''
651
- };
652
- let currentRoundId = generateUniqueId(8);
653
- let currentType = null;
654
- const interiaTimeObj = {};
655
- function pushNewDebugLog(logParams) {
656
- var _a;
657
- if (!debugMode) return;
658
- const now = new Date();
659
- const _logParams = JSON.parse(JSON.stringify(logParams));
660
- if (_logParams.result) {
661
- (_a = _logParams.result) === null || _a === void 0 ? true : delete _a.imageData;
662
- }
663
- const newDebugLog = Object.assign(Object.assign({
664
- dateTime: now.toLocaleString(),
665
- roundId: currentRoundId,
666
- type: currentType !== null && currentType !== void 0 ? currentType : undefined
667
- }, _logParams), {
668
- time: now.getTime(),
669
- _id: generateUniqueId()
670
- });
671
- debugLogs.push(newDebugLog);
672
- return newDebugLog;
673
- }
674
- function pushNewDebugImage(image, log, options) {
675
- var _a, _b;
676
- if (!debugMode) return;
677
- const newLog = pushNewDebugLog(log);
678
- const recognitionFunctions = [exports.RUN_FUNCTION_NAME.ANTI_FARUD_RECOGNITION, exports.RUN_FUNCTION_NAME.RECOGNITION];
679
- const currentRoundRecognitionResultItem = debugLogs.find(item => item.roundId === (newLog === null || newLog === void 0 ? void 0 : newLog.roundId) && item.status === 'run-end' && (item.runFunction ? recognitionFunctions.includes(item.runFunction) : false));
680
- const imageStatus = (_a = currentRoundRecognitionResultItem === null || currentRoundRecognitionResultItem === void 0 ? void 0 : currentRoundRecognitionResultItem.result) === null || _a === void 0 ? void 0 : _a.eStatus;
681
- pushFile({
682
- name: `${(_b = options === null || options === void 0 ? void 0 : options.prefix) !== null && _b !== void 0 ? _b : ''}${newLog === null || newLog === void 0 ? void 0 : newLog.time}-${newLog === null || newLog === void 0 ? void 0 : newLog._id}${imageStatus ? `__${imageStatus}` : ''}.jpeg`,
683
- file: image
684
- });
685
- }
686
- function functionLogging(func, logParams) {
687
- return new Promise((resolve, reject) => {
688
- pushNewDebugLog(Object.assign(Object.assign({}, logParams), {
689
- status: 'run-start'
690
- }));
691
- func().then(result => {
692
- pushNewDebugLog(Object.assign(Object.assign({}, logParams), {
693
- status: 'run-end',
694
- roundId: currentRoundId,
695
- result
696
- }));
697
- resolve(result);
698
- }).catch(error => {
699
- pushNewDebugLog(Object.assign(Object.assign({}, logParams), {
700
- status: 'run-error',
701
- roundId: currentRoundId,
702
- result: error
703
- }));
704
- reject(error);
705
- });
706
- });
707
- }
708
- function renderDebugTips() {
709
- if (document.getElementById('debug-tips')) {
710
- return;
711
- }
712
- const debugTips = document.createElement('div');
713
- debugTips.style.position = 'fixed';
714
- debugTips.style.top = '50px';
715
- debugTips.style.right = '0';
716
- debugTips.style.zIndex = '999';
717
- debugTips.innerHTML = 'Debug Mode';
718
- debugTips.style.color = 'red';
719
- debugTips.style.fontWeight = 'bold';
720
- debugTips.setAttribute('id', 'debug-tips');
721
- document.body.appendChild(debugTips);
722
- }
723
- function renderDebugUI() {
724
- if (document.getElementById('debug-ui')) {
725
- return;
726
- }
727
- const debugUI = document.createElement('div');
728
- debugUI.style.position = 'fixed';
729
- debugUI.style.top = '0';
730
- debugUI.style.right = '0';
731
- debugUI.style.zIndex = '777';
732
- debugUI.style.backgroundColor = 'black';
733
- debugUI.style.color = 'white';
734
- debugUI.style.padding = '10px';
735
- debugUI.style.paddingRight = '150px';
736
- debugUI.style.fontSize = '12px';
737
- debugUI.style.opacity = '0.7';
738
- debugUI.style.boxSizing = 'border-box';
739
- debugUI.style.width = '100%';
740
- debugUI.style.maxHeight = '50vh';
741
- debugUI.style.overflow = 'auto';
742
- debugUI.setAttribute('id', 'debug-ui');
743
- const closeUI = document.createElement('button');
744
- closeUI.style.position = 'fixed';
745
- closeUI.style.top = '0';
746
- closeUI.style.right = '100px';
747
- closeUI.innerHTML = 'close';
748
- closeUI.addEventListener('click', () => {
749
- debugUI.style.display = 'none';
750
- });
751
- debugUI.appendChild(closeUI);
752
- const accordionUI = document.createElement('button');
753
- accordionUI.style.position = 'fixed';
754
- accordionUI.style.top = '0';
755
- accordionUI.style.right = '0';
756
- accordionUI.innerHTML = '收合/展開';
757
- accordionUI.addEventListener('click', () => {
758
- if (debugUI.style.maxHeight === '50vh') {
759
- debugUI.style.maxHeight = '5vh';
760
- } else {
761
- debugUI.style.maxHeight = '50vh';
762
- }
763
- });
764
- debugUI.appendChild(accordionUI);
765
- document.body.appendChild(debugUI);
766
- }
767
- function setTimeStart(behavior) {
768
- if (!debugModeUI) {
769
- return;
770
- }
771
- const dStart = new Date();
772
- const nStart = dStart.getTime();
773
- if (interiaTimeObj && interiaTimeObj[behavior]) {
774
- console.error('debugmode: setTimeStart duplicate', behavior);
775
- return false;
776
- }
777
- interiaTimeObj[behavior] = {
778
- behavior,
779
- start: nStart / 1000,
780
- duration: 0,
781
- end: 0
782
- };
783
- // console.log(interiaTimeObj[behavior])
784
- renderTimeInfo(behavior);
785
- return interiaTimeObj[behavior];
786
- }
787
- function setTimeEnd(behavior) {
788
- if (!debugModeUI) {
789
- return;
790
- }
791
- const dEnd = new Date();
792
- const nEnd = dEnd.getTime();
793
- if (!interiaTimeObj[behavior]) {
794
- console.error('debugmode: setTimeEnd not found', behavior);
795
- return false;
796
- }
797
- interiaTimeObj[behavior].end = nEnd / 1000;
798
- interiaTimeObj[behavior].duration = interiaTimeObj[behavior].end - interiaTimeObj[behavior].start;
799
- // console.log(interiaTimeObj[behavior])
800
- renderTimeInfo(behavior);
801
- return interiaTimeObj[behavior];
802
- }
803
- function setTimeDuration(behavior) {
804
- const ts = Date.now();
805
- setTimeStart(`${behavior}_${ts}`);
806
- return {
807
- end: () => {
808
- setTimeEnd(`${behavior}_${ts}`);
809
- }
810
- };
811
- }
812
- function renderTimeInfo(behavior) {
813
- const dom = document.querySelector(`#debug-ui-${behavior}`);
814
- const info = `{"behavior":<span style="color:green;">"${behavior}"</span>, "start": ${interiaTimeObj[behavior].start}, "duration": ${interiaTimeObj[behavior].duration}, "end": ${interiaTimeObj[behavior].end}}`;
815
- // const info = `<span style="color:green;">${behavior}</span>: Duration: ${interiaTimeObj[behavior].duration}s`;
816
- if (dom) {
817
- dom.innerHTML = info;
818
- return;
819
- }
820
- const debugUI = document.getElementById('debug-ui');
821
- const div = document.createElement('div');
822
- div.setAttribute('class', 'debug-ui-item');
823
- div.setAttribute('id', `debug-ui-${behavior}`);
824
- div.innerHTML = info;
825
- debugUI.appendChild(div);
826
- }
827
- function functionRunTime() {
828
- const arr = [];
829
- const items = document.querySelectorAll('.debug-ui-item');
830
- items.forEach(item => {
831
- arr.push(JSON.parse(item.innerText));
832
- });
833
- return arr;
834
- }
835
- if (debugMode) {
836
- renderDebugTips();
837
- // setRequestLoggingFunc(functionLogging)
838
- }
839
-
840
- if (debugModeUI) {
841
- console.log('debugModeUI Init');
842
- renderDebugUI();
843
- }
844
- function saveDebugImage({
845
- getDebugImageData,
846
- data,
847
- width,
848
- height,
849
- result,
850
- type
851
- }) {
852
- return __awaiter(this, void 0, void 0, function* () {
853
- if (!debugMode || !shouldGetDebugImage) return;
854
- const debugImage = yield getDebugImageData(data);
855
- // 創建一個虛擬的 canvas
856
- const canvas = document.createElement('canvas');
857
- const ctx = canvas.getContext('2d', {
858
- willReadFrequently: true
859
- });
860
- // 設置 canvas 的尺寸
861
- canvas.width = width;
862
- canvas.height = height;
863
- // 使用 Uint8ClampedArray 將圖像數據繪製到 canvas 上
864
- const imgData = ctx === null || ctx === void 0 ? void 0 : ctx.createImageData(width, height);
865
- if (imgData) {
866
- imgData.data.set(debugImage);
867
- ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imgData, 0, 0);
868
- canvas.toBlob(blob => {
869
- if (blob) {
870
- pushNewDebugImage(blob, {
871
- result: result,
872
- status: 'recognition',
873
- type: type
874
- }, {
875
- prefix: 'debugImage_'
876
- });
877
- }
878
- }, 'image/jpeg');
879
- }
880
- });
881
- }
882
- return {
883
- debugMode,
884
- debugModeUI,
885
- pushNewDebugLog,
886
- getDebugLogs: () => debugLogs,
887
- getDebugLogsLength: () => debugLogs.length,
888
- modifyDeubgLog: (index, logParams) => {
889
- if (!debugMode) return;
890
- debugLogs[index] = Object.assign(Object.assign({}, debugLogs[index]), logParams);
891
- },
892
- downloadDebugLogs: () => {
893
- if (!debugMode) return;
894
- saveFiles(`debugLog${new Date().getTime().toString()}`, {
895
- info: logInfo,
896
- logs: debugLogs,
897
- functionRunTime: functionRunTime()
898
- });
899
- },
900
- functionLogging,
901
- nextDebugRound: type => {
902
- if (!debugMode) return;
903
- currentRoundId = generateUniqueId(8);
904
- if (type) currentType = type;
905
- },
906
- modifyDebugType: type => {
907
- if (!debugMode) return;
908
- currentType = type;
909
- },
910
- pushNewDebugImage,
911
- setTimeDuration: setTimeDuration,
912
- saveDebugImage
913
- };
914
- }
915
-
916
- exports.TIME_UNIT = void 0;
917
- (function (TIME_UNIT) {
918
- TIME_UNIT[TIME_UNIT["SECOND"] = 1000] = "SECOND";
919
- TIME_UNIT[TIME_UNIT["MINUTE"] = 60000] = "MINUTE";
920
- TIME_UNIT[TIME_UNIT["HOUR"] = 3600000] = "HOUR";
921
- })(exports.TIME_UNIT || (exports.TIME_UNIT = {}));
922
-
923
- exports.DEVICE_TYPE = void 0;
924
- (function (DEVICE_TYPE) {
925
- DEVICE_TYPE["web"] = "web";
926
- DEVICE_TYPE["mobile"] = "mobile";
927
- DEVICE_TYPE["pad"] = "pad";
928
- })(exports.DEVICE_TYPE || (exports.DEVICE_TYPE = {}));
929
-
930
- function getImageData(canvas, ctx, video, sizeInfo, base64 = false, imageType = 'jpg') {
931
- canvas.width = sizeInfo.canvasWidth;
932
- canvas.height = sizeInfo.canvasHeight;
933
- ctx.drawImage(video, sizeInfo.startX, sizeInfo.startY, sizeInfo.width, sizeInfo.height, 0, 0, sizeInfo.canvasWidth, sizeInfo.canvasHeight);
934
- return {
935
- data: ctx.getImageData(0, 0, sizeInfo.canvasWidth, sizeInfo.canvasHeight).data,
936
- base64: base64 ? {
937
- jpg: imageType === 'jpg' || imageType === 'all' ? canvas.toDataURL('image/jpeg', 0.85) : '',
938
- png: imageType === 'png' || imageType === 'all' ? canvas.toDataURL('image/png') : ''
939
- } : {
940
- jpg: '',
941
- png: ''
942
- }
943
- };
944
- }
945
-
946
- function clearCanvas(canvas) {
947
- const ctx = canvas.getContext('2d', {
948
- willReadFrequently: true
949
- });
950
- ctx.clearRect(0, 0, canvas.width, canvas.height);
951
- }
952
-
953
- function resize(originWidth, originHeight, targetWidth, targetHeight) {
954
- const originRatio = originWidth / originHeight;
955
- const targetRatio = targetWidth / targetHeight;
956
- if (originRatio > targetRatio) {
957
- return {
958
- width: originHeight * targetRatio,
959
- height: originHeight,
960
- startX: (originWidth - originHeight * targetRatio) / 2,
961
- startY: 0
962
- };
963
- } else {
964
- return {
965
- width: originWidth,
966
- height: originWidth * targetRatio,
967
- startX: 0,
968
- startY: (originHeight - originWidth * targetRatio) / 2
969
- };
970
- }
971
- }
972
- function getCanvasSize(video) {
973
- return __awaiter(this, void 0, void 0, function* () {
974
- let videoWidth = video.videoWidth;
975
- let videoHeight = video.videoHeight;
976
- while (video.videoWidth === 0 || video.videoHeight === 0) {
977
- yield waitTime(200);
978
- videoWidth = video.videoWidth;
979
- videoHeight = video.videoHeight;
980
- }
981
- const result = {
982
- height: 0,
983
- width: 0,
984
- startX: 0,
985
- startY: 0,
986
- canvasWidth: 0,
987
- canvasHeight: 0
988
- };
989
- const windowWidth = window.innerWidth;
990
- const windowHeight = window.innerHeight;
991
- const videoRatio = videoWidth / videoHeight;
992
- const windowRatio = windowWidth / windowHeight;
993
- if (videoRatio > windowRatio) {
994
- result.height = videoHeight;
995
- result.width = Math.floor(videoHeight * windowRatio);
996
- result.startX = Math.floor((videoWidth - result.width) / 2);
997
- result.startY = 0;
998
- } else {
999
- result.width = videoWidth;
1000
- result.height = Math.floor(videoWidth / windowRatio);
1001
- result.startX = 0;
1002
- result.startY = Math.floor((videoHeight - result.height) / 2);
1003
- }
1004
- // const maxHeight = videoHeight > videoWidth ? 1280 : 720;
1005
- // const maxWidth = videoHeight > videoWidth ? 720 : 1280;
1006
- // const resizeRatioH = maxHeight / Math.max(result.height, maxHeight);
1007
- // const resizeRatioW = maxWidth / Math.max(result.width, maxWidth);
1008
- // const resizeRatio = Math.max(resizeRatioH, resizeRatioW);
1009
- // 暫時降低解析度測試
1010
- const maxDimension = 1920; // 限制最大尺寸
1011
- const resizeRatio = Math.min(1, maxDimension / Math.max(result.width, result.height));
1012
- result.canvasWidth = Math.floor(result.width * resizeRatio);
1013
- result.canvasHeight = Math.floor(result.height * resizeRatio);
1014
- return result;
1015
- });
1016
- }
1017
- function cropByRatio(width, height, ratio) {
1018
- let expectedHeight = height;
1019
- let expectedWidth = Math.floor(height * ratio);
1020
- if (expectedWidth > width) {
1021
- expectedWidth = width;
1022
- expectedHeight = Math.floor(width / ratio);
1023
- }
1024
- return {
1025
- width: expectedWidth,
1026
- height: expectedHeight
1027
- };
1028
- }
1029
-
1030
- const fontWeight = {
1031
- regular: '400',
1032
- medium: '500',
1033
- bold: '700'
1034
- };
1035
- const hexToRgba = (hex, alpha = 1) => {
1036
- // 移除 # 符號(如果有的話)
1037
- hex = hex.replace(/^#/, '');
1038
- // 解析短格式 (e.g., #RGB -> #RRGGBB)
1039
- if (hex.length === 3) {
1040
- hex = hex.split('').map(x => x + x).join('');
1041
- }
1042
- // 確保是有效的 HEX 格式
1043
- if (hex.length !== 6) {
1044
- throw new Error('Invalid HEX color.');
1045
- }
1046
- // 轉換 HEX 到 RGB
1047
- const r = parseInt(hex.substring(0, 2), 16);
1048
- const g = parseInt(hex.substring(2, 4), 16);
1049
- const b = parseInt(hex.substring(4, 6), 16);
1050
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
1051
- };
1052
- const uiThemeText = (dom, textStyle, distance) => {
1053
- dom.style.color = textStyle.textColor;
1054
- dom.style.fontWeight = fontWeight[textStyle.textWeight];
1055
- dom.style.fontSize = `${textStyle.fontSize}px`;
1056
- // Position parent element at the bottom by default
1057
- if (dom.parentElement) {
1058
- const parent = dom.parentElement;
1059
- parent.style.position = 'absolute';
1060
- parent.style.display = 'block';
1061
- parent.style.padding = '24px 32px';
1062
- // Adjust based on direction if provided
1063
- if (textStyle.direction === 'top') {
1064
- parent.style.top = distance || '5vh';
1065
- parent.style.bottom = 'unset';
1066
- } else if (textStyle.direction === 'bottom') {
1067
- parent.style.top = 'unset';
1068
- parent.style.bottom = distance || '5vh';
1069
- }
1070
- }
1071
- };
1072
- const uiThemeHint = (dom, hintStyle, distance) => {
1073
- dom.style.borderRadius = `${hintStyle.cornerRadius}px`;
1074
- dom.style.backgroundColor = hintStyle.backgroundColor;
1075
- dom.style.opacity = hintStyle.opacity;
1076
- dom.style.color = hintStyle.textColor;
1077
- dom.style.fontWeight = fontWeight[hintStyle.textWeight];
1078
- dom.style.fontSize = `${hintStyle.fontSize}px`;
1079
- // Position parent element at the top by default
1080
- if (dom.parentElement) {
1081
- const parent = dom.parentElement;
1082
- parent.style.display = 'block';
1083
- parent.style.position = 'absolute';
1084
- // Adjust based on direction if provided
1085
- if (hintStyle.direction === 'top') {
1086
- parent.style.top = distance || '5vh';
1087
- parent.style.bottom = 'unset';
1088
- } else {
1089
- parent.style.top = 'unset';
1090
- parent.style.bottom = distance || '5vh';
1091
- }
1092
- }
1093
- };
1094
- const uiThemeDirection = (panel, hintStyle) => {
1095
- // Apply background styles to the panel (directionTextPanel)
1096
- panel.style.borderRadius = `${hintStyle.cornerRadius || 20}px`;
1097
- panel.style.backgroundColor = hintStyle.backgroundColor;
1098
- panel.style.opacity = hintStyle.backgroundOpacity;
1099
- panel.style.flexDirection = 'row';
1100
- panel.style.alignItems = 'center';
1101
- panel.style.justifyContent = 'center';
1102
- panel.style.gap = '12px';
1103
- panel.style.padding = '16px 24px';
1104
- panel.style.boxSizing = 'border-box';
1105
- panel.style.minWidth = hintStyle.width;
1106
- panel.style.width = hintStyle.width;
1107
- panel.style.height = `${hintStyle.height || 'auto'}`;
1108
- // Style the text child
1109
- const directionText = panel.querySelector('.status-text');
1110
- if (directionText) {
1111
- directionText.style.color = hintStyle.textColor;
1112
- directionText.style.fontSize = `${hintStyle.fontSize}px`;
1113
- directionText.style.fontWeight = fontWeight[hintStyle.textWeight];
1114
- directionText.style.whiteSpace = 'nowrap';
1115
- directionText.style.display = 'inline-block';
1116
- directionText.style.verticalAlign = 'middle';
1117
- }
1118
- // Style the icon child
1119
- const directionIcon = panel.querySelector('.direction-icon');
1120
- if (directionIcon) {
1121
- directionIcon.style.display = 'flex';
1122
- directionIcon.style.alignItems = 'center';
1123
- directionIcon.style.justifyContent = 'center';
1124
- directionIcon.style.flexShrink = '0';
1125
- directionIcon.style.width = '72px';
1126
- directionIcon.style.height = '72px';
1127
- }
1128
- };
1129
- const uiThemeButton = (dom, buttonStyle, disabled) => {
1130
- dom.style.opacity = buttonStyle.backgroundOpacity;
1131
- if (disabled) {
1132
- dom.style.color = buttonStyle.disabledTextColor;
1133
- dom.style.borderRadius = `100px`;
1134
- dom.style.backgroundColor = buttonStyle.disabledBackgroundColor;
1135
- dom.style.borderColor = hexToRgba(buttonStyle.disabledBorderColor, buttonStyle.borderOpacity);
1136
- } else {
1137
- dom.style.color = buttonStyle.textColor;
1138
- dom.style.borderRadius = `100px`;
1139
- dom.style.backgroundColor = buttonStyle.backgroundColor;
1140
- dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1141
- }
1142
- dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1143
- dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1144
- dom.style.fontSize = `${buttonStyle.fontSize}px`;
1145
- dom.style.borderStyle = 'solid';
1146
- // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1147
- dom.style.height = `48px`;
1148
- dom.style.maxWidth = `774px`;
1149
- dom.style.width = `100%`;
1150
- };
1151
- const uiThemeSmallButton = (dom, buttonStyle) => {
1152
- dom.style.borderRadius = `${buttonStyle.cornerRadius}px`;
1153
- dom.style.backgroundColor = buttonStyle.backgroundColor;
1154
- dom.style.opacity = buttonStyle.backgroundOpacity;
1155
- dom.style.color = buttonStyle.textColor;
1156
- dom.style.borderColor = hexToRgba(buttonStyle.borderColor, buttonStyle.borderOpacity);
1157
- dom.style.borderWidth = `${buttonStyle.borderWidth}px`;
1158
- dom.style.fontWeight = fontWeight[buttonStyle.textWeight];
1159
- dom.style.fontSize = `${buttonStyle.fontSize}px`;
1160
- dom.style.borderStyle = 'solid';
1161
- // dom.style.height = `${buttonStyle.cornerRadius * 2}px`;
1162
- dom.style.height = `30px`;
1163
- dom.style.width = `calc(100% - ${buttonStyle.cornerRadius * 2}px)`;
1164
- dom.style.maxWidth = `106px`;
1165
- };
1166
-
1167
- function startSpinner(args) {
1168
- const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
1169
- const themeConfig = Storage.getItem('themeConfig');
1170
- const body = document.querySelector('.authme-container');
1171
- //Statement
1172
- const statementContainer = document.createElement('div');
1173
- statementContainer.classList.add('statement');
1174
- uiThemeText(statementContainer, themeConfig.bodyThreeDarkMode);
1175
- statementContainer.textContent = args.statement || '';
1176
- if (loadingLottie) {
1177
- const loadingSDKOuter = document.createElement('div');
1178
- const loadingSDKContent = document.createElement('div');
1179
- const loadingSDKText = document.createElement('div');
1180
- loadingSDKOuter.classList.add('authme-loading-sdk-outer');
1181
- loadingSDKContent.classList.add('authme-loading-sdk-content');
1182
- loadingSDKOuter.appendChild(loadingSDKContent);
1183
- Lottie__default["default"].loadAnimation({
1184
- container: loadingSDKContent,
1185
- renderer: 'svg',
1186
- loop: true,
1187
- autoplay: true,
1188
- name: 'spinner-loading',
1189
- animationData: loadingLottie
1190
- });
1191
- body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
1192
- if (args.text) {
1193
- loadingSDKText.classList.add('authme-loading-sdk-text');
1194
- loadingSDKText.textContent = args.text;
1195
- loadingSDKText.style.color = themeConfig.titleTwo.textColor;
1196
- loadingSDKText.style.fontWeight = themeConfig.titleTwo.textWeight;
1197
- loadingSDKText.style.fontSize = `${themeConfig.titleTwo.fontSize}px`;
1198
- loadingSDKContent.appendChild(loadingSDKText);
1199
- }
1200
- if (args.backgroundOpaque) {
1201
- loadingSDKOuter.classList.add('loading-outer--opaque');
1202
- }
1203
- if (args.backgroundOpaque) {
1204
- loadingSDKOuter.classList.add('authme-loading-sdk-outer--opaque');
1205
- }
1206
- return;
1207
- }
1208
- const spinnerOuter = document.createElement('div');
1209
- const spinner = document.createElement('div');
1210
- const spinnerText = document.createElement('div');
1211
- spinnerOuter.appendChild(spinner);
1212
- spinnerOuter.className = 'loading-outer';
1213
- spinner.className = 'loading';
1214
- // spinner.style.borderRightColor = themeConfig.loadingViewContentColor;
1215
- // spinner.style.borderBottomColor = themeConfig.loadingViewContentColor;
1216
- // spinner.style.borderLeftColor = themeConfig.loadingViewContentColor;
1217
- spinner.style.backgroundImage = `linear-gradient(to bottom right, white, white),
1218
- linear-gradient(to bottom right, ${themeConfig.loadingViewContentColor}, #fff)`;
1219
- spinner.style.borderColor = `transparent`;
1220
- spinner.style.mask = `linear-gradient(white, white)`;
1221
- spinner.style.backgroundClip = `padding-box, border-box`;
1222
- spinner.style.backgroundOrigin = `padding-box, border-box`;
1223
- if (args.text) {
1224
- spinnerText.className = 'loading-text';
1225
- spinnerText.textContent = args.text;
1226
- uiThemeText(spinnerText, themeConfig.titleTwo);
1227
- spinnerOuter.appendChild(spinnerText);
1228
- }
1229
- if (args.backgroundOpaque) {
1230
- spinnerOuter.classList.add('loading-outer--opaque');
1231
- }
1232
- if (themeConfig.isStatementEnabled) {
1233
- spinnerOuter.appendChild(statementContainer);
1234
- }
1235
- body === null || body === void 0 ? void 0 : body.appendChild(spinnerOuter);
1236
- }
1237
- function stopSpinner() {
1238
- const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
1239
- const body = document.querySelector('.authme-container');
1240
- if (loadingLottie) {
1241
- Lottie__default["default"].destroy('spinner-loading');
1242
- }
1243
- const spinner = loadingLottie ? document.querySelector('.authme-loading-sdk-outer') : document.querySelector('.loading-outer');
1244
- if (spinner) {
1245
- body === null || body === void 0 ? void 0 : body.removeChild(spinner);
1246
- }
1247
- }
1248
-
1249
- exports.Icon = void 0;
1250
- (function (Icon) {
1251
- Icon["CloseIcon"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAALdSURBVHgBzZm/bhpBEMY/TINEgxuUEjoKpNDhzrhLid8geQDkuAopUM6ioYstXoA2lUmXVJy7hMoukOhyaWlCCqS4y3znPXJcuD97rOF+0rCnu13p0+zO7O6QQ0ra7XZLmobYqWpLyshSzFH2IGaPx2MbKcjpdBZRFHAh9tYnJimOmC12JWKdpIMSCVTCPihhJhghodB8XAcRR4+NxVowB5dEu1ar/Z7P5/dRHSMFiriP0lhiBZiHs0KRJRH5NaxTLkQYB9/CrNeioBfPZMqXwQ9HIQNs7E8c4ZTfbvvw3xSraW1j/1S2TfeGQBH3WpoBDseJCpxv3ov1GhRxFWkmYhUcFq7Dqrce/WvQwuHFES/nurgeVN77gWxxTC96HrSQPdxdyxN4Cg3K5TL6/b7bmuwbgDsY8upUorXHdrtd1Ot1NJtNTKdTrFYrRImrVquuTSYTaFCQiL6jB1vQZDgcYrFYRHrH/419OSYFjbyopPdqOqPoMXqOHqSAoCeD4nq9ntum4JEC38nDC2gSJrJYLJoSRwo5WYO/oH/4XBP0lvfOgDjippnU4ohfCIUZFEdKR8g4FLjEDgSnOC66NVnuJHBbtPqn24BIh1F8Bs00EyaObVwK0uQ7BTLFvNIZFZfnDIr8xCm+1x3V6XRiozUY3RyTAjsvp1dH7SaJb26z2czdWweDQWQq8TzJvtzqND3oyHHr0jsPWvAdEjPCSAS+8fLgNbLHFX9cger8f4PsMPLKIsE7yU5J2xAOlPfI+topwfJHguURminnGbj0l+o27sW8j4rIY3k8wWG4EXEb9/Kw2gzP5i3slwcR1wi+DDvNnCNFAt8BGyEOiSxgiieZfi7wvHBaQy9tkfVBWZNfZE3+xL8atEmYMd6LOCuqU2yFlRVQEflZHhk8DZiBOfc8SWFdt4hewVO+5EW/Aj28zeB6W6EyDC2BftSFn/YST2Jp/r8haAy0O7Zp/4b4C0A7bruoqtIMAAAAAElFTkSuQmCC";
1252
- Icon["PictureIcon"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAt9SURBVHgB7VxdTFRJFq7q23/Q0NC6IKDGhrgiG4mSGAejmyDoToxri5F1ZV9Gk0lWn8CnyY4Pgw9rsk+LT2M2k+juw+KOGBU3cUYjsoljNDFRA1llZwNNEJVGpIFu+v/W1mmmtar63u6G/pHu7e9Fq/rem3s/vlPnVNU5hVAeeeSRx/8vMPqImGntLEWFfisKBZs0RNpAELIiRLaFfyTwfwYY2RHBTvqDE2P8VMahMYQ1Ty2XLwygj4iMExgmzbBwHMuaQ4tk4VKUPAYo+X9FEhqghNpRBpERAnnSUBNKL8JkWq5cuIQygLQSCMRp9N4OQkhnipS2FNgxRpdkDSUzjapMC4FLIS4gYcecVjM0p5NG3DrJMaXXOFxajftHc8Eke93P5zxrioKyqcwvl6/yBasLg6EaU4BU6wgpR7ERJrLk2wtnURqQcgJnjp1swjK6GOUEGFCChqaM2odDJYZHIlFLxcZ5b3ndvH9Lpdu/lxK8JcaldoLl05Zv/3IdpRApI3BRdb6vFlUXjRDG7skCbV9/RXGfw6B1ozQAyNw95W4v9sv1asrEmHTL/oKzluvdTpQCpIRAqjorVd09JdVlgjgR5b6g6ZcOV0uVO2BTIdJOJLQnFWNj0gSGTTZErimNdVMFur7vK4t7YhFXWVlpqqurq1m7dm11aWlpjclkqtZqtSadTsd9eCAQcPh8Pgf91z09PT04MTEx2t/fP4hiIKLIVb5QS/Sv2ElkdMJy9eukTDopAmd/+/sOIuNusT+AsePJ6sLz98tMih8IpG3fvr1+8+bNtoKCgmpJkkxoGQiFQu65ubkhSubDK1eu3FW7DojcPzF/TkmNRINPW/7xdTdaJpZN4OzRk3S8Q11ifyzVAXEHDhywVVVV2ZZLmhpAoZTMwdu3b19+8eJFlGMCs/709Vx7mSdoE3+jXrpruV56WQSqKW+0SP/NtfWlfWJ/OolTwvj4eM/9+/f7lYg8NjbTXrUQaBf7l6vEJRM4c+RUK9bAmMfjP2bj+X+uNUeZ0aFDhz7ZunVrZyaIYwGKHB4e7lEy7V9PzLVsmvN2iP3UovZYepc2t14SgWFvGyJPRIdxb42p88kq0wjbB6prbW1tr6iosKGPiDdv3vRdv3695/Xr19yQ0vDOXbNn0i0ojjoWiTQsxTsnTCDEeVjvfSKGKkrKo161nJL3pdForEErAKDG3t7eM6JJqyjRTgLGhkTjRA1KEBAki+S9KtT1KJF35MiRcyuFPACERG1tbX+kXn8N2w/vPkbHbeFyq0bv+QolCCmRi2aOnmqlAwQnd/C2f7da/sb2RcgTY7iVABiDKYGNDofj0du3b9+b8/MS4/BGt89kCsq1H67GjV/8Yvu//vTvx/Z4z01IgRiRP7NtiPMgVGH7VjJ5Eagp8ftKcw98E9tHQ5uL4WW4OIhLIMR7oul+V1V0ho3zwGGsdPIigHc8fPjwH+CdI33wLRD4C5dakd7bGe95MQkEr0sXJ4+zfe8M0l1xBQW8bTaQFwGMz/DObB/MmqbonJ3twwR3xFNhTAI1MvqMVR/I/IefFV5mrzl69Gjzxw5VlgN454MHDzayfWDKsPjxoYeUxlNhTAJF9b006fpY9cG4t2nTpt+hLEVDQ0OHaMqTS1ShKoEzvzl5PEp95SVcyLJr166WbDJdEeCZ9+/fz1kPLLtFqdDgO672DFUCaYT9Gdue12sGHYYPDwb1rV+/vh1lOdatW2eLq0KZHFK7X5FAcB5I2D0Tx759+/ZlPXkANRUKlzWpmbGyAkM8ebCHIXpes9lcj3IESipc0Er8WqaKGSsSKJrvq0I9N/aB583msU8EqHDHjh3chtSkUXrEttXMWG0MbGIbw8W6IbZN/2KNKMdQW1vLmfFgqfEhfwXepmTGUQTCHgfbBu8rmm9RUVHOmG8EEFyzZvzfYqODn96RxTweAdEKJPI2tunVYW6dr7m5uT7Ti6OZAHwTbG6xfRB5cBeFSJN4XzSBssbKPUQrjbJt2D1DOQrx22Z1/LcjmVjFe6IIpA5kK9ueNug4BZaVlcXa/c9q0MiCUyCkmgiXWMV7FJwIv1w/bdBwD6FSL0I5CkqglW1P6bX8EpcgLkA0gZhwBM5LeIFtGwyGnAlfRIjimNdhV7x7FJwIL1PRA+dS/CdC/DbwxMIlVvGehPdE8lBGnsAkkScwSSg4EWRnm5AZyrZhjxXlKMRvg6Qk4RK7eE9cBRaHSCHbhowolKOA9Dm2XRwgQshGojbbleLAp2xrtU/m/goul2sE5SioOLiwpcwfFBSI4xNICBlj20WBIGfCTqdzFOUopqamuFUnSGZn23SP6Jl4T7QCNbKdbZYGQtz0BjJDUY5C/DZqwvy8X4Pt4j0KiwnaAbZZ5Ocz358/fz6Si+MgfJOYMmwM8uKhqzFPxfuiCQzo7exgCWmxrCeGNDGv15tz4yAd2znyNs4HysWUYKXcwSgCF9O6eEeyZdb3CdumKryJcgzj4+PcEn7dvEdcdRpQuk8xjCEa+QbbXuMNcQQ+fvx4MJfMGOI/MZO10uXfy7bDxYwKUI4DfYWX2GZhMFRf7iPvV6HBjF++fNmHcgSzs7NR5lsUEqqepCUo8KfsTO6G5jdObtPl1q1bfbmiwjt37nB73rsdLnHPW7WMVnUmEmXGnqAtF1U4NjbWw6b+QjlEcSDIbZqpmS9AfSoXNuMP3lgixKSkwmyeG8O7P3jwoJ/t2/XG1SJ4X3us2mNVAsGMCcZc0qGSCp89e/YNylJAGQSrPhj71nkCnEgIUVcfIPZigt/YLarwVxNObny4efPmQyglQFkGeGfR88LYJ6oPadGlWM+JSaCSCst9AdvuKTc3RkAdBl3JyJrgGkwX3pntA/Wt8ge4okRQX7yakfgLqqBCYY2wYXqhQzTla9euncuG8TBSM8IW3sC37J9wnhMutdOZR1e858UlMKxCGZ1g+0DmoinT2Ynj6tWrX65kEtUKbj6dmBFNFxEZn07kmQnViUC9xBd12y0Yo/dJRaaQXFvhDbhflBiHI31Qf0GXhB7W1tY2rrT0DzXyjtln2iu8wTa2jwrmvOXqhYQKDxPfEwkZu0RTrnb5P4dyKbZvJSoRFj8US73G51qqPFGVm/bwtyaIFBUbFnc+WVWQZcWGnpo9k/OCyoiTSDg9xYYRzLSdbKKmfE/sVyt3hWRMyOTP9IY8TDNpjNp948aNR+JvoLxNLoVyVxkfXuoRAMsquJ5pO9WJMV/+BXhVoOu5bLX0iP2QkL5z586WDRs2pD2vGoiDKSbMkkTVAQ6POW3VC/7PxX5C8GlLbwYKriOgSuyiSoyqanQYdH2315b2sBn9EQCRe/fubS8pKalPtSLjEQehCnjbMl90yT+N984mErIoIalDJ9SUCJmd31WVnPnRrFc9VAdMu6qqaqfZbN6SzKETHo9nlDqHPlijVCIOAIE/xK6Kh04sU3kRJH/sSfgIAPmi0rEn7/S6uz+UmS7HIhIAWa+Q3Lh69WpQpgkywJSOPQHC6NL7KN0ZHIENINifUSMNEEt1YYdB6JjXm9zxeWk/eAfUCCViUOWkZNbpABDX/NppW+MN2mD+rnDJyjl4J4JwBrvk7cIa1KH0OxA5r9MOJqLI5SIB4sJBMsR5K+roJxZhk5bouBjr8DFJM/TKpL87XGwcSpZM2DGETa8yT7Axahmeh506ixPJmqyItJ0fGPbSGr5cVgmgTI+kGXXpNSPvDNpRSKt1aZHK8XfIBOkWpkCo3OwL1ZiD8pb4x9+Fx7rzKGjsTpXqWKT3AEaouQui44kQmXqkl7gIMnaGKpTP/lRC1oTSi4Hwfg7dkkgncRFkjMAIwqoMoabUkUnCiQCZJI1FxgkUAXNrJMnboMBnsYyAxpNQKaB0DHIY5Ck1zbFwEpRMBlDAZM80aXnkkUceeSzif3+l5taU5LriAAAAAElFTkSuQmCC";
1253
- })(exports.Icon || (exports.Icon = {}));
1254
-
1255
- function showErrorMessage(text, showRetryBtn, callback, buttonText, _titleText) {
1256
- return __awaiter(this, void 0, void 0, function* () {
1257
- const target = document.querySelector('.authme-container');
1258
- if (!target) {
1259
- return;
1260
- }
1261
- const uiThemeConfig = Storage.getItem('themeConfig');
1262
- const errorMessagePanel = document.createElement('div');
1263
- errorMessagePanel.className = 'error-message-panel';
1264
- const icon = document.createElement('img');
1265
- icon.className = 'error-icon';
1266
- icon.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIoSURBVHgBrZY9TxRBGMdn5XwpOCRyJlZoI8HTShNfGkqNEs8GrO4z2HqFwQr9DpYWaGKuUKOJL5XxMxATTSBCAwcFHITjLcPvYf9HNhd2doF7kt/uZud5mdmZ+c9GLsW89xG3q/AURqAMJbD3DfgDX+EbTEdR5F1eI/kw1KHpY2vBAszCfz3vqM183sGVvMnHYUnBczAJt2EACnAaLsE9mJCPV9FqVvIabAkLLuboUFGdWFNcLc2xKodFGNUc5B11BE8UaznGOh0uq9F6UXHHNHVsE5bhWrL6e33HybSe875HEz8F51z6SF4qV30/F5cbWglzoW9OWz/MiP6AXx/MK+fQKd49gF54w1puuhMaOVa5vVXOcSvwEHbhh+uefYRNGLECw7AMM6579g9sJGUrcBFaKtItW4ENKFmB/BqS36I2BS5LYMvuvAuPYh1+wxk9h2xAORu2rL5LzO5kBLX3QuYOl06ZGP60T/QLzkIlI8iW3Wf4xPOFjBr3oQe+WOBQYqP1BQrc0g7dhpsBv+RGu97e3nUFTwSkoheewYuAj+V6rVxTB34mTD4+A0wJR90xTYq6prNhsLNxTEpoqlrxR5frxwm5rqY5PpfDOrwKzUkipigF3VIHa1kBVQ3Ra+JtXu76+JgsiJIta3ViXr4N33nQBIoM+vggbx/6OypqB/6snltqa2qRlA/LFQWKWJsFmZw/crEomm6ZtNhvy7SL99AH+Jv227IHljuhn5g7LqwAAAAASUVORK5CYII=';
1267
- const errorText = document.createElement('div');
1268
- errorText.className = 'error-text';
1269
- errorText.textContent = text;
1270
- uiThemeText(errorText, uiThemeConfig.hint);
1271
- errorMessagePanel.appendChild(icon);
1272
- errorMessagePanel.appendChild(errorText);
1273
- if (showRetryBtn) {
1274
- const retryText = document.createElement('div');
1275
- retryText.className = 'retry-text';
1276
- retryText.textContent = buttonText !== null && buttonText !== void 0 ? buttonText : '重試';
1277
- uiThemeButton(retryText, uiThemeConfig.minorButton);
1278
- errorMessagePanel.appendChild(retryText);
1279
- if (callback) {
1280
- retryText.addEventListener('click', e => {
1281
- callback(e, {
1282
- hideErrorMessage
1283
- });
1284
- });
1285
- }
1286
- }
1287
- target === null || target === void 0 ? void 0 : target.appendChild(errorMessagePanel);
1288
- });
1289
- }
1290
- function showErrorMessageEventName(text, showRetryBtn, callback, buttonText, titleText) {
1291
- return __awaiter(this, void 0, void 0, function* () {
1292
- const target = document.querySelector('.authme-container');
1293
- if (!target) {
1294
- return;
1295
- }
1296
- const uiThemeConfig = Storage.getItem('themeConfig');
1297
- const errorMessagePanel = document.createElement('div');
1298
- errorMessagePanel.classList.add('error-message-panel');
1299
- errorMessagePanel.classList.add('event-name');
1300
- const errorText = document.createElement('div');
1301
- errorText.className = 'error-text';
1302
- errorText.textContent = text;
1303
- uiThemeText(errorText, uiThemeConfig.bodyOne);
1304
- const title = document.createElement('div');
1305
- title.className = 'error-title';
1306
- title.textContent = titleText !== null && titleText !== void 0 ? titleText : 'error';
1307
- errorMessagePanel.appendChild(title);
1308
- errorMessagePanel.appendChild(errorText);
1309
- if (showRetryBtn) {
1310
- const retryText = document.createElement('div');
1311
- retryText.className = 'retry-text';
1312
- retryText.textContent = buttonText !== null && buttonText !== void 0 ? buttonText : '重試';
1313
- uiThemeButton(retryText, uiThemeConfig.majorButton);
1314
- errorMessagePanel.appendChild(retryText);
1315
- if (callback) {
1316
- retryText.addEventListener('click', e => {
1317
- target.removeChild(errorMessagePanel);
1318
- callback(e);
1319
- });
1320
- }
1321
- }
1322
- target === null || target === void 0 ? void 0 : target.appendChild(errorMessagePanel);
1323
- });
1324
- }
1325
- function hideErrorMessage() {
1326
- const body = document.querySelector('.authme-container');
1327
- const errorMessagePanel = document.querySelector('.error-message-panel');
1328
- if (body && errorMessagePanel) {
1329
- body === null || body === void 0 ? void 0 : body.removeChild(errorMessagePanel);
1330
- }
1331
- }
1332
- function asyncShowErrorMessage(text, showRetryBtn, options) {
1333
- var _a;
1334
- return __awaiter(this, void 0, void 0, function* () {
1335
- const _showErrorMessage = (_a = options === null || options === void 0 ? void 0 : options.showErrorMessageHandler) !== null && _a !== void 0 ? _a : showErrorMessage;
1336
- return new Promise((res, rej) => {
1337
- var _a;
1338
- const callback = () => {
1339
- res(true);
1340
- hideErrorMessage();
1341
- };
1342
- _showErrorMessage(text, showRetryBtn, (_a = options === null || options === void 0 ? void 0 : options.callback) !== null && _a !== void 0 ? _a : callback, options === null || options === void 0 ? void 0 : options.buttonText, options === null || options === void 0 ? void 0 : options.titleText);
1343
- });
1344
- });
1345
- }
1346
- function asyncOnLineShowErrorMessage(text, buttonText, showRetryBtn) {
1347
- return __awaiter(this, void 0, void 0, function* () {
1348
- return new Promise((res, rej) => {
1349
- showErrorMessage(text, showRetryBtn, (_, tools) => {
1350
- if (window.navigator.onLine) {
1351
- res(true);
1352
- tools === null || tools === void 0 ? void 0 : tools.hideErrorMessage();
1353
- }
1354
- }, buttonText);
1355
- });
1356
- });
1357
- }
1358
- function checkOnlineStatus(msg, buttonText) {
1359
- return __awaiter(this, void 0, void 0, function* () {
1360
- if (!window.navigator.onLine) {
1361
- yield asyncOnLineShowErrorMessage(msg, buttonText, true);
1362
- }
1363
- });
1364
- }
1365
-
1366
- function showPopup(title, content, showButton = true, buttonText, callback) {
1367
- return __awaiter(this, void 0, void 0, function* () {
1368
- const target = document.querySelector('.authme-container');
1369
- const popupBackground = document.createElement('div');
1370
- popupBackground.className = 'popup-background';
1371
- const popupPanel = document.createElement('div');
1372
- popupPanel.className = 'popup-panel';
1373
- const popupTitle = document.createElement('div');
1374
- popupTitle.className = 'popup-title';
1375
- popupTitle.textContent = title;
1376
- const popupContent = document.createElement('div');
1377
- popupContent.className = 'popup-content';
1378
- popupContent.textContent = content;
1379
- const popupConfirmBtn = document.createElement('button');
1380
- popupConfirmBtn.className = 'popup-btn';
1381
- popupConfirmBtn.textContent = buttonText || '確定';
1382
- popupPanel.appendChild(popupTitle);
1383
- popupPanel.appendChild(popupContent);
1384
- if (showButton) {
1385
- popupPanel.appendChild(popupConfirmBtn);
1386
- }
1387
- if (callback && showButton) {
1388
- popupConfirmBtn.addEventListener('click', callback);
1389
- }
1390
- target === null || target === void 0 ? void 0 : target.appendChild(popupPanel);
1391
- target === null || target === void 0 ? void 0 : target.appendChild(popupBackground);
1392
- });
1393
- }
1394
- function hidePopup() {
1395
- const popupPanel = document.querySelector('.popup-panel');
1396
- if (popupPanel) {
1397
- popupPanel.remove();
1398
- }
1399
- const popupBackground = document.querySelector('.popup-background');
1400
- if (popupBackground) {
1401
- popupBackground.remove();
1402
- }
1403
- }
1404
- function asyncShowPopup(title, content, showButton = true, buttonText) {
1405
- return __awaiter(this, void 0, void 0, function* () {
1406
- return new Promise((res, rej) => {
1407
- const callback = () => {
1408
- res(true);
1409
- hidePopup();
1410
- };
1411
- showPopup(title, content, showButton, buttonText, callback);
1412
- });
1413
- });
1414
- }
1415
-
1416
- var BROWSER_CAMERA_ERRORS;
1417
- (function (BROWSER_CAMERA_ERRORS) {
1418
- BROWSER_CAMERA_ERRORS["NOT_SUPPORT"] = "NOT_SUPPORT";
1419
- BROWSER_CAMERA_ERRORS["NO_CAMERA"] = "NO_CAMERA";
1420
- BROWSER_CAMERA_ERRORS["NOT_ALLOWED_ERROR"] = "NotAllowedError";
1421
- BROWSER_CAMERA_ERRORS["NOT_FOUND_ERROR"] = "NotFoundError";
1422
- BROWSER_CAMERA_ERRORS["NOT_READABLE_ERROR"] = "NotReadableError";
1423
- BROWSER_CAMERA_ERRORS["ABORT_ERROR"] = "AbortError";
1424
- BROWSER_CAMERA_ERRORS["LOW_RESOLUTION"] = "LowResolutionError";
1425
- })(BROWSER_CAMERA_ERRORS || (BROWSER_CAMERA_ERRORS = {}));
1426
- let stream;
1427
- const videoConstraintsFactory = (isPC, facingMode) => {
1428
- return isPC ? {
1429
- video: {
1430
- width: {
1431
- min: 1280,
1432
- ideal: 1920
1433
- },
1434
- height: {
1435
- min: 720,
1436
- ideal: 1080
1437
- },
1438
- facingMode
1439
- }
1440
- } : {
1441
- video: {
1442
- width: {
1443
- ideal: 1920
1444
- },
1445
- height: {
1446
- ideal: 1080
1447
- },
1448
- facingMode
1449
- }
1450
- };
1451
- };
1452
- function inferFacingModeFromLabel(label) {
1453
- const pattern = /rear|back|rück|arrière|trasera|trás|traseira|posteriore|后|後|背|задней|الخلفية|후|arka|achterzijde|หลัง|baksidan|bagside|sau|bak|tylny|takakamera|belakang|אחורית|πίσω|spate|hátsó|zadní|darrere|zadná|задня|stražnja|belakang|बैक/i;
1454
- if (pattern.test(label !== null && label !== void 0 ? label : '')) {
1455
- return 'back';
1456
- } else {
1457
- return undefined;
1458
- }
1459
- }
1460
- function inferFacingModeFromCapabilities(capabilities) {
1461
- var _a, _b, _c, _d;
1462
- if (((_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.facingMode) === null || _a === void 0 ? void 0 : _a.indexOf('user')) !== null && _b !== void 0 ? _b : -1) >= 0) {
1463
- return 'front';
1464
- } else if (((_d = (_c = capabilities === null || capabilities === void 0 ? void 0 : capabilities.facingMode) === null || _c === void 0 ? void 0 : _c.indexOf('environment')) !== null && _d !== void 0 ? _d : -1) >= 0) {
1465
- return 'back';
1466
- } else {
1467
- return undefined;
1468
- }
1469
- }
1470
- function inferFacingModeFromMixedInfo(fromLabel, fromCapabilities) {
1471
- var _a;
1472
- return (_a = fromLabel !== null && fromLabel !== void 0 ? fromLabel : fromCapabilities) !== null && _a !== void 0 ? _a : 'front';
1473
- }
1474
- function asyncMap(mapping, items) {
1475
- return __asyncGenerator(this, arguments, function* asyncMap_1() {
1476
- for (const item of items) {
1477
- yield yield __await(yield __await(mapping(item)));
1478
- }
1479
- });
1480
- }
1481
- function arrayFromAsync(asyncIterable) {
1482
- var asyncIterable_1, asyncIterable_1_1;
1483
- var e_1, _a;
1484
- return __awaiter(this, void 0, void 0, function* () {
1485
- const result = [];
1486
- try {
1487
- for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {
1488
- const item = asyncIterable_1_1.value;
1489
- result.push(item);
1490
- }
1491
- } catch (e_1_1) {
1492
- e_1 = {
1493
- error: e_1_1
1494
- };
1495
- } finally {
1496
- try {
1497
- if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);
1498
- } finally {
1499
- if (e_1) throw e_1.error;
1500
- }
1501
- }
1502
- return result;
1503
- });
1504
- }
1505
- function upgradeResolution(videoTrack) {
1506
- var _a;
1507
- return __awaiter(this, void 0, void 0, function* () {
1508
- const targetConstraints = {
1509
- width: {
1510
- ideal: 1920,
1511
- max: 3840
1512
- },
1513
- height: {
1514
- ideal: 1080,
1515
- max: 2160
1516
- }
1517
- };
1518
- const minAcceptableWidth = 1280; // 最低可接受的解析度寬度
1519
- const maxAttempts = 15; // 最多嘗試10次
1520
- const retryDelay = 2000; // 每次重試間隔1秒
1521
- console.log('🚀 開始提升解析度...');
1522
- const startTime = Date.now();
1523
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1524
- try {
1525
- yield videoTrack.applyConstraints(targetConstraints);
1526
- const settings = videoTrack.getSettings();
1527
- const currentWidth = (_a = settings.width) !== null && _a !== void 0 ? _a : 0;
1528
- console.log(`嘗試 ${attempt}/${maxAttempts} - 解析度: ${currentWidth}x${settings.height}`);
1529
- // 檢查是否達到可接受的解析度
1530
- if (currentWidth >= minAcceptableWidth) {
1531
- const elapsedTime = Date.now() - startTime;
1532
- console.log(`✅ 解析度提升成功!最終: ${currentWidth}x${settings.height} (耗時: ${elapsedTime}ms)`);
1533
- return; // 成功,退出
1534
- }
1535
- // 解析度還不夠,繼續重試
1536
- console.log(`⚠️ 解析度 ${currentWidth} < ${minAcceptableWidth},繼續重試...`);
1537
- } catch (e) {
1538
- console.warn(`⚠️ 第 ${attempt} 次嘗試失敗:`, e);
1539
- }
1540
- // 如果不是最後一次嘗試,等待後重試
1541
- if (attempt < maxAttempts) {
1542
- yield new Promise(resolve => setTimeout(resolve, retryDelay));
1543
- }
1544
- }
1545
- // 所有嘗試都失敗
1546
- const finalSettings = videoTrack.getSettings();
1547
- console.warn(`⚠️ 達到最大重試次數,使用當前解析度: ${finalSettings.width}x${finalSettings.height}`);
1548
- });
1549
- }
1550
- function switchCamera(deviceId, video, translate) {
1551
- var _a, _b;
1552
- return __awaiter(this, void 0, void 0, function* () {
1553
- const startTime = performance.now();
1554
- try {
1555
- if (stream) {
1556
- stream.getTracks().forEach(track => track.stop());
1557
- }
1558
- // 第一階段:使用基本約束獲取流,確保相機能工作
1559
- const basicConstraints = {
1560
- video: {
1561
- deviceId: deviceId,
1562
- focusMode: 'auto'
1563
- }
1564
- };
1565
- const constraint = localStorage.getItem('camera_constraint');
1566
- stream = yield navigator.mediaDevices.getUserMedia(basicConstraints);
1567
- if (!constraint && stream) {
1568
- const videoTrack = stream.getVideoTracks()[0];
1569
- yield upgradeResolution(videoTrack); // ✅ 加上 await 等待解析度提升完成
1570
- // 🆕 記錄最終解析度資訊
1571
- const finalSettings = videoTrack.getSettings();
1572
- const initTime = (performance.now() - startTime).toFixed(2);
1573
- console.log('📹 Camera初始化完成', {
1574
- deviceId,
1575
- deviceLabel: videoTrack.label,
1576
- resolution: `${finalSettings.width}x${finalSettings.height}`,
1577
- frameRate: finalSettings.frameRate,
1578
- facingMode: finalSettings.facingMode,
1579
- initTime: `${initTime}ms`
1580
- });
1581
- }
1582
- // 檢查最終解析度是否達到最低要求
1583
- const currentTrack = stream.getVideoTracks()[0];
1584
- if (currentTrack) {
1585
- const currentSettings = currentTrack.getSettings();
1586
- const minRequiredWidth = 1280;
1587
- if (currentSettings.width && currentSettings.width < minRequiredWidth) {
1588
- console.error('❌ Camera解析度不足', {
1589
- current: `${currentSettings.width}x${currentSettings.height}`,
1590
- required: `${minRequiredWidth}px minimum width`,
1591
- deviceId
1592
- });
1593
- // 關閉當前相機流
1594
- stream.getTracks().forEach(track => track.stop());
1595
- // 顯示彈窗並等待用戶點擊
1596
- if (translate) {
1597
- yield asyncShowPopup('相機解析度不足', '相機解析度不足,請重新嘗試或更換裝置', true, '重新嘗試');
1598
- }
1599
- throw BROWSER_CAMERA_ERRORS.LOW_RESOLUTION;
1600
- }
1601
- }
1602
- // try {
1603
- // stream = await navigator.mediaDevices.getUserMedia(constraints);
1604
- // console.log("獲取媒體流成功:", stream);
1605
- // } catch (error) {
1606
- // console.error("獲取媒體流失敗:", error);
1607
- // }
1608
- if (stream.getVideoTracks().length === 0) {
1609
- throw new Error('沒有 video track');
1610
- }
1611
- try {
1612
- video.srcObject = stream;
1613
- } catch (error) {
1614
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1615
- }
1616
- try {
1617
- yield video.play();
1618
- } catch (error) {
1619
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1620
- }
1621
- // console.log('stream', stream.getVideoTracks()[0].getSettings());
1622
- // console.log('constraints', navigator.mediaDevices.getSupportedConstraints());
1623
- // const videoTracks = stream.getVideoTracks();
1624
- // console.log("視訊軌道:", videoTracks.length, videoTracks);
1625
- // const videoTrack = stream.getVideoTracks()[0];
1626
- // if (videoTrack) {
1627
- // console.log("視訊軌道啟用狀態:", videoTrack.enabled);
1628
- // console.log("視訊軌道活躍狀態:", videoTrack.readyState);
1629
- // console.log("視訊軌道設置:", videoTrack.getSettings());
1630
- // console.log("視訊軌道約束:", videoTrack.getConstraints());
1631
- // }
1632
- stream.getTracks().forEach(track => {
1633
- // track.onended = () => console.log("軌道結束:", track.kind);
1634
- // track.onmute = () => console.log("軌道靜音:", track.kind);
1635
- // track.onunmute = () => console.log("軌道取消靜音:", track.kind);
1636
- });
1637
- // const isStreamActive = stream.active;
1638
- // console.log("流是否活躍:", isStreamActive);
1639
- // Note: Fix Safari 15 video not showing bug
1640
- video.srcObject = null;
1641
- setTimeout(() => {
1642
- video.srcObject = stream;
1643
- }, 10);
1644
- } catch (e) {
1645
- // 如果是低解析度錯誤,直接拋出不包裝,讓外層處理重試
1646
- if (e === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
1647
- throw e;
1648
- }
1649
- // 🆕 增強錯誤日誌
1650
- const initTime = (performance.now() - startTime).toFixed(2);
1651
- console.error('❌ Camera切換失敗', {
1652
- deviceId,
1653
- error: e,
1654
- errorName: e === null || e === void 0 ? void 0 : e.name,
1655
- errorMessage: e === null || e === void 0 ? void 0 : e.message,
1656
- initTime: `${initTime}ms`,
1657
- streamExists: !!stream,
1658
- trackCount: (_b = (_a = stream === null || stream === void 0 ? void 0 : stream.getTracks()) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0
1659
- });
1660
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, e);
1661
- }
1662
- });
1663
- }
1664
- function _requestCamera(video, facingMode, translate) {
1665
- var _a, _b, _c, _d, _e, _f;
1666
- return __awaiter(this, void 0, void 0, function* () {
1667
- const requestStartTime = performance.now();
1668
- console.log('🎬 開始camera請求流程', {
1669
- facingMode
1670
- });
1671
- if (!('mediaDevices' in navigator)) {
1672
- throw BROWSER_CAMERA_ERRORS.NOT_SUPPORT;
1673
- }
1674
- let isSamsung = false;
1675
- if (navigator.userAgent.match(/SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|G|N|P|T|Z|S]|SHV-E|SCH-[I|J|R|S]|SPH-L/i)) {
1676
- isSamsung = true;
1677
- }
1678
- // 必須先請求攝影機權限,才能透過 enumerateDevices 取得攝影機 Label 資訊
1679
- const media = yield navigator.mediaDevices.getUserMedia({
1680
- video: true
1681
- });
1682
- const videoTrack = media.getVideoTracks()[0];
1683
- // console.log('使用的攝影機:', videoTrack);
1684
- // console.log('使用的攝影機:', videoTrack.label);
1685
- const currentCamersDeviceId = videoTrack.id;
1686
- // console.log('使用的攝影機:', currentCamersDeviceId);
1687
- media.getTracks().forEach(function (track) {
1688
- track.stop(); // 取得後會啟用攝影機,所以要關閉
1689
- });
1690
- // 輪詢取得攝影機 解析度等資訊
1691
- const videoDevices = (yield navigator.mediaDevices.enumerateDevices()).filter(device => device.kind === 'videoinput');
1692
- const deviceMetas = yield arrayFromAsync(asyncMap(device => __awaiter(this, void 0, void 0, function* () {
1693
- var _g, _h, _j, _k;
1694
- const stream = yield navigator.mediaDevices.getUserMedia({
1695
- video: {
1696
- deviceId: {
1697
- exact: device.deviceId
1698
- }
1699
- }
1700
- });
1701
- const track = (_g = stream.getVideoTracks()) === null || _g === void 0 ? void 0 : _g[0];
1702
- const capabilities = ((_h = track === null || track === void 0 ? void 0 : track.getCapabilities) !== null && _h !== void 0 ? _h : () => undefined).bind(track)(); // firefox 沒有 getCapabilities 可以用。
1703
- const widthMax = (_j = capabilities === null || capabilities === void 0 ? void 0 : capabilities.width) === null || _j === void 0 ? void 0 : _j.max;
1704
- const heightMax = (_k = capabilities === null || capabilities === void 0 ? void 0 : capabilities.height) === null || _k === void 0 ? void 0 : _k.max;
1705
- const resolution = widthMax && heightMax ? widthMax * heightMax : 0;
1706
- const facingModeFromLabel = inferFacingModeFromLabel(device === null || device === void 0 ? void 0 : device.label);
1707
- const facingModeFromapabilities = inferFacingModeFromCapabilities(capabilities);
1708
- const facingMode = inferFacingModeFromMixedInfo(facingModeFromLabel, facingModeFromapabilities);
1709
- const meta = {
1710
- resolution,
1711
- facingMode,
1712
- facingModeFromLabel,
1713
- facingModeFromapabilities,
1714
- capabilities
1715
- };
1716
- track === null || track === void 0 ? void 0 : track.stop();
1717
- return {
1718
- device,
1719
- meta,
1720
- capabilities
1721
- };
1722
- }), videoDevices));
1723
- const devices = deviceMetas.sort((a, b) => {
1724
- // 若是 Samsung 手機且模式為後鏡頭,則優先使用Label為 camera2 0 的鏡頭
1725
- let samsungCondition = 0;
1726
- if (isSamsung && facingMode === 'back') {
1727
- const samsungCamera = 'camera2 0';
1728
- const bScore = b.device.label.includes(samsungCamera) ? 1 : 0; // 特定鏡頭優先
1729
- const aScore = a.device.label.includes(samsungCamera) ? 1 : 0;
1730
- samsungCondition = bScore - aScore;
1731
- }
1732
- let cameraFacingCondition = 0;
1733
- {
1734
- const aFacingMode = a.meta.facingMode;
1735
- const bFacingMode = b.meta.facingMode;
1736
- const bScore = bFacingMode === facingMode ? 1 : 0; // 鏡頭符合 faceMode 優先。
1737
- const aScore = aFacingMode === facingMode ? 1 : 0;
1738
- cameraFacingCondition = bScore - aScore;
1739
- }
1740
- const resolutionCondition = b.meta.resolution - a.meta.resolution;
1741
- return samsungCondition || cameraFacingCondition || resolutionCondition;
1742
- });
1743
- const cameraIndex = window.localStorage.getItem('camera') || '0';
1744
- const firstDevice = devices[parseInt(cameraIndex, 10)];
1745
- let deviceId = firstDevice.device.deviceId;
1746
- // 判斷是不是只有前鏡頭(電腦環境)
1747
- let frontCameraCount = 0;
1748
- devices.forEach(device => {
1749
- if (device.meta.facingMode === 'front') {
1750
- frontCameraCount++;
1751
- }
1752
- });
1753
- if (frontCameraCount === devices.length) {
1754
- deviceId = currentCamersDeviceId; // currentCamersDeviceId 是瀏覽器當前使用的攝影機
1755
- }
1756
-
1757
- if (!deviceId) {
1758
- throw BROWSER_CAMERA_ERRORS.NO_CAMERA;
1759
- }
1760
- if (stream) {
1761
- stream.getTracks().forEach(track => track.stop());
1762
- }
1763
- // 嘗試開啟相機,如果解析度不足會持續重試
1764
- let retryCount = 0;
1765
- const MAX_RETRIES = 12;
1766
- while (retryCount < MAX_RETRIES) {
1767
- try {
1768
- yield switchCamera(deviceId, video, translate);
1769
- break; // 成功就跳出循環
1770
- } catch (error) {
1771
- if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
1772
- retryCount++;
1773
- if (retryCount >= MAX_RETRIES) {
1774
- console.error(`❌ 達到最大重試次數 (${MAX_RETRIES}),相機解析度持續不足`);
1775
- throw error;
1776
- }
1777
- console.log(`🔄 解析度不足,第 ${retryCount} 次重試...`);
1778
- // 等待一下再重試
1779
- yield new Promise(resolve => setTimeout(resolve, 500));
1780
- } else {
1781
- throw error; // 其他錯誤直接拋出
1782
- }
1783
- }
1784
- }
1785
- // 🆕 記錄整個請求流程的總結資訊
1786
- const totalTime = (performance.now() - requestStartTime).toFixed(2);
1787
- console.log('🎉 Camera請求流程完成', {
1788
- totalTime: `${totalTime}ms`,
1789
- selectedDevice: {
1790
- deviceId,
1791
- label: firstDevice.device.label,
1792
- facingMode: firstDevice.meta.facingMode,
1793
- resolution: `${(_c = (_b = (_a = firstDevice.meta.capabilities) === null || _a === void 0 ? void 0 : _a.width) === null || _b === void 0 ? void 0 : _b.max) !== null && _c !== void 0 ? _c : 0}x${(_f = (_e = (_d = firstDevice.meta.capabilities) === null || _d === void 0 ? void 0 : _d.height) === null || _e === void 0 ? void 0 : _e.max) !== null && _f !== void 0 ? _f : 0}`
1794
- },
1795
- availableDevices: deviceMetas.length,
1796
- isSamsung
1797
- });
1798
- return {
1799
- facingMode: firstDevice.meta.facingMode,
1800
- deviceMetas: deviceMetas
1801
- };
1802
- });
1803
- }
1804
- function isOverconstrainedError(error) {
1805
- if (error === null || typeof error === 'undefined') {
1806
- return false;
1807
- }
1808
- if (typeof error !== 'object') {
1809
- return false;
1810
- }
1811
- return 'constraint' in error;
1812
- }
1813
- function sleep(ms) {
1814
- return new Promise(resolve => setTimeout(resolve, ms));
1815
- }
1816
- function requestCamera({
1817
- video,
1818
- facingMode,
1819
- translate,
1820
- showMessage
1821
- }) {
1822
- return __awaiter(this, void 0, void 0, function* () {
1823
- try {
1824
- let perm = yield navigator.permissions.query({
1825
- name: 'camera'
1826
- });
1827
- if (perm.state == 'prompt') {
1828
- for (let i = 0; i < 5; ++i) {
1829
- try {
1830
- //for ios 17.4.1 hack, if you call getUserMedia too early will only get not allowed.
1831
- yield sleep(1000);
1832
- return yield _requestCamera(video, facingMode, translate);
1833
- } catch (error) {
1834
- if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR) {
1835
- perm = yield navigator.permissions.query({
1836
- name: 'camera'
1837
- });
1838
- } else {
1839
- throw error;
1840
- }
1841
- }
1842
- }
1843
- return yield _requestCamera(video, facingMode, translate);
1844
- } else {
1845
- return yield _requestCamera(video, facingMode, translate);
1846
- }
1847
- } catch (error) {
1848
- if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
1849
- showMessage(translate('sdk.general.error.cameraNotFound.title'));
1850
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'Browser not support WebRTC, or https required.');
1851
- }
1852
- if (error === BROWSER_CAMERA_ERRORS.NO_CAMERA) {
1853
- showMessage(translate('sdk.general.error.cameraNotFound.content'));
1854
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'camera not found');
1855
- }
1856
- if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_FOUND_ERROR) {
1857
- showMessage(translate('sdk.general.error.cameraNotFound.content'));
1858
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1859
- }
1860
- if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_READABLE_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.ABORT_ERROR) {
1861
- showMessage(translate('sdk.general.error.cameraNotFound.content'));
1862
- /* NOT_READABLE_ERROR,ABORT_ERROR 這兩個錯誤是用戶授權了,但在呼叫裝置時出現錯誤,
1863
- * 常發生在APP webview ,例如: 手機開啟 web 使用 sdk,儘管在 webview 層級上授權了,但手機在設定層級沒有授權 app 使用相機,會導致此問題。
1864
- * 但每個 android 手機的在這方面的實作不一致,不是每個手機在這種情況下都會拋出錯誤。
1865
- * 參考 https://developer.mozilla.org/zh-CN/docs/Web/API/MediaDevices/getUserMedia#notreadableerror
1866
- */
1867
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1868
- }
1869
- if (error === BROWSER_CAMERA_ERRORS.LOW_RESOLUTION) {
1870
- // 顯示彈窗並等待用戶點擊後重新載入
1871
- yield asyncShowPopup(translate('sdk.general.error.cameraLowResolution'), translate('sdk.general.error.cameraLowResolution') + ',請重新嘗試或更換裝置', true);
1872
- // 用戶點擊確定後,重新載入頁面
1873
- globalThis.location.reload();
1874
- // 不會執行到這裡,因為頁面已重新載入
1875
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1876
- }
1877
- if (isOverconstrainedError(error)) {
1878
- showMessage(translate('sdk.general.error.cameraLowResolution'));
1879
- throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
1880
- }
1881
- throw error;
1882
- }
1883
- });
1884
- }
1885
-
1886
- function showElement(element) {
1887
- element.classList.remove('hide');
1888
- element.classList.add('show');
1889
- }
1890
- function hideElement(element) {
1891
- element.classList.remove('show');
1892
- element.classList.add('hide');
1893
- }
1894
-
1895
- const sdk_loading = () => ({
1896
- nm: 'Waiting',
1897
- mn: '',
1898
- layers: [{
1899
- ty: 4,
1900
- nm: '3',
1901
- mn: '',
1902
- sr: 1,
1903
- st: 38,
1904
- op: 938,
1905
- ip: -20,
1906
- hd: false,
1907
- cl: '',
1908
- ln: '',
1909
- ddd: 0,
1910
- bm: 0,
1911
- tt: 0,
1912
- hasMask: false,
1913
- td: 0,
1914
- ao: 0,
1915
- ks: {
1916
- a: {
1917
- a: 0,
1918
- k: [113, -41.653, 0],
1919
- ix: 1
1920
- },
1921
- s: {
1922
- a: 0,
1923
- k: [100, 100, 100],
1924
- ix: 6
1925
- },
1926
- sk: {
1927
- a: 0,
1928
- k: 0
1929
- },
1930
- p: {
1931
- a: 1,
1932
- k: [{
1933
- o: {
1934
- x: 0.167,
1935
- y: 0
1936
- },
1937
- i: {
1938
- x: 0.29,
1939
- y: 1
1940
- },
1941
- s: [250, 100.847, 0],
1942
- t: 20.251
1943
- }, {
1944
- o: {
1945
- x: 0.167,
1946
- y: 0
1947
- },
1948
- i: {
1949
- x: 0.29,
1950
- y: 1
1951
- },
1952
- s: [250, 53.847, 0],
1953
- t: 29.715
1954
- }, {
1955
- o: {
1956
- x: 0.167,
1957
- y: 0
1958
- },
1959
- i: {
1960
- x: 0.29,
1961
- y: 1
1962
- },
1963
- s: [250, 66.885, 0],
1964
- t: 41.702
1965
- }, {
1966
- o: {
1967
- x: 0.167,
1968
- y: 0.167
1969
- },
1970
- i: {
1971
- x: 0.833,
1972
- y: 0.833
1973
- },
1974
- s: [250, 100.847, 0],
1975
- t: 46.75
1976
- }],
1977
- ix: 2
1978
- },
1979
- sa: {
1980
- a: 0,
1981
- k: 0
1982
- },
1983
- o: {
1984
- a: 0,
1985
- k: 100,
1986
- ix: 11
1987
- },
1988
- r: {
1989
- a: 0,
1990
- k: 0,
1991
- ix: 10
1992
- }
1993
- },
1994
- ef: [],
1995
- shapes: [{
1996
- ty: 'gr',
1997
- bm: 0,
1998
- cl: '',
1999
- ln: '',
2000
- hd: false,
2001
- mn: 'ADBE Vector Group',
2002
- nm: 'Group 1',
2003
- ix: 1,
2004
- cix: 2,
2005
- np: 3,
2006
- it: [{
2007
- ty: 'sh',
2008
- bm: 0,
2009
- cl: '',
2010
- ln: '',
2011
- hd: false,
2012
- mn: 'ADBE Vector Shape - Group',
2013
- nm: 'Path 1',
2014
- ix: 1,
2015
- d: 1,
2016
- ks: {
2017
- a: 1,
2018
- k: [{
2019
- o: {
2020
- x: 0.167,
2021
- y: 0
2022
- },
2023
- i: {
2024
- x: 0.29,
2025
- y: 1
2026
- },
2027
- s: [{
2028
- c: true,
2029
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2030
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2031
- v: [[114.22, -40.406], [114.188, -40.373], [114.22, -40.34], [114.253, -40.373]]
2032
- }],
2033
- t: 27.2
2034
- }, {
2035
- o: {
2036
- x: 0.167,
2037
- y: 0
2038
- },
2039
- i: {
2040
- x: 0.29,
2041
- y: 1
2042
- },
2043
- s: [{
2044
- c: true,
2045
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2046
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2047
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2048
- }],
2049
- t: 34
2050
- }, {
2051
- o: {
2052
- x: 0.167,
2053
- y: 0
2054
- },
2055
- i: {
2056
- x: 0.29,
2057
- y: 1
2058
- },
2059
- s: [{
2060
- c: true,
2061
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2062
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2063
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2064
- }],
2065
- t: 46.75
2066
- }, {
2067
- o: {
2068
- x: 0.167,
2069
- y: 0.167
2070
- },
2071
- i: {
2072
- x: 0.833,
2073
- y: 0.833
2074
- },
2075
- s: [{
2076
- c: true,
2077
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2078
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2079
- v: [[114.22, -40.406], [114.188, -40.373], [114.22, -40.34], [114.253, -40.373]]
2080
- }],
2081
- t: 59.5
2082
- }],
2083
- ix: 2
2084
- }
2085
- }, {
2086
- ty: 'sh',
2087
- bm: 0,
2088
- cl: '',
2089
- ln: '',
2090
- hd: false,
2091
- mn: 'ADBE Vector Shape - Group',
2092
- nm: 'Path 2',
2093
- ix: 2,
2094
- d: 1,
2095
- ks: {
2096
- a: 0,
2097
- k: {
2098
- c: true,
2099
- i: [[18.404, 0], [0, 18.404], [-18.404, 0], [0, -18.404]],
2100
- o: [[-18.404, 0], [0, -18.404], [18.404, 0], [0, 18.404]],
2101
- v: [[113, -8.276], [79.623, -41.653], [113, -75.029], [146.377, -41.653]]
2102
- },
2103
- ix: 2
2104
- }
2105
- }, {
2106
- ty: 'fl',
2107
- bm: 0,
2108
- cl: '',
2109
- ln: '',
2110
- hd: false,
2111
- mn: 'ADBE Vector Graphic - Fill',
2112
- nm: 'Fill 1',
2113
- c: {
2114
- a: 0,
2115
- k: [0, 0.7569, 0.7137],
2116
- ix: 4
2117
- },
2118
- r: 1,
2119
- o: {
2120
- a: 0,
2121
- k: 100,
2122
- ix: 5
2123
- }
2124
- }, {
2125
- ty: 'tr',
2126
- a: {
2127
- a: 0,
2128
- k: [0, 0],
2129
- ix: 1
2130
- },
2131
- s: {
2132
- a: 0,
2133
- k: [100, 100],
2134
- ix: 3
2135
- },
2136
- sk: {
2137
- a: 0,
2138
- k: 0,
2139
- ix: 4
2140
- },
2141
- p: {
2142
- a: 0,
2143
- k: [0, 0],
2144
- ix: 2
2145
- },
2146
- r: {
2147
- a: 0,
2148
- k: 0,
2149
- ix: 6
2150
- },
2151
- sa: {
2152
- a: 0,
2153
- k: 0,
2154
- ix: 5
2155
- },
2156
- o: {
2157
- a: 0,
2158
- k: 100,
2159
- ix: 7
2160
- }
2161
- }]
2162
- }],
2163
- ind: 0
2164
- }, {
2165
- ty: 4,
2166
- nm: '2',
2167
- mn: '',
2168
- sr: 1,
2169
- st: 19,
2170
- op: 919,
2171
- ip: -9,
2172
- hd: false,
2173
- cl: '',
2174
- ln: '',
2175
- ddd: 0,
2176
- bm: 0,
2177
- tt: 0,
2178
- hasMask: false,
2179
- td: 0,
2180
- ao: 0,
2181
- ks: {
2182
- a: {
2183
- a: 0,
2184
- k: [113, -41.653, 0],
2185
- ix: 1
2186
- },
2187
- s: {
2188
- a: 0,
2189
- k: [100, 100, 100],
2190
- ix: 6
2191
- },
2192
- sk: {
2193
- a: 0,
2194
- k: 0
2195
- },
2196
- p: {
2197
- a: 1,
2198
- k: [{
2199
- o: {
2200
- x: 0.167,
2201
- y: 0
2202
- },
2203
- i: {
2204
- x: 0.29,
2205
- y: 1
2206
- },
2207
- s: [150, 100.847, 0],
2208
- t: 10.673
2209
- }, {
2210
- o: {
2211
- x: 0.167,
2212
- y: 0
2213
- },
2214
- i: {
2215
- x: 0.29,
2216
- y: 1
2217
- },
2218
- s: [150, 53.847, 0],
2219
- t: 20.137
2220
- }, {
2221
- o: {
2222
- x: 0.167,
2223
- y: 0
2224
- },
2225
- i: {
2226
- x: 0.29,
2227
- y: 1
2228
- },
2229
- s: [150, 66.885, 0],
2230
- t: 32.125
2231
- }, {
2232
- o: {
2233
- x: 0.167,
2234
- y: 0.167
2235
- },
2236
- i: {
2237
- x: 0.833,
2238
- y: 0.833
2239
- },
2240
- s: [150, 100.847, 0],
2241
- t: 37.1728515625
2242
- }],
2243
- ix: 2
2244
- },
2245
- sa: {
2246
- a: 0,
2247
- k: 0
2248
- },
2249
- o: {
2250
- a: 0,
2251
- k: 100,
2252
- ix: 11
2253
- },
2254
- r: {
2255
- a: 0,
2256
- k: 0,
2257
- ix: 10
2258
- }
2259
- },
2260
- ef: [],
2261
- shapes: [{
2262
- ty: 'gr',
2263
- bm: 0,
2264
- cl: '',
2265
- ln: '',
2266
- hd: false,
2267
- mn: 'ADBE Vector Group',
2268
- nm: 'Group 1',
2269
- ix: 1,
2270
- cix: 2,
2271
- np: 3,
2272
- it: [{
2273
- ty: 'sh',
2274
- bm: 0,
2275
- cl: '',
2276
- ln: '',
2277
- hd: false,
2278
- mn: 'ADBE Vector Shape - Group',
2279
- nm: 'Path 1',
2280
- ix: 1,
2281
- d: 1,
2282
- ks: {
2283
- a: 1,
2284
- k: [{
2285
- o: {
2286
- x: 0.167,
2287
- y: 0
2288
- },
2289
- i: {
2290
- x: 0.29,
2291
- y: 1
2292
- },
2293
- s: [{
2294
- c: true,
2295
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2296
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2297
- v: [[114.22, -40.406], [114.188, -40.373], [114.22, -40.34], [114.253, -40.373]]
2298
- }],
2299
- t: 17.85
2300
- }, {
2301
- o: {
2302
- x: 0.167,
2303
- y: 0
2304
- },
2305
- i: {
2306
- x: 0.29,
2307
- y: 1
2308
- },
2309
- s: [{
2310
- c: true,
2311
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2312
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2313
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2314
- }],
2315
- t: 25.5
2316
- }, {
2317
- o: {
2318
- x: 0.167,
2319
- y: 0
2320
- },
2321
- i: {
2322
- x: 0.29,
2323
- y: 1
2324
- },
2325
- s: [{
2326
- c: true,
2327
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2328
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2329
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2330
- }],
2331
- t: 28.949
2332
- }, {
2333
- o: {
2334
- x: 0.167,
2335
- y: 0
2336
- },
2337
- i: {
2338
- x: 0.29,
2339
- y: 1
2340
- },
2341
- s: [{
2342
- c: true,
2343
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2344
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2345
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2346
- }],
2347
- t: 35.005
2348
- }, {
2349
- o: {
2350
- x: 0.167,
2351
- y: 0
2352
- },
2353
- i: {
2354
- x: 0.29,
2355
- y: 1
2356
- },
2357
- s: [{
2358
- c: true,
2359
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2360
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2361
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2362
- }],
2363
- t: 46.75
2364
- }, {
2365
- o: {
2366
- x: 0.167,
2367
- y: 0
2368
- },
2369
- i: {
2370
- x: 0.29,
2371
- y: 1
2372
- },
2373
- s: [{
2374
- c: true,
2375
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2376
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2377
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2378
- }],
2379
- t: 59.5
2380
- }, {
2381
- o: {
2382
- x: 0.167,
2383
- y: 0.167
2384
- },
2385
- i: {
2386
- x: 0.833,
2387
- y: 0.833
2388
- },
2389
- s: [{
2390
- c: true,
2391
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2392
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2393
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2394
- }],
2395
- t: 72.25
2396
- }],
2397
- ix: 2
2398
- }
2399
- }, {
2400
- ty: 'sh',
2401
- bm: 0,
2402
- cl: '',
2403
- ln: '',
2404
- hd: false,
2405
- mn: 'ADBE Vector Shape - Group',
2406
- nm: 'Path 2',
2407
- ix: 2,
2408
- d: 1,
2409
- ks: {
2410
- a: 0,
2411
- k: {
2412
- c: true,
2413
- i: [[18.404, 0], [0, 18.404], [-18.404, 0], [0, -18.404]],
2414
- o: [[-18.404, 0], [0, -18.404], [18.404, 0], [0, 18.404]],
2415
- v: [[113, -8.276], [79.623, -41.653], [113, -75.029], [146.377, -41.653]]
2416
- },
2417
- ix: 2
2418
- }
2419
- }, {
2420
- ty: 'fl',
2421
- bm: 0,
2422
- cl: '',
2423
- ln: '',
2424
- hd: false,
2425
- mn: 'ADBE Vector Graphic - Fill',
2426
- nm: 'Fill 1',
2427
- c: {
2428
- a: 0,
2429
- k: [0, 0.7569, 0.7137],
2430
- ix: 4
2431
- },
2432
- r: 1,
2433
- o: {
2434
- a: 0,
2435
- k: 100,
2436
- ix: 5
2437
- }
2438
- }, {
2439
- ty: 'tr',
2440
- a: {
2441
- a: 0,
2442
- k: [0, 0],
2443
- ix: 1
2444
- },
2445
- s: {
2446
- a: 0,
2447
- k: [100, 100],
2448
- ix: 3
2449
- },
2450
- sk: {
2451
- a: 0,
2452
- k: 0,
2453
- ix: 4
2454
- },
2455
- p: {
2456
- a: 0,
2457
- k: [0, 0],
2458
- ix: 2
2459
- },
2460
- r: {
2461
- a: 0,
2462
- k: 0,
2463
- ix: 6
2464
- },
2465
- sa: {
2466
- a: 0,
2467
- k: 0,
2468
- ix: 5
2469
- },
2470
- o: {
2471
- a: 0,
2472
- k: 100,
2473
- ix: 7
2474
- }
2475
- }]
2476
- }],
2477
- ind: 1
2478
- }, {
2479
- ty: 4,
2480
- nm: '1',
2481
- mn: '',
2482
- sr: 1,
2483
- st: 0,
2484
- op: 900,
2485
- ip: 0,
2486
- hd: false,
2487
- cl: '',
2488
- ln: '',
2489
- ddd: 0,
2490
- bm: 0,
2491
- tt: 0,
2492
- hasMask: false,
2493
- td: 0,
2494
- ao: 0,
2495
- ks: {
2496
- a: {
2497
- a: 0,
2498
- k: [113, -41.653, 0],
2499
- ix: 1
2500
- },
2501
- s: {
2502
- a: 0,
2503
- k: [100, 100, 100],
2504
- ix: 6
2505
- },
2506
- sk: {
2507
- a: 0,
2508
- k: 0
2509
- },
2510
- p: {
2511
- a: 1,
2512
- k: [{
2513
- o: {
2514
- x: 0.167,
2515
- y: 0
2516
- },
2517
- i: {
2518
- x: 0.29,
2519
- y: 1
2520
- },
2521
- s: [46.5, 100.847, 0],
2522
- t: 0
2523
- }, {
2524
- o: {
2525
- x: 0.167,
2526
- y: 0
2527
- },
2528
- i: {
2529
- x: 0.29,
2530
- y: 1
2531
- },
2532
- s: [46.5, 53.847, 0],
2533
- t: 9.464
2534
- }, {
2535
- o: {
2536
- x: 0.167,
2537
- y: 0
2538
- },
2539
- i: {
2540
- x: 0.29,
2541
- y: 1
2542
- },
2543
- s: [46.5, 66.885, 0],
2544
- t: 21.452
2545
- }, {
2546
- o: {
2547
- x: 0.167,
2548
- y: 0.167
2549
- },
2550
- i: {
2551
- x: 0.833,
2552
- y: 0.833
2553
- },
2554
- s: [46.5, 100.847, 0],
2555
- t: 26.4990234375
2556
- }],
2557
- ix: 2
2558
- },
2559
- sa: {
2560
- a: 0,
2561
- k: 0
2562
- },
2563
- o: {
2564
- a: 0,
2565
- k: 100,
2566
- ix: 11
2567
- },
2568
- r: {
2569
- a: 0,
2570
- k: 0,
2571
- ix: 10
2572
- }
2573
- },
2574
- ef: [],
2575
- shapes: [{
2576
- ty: 'gr',
2577
- bm: 0,
2578
- cl: '',
2579
- ln: '',
2580
- hd: false,
2581
- mn: 'ADBE Vector Group',
2582
- nm: 'Group 1',
2583
- ix: 1,
2584
- cix: 2,
2585
- np: 3,
2586
- it: [{
2587
- ty: 'sh',
2588
- bm: 0,
2589
- cl: '',
2590
- ln: '',
2591
- hd: false,
2592
- mn: 'ADBE Vector Shape - Group',
2593
- nm: 'Path 1',
2594
- ix: 1,
2595
- d: 1,
2596
- ks: {
2597
- a: 1,
2598
- k: [{
2599
- o: {
2600
- x: 0.167,
2601
- y: 0
2602
- },
2603
- i: {
2604
- x: 0.29,
2605
- y: 1
2606
- },
2607
- s: [{
2608
- c: true,
2609
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2610
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2611
- v: [[114.22, -40.406], [114.188, -40.373], [114.22, -40.34], [114.253, -40.373]]
2612
- }],
2613
- t: 6.8
2614
- }, {
2615
- o: {
2616
- x: 0.167,
2617
- y: 0
2618
- },
2619
- i: {
2620
- x: 0.29,
2621
- y: 1
2622
- },
2623
- s: [{
2624
- c: true,
2625
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2626
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2627
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2628
- }],
2629
- t: 13.6
2630
- }, {
2631
- o: {
2632
- x: 0.167,
2633
- y: 0
2634
- },
2635
- i: {
2636
- x: 0.29,
2637
- y: 1
2638
- },
2639
- s: [{
2640
- c: true,
2641
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2642
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2643
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2644
- }],
2645
- t: 17.899
2646
- }, {
2647
- o: {
2648
- x: 0.167,
2649
- y: 0
2650
- },
2651
- i: {
2652
- x: 0.29,
2653
- y: 1
2654
- },
2655
- s: [{
2656
- c: true,
2657
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2658
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2659
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2660
- }],
2661
- t: 23.954
2662
- }, {
2663
- o: {
2664
- x: 0.167,
2665
- y: 0
2666
- },
2667
- i: {
2668
- x: 0.29,
2669
- y: 1
2670
- },
2671
- s: [{
2672
- c: true,
2673
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2674
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2675
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2676
- }],
2677
- t: 59.5
2678
- }, {
2679
- o: {
2680
- x: 0.167,
2681
- y: 0
2682
- },
2683
- i: {
2684
- x: 0.29,
2685
- y: 1
2686
- },
2687
- s: [{
2688
- c: true,
2689
- i: [[12.339, 0], [0, -12.338], [-12.339, 0], [0, 12.339]],
2690
- o: [[-12.339, 0], [0, 12.339], [12.339, 0], [0, -12.338]],
2691
- v: [[113, -64.029], [90.623, -41.653], [113, -19.276], [135.377, -41.653]]
2692
- }],
2693
- t: 72.25
2694
- }, {
2695
- o: {
2696
- x: 0.167,
2697
- y: 0.167
2698
- },
2699
- i: {
2700
- x: 0.833,
2701
- y: 0.833
2702
- },
2703
- s: [{
2704
- c: true,
2705
- i: [[0.018, 0], [0, -0.018], [-0.018, 0], [0, 0.018]],
2706
- o: [[-0.018, 0], [0, 0.018], [0.018, 0], [0, -0.018]],
2707
- v: [[111.72, -40.406], [111.688, -40.373], [111.72, -40.34], [111.753, -40.373]]
2708
- }],
2709
- t: 85
2710
- }],
2711
- ix: 2
2712
- }
2713
- }, {
2714
- ty: 'sh',
2715
- bm: 0,
2716
- cl: '',
2717
- ln: '',
2718
- hd: false,
2719
- mn: 'ADBE Vector Shape - Group',
2720
- nm: 'Path 2',
2721
- ix: 2,
2722
- d: 1,
2723
- ks: {
2724
- a: 0,
2725
- k: {
2726
- c: true,
2727
- i: [[18.404, 0], [0, 18.404], [-18.404, 0], [0, -18.404]],
2728
- o: [[-18.404, 0], [0, -18.404], [18.404, 0], [0, 18.404]],
2729
- v: [[113, -8.276], [79.623, -41.653], [113, -75.029], [146.377, -41.653]]
2730
- },
2731
- ix: 2
2732
- }
2733
- }, {
2734
- ty: 'fl',
2735
- bm: 0,
2736
- cl: '',
2737
- ln: '',
2738
- hd: false,
2739
- mn: 'ADBE Vector Graphic - Fill',
2740
- nm: 'Fill 1',
2741
- c: {
2742
- a: 0,
2743
- k: [0, 0.7569, 0.7137],
2744
- ix: 4
2745
- },
2746
- r: 1,
2747
- o: {
2748
- a: 0,
2749
- k: 100,
2750
- ix: 5
2751
- }
2752
- }, {
2753
- ty: 'tr',
2754
- a: {
2755
- a: 0,
2756
- k: [0, 0],
2757
- ix: 1
2758
- },
2759
- s: {
2760
- a: 0,
2761
- k: [100, 100],
2762
- ix: 3
2763
- },
2764
- sk: {
2765
- a: 0,
2766
- k: 0,
2767
- ix: 4
2768
- },
2769
- p: {
2770
- a: 0,
2771
- k: [0, 0],
2772
- ix: 2
2773
- },
2774
- r: {
2775
- a: 0,
2776
- k: 0,
2777
- ix: 6
2778
- },
2779
- sa: {
2780
- a: 0,
2781
- k: 0,
2782
- ix: 5
2783
- },
2784
- o: {
2785
- a: 0,
2786
- k: 100,
2787
- ix: 7
2788
- }
2789
- }]
2790
- }],
2791
- ind: 2
2792
- }],
2793
- ddd: 0,
2794
- h: 200,
2795
- w: 300,
2796
- meta: {
2797
- a: '',
2798
- k: '',
2799
- d: '',
2800
- g: 'LottieFiles AE 1.0.0',
2801
- tc: '#ffffff'
2802
- },
2803
- v: '4.8.0',
2804
- fr: 30,
2805
- op: 86,
2806
- ip: 0,
2807
- assets: []
2808
- });
2809
-
2810
- function startLoadingSDK(text) {
2811
- const loadingLottie = Storage.getItem(exports.STORAGE_KEY.LOADING_LOTTIE);
2812
- const body = document.body;
2813
- const loadingSDKOuter = document.createElement('div');
2814
- const loadingSDKContent = document.createElement('div');
2815
- loadingSDKOuter.classList.add('authme-loading-sdk-outer');
2816
- loadingSDKContent.classList.add('authme-loading-sdk-content');
2817
- loadingSDKOuter.appendChild(loadingSDKContent);
2818
- Lottie__default["default"].loadAnimation({
2819
- container: loadingSDKContent,
2820
- renderer: 'svg',
2821
- loop: true,
2822
- autoplay: true,
2823
- name: 'init-sdk-loading',
2824
- animationData: loadingLottie ? loadingLottie : sdk_loading()
2825
- });
2826
- body === null || body === void 0 ? void 0 : body.appendChild(loadingSDKOuter);
2827
- }
2828
- function stopLoadingSDK() {
2829
- const body = document.body;
2830
- const loadingSDKOuter = document.querySelector('.authme-loading-sdk-outer');
2831
- Lottie__default["default"].destroy('init-sdk-loading');
2832
- if (loadingSDKOuter) {
2833
- body === null || body === void 0 ? void 0 : body.removeChild(loadingSDKOuter);
2834
- }
2835
- }
2836
-
2837
- function getCssVariable(name, className) {
2838
- if (className) {
2839
- const element = document.querySelector(`.${className}`);
2840
- const value = element ? getComputedStyle(element).getPropertyValue(name) : '';
2841
- return value;
2842
- }
2843
- return getComputedStyle(document.documentElement).getPropertyValue(name);
2844
- }
2845
- function colorStringToRGB(color) {
2846
- const rgb = color.replace('rgb(', '').replace(')', '').split(',').map(c => parseInt(c, 10));
2847
- return rgb;
2848
- }
2849
- function hexToRGB(hex) {
2850
- if (hex.length === 4) {
2851
- const _r = parseInt(hex.slice(1, 2), 16);
2852
- const _g = parseInt(hex.slice(2, 3), 16);
2853
- const _b = parseInt(hex.slice(3, 4), 16);
2854
- return [_r, _g, _b];
2855
- }
2856
- const r = parseInt(hex.slice(1, 3), 16);
2857
- const g = parseInt(hex.slice(3, 5), 16);
2858
- const b = parseInt(hex.slice(5, 7), 16);
2859
- return [r, g, b];
2860
- }
2861
- function colorToRGB(color) {
2862
- const _color = color.trim();
2863
- if (_color.startsWith('#')) {
2864
- return hexToRGB(_color);
2865
- }
2866
- return colorStringToRGB(_color);
2867
- }
2868
- function RGBToLottieColor(color) {
2869
- return color.map(c => c / 255);
2870
- }
2871
-
2872
- const uploadModal = arg => {
2873
- const authmeContainer = document.querySelector('.authme-container');
2874
- if (!authmeContainer) {
2875
- console.error('uploadModal: authmeContainer not found');
2876
- return;
2877
- }
2878
- const uiThemeConfig = Storage.getItem('themeConfig');
2879
- function removeModal() {
2880
- var _a;
2881
- (_a = document.querySelector('.video-container__upload')) === null || _a === void 0 ? void 0 : _a.remove();
2882
- }
2883
- const domModal = document.createElement('div');
2884
- const domIcon = document.createElement('div');
2885
- const domTitle = document.createElement('div');
2886
- const domMessage = document.createElement('div');
2887
- const domStatement = document.createElement('div');
2888
- const domFooterContainer = document.createElement('div');
2889
- const domClose = document.createElement('div');
2890
- const domRetry = document.createElement('div');
2891
- domModal.classList.add('video-container__upload');
2892
- domIcon.classList.add('video-container__upload-icon');
2893
- domTitle.classList.add('video-container__upload-title');
2894
- domMessage.classList.add('video-container__upload-message');
2895
- domStatement.classList.add('video-container__upload-statement');
2896
- domFooterContainer.classList.add('video-container__upload-footer-container');
2897
- domClose.classList.add('video-container__upload-close');
2898
- domRetry.classList.add('video-container__upload-retry');
2899
- uiThemeText(domTitle, uiThemeConfig.titleTwo);
2900
- uiThemeText(domMessage, uiThemeConfig.bodyOne);
2901
- if (arg.type === 'success') {
2902
- domIcon.innerHTML = `<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
2903
- <rect width="96" height="96" rx="48" fill="${uiThemeConfig.uploadCompleteView.backgroundColor}" fill-opacity="${uiThemeConfig.uploadCompleteView.backgroundOpacity}" />
2904
- <g clip-path="url(#clip0_success)">
2905
- <path d="M32 51L43 62L67 38" stroke="${uiThemeConfig.uploadCompleteView.contentColor}" stroke-opacity="${uiThemeConfig.uploadCompleteView.contentOpacity}" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
2906
- </g>
2907
- <defs>
2908
- <clipPath id="clip0_success">
2909
- <rect width="48" height="48" fill="white" transform="translate(24 24)"/>
2910
- </clipPath>
2911
- </defs>
2912
- </svg>`;
2913
- }
2914
- if (arg.type === 'error') {
2915
- domIcon.innerHTML = `<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
2916
- <rect width="96" height="96" rx="48" fill="${uiThemeConfig.uploadIncompleteView.backgroundColor}" fill-opacity="${uiThemeConfig.uploadIncompleteView.backgroundOpacity}"/>
2917
- <g clip-path="url(#clip0_error)">
2918
- <path d="M62 34L34 62" stroke="${uiThemeConfig.uploadIncompleteView.contentColor}" stroke-opacity="${uiThemeConfig.uploadIncompleteView.contentOpacity}" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
2919
- <path d="M62 62L34 34" stroke="${uiThemeConfig.uploadIncompleteView.contentColor}" stroke-opacity="${uiThemeConfig.uploadIncompleteView.contentOpacity}" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
2920
- </g>
2921
- <defs>
2922
- <clipPath id="clip0_error">
2923
- <rect width="48" height="48" fill="white" transform="translate(24 24)"/>
2924
- </clipPath>
2925
- </defs>
2926
- </svg>
2927
- `;
2928
- }
2929
- if (arg.type === 'success') {
2930
- domTitle.innerText = arg.titleSuccess || '';
2931
- domMessage.innerText = arg.messageSuccess || '';
2932
- }
2933
- if (arg.type === 'error') {
2934
- domTitle.innerText = arg.titleError || '';
2935
- domMessage.innerText = arg.messageError || '';
2936
- }
2937
- domModal.appendChild(domIcon);
2938
- domModal.appendChild(domTitle);
2939
- domModal.appendChild(domMessage);
2940
- if (uiThemeConfig.isStatementEnabled && arg.statement && arg.type === 'success') {
2941
- uiThemeText(domStatement, uiThemeConfig.bodyThree);
2942
- domStatement.innerText = arg.statement;
2943
- domModal.appendChild(domStatement);
2944
- }
2945
- if (arg.type === 'error' && arg.retryText && arg.closeText) {
2946
- uiThemeButton(domRetry, uiThemeConfig.majorButton);
2947
- domRetry.innerText = arg.retryText;
2948
- domRetry.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
2949
- if (arg.onRetry) {
2950
- yield arg.onRetry();
2951
- }
2952
- removeModal();
2953
- }));
2954
- uiThemeButton(domClose, uiThemeConfig.minorButton);
2955
- domClose.innerText = arg.closeText;
2956
- domClose.addEventListener('click', () => __awaiter(void 0, void 0, void 0, function* () {
2957
- if (arg.onClose) {
2958
- yield arg.onClose();
2959
- }
2960
- removeModal();
2961
- }));
2962
- domFooterContainer.appendChild(domRetry);
2963
- domFooterContainer.appendChild(domClose);
2964
- domModal.appendChild(domFooterContainer);
2965
- }
2966
- authmeContainer.appendChild(domModal);
2967
- return {
2968
- removeModal
2969
- };
2970
- };
2971
-
2972
- const dropMenu = function dropMenu(dom, callback) {
2973
- if (!dom) {
2974
- console.error('dom is required');
2975
- return;
2976
- }
2977
- const ul = dom.querySelector('ul');
2978
- const ulSection = dom.querySelector('section');
2979
- const list = dom.querySelectorAll('li');
2980
- dom.querySelector('.drop_menu_title').addEventListener('click', function (e) {
2981
- e.stopPropagation();
2982
- ulSection.classList.toggle('hide');
2983
- dom.querySelector('.drop_menu_title').classList.toggle('focus');
2984
- });
2985
- for (let i = 0; i < list.length; i++) {
2986
- const element = list[i];
2987
- element.addEventListener('click', function (e) {
2988
- e.stopPropagation();
2989
- if (ul.querySelector('.active')) {
2990
- ul.querySelector('.active').classList.remove('active');
2991
- }
2992
- this.classList.add('active');
2993
- dom.querySelector('.drop_menu_title span').innerText = this.innerText.trim();
2994
- if (callback) {
2995
- callback(this);
2996
- }
2997
- ulSection.classList.toggle('hide');
2998
- dom.querySelector('.drop_menu_title').classList.toggle('focus');
2999
- });
3000
- }
3001
- window.addEventListener('click', function (e) {
3002
- e.stopPropagation();
3003
- if (!ulSection.classList.contains('hide')) {
3004
- ulSection.classList.add('hide');
3005
- }
3006
- if (dom.querySelector('.drop_menu_title').classList.contains('focus')) {
3007
- dom.querySelector('.drop_menu_title').classList.remove('focus');
3008
- }
3009
- });
3010
- };
3011
-
3012
- const QUEUE_LENGTH = 10;
3013
- const requstQueue = [];
3014
- function pushRequest(request) {
3015
- if (requstQueue.length > QUEUE_LENGTH - 1) {
3016
- requstQueue.shift();
3017
- }
3018
- requstQueue.push(request);
3019
- }
3020
- function clearRequest() {
3021
- requstQueue.splice(0, requstQueue.length);
3022
- }
3023
- function backgroundRequest(request) {
3024
- const requestPromise = request();
3025
- requestPromise.catch(err => {
3026
- if (err._code === exports.ErrorCode.NETWORK_ERROR) {
3027
- pushRequest(request);
3028
- }
3029
- });
3030
- }
3031
- window.ononline = () => {
3032
- const tasks = [...requstQueue];
3033
- clearRequest();
3034
- tasks.forEach(request => {
3035
- backgroundRequest(request);
3036
- });
3037
- };
3038
-
3039
- const themeConfigDefault = {
3040
- isFraudAnimationLoadingPageEnabled: true,
3041
- isStatementEnabled: true,
3042
- isLivenessIntroPageEnabled: true,
3043
- resultPageCountdown: {
3044
- // 結果頁倒數的參數們
3045
- // 結果頁是否顯示倒數
3046
- isEnabled: true,
3047
- // 倒數敘述文字
3048
- textColor: '#212121',
3049
- textWeight: 'regular',
3050
- fontSize: 14,
3051
- // 倒數時間
3052
- timeTextColor: '#FF3B30',
3053
- timeTextWeight: 'regular',
3054
- timeFontSize: 14
3055
- },
3056
- headerTitle: {
3057
- // G.H.2
3058
- // Header(畫面上方標題,如前導頁)的參數們
3059
- textColor: '#212121',
3060
- textWeight: 'medium',
3061
- fontSize: 18
3062
- },
3063
- nonEkycCloseButton: {
3064
- // G.A.3
3065
- // 非ekyc流程中的X
3066
- contentColor: '#424242',
3067
- contentOpacity: 1
3068
- },
3069
- backButton: {
3070
- // iOS only
3071
- // ekyc流程中的返回
3072
- contentColor: '#424242',
3073
- contentOpacity: 1
3074
- },
3075
- ekycCloseButton: {
3076
- // G.A.1、G.A.2
3077
- // ekyc流程中的X
3078
- contentColor: '#ffffff',
3079
- contentOpacity: 1,
3080
- backgroundColor: '#000000',
3081
- backgroundOpacity: 0.2
3082
- },
3083
- majorButton: {
3084
- // G.B.1、G.B.2、G.B.3、G.B.4
3085
- // 主要button
3086
- cornerRadius: 24,
3087
- backgroundColor: '#00c1b6',
3088
- backgroundOpacity: 1,
3089
- borderColor: '#000000',
3090
- borderOpacity: 1,
3091
- borderWidth: 0,
3092
- textColor: '#ffffff',
3093
- textWeight: 'medium',
3094
- fontSize: 16,
3095
- disabledBackgroundColor: '#E0E0E0',
3096
- disabledBorderColor: '#E0E0E0',
3097
- disabledTextColor: '#FFFFFF'
3098
- },
3099
- minorButton: {
3100
- // G.B.5、G.B.6、G.B.7、G.B.8
3101
- // 次要button
3102
- cornerRadius: 24,
3103
- backgroundColor: '#ffffff',
3104
- backgroundOpacity: 1,
3105
- borderColor: '#00c1b6',
3106
- borderOpacity: 1,
3107
- borderWidth: 1,
3108
- textColor: '#00c1b6',
3109
- textWeight: 'medium',
3110
- fontSize: 16,
3111
- disabledBackgroundColor: '#FFFFFF',
3112
- disabledBorderColor: '#BDBDBD',
3113
- disabledTextColor: '#BDBDBD'
3114
- },
3115
- smallermMajorButton: {
3116
- // 主要button(小)
3117
- // 用於dialog/alert的按鈕
3118
- cornerRadius: 15,
3119
- backgroundColor: '#00c1b6',
3120
- backgroundOpacity: 1,
3121
- borderColor: '#000000',
3122
- borderOpacity: 1,
3123
- borderWidth: 0,
3124
- textColor: '#ffffff',
3125
- textWeight: 'medium',
3126
- fontSize: 14,
3127
- disabledBackgroundColor: '#E0E0E0',
3128
- disabledBorderColor: '#E0E0E0',
3129
- disabledTextColor: '#FFFFFF' //預設值: #FFFFFF
3130
- },
3131
-
3132
- // 次要button(小)
3133
- smallerMinorButton: {
3134
- cornerRadius: 15,
3135
- backgroundColor: '#ffffff',
3136
- backgroundOpacity: 1,
3137
- borderColor: '#00c1b6',
3138
- borderOpacity: 1,
3139
- borderWidth: 1,
3140
- textColor: '#00c1b6',
3141
- textWeight: 'medium',
3142
- fontSize: 14,
3143
- disabledBackgroundColor: '#FFFFFF',
3144
- disabledBorderColor: '#BDBDBD',
3145
- disabledTextColor: '#BDBDBD' //預設值: #BDBDBD
3146
- },
3147
-
3148
- hint: {
3149
- // G.HT.2
3150
- // Hint 提示框(OCR、防偽、活體下面的提示的訊息)
3151
- cornerRadius: 8,
3152
- backgroundColor: '#000000',
3153
- opacity: 0.4,
3154
- textColor: '#ffffff',
3155
- textWeight: 'regular',
3156
- fontSize: 14
3157
- },
3158
- fraudIntroStepTitle: {
3159
- // G.L.1、G.L.2
3160
- // Fraud引導頁Step title(step1, step2 那塊)
3161
- cornerRadius: 15,
3162
- backgroundColor: '#25608A',
3163
- backgroundOpacity: 1,
3164
- textColor: '#ffffff',
3165
- textWeight: 'medium',
3166
- fontSize: 14
3167
- },
3168
- uploadCompleteView: {
3169
- // G.S.1、G.S.2
3170
- // 上傳完成的勾勾圖
3171
- contentColor: '#ffffff',
3172
- contentOpacity: 1,
3173
- backgroundColor: '#00c1b6',
3174
- backgroundOpacity: 1
3175
- },
3176
- uploadIncompleteView: {
3177
- // G.S.3、G.S.4
3178
- // 上傳失敗的X圖
3179
- contentColor: '#ffffff',
3180
- contentOpacity: 1,
3181
- backgroundColor: '#FF3B30',
3182
- backgroundOpacity: 1
3183
- },
3184
- loadingViewContentColor: '#00c1b6',
3185
- scanFrame: {
3186
- // G.SC.1、G.SC.2
3187
- // 框線圖相關(外框)
3188
- isEnabled: true,
3189
- style: 'cornered',
3190
- width: 2,
3191
- opacity: 1,
3192
- undetectedColor: '#ffffff',
3193
- detectedColor: '#7CFFF9'
3194
- },
3195
- scanLine: {
3196
- // 框線圖相關(掃描線)
3197
- isEnabled: true,
3198
- color: '#00c1b6'
3199
- },
3200
- scanHint: {
3201
- // G.SC.4
3202
- // 框線圖相關(掃描線)
3203
- isEnabled: true,
3204
- style: 'image',
3205
- color: '#ffffff',
3206
- opacity: 0.7,
3207
- textWeight: 'medium',
3208
- fontSize: 60
3209
- },
3210
- fraudScanHint: {
3211
- // D.F.SC.1
3212
- // 防偽框線圖相關參數(圖)
3213
- isEnabled: true,
3214
- style: 'animation',
3215
- color: '#000000',
3216
- opacity: 0.7
3217
- },
3218
- popupView: {
3219
- // popup
3220
- width: 0.75,
3221
- cornerRadius: 12,
3222
- backgroundColor: '#ffffff'
3223
- },
3224
- livenessErrorScanFrame: {
3225
- // G.LIVE.2
3226
- // 活體偵測錯誤
3227
- color: '#FF3B30',
3228
- opacity: 1,
3229
- borderWidth: 6
3230
- },
3231
- livenessSuccessScanFrame: {
3232
- // G.LIVE.1
3233
- // 活體偵測成功
3234
- color: '#00C1B6',
3235
- opacity: 1,
3236
- borderWidth: 6
3237
- },
3238
- isFraudScanIntroPageEnabled: true,
3239
- pageDotColor: '#00C1B6',
3240
- titleOne: {
3241
- // G.T.1
3242
- // figma 上的 title 1
3243
- // OCR 確認頁的"確認xx正面、反面"、nfc 護照的"掃描護照晶片(Android 要調整 nfc sdk,比較麻煩)"[後面做]
3244
- // 、"厚度檢測"、人臉辨識導引頁的"即將進行人臉拍攝"
3245
- textColor: '#212121',
3246
- textWeight: 'medium',
3247
- fontSize: 20
3248
- },
3249
- titleTwo: {
3250
- // G.T.2
3251
- // Figma標示title 2
3252
- // loading 圖的"上傳中"、"上傳失敗"、"上傳完成,等待審核中"、
3253
- // timeout或其他錯誤 alert 的內容"請聯繫客服以協助處理此問題"
3254
- textColor: '#212121',
3255
- textWeight: 'medium',
3256
- fontSize: 18
3257
- },
3258
- titleThree: {
3259
- // G.T.3
3260
- // Figma標示title 3
3261
- // 活體的標題"將人臉放入邊框中"、nfc 護照的"尋找生物特徵的圖示(Android 要調整 nfc sdk,比較麻煩)"
3262
- // 結果頁的"請在xx:xx內完成確認"
3263
- textColor: '#212121',
3264
- textWeight: 'medium',
3265
- fontSize: 16
3266
- },
3267
- bodyOne: {
3268
- // G.T.4
3269
- // figma 上的 body 1
3270
- // "完成流程"、"請檢查網路連線狀況並重新嘗試"、"請根據下方教學步驟依序完成NFC操作"、"請將卡面傾斜45度角放入畫面框線進行拍攝"
3271
- // "將臉部置於方框中,依照畫面指示進行操作"
3272
- textColor: '#212121',
3273
- textWeight: 'regular',
3274
- fontSize: 16
3275
- },
3276
- bodyTwo: {
3277
- // G.T.5
3278
- // Figma標示body 2或body2
3279
- textColor: '#212121',
3280
- textWeight: 'regular',
3281
- fontSize: 14
3282
- },
3283
- bodyThree: {
3284
- // G.T.6
3285
- // Figma標示body 3或body3
3286
- textColor: '#212121',
3287
- textWeight: 'regular',
3288
- fontSize: 12
3289
- },
3290
- titleOneDarkMode: {
3291
- // G.T.D.1
3292
- // Figma標示dark_title 1
3293
- textColor: '#ffffff',
3294
- textWeight: 'medium',
3295
- fontSize: 20,
3296
- direction: 'bottom' //文字方向 bottom / top / center,
3297
- },
3298
-
3299
- fraudScanHintText: {
3300
- // D.F.SC.2
3301
- backgroundColor: '#000000',
3302
- backgroundOpacity: 0.7,
3303
- cornerRadius: 28,
3304
- width: '153px',
3305
- height: '56px',
3306
- textColor: '#FFFFFF',
3307
- textWeight: 'medium',
3308
- fontSize: 18,
3309
- leftText: '向左翻轉',
3310
- rightText: '向右翻轉',
3311
- upText: '向上翻轉',
3312
- downText: '向下翻轉'
3313
- },
3314
- titleTwoDarkMode: {
3315
- // G.T.D.2
3316
- // Figma標示dark_title 2
3317
- textColor: '#ffffff',
3318
- textWeight: 'medium',
3319
- fontSize: 18
3320
- },
3321
- bodyTwoDarkMode: {
3322
- textColor: '#ffffff',
3323
- textWeight: 'regular',
3324
- fontSize: 14
3325
- },
3326
- bodyThreeDarkMode: {
3327
- // G.T.D.4
3328
- // Figma標示dark_body 3
3329
- textColor: '#E0E0E0',
3330
- textWeight: 'regular',
3331
- fontSize: 12
3332
- },
3333
- resultTitle: {
3334
- // G.6
3335
- // Figma標示resultPage_text_title
3336
- textColor: '#25608A',
3337
- textWeight: 'medium',
3338
- fontSize: 22
3339
- },
3340
- resultBody: {
3341
- // G.7
3342
- // Figma標示resultPage_text_body
3343
- textColor: '#757575',
3344
- textWeight: 'regular',
3345
- fontSize: 14
3346
- },
3347
- resultTime: {
3348
- // G.8
3349
- // Figma標示resultPage_timeText
3350
- textColor: '#FF3B30',
3351
- textWeight: 'medium',
3352
- fontSize: 16
3353
- },
3354
- fraudInfoButton: {
3355
- cornerRadius: 24,
3356
- backgroundColor: '#00c1b6',
3357
- backgroundOpacity: 1,
3358
- borderColor: '#000000',
3359
- borderOpacity: 1,
3360
- borderWidth: 0,
3361
- textColor: '#ffffff',
3362
- textWeight: 'medium',
3363
- fontSize: 16,
3364
- disabledBackgroundColor: '#E0E0E0',
3365
- disabledBorderColor: '#E0E0E0',
3366
- disabledTextColor: '#FFFFFF'
3367
- }
3368
- };
3369
-
3370
- var name = "authme/sdk";
3371
- var version$1 = "2.8.41";
3372
- var date = "2026-01-30T10:27:23+0000";
3373
- var packageInfo = {
3374
- name: name,
3375
- version: version$1,
3376
- date: date
3377
- };
3378
-
3379
- var _a;
3380
- var _b, _c;
3381
- const version = packageInfo.version;
3382
- (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
3383
- window[Symbol.for('authme-sdk')][packageInfo.name] = version;
3384
-
3385
- exports.AuthmeError = AuthmeError;
3386
- exports.RGBToLottieColor = RGBToLottieColor;
3387
- exports.Storage = Storage;
3388
- exports.UintArrayToBlob = UintArrayToBlob;
3389
- exports.asyncOnLineShowErrorMessage = asyncOnLineShowErrorMessage;
3390
- exports.asyncShowErrorMessage = asyncShowErrorMessage;
3391
- exports.asyncShowPopup = asyncShowPopup;
3392
- exports.backgroundRequest = backgroundRequest;
3393
- exports.checkOnlineStatus = checkOnlineStatus;
3394
- exports.clearCanvas = clearCanvas;
3395
- exports.colorStringToRGB = colorStringToRGB;
3396
- exports.colorToRGB = colorToRGB;
3397
- exports.combineResult = combineResult;
3398
- exports.cropByRatio = cropByRatio;
3399
- exports.dataURItoBlob = dataURItoBlob;
3400
- exports.debugLog = debugLog;
3401
- exports.debugTools = debugTools;
3402
- exports.decodeToken = decodeToken;
3403
- exports.dropMenu = dropMenu;
3404
- exports.fontWeight = fontWeight;
3405
- exports.getCanvasSize = getCanvasSize;
3406
- exports.getCssVariable = getCssVariable;
3407
- exports.getDeviceInfo = getDeviceInfo;
3408
- exports.getImageData = getImageData;
3409
- exports.getSystemInfo = getSystemInfo;
3410
- exports.hexToRGB = hexToRGB;
3411
- exports.hideElement = hideElement;
3412
- exports.hideErrorMessage = hideErrorMessage;
3413
- exports.hidePopup = hidePopup;
3414
- exports.isIphone14proOrProMax = isIphone14proOrProMax;
3415
- exports.isMobile = isMobile;
3416
- exports.isMobileOrTablet = isMobileOrTablet;
3417
- exports.osVersion = osVersion;
3418
- exports.requestCamera = requestCamera;
3419
- exports.resize = resize;
3420
- exports.retryPromiseWithCondition = retryPromiseWithCondition;
3421
- exports.showElement = showElement;
3422
- exports.showErrorMessage = showErrorMessage;
3423
- exports.showErrorMessageEventName = showErrorMessageEventName;
3424
- exports.showPopup = showPopup;
3425
- exports.splitResult = splitResult;
3426
- exports.startLoadingSDK = startLoadingSDK;
3427
- exports.startSpinner = startSpinner;
3428
- exports.stopLoadingSDK = stopLoadingSDK;
3429
- exports.stopSpinner = stopSpinner;
3430
- exports.switchCamera = switchCamera;
3431
- exports.themeConfigDefault = themeConfigDefault;
3432
- exports.uiThemeButton = uiThemeButton;
3433
- exports.uiThemeDirection = uiThemeDirection;
3434
- exports.uiThemeHint = uiThemeHint;
3435
- exports.uiThemeSmallButton = uiThemeSmallButton;
3436
- exports.uiThemeText = uiThemeText;
3437
- exports.uploadModal = uploadModal;
3438
- exports.useState = useState;
3439
- exports.verificationErrorMessages = verificationErrorMessages;
3440
- exports.version = version;
3441
- exports.videoConstraintsFactory = videoConstraintsFactory;
3442
- exports.waitTime = waitTime;