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