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