@kc-one/smart-fill-sdk 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +848 -786
- package/dist/index.umd.cjs +9 -9
- package/dist/src/config/defaults.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (e, t, n) =>
|
|
4
|
-
const
|
|
1
|
+
var pn = Object.defineProperty;
|
|
2
|
+
var hn = (e, t, n) => t in e ? pn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var d = (e, t, n) => hn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const ti = {
|
|
5
5
|
name: "native",
|
|
6
6
|
/** 匹配 input / textarea / select 原生控件 */
|
|
7
7
|
match: (e) => e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement,
|
|
@@ -14,7 +14,7 @@ const Zo = {
|
|
|
14
14
|
const n = e.element;
|
|
15
15
|
n instanceof HTMLInputElement && n.type === "checkbox" ? n.checked = !!t : (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) && (n.value = String(t ?? "")), n == null || n.dispatchEvent(new Event("input", { bubbles: !0 })), n == null || n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
16
16
|
}
|
|
17
|
-
},
|
|
17
|
+
}, wt = [
|
|
18
18
|
// Element Plus / Element UI
|
|
19
19
|
{ framework: "element", selectors: ".el-select,.el-select-v2", type: "select", kind: "input" },
|
|
20
20
|
{ framework: "element", selectors: ".el-cascader", type: "cascader", kind: "input" },
|
|
@@ -59,7 +59,7 @@ const Zo = {
|
|
|
59
59
|
{ framework: "vant", selectors: ".van-checkbox-group", type: "checkbox", kind: "checkboxGroup", optionSelector: '.van-checkbox,[role="checkbox"],input[type="checkbox"]' },
|
|
60
60
|
// 通用 ARIA 下拉(无框架 class 或作为内层触发器)
|
|
61
61
|
{ framework: "generic", selectors: '[role="combobox"]', type: "select", kind: "input" }
|
|
62
|
-
],
|
|
62
|
+
], gn = [
|
|
63
63
|
"is-disabled",
|
|
64
64
|
"ant-select-disabled",
|
|
65
65
|
"n-select--disabled",
|
|
@@ -68,7 +68,7 @@ const Zo = {
|
|
|
68
68
|
"van-switch--disabled",
|
|
69
69
|
"van-stepper--disabled",
|
|
70
70
|
"van-dropdown-menu--disabled"
|
|
71
|
-
],
|
|
71
|
+
], vt = wt.map((e) => e.selectors).join(", "), yn = [
|
|
72
72
|
".form-item",
|
|
73
73
|
".ant-form-item",
|
|
74
74
|
".el-form-item",
|
|
@@ -78,7 +78,7 @@ const Zo = {
|
|
|
78
78
|
".van-field",
|
|
79
79
|
".field",
|
|
80
80
|
".form-row"
|
|
81
|
-
].join(", "),
|
|
81
|
+
].join(", "), bn = [
|
|
82
82
|
"label",
|
|
83
83
|
".ant-form-item-label",
|
|
84
84
|
".el-form-item__label",
|
|
@@ -86,7 +86,7 @@ const Zo = {
|
|
|
86
86
|
".arco-form-item-label",
|
|
87
87
|
".van-field__label",
|
|
88
88
|
".label"
|
|
89
|
-
].join(", "),
|
|
89
|
+
].join(", "), Xe = [
|
|
90
90
|
"dialog[open]",
|
|
91
91
|
"[role='dialog']",
|
|
92
92
|
"[aria-modal='true']",
|
|
@@ -105,7 +105,7 @@ const Zo = {
|
|
|
105
105
|
".van-action-sheet",
|
|
106
106
|
".popup",
|
|
107
107
|
".drawer"
|
|
108
|
-
].join(", "),
|
|
108
|
+
].join(", "), mn = [
|
|
109
109
|
"is-checked",
|
|
110
110
|
"ant-switch-checked",
|
|
111
111
|
"n-switch--active",
|
|
@@ -114,20 +114,20 @@ const Zo = {
|
|
|
114
114
|
"van-radio--checked",
|
|
115
115
|
"van-checkbox--checked"
|
|
116
116
|
];
|
|
117
|
-
function
|
|
118
|
-
return
|
|
117
|
+
function K(e) {
|
|
118
|
+
return wt.find((t) => e.matches(t.selectors)) || null;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return !!
|
|
120
|
+
function St(e) {
|
|
121
|
+
return !!K(e);
|
|
122
122
|
}
|
|
123
123
|
function Fe(e) {
|
|
124
124
|
for (let t = e; t; t = t.parentElement)
|
|
125
|
-
if (
|
|
125
|
+
if (St(t)) return t;
|
|
126
126
|
return null;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function me(e) {
|
|
129
129
|
var n;
|
|
130
|
-
const t =
|
|
130
|
+
const t = K(e);
|
|
131
131
|
if (!t) return null;
|
|
132
132
|
if (e.matches(".van-field")) {
|
|
133
133
|
if (e.querySelector("textarea")) return "textarea";
|
|
@@ -146,29 +146,29 @@ function ge(e) {
|
|
|
146
146
|
}
|
|
147
147
|
return t.type;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
const t =
|
|
149
|
+
function Et(e) {
|
|
150
|
+
const t = K(e);
|
|
151
151
|
if (t != null && t.optionSelector)
|
|
152
|
-
return Array.from(e.querySelectorAll(t.optionSelector)).map((n) =>
|
|
152
|
+
return Array.from(e.querySelectorAll(t.optionSelector)).map((n) => wn(n)).filter((n) => !!(n.label || n.value));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function wn(e) {
|
|
155
155
|
const t = e instanceof HTMLInputElement ? e : e.querySelector('input[type="radio"],input[type="checkbox"]'), n = f(e.textContent || e.getAttribute("aria-label") || e.getAttribute("title") || ""), r = e.getAttribute("value") || (t == null ? void 0 : t.value) || n;
|
|
156
156
|
return { label: n, value: r };
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
158
|
+
function Q(e) {
|
|
159
|
+
return mn.some((t) => e.classList.contains(t)) || e.getAttribute("aria-checked") === "true" || !!e.querySelector("input:checked");
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function $(e) {
|
|
162
162
|
return e.querySelector('input:not([type="hidden"]), textarea');
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function xt(e) {
|
|
165
165
|
var t, n, r;
|
|
166
|
-
return e.getAttribute("name") || ((t =
|
|
166
|
+
return e.getAttribute("name") || ((t = $(e)) == null ? void 0 : t.getAttribute("name")) || e.getAttribute("data-smart-fill-key") || ((n = $(e)) == null ? void 0 : n.getAttribute("data-smart-fill-key")) || ((r = e.querySelector("[data-smart-fill-key]")) == null ? void 0 : r.getAttribute("data-smart-fill-key"));
|
|
167
167
|
}
|
|
168
168
|
function f(e) {
|
|
169
169
|
return e.replace(/[*::]/g, "").replace(/\s+/g, " ").trim();
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const qe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-style", kt = [
|
|
172
172
|
"[role='combobox']",
|
|
173
173
|
"[aria-haspopup='listbox']",
|
|
174
174
|
".el-cascader",
|
|
@@ -191,7 +191,7 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
191
191
|
".van-dropdown-menu__bar",
|
|
192
192
|
".van-field--picker",
|
|
193
193
|
".van-field--clickable"
|
|
194
|
-
].join(", "),
|
|
194
|
+
].join(", "), vn = [
|
|
195
195
|
".ant-select-selection-item",
|
|
196
196
|
".el-select__selected-item",
|
|
197
197
|
".el-select-v2__selected-item",
|
|
@@ -207,7 +207,7 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
207
207
|
".select-value",
|
|
208
208
|
".selection-item",
|
|
209
209
|
".van-field__control"
|
|
210
|
-
].join(", "),
|
|
210
|
+
].join(", "), De = [
|
|
211
211
|
"[role='option']",
|
|
212
212
|
".ant-select-item-option",
|
|
213
213
|
".el-select-dropdown__item",
|
|
@@ -219,8 +219,8 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
219
219
|
".t-select-option",
|
|
220
220
|
".van-picker-column__item",
|
|
221
221
|
".van-action-sheet__item"
|
|
222
|
-
].join(", "),
|
|
223
|
-
|
|
222
|
+
].join(", "), we = [
|
|
223
|
+
De,
|
|
224
224
|
".van-action-sheet__name",
|
|
225
225
|
".van-cascader__option",
|
|
226
226
|
".van-dropdown-item__option",
|
|
@@ -229,7 +229,7 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
229
229
|
".ant-cascader-menu-item",
|
|
230
230
|
".n-cascader-node",
|
|
231
231
|
".arco-cascader-option"
|
|
232
|
-
].join(", "),
|
|
232
|
+
].join(", "), Pe = [
|
|
233
233
|
".el-select-dropdown",
|
|
234
234
|
".el-cascader__dropdown",
|
|
235
235
|
".el-cascader-panel",
|
|
@@ -253,7 +253,7 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
253
253
|
".van-dropdown-item",
|
|
254
254
|
".van-picker",
|
|
255
255
|
"[role='listbox']"
|
|
256
|
-
].join(", "),
|
|
256
|
+
].join(", "), _t = [
|
|
257
257
|
".el-select-dropdown",
|
|
258
258
|
".el-select__popper",
|
|
259
259
|
".el-select-v2__popper",
|
|
@@ -270,7 +270,7 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
270
270
|
".van-dropdown-item",
|
|
271
271
|
".van-picker",
|
|
272
272
|
"[role='listbox']"
|
|
273
|
-
].join(", "),
|
|
273
|
+
].join(", "), At = [
|
|
274
274
|
".el-cascader__dropdown",
|
|
275
275
|
".el-cascader-panel",
|
|
276
276
|
".el-popper.el-cascader__dropdown",
|
|
@@ -279,9 +279,9 @@ const Oe = "data-smart-fill-hide-dropdown-mode", Xe = "smart-fill-hide-dropdown-
|
|
|
279
279
|
".arco-cascader-panel",
|
|
280
280
|
".van-cascader",
|
|
281
281
|
".van-cascader__options"
|
|
282
|
-
].join(", "),
|
|
283
|
-
function
|
|
284
|
-
return !
|
|
282
|
+
].join(", "), Sn = /(?:省|市|自治区|特别行政区|自治州|地区|盟|县|区)$/, En = /地址|省|市|区|县|地区|籍贯|户籍|居住地|所在地|区域/, xn = /* @__PURE__ */ new Set(["select", "cascader", "date"]);
|
|
283
|
+
function I(e) {
|
|
284
|
+
return !Dt(e) || Lt(e) ? !1 : !!e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
|
|
285
285
|
}
|
|
286
286
|
function k(e) {
|
|
287
287
|
var n;
|
|
@@ -300,10 +300,10 @@ function k(e) {
|
|
|
300
300
|
}
|
|
301
301
|
return !1;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
return !
|
|
303
|
+
function ee(e) {
|
|
304
|
+
return !Dt(e) || Lt(e) || e instanceof HTMLSelectElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? !1 : e.matches(kt) || e.getAttribute("role") === "combobox" || e.getAttribute("aria-haspopup") === "listbox" || e.classList.contains("el-select__wrapper") || e.classList.contains("el-select-v2__wrapper") || k(e);
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function te(e) {
|
|
307
307
|
const t = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
|
|
308
308
|
if (t instanceof HTMLElement) return t;
|
|
309
309
|
const n = e.closest([
|
|
@@ -333,26 +333,26 @@ function Z(e) {
|
|
|
333
333
|
".el-select__wrapper",
|
|
334
334
|
".el-select-v2__wrapper"
|
|
335
335
|
].join(", "));
|
|
336
|
-
return n instanceof HTMLElement ? n.matches(".van-field") && !k(n) ? null : n :
|
|
336
|
+
return n instanceof HTMLElement ? n.matches(".van-field") && !k(n) ? null : n : ee(e) ? e : null;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function He(e) {
|
|
339
339
|
if (e instanceof HTMLSelectElement) return e;
|
|
340
|
-
if (
|
|
340
|
+
if (I(e))
|
|
341
341
|
return e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader") || e;
|
|
342
|
-
const t =
|
|
342
|
+
const t = te(e);
|
|
343
343
|
return t || (e.matches(".van-field") && k(e) ? e : null);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
if (
|
|
347
|
-
if (
|
|
348
|
-
const t =
|
|
345
|
+
function Ct(e) {
|
|
346
|
+
if (I(e)) return "cascader";
|
|
347
|
+
if (ee(e) || k(e)) return "select";
|
|
348
|
+
const t = me(e);
|
|
349
349
|
return t || (e instanceof HTMLSelectElement ? "select" : null);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
const n = t ||
|
|
353
|
-
return n != null &&
|
|
351
|
+
function Ne(e, t) {
|
|
352
|
+
const n = t || Ct(e);
|
|
353
|
+
return n != null && xn.has(n);
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function kn(e) {
|
|
356
356
|
const t = e.matches(".van-field") ? e : e.closest(".van-field");
|
|
357
357
|
if (t instanceof HTMLElement && k(t)) {
|
|
358
358
|
const i = t.querySelector(".van-field__control");
|
|
@@ -361,7 +361,7 @@ function vn(e) {
|
|
|
361
361
|
const s = f((i == null ? void 0 : i.textContent) || "");
|
|
362
362
|
return s && s !== "请选择" ? s : "";
|
|
363
363
|
}
|
|
364
|
-
const n = e.querySelector(
|
|
364
|
+
const n = e.querySelector(vn);
|
|
365
365
|
if (n instanceof HTMLInputElement)
|
|
366
366
|
return f(n.value);
|
|
367
367
|
const r = f((n == null ? void 0 : n.textContent) || "");
|
|
@@ -369,46 +369,46 @@ function vn(e) {
|
|
|
369
369
|
const o = e.querySelector('input:not([type="hidden"])');
|
|
370
370
|
return o != null && o.value ? f(o.value) : r;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
const t =
|
|
372
|
+
function Tt(e) {
|
|
373
|
+
const t = Mn(e);
|
|
374
374
|
if (!t.length) return;
|
|
375
|
-
const n =
|
|
375
|
+
const n = Rn(t);
|
|
376
376
|
return n.length ? n : void 0;
|
|
377
377
|
}
|
|
378
|
-
function
|
|
378
|
+
function ce(e) {
|
|
379
379
|
var t;
|
|
380
|
-
return !((t = e.options) != null && t.length) || e.type === "cascader" ||
|
|
380
|
+
return !((t = e.options) != null && t.length) || e.type === "cascader" || En.test(e.label || "") ? !1 : Hn(e.options);
|
|
381
381
|
}
|
|
382
|
-
async function
|
|
382
|
+
async function _n(e) {
|
|
383
383
|
if (e instanceof HTMLSelectElement)
|
|
384
384
|
return Array.from(e.options).map((s) => ({ value: s.value, label: f(s.textContent || s.label) })).filter((s) => s.label || s.value);
|
|
385
|
-
const t =
|
|
385
|
+
const t = Tt(e);
|
|
386
386
|
if (t != null && t.length) return t;
|
|
387
|
-
const n =
|
|
388
|
-
if (!
|
|
387
|
+
const n = te(e) || e;
|
|
388
|
+
if (!ee(n) && !I(n) && !k(n))
|
|
389
389
|
return;
|
|
390
|
-
const r =
|
|
390
|
+
const r = Kn(), o = Nn(), i = new Set(o.getTrackedDropdowns());
|
|
391
391
|
try {
|
|
392
|
-
if (!(
|
|
393
|
-
const a = await
|
|
392
|
+
if (!(I(n) ? await Cn(n, o, i) : await An(n, o, i))) return;
|
|
393
|
+
const a = await Ln(o, i, n);
|
|
394
394
|
if (!a.length) return;
|
|
395
|
-
const c =
|
|
395
|
+
const c = Tn(a);
|
|
396
396
|
return c.length ? c : void 0;
|
|
397
397
|
} finally {
|
|
398
|
-
await
|
|
398
|
+
await zn(n, o), await D(60), o.restore(), r();
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function Lt(e) {
|
|
402
402
|
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
|
|
403
403
|
}
|
|
404
|
-
async function
|
|
405
|
-
const r =
|
|
404
|
+
async function An(e, t, n) {
|
|
405
|
+
const r = ne(e);
|
|
406
406
|
if (!r.length) return !1;
|
|
407
407
|
for (const o of r)
|
|
408
|
-
if (
|
|
408
|
+
if (Ft(o), Ot(o), await D(160), Je(e, t, n) || (qt(o), await D(180), Je(e, t, n))) return !0;
|
|
409
409
|
return !1;
|
|
410
410
|
}
|
|
411
|
-
async function
|
|
411
|
+
async function Cn(e, t, n) {
|
|
412
412
|
const r = [
|
|
413
413
|
e,
|
|
414
414
|
e.querySelector(".el-input__wrapper"),
|
|
@@ -417,14 +417,14 @@ async function En(e, t, n) {
|
|
|
417
417
|
e.querySelector("input")
|
|
418
418
|
].filter((o) => o instanceof HTMLElement);
|
|
419
419
|
for (const o of r)
|
|
420
|
-
if (
|
|
420
|
+
if (Ft(o), Ot(o), await D(180), ve(t, n, e).length || (qt(o), await D(180), ve(t, n, e).length)) return !0;
|
|
421
421
|
return !1;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function Tn(e) {
|
|
424
424
|
var r;
|
|
425
425
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
426
426
|
for (const o of e) {
|
|
427
|
-
const i = o.matches(
|
|
427
|
+
const i = o.matches(we) ? [o] : Array.from(o.querySelectorAll(we));
|
|
428
428
|
for (const s of i) {
|
|
429
429
|
if (s.classList.contains("is-disabled") || s.classList.contains("ant-select-item-option-disabled") || s.getAttribute("aria-disabled") === "true")
|
|
430
430
|
continue;
|
|
@@ -438,52 +438,52 @@ function xn(e) {
|
|
|
438
438
|
}
|
|
439
439
|
return n;
|
|
440
440
|
}
|
|
441
|
-
async function
|
|
441
|
+
async function Ln(e, t, n) {
|
|
442
442
|
for (let r = 0; r < 8; r += 1) {
|
|
443
|
-
const o =
|
|
443
|
+
const o = ve(e, t, n);
|
|
444
444
|
if (o.length) return o;
|
|
445
|
-
await
|
|
445
|
+
await D(r === 0 ? 120 : 80);
|
|
446
446
|
}
|
|
447
447
|
return [];
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
449
|
+
function Je(e, t, n) {
|
|
450
|
+
return ve(t, n, e).length > 0 ? !0 : ne(e).some((r) => r.getAttribute("aria-expanded") === "true" || r.classList.contains("is-focus") || r.classList.contains("is-focused"));
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
const r = t.filter((c) =>
|
|
452
|
+
function In(e, t, n) {
|
|
453
|
+
const r = t.filter((c) => $e(e, c)), o = r.filter((c) => On(e, c)), i = o.filter((c) => !n.has(c));
|
|
454
454
|
if (i.length)
|
|
455
|
-
return i.sort((c, l) =>
|
|
456
|
-
const s =
|
|
455
|
+
return i.sort((c, l) => N(l, e) - N(c, e));
|
|
456
|
+
const s = It(e);
|
|
457
457
|
if (s.size) {
|
|
458
458
|
const c = o.filter((l) => l.id && s.has(l.id));
|
|
459
459
|
if (c.length) return c;
|
|
460
460
|
}
|
|
461
461
|
if (o.length)
|
|
462
|
-
return o.sort((c, l) =>
|
|
463
|
-
const a = r.filter((c) =>
|
|
462
|
+
return o.sort((c, l) => N(l, e) - N(c, e)).slice(0, 1);
|
|
463
|
+
const a = r.filter((c) => Pn(c) && Mt(e)).sort((c, l) => N(l, e) - N(c, e)).slice(0, 1);
|
|
464
464
|
return a.length ? a : [];
|
|
465
465
|
}
|
|
466
|
-
function
|
|
467
|
-
return
|
|
466
|
+
function ve(e, t, n) {
|
|
467
|
+
return In(n, e.getTrackedDropdowns(), t);
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function N(e, t) {
|
|
470
470
|
const n = e.getBoundingClientRect(), r = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
|
|
471
471
|
let o = (Number.isNaN(r) ? 0 : r) * 10 + n.width * n.height;
|
|
472
|
-
return t && (o +=
|
|
472
|
+
return t && (o += Rt(t, e)), o;
|
|
473
473
|
}
|
|
474
|
-
function
|
|
475
|
-
const t =
|
|
474
|
+
function Mn(e) {
|
|
475
|
+
const t = I(e) ? At : _t, n = /* @__PURE__ */ new Set();
|
|
476
476
|
e.matches(t) && n.add(e);
|
|
477
477
|
for (const r of e.querySelectorAll(t))
|
|
478
|
-
|
|
478
|
+
$e(e, r) && n.add(r);
|
|
479
479
|
for (const r of e.querySelectorAll("[role='listbox']"))
|
|
480
|
-
e.contains(r) &&
|
|
480
|
+
e.contains(r) && $e(e, r) && n.add(r);
|
|
481
481
|
return [...n];
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function Rn(e) {
|
|
484
484
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
485
485
|
for (const r of e) {
|
|
486
|
-
const o = r.matches(
|
|
486
|
+
const o = r.matches(De) ? [r] : Array.from(r.querySelectorAll(De));
|
|
487
487
|
for (const i of o) {
|
|
488
488
|
if (i.classList.contains("is-disabled") || i.classList.contains("ant-select-item-option-disabled") || i.getAttribute("aria-disabled") === "true")
|
|
489
489
|
continue;
|
|
@@ -495,35 +495,35 @@ function Cn(e) {
|
|
|
495
495
|
}
|
|
496
496
|
return n;
|
|
497
497
|
}
|
|
498
|
-
function
|
|
498
|
+
function It(e) {
|
|
499
499
|
return new Set(
|
|
500
|
-
|
|
500
|
+
ne(e).flatMap((t) => [t.getAttribute("aria-controls"), t.getAttribute("aria-owns")]).filter((t) => !!t)
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
-
function
|
|
504
|
-
const n =
|
|
505
|
-
return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 :
|
|
503
|
+
function On(e, t) {
|
|
504
|
+
const n = It(e);
|
|
505
|
+
return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 : Dn(t) ? Mt(e) : n.size > 0 || ne(e).some((o) => o.getAttribute("aria-controls") || o.getAttribute("aria-owns")) ? !1 : Rt(e, t) > 0;
|
|
506
506
|
}
|
|
507
|
-
function
|
|
508
|
-
const n =
|
|
509
|
-
return n ? r : r ? !1 :
|
|
507
|
+
function $e(e, t) {
|
|
508
|
+
const n = I(e), r = Fn(t);
|
|
509
|
+
return n ? r : r ? !1 : qn(t);
|
|
510
510
|
}
|
|
511
|
-
function
|
|
512
|
-
return e.matches(
|
|
511
|
+
function Fn(e) {
|
|
512
|
+
return e.matches(At) || !!e.querySelector(".el-cascader-node, .ant-cascader-menu-item, .van-cascader__option, .n-cascader-node, .arco-cascader-option");
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
return e.matches(
|
|
514
|
+
function qn(e) {
|
|
515
|
+
return e.matches(_t) || !!e.querySelector('.el-select-dropdown__item, .ant-select-item-option, .van-picker-column__item, .van-action-sheet__item, .van-dropdown-item__option, [role="option"]');
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function Dn(e) {
|
|
518
518
|
return e.matches(".van-popup, .van-action-sheet, .van-picker, .van-dropdown-item__content, .van-dropdown-item");
|
|
519
519
|
}
|
|
520
|
-
function
|
|
521
|
-
return
|
|
520
|
+
function Mt(e) {
|
|
521
|
+
return ne(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused") || e.contains(document.activeElement));
|
|
522
522
|
}
|
|
523
|
-
function
|
|
524
|
-
return e.matches(
|
|
523
|
+
function Pn(e) {
|
|
524
|
+
return e.matches(we) || !!e.querySelector(we);
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function Rt(e, t) {
|
|
527
527
|
const n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
528
528
|
if (!n.width || !n.height || !r.width || !r.height)
|
|
529
529
|
return 0;
|
|
@@ -532,11 +532,11 @@ function It(e, t) {
|
|
|
532
532
|
const i = r.top >= n.bottom ? r.top - n.bottom : n.top - r.bottom;
|
|
533
533
|
return i > 320 ? 0 : Math.max(0, 400 - i) + o;
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Hn(e) {
|
|
536
536
|
const t = e.slice(0, 8).map((r) => f(String(r.label || r.value || ""))).filter(Boolean);
|
|
537
|
-
return t.length < 4 ? !1 : t.filter((r) =>
|
|
537
|
+
return t.length < 4 ? !1 : t.filter((r) => Sn.test(r)).length / t.length >= 0.75;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function ne(e) {
|
|
540
540
|
return [
|
|
541
541
|
e,
|
|
542
542
|
e.querySelector(".van-field__control"),
|
|
@@ -561,11 +561,11 @@ function J(e) {
|
|
|
561
561
|
e.querySelector(".select__wrapper")
|
|
562
562
|
].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function Nn() {
|
|
565
565
|
const e = /* @__PURE__ */ new Map();
|
|
566
|
-
|
|
566
|
+
$n(), document.documentElement.setAttribute(qe, "true");
|
|
567
567
|
const t = () => {
|
|
568
|
-
for (const r of document.querySelectorAll(
|
|
568
|
+
for (const r of document.querySelectorAll(Pe))
|
|
569
569
|
e.has(r) || e.set(r, {
|
|
570
570
|
display: r.style.display,
|
|
571
571
|
opacity: r.style.opacity,
|
|
@@ -581,19 +581,19 @@ function On() {
|
|
|
581
581
|
attributes: !0,
|
|
582
582
|
attributeFilter: ["class", "style", "aria-hidden"]
|
|
583
583
|
}), {
|
|
584
|
-
getTrackedDropdowns: () => Array.from(document.querySelectorAll(
|
|
584
|
+
getTrackedDropdowns: () => Array.from(document.querySelectorAll(Pe)),
|
|
585
585
|
restore: () => {
|
|
586
|
-
n.disconnect(), document.documentElement.removeAttribute(
|
|
586
|
+
n.disconnect(), document.documentElement.removeAttribute(qe);
|
|
587
587
|
for (const [r, o] of e)
|
|
588
588
|
r.style.display = o.display, r.style.opacity = o.opacity, r.style.visibility = o.visibility, r.style.pointerEvents = o.pointerEvents;
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
if (document.getElementById(
|
|
592
|
+
function $n() {
|
|
593
|
+
if (document.getElementById(Ze)) return;
|
|
594
594
|
const e = document.createElement("style");
|
|
595
|
-
e.id =
|
|
596
|
-
${
|
|
595
|
+
e.id = Ze, e.textContent = `
|
|
596
|
+
${Pe.split(",").map((t) => `html[${qe}="true"] ${t.trim()}`).join(`,
|
|
597
597
|
`)} {
|
|
598
598
|
opacity: 0 !important;
|
|
599
599
|
visibility: hidden !important;
|
|
@@ -603,27 +603,27 @@ function qn() {
|
|
|
603
603
|
}
|
|
604
604
|
`, document.head.appendChild(e);
|
|
605
605
|
}
|
|
606
|
-
async function
|
|
607
|
-
e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await
|
|
606
|
+
async function zn(e, t) {
|
|
607
|
+
e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await D(120);
|
|
608
608
|
for (const n of t.getTrackedDropdowns())
|
|
609
609
|
n.isConnected && (n.style.display = "none", n.setAttribute("aria-hidden", "true"));
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function Ot(e) {
|
|
612
612
|
window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function Ft(e) {
|
|
615
615
|
e.focus({ preventScroll: !0 });
|
|
616
616
|
const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
|
|
617
617
|
t instanceof HTMLElement && t.focus({ preventScroll: !0 });
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function qt(e) {
|
|
620
620
|
for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
|
|
621
621
|
e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
|
|
622
622
|
}
|
|
623
|
-
function
|
|
623
|
+
function D(e) {
|
|
624
624
|
return new Promise((t) => window.setTimeout(t, e));
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function Kn() {
|
|
627
627
|
const e = /* @__PURE__ */ new Map();
|
|
628
628
|
e.set(window, { left: window.scrollX, top: window.scrollY });
|
|
629
629
|
for (const t of document.querySelectorAll("*"))
|
|
@@ -633,27 +633,27 @@ function Pn() {
|
|
|
633
633
|
t === window ? window.scrollTo(n.left, n.top) : t instanceof HTMLElement && (t.scrollLeft = n.left, t.scrollTop = n.top);
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
|
-
function
|
|
636
|
+
function Dt(e) {
|
|
637
637
|
const t = window.getComputedStyle(e);
|
|
638
638
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
|
|
639
639
|
return !1;
|
|
640
640
|
const n = e.getBoundingClientRect();
|
|
641
641
|
return n.width > 0 && n.height > 0;
|
|
642
642
|
}
|
|
643
|
-
const
|
|
644
|
-
let
|
|
645
|
-
function
|
|
643
|
+
const Vn = /(维吾尔自治区|壮族自治区|回族自治区|特别行政区|自治区直辖县级行政区划|自治区|自治州|地区|盟|林区|街道|苏木|社区|省|市|区|县|旗|镇|乡)$/g, Bn = /* @__PURE__ */ new Set(["市辖区", "县", "自治区直辖县级行政区划"]);
|
|
644
|
+
let le = null;
|
|
645
|
+
function w(e) {
|
|
646
646
|
return String(e ?? "").replace(/\s+/g, "").replace(/[,,。.、/\\\-]/g, "").trim().toLowerCase();
|
|
647
647
|
}
|
|
648
|
-
function
|
|
649
|
-
return
|
|
648
|
+
function M(e) {
|
|
649
|
+
return w(e).replace(Vn, "");
|
|
650
650
|
}
|
|
651
|
-
function
|
|
651
|
+
function Ue(e) {
|
|
652
652
|
if (e == null) return "";
|
|
653
653
|
if (typeof e == "string" || typeof e == "number")
|
|
654
654
|
return String(e).trim();
|
|
655
655
|
if (Array.isArray(e))
|
|
656
|
-
return e.map((t) =>
|
|
656
|
+
return e.map((t) => Ue(t)).filter(Boolean).join("");
|
|
657
657
|
if (typeof e == "object") {
|
|
658
658
|
const t = [], n = /* @__PURE__ */ new Set(), r = (o) => {
|
|
659
659
|
const i = f(String(o ?? ""));
|
|
@@ -688,12 +688,12 @@ function Be(e) {
|
|
|
688
688
|
}
|
|
689
689
|
return f(String(e));
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function ke(e) {
|
|
692
692
|
const t = [], n = [], r = (s) => {
|
|
693
693
|
const a = f(String(s ?? ""));
|
|
694
694
|
a && t.push(a);
|
|
695
695
|
}, o = (s) => {
|
|
696
|
-
const a =
|
|
696
|
+
const a = w(s);
|
|
697
697
|
a && (n.push(a), r(s));
|
|
698
698
|
};
|
|
699
699
|
if (Array.isArray(e))
|
|
@@ -719,49 +719,49 @@ function Ee(e) {
|
|
|
719
719
|
r(e[s]);
|
|
720
720
|
} else
|
|
721
721
|
r(e);
|
|
722
|
-
const i =
|
|
722
|
+
const i = w(t.join(""));
|
|
723
723
|
return {
|
|
724
724
|
fullText: i,
|
|
725
|
-
looseFullText:
|
|
725
|
+
looseFullText: M(i),
|
|
726
726
|
structuredParts: n
|
|
727
727
|
};
|
|
728
728
|
}
|
|
729
|
-
function
|
|
730
|
-
const n =
|
|
729
|
+
function ue(e, t) {
|
|
730
|
+
const n = w(e), r = w(t);
|
|
731
731
|
if (!n || !r) return !1;
|
|
732
732
|
if (n === r || n.includes(r) || r.includes(n))
|
|
733
733
|
return !0;
|
|
734
|
-
const o =
|
|
734
|
+
const o = M(n), i = M(r);
|
|
735
735
|
return !o || !i ? !1 : o === i || o.includes(i) || i.includes(o);
|
|
736
736
|
}
|
|
737
|
-
function
|
|
738
|
-
const n =
|
|
737
|
+
function je(e, t = ke(e)) {
|
|
738
|
+
const n = Xn();
|
|
739
739
|
if (!n.length) return [];
|
|
740
740
|
let r = null, o = 0;
|
|
741
741
|
for (const i of n) {
|
|
742
|
-
const s =
|
|
742
|
+
const s = Gn(i, t);
|
|
743
743
|
s > o && (o = s, r = i);
|
|
744
744
|
}
|
|
745
745
|
return o >= 120 ? (r == null ? void 0 : r.labels) || [] : [];
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function Qe(e, t, n, r) {
|
|
748
748
|
let o = null, i = 0;
|
|
749
|
-
const s =
|
|
749
|
+
const s = Un(t, n, r);
|
|
750
750
|
for (const a of e) {
|
|
751
|
-
const c = a.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label"), l = f((c == null ? void 0 : c.textContent) || a.textContent || ""), u =
|
|
751
|
+
const c = a.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label"), l = f((c == null ? void 0 : c.textContent) || a.textContent || ""), u = w(l);
|
|
752
752
|
if (!u) continue;
|
|
753
|
-
const p =
|
|
754
|
-
let
|
|
755
|
-
!
|
|
753
|
+
const p = M(u);
|
|
754
|
+
let h = jn(u, p, s);
|
|
755
|
+
!h && t.fullText && (t.fullText.includes(u) ? h = 100 + u.length : u.includes(t.fullText) ? h = 70 + t.fullText.length : t.looseFullText.includes(p) && (h = 80 + p.length)), h > i && (i = h, o = a);
|
|
756
756
|
}
|
|
757
757
|
return i >= 75 ? o : null;
|
|
758
758
|
}
|
|
759
|
-
function
|
|
759
|
+
function Un(e, t, n) {
|
|
760
760
|
const r = [], o = /* @__PURE__ */ new Set(), i = (s, a) => {
|
|
761
|
-
const c =
|
|
761
|
+
const c = w(s);
|
|
762
762
|
!c || o.has(c) || (o.add(c), r.push({
|
|
763
763
|
normalized: c,
|
|
764
|
-
stripped:
|
|
764
|
+
stripped: M(c),
|
|
765
765
|
score: a
|
|
766
766
|
}));
|
|
767
767
|
};
|
|
@@ -775,7 +775,7 @@ function zn(e, t, n) {
|
|
|
775
775
|
s !== n && i(e.structuredParts[s], 180 - Math.abs(s - n) * 20);
|
|
776
776
|
return e.fullText && i(e.fullText, 130), r;
|
|
777
777
|
}
|
|
778
|
-
function
|
|
778
|
+
function jn(e, t, n) {
|
|
779
779
|
let r = 0;
|
|
780
780
|
for (const o of n) {
|
|
781
781
|
let i = 0;
|
|
@@ -783,10 +783,10 @@ function Kn(e, t, n) {
|
|
|
783
783
|
}
|
|
784
784
|
return r;
|
|
785
785
|
}
|
|
786
|
-
function
|
|
786
|
+
function Gn(e, t) {
|
|
787
787
|
let n = 0, r = 0;
|
|
788
788
|
for (let o = 0; o < e.aliasesByLevel.length; o += 1) {
|
|
789
|
-
const i =
|
|
789
|
+
const i = Yn(
|
|
790
790
|
e.aliasesByLevel[o],
|
|
791
791
|
t.structuredParts[o] || "",
|
|
792
792
|
t.fullText,
|
|
@@ -797,21 +797,21 @@ function Vn(e, t) {
|
|
|
797
797
|
}
|
|
798
798
|
return n += r * 18 + e.labels.length * 4, t.structuredParts.length > e.labels.length && (n -= (t.structuredParts.length - e.labels.length) * 10), n;
|
|
799
799
|
}
|
|
800
|
-
function
|
|
800
|
+
function Yn(e, t, n, r, o) {
|
|
801
801
|
const i = [60, 95, 135, 160][o] || 160;
|
|
802
802
|
let s = 0;
|
|
803
803
|
for (const a of e) {
|
|
804
804
|
let c = 0;
|
|
805
|
-
const l =
|
|
806
|
-
t && (t === a ? c = Math.max(c, i + 130 + a.length) : t.includes(a) || a.includes(t) ? c = Math.max(c, i + 95 + Math.min(a.length, t.length)) : l &&
|
|
805
|
+
const l = M(a);
|
|
806
|
+
t && (t === a ? c = Math.max(c, i + 130 + a.length) : t.includes(a) || a.includes(t) ? c = Math.max(c, i + 95 + Math.min(a.length, t.length)) : l && M(t) === l && (c = Math.max(c, i + 80 + l.length))), n && (n.includes(a) ? c = Math.max(c, i + 50 + a.length) : l && r.includes(l) && (c = Math.max(c, i + 35 + l.length))), c > s && (s = c);
|
|
807
807
|
}
|
|
808
808
|
return s;
|
|
809
809
|
}
|
|
810
|
-
function
|
|
811
|
-
const t = f(e), n =
|
|
810
|
+
function Wn(e) {
|
|
811
|
+
const t = f(e), n = w(t);
|
|
812
812
|
if (!n) return [];
|
|
813
|
-
const r = /* @__PURE__ */ new Set([n]), o =
|
|
814
|
-
o && !
|
|
813
|
+
const r = /* @__PURE__ */ new Set([n]), o = M(n);
|
|
814
|
+
o && !Bn.has(t) && r.add(o);
|
|
815
815
|
const i = {
|
|
816
816
|
内蒙古自治区: "内蒙古",
|
|
817
817
|
广西壮族自治区: "广西",
|
|
@@ -823,19 +823,19 @@ function Un(e) {
|
|
|
823
823
|
};
|
|
824
824
|
return i[t] && r.add(i[t]), Array.from(r).filter(Boolean);
|
|
825
825
|
}
|
|
826
|
-
function
|
|
827
|
-
if (
|
|
826
|
+
function Xn() {
|
|
827
|
+
if (le) return le;
|
|
828
828
|
const e = globalThis.__SMART_FILL_ADDRESS_MAP__, t = e == null ? void 0 : e.data, n = Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.data) ? t.data : [];
|
|
829
|
-
return
|
|
829
|
+
return le = Zn(n), le;
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Zn(e) {
|
|
832
832
|
const t = [], n = /* @__PURE__ */ new Set(), r = (o) => {
|
|
833
833
|
const i = o.map((a) => f(a)).filter(Boolean);
|
|
834
834
|
if (!i.length) return;
|
|
835
835
|
const s = i.join(">");
|
|
836
836
|
n.has(s) || (n.add(s), t.push({
|
|
837
837
|
labels: i,
|
|
838
|
-
aliasesByLevel: i.map((a) =>
|
|
838
|
+
aliasesByLevel: i.map((a) => Wn(a))
|
|
839
839
|
}));
|
|
840
840
|
};
|
|
841
841
|
for (const o of e)
|
|
@@ -847,36 +847,36 @@ function Gn(e) {
|
|
|
847
847
|
}
|
|
848
848
|
return t;
|
|
849
849
|
}
|
|
850
|
-
function
|
|
851
|
-
const n =
|
|
850
|
+
function Z(e, t) {
|
|
851
|
+
const n = _e(t);
|
|
852
852
|
if (!n.length) return null;
|
|
853
853
|
let r = null, o = 0;
|
|
854
854
|
for (const i of e) {
|
|
855
|
-
const s =
|
|
855
|
+
const s = L(i.value), a = L(i.label);
|
|
856
856
|
for (const c of n) {
|
|
857
857
|
let l = 0;
|
|
858
|
-
c === s || c === a ? l = 120 : s && c.includes(s) || a && c.includes(a) ? l = 100 : s && s.includes(c) || a && a.includes(c) ? l = 90 : (s &&
|
|
858
|
+
c === s || c === a ? l = 120 : s && c.includes(s) || a && c.includes(a) ? l = 100 : s && s.includes(c) || a && a.includes(c) ? l = 90 : (s && de(s) === de(c) || a && de(a) === de(c)) && (l = 80), l > o && (o = l, r = i);
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
return o >= 80 ? r : null;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
863
|
+
function _e(e) {
|
|
864
864
|
if (Array.isArray(e))
|
|
865
|
-
return e.flatMap((n) =>
|
|
865
|
+
return e.flatMap((n) => _e(n));
|
|
866
866
|
if (typeof e == "object" && e) {
|
|
867
867
|
const n = e;
|
|
868
|
-
return [n.label, n.value, n.text, n.answer, n.name].filter((r) => r != null).map((r) =>
|
|
868
|
+
return [n.label, n.value, n.text, n.answer, n.name].filter((r) => r != null).map((r) => L(r)).filter(Boolean);
|
|
869
869
|
}
|
|
870
|
-
const t =
|
|
870
|
+
const t = L(e);
|
|
871
871
|
return t ? [t] : [];
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function L(e) {
|
|
874
874
|
return String(e ?? "").replace(/\s+/g, "").replace(/[::,,。.、()()\-_/]/g, "").trim().toLowerCase();
|
|
875
875
|
}
|
|
876
|
-
function
|
|
877
|
-
return
|
|
876
|
+
function de(e) {
|
|
877
|
+
return L(e).replace(/(请选择|选择|状态|情况|类型|方式|所属|是否)$/g, "");
|
|
878
878
|
}
|
|
879
|
-
const
|
|
879
|
+
const Se = [
|
|
880
880
|
".ant-select-item-option",
|
|
881
881
|
".el-select-dropdown__item",
|
|
882
882
|
".el-select-v2__option",
|
|
@@ -893,113 +893,120 @@ const me = [
|
|
|
893
893
|
".van-dropdown-item__option",
|
|
894
894
|
".van-radio",
|
|
895
895
|
"[role='option']"
|
|
896
|
-
].join(", "),
|
|
896
|
+
].join(", "), Jn = [
|
|
897
897
|
".el-cascader-panel .el-cascader-menu",
|
|
898
898
|
".ant-cascader-menu",
|
|
899
899
|
".van-cascader__options",
|
|
900
900
|
".n-cascader-menu",
|
|
901
901
|
".arco-cascader-list"
|
|
902
|
-
].join(", "),
|
|
902
|
+
].join(", "), Qn = [
|
|
903
903
|
".el-cascader-node",
|
|
904
904
|
".ant-cascader-menu-item",
|
|
905
905
|
".van-cascader__option",
|
|
906
906
|
".n-cascader-node",
|
|
907
907
|
".arco-cascader-option"
|
|
908
|
-
].join(", "),
|
|
909
|
-
async function
|
|
910
|
-
const o =
|
|
911
|
-
return e instanceof HTMLSelectElement ?
|
|
908
|
+
].join(", "), er = ".van-picker__confirm, .van-picker__toolbar .van-picker__confirm";
|
|
909
|
+
async function tr(e, t, n, r) {
|
|
910
|
+
const o = Ht(t, r);
|
|
911
|
+
return e instanceof HTMLSelectElement ? nr(e, o) : I(e) || n === "cascader" ? rr(e, o) : (ee(e) || k(e) || n === "select" || n === "date", et(e, o));
|
|
912
912
|
}
|
|
913
|
-
function
|
|
913
|
+
function Pt(e) {
|
|
914
914
|
if (e instanceof HTMLSelectElement) {
|
|
915
915
|
const n = e.options[e.selectedIndex];
|
|
916
916
|
return f((n == null ? void 0 : n.textContent) || e.value);
|
|
917
917
|
}
|
|
918
|
-
if (
|
|
918
|
+
if (I(e)) {
|
|
919
919
|
const n = e.querySelector("input");
|
|
920
920
|
if (n != null && n.value) return f(n.value);
|
|
921
921
|
const r = e.querySelector(".el-cascader__tags-text, .el-cascader__label");
|
|
922
922
|
return f((r == null ? void 0 : r.textContent) || "");
|
|
923
923
|
}
|
|
924
|
-
if (
|
|
925
|
-
return
|
|
924
|
+
if (ee(e) || k(e))
|
|
925
|
+
return kn(e);
|
|
926
926
|
const t = e.querySelector("input, textarea");
|
|
927
927
|
return f((t == null ? void 0 : t.value) || e.textContent || "");
|
|
928
928
|
}
|
|
929
|
-
async function
|
|
929
|
+
async function nr(e, t) {
|
|
930
930
|
const n = Array.from(e.options).map((o) => ({
|
|
931
931
|
source: o,
|
|
932
932
|
value: o.value,
|
|
933
933
|
label: o.textContent
|
|
934
|
-
})), r =
|
|
934
|
+
})), r = Z(n, t.searchValue);
|
|
935
935
|
if ((r == null ? void 0 : r.source) instanceof HTMLOptionElement) {
|
|
936
|
-
|
|
936
|
+
if (r.source.disabled)
|
|
937
|
+
throw Kt(e), new Error("下拉目标选项已禁用");
|
|
938
|
+
P(e, r.source.value), E(e);
|
|
937
939
|
return;
|
|
938
940
|
}
|
|
939
|
-
if (!
|
|
941
|
+
if (!ye(e, t))
|
|
940
942
|
throw new Error("原生下拉框中没有匹配到对应选项");
|
|
941
943
|
}
|
|
942
|
-
async function
|
|
943
|
-
const n =
|
|
944
|
-
if (
|
|
945
|
-
const r = new Set(
|
|
944
|
+
async function et(e, t) {
|
|
945
|
+
const n = te(e) || e;
|
|
946
|
+
if (Ce(n, t.searchValue)) return;
|
|
947
|
+
const r = new Set(re());
|
|
946
948
|
try {
|
|
947
|
-
if (!await
|
|
948
|
-
if (
|
|
949
|
+
if (!await or(n)) {
|
|
950
|
+
if (ye(n, t)) return;
|
|
949
951
|
throw new Error("自定义下拉框未能成功展开");
|
|
950
952
|
}
|
|
951
|
-
const i = await
|
|
952
|
-
if (
|
|
953
|
-
|
|
953
|
+
const i = await hr(n, r), s = await Nt(t.searchValue, i, !0, !0);
|
|
954
|
+
if (s != null && s.source && z(s.source))
|
|
955
|
+
throw await W(n), await dr(n), new Error("下拉目标选项已禁用");
|
|
956
|
+
const a = await sr(t.searchValue, i, !0);
|
|
957
|
+
if (!(a != null && a.source)) {
|
|
958
|
+
if (await W(n), ye(n, t)) return;
|
|
954
959
|
throw new Error("自定义下拉框展开后未找到匹配选项");
|
|
955
960
|
}
|
|
956
|
-
if (
|
|
961
|
+
if (R(a.source), await b(120), yr(), E(n), await b(120), Ce(n, t.searchValue) || ye(n, t) && Ce(n, t.searchValue))
|
|
957
962
|
return;
|
|
958
963
|
throw new Error("自定义下拉框点击选项后未成功回填");
|
|
959
964
|
} finally {
|
|
960
|
-
await
|
|
965
|
+
await W(n), await b(80);
|
|
961
966
|
}
|
|
962
967
|
}
|
|
963
|
-
async function
|
|
968
|
+
async function rr(e, t) {
|
|
964
969
|
const n = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader") || e;
|
|
965
|
-
if (
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
970
|
+
if (rt(n, t.searchValue)) return;
|
|
971
|
+
be(n) && (await tt(n), await b(120));
|
|
972
|
+
let r = "级联选择框匹配失败";
|
|
973
|
+
try {
|
|
974
|
+
if (await ir(n)) {
|
|
975
|
+
const i = await lr(t.searchValue);
|
|
976
|
+
if (await b(180), await W(n), await b(120), i && rt(n, t.searchValue)) {
|
|
977
|
+
E(n);
|
|
978
|
+
return;
|
|
974
979
|
}
|
|
975
|
-
} finally {
|
|
976
|
-
await ve(n), await g(80);
|
|
977
980
|
}
|
|
978
|
-
|
|
981
|
+
} catch (o) {
|
|
982
|
+
o instanceof Error && o.message && (r = o.message);
|
|
983
|
+
} finally {
|
|
984
|
+
await W(n), await b(80);
|
|
979
985
|
}
|
|
986
|
+
throw await tt(n), new Error(r);
|
|
980
987
|
}
|
|
981
|
-
function
|
|
988
|
+
function Ht(e, t) {
|
|
982
989
|
var s;
|
|
983
|
-
const n = (s = t == null ? void 0 : t.options) != null && s.length ?
|
|
990
|
+
const n = (s = t == null ? void 0 : t.options) != null && s.length ? Z(
|
|
984
991
|
t.options.map((a) => ({
|
|
985
992
|
value: String(a.value),
|
|
986
993
|
label: a.label
|
|
987
994
|
})),
|
|
988
995
|
e
|
|
989
|
-
) : null, r =
|
|
996
|
+
) : null, r = V(e), o = f(String((n == null ? void 0 : n.label) ?? r ?? "")), i = f(String((n == null ? void 0 : n.value) ?? (n == null ? void 0 : n.label) ?? r ?? ""));
|
|
990
997
|
return {
|
|
991
998
|
searchValue: n ? [e, n.label, n.value] : e,
|
|
992
999
|
fillValue: i,
|
|
993
1000
|
displayValue: o
|
|
994
1001
|
};
|
|
995
1002
|
}
|
|
996
|
-
async function
|
|
997
|
-
const t =
|
|
1003
|
+
async function or(e) {
|
|
1004
|
+
const t = Ge(e);
|
|
998
1005
|
for (const n of t)
|
|
999
|
-
if (
|
|
1006
|
+
if (jt(n), R(n), await b(160), nt(e) || (Gt(n), await b(180), nt(e))) return !0;
|
|
1000
1007
|
return !1;
|
|
1001
1008
|
}
|
|
1002
|
-
async function
|
|
1009
|
+
async function ir(e) {
|
|
1003
1010
|
const t = [
|
|
1004
1011
|
e,
|
|
1005
1012
|
e.querySelector(".el-input__wrapper"),
|
|
@@ -1008,167 +1015,219 @@ async function tr(e) {
|
|
|
1008
1015
|
e.querySelector("input")
|
|
1009
1016
|
].filter((n) => n instanceof HTMLElement);
|
|
1010
1017
|
for (const n of t)
|
|
1011
|
-
if (n.scrollIntoView({ block: "nearest", inline: "nearest" }),
|
|
1018
|
+
if (n.scrollIntoView({ block: "nearest", inline: "nearest" }), jt(n), R(n), await b(180), Y().length || (Gt(n), await b(180), Y().length)) return !0;
|
|
1012
1019
|
return !1;
|
|
1013
1020
|
}
|
|
1014
|
-
async function
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
+
async function sr(e, t, n = !1) {
|
|
1022
|
+
return Nt(e, t, n, !1);
|
|
1023
|
+
}
|
|
1024
|
+
async function Nt(e, t, n = !1, r = !1) {
|
|
1025
|
+
for (let o = 0; o < 12; o += 1) {
|
|
1026
|
+
const i = Z(
|
|
1027
|
+
Bt(t, n, r).map((s) => ({
|
|
1028
|
+
source: s,
|
|
1029
|
+
value: ar(s),
|
|
1030
|
+
label: cr(s)
|
|
1021
1031
|
})),
|
|
1022
1032
|
e
|
|
1023
1033
|
);
|
|
1024
|
-
if (
|
|
1025
|
-
await
|
|
1034
|
+
if (i) return i;
|
|
1035
|
+
await b(100);
|
|
1026
1036
|
}
|
|
1027
1037
|
return null;
|
|
1028
1038
|
}
|
|
1029
|
-
function
|
|
1039
|
+
function ar(e) {
|
|
1030
1040
|
return e.getAttribute("data-value") || e.getAttribute("data-name") || e.getAttribute("value") || e.getAttribute("name") || e.textContent || "";
|
|
1031
1041
|
}
|
|
1032
|
-
function
|
|
1042
|
+
function cr(e) {
|
|
1033
1043
|
var t;
|
|
1034
1044
|
return f(
|
|
1035
1045
|
((t = e.querySelector(".van-action-sheet__name, .el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label")) == null ? void 0 : t.textContent) || e.textContent || ""
|
|
1036
1046
|
);
|
|
1037
1047
|
}
|
|
1038
|
-
async function
|
|
1039
|
-
const t =
|
|
1048
|
+
async function lr(e) {
|
|
1049
|
+
const t = ke(e), n = je(e, t), r = Ut(e), o = Math.max(n.length, r.length, 1);
|
|
1040
1050
|
if (!t.fullText && !t.structuredParts.length && !r.length)
|
|
1041
1051
|
return !1;
|
|
1042
1052
|
for (let i = 0; i < o; i += 1) {
|
|
1043
|
-
const s =
|
|
1053
|
+
const s = Y();
|
|
1044
1054
|
if (!s.length) return i > 0;
|
|
1045
|
-
const a = s[Math.min(i, s.length - 1)], c = Array.from(a.querySelectorAll(
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1055
|
+
const a = s[Math.min(i, s.length - 1)], c = Array.from(a.querySelectorAll(Qn)), l = c.filter((h) => !z(h));
|
|
1056
|
+
let u = null;
|
|
1057
|
+
if (n.length || t.structuredParts.length) {
|
|
1058
|
+
const h = c.filter((y) => z(y));
|
|
1059
|
+
h.length && (u = Qe(h, t, n, i));
|
|
1060
|
+
}
|
|
1061
|
+
if (!l.length) {
|
|
1062
|
+
if (u) throw new Error("级联目标选项已禁用");
|
|
1063
|
+
return !1;
|
|
1064
|
+
}
|
|
1065
|
+
let p = null;
|
|
1066
|
+
if ((n.length || t.structuredParts.length) && (p = Qe(l, t, n, i)), !p && !u && r[i]) {
|
|
1067
|
+
const h = Z(
|
|
1068
|
+
c.filter((y) => z(y)).map((y) => {
|
|
1069
|
+
var x;
|
|
1052
1070
|
return {
|
|
1053
|
-
source:
|
|
1054
|
-
value:
|
|
1055
|
-
label: ((
|
|
1071
|
+
source: y,
|
|
1072
|
+
value: y.getAttribute("data-value") || y.textContent,
|
|
1073
|
+
label: ((x = y.querySelector(".el-cascader-node__label")) == null ? void 0 : x.textContent) || y.textContent
|
|
1056
1074
|
};
|
|
1057
1075
|
}),
|
|
1058
1076
|
r[i]
|
|
1059
1077
|
);
|
|
1060
|
-
|
|
1078
|
+
u = (h == null ? void 0 : h.source) instanceof HTMLElement ? h.source : null;
|
|
1061
1079
|
}
|
|
1062
|
-
if (!
|
|
1063
|
-
|
|
1080
|
+
if (!p && u)
|
|
1081
|
+
throw new Error("级联目标选项已禁用");
|
|
1082
|
+
if (!p && r[i]) {
|
|
1083
|
+
const h = Z(
|
|
1084
|
+
l.map((y) => {
|
|
1085
|
+
var x;
|
|
1086
|
+
return {
|
|
1087
|
+
source: y,
|
|
1088
|
+
value: y.getAttribute("data-value") || y.textContent,
|
|
1089
|
+
label: ((x = y.querySelector(".el-cascader-node__label")) == null ? void 0 : x.textContent) || y.textContent
|
|
1090
|
+
};
|
|
1091
|
+
}),
|
|
1092
|
+
r[i]
|
|
1093
|
+
);
|
|
1094
|
+
p = (h == null ? void 0 : h.source) instanceof HTMLElement ? h.source : null;
|
|
1095
|
+
}
|
|
1096
|
+
if (!p) return !1;
|
|
1097
|
+
if (R(p), await b(220), !Y().length) return !0;
|
|
1064
1098
|
}
|
|
1065
|
-
return !
|
|
1099
|
+
return !Y().length || !0;
|
|
1066
1100
|
}
|
|
1067
|
-
function
|
|
1068
|
-
const n =
|
|
1101
|
+
function ye(e, t) {
|
|
1102
|
+
const n = pr(t) ? t : Ht(t), r = n.displayValue || V(t), o = n.fillValue || r;
|
|
1069
1103
|
if (!r && !o) return !1;
|
|
1070
|
-
const i =
|
|
1104
|
+
const i = te(e) || e;
|
|
1071
1105
|
if (k(i))
|
|
1072
|
-
return
|
|
1106
|
+
return fr(i, r, o);
|
|
1073
1107
|
if (e instanceof HTMLSelectElement) {
|
|
1074
1108
|
let l = Array.from(e.options).find((u) => u.dataset.smartFillFallbackOption === "true");
|
|
1075
|
-
return l || (l = document.createElement("option"), l.dataset.smartFillFallbackOption = "true", e.appendChild(l)), l.value = o, l.textContent = r || o, l.selected = !0,
|
|
1109
|
+
return l || (l = document.createElement("option"), l.dataset.smartFillFallbackOption = "true", e.appendChild(l)), l.value = o, l.textContent = r || o, l.selected = !0, P(e, o), E(e), !0;
|
|
1076
1110
|
}
|
|
1077
1111
|
const s = e.querySelector('input:not([type="hidden"])');
|
|
1078
1112
|
if (!(s instanceof HTMLInputElement) || s.disabled) return !1;
|
|
1079
1113
|
const a = s.readOnly, c = s.hasAttribute("readonly");
|
|
1080
1114
|
try {
|
|
1081
|
-
return a && (s.readOnly = !1, s.removeAttribute("readonly")), s.focus(),
|
|
1115
|
+
return a && (s.readOnly = !1, s.removeAttribute("readonly")), s.focus(), P(s, r), s.dispatchEvent(new InputEvent("input", {
|
|
1082
1116
|
bubbles: !0,
|
|
1083
1117
|
composed: !0,
|
|
1084
1118
|
data: r,
|
|
1085
1119
|
inputType: "insertReplacementText"
|
|
1086
|
-
})), s.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })),
|
|
1120
|
+
})), s.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), E(s), E(e), s.blur(), !0;
|
|
1087
1121
|
} catch {
|
|
1088
1122
|
return !1;
|
|
1089
1123
|
} finally {
|
|
1090
1124
|
a && (s.readOnly = !0, c && s.setAttribute("readonly", ""));
|
|
1091
1125
|
}
|
|
1092
1126
|
}
|
|
1093
|
-
function
|
|
1094
|
-
const t =
|
|
1127
|
+
function ur(e) {
|
|
1128
|
+
const t = ke(e), n = je(e, t);
|
|
1095
1129
|
if (n.length) return n.join(" / ");
|
|
1096
|
-
const r =
|
|
1097
|
-
return r.length ? r.join(" / ") :
|
|
1130
|
+
const r = Ut(e);
|
|
1131
|
+
return r.length ? r.join(" / ") : Ue(e);
|
|
1098
1132
|
}
|
|
1099
|
-
function
|
|
1133
|
+
function $t(e) {
|
|
1100
1134
|
const t = e.querySelector("input");
|
|
1101
1135
|
return t instanceof HTMLInputElement ? t : null;
|
|
1102
1136
|
}
|
|
1103
|
-
function
|
|
1104
|
-
const t =
|
|
1137
|
+
function zt(e) {
|
|
1138
|
+
const t = $t(e);
|
|
1105
1139
|
if (t != null && t.value) return f(t.value);
|
|
1106
1140
|
const n = e.querySelector(".el-cascader__tags-text, .el-cascader__label");
|
|
1107
1141
|
return f((n == null ? void 0 : n.textContent) || "");
|
|
1108
1142
|
}
|
|
1109
|
-
function
|
|
1110
|
-
return !!
|
|
1143
|
+
function be(e) {
|
|
1144
|
+
return !!w(zt(e));
|
|
1111
1145
|
}
|
|
1112
|
-
async function
|
|
1113
|
-
if (!
|
|
1146
|
+
async function tt(e) {
|
|
1147
|
+
if (!be(e)) return;
|
|
1114
1148
|
const t = e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector");
|
|
1115
|
-
t && (t.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !0 })), t.dispatchEvent(new MouseEvent("mouseover", { bubbles: !0 })), await
|
|
1149
|
+
t && (t.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !0 })), t.dispatchEvent(new MouseEvent("mouseover", { bubbles: !0 })), await b(80));
|
|
1116
1150
|
const n = e.querySelector(
|
|
1117
1151
|
".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-cascader-picker-clear, .van-icon-clear"
|
|
1118
1152
|
);
|
|
1119
|
-
if (n && (
|
|
1153
|
+
if (n && (R(n), await b(180), !be(e)))
|
|
1120
1154
|
return;
|
|
1121
|
-
const r =
|
|
1155
|
+
const r = $t(e);
|
|
1122
1156
|
if (r && !r.disabled) {
|
|
1123
1157
|
const i = r.readOnly, s = r.hasAttribute("readonly");
|
|
1124
1158
|
try {
|
|
1125
|
-
i && (r.readOnly = !1, r.removeAttribute("readonly")),
|
|
1159
|
+
i && (r.readOnly = !1, r.removeAttribute("readonly")), P(r, ""), r.dispatchEvent(new InputEvent("input", {
|
|
1126
1160
|
bubbles: !0,
|
|
1127
1161
|
composed: !0,
|
|
1128
1162
|
inputType: "deleteContentBackward"
|
|
1129
|
-
})), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })),
|
|
1163
|
+
})), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), E(r);
|
|
1130
1164
|
} finally {
|
|
1131
1165
|
i && (r.readOnly = !0, s && r.setAttribute("readonly", ""));
|
|
1132
1166
|
}
|
|
1133
|
-
await
|
|
1167
|
+
await b(120);
|
|
1134
1168
|
}
|
|
1135
1169
|
const o = e.querySelector(".el-tag__close, .el-cascader__tags .el-icon-close");
|
|
1136
|
-
o &&
|
|
1170
|
+
o && be(e) && (R(o), await b(120));
|
|
1171
|
+
}
|
|
1172
|
+
async function dr(e) {
|
|
1173
|
+
if (e instanceof HTMLSelectElement) {
|
|
1174
|
+
Kt(e);
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (k(e)) {
|
|
1178
|
+
Vt(e);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
const t = e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector, .ant-picker, .n-base-selection, .arco-select-view, .semi-select-selection");
|
|
1182
|
+
t && (t.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !0 })), t.dispatchEvent(new MouseEvent("mouseover", { bubbles: !0 })), await b(80));
|
|
1183
|
+
const n = e.querySelector(
|
|
1184
|
+
".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-picker-clear, .ant-cascader-picker-clear, .n-base-clear, .van-icon-clear"
|
|
1185
|
+
);
|
|
1186
|
+
n && (R(n), await b(180));
|
|
1187
|
+
const r = e.querySelector('input:not([type="hidden"])');
|
|
1188
|
+
r && !r.disabled && q(r, "");
|
|
1189
|
+
for (const o of e.querySelectorAll('input[type="hidden"]'))
|
|
1190
|
+
q(o, "");
|
|
1191
|
+
E(e);
|
|
1192
|
+
}
|
|
1193
|
+
function Kt(e) {
|
|
1194
|
+
const t = Array.from(e.options).find((n) => n.value === "");
|
|
1195
|
+
t ? P(e, t.value) : (e.selectedIndex = -1, P(e, "")), E(e);
|
|
1137
1196
|
}
|
|
1138
|
-
function
|
|
1139
|
-
|
|
1197
|
+
function fr(e, t, n) {
|
|
1198
|
+
Vt(e);
|
|
1140
1199
|
const r = e.querySelector(".van-field__control"), o = Array.from(e.querySelectorAll('input[type="hidden"]')), i = Array.from(e.querySelectorAll('input:not([type="hidden"])'));
|
|
1141
|
-
r instanceof HTMLInputElement ?
|
|
1200
|
+
r instanceof HTMLInputElement ? q(r, t || n) : r instanceof HTMLElement && (r.textContent = t || n);
|
|
1142
1201
|
for (const s of o)
|
|
1143
|
-
|
|
1202
|
+
q(s, n);
|
|
1144
1203
|
for (const s of i)
|
|
1145
|
-
r !== s &&
|
|
1146
|
-
return
|
|
1204
|
+
r !== s && q(s, t || n);
|
|
1205
|
+
return E(e), !0;
|
|
1147
1206
|
}
|
|
1148
|
-
function
|
|
1207
|
+
function Vt(e) {
|
|
1149
1208
|
const t = e.querySelector(".van-field__control");
|
|
1150
|
-
t instanceof HTMLInputElement ?
|
|
1209
|
+
t instanceof HTMLInputElement ? q(t, "") : t instanceof HTMLElement && (t.textContent = "");
|
|
1151
1210
|
for (const n of e.querySelectorAll("input"))
|
|
1152
|
-
|
|
1211
|
+
q(n, "");
|
|
1153
1212
|
}
|
|
1154
|
-
function
|
|
1213
|
+
function q(e, t) {
|
|
1155
1214
|
if (e.disabled) return;
|
|
1156
1215
|
const n = e.readOnly, r = e.hasAttribute("readonly");
|
|
1157
1216
|
try {
|
|
1158
|
-
n && (e.readOnly = !1, e.removeAttribute("readonly")),
|
|
1217
|
+
n && (e.readOnly = !1, e.removeAttribute("readonly")), P(e, t), e.dispatchEvent(new InputEvent("input", {
|
|
1159
1218
|
bubbles: !0,
|
|
1160
1219
|
composed: !0,
|
|
1161
1220
|
data: t,
|
|
1162
1221
|
inputType: t ? "insertReplacementText" : "deleteContentBackward"
|
|
1163
|
-
})), e.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })),
|
|
1222
|
+
})), e.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), E(e);
|
|
1164
1223
|
} finally {
|
|
1165
1224
|
n && (e.readOnly = !0, r && e.setAttribute("readonly", ""));
|
|
1166
1225
|
}
|
|
1167
1226
|
}
|
|
1168
|
-
function
|
|
1227
|
+
function pr(e) {
|
|
1169
1228
|
return typeof e == "object" && e != null && "searchValue" in e && "fillValue" in e && "displayValue" in e;
|
|
1170
1229
|
}
|
|
1171
|
-
function
|
|
1230
|
+
function Ge(e) {
|
|
1172
1231
|
return [
|
|
1173
1232
|
e,
|
|
1174
1233
|
e.querySelector(".van-field__control"),
|
|
@@ -1188,76 +1247,79 @@ function je(e) {
|
|
|
1188
1247
|
e.querySelector(".select__wrapper")
|
|
1189
1248
|
].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
|
|
1190
1249
|
}
|
|
1191
|
-
function
|
|
1192
|
-
return (e.length ? e :
|
|
1250
|
+
function Bt(e, t, n = !1) {
|
|
1251
|
+
return (e.length ? e : re()).flatMap((i) => i.matches(Se) ? [i] : Array.from(i.querySelectorAll(Se))).filter((i, s, a) => a.indexOf(i) === s).filter((i) => n ? t ? !0 : H(i) : (t || H(i)) && !z(i));
|
|
1193
1252
|
}
|
|
1194
|
-
function
|
|
1195
|
-
return Array.from(document.querySelectorAll(
|
|
1253
|
+
function Y() {
|
|
1254
|
+
return Array.from(document.querySelectorAll(Jn)).filter(H);
|
|
1196
1255
|
}
|
|
1197
|
-
async function
|
|
1256
|
+
async function hr(e, t) {
|
|
1198
1257
|
for (let n = 0; n < 10; n += 1) {
|
|
1199
|
-
const r =
|
|
1258
|
+
const r = gr(e, t);
|
|
1200
1259
|
if (r.length) return r;
|
|
1201
|
-
await
|
|
1260
|
+
await b(80);
|
|
1202
1261
|
}
|
|
1203
|
-
return
|
|
1262
|
+
return re().filter(H);
|
|
1204
1263
|
}
|
|
1205
|
-
function
|
|
1206
|
-
const n =
|
|
1264
|
+
function gr(e, t) {
|
|
1265
|
+
const n = re(), r = n.filter((i) => !t.has(i));
|
|
1207
1266
|
if (r.length)
|
|
1208
|
-
return r.sort((i, s) =>
|
|
1267
|
+
return r.sort((i, s) => fe(s) - fe(i));
|
|
1209
1268
|
const o = new Set(
|
|
1210
|
-
|
|
1269
|
+
Ge(e).flatMap((i) => [i.getAttribute("aria-controls"), i.getAttribute("aria-owns")]).filter((i) => !!i)
|
|
1211
1270
|
);
|
|
1212
1271
|
if (o.size) {
|
|
1213
1272
|
const i = n.filter((s) => o.has(s.id));
|
|
1214
1273
|
if (i.length) return i;
|
|
1215
1274
|
}
|
|
1216
|
-
return n.filter((i) =>
|
|
1275
|
+
return n.filter((i) => H(i) && (i.querySelector(Se) || i.matches(Se))).sort((i, s) => fe(s) - fe(i)).slice(0, 1);
|
|
1217
1276
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return
|
|
1277
|
+
function nt(e) {
|
|
1278
|
+
return Bt(re().filter(H), !1).length > 0 ? !0 : Ge(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused"));
|
|
1220
1279
|
}
|
|
1221
|
-
function
|
|
1222
|
-
const n =
|
|
1280
|
+
function rt(e, t) {
|
|
1281
|
+
const n = zt(e), r = w(n);
|
|
1223
1282
|
if (!r) return !1;
|
|
1224
|
-
const o =
|
|
1225
|
-
if (
|
|
1226
|
-
const s =
|
|
1227
|
-
if (
|
|
1228
|
-
const l =
|
|
1229
|
-
if (
|
|
1230
|
-
const u =
|
|
1231
|
-
return
|
|
1232
|
-
}
|
|
1233
|
-
function
|
|
1234
|
-
const n =
|
|
1283
|
+
const o = Ue(t), i = w(o);
|
|
1284
|
+
if (ue(r, i)) return !0;
|
|
1285
|
+
const s = ke(t), a = je(t, s), c = w(a.join(""));
|
|
1286
|
+
if (ue(r, c)) return !0;
|
|
1287
|
+
const l = w(ur(t));
|
|
1288
|
+
if (ue(r, l)) return !0;
|
|
1289
|
+
const u = w(s.structuredParts.join(""));
|
|
1290
|
+
return ue(r, u);
|
|
1291
|
+
}
|
|
1292
|
+
function Ce(e, t) {
|
|
1293
|
+
const n = L(Pt(e));
|
|
1235
1294
|
if (!n) return !1;
|
|
1236
|
-
const r =
|
|
1295
|
+
const r = _e(t);
|
|
1237
1296
|
if (!r.length) {
|
|
1238
|
-
const o =
|
|
1297
|
+
const o = L(V(t));
|
|
1239
1298
|
return o ? n === o || n.includes(o) || o.includes(n) : !1;
|
|
1240
1299
|
}
|
|
1241
1300
|
return r.some((o) => {
|
|
1242
|
-
const i =
|
|
1301
|
+
const i = L(o);
|
|
1243
1302
|
return !!i && (n === i || n.includes(i) || i.includes(n));
|
|
1244
1303
|
});
|
|
1245
1304
|
}
|
|
1246
|
-
function
|
|
1247
|
-
|
|
1248
|
-
|
|
1305
|
+
function z(e) {
|
|
1306
|
+
return e instanceof HTMLOptionElement ? e.disabled : e.classList.contains("is-disabled") || e.classList.contains("ant-select-item-option-disabled") || e.classList.contains("van-cascader__option--disabled") || e.classList.contains("n-cascader-node--disabled") || e.classList.contains("arco-cascader-option-disabled") || e.classList.contains("arco-select-option-disabled") || e.getAttribute("aria-disabled") === "true";
|
|
1307
|
+
}
|
|
1308
|
+
function yr() {
|
|
1309
|
+
const e = document.querySelector(er);
|
|
1310
|
+
e && H(e) && R(e);
|
|
1249
1311
|
}
|
|
1250
|
-
async function
|
|
1251
|
-
e == null || e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await
|
|
1312
|
+
async function W(e) {
|
|
1313
|
+
e == null || e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await b(120);
|
|
1252
1314
|
}
|
|
1253
|
-
function
|
|
1254
|
-
return Array.from(document.querySelectorAll(
|
|
1315
|
+
function re() {
|
|
1316
|
+
return Array.from(document.querySelectorAll(br()));
|
|
1255
1317
|
}
|
|
1256
|
-
function
|
|
1318
|
+
function fe(e) {
|
|
1257
1319
|
const t = e.getBoundingClientRect(), n = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
|
|
1258
1320
|
return (Number.isNaN(n) ? 0 : n) * 10 + t.width * t.height;
|
|
1259
1321
|
}
|
|
1260
|
-
function
|
|
1322
|
+
function br() {
|
|
1261
1323
|
return [
|
|
1262
1324
|
".el-select-dropdown",
|
|
1263
1325
|
".el-cascader__dropdown",
|
|
@@ -1283,162 +1345,162 @@ function pr() {
|
|
|
1283
1345
|
"[role='listbox']"
|
|
1284
1346
|
].join(", ");
|
|
1285
1347
|
}
|
|
1286
|
-
function
|
|
1348
|
+
function V(e) {
|
|
1287
1349
|
if (e == null) return "";
|
|
1288
1350
|
if (typeof e == "string" || typeof e == "number" || typeof e == "boolean")
|
|
1289
1351
|
return f(String(e));
|
|
1290
1352
|
if (Array.isArray(e))
|
|
1291
|
-
return e.map((t) =>
|
|
1353
|
+
return e.map((t) => V(t)).filter(Boolean).join(" ");
|
|
1292
1354
|
if (typeof e == "object") {
|
|
1293
1355
|
const t = e;
|
|
1294
1356
|
for (const n of ["label", "text", "value", "answer", "name"]) {
|
|
1295
|
-
const r =
|
|
1357
|
+
const r = V(t[n]);
|
|
1296
1358
|
if (r) return r;
|
|
1297
1359
|
}
|
|
1298
1360
|
}
|
|
1299
1361
|
return f(String(e));
|
|
1300
1362
|
}
|
|
1301
|
-
function
|
|
1302
|
-
const t =
|
|
1363
|
+
function Ut(e) {
|
|
1364
|
+
const t = V(e);
|
|
1303
1365
|
if (!t) return [];
|
|
1304
1366
|
if (t.includes("/") || t.includes("、"))
|
|
1305
1367
|
return t.split(/[//、]/).map((r) => r.trim()).filter(Boolean);
|
|
1306
|
-
const n =
|
|
1368
|
+
const n = _e(e);
|
|
1307
1369
|
return n.length ? [f(n[0])] : [t];
|
|
1308
1370
|
}
|
|
1309
|
-
function
|
|
1371
|
+
function P(e, t) {
|
|
1310
1372
|
var o;
|
|
1311
1373
|
const n = Object.getPrototypeOf(e), r = Object.getOwnPropertyDescriptor(n, "value");
|
|
1312
1374
|
(o = r == null ? void 0 : r.set) == null || o.call(e, t);
|
|
1313
1375
|
}
|
|
1314
|
-
function
|
|
1376
|
+
function E(e) {
|
|
1315
1377
|
e.dispatchEvent(new Event("focus", { bubbles: !0 })), e.dispatchEvent(new InputEvent("input", { bubbles: !0, composed: !0, data: null, inputType: "insertText" })), e.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), e.dispatchEvent(new Event("blur", { bubbles: !0 }));
|
|
1316
1378
|
}
|
|
1317
|
-
function
|
|
1379
|
+
function R(e) {
|
|
1318
1380
|
window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
|
|
1319
1381
|
}
|
|
1320
|
-
function
|
|
1382
|
+
function jt(e) {
|
|
1321
1383
|
e.focus({ preventScroll: !0 });
|
|
1322
1384
|
const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
|
|
1323
1385
|
t instanceof HTMLElement && t.focus({ preventScroll: !0 });
|
|
1324
1386
|
}
|
|
1325
|
-
function
|
|
1387
|
+
function Gt(e) {
|
|
1326
1388
|
for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
|
|
1327
1389
|
e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
|
|
1328
1390
|
}
|
|
1329
|
-
function
|
|
1391
|
+
function H(e) {
|
|
1330
1392
|
const t = window.getComputedStyle(e);
|
|
1331
1393
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0) return !1;
|
|
1332
1394
|
const n = e.getBoundingClientRect();
|
|
1333
1395
|
return n.width > 0 && n.height > 0;
|
|
1334
1396
|
}
|
|
1335
|
-
function
|
|
1397
|
+
function b(e) {
|
|
1336
1398
|
return new Promise((t) => window.setTimeout(t, e));
|
|
1337
1399
|
}
|
|
1338
|
-
const
|
|
1400
|
+
const ot = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Yt = {
|
|
1339
1401
|
name: "ui-framework",
|
|
1340
|
-
match: (e) => e.matches(
|
|
1402
|
+
match: (e) => e.matches(vt) || St(e) || !mr(e) && Ne(e),
|
|
1341
1403
|
getValue: (e) => {
|
|
1342
1404
|
var o, i;
|
|
1343
1405
|
const t = e.element;
|
|
1344
1406
|
if (!t) return;
|
|
1345
|
-
const n =
|
|
1346
|
-
if ((n == null ? void 0 : n.kind) === "switch") return
|
|
1347
|
-
if ((n == null ? void 0 : n.kind) === "radioGroup") return
|
|
1348
|
-
if ((n == null ? void 0 : n.kind) === "checkboxGroup") return
|
|
1349
|
-
const r = e.type ||
|
|
1350
|
-
return r &&
|
|
1407
|
+
const n = K(t);
|
|
1408
|
+
if ((n == null ? void 0 : n.kind) === "switch") return Q(t);
|
|
1409
|
+
if ((n == null ? void 0 : n.kind) === "radioGroup") return Er(t);
|
|
1410
|
+
if ((n == null ? void 0 : n.kind) === "checkboxGroup") return xr(t);
|
|
1411
|
+
const r = e.type || me(t) || (n == null ? void 0 : n.type);
|
|
1412
|
+
return r && ot.has(r) ? Pt(t) : n ? ((i = $(t)) == null ? void 0 : i.value) || t.textContent || void 0 : (o = $(t)) == null ? void 0 : o.value;
|
|
1351
1413
|
},
|
|
1352
1414
|
setValue: async (e, t) => {
|
|
1353
1415
|
const n = e.element;
|
|
1354
1416
|
if (!n) return;
|
|
1355
|
-
const r =
|
|
1417
|
+
const r = K(n);
|
|
1356
1418
|
if ((r == null ? void 0 : r.kind) === "switch") {
|
|
1357
|
-
|
|
1419
|
+
wr(n, t);
|
|
1358
1420
|
return;
|
|
1359
1421
|
}
|
|
1360
1422
|
if ((r == null ? void 0 : r.kind) === "radioGroup") {
|
|
1361
|
-
|
|
1423
|
+
Sr(n, t);
|
|
1362
1424
|
return;
|
|
1363
1425
|
}
|
|
1364
1426
|
if ((r == null ? void 0 : r.kind) === "checkboxGroup") {
|
|
1365
|
-
|
|
1427
|
+
vr(n, t);
|
|
1366
1428
|
return;
|
|
1367
1429
|
}
|
|
1368
|
-
const o = e.type ||
|
|
1369
|
-
if (o &&
|
|
1370
|
-
await
|
|
1430
|
+
const o = e.type || me(n) || (r == null ? void 0 : r.type);
|
|
1431
|
+
if (o && ot.has(o) || Ne(n, o || void 0)) {
|
|
1432
|
+
await tr(n, t, o || "select", e);
|
|
1371
1433
|
return;
|
|
1372
1434
|
}
|
|
1373
|
-
const i =
|
|
1435
|
+
const i = $(n);
|
|
1374
1436
|
if (i) {
|
|
1375
|
-
|
|
1437
|
+
kr(i, t);
|
|
1376
1438
|
return;
|
|
1377
1439
|
}
|
|
1378
1440
|
n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1379
1441
|
}
|
|
1380
|
-
},
|
|
1381
|
-
function
|
|
1442
|
+
}, ni = Yt;
|
|
1443
|
+
function mr(e) {
|
|
1382
1444
|
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
1383
1445
|
}
|
|
1384
|
-
function
|
|
1385
|
-
|
|
1446
|
+
function wr(e, t) {
|
|
1447
|
+
Q(e) !== _r(t) && Ee(e);
|
|
1386
1448
|
}
|
|
1387
|
-
function
|
|
1449
|
+
function vr(e, t) {
|
|
1388
1450
|
var o;
|
|
1389
|
-
const n = new Set(
|
|
1390
|
-
for (const i of
|
|
1391
|
-
const s =
|
|
1392
|
-
c !== l &&
|
|
1451
|
+
const n = new Set(Ar(t).map(T)), r = Et(e) || [];
|
|
1452
|
+
for (const i of J(e)) {
|
|
1453
|
+
const s = oe(i.textContent || ""), a = i.getAttribute("value") || ((o = i.querySelector("input")) == null ? void 0 : o.value) || s, c = Q(i), l = n.has(T(String(a))) || n.has(T(s));
|
|
1454
|
+
c !== l && Ee(i);
|
|
1393
1455
|
}
|
|
1394
|
-
if (!
|
|
1456
|
+
if (!J(e).length && r.length)
|
|
1395
1457
|
for (const i of r)
|
|
1396
|
-
(n.has(
|
|
1458
|
+
(n.has(T(String(i.value))) || n.has(T(i.label))) && Ee(e);
|
|
1397
1459
|
}
|
|
1398
|
-
function
|
|
1399
|
-
const n =
|
|
1460
|
+
function Sr(e, t) {
|
|
1461
|
+
const n = T(String(t ?? "")), r = J(e).find((o) => {
|
|
1400
1462
|
var a;
|
|
1401
|
-
const i =
|
|
1402
|
-
return
|
|
1463
|
+
const i = oe(o.textContent || ""), s = o.getAttribute("value") || ((a = o.querySelector("input")) == null ? void 0 : a.value) || i;
|
|
1464
|
+
return T(String(s)) === n || T(i) === n;
|
|
1403
1465
|
});
|
|
1404
|
-
r &&
|
|
1466
|
+
r && Ee(r);
|
|
1405
1467
|
}
|
|
1406
|
-
function
|
|
1468
|
+
function Er(e) {
|
|
1407
1469
|
var n;
|
|
1408
|
-
const t =
|
|
1470
|
+
const t = J(e).find((r) => Q(r));
|
|
1409
1471
|
if (t)
|
|
1410
|
-
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) ||
|
|
1472
|
+
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || oe(t.textContent || "");
|
|
1411
1473
|
}
|
|
1412
|
-
function
|
|
1413
|
-
return
|
|
1474
|
+
function xr(e) {
|
|
1475
|
+
return J(e).filter((t) => Q(t)).map((t) => {
|
|
1414
1476
|
var n;
|
|
1415
|
-
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) ||
|
|
1477
|
+
return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || oe(t.textContent || "");
|
|
1416
1478
|
});
|
|
1417
1479
|
}
|
|
1418
|
-
function
|
|
1419
|
-
const t =
|
|
1480
|
+
function J(e) {
|
|
1481
|
+
const t = K(e);
|
|
1420
1482
|
return t != null && t.optionSelector ? Array.from(e.querySelectorAll(t.optionSelector)) : [];
|
|
1421
1483
|
}
|
|
1422
|
-
function
|
|
1484
|
+
function kr(e, t) {
|
|
1423
1485
|
e.value = String(t ?? ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 })), e.dispatchEvent(new Event("blur", { bubbles: !0 }));
|
|
1424
1486
|
}
|
|
1425
|
-
function
|
|
1487
|
+
function Ee(e) {
|
|
1426
1488
|
e.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window }));
|
|
1427
1489
|
}
|
|
1428
|
-
function
|
|
1490
|
+
function _r(e) {
|
|
1429
1491
|
return typeof e == "boolean" ? e : ["true", "1", "是", "开启", "启用", "yes", "y"].includes(String(e ?? "").trim().toLowerCase());
|
|
1430
1492
|
}
|
|
1431
|
-
function
|
|
1493
|
+
function Ar(e) {
|
|
1432
1494
|
return Array.isArray(e) ? e.map(String) : String(e ?? "").split(/[,,;;、]/).map((t) => t.trim()).filter(Boolean);
|
|
1433
1495
|
}
|
|
1434
|
-
function
|
|
1435
|
-
return
|
|
1496
|
+
function T(e) {
|
|
1497
|
+
return oe(e).toLowerCase();
|
|
1436
1498
|
}
|
|
1437
|
-
function
|
|
1499
|
+
function oe(e) {
|
|
1438
1500
|
return e.replace(/\s+/g, " ").trim();
|
|
1439
1501
|
}
|
|
1440
|
-
const
|
|
1441
|
-
class
|
|
1502
|
+
const Cr = "https://www.kingdeefin.com";
|
|
1503
|
+
class Wt extends Error {
|
|
1442
1504
|
constructor(n) {
|
|
1443
1505
|
super(n.message);
|
|
1444
1506
|
/** 结构化错误信息,含 code / stage / retryable */
|
|
@@ -1447,25 +1509,25 @@ class Bt extends Error {
|
|
|
1447
1509
|
}
|
|
1448
1510
|
}
|
|
1449
1511
|
function v(e, t, n, r = {}) {
|
|
1450
|
-
return new
|
|
1512
|
+
return new Wt({ code: e, message: t, stage: n, ...r });
|
|
1451
1513
|
}
|
|
1452
|
-
function
|
|
1453
|
-
return e instanceof
|
|
1514
|
+
function it(e, t, n = "RECOGNIZE_FAILED") {
|
|
1515
|
+
return e instanceof Wt ? e.smartFillError : {
|
|
1454
1516
|
code: n,
|
|
1455
1517
|
message: e instanceof Error ? e.message : String(e || "智能录入异常"),
|
|
1456
1518
|
stage: t,
|
|
1457
1519
|
retryable: t === "recognize"
|
|
1458
1520
|
};
|
|
1459
1521
|
}
|
|
1460
|
-
function
|
|
1522
|
+
function xe(e = "sf") {
|
|
1461
1523
|
return `${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1462
1524
|
}
|
|
1463
|
-
class
|
|
1525
|
+
class Tr {
|
|
1464
1526
|
constructor(t) {
|
|
1465
1527
|
/** 会话 accessToken,写入请求头 seToken */
|
|
1466
1528
|
d(this, "seToken", "");
|
|
1467
1529
|
/** 网关根地址,见 config/defaults.ts */
|
|
1468
|
-
d(this, "baseURL",
|
|
1530
|
+
d(this, "baseURL", Cr);
|
|
1469
1531
|
this.config = t;
|
|
1470
1532
|
}
|
|
1471
1533
|
/** 设置会话 token,后续 request 自动携带 seToken 请求头 */
|
|
@@ -1523,17 +1585,17 @@ class kr {
|
|
|
1523
1585
|
// scanToken: payload.scanToken,
|
|
1524
1586
|
formCode: t.formCode || "",
|
|
1525
1587
|
configVersion: t.configVersion || "",
|
|
1526
|
-
formMsg: t.fields.map(({ fingerprint: c, element: l, localRuleMode: u, scanToken: p, source:
|
|
1588
|
+
formMsg: t.fields.map(({ fingerprint: c, element: l, localRuleMode: u, scanToken: p, source: h, ...y }) => y),
|
|
1527
1589
|
// 将字段描述符转换为后端需要的格式
|
|
1528
1590
|
userInputMsg: r || ""
|
|
1529
1591
|
})
|
|
1530
1592
|
}
|
|
1531
|
-
), i =
|
|
1593
|
+
), i = Ir(o, t.fields, t.scanToken);
|
|
1532
1594
|
return console.log("suggestions", i), {
|
|
1533
1595
|
scanToken: t.scanToken,
|
|
1534
1596
|
suggestions: i,
|
|
1535
1597
|
trace: o.trace || {
|
|
1536
|
-
traceId:
|
|
1598
|
+
traceId: xe("trace"),
|
|
1537
1599
|
usedOcr: !!t.usedOcr,
|
|
1538
1600
|
usedAi: !0,
|
|
1539
1601
|
durationMs: Math.round(performance.now() - n)
|
|
@@ -1552,7 +1614,7 @@ class kr {
|
|
|
1552
1614
|
method: "POST",
|
|
1553
1615
|
body: n
|
|
1554
1616
|
}
|
|
1555
|
-
), o =
|
|
1617
|
+
), o = Rr(r);
|
|
1556
1618
|
if (!o)
|
|
1557
1619
|
throw v("RECOGNIZE_FAILED", "图片识别未提取到文本内容。", "recognize");
|
|
1558
1620
|
return o;
|
|
@@ -1560,7 +1622,7 @@ class kr {
|
|
|
1560
1622
|
/** 通用 fetch 封装:超时控制、trace 头、HTTP 错误映射为 SmartFillException */
|
|
1561
1623
|
async request(t, n) {
|
|
1562
1624
|
const r = new AbortController(), o = window.setTimeout(() => r.abort(), this.config.requestTimeoutMs ?? 3e4), i = new Headers(n.headers);
|
|
1563
|
-
n.body && !(n.body instanceof FormData) && !i.has("Content-Type") && i.set("Content-Type", "application/json"), i.set("x-trace-id",
|
|
1625
|
+
n.body && !(n.body instanceof FormData) && !i.has("Content-Type") && i.set("Content-Type", "application/json"), i.set("x-trace-id", xe("trace")), this.seToken && i.set("seToken", `${this.seToken}`);
|
|
1564
1626
|
try {
|
|
1565
1627
|
const s = await fetch(`${this.baseURL}${t}`, {
|
|
1566
1628
|
...n,
|
|
@@ -1568,7 +1630,7 @@ class kr {
|
|
|
1568
1630
|
signal: r.signal
|
|
1569
1631
|
});
|
|
1570
1632
|
if (!s.ok)
|
|
1571
|
-
throw v(
|
|
1633
|
+
throw v(Or(s.status), await s.text(), t.includes("session") ? "setup" : "recognize", {
|
|
1572
1634
|
retryable: s.status >= 500 || s.status === 429
|
|
1573
1635
|
});
|
|
1574
1636
|
return s.json();
|
|
@@ -1579,8 +1641,8 @@ class kr {
|
|
|
1579
1641
|
}
|
|
1580
1642
|
}
|
|
1581
1643
|
}
|
|
1582
|
-
const
|
|
1583
|
-
function
|
|
1644
|
+
const Lr = 0.95;
|
|
1645
|
+
function Ir(e, t, n) {
|
|
1584
1646
|
var i;
|
|
1585
1647
|
const r = new Map(t.map((s) => [s.fieldId, s]));
|
|
1586
1648
|
return (((i = e.data) == null ? void 0 : i.fieldValues) || []).filter((s) => !!(s != null && s.fieldId)).map((s) => {
|
|
@@ -1591,24 +1653,24 @@ function Ar(e, t, n) {
|
|
|
1591
1653
|
label: s.label || (a == null ? void 0 : a.label) || s.fieldId,
|
|
1592
1654
|
value: s.value,
|
|
1593
1655
|
displayValue: s.value == null ? "" : String(s.value),
|
|
1594
|
-
confidence:
|
|
1656
|
+
confidence: Mr(s.confidence),
|
|
1595
1657
|
source: s.source || "ai",
|
|
1596
1658
|
warnings: s.warnings
|
|
1597
1659
|
};
|
|
1598
1660
|
});
|
|
1599
1661
|
}
|
|
1600
|
-
function
|
|
1601
|
-
return typeof e != "number" || Number.isNaN(e) ?
|
|
1662
|
+
function Mr(e) {
|
|
1663
|
+
return typeof e != "number" || Number.isNaN(e) ? Lr : e < 0 ? 0 : e > 1 ? 1 : e;
|
|
1602
1664
|
}
|
|
1603
|
-
function
|
|
1665
|
+
function Rr(e) {
|
|
1604
1666
|
var n;
|
|
1605
1667
|
const t = typeof e.data == "string" ? e.data : ((n = e.data) == null ? void 0 : n.text) || e.text || "";
|
|
1606
1668
|
return String(t || "").trim();
|
|
1607
1669
|
}
|
|
1608
|
-
function
|
|
1670
|
+
function Or(e) {
|
|
1609
1671
|
return e === 401 ? "TOKEN_EXPIRED" : e === 403 ? "API_KEY_FORBIDDEN" : e === 404 ? "FORM_CONFIG_NOT_FOUND" : "RECOGNIZE_FAILED";
|
|
1610
1672
|
}
|
|
1611
|
-
class
|
|
1673
|
+
class Xt {
|
|
1612
1674
|
constructor() {
|
|
1613
1675
|
d(this, "handlers", /* @__PURE__ */ new Map());
|
|
1614
1676
|
}
|
|
@@ -1629,7 +1691,7 @@ class Ut {
|
|
|
1629
1691
|
this.handlers.clear();
|
|
1630
1692
|
}
|
|
1631
1693
|
}
|
|
1632
|
-
class
|
|
1694
|
+
class Fr {
|
|
1633
1695
|
constructor() {
|
|
1634
1696
|
/** 当前页面所有存活实例 */
|
|
1635
1697
|
d(this, "instances", /* @__PURE__ */ new Set());
|
|
@@ -1653,24 +1715,24 @@ class Ir {
|
|
|
1653
1715
|
this.instances.forEach((t) => t.destroy()), this.instances.clear(), this.active = null;
|
|
1654
1716
|
}
|
|
1655
1717
|
}
|
|
1656
|
-
const
|
|
1718
|
+
const qr = [
|
|
1657
1719
|
/^(el|rc|ant|radix|headlessui|mui|chakra)-/i,
|
|
1658
1720
|
/[0-9a-f]{8,}/i,
|
|
1659
1721
|
/\d{6,}/
|
|
1660
1722
|
];
|
|
1661
|
-
function
|
|
1723
|
+
function A(e) {
|
|
1662
1724
|
const t = String(e || "").trim();
|
|
1663
|
-
return !t ||
|
|
1725
|
+
return !t || qr.some((n) => n.test(t)) ? "" : t;
|
|
1664
1726
|
}
|
|
1665
|
-
function
|
|
1727
|
+
function X(e) {
|
|
1666
1728
|
const t = (e.options || []).slice(0, 20).map((n) => `${n.label}:${String(n.value)}`).join("|");
|
|
1667
|
-
return
|
|
1729
|
+
return B(
|
|
1668
1730
|
[
|
|
1669
1731
|
e.fieldId,
|
|
1670
1732
|
e.tagName,
|
|
1671
1733
|
e.type,
|
|
1672
|
-
|
|
1673
|
-
|
|
1734
|
+
A(e.name),
|
|
1735
|
+
A(e.id),
|
|
1674
1736
|
e.label,
|
|
1675
1737
|
e.placeholder,
|
|
1676
1738
|
e.section,
|
|
@@ -1678,10 +1740,10 @@ function j(e) {
|
|
|
1678
1740
|
].join("::")
|
|
1679
1741
|
);
|
|
1680
1742
|
}
|
|
1681
|
-
function
|
|
1743
|
+
function B(e) {
|
|
1682
1744
|
return String(e ?? "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
1683
1745
|
}
|
|
1684
|
-
const
|
|
1746
|
+
const st = "smart-fill-highlight-style", Dr = `
|
|
1685
1747
|
[data-smart-fill-highlighted="true"] {
|
|
1686
1748
|
background: #eaf3ff !important;
|
|
1687
1749
|
box-shadow: 0 0 0 1px #91caff inset !important;
|
|
@@ -1709,13 +1771,13 @@ const ot = "smart-fill-highlight-style", Rr = `
|
|
|
1709
1771
|
box-shadow: 0 0 0 1px #91caff inset !important;
|
|
1710
1772
|
}
|
|
1711
1773
|
`.trim();
|
|
1712
|
-
function
|
|
1713
|
-
if (typeof document > "u" || document.getElementById(
|
|
1774
|
+
function Pr() {
|
|
1775
|
+
if (typeof document > "u" || document.getElementById(st))
|
|
1714
1776
|
return;
|
|
1715
1777
|
const e = document.createElement("style");
|
|
1716
|
-
e.id =
|
|
1778
|
+
e.id = st, e.textContent = Dr, document.head.appendChild(e);
|
|
1717
1779
|
}
|
|
1718
|
-
const
|
|
1780
|
+
const Te = /* @__PURE__ */ new WeakMap(), Hr = [
|
|
1719
1781
|
'input:not([type="hidden"])',
|
|
1720
1782
|
"textarea",
|
|
1721
1783
|
"select",
|
|
@@ -1736,7 +1798,7 @@ const Ce = /* @__PURE__ */ new WeakMap(), Or = [
|
|
|
1736
1798
|
".van-field__body",
|
|
1737
1799
|
"[role='combobox']"
|
|
1738
1800
|
].join(", ");
|
|
1739
|
-
class
|
|
1801
|
+
class at {
|
|
1740
1802
|
constructor(t, n, r = []) {
|
|
1741
1803
|
this.fields = t, this.schemas = n, this.adapters = r;
|
|
1742
1804
|
}
|
|
@@ -1750,23 +1812,23 @@ class it {
|
|
|
1750
1812
|
for (const o of t.values) {
|
|
1751
1813
|
const i = this.fields.find((l) => l.fieldId === o.fieldId);
|
|
1752
1814
|
if (!i) {
|
|
1753
|
-
r.push(
|
|
1815
|
+
r.push(he(o.fieldId, "", o.value, "字段不在当前扫描结果中", "FIELD_NOT_FOUND"));
|
|
1754
1816
|
continue;
|
|
1755
1817
|
}
|
|
1756
1818
|
if (i.scanToken !== t.scanToken) {
|
|
1757
|
-
r.push(
|
|
1819
|
+
r.push(he(i.fieldId, i.label, o.value, "页面扫描已过期,请重新扫描", "SCAN_TOKEN_EXPIRED"));
|
|
1758
1820
|
continue;
|
|
1759
1821
|
}
|
|
1760
|
-
const s =
|
|
1822
|
+
const s = Br(this.schemas, o.fieldId), a = s != null && s.transform ? s.transform(o.value) : o.value, c = await this.getValue(i, s);
|
|
1761
1823
|
try {
|
|
1762
1824
|
const l = s != null && s.validate ? await s.validate(a) : !0;
|
|
1763
1825
|
if (l !== !0) {
|
|
1764
|
-
r.push(
|
|
1826
|
+
r.push(he(i.fieldId, i.label, a, typeof l == "string" ? l : "字段校验未通过", "VALIDATE_FAILED"));
|
|
1765
1827
|
continue;
|
|
1766
1828
|
}
|
|
1767
1829
|
await this.setValue(i, a, s), n.push({ fieldId: i.fieldId, label: i.label, value: a, previousValue: c });
|
|
1768
1830
|
} catch (l) {
|
|
1769
|
-
r.push(
|
|
1831
|
+
r.push(he(i.fieldId, i.label, a, l instanceof Error ? l.message : "字段回填失败", "SET_VALUE_FAILED"));
|
|
1770
1832
|
}
|
|
1771
1833
|
}
|
|
1772
1834
|
return {
|
|
@@ -1780,7 +1842,7 @@ class it {
|
|
|
1780
1842
|
if (n != null && n.getValue) return n.getValue();
|
|
1781
1843
|
const r = this.matchAdapter(t, n);
|
|
1782
1844
|
if (r != null && r.getValue) return r.getValue(t);
|
|
1783
|
-
const o =
|
|
1845
|
+
const o = pe(t, n);
|
|
1784
1846
|
if (o)
|
|
1785
1847
|
return o instanceof HTMLInputElement && o.type === "checkbox" ? o.checked : o instanceof HTMLInputElement && o.type === "radio" ? o.checked ? o.value : void 0 : o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement ? o.value : o.textContent;
|
|
1786
1848
|
}
|
|
@@ -1791,13 +1853,13 @@ class it {
|
|
|
1791
1853
|
async setValue(t, n, r) {
|
|
1792
1854
|
if (r != null && r.setValue) {
|
|
1793
1855
|
await r.setValue(n);
|
|
1794
|
-
const s =
|
|
1795
|
-
s &&
|
|
1856
|
+
const s = pe(t, r);
|
|
1857
|
+
s && Le(s, t);
|
|
1796
1858
|
return;
|
|
1797
1859
|
}
|
|
1798
|
-
const o =
|
|
1860
|
+
const o = pe(t, r);
|
|
1799
1861
|
if (!o) throw new Error("页面中未找到对应字段");
|
|
1800
|
-
if (t.fingerprint && t.fingerprint !==
|
|
1862
|
+
if (t.fingerprint && t.fingerprint !== X({ ...t, tagName: o.tagName.toLowerCase() }))
|
|
1801
1863
|
throw new Error("字段结构已变化,请重新扫描");
|
|
1802
1864
|
const i = this.matchAdapter(t, r);
|
|
1803
1865
|
if (t.disabled || o.hasAttribute("disabled") || o.getAttribute("aria-disabled") === "true")
|
|
@@ -1805,24 +1867,24 @@ class it {
|
|
|
1805
1867
|
if (t.readonly || o.hasAttribute("readonly"))
|
|
1806
1868
|
throw new Error("字段不可编辑");
|
|
1807
1869
|
if (i) {
|
|
1808
|
-
await i.setValue(t, n),
|
|
1870
|
+
await i.setValue(t, n), Le(o, t);
|
|
1809
1871
|
return;
|
|
1810
1872
|
}
|
|
1811
|
-
|
|
1873
|
+
$r(o, n), Le(o, t);
|
|
1812
1874
|
}
|
|
1813
1875
|
/** 匹配第一个适用的组件库适配器 */
|
|
1814
1876
|
matchAdapter(t, n) {
|
|
1815
|
-
const r =
|
|
1877
|
+
const r = pe(t, n);
|
|
1816
1878
|
return r ? this.adapters.find((o) => o.match(r, t)) : void 0;
|
|
1817
1879
|
}
|
|
1818
1880
|
}
|
|
1819
|
-
function
|
|
1881
|
+
function pe(e, t) {
|
|
1820
1882
|
var r;
|
|
1821
1883
|
if ((r = e.element) != null && r.isConnected) return e.element;
|
|
1822
|
-
const n =
|
|
1823
|
-
return n || document.querySelector(`[data-smart-fill-id="${
|
|
1884
|
+
const n = Nr(t == null ? void 0 : t.element);
|
|
1885
|
+
return n || document.querySelector(`[data-smart-fill-id="${ze(e.fieldId)}"]`);
|
|
1824
1886
|
}
|
|
1825
|
-
function
|
|
1887
|
+
function Nr(e) {
|
|
1826
1888
|
if (e instanceof HTMLElement)
|
|
1827
1889
|
return e.isConnected ? e : null;
|
|
1828
1890
|
if (typeof e == "string")
|
|
@@ -1834,73 +1896,73 @@ function qr(e) {
|
|
|
1834
1896
|
}
|
|
1835
1897
|
return null;
|
|
1836
1898
|
}
|
|
1837
|
-
function
|
|
1899
|
+
function $r(e, t) {
|
|
1838
1900
|
if (e instanceof HTMLInputElement && e.type === "checkbox")
|
|
1839
1901
|
e.checked = !!t;
|
|
1840
1902
|
else if (e instanceof HTMLInputElement && e.type === "radio") {
|
|
1841
|
-
const n = document.querySelector(`input[type="radio"][name="${
|
|
1903
|
+
const n = document.querySelector(`input[type="radio"][name="${ze(e.name)}"][value="${ze(String(t))}"]`);
|
|
1842
1904
|
(n || e).checked = !0;
|
|
1843
1905
|
} else e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.isContentEditable && (e.textContent = String(t ?? ""));
|
|
1844
1906
|
e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1845
1907
|
}
|
|
1846
|
-
function
|
|
1847
|
-
|
|
1848
|
-
const n =
|
|
1908
|
+
function Le(e, t) {
|
|
1909
|
+
Pr();
|
|
1910
|
+
const n = zr(e, t), r = () => {
|
|
1849
1911
|
for (const o of n)
|
|
1850
|
-
o.isConnected &&
|
|
1912
|
+
o.isConnected && Kr(o);
|
|
1851
1913
|
};
|
|
1852
1914
|
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => requestAnimationFrame(r)) : r();
|
|
1853
1915
|
}
|
|
1854
|
-
function
|
|
1916
|
+
function zr(e, t) {
|
|
1855
1917
|
if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)
|
|
1856
1918
|
return [e];
|
|
1857
|
-
const n =
|
|
1858
|
-
Array.from(n.querySelectorAll(
|
|
1919
|
+
const n = Ne(e, t == null ? void 0 : t.type) && te(e) || e, r = Vr(
|
|
1920
|
+
Array.from(n.querySelectorAll(Hr)).filter(ct)
|
|
1859
1921
|
);
|
|
1860
1922
|
if (r.length)
|
|
1861
1923
|
return r;
|
|
1862
|
-
const o =
|
|
1863
|
-
return o &&
|
|
1924
|
+
const o = $(n);
|
|
1925
|
+
return o && ct(o) ? [o] : [n];
|
|
1864
1926
|
}
|
|
1865
|
-
function
|
|
1927
|
+
function Kr(e) {
|
|
1866
1928
|
var r;
|
|
1867
|
-
e.setAttribute("data-smart-fill-highlighted", "true"), (r =
|
|
1929
|
+
e.setAttribute("data-smart-fill-highlighted", "true"), (r = Te.get(e)) == null || r.abort();
|
|
1868
1930
|
const t = new AbortController(), n = (o) => {
|
|
1869
|
-
o && "isTrusted" in o && !o.isTrusted || (e.removeAttribute("data-smart-fill-highlighted"), t.abort(),
|
|
1931
|
+
o && "isTrusted" in o && !o.isTrusted || (e.removeAttribute("data-smart-fill-highlighted"), t.abort(), Te.delete(e));
|
|
1870
1932
|
};
|
|
1871
|
-
|
|
1933
|
+
Te.set(e, t), e.addEventListener("pointerdown", n, { signal: t.signal }), e.addEventListener("mousedown", n, { signal: t.signal }), e.addEventListener("keydown", n, { signal: t.signal }), e.addEventListener("input", n, { signal: t.signal }), e.addEventListener("change", n, { signal: t.signal });
|
|
1872
1934
|
}
|
|
1873
|
-
function
|
|
1935
|
+
function Vr(e) {
|
|
1874
1936
|
return e.filter((t) => !e.some((n) => n !== t && n.contains(t)));
|
|
1875
1937
|
}
|
|
1876
|
-
function
|
|
1938
|
+
function ct(e) {
|
|
1877
1939
|
const t = window.getComputedStyle(e);
|
|
1878
1940
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
|
|
1879
1941
|
return !1;
|
|
1880
1942
|
const n = e.getBoundingClientRect();
|
|
1881
1943
|
return n.width > 0 && n.height > 0;
|
|
1882
1944
|
}
|
|
1883
|
-
function
|
|
1945
|
+
function he(e, t, n, r, o) {
|
|
1884
1946
|
return { fieldId: e, label: t, attemptedValue: n, reason: r, reasonCode: o };
|
|
1885
1947
|
}
|
|
1886
|
-
function
|
|
1948
|
+
function ze(e) {
|
|
1887
1949
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1888
1950
|
}
|
|
1889
|
-
function
|
|
1951
|
+
function Br(e, t) {
|
|
1890
1952
|
const n = e.find((o) => o.fieldId === t);
|
|
1891
1953
|
if (n) return n;
|
|
1892
1954
|
const r = t.includes(":") ? t.slice(t.lastIndexOf(":") + 1) : "";
|
|
1893
1955
|
if (r)
|
|
1894
1956
|
return e.find((o) => o.rowKey != null && String(o.rowKey) === r && `${o.fieldId}:${o.rowKey}` === t);
|
|
1895
1957
|
}
|
|
1896
|
-
const
|
|
1958
|
+
const Ur = [
|
|
1897
1959
|
{ key: "mobile", pattern: new RegExp("(?<!\\d)1[3-9]\\d{9}(?!\\d)", "g"), confidence: 0.98, reason: "手机号正则命中" },
|
|
1898
1960
|
{ key: "idCard", pattern: new RegExp("(?<!\\d)\\d{17}[\\dXx](?!\\d)", "g"), confidence: 0.96, reason: "身份证号正则命中" },
|
|
1899
1961
|
{ key: "email", pattern: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, confidence: 0.95, reason: "邮箱正则命中" },
|
|
1900
1962
|
{ key: "bankCard", pattern: new RegExp("(?<!\\d)\\d{16,19}(?!\\d)", "g"), confidence: 0.9, reason: "银行卡号正则命中" },
|
|
1901
1963
|
{ key: "amount", pattern: /(?:金额|价格|费用|合计|总计)[::\s]*([0-9]+(?:\.[0-9]{1,2})?)/g, confidence: 0.88, reason: "金额关键词命中" },
|
|
1902
1964
|
{ key: "date", pattern: /\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g, confidence: 0.86, reason: "日期格式命中" }
|
|
1903
|
-
],
|
|
1965
|
+
], F = {
|
|
1904
1966
|
mobile: [
|
|
1905
1967
|
"手机",
|
|
1906
1968
|
"手机号",
|
|
@@ -1952,7 +2014,7 @@ const zr = [
|
|
|
1952
2014
|
"申请额度"
|
|
1953
2015
|
],
|
|
1954
2016
|
date: ["日期", "时间", "有效期", "date", "申请日期", "申请时间", "受理日期", "进件日期"]
|
|
1955
|
-
},
|
|
2017
|
+
}, Zt = {
|
|
1956
2018
|
mobile: "mobile",
|
|
1957
2019
|
idCard: "idCard",
|
|
1958
2020
|
email: "email",
|
|
@@ -1960,20 +2022,20 @@ const zr = [
|
|
|
1960
2022
|
amount: "amount",
|
|
1961
2023
|
date: "date"
|
|
1962
2024
|
};
|
|
1963
|
-
class
|
|
2025
|
+
class jr {
|
|
1964
2026
|
/**
|
|
1965
2027
|
* 从文本中提取事实并匹配到 scan 字段。
|
|
1966
2028
|
* 按 confidence 降序分配,每个 fieldId 仅匹配一次(usedFieldIds 去重)。
|
|
1967
2029
|
*/
|
|
1968
2030
|
recognize(t, n, r) {
|
|
1969
|
-
const o =
|
|
2031
|
+
const o = to([...Gr(t), ...Yr(t)]), i = /* @__PURE__ */ new Set(), s = [];
|
|
1970
2032
|
for (const a of o.sort((c, l) => l.confidence - c.confidence)) {
|
|
1971
|
-
const c =
|
|
2033
|
+
const c = Xr(a, n, i);
|
|
1972
2034
|
c && (s.push({
|
|
1973
2035
|
fieldId: c.fieldId,
|
|
1974
2036
|
scanToken: r,
|
|
1975
2037
|
label: c.label,
|
|
1976
|
-
value:
|
|
2038
|
+
value: Jr(a.value, c),
|
|
1977
2039
|
displayValue: a.value,
|
|
1978
2040
|
confidence: a.confidence,
|
|
1979
2041
|
source: "local_rule",
|
|
@@ -1983,76 +2045,76 @@ class Kr {
|
|
|
1983
2045
|
return s;
|
|
1984
2046
|
}
|
|
1985
2047
|
}
|
|
1986
|
-
function
|
|
2048
|
+
function Gr(e) {
|
|
1987
2049
|
const t = [];
|
|
1988
|
-
for (const n of
|
|
2050
|
+
for (const n of Ur)
|
|
1989
2051
|
for (const r of e.matchAll(n.pattern)) {
|
|
1990
|
-
const o =
|
|
2052
|
+
const o = Jt(r[1] || r[0]);
|
|
1991
2053
|
t.push({
|
|
1992
2054
|
key: n.key,
|
|
1993
2055
|
value: o,
|
|
1994
2056
|
confidence: n.confidence,
|
|
1995
2057
|
reason: n.reason,
|
|
1996
|
-
baseKey:
|
|
2058
|
+
baseKey: Zt[n.key]
|
|
1997
2059
|
});
|
|
1998
2060
|
}
|
|
1999
2061
|
return t;
|
|
2000
2062
|
}
|
|
2001
|
-
function
|
|
2063
|
+
function Yr(e) {
|
|
2002
2064
|
const t = [], n = e.split(/\r?\n|[;,;]/).map((r) => r.trim()).filter(Boolean);
|
|
2003
2065
|
for (const r of n) {
|
|
2004
2066
|
const o = r.match(/^[“"'`]?([^::=]{2,30})[”"'`]?[::=]\s*(.+)$/);
|
|
2005
2067
|
if (!o) continue;
|
|
2006
|
-
const i =
|
|
2068
|
+
const i = eo(o[1]), s = Jt(o[2]);
|
|
2007
2069
|
if (!(!i || !s))
|
|
2008
|
-
for (const a of
|
|
2070
|
+
for (const a of Wr(i, s))
|
|
2009
2071
|
t.push(a);
|
|
2010
2072
|
}
|
|
2011
2073
|
return t;
|
|
2012
2074
|
}
|
|
2013
|
-
function
|
|
2014
|
-
const n =
|
|
2015
|
-
return (
|
|
2075
|
+
function Wr(e, t) {
|
|
2076
|
+
const n = B(e), r = Qr(t), o = [];
|
|
2077
|
+
return (C(n, F.mobile) || r === "mobile") && o.push("mobile"), (C(n, F.idCard) || r === "idCard") && o.push("idCard"), (C(n, F.email) || r === "email") && o.push("email"), (C(n, F.bankCard) || r === "bankCard") && o.push("bankCard"), (C(n, F.amount) || r === "amount") && o.push("amount"), (C(n, F.date) || r === "date") && o.push("date"), no(o).map((i, s) => ({
|
|
2016
2078
|
key: i,
|
|
2017
2079
|
value: t,
|
|
2018
2080
|
confidence: Math.max(0.84, 0.96 - s * 0.04),
|
|
2019
2081
|
reason: `键值对文本命中(${e})`,
|
|
2020
|
-
baseKey:
|
|
2082
|
+
baseKey: Zt[i]
|
|
2021
2083
|
}));
|
|
2022
2084
|
}
|
|
2023
|
-
function
|
|
2085
|
+
function Xr(e, t, n) {
|
|
2024
2086
|
let r = null;
|
|
2025
2087
|
for (const o of t) {
|
|
2026
2088
|
if (n.has(o.fieldId)) continue;
|
|
2027
|
-
const i =
|
|
2089
|
+
const i = Zr(e, o);
|
|
2028
2090
|
i > ((r == null ? void 0 : r.score) ?? 0) && (r = { field: o, score: i });
|
|
2029
2091
|
}
|
|
2030
2092
|
return r && r.score >= 0.45 ? r.field : null;
|
|
2031
2093
|
}
|
|
2032
|
-
function
|
|
2033
|
-
const n =
|
|
2094
|
+
function Zr(e, t) {
|
|
2095
|
+
const n = B([t.fieldId, t.label, t.placeholder, t.name, t.id, t.section].join(" ")), r = F[e.key] || [e.key];
|
|
2034
2096
|
let o = 0;
|
|
2035
|
-
return
|
|
2097
|
+
return C(n, r) ? o += 0.95 : C(n, [e.key]) && (o += 0.82), n.includes(B(e.key)) && (o += 0.22), t.required && (o += 0.05), e.baseKey === "amount" && (t.type === "amount" || t.type === "number") && (o += 0.18), e.baseKey === "date" && t.type === "date" && (o += 0.18), ["email", "mobile", "idCard", "bankCard"].includes(e.baseKey) && t.type === "text" && (o += 0.08), Math.min(o, 1);
|
|
2036
2098
|
}
|
|
2037
|
-
function
|
|
2099
|
+
function Jr(e, t) {
|
|
2038
2100
|
var n;
|
|
2039
2101
|
return t.type === "date" ? e.replace(/[年月/.]/g, "-").replace(/日/g, "").replace(/--/g, "-") : t.type === "number" || t.type === "amount" ? ((n = e.match(/[0-9]+(?:\.[0-9]+)?/)) == null ? void 0 : n[0]) ?? e : t.name && /mobile|phone|idcard|bankcard/i.test(t.name) || t.id && /mobile|phone|idcard|bankcard/i.test(t.id) || /mobile|phone|idcard|bankcard/i.test(t.fieldId) ? e.replace(/\s+/g, "") : e;
|
|
2040
2102
|
}
|
|
2041
|
-
function
|
|
2103
|
+
function Qr(e) {
|
|
2042
2104
|
const t = e.replace(/\s+/g, "");
|
|
2043
2105
|
return /^1[3-9]\d{9}$/.test(t) ? "mobile" : /^\d{17}[\dXx]$/.test(t) ? "idCard" : /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(e) ? "email" : /^\d{16,19}$/.test(t) ? "bankCard" : /^\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?$/.test(e) ? "date" : /^[0-9]+(?:\.[0-9]{1,2})?$/.test(t) ? "amount" : "unknown";
|
|
2044
2106
|
}
|
|
2045
|
-
function
|
|
2107
|
+
function eo(e) {
|
|
2046
2108
|
return e.replace(/[“”"'`]/g, "").replace(/\s+/g, " ").trim();
|
|
2047
2109
|
}
|
|
2048
|
-
function
|
|
2110
|
+
function Jt(e) {
|
|
2049
2111
|
return e.replace(/[,。;;]+$/g, "").replace(/^[“”"'`\s]+|[“”"'`\s]+$/g, "").trim();
|
|
2050
2112
|
}
|
|
2051
|
-
function
|
|
2052
|
-
const n =
|
|
2053
|
-
return t.some((r) => n.includes(
|
|
2113
|
+
function C(e, t) {
|
|
2114
|
+
const n = B(e);
|
|
2115
|
+
return t.some((r) => n.includes(B(r)));
|
|
2054
2116
|
}
|
|
2055
|
-
function
|
|
2117
|
+
function to(e) {
|
|
2056
2118
|
const t = /* @__PURE__ */ new Map();
|
|
2057
2119
|
for (const n of e) {
|
|
2058
2120
|
const r = `${n.key}::${n.value}`, o = t.get(r);
|
|
@@ -2060,16 +2122,16 @@ function Zr(e) {
|
|
|
2060
2122
|
}
|
|
2061
2123
|
return [...t.values()];
|
|
2062
2124
|
}
|
|
2063
|
-
function
|
|
2125
|
+
function no(e) {
|
|
2064
2126
|
return [...new Set(e)];
|
|
2065
2127
|
}
|
|
2066
|
-
const
|
|
2128
|
+
const lt = [
|
|
2067
2129
|
"input",
|
|
2068
2130
|
"textarea",
|
|
2069
2131
|
"select",
|
|
2070
2132
|
"[contenteditable]:not([contenteditable='false'])"
|
|
2071
|
-
].join(", "),
|
|
2072
|
-
class
|
|
2133
|
+
].join(", "), ro = /* @__PURE__ */ new Set(["hidden", "submit", "button", "image", "reset", "file", "password"]);
|
|
2134
|
+
class oo {
|
|
2073
2135
|
constructor(t = document) {
|
|
2074
2136
|
this.root = t;
|
|
2075
2137
|
}
|
|
@@ -2080,7 +2142,7 @@ class eo {
|
|
|
2080
2142
|
*/
|
|
2081
2143
|
scan(t = {}) {
|
|
2082
2144
|
var l;
|
|
2083
|
-
const n =
|
|
2145
|
+
const n = xe("scan");
|
|
2084
2146
|
if ((l = t.registered) != null && l.length)
|
|
2085
2147
|
return {
|
|
2086
2148
|
scanToken: n,
|
|
@@ -2100,18 +2162,18 @@ class eo {
|
|
|
2100
2162
|
return n;
|
|
2101
2163
|
const r = [];
|
|
2102
2164
|
for (const s of n.fields) {
|
|
2103
|
-
const a = !!((i = s.options) != null && i.length) && !
|
|
2165
|
+
const a = !!((i = s.options) != null && i.length) && !ce(s);
|
|
2104
2166
|
if (!s.element || a || s.type !== "select" && s.type !== "cascader") {
|
|
2105
2167
|
r.push(s);
|
|
2106
2168
|
continue;
|
|
2107
2169
|
}
|
|
2108
|
-
const c = await
|
|
2170
|
+
const c = await _n(s.element), l = c != null && c.length && !ce({ ...s, options: c }) ? c : void 0;
|
|
2109
2171
|
if (!(l != null && l.length)) {
|
|
2110
|
-
r.push({ ...s, options:
|
|
2172
|
+
r.push({ ...s, options: ce(s) ? void 0 : s.options });
|
|
2111
2173
|
continue;
|
|
2112
2174
|
}
|
|
2113
2175
|
const u = { ...s, options: l };
|
|
2114
|
-
u.fingerprint =
|
|
2176
|
+
u.fingerprint = X({
|
|
2115
2177
|
...u,
|
|
2116
2178
|
tagName: s.element.tagName.toLowerCase()
|
|
2117
2179
|
}), r.push(u);
|
|
@@ -2120,7 +2182,7 @@ class eo {
|
|
|
2120
2182
|
}
|
|
2121
2183
|
/** FieldSchema → FieldDescriptor,解析 element 并生成 fingerprint */
|
|
2122
2184
|
fromSchema(t, n) {
|
|
2123
|
-
const r =
|
|
2185
|
+
const r = go(t.element, this.root), o = r ? He(r) || Fe(r) || r : null, i = {
|
|
2124
2186
|
fieldId: t.rowKey == null ? t.fieldId : `${t.fieldId}:${t.rowKey}`,
|
|
2125
2187
|
label: t.label,
|
|
2126
2188
|
type: t.type,
|
|
@@ -2134,32 +2196,32 @@ class eo {
|
|
|
2134
2196
|
element: o || void 0,
|
|
2135
2197
|
fingerprint: ""
|
|
2136
2198
|
};
|
|
2137
|
-
return i.fingerprint =
|
|
2199
|
+
return i.fingerprint = X({
|
|
2138
2200
|
...i,
|
|
2139
2201
|
tagName: o == null ? void 0 : o.tagName.toLowerCase()
|
|
2140
2202
|
}), i;
|
|
2141
2203
|
}
|
|
2142
2204
|
/** DOM 元素 → FieldDescriptor,自动推断 label/type 并写入 data-smart-fill-id */
|
|
2143
2205
|
fromElement(t, n, r, o = this.root) {
|
|
2144
|
-
const i =
|
|
2206
|
+
const i = io(t, n), s = co(t, o), a = {
|
|
2145
2207
|
fieldId: i,
|
|
2146
2208
|
fingerprint: "",
|
|
2147
2209
|
scanToken: r,
|
|
2148
|
-
type:
|
|
2210
|
+
type: so(t),
|
|
2149
2211
|
localRuleMode: "inherit",
|
|
2150
|
-
label:
|
|
2151
|
-
placeholder:
|
|
2152
|
-
name:
|
|
2153
|
-
id:
|
|
2154
|
-
section:
|
|
2212
|
+
label: Qt(t),
|
|
2213
|
+
placeholder: tn(t),
|
|
2214
|
+
name: A(xt(t)) || void 0,
|
|
2215
|
+
id: A(t.id) || void 0,
|
|
2216
|
+
section: ao(t),
|
|
2155
2217
|
options: s,
|
|
2156
|
-
required:
|
|
2157
|
-
readonly:
|
|
2158
|
-
disabled:
|
|
2218
|
+
required: fo(t),
|
|
2219
|
+
readonly: uo(t),
|
|
2220
|
+
disabled: Ie(t),
|
|
2159
2221
|
source: "form_scan",
|
|
2160
2222
|
element: t
|
|
2161
2223
|
};
|
|
2162
|
-
return
|
|
2224
|
+
return ce(a) && (a.options = void 0), a.fingerprint = X({
|
|
2163
2225
|
...a,
|
|
2164
2226
|
tagName: t.tagName.toLowerCase()
|
|
2165
2227
|
}), a;
|
|
@@ -2167,7 +2229,7 @@ class eo {
|
|
|
2167
2229
|
/** 解析扫描根节点,scanContainer 为 CSS 选择器 */
|
|
2168
2230
|
resolveRoot(t) {
|
|
2169
2231
|
if (t) {
|
|
2170
|
-
const n =
|
|
2232
|
+
const n = nn(this.root, t);
|
|
2171
2233
|
if (n)
|
|
2172
2234
|
return n;
|
|
2173
2235
|
}
|
|
@@ -2175,38 +2237,38 @@ class eo {
|
|
|
2175
2237
|
}
|
|
2176
2238
|
/** 收集 root 下可见且可编辑的表单控件 */
|
|
2177
2239
|
collectVisibleFields(t) {
|
|
2178
|
-
const n = /* @__PURE__ */ new Set(), r = [
|
|
2240
|
+
const n = /* @__PURE__ */ new Set(), r = [lt, kt, vt, ".van-field"].join(", ");
|
|
2179
2241
|
for (const s of t.querySelectorAll(r)) {
|
|
2180
2242
|
if (!(s instanceof HTMLElement)) continue;
|
|
2181
|
-
const a =
|
|
2182
|
-
!a || !
|
|
2243
|
+
const a = He(s) || Fe(s);
|
|
2244
|
+
!a || !Ke(a) || Ie(a) || n.add(a);
|
|
2183
2245
|
}
|
|
2184
|
-
const o = [...n], i = Array.from(t.querySelectorAll(
|
|
2185
|
-
return
|
|
2246
|
+
const o = [...n], i = Array.from(t.querySelectorAll(lt)).filter((s) => !(s instanceof HTMLElement) || !Ke(s) || po(s) || s instanceof HTMLInputElement && ro.has((s.type || "").toLowerCase()) ? !1 : !Ie(s) && !s.hasAttribute("readonly"));
|
|
2247
|
+
return ho([...i, ...o]);
|
|
2186
2248
|
}
|
|
2187
2249
|
/**
|
|
2188
2250
|
* 检测最应优先扫描的容器。
|
|
2189
2251
|
* 优先 activeElement 所在弹窗,否则取包含最多字段的弹窗容器。
|
|
2190
2252
|
*/
|
|
2191
2253
|
detectTopLayerContainer(t) {
|
|
2192
|
-
const n = document.activeElement instanceof HTMLElement ? document.activeElement : null, r = n == null ? void 0 : n.closest(
|
|
2254
|
+
const n = document.activeElement instanceof HTMLElement ? document.activeElement : null, r = n == null ? void 0 : n.closest(Xe);
|
|
2193
2255
|
if (r instanceof HTMLElement && t.some((i) => r.contains(i)))
|
|
2194
2256
|
return r;
|
|
2195
|
-
const o = t.map((i) => i.closest(
|
|
2257
|
+
const o = t.map((i) => i.closest(Xe)).filter((i) => i instanceof HTMLElement);
|
|
2196
2258
|
return o.length ? o.sort((i, s) => t.filter((a) => s.contains(a)).length - t.filter((a) => i.contains(a)).length)[0] : document.body;
|
|
2197
2259
|
}
|
|
2198
2260
|
}
|
|
2199
|
-
function
|
|
2261
|
+
function io(e, t) {
|
|
2200
2262
|
const n = e.getAttribute("data-smart-fill-id");
|
|
2201
2263
|
if (n)
|
|
2202
2264
|
return n;
|
|
2203
|
-
const o =
|
|
2265
|
+
const o = A(e.getAttribute("name")) || A(e.getAttribute("data-smart-fill-key")) || A(xt(e)) || A(e.id) || A(Qt(e)) || `smart-fill-${Date.now()}-${t}`;
|
|
2204
2266
|
return e.setAttribute("data-smart-fill-id", o), o;
|
|
2205
2267
|
}
|
|
2206
|
-
function
|
|
2207
|
-
const t =
|
|
2268
|
+
function so(e) {
|
|
2269
|
+
const t = Ct(e);
|
|
2208
2270
|
if (t) return t;
|
|
2209
|
-
const n =
|
|
2271
|
+
const n = me(e);
|
|
2210
2272
|
if (n) return n;
|
|
2211
2273
|
if (e instanceof HTMLTextAreaElement) return "textarea";
|
|
2212
2274
|
if (e instanceof HTMLSelectElement) return "select";
|
|
@@ -2219,23 +2281,23 @@ function no(e) {
|
|
|
2219
2281
|
}
|
|
2220
2282
|
return "text";
|
|
2221
2283
|
}
|
|
2222
|
-
function
|
|
2284
|
+
function Qt(e) {
|
|
2223
2285
|
const t = e.getAttribute("aria-label");
|
|
2224
2286
|
if (t) return t.trim();
|
|
2225
2287
|
if (e.id) {
|
|
2226
|
-
const i = document.querySelector(`label[for="${
|
|
2288
|
+
const i = document.querySelector(`label[for="${Ye(e.id)}"]`);
|
|
2227
2289
|
if (i != null && i.textContent) return f(i.textContent);
|
|
2228
2290
|
}
|
|
2229
|
-
const n = e.closest(
|
|
2291
|
+
const n = e.closest(yn), r = n == null ? void 0 : n.querySelector(bn);
|
|
2230
2292
|
if (r != null && r.textContent) return f(r.textContent);
|
|
2231
2293
|
const o = e.closest("label");
|
|
2232
2294
|
if (o) {
|
|
2233
|
-
const i =
|
|
2295
|
+
const i = en(o, e);
|
|
2234
2296
|
if (i) return i;
|
|
2235
2297
|
}
|
|
2236
|
-
return
|
|
2298
|
+
return tn(e) || e.getAttribute("name") || e.id || "未命名字段";
|
|
2237
2299
|
}
|
|
2238
|
-
function
|
|
2300
|
+
function en(e, t) {
|
|
2239
2301
|
const n = e.cloneNode(!0);
|
|
2240
2302
|
for (const o of n.querySelectorAll('input, textarea, select, button, [role="combobox"], [role="listbox"]'))
|
|
2241
2303
|
o.remove();
|
|
@@ -2243,18 +2305,18 @@ function Wt(e, t) {
|
|
|
2243
2305
|
if (r)
|
|
2244
2306
|
return t instanceof HTMLInputElement && t.value && r.includes(t.value) ? f(r.replace(t.value, "")) || void 0 : r;
|
|
2245
2307
|
}
|
|
2246
|
-
function
|
|
2308
|
+
function tn(e) {
|
|
2247
2309
|
var t;
|
|
2248
2310
|
return e.getAttribute("placeholder") || e.getAttribute("aria-placeholder") || ((t = e.querySelector("[placeholder]")) == null ? void 0 : t.getAttribute("placeholder")) || void 0;
|
|
2249
2311
|
}
|
|
2250
|
-
function
|
|
2312
|
+
function ao(e) {
|
|
2251
2313
|
const t = e.closest("fieldset, section, .panel, .card, .form-section"), n = t == null ? void 0 : t.querySelector("legend, h1, h2, h3, .title, .section-title");
|
|
2252
2314
|
return n != null && n.textContent ? f(n.textContent) : void 0;
|
|
2253
2315
|
}
|
|
2254
|
-
function
|
|
2255
|
-
const n =
|
|
2316
|
+
function co(e, t = document) {
|
|
2317
|
+
const n = Tt(e);
|
|
2256
2318
|
if (n != null && n.length) return n;
|
|
2257
|
-
const r =
|
|
2319
|
+
const r = Et(e);
|
|
2258
2320
|
if (r != null && r.length) return r;
|
|
2259
2321
|
if (e instanceof HTMLSelectElement)
|
|
2260
2322
|
return Array.from(e.options).map((o) => ({
|
|
@@ -2262,49 +2324,49 @@ function oo(e, t = document) {
|
|
|
2262
2324
|
value: o.value
|
|
2263
2325
|
}));
|
|
2264
2326
|
if (e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && e.name)
|
|
2265
|
-
return Array.from(t.querySelectorAll(`input[name="${
|
|
2266
|
-
label:
|
|
2327
|
+
return Array.from(t.querySelectorAll(`input[name="${Ye(e.name)}"]`)).filter((o) => o.type === e.type && Ke(o)).map((o) => ({
|
|
2328
|
+
label: lo(o),
|
|
2267
2329
|
value: o.value || !0
|
|
2268
2330
|
}));
|
|
2269
2331
|
}
|
|
2270
|
-
function
|
|
2332
|
+
function lo(e) {
|
|
2271
2333
|
if (e.id) {
|
|
2272
|
-
const n = document.querySelector(`label[for="${
|
|
2334
|
+
const n = document.querySelector(`label[for="${Ye(e.id)}"]`);
|
|
2273
2335
|
if (n != null && n.textContent) return f(n.textContent);
|
|
2274
2336
|
}
|
|
2275
2337
|
const t = e.closest("label");
|
|
2276
2338
|
if (t) {
|
|
2277
|
-
const n =
|
|
2339
|
+
const n = en(t, e);
|
|
2278
2340
|
if (n) return n;
|
|
2279
2341
|
}
|
|
2280
2342
|
return f(e.getAttribute("aria-label") || e.value || "");
|
|
2281
2343
|
}
|
|
2282
|
-
function
|
|
2344
|
+
function Ke(e) {
|
|
2283
2345
|
const t = window.getComputedStyle(e);
|
|
2284
2346
|
return t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0 ? !1 : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
2285
2347
|
}
|
|
2286
|
-
function
|
|
2287
|
-
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" ||
|
|
2348
|
+
function Ie(e) {
|
|
2349
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" || gn.some((t) => e.classList.contains(t));
|
|
2288
2350
|
}
|
|
2289
|
-
function
|
|
2351
|
+
function uo(e) {
|
|
2290
2352
|
return e.hasAttribute("readonly") || !!e.querySelector("[readonly]");
|
|
2291
2353
|
}
|
|
2292
|
-
function
|
|
2354
|
+
function fo(e) {
|
|
2293
2355
|
return e.hasAttribute("required") || e.getAttribute("aria-required") === "true" || !!e.querySelector('[required], [aria-required="true"]');
|
|
2294
2356
|
}
|
|
2295
|
-
function
|
|
2296
|
-
return
|
|
2357
|
+
function po(e) {
|
|
2358
|
+
return He(e) != null || Fe(e) != null;
|
|
2297
2359
|
}
|
|
2298
|
-
function
|
|
2360
|
+
function ho(e) {
|
|
2299
2361
|
const t = [];
|
|
2300
2362
|
for (const n of e)
|
|
2301
2363
|
t.some((r) => r === n || r.contains(n) || n.contains(r)) || t.push(n);
|
|
2302
2364
|
return t;
|
|
2303
2365
|
}
|
|
2304
|
-
function
|
|
2305
|
-
return e instanceof HTMLElement ? e : typeof e == "string" ?
|
|
2366
|
+
function go(e, t) {
|
|
2367
|
+
return e instanceof HTMLElement ? e : typeof e == "string" ? nn(t, e) : null;
|
|
2306
2368
|
}
|
|
2307
|
-
function
|
|
2369
|
+
function nn(e, t) {
|
|
2308
2370
|
try {
|
|
2309
2371
|
const n = e.querySelector(t);
|
|
2310
2372
|
return n instanceof HTMLElement ? n : null;
|
|
@@ -2312,11 +2374,11 @@ function Zt(e, t) {
|
|
|
2312
2374
|
return null;
|
|
2313
2375
|
}
|
|
2314
2376
|
}
|
|
2315
|
-
function
|
|
2377
|
+
function Ye(e) {
|
|
2316
2378
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
2317
2379
|
}
|
|
2318
|
-
const
|
|
2319
|
-
class
|
|
2380
|
+
const Me = 5, yo = 10 * 1024 * 1024, bo = 50 * 1024 * 1024;
|
|
2381
|
+
class mo {
|
|
2320
2382
|
constructor(t) {
|
|
2321
2383
|
/** 面板宿主元素,挂载到 container 下 */
|
|
2322
2384
|
d(this, "host", null);
|
|
@@ -2342,7 +2404,7 @@ class ho {
|
|
|
2342
2404
|
if (!this.dragState || !this.host || t.pointerId !== this.dragState.pointerId) return;
|
|
2343
2405
|
const n = t.clientX - this.dragState.startX, r = t.clientY - this.dragState.startY;
|
|
2344
2406
|
(Math.abs(n) > 3 || Math.abs(r) > 3) && (this.dragState.moved = !0);
|
|
2345
|
-
const o = this.host.getBoundingClientRect(), i = Math.max(8, window.innerWidth - o.width - 8), s = Math.max(8, window.innerHeight - o.height - 8), a =
|
|
2407
|
+
const o = this.host.getBoundingClientRect(), i = Math.max(8, window.innerWidth - o.width - 8), s = Math.max(8, window.innerHeight - o.height - 8), a = ge(this.dragState.startLeft + n, 8, i), c = ge(this.dragState.startTop + r, 8, s);
|
|
2346
2408
|
this.host.style.left = `${a}px`, this.host.style.top = `${c}px`;
|
|
2347
2409
|
});
|
|
2348
2410
|
d(this, "handleDragEnd", (t) => {
|
|
@@ -2352,7 +2414,7 @@ class ho {
|
|
|
2352
2414
|
});
|
|
2353
2415
|
/** 面板聚焦或鼠标悬浮在图片区时接管全局粘贴图片 */
|
|
2354
2416
|
d(this, "handleDocumentPaste", (t) => {
|
|
2355
|
-
const n =
|
|
2417
|
+
const n = vo(t);
|
|
2356
2418
|
if (!n.length || !this.isOpen || !this.host)
|
|
2357
2419
|
return;
|
|
2358
2420
|
const r = document.activeElement, o = this.root instanceof ShadowRoot ? this.root.activeElement : null;
|
|
@@ -2405,7 +2467,7 @@ class ho {
|
|
|
2405
2467
|
}
|
|
2406
2468
|
render(t) {
|
|
2407
2469
|
this.root && (this.root.innerHTML = `
|
|
2408
|
-
<style>${
|
|
2470
|
+
<style>${So}</style>
|
|
2409
2471
|
${this.options.mode === "floating" ? `<button class="sf-float" type="button" data-role="open">${this.t("entry", "智能录入")}</button>` : ""}
|
|
2410
2472
|
<section class="sf-panel ${t ? "is-open" : ""} ${this.options.mode === "inline" ? "is-inline" : "is-floating"}" aria-label="智能录入面板">
|
|
2411
2473
|
<header class="sf-header" data-role="close" >
|
|
@@ -2415,7 +2477,7 @@ class ho {
|
|
|
2415
2477
|
<div class="sf-body ${t ? "is-open" : ""}">
|
|
2416
2478
|
<div class="sf-entry-grid">
|
|
2417
2479
|
<div class="sf-textarea-wrap">
|
|
2418
|
-
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${
|
|
2480
|
+
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${wo(this.inputText)}</textarea>
|
|
2419
2481
|
<div class="sf-textarea-actions">
|
|
2420
2482
|
<button class="sf-btn sf-btn-secondary" type="button" data-role="clear">${this.t("clear", "清空")}</button>
|
|
2421
2483
|
<button class="sf-btn sf-btn-primary" type="button" data-role="recognize">${this.t("recognize", "智能识别")}</button>
|
|
@@ -2432,7 +2494,7 @@ class ho {
|
|
|
2432
2494
|
<circle cx="10" cy="10.5" r="1" fill="currentColor"/>
|
|
2433
2495
|
</svg>
|
|
2434
2496
|
</span>
|
|
2435
|
-
<span class="sf-upload-hint">${this.t("uploadHint", `点击、拖拽、Ctrl + V 粘贴图片至此(最多 ${
|
|
2497
|
+
<span class="sf-upload-hint">${this.t("uploadHint", `点击、拖拽、Ctrl + V 粘贴图片至此(最多 ${Me} 张)`)}</span>
|
|
2436
2498
|
</span>
|
|
2437
2499
|
<span class="sf-upload-btn" data-role="file-label">图片识别</span>
|
|
2438
2500
|
</label>
|
|
@@ -2476,8 +2538,8 @@ class ho {
|
|
|
2476
2538
|
}), (s = this.query('[data-role="text"]')) == null || s.addEventListener("input", (u) => {
|
|
2477
2539
|
this.inputText = u.target.value;
|
|
2478
2540
|
}), (a = this.query('[data-role="local-priority-toggle"]')) == null || a.addEventListener("change", (u) => {
|
|
2479
|
-
var p,
|
|
2480
|
-
this.localPriorityEnabled = u.target.checked, (
|
|
2541
|
+
var p, h;
|
|
2542
|
+
this.localPriorityEnabled = u.target.checked, (h = (p = this.options).onLocalPriorityChange) == null || h.call(p, this.localPriorityEnabled);
|
|
2481
2543
|
}), (c = this.query('[data-role="clear"]')) == null || c.addEventListener("click", () => {
|
|
2482
2544
|
this.clearFormState();
|
|
2483
2545
|
}), (l = this.query('[data-role="recognize"]')) == null || l.addEventListener("click", () => {
|
|
@@ -2506,15 +2568,15 @@ class ho {
|
|
|
2506
2568
|
this.resetSelectedFiles(), this.setError(this.t("invalidImageError", "请选择图片文件。"));
|
|
2507
2569
|
return;
|
|
2508
2570
|
}
|
|
2509
|
-
if (n.length >
|
|
2510
|
-
this.resetSelectedFiles(), this.setError(this.t("maxFilesError", `最多上传 ${
|
|
2571
|
+
if (n.length > Me) {
|
|
2572
|
+
this.resetSelectedFiles(), this.setError(this.t("maxFilesError", `最多上传 ${Me} 张图片。`));
|
|
2511
2573
|
return;
|
|
2512
2574
|
}
|
|
2513
|
-
if (n.find((i) => i.size >
|
|
2575
|
+
if (n.find((i) => i.size > yo)) {
|
|
2514
2576
|
this.resetSelectedFiles(), this.setError(this.t("maxSingleFileSizeError", "单张图片不能超过 10MB。"));
|
|
2515
2577
|
return;
|
|
2516
2578
|
}
|
|
2517
|
-
if (n.reduce((i, s) => i + s.size, 0) >
|
|
2579
|
+
if (n.reduce((i, s) => i + s.size, 0) > bo) {
|
|
2518
2580
|
this.resetSelectedFiles(), this.setError(this.t("maxTotalFileSizeError", "上传图片总大小不能超过 50MB。"));
|
|
2519
2581
|
return;
|
|
2520
2582
|
}
|
|
@@ -2540,7 +2602,7 @@ class ho {
|
|
|
2540
2602
|
keepHostInViewport() {
|
|
2541
2603
|
this.options.mode !== "floating" || !this.host || !this.host.style.left || !this.host.style.top || window.requestAnimationFrame(() => {
|
|
2542
2604
|
if (!this.host) return;
|
|
2543
|
-
const t = this.host.getBoundingClientRect(), n =
|
|
2605
|
+
const t = this.host.getBoundingClientRect(), n = ge(t.left, 8, Math.max(8, window.innerWidth - t.width - 8)), r = ge(t.top, 8, Math.max(8, window.innerHeight - t.height - 8));
|
|
2544
2606
|
this.host.style.left = `${n}px`, this.host.style.top = `${r}px`;
|
|
2545
2607
|
});
|
|
2546
2608
|
}
|
|
@@ -2553,7 +2615,7 @@ class ho {
|
|
|
2553
2615
|
return ((r = this.options.messages) == null ? void 0 : r[t]) || n;
|
|
2554
2616
|
}
|
|
2555
2617
|
}
|
|
2556
|
-
function
|
|
2618
|
+
function wo(e) {
|
|
2557
2619
|
return e.replace(/[&<>"']/g, (t) => ({
|
|
2558
2620
|
"&": "&",
|
|
2559
2621
|
"<": "<",
|
|
@@ -2562,14 +2624,14 @@ function go(e) {
|
|
|
2562
2624
|
"'": "'"
|
|
2563
2625
|
})[t] || t);
|
|
2564
2626
|
}
|
|
2565
|
-
function
|
|
2627
|
+
function ge(e, t, n) {
|
|
2566
2628
|
return Math.min(Math.max(e, t), n);
|
|
2567
2629
|
}
|
|
2568
|
-
function
|
|
2630
|
+
function vo(e) {
|
|
2569
2631
|
var n;
|
|
2570
2632
|
return Array.from(((n = e.clipboardData) == null ? void 0 : n.items) || []).filter((r) => r.kind === "file" && r.type.startsWith("image/")).map((r) => r.getAsFile()).filter((r) => !!r);
|
|
2571
2633
|
}
|
|
2572
|
-
const
|
|
2634
|
+
const So = `
|
|
2573
2635
|
:host, .sf-panel { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
2574
2636
|
:host(.sf-sdk-host-floating), .sf-sdk-host-floating { position: fixed; top: 30px; right: 30px; z-index: 2147483647; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; width: min(450px, calc(100vw - 32px)); pointer-events: none; }
|
|
2575
2637
|
.sf-float { font-size: 15px; align-self: flex-end; border: 0; border-radius: 999px; padding: 10px 30px; color: #fff; background: linear-gradient(to right, #FF7E49, #FFA34E); box-shadow: 0 10px 24px rgba(37,99,235,.3); cursor: move; user-select: none; touch-action: none; pointer-events: auto; }
|
|
@@ -2640,23 +2702,23 @@ const bo = `
|
|
|
2640
2702
|
width: min(450px, calc(100vw - 32px))
|
|
2641
2703
|
}
|
|
2642
2704
|
}
|
|
2643
|
-
`,
|
|
2644
|
-
let
|
|
2645
|
-
const
|
|
2646
|
-
let
|
|
2647
|
-
const
|
|
2648
|
-
let
|
|
2649
|
-
function
|
|
2650
|
-
|
|
2705
|
+
`, Eo = 0.75, xo = 1800, U = /* @__PURE__ */ new Map();
|
|
2706
|
+
let j = 0;
|
|
2707
|
+
const Ve = "smart-fill:routechange", rn = "smart-fill:session-scan:";
|
|
2708
|
+
let ut = !1;
|
|
2709
|
+
const dt = /* @__PURE__ */ new WeakMap();
|
|
2710
|
+
let ko = 0;
|
|
2711
|
+
function on() {
|
|
2712
|
+
U.clear(), dn(), j += 1;
|
|
2651
2713
|
}
|
|
2652
|
-
class
|
|
2714
|
+
class _o {
|
|
2653
2715
|
constructor(t, n) {
|
|
2654
2716
|
/** 实例级事件总线,对应 instance.on(...) */
|
|
2655
|
-
d(this, "events", new
|
|
2717
|
+
d(this, "events", new Xt());
|
|
2656
2718
|
/** 页面字段扫描器,root 来自 SmartFill.create({ root }) */
|
|
2657
2719
|
d(this, "scanner");
|
|
2658
2720
|
/** 浏览器端本地规则引擎,用于文本正则/键值对提取 */
|
|
2659
|
-
d(this, "ruleEngine", new
|
|
2721
|
+
d(this, "ruleEngine", new jr());
|
|
2660
2722
|
/** Shadow DOM 面板,mount / mountFloatingButton 后可用(指向最后挂载的面板,用于状态展示) */
|
|
2661
2723
|
d(this, "panel", null);
|
|
2662
2724
|
/** 已挂载的全部面板(inline / floating 可同时存在),用于本地优先开关广播与销毁 */
|
|
@@ -2666,7 +2728,7 @@ class So {
|
|
|
2666
2728
|
/** 业务方 registerFields 注册的字段;非空时 rescan 仅扫描这些字段 */
|
|
2667
2729
|
d(this, "registeredFields", []);
|
|
2668
2730
|
/** 组件库回填适配器链,如 AntD / Element 自定义控件 */
|
|
2669
|
-
d(this, "adapters", [
|
|
2731
|
+
d(this, "adapters", [Yt]);
|
|
2670
2732
|
/** 最近一次 rescan 结果;scanToken 用于识别/回填防过期校验 */
|
|
2671
2733
|
d(this, "scanResult", null);
|
|
2672
2734
|
/** recognize 完成后生成的自动回填候选,供面板展示与 applyAutoItems 使用 */
|
|
@@ -2678,14 +2740,14 @@ class So {
|
|
|
2678
2740
|
/** 实例是否已 destroy,销毁后所有公开方法抛 INSTANCE_DESTROYED */
|
|
2679
2741
|
d(this, "destroyed", !1);
|
|
2680
2742
|
/** 页面扫描缓存代际快照;变化时说明缓存已被全局清空 */
|
|
2681
|
-
d(this, "scanCacheVersion",
|
|
2743
|
+
d(this, "scanCacheVersion", j);
|
|
2682
2744
|
/** 悬浮挂载时记录当前路由快照,路由切换后自动销毁实例 */
|
|
2683
2745
|
d(this, "floatingRouteSnapshot", null);
|
|
2684
2746
|
/** 悬浮挂载生命周期清理函数:移除路由监听和容器 observer */
|
|
2685
2747
|
d(this, "floatingLifecycleCleanup", null);
|
|
2686
2748
|
/** mount 后预扫描定时器 */
|
|
2687
2749
|
d(this, "preScanTimer", null);
|
|
2688
|
-
this.config = t, this.context = n, this.scanner = new
|
|
2750
|
+
this.config = t, this.context = n, this.scanner = new oo(t.root || document), this.localPriorityEnabled = Wo(), this.context.manager.add(this);
|
|
2689
2751
|
}
|
|
2690
2752
|
/** 订阅实例事件,返回取消订阅函数 */
|
|
2691
2753
|
on(t, n) {
|
|
@@ -2721,13 +2783,13 @@ class So {
|
|
|
2721
2783
|
const n = typeof t == "string" ? document.querySelector(t) : t;
|
|
2722
2784
|
if (!n)
|
|
2723
2785
|
throw v("UNSUPPORTED_PAGE", "未找到智能录入挂载点。", "ui");
|
|
2724
|
-
const r =
|
|
2786
|
+
const r = gt("inline", Yo(t, n)), o = yt(r, !0);
|
|
2725
2787
|
return this.createPanel("inline", r, o).mount(n), this.schedulePreScan(), this;
|
|
2726
2788
|
}
|
|
2727
2789
|
/** 挂载右下角悬浮按钮 + 弹框(floating 模式),优先挂到当前子路由页面顶层容器 */
|
|
2728
2790
|
mountFloatingButton() {
|
|
2729
2791
|
this.assertAlive();
|
|
2730
|
-
const t =
|
|
2792
|
+
const t = Ho(this.config), n = gt("floating"), r = yt(n, !0);
|
|
2731
2793
|
return this.createPanel("floating", n, r).mount(t), this.bindFloatingLifecycle(t), this.schedulePreScan(), this;
|
|
2732
2794
|
}
|
|
2733
2795
|
/**
|
|
@@ -2736,7 +2798,7 @@ class So {
|
|
|
2736
2798
|
*/
|
|
2737
2799
|
createPanel(t, n, r) {
|
|
2738
2800
|
let o;
|
|
2739
|
-
return o = new
|
|
2801
|
+
return o = new mo({
|
|
2740
2802
|
mode: t,
|
|
2741
2803
|
initialOpen: r,
|
|
2742
2804
|
messages: this.config.messages,
|
|
@@ -2749,17 +2811,17 @@ class So {
|
|
|
2749
2811
|
}
|
|
2750
2812
|
/** 同步本地优先开关:更新内存态、写入 localStorage,并广播到其他已挂载面板 */
|
|
2751
2813
|
handleLocalPriorityChange(t, n) {
|
|
2752
|
-
this.localPriorityEnabled = t,
|
|
2814
|
+
this.localPriorityEnabled = t, Xo(t);
|
|
2753
2815
|
for (const r of this.panels)
|
|
2754
2816
|
r !== n && r.setLocalPriorityEnabled(t);
|
|
2755
2817
|
}
|
|
2756
2818
|
/** 打开面板并触发 rescan,同时激活当前实例(关闭其他实例面板) */
|
|
2757
2819
|
async open(t = this.panel) {
|
|
2758
|
-
this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0),
|
|
2820
|
+
this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0), bt(this.panelStorageKeys.get(t), !0), this.scanResult || await this.rescan());
|
|
2759
2821
|
}
|
|
2760
2822
|
/** 关闭面板(不销毁实例) */
|
|
2761
2823
|
close(t = this.panel) {
|
|
2762
|
-
t && (this.panel = t, t.setOpen(!1),
|
|
2824
|
+
t && (this.panel = t, t.setOpen(!1), bt(this.panelStorageKeys.get(t), !1));
|
|
2763
2825
|
}
|
|
2764
2826
|
/**
|
|
2765
2827
|
* 扫描页面可回填字段。
|
|
@@ -2799,7 +2861,7 @@ class So {
|
|
|
2799
2861
|
this.destroyed || !this.panels.length || (this.preScanTimer != null && window.clearTimeout(this.preScanTimer), this.preScanTimer = window.setTimeout(() => {
|
|
2800
2862
|
this.preScanTimer = null, !(this.destroyed || this.scanResult) && this.preScan().catch(() => {
|
|
2801
2863
|
});
|
|
2802
|
-
},
|
|
2864
|
+
}, xo));
|
|
2803
2865
|
}
|
|
2804
2866
|
cancelPreScan() {
|
|
2805
2867
|
this.preScanTimer != null && (window.clearTimeout(this.preScanTimer), this.preScanTimer = null);
|
|
@@ -2817,72 +2879,72 @@ class So {
|
|
|
2817
2879
|
async recognize(t) {
|
|
2818
2880
|
var i, s, a, c, l, u;
|
|
2819
2881
|
this.assertAlive(), this.syncScanCacheVersion(), (i = this.panel) == null || i.setBusy(!0, "扫描中..."), (s = this.panel) == null || s.setStatus("扫描中...");
|
|
2820
|
-
const n = await this.rescan(), r =
|
|
2882
|
+
const n = await this.rescan(), r = xe("trace"), o = performance.now();
|
|
2821
2883
|
this.events.emit("recognizing", { scanToken: n.scanToken, traceId: r }), (a = this.panel) == null || a.setBusy(!0, "识别中...");
|
|
2822
2884
|
try {
|
|
2823
|
-
const p = n.fields.filter((
|
|
2885
|
+
const p = n.fields.filter((m) => Io(m.localRuleMode, this.localPriorityEnabled)), h = n.fields.filter((m) => m.localRuleMode !== "only"), { text: y, usedOcr: x } = await this.context.client.resolveInputText({
|
|
2824
2886
|
text: t.text,
|
|
2825
2887
|
images: t.images,
|
|
2826
|
-
onStatusChange: (
|
|
2827
|
-
var
|
|
2828
|
-
if (
|
|
2829
|
-
(
|
|
2888
|
+
onStatusChange: (m) => {
|
|
2889
|
+
var se, O, ae;
|
|
2890
|
+
if (m === "image_uploading") {
|
|
2891
|
+
(se = this.panel) == null || se.setStatus("图片上传中...");
|
|
2830
2892
|
return;
|
|
2831
2893
|
}
|
|
2832
|
-
if (
|
|
2833
|
-
(
|
|
2894
|
+
if (m === "image_recognizing") {
|
|
2895
|
+
(O = this.panel) == null || O.setStatus("图片识别中...");
|
|
2834
2896
|
return;
|
|
2835
2897
|
}
|
|
2836
|
-
(
|
|
2898
|
+
(ae = this.panel) == null || ae.setStatus("识别中...");
|
|
2837
2899
|
}
|
|
2838
|
-
}),
|
|
2839
|
-
let
|
|
2840
|
-
if (!
|
|
2841
|
-
|
|
2900
|
+
}), ie = y ? this.ruleEngine.recognize(y, p, n.scanToken) : [];
|
|
2901
|
+
let _;
|
|
2902
|
+
if (!h.length)
|
|
2903
|
+
_ = ft(n.scanToken, r, ie, o, void 0, x);
|
|
2842
2904
|
else
|
|
2843
2905
|
try {
|
|
2844
|
-
const
|
|
2906
|
+
const m = await this.context.client.recognize({
|
|
2845
2907
|
scanToken: n.scanToken,
|
|
2846
2908
|
formCode: this.config.formCode,
|
|
2847
2909
|
configVersion: this.formConfigVersion,
|
|
2848
|
-
text:
|
|
2849
|
-
usedOcr:
|
|
2850
|
-
fields:
|
|
2910
|
+
text: y,
|
|
2911
|
+
usedOcr: x,
|
|
2912
|
+
fields: h,
|
|
2851
2913
|
onStatusChange: () => {
|
|
2852
|
-
var
|
|
2853
|
-
(
|
|
2914
|
+
var O;
|
|
2915
|
+
(O = this.panel) == null || O.setStatus("识别中...");
|
|
2854
2916
|
}
|
|
2855
2917
|
});
|
|
2856
|
-
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2859
|
-
|
|
2918
|
+
m.trace.durationMs = m.trace.durationMs || Math.round(performance.now() - o);
|
|
2919
|
+
const se = Lo(
|
|
2920
|
+
ie,
|
|
2921
|
+
m.suggestions.filter((O) => h.some((ae) => ae.fieldId === O.fieldId))
|
|
2860
2922
|
);
|
|
2861
|
-
|
|
2862
|
-
} catch (
|
|
2863
|
-
if (!
|
|
2864
|
-
throw
|
|
2865
|
-
|
|
2923
|
+
_ = { ...m, suggestions: se };
|
|
2924
|
+
} catch (m) {
|
|
2925
|
+
if (!ie.length)
|
|
2926
|
+
throw m;
|
|
2927
|
+
_ = ft(
|
|
2866
2928
|
n.scanToken,
|
|
2867
2929
|
r,
|
|
2868
|
-
|
|
2930
|
+
ie,
|
|
2869
2931
|
o,
|
|
2870
|
-
[
|
|
2871
|
-
|
|
2932
|
+
[x ? "后端识别失败,已使用 OCR 文本触发本地识别继续回填。" : "后端识别失败,已启用本地识别继续回填。"],
|
|
2933
|
+
x
|
|
2872
2934
|
);
|
|
2873
2935
|
}
|
|
2874
|
-
if (this.autoApplyState =
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2936
|
+
if (this.autoApplyState = Co(
|
|
2937
|
+
_.scanToken,
|
|
2938
|
+
_.trace.traceId,
|
|
2939
|
+
_.suggestions,
|
|
2878
2940
|
n,
|
|
2879
2941
|
this.registeredFields
|
|
2880
|
-
), this.events.emit("recognized",
|
|
2881
|
-
const
|
|
2882
|
-
this.config.apiCallback && await Promise.resolve(this.config.apiCallback(
|
|
2942
|
+
), this.events.emit("recognized", _), (c = this.panel) == null || c.setAutoApplyState(this.autoApplyState), this.config.apiEnable) {
|
|
2943
|
+
const m = Ao(_, this.autoApplyState, n);
|
|
2944
|
+
this.config.apiCallback && await Promise.resolve(this.config.apiCallback(m)), (l = this.panel) == null || l.setStatus(`识别完成,已返回 ${m.fields.length} 个字段。`);
|
|
2883
2945
|
} else
|
|
2884
2946
|
await this.applyAutoItems(this.autoApplyState);
|
|
2885
|
-
return
|
|
2947
|
+
return _;
|
|
2886
2948
|
} catch (p) {
|
|
2887
2949
|
throw this.clearScanStateOnTokenExpired(p), this.emitError(p, "recognize"), p;
|
|
2888
2950
|
} finally {
|
|
@@ -2899,7 +2961,7 @@ class So {
|
|
|
2899
2961
|
if (this.assertAlive(), this.syncScanCacheVersion(), !this.scanResult)
|
|
2900
2962
|
throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2901
2963
|
this.events.emit("applying", { scanToken: t.scanToken, count: t.values.length });
|
|
2902
|
-
const r = await new
|
|
2964
|
+
const r = await new at(this.scanResult.fields, this.registeredFields, this.adapters).apply(t);
|
|
2903
2965
|
return this.events.emit("applied", r), (o = this.panel) == null || o.setApplyResult(r), r;
|
|
2904
2966
|
}
|
|
2905
2967
|
/**
|
|
@@ -2910,9 +2972,9 @@ class So {
|
|
|
2910
2972
|
var a, c;
|
|
2911
2973
|
if (!this.scanResult)
|
|
2912
2974
|
throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2913
|
-
const n =
|
|
2975
|
+
const n = To(t), r = t.items.filter((l) => sn(l)).map((l) => ({ fieldId: l.fieldId, value: l.value, source: l.source }));
|
|
2914
2976
|
this.events.emit("applying", { scanToken: t.scanToken, count: r.length }), (a = this.panel) == null || a.setStatus("识别完成,正在自动回填...");
|
|
2915
|
-
const i = await new
|
|
2977
|
+
const i = await new at(this.scanResult.fields, this.registeredFields, this.adapters).apply({ scanToken: t.scanToken, values: r }), s = {
|
|
2916
2978
|
...i,
|
|
2917
2979
|
skipped: [...n, ...i.skipped],
|
|
2918
2980
|
warnings: [
|
|
@@ -2936,17 +2998,17 @@ class So {
|
|
|
2936
2998
|
}
|
|
2937
2999
|
emitError(t, n) {
|
|
2938
3000
|
var o;
|
|
2939
|
-
const r =
|
|
3001
|
+
const r = it(t, n);
|
|
2940
3002
|
this.events.emit("error", r), (o = this.panel) == null || o.setError(r.message);
|
|
2941
3003
|
}
|
|
2942
3004
|
getCachedPageScanResult(t) {
|
|
2943
3005
|
const n = this.getPageScanCacheKey();
|
|
2944
3006
|
if (!n) return null;
|
|
2945
|
-
const r =
|
|
3007
|
+
const r = U.get(n);
|
|
2946
3008
|
if (r && (!t || r.dynamicOptionsReady)) {
|
|
2947
|
-
const i =
|
|
3009
|
+
const i = Ro(r.scanResult);
|
|
2948
3010
|
if (!i)
|
|
2949
|
-
|
|
3011
|
+
U.delete(n);
|
|
2950
3012
|
else
|
|
2951
3013
|
return i;
|
|
2952
3014
|
}
|
|
@@ -2956,54 +3018,54 @@ class So {
|
|
|
2956
3018
|
cachePageScanResult(t, n) {
|
|
2957
3019
|
const r = this.getPageScanCacheKey();
|
|
2958
3020
|
if (!r || !t.fields.length) return;
|
|
2959
|
-
const o =
|
|
2960
|
-
o != null && o.dynamicOptionsReady && !n || (
|
|
3021
|
+
const o = U.get(r);
|
|
3022
|
+
o != null && o.dynamicOptionsReady && !n || (U.set(r, {
|
|
2961
3023
|
scanResult: t,
|
|
2962
3024
|
dynamicOptionsReady: (o == null ? void 0 : o.dynamicOptionsReady) || n
|
|
2963
3025
|
}), this.persistPageScanResult(t, (o == null ? void 0 : o.dynamicOptionsReady) || n));
|
|
2964
3026
|
}
|
|
2965
3027
|
getPageScanCacheKey() {
|
|
2966
|
-
return this.registeredFields.length ? null :
|
|
3028
|
+
return this.registeredFields.length ? null : qo(this.config);
|
|
2967
3029
|
}
|
|
2968
3030
|
getSessionPageScanCacheKey() {
|
|
2969
|
-
return this.registeredFields.length || !this.config.formCode ? null :
|
|
3031
|
+
return this.registeredFields.length || !this.config.formCode ? null : Do(this.config);
|
|
2970
3032
|
}
|
|
2971
3033
|
clearScanStateOnTokenExpired(t) {
|
|
2972
|
-
|
|
3034
|
+
it(t, "recognize").code === "TOKEN_EXPIRED" && (on(), this.scanCacheVersion = j, this.scanResult = null, this.autoApplyState = null);
|
|
2973
3035
|
}
|
|
2974
3036
|
syncScanCacheVersion() {
|
|
2975
|
-
this.scanCacheVersion !==
|
|
3037
|
+
this.scanCacheVersion !== j && (this.scanCacheVersion = j, this.scanResult = null, this.autoApplyState = null);
|
|
2976
3038
|
}
|
|
2977
3039
|
getPersistedPageScanResult(t) {
|
|
2978
3040
|
const n = this.getSessionPageScanCacheKey();
|
|
2979
3041
|
if (!n) return null;
|
|
2980
|
-
const r =
|
|
3042
|
+
const r = jo(n);
|
|
2981
3043
|
if (!r || t && !r.dynamicOptionsReady) return null;
|
|
2982
|
-
const o = this.scanner.scan({ maxFields: this.config.maxFields }), i =
|
|
3044
|
+
const o = this.scanner.scan({ maxFields: this.config.maxFields }), i = Oo(r, o);
|
|
2983
3045
|
return i ? {
|
|
2984
3046
|
scanResult: i,
|
|
2985
3047
|
dynamicOptionsReady: r.dynamicOptionsReady
|
|
2986
|
-
} : (
|
|
3048
|
+
} : (dn(n), null);
|
|
2987
3049
|
}
|
|
2988
3050
|
persistPageScanResult(t, n) {
|
|
2989
3051
|
const r = this.getSessionPageScanCacheKey();
|
|
2990
|
-
!r || !t.fields.length ||
|
|
3052
|
+
!r || !t.fields.length || Go(r, {
|
|
2991
3053
|
version: 1,
|
|
2992
3054
|
dynamicOptionsReady: n,
|
|
2993
3055
|
fields: t.fields.map(({ element: o, scanToken: i, ...s }) => s)
|
|
2994
3056
|
});
|
|
2995
3057
|
}
|
|
2996
3058
|
bindFloatingLifecycle(t) {
|
|
2997
|
-
this.clearFloatingLifecycle(), this.floatingRouteSnapshot =
|
|
3059
|
+
this.clearFloatingLifecycle(), this.floatingRouteSnapshot = ht(), Po();
|
|
2998
3060
|
const n = () => {
|
|
2999
|
-
this.destroyed ||
|
|
3061
|
+
this.destroyed || ht() !== this.floatingRouteSnapshot && this.destroy();
|
|
3000
3062
|
};
|
|
3001
|
-
window.addEventListener(
|
|
3063
|
+
window.addEventListener(Ve, n);
|
|
3002
3064
|
const r = new MutationObserver(() => {
|
|
3003
3065
|
this.destroyed || t !== document.body && !t.isConnected && this.destroy();
|
|
3004
3066
|
});
|
|
3005
3067
|
r.observe(document.body, { childList: !0, subtree: !0 }), this.floatingLifecycleCleanup = () => {
|
|
3006
|
-
window.removeEventListener(
|
|
3068
|
+
window.removeEventListener(Ve, n), r.disconnect(), this.floatingRouteSnapshot = null, this.floatingLifecycleCleanup = null;
|
|
3007
3069
|
};
|
|
3008
3070
|
}
|
|
3009
3071
|
clearFloatingLifecycle() {
|
|
@@ -3011,7 +3073,7 @@ class So {
|
|
|
3011
3073
|
(t = this.floatingLifecycleCleanup) == null || t.call(this);
|
|
3012
3074
|
}
|
|
3013
3075
|
}
|
|
3014
|
-
function
|
|
3076
|
+
function Ao(e, t, n) {
|
|
3015
3077
|
return {
|
|
3016
3078
|
scanToken: e.scanToken,
|
|
3017
3079
|
trace: e.trace,
|
|
@@ -3032,12 +3094,12 @@ function Eo(e, t, n) {
|
|
|
3032
3094
|
})
|
|
3033
3095
|
};
|
|
3034
3096
|
}
|
|
3035
|
-
function
|
|
3097
|
+
function Co(e, t, n, r, o) {
|
|
3036
3098
|
return {
|
|
3037
3099
|
scanToken: e,
|
|
3038
3100
|
traceId: t,
|
|
3039
3101
|
items: n.map((i) => {
|
|
3040
|
-
const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() :
|
|
3102
|
+
const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() : Mo(s == null ? void 0 : s.element);
|
|
3041
3103
|
return {
|
|
3042
3104
|
applyItemId: `${i.fieldId}_${Math.random().toString(36).slice(2, 8)}`,
|
|
3043
3105
|
fieldId: i.fieldId,
|
|
@@ -3055,12 +3117,12 @@ function xo(e, t, n, r, o) {
|
|
|
3055
3117
|
})
|
|
3056
3118
|
};
|
|
3057
3119
|
}
|
|
3058
|
-
function
|
|
3120
|
+
function sn(e) {
|
|
3059
3121
|
var t;
|
|
3060
|
-
return e.confidence >=
|
|
3122
|
+
return e.confidence >= Eo && !((t = e.warnings) != null && t.length);
|
|
3061
3123
|
}
|
|
3062
|
-
function
|
|
3063
|
-
return e.items.filter((t) => !
|
|
3124
|
+
function To(e) {
|
|
3125
|
+
return e.items.filter((t) => !sn(t)).map((t) => {
|
|
3064
3126
|
var n, r;
|
|
3065
3127
|
return {
|
|
3066
3128
|
fieldId: t.fieldId,
|
|
@@ -3071,7 +3133,7 @@ function ko(e) {
|
|
|
3071
3133
|
};
|
|
3072
3134
|
});
|
|
3073
3135
|
}
|
|
3074
|
-
function
|
|
3136
|
+
function Lo(e, t) {
|
|
3075
3137
|
const n = /* @__PURE__ */ new Map();
|
|
3076
3138
|
for (const r of t)
|
|
3077
3139
|
n.set(r.fieldId, r);
|
|
@@ -3079,10 +3141,10 @@ function _o(e, t) {
|
|
|
3079
3141
|
n.has(r.fieldId) || n.set(r.fieldId, r);
|
|
3080
3142
|
return [...n.values()];
|
|
3081
3143
|
}
|
|
3082
|
-
function
|
|
3144
|
+
function Io(e, t) {
|
|
3083
3145
|
return e === "only" ? !0 : e === "off" ? !1 : t;
|
|
3084
3146
|
}
|
|
3085
|
-
function
|
|
3147
|
+
function ft(e, t, n, r, o, i = !1) {
|
|
3086
3148
|
return {
|
|
3087
3149
|
scanToken: e,
|
|
3088
3150
|
suggestions: n,
|
|
@@ -3095,15 +3157,15 @@ function ut(e, t, n, r, o, i = !1) {
|
|
|
3095
3157
|
}
|
|
3096
3158
|
};
|
|
3097
3159
|
}
|
|
3098
|
-
function
|
|
3160
|
+
function Mo(e) {
|
|
3099
3161
|
if (e)
|
|
3100
3162
|
return e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked : e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value : e.textContent;
|
|
3101
3163
|
}
|
|
3102
|
-
function
|
|
3164
|
+
function Ro(e) {
|
|
3103
3165
|
const t = e.fields.map((n) => {
|
|
3104
3166
|
if (n.source === "registered")
|
|
3105
3167
|
return n;
|
|
3106
|
-
const r =
|
|
3168
|
+
const r = Fo(n);
|
|
3107
3169
|
return r ? { ...n, element: r } : null;
|
|
3108
3170
|
});
|
|
3109
3171
|
return t.some((n) => !n) ? null : {
|
|
@@ -3111,7 +3173,7 @@ function To(e) {
|
|
|
3111
3173
|
fields: t
|
|
3112
3174
|
};
|
|
3113
3175
|
}
|
|
3114
|
-
function
|
|
3176
|
+
function Oo(e, t) {
|
|
3115
3177
|
var s, a;
|
|
3116
3178
|
const n = new Map(t.fields.map((c) => [c.fieldId, c])), r = [], o = /* @__PURE__ */ new Set();
|
|
3117
3179
|
for (const c of e.fields) {
|
|
@@ -3130,7 +3192,7 @@ function Lo(e, t) {
|
|
|
3130
3192
|
readonly: c.readonly ?? l.readonly,
|
|
3131
3193
|
disabled: c.disabled ?? l.disabled
|
|
3132
3194
|
};
|
|
3133
|
-
u.fingerprint =
|
|
3195
|
+
u.fingerprint = X({
|
|
3134
3196
|
...u,
|
|
3135
3197
|
tagName: (a = u.element) == null ? void 0 : a.tagName.toLowerCase()
|
|
3136
3198
|
}), r.push(u);
|
|
@@ -3143,77 +3205,77 @@ function Lo(e, t) {
|
|
|
3143
3205
|
fields: [...r, ...i]
|
|
3144
3206
|
};
|
|
3145
3207
|
}
|
|
3146
|
-
function
|
|
3208
|
+
function Fo(e) {
|
|
3147
3209
|
var t;
|
|
3148
3210
|
if ((t = e.element) != null && t.isConnected) return e.element;
|
|
3149
3211
|
try {
|
|
3150
|
-
return document.querySelector(`[data-smart-fill-id="${
|
|
3212
|
+
return document.querySelector(`[data-smart-fill-id="${Zo(e.fieldId)}"]`);
|
|
3151
3213
|
} catch {
|
|
3152
3214
|
return null;
|
|
3153
3215
|
}
|
|
3154
3216
|
}
|
|
3155
|
-
function
|
|
3156
|
-
const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n =
|
|
3217
|
+
function qo(e) {
|
|
3218
|
+
const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n = an(e.root || document);
|
|
3157
3219
|
return `smart-fill:${t}:${e.formCode || "default-form"}:${n}:${e.maxFields ?? 200}:scan`;
|
|
3158
3220
|
}
|
|
3159
|
-
function
|
|
3160
|
-
const t =
|
|
3161
|
-
return `${
|
|
3221
|
+
function Do(e) {
|
|
3222
|
+
const t = an(e.root || document);
|
|
3223
|
+
return `${rn}${e.formCode || "default-form"}:${t}:${e.maxFields ?? 200}`;
|
|
3162
3224
|
}
|
|
3163
|
-
function
|
|
3225
|
+
function an(e) {
|
|
3164
3226
|
if (e === document) return "document";
|
|
3165
|
-
const t =
|
|
3227
|
+
const t = dt.get(e);
|
|
3166
3228
|
if (t) return t;
|
|
3167
|
-
const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++
|
|
3168
|
-
return
|
|
3229
|
+
const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++ko}`;
|
|
3230
|
+
return dt.set(e, n), n;
|
|
3169
3231
|
}
|
|
3170
|
-
function
|
|
3171
|
-
if (
|
|
3172
|
-
|
|
3232
|
+
function Po() {
|
|
3233
|
+
if (ut || typeof window > "u") return;
|
|
3234
|
+
ut = !0;
|
|
3173
3235
|
const e = () => {
|
|
3174
|
-
window.dispatchEvent(new Event(
|
|
3236
|
+
window.dispatchEvent(new Event(Ve));
|
|
3175
3237
|
};
|
|
3176
|
-
window.addEventListener("popstate", e), window.addEventListener("hashchange", e),
|
|
3238
|
+
window.addEventListener("popstate", e), window.addEventListener("hashchange", e), pt("pushState", e), pt("replaceState", e);
|
|
3177
3239
|
}
|
|
3178
|
-
function
|
|
3240
|
+
function pt(e, t) {
|
|
3179
3241
|
const n = window.history[e];
|
|
3180
3242
|
window.history[e] = function(...o) {
|
|
3181
3243
|
const i = n.apply(this, o);
|
|
3182
3244
|
return t(), i;
|
|
3183
3245
|
};
|
|
3184
3246
|
}
|
|
3185
|
-
function
|
|
3247
|
+
function ht() {
|
|
3186
3248
|
return typeof location > "u" ? "unknown-route" : `${location.pathname}${location.search}${location.hash}`;
|
|
3187
3249
|
}
|
|
3188
|
-
function
|
|
3189
|
-
const t =
|
|
3250
|
+
function Ho(e) {
|
|
3251
|
+
const t = No(e.floatingContainer);
|
|
3190
3252
|
if (t)
|
|
3191
3253
|
return t;
|
|
3192
|
-
const n =
|
|
3193
|
-
return n ||
|
|
3254
|
+
const n = $o(e.routeContainerSelector);
|
|
3255
|
+
return n || zo() || document.body;
|
|
3194
3256
|
}
|
|
3195
|
-
function
|
|
3196
|
-
return e ? e instanceof HTMLElement ? e :
|
|
3257
|
+
function No(e) {
|
|
3258
|
+
return e ? e instanceof HTMLElement ? e : Be(e) : null;
|
|
3197
3259
|
}
|
|
3198
|
-
function
|
|
3260
|
+
function $o(e) {
|
|
3199
3261
|
if (!e) return null;
|
|
3200
|
-
const t =
|
|
3201
|
-
return n ||
|
|
3262
|
+
const t = cn(), n = t ? Be(e, t) : null;
|
|
3263
|
+
return n || Be(e);
|
|
3202
3264
|
}
|
|
3203
|
-
function
|
|
3204
|
-
const e =
|
|
3265
|
+
function zo() {
|
|
3266
|
+
const e = cn();
|
|
3205
3267
|
if (!e)
|
|
3206
3268
|
return null;
|
|
3207
|
-
const t =
|
|
3269
|
+
const t = Ko(e);
|
|
3208
3270
|
if (t)
|
|
3209
3271
|
return t;
|
|
3210
|
-
const n =
|
|
3272
|
+
const n = Vo(e);
|
|
3211
3273
|
if (n)
|
|
3212
3274
|
return n;
|
|
3213
|
-
const r =
|
|
3275
|
+
const r = Bo(e);
|
|
3214
3276
|
return r !== e ? r : null;
|
|
3215
3277
|
}
|
|
3216
|
-
function
|
|
3278
|
+
function cn() {
|
|
3217
3279
|
const e = [
|
|
3218
3280
|
"#app",
|
|
3219
3281
|
"#root",
|
|
@@ -3227,16 +3289,16 @@ function nn() {
|
|
|
3227
3289
|
];
|
|
3228
3290
|
for (const t of e) {
|
|
3229
3291
|
const n = document.querySelector(t);
|
|
3230
|
-
if (n &&
|
|
3292
|
+
if (n && Ae(n))
|
|
3231
3293
|
return n;
|
|
3232
3294
|
}
|
|
3233
3295
|
return null;
|
|
3234
3296
|
}
|
|
3235
|
-
function
|
|
3236
|
-
const t =
|
|
3237
|
-
return r.length ? r.sort((o, i) =>
|
|
3297
|
+
function Ko(e) {
|
|
3298
|
+
const t = S(e), n = ln(e).filter((o) => !We(o)).filter((o) => S(o) >= Math.max(t * 0.2, 48e3)), r = n.filter((o) => Uo(o));
|
|
3299
|
+
return r.length ? r.sort((o, i) => S(i) - S(o))[0] : n.length === 1 ? n[0] : null;
|
|
3238
3300
|
}
|
|
3239
|
-
function
|
|
3301
|
+
function Vo(e) {
|
|
3240
3302
|
const t = [
|
|
3241
3303
|
"[data-route-root]",
|
|
3242
3304
|
"[data-router-view]",
|
|
@@ -3252,63 +3314,63 @@ function No(e) {
|
|
|
3252
3314
|
".app-content",
|
|
3253
3315
|
"main",
|
|
3254
3316
|
'[role="main"]'
|
|
3255
|
-
], n =
|
|
3256
|
-
return t.flatMap((i) => Array.from(e.querySelectorAll(i))).filter((i) =>
|
|
3317
|
+
], n = un(e), r = S(e);
|
|
3318
|
+
return t.flatMap((i) => Array.from(e.querySelectorAll(i))).filter((i) => Ae(i) && !We(i)).filter((i) => Re(i, n) <= 3).filter((i) => S(i) >= Math.max(r * 0.2, 48e3)).sort((i, s) => Re(i, n) - Re(s, n) || S(s) - S(i))[0] || null;
|
|
3257
3319
|
}
|
|
3258
|
-
function
|
|
3320
|
+
function Bo(e) {
|
|
3259
3321
|
let t = e;
|
|
3260
3322
|
for (; ; ) {
|
|
3261
|
-
const n =
|
|
3323
|
+
const n = ln(t).filter((o) => !We(o));
|
|
3262
3324
|
if (n.length !== 1)
|
|
3263
3325
|
return t;
|
|
3264
3326
|
const [r] = n;
|
|
3265
|
-
if (
|
|
3327
|
+
if (S(r) < Math.max(S(t) * 0.25, 48e3))
|
|
3266
3328
|
return t;
|
|
3267
3329
|
t = r;
|
|
3268
3330
|
}
|
|
3269
3331
|
}
|
|
3270
|
-
function
|
|
3271
|
-
return Array.from(e.children).filter((t) => t instanceof HTMLElement).filter((t) =>
|
|
3332
|
+
function ln(e) {
|
|
3333
|
+
return Array.from(e.children).filter((t) => t instanceof HTMLElement).filter((t) => Ae(t));
|
|
3272
3334
|
}
|
|
3273
|
-
function
|
|
3335
|
+
function Be(e, t = document) {
|
|
3274
3336
|
try {
|
|
3275
3337
|
const n = t.querySelector(e);
|
|
3276
|
-
return n &&
|
|
3338
|
+
return n && Ae(n) ? n : null;
|
|
3277
3339
|
} catch {
|
|
3278
3340
|
return null;
|
|
3279
3341
|
}
|
|
3280
3342
|
}
|
|
3281
|
-
function
|
|
3343
|
+
function Ae(e) {
|
|
3282
3344
|
const t = window.getComputedStyle(e);
|
|
3283
3345
|
if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
|
|
3284
3346
|
return !1;
|
|
3285
3347
|
const n = e.getBoundingClientRect();
|
|
3286
3348
|
return n.width > 0 && n.height > 0;
|
|
3287
3349
|
}
|
|
3288
|
-
function
|
|
3350
|
+
function We(e) {
|
|
3289
3351
|
const t = window.getComputedStyle(e);
|
|
3290
|
-
return t.position === "fixed" || t.position === "sticky" ? !0 :
|
|
3352
|
+
return t.position === "fixed" || t.position === "sticky" ? !0 : S(e) < 24e3;
|
|
3291
3353
|
}
|
|
3292
|
-
function
|
|
3354
|
+
function Uo(e) {
|
|
3293
3355
|
if (e.tagName.toLowerCase() === "main" || e.getAttribute("role") === "main")
|
|
3294
3356
|
return !0;
|
|
3295
3357
|
const t = e.id || "", n = typeof e.className == "string" ? e.className : "", r = `${t} ${n}`.toLowerCase();
|
|
3296
3358
|
return /(page|layout|content|container|main|router|route|view)/.test(r);
|
|
3297
3359
|
}
|
|
3298
|
-
function
|
|
3360
|
+
function S(e) {
|
|
3299
3361
|
const t = e.getBoundingClientRect();
|
|
3300
3362
|
return Math.max(0, t.width) * Math.max(0, t.height);
|
|
3301
3363
|
}
|
|
3302
|
-
function
|
|
3364
|
+
function un(e) {
|
|
3303
3365
|
let t = 0, n = e;
|
|
3304
3366
|
for (; n && n !== document.body; )
|
|
3305
3367
|
t += 1, n = n.parentElement;
|
|
3306
3368
|
return t;
|
|
3307
3369
|
}
|
|
3308
|
-
function
|
|
3309
|
-
return Math.max(0,
|
|
3370
|
+
function Re(e, t) {
|
|
3371
|
+
return Math.max(0, un(e) - t);
|
|
3310
3372
|
}
|
|
3311
|
-
function
|
|
3373
|
+
function jo(e) {
|
|
3312
3374
|
try {
|
|
3313
3375
|
const t = window.sessionStorage.getItem(e);
|
|
3314
3376
|
if (!t) return null;
|
|
@@ -3318,13 +3380,13 @@ function Ko(e) {
|
|
|
3318
3380
|
return null;
|
|
3319
3381
|
}
|
|
3320
3382
|
}
|
|
3321
|
-
function
|
|
3383
|
+
function Go(e, t) {
|
|
3322
3384
|
try {
|
|
3323
3385
|
window.sessionStorage.setItem(e, JSON.stringify(t));
|
|
3324
3386
|
} catch {
|
|
3325
3387
|
}
|
|
3326
3388
|
}
|
|
3327
|
-
function
|
|
3389
|
+
function dn(e) {
|
|
3328
3390
|
try {
|
|
3329
3391
|
if (e) {
|
|
3330
3392
|
window.sessionStorage.removeItem(e);
|
|
@@ -3333,24 +3395,24 @@ function sn(e) {
|
|
|
3333
3395
|
const t = [];
|
|
3334
3396
|
for (let n = 0; n < window.sessionStorage.length; n += 1) {
|
|
3335
3397
|
const r = window.sessionStorage.key(n);
|
|
3336
|
-
r != null && r.startsWith(
|
|
3398
|
+
r != null && r.startsWith(rn) && t.push(r);
|
|
3337
3399
|
}
|
|
3338
3400
|
for (const n of t)
|
|
3339
3401
|
window.sessionStorage.removeItem(n);
|
|
3340
3402
|
} catch {
|
|
3341
3403
|
}
|
|
3342
3404
|
}
|
|
3343
|
-
function
|
|
3405
|
+
function gt(e, t = "default") {
|
|
3344
3406
|
const n = typeof location < "u" ? location.pathname : "unknown-page", r = t.replace(/[^\w-]/g, "_") || "default";
|
|
3345
3407
|
return `smart-fill:${e}:${n}:${r}:open`;
|
|
3346
3408
|
}
|
|
3347
|
-
function
|
|
3409
|
+
function Yo(e, t) {
|
|
3348
3410
|
if (typeof e == "string") return e;
|
|
3349
3411
|
if (t.id) return `#${t.id}`;
|
|
3350
3412
|
const n = typeof t.className == "string" ? t.className.trim().split(/\s+/).filter(Boolean)[0] : "";
|
|
3351
3413
|
return n ? `.${n}` : t.tagName.toLowerCase();
|
|
3352
3414
|
}
|
|
3353
|
-
function
|
|
3415
|
+
function yt(e, t) {
|
|
3354
3416
|
try {
|
|
3355
3417
|
const n = window.localStorage.getItem(e);
|
|
3356
3418
|
return n == null ? t : n === "1";
|
|
@@ -3358,63 +3420,63 @@ function ht(e, t) {
|
|
|
3358
3420
|
return t;
|
|
3359
3421
|
}
|
|
3360
3422
|
}
|
|
3361
|
-
function
|
|
3423
|
+
function bt(e, t) {
|
|
3362
3424
|
if (e)
|
|
3363
3425
|
try {
|
|
3364
3426
|
window.localStorage.setItem(e, t ? "1" : "0");
|
|
3365
3427
|
} catch {
|
|
3366
3428
|
}
|
|
3367
3429
|
}
|
|
3368
|
-
function
|
|
3430
|
+
function fn() {
|
|
3369
3431
|
return `smart-fill:${typeof location < "u" ? location.pathname : "unknown-page"}:local-priority`;
|
|
3370
3432
|
}
|
|
3371
|
-
function
|
|
3433
|
+
function Wo() {
|
|
3372
3434
|
try {
|
|
3373
|
-
return window.localStorage.getItem(
|
|
3435
|
+
return window.localStorage.getItem(fn()) === "1";
|
|
3374
3436
|
} catch {
|
|
3375
3437
|
return !1;
|
|
3376
3438
|
}
|
|
3377
3439
|
}
|
|
3378
|
-
function
|
|
3440
|
+
function Xo(e) {
|
|
3379
3441
|
try {
|
|
3380
|
-
window.localStorage.setItem(
|
|
3442
|
+
window.localStorage.setItem(fn(), e ? "1" : "0");
|
|
3381
3443
|
} catch {
|
|
3382
3444
|
}
|
|
3383
3445
|
}
|
|
3384
|
-
function
|
|
3446
|
+
function Zo(e) {
|
|
3385
3447
|
return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
3386
3448
|
}
|
|
3387
|
-
const
|
|
3388
|
-
class
|
|
3449
|
+
const g = { status: "idle" }, Oe = new Xt(), mt = new Fr();
|
|
3450
|
+
class Jo {
|
|
3389
3451
|
/** 初始化 SDK:校验 apiKey、创建会话、获取 accessToken */
|
|
3390
3452
|
static async setup(t) {
|
|
3391
3453
|
if (typeof window > "u")
|
|
3392
|
-
return
|
|
3393
|
-
if (
|
|
3394
|
-
return
|
|
3395
|
-
if (
|
|
3396
|
-
return
|
|
3397
|
-
|
|
3398
|
-
const n = new
|
|
3399
|
-
return
|
|
3400
|
-
throw
|
|
3401
|
-
}),
|
|
3454
|
+
return g.status = "ready", Qo();
|
|
3455
|
+
if (g.status === "ready" && g.apiKey === t.apiKey && g.session)
|
|
3456
|
+
return g.session;
|
|
3457
|
+
if (g.status === "loading" && g.apiKey === t.apiKey && g.promise)
|
|
3458
|
+
return g.promise;
|
|
3459
|
+
g.apiKey && g.apiKey !== t.apiKey && (on(), mt.destroyAll());
|
|
3460
|
+
const n = new Tr(t);
|
|
3461
|
+
return g.status = "loading", g.apiKey = t.apiKey, g.client = n, g.promise = n.createSession().then((r) => (console.log("SmartFill session created:", r), n.setAccessToken(r.apiKey), g.status = "ready", g.session = r, Oe.emit("ready", { apiKey: t.apiKey }), r)).catch((r) => {
|
|
3462
|
+
throw g.status = "error", r;
|
|
3463
|
+
}), g.promise;
|
|
3402
3464
|
}
|
|
3403
3465
|
/** 创建页面实例,必须在 setup ready 后调用 */
|
|
3404
3466
|
static create(t = {}) {
|
|
3405
3467
|
if (typeof window > "u")
|
|
3406
|
-
return
|
|
3407
|
-
if (
|
|
3468
|
+
return G();
|
|
3469
|
+
if (g.status !== "ready" || !g.client)
|
|
3408
3470
|
throw v("SDK_NOT_READY", "请先 await SmartFill.setup({ apiKey })。", "setup");
|
|
3409
|
-
return new
|
|
3410
|
-
client:
|
|
3411
|
-
manager:
|
|
3471
|
+
return new _o(t, {
|
|
3472
|
+
client: g.client,
|
|
3473
|
+
manager: mt
|
|
3412
3474
|
});
|
|
3413
3475
|
}
|
|
3414
3476
|
}
|
|
3415
3477
|
/** 订阅全局事件(目前仅 ready) */
|
|
3416
|
-
d(
|
|
3417
|
-
function
|
|
3478
|
+
d(Jo, "on", Oe.on.bind(Oe));
|
|
3479
|
+
function Qo() {
|
|
3418
3480
|
return {
|
|
3419
3481
|
apiKey: "server-mock",
|
|
3420
3482
|
accessToken: "server-mock",
|
|
@@ -3424,16 +3486,16 @@ function Wo() {
|
|
|
3424
3486
|
rulesVersion: "server"
|
|
3425
3487
|
};
|
|
3426
3488
|
}
|
|
3427
|
-
function
|
|
3489
|
+
function G(e) {
|
|
3428
3490
|
const t = () => {
|
|
3429
3491
|
};
|
|
3430
3492
|
return {
|
|
3431
3493
|
on: t,
|
|
3432
|
-
useAdapter: () =>
|
|
3433
|
-
registerFields: () =>
|
|
3494
|
+
useAdapter: () => G(),
|
|
3495
|
+
registerFields: () => G(),
|
|
3434
3496
|
unregisterFields: t,
|
|
3435
|
-
mount: () =>
|
|
3436
|
-
mountFloatingButton: () =>
|
|
3497
|
+
mount: () => G(),
|
|
3498
|
+
mountFloatingButton: () => G(),
|
|
3437
3499
|
open: async () => {
|
|
3438
3500
|
},
|
|
3439
3501
|
close: t,
|
|
@@ -3451,14 +3513,14 @@ function V(e) {
|
|
|
3451
3513
|
};
|
|
3452
3514
|
}
|
|
3453
3515
|
export {
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3516
|
+
Cr as DEFAULT_BASE_URL,
|
|
3517
|
+
at as DomFiller,
|
|
3518
|
+
oo as DomScanner,
|
|
3519
|
+
ni as ElementAdapter,
|
|
3520
|
+
Xt as EventBus,
|
|
3521
|
+
jr as LocalRuleEngine,
|
|
3522
|
+
ti as NativeAdapter,
|
|
3523
|
+
Jo as SmartFill,
|
|
3524
|
+
_o as SmartFillInstance,
|
|
3525
|
+
Yt as UiFrameworkAdapter
|
|
3464
3526
|
};
|