base-screen 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/_internal/contracts/document/schema.d.ts +7 -0
  2. package/dist/_internal/contracts/document/schema.js +1 -1
  3. package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
  4. package/dist/_internal/contracts/screen-document.schema.json +15 -3
  5. package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
  6. package/dist/_internal/contracts/types/document.d.ts +3 -1
  7. package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
  8. package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
  9. package/dist/_internal/core/blueprint/runtime.d.ts +1 -0
  10. package/dist/_internal/core/blueprint/runtime.js +1 -0
  11. package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
  12. package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
  13. package/dist/_internal/core/commands/apply.js +13 -0
  14. package/dist/_internal/core/commands/parse-command.js +12 -0
  15. package/dist/_internal/core/commands/types.d.ts +29 -1
  16. package/dist/_internal/core/data/data-candidates.d.ts +38 -0
  17. package/dist/_internal/core/data/data-candidates.js +186 -0
  18. package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
  19. package/dist/_internal/core/data/dataset-profile.js +170 -0
  20. package/dist/_internal/core/data/sample-values.d.ts +25 -0
  21. package/dist/_internal/core/data/sample-values.js +45 -0
  22. package/dist/_internal/core/diff/screen-diff.js +6 -0
  23. package/dist/_internal/core/index.d.ts +7 -1
  24. package/dist/_internal/core/index.js +7 -1
  25. package/dist/_internal/core/state/state-preset.d.ts +32 -0
  26. package/dist/_internal/core/state/state-preset.js +37 -0
  27. package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
  28. package/dist/_internal/core/validation/layout-audit.js +228 -0
  29. package/dist/_internal/core/validation/legibility.d.ts +9 -0
  30. package/dist/_internal/core/validation/legibility.js +33 -0
  31. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +6 -1
  32. package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +27 -0
  33. package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +21 -5
  34. package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
  35. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +2 -0
  36. package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +3 -3
  37. package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +5 -3
  38. package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +2 -14
  39. package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +2 -0
  40. package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
  41. package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
  42. package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
  43. package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
  44. package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +7 -2
  45. package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +42 -2
  46. package/dist/_internal/engine/{designer-blueprint-workbench-panel-CJ3iZo5v.js → designer-blueprint-workbench-panel-BWSglfAb.js} +210 -290
  47. package/dist/_internal/engine/{designer-dataset-controller-CrfOg2Ys.js → designer-dataset-controller-DdbY4ILC.js} +619 -561
  48. package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
  49. package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +12 -0
  50. package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +2 -1
  51. package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +1 -1
  52. package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +4 -1
  53. package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
  54. package/dist/_internal/engine/{designer-field-primitives-KBZuWN_D.js → designer-field-primitives-Crn464Qg.js} +44 -3
  55. package/dist/_internal/engine/{designer-left-panel-groups-dom-N2OHOWjl.js → designer-left-panel-groups-dom-DFdLWxxY.js} +2 -2
  56. package/dist/_internal/engine/{host-resource-selection-xo2mLCD4.js → host-resource-selection-CWrPLVOc.js} +2 -2
  57. package/dist/_internal/engine/index.js +4742 -4360
  58. package/dist/_internal/host-kit/index.d.ts +1 -0
  59. package/dist/_internal/host-kit/index.js +1 -0
  60. package/dist/_internal/host-kit/intent/index.d.ts +16 -0
  61. package/dist/_internal/host-kit/intent/index.js +13 -0
  62. package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
  63. package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
  64. package/dist/_internal/host-kit/intent/intent-block.d.ts +59 -0
  65. package/dist/_internal/host-kit/intent/intent-block.js +359 -0
  66. package/dist/_internal/host-kit/intent/intent-catalog.d.ts +105 -0
  67. package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
  68. package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
  69. package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
  70. package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
  71. package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
  72. package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
  73. package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
  74. package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
  75. package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
  76. package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
  77. package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
  78. package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
  79. package/dist/_internal/host-kit/intent/intent-format.js +94 -0
  80. package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
  81. package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
  82. package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
  83. package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
  84. package/dist/_internal/host-kit/intent/intent-parse.d.ts +39 -0
  85. package/dist/_internal/host-kit/intent/intent-parse.js +930 -0
  86. package/dist/_internal/host-kit/intent/intent-prepare.d.ts +52 -0
  87. package/dist/_internal/host-kit/intent/intent-prepare.js +104 -0
  88. package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
  89. package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
  90. package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
  91. package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
  92. package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
  93. package/dist/_internal/host-kit/intent/intent-style.js +77 -0
  94. package/dist/_internal/host-kit/intent/intent-types.d.ts +234 -0
  95. package/dist/_internal/host-kit/intent/intent-types.js +10 -0
  96. package/dist/_internal/material/chart.js +34 -12
  97. package/dist/_internal/material/table.js +52 -21
  98. package/dist/_internal/plugin-sdk/index.d.ts +6 -0
  99. package/dist/_internal/plugin-sdk/index.js +6 -0
  100. package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
  101. package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
  102. package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
  103. package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
  104. package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
  105. package/dist/_internal/plugin-sdk/material-isolated.js +1024 -0
  106. package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +10 -2
  107. package/dist/_internal/plugin-sdk/material-rendered-element.js +71 -7
  108. package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +2 -0
  109. package/dist/_internal/plugin-sdk/material-spec-audit.js +26 -6
  110. package/dist/_internal/plugin-sdk/material-spec.d.ts +20 -0
  111. package/dist/_internal/plugin-sdk/material-spec.js +78 -3
  112. package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
  113. package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
  114. package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
  115. package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
  116. package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
  117. package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
  118. package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
  119. package/dist/_internal/plugin-sdk/material-template.js +879 -0
  120. package/dist/auto-register.js +10 -10
  121. package/dist/contracts.js +5 -5
  122. package/dist/contrast-DRPezUIl.js +131 -0
  123. package/dist/contrast-DRPezUIl.js.map +1 -0
  124. package/dist/core.js +156 -136
  125. package/dist/core.js.map +1 -1
  126. package/dist/dataset-profile-Dk6xdtsM.js +261 -0
  127. package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
  128. package/dist/{designer-3Tb0EIDV.js → designer-CFOvOmLn.js} +2 -2
  129. package/dist/{designer-3Tb0EIDV.js.map → designer-CFOvOmLn.js.map} +1 -1
  130. package/dist/designer-auto-register.js +5 -5
  131. package/dist/{designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js → designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js} +452 -531
  132. package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map +1 -0
  133. package/dist/{designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js → designer-dataset-controller-DdbY4ILC-CMdGdGbr.js} +862 -804
  134. package/dist/designer-dataset-controller-DdbY4ILC-CMdGdGbr.js.map +1 -0
  135. package/dist/{designer-field-primitives-KBZuWN_D-B3h4jpYe.js → designer-field-primitives-Crn464Qg-Bi7q8s5J.js} +45 -4
  136. package/dist/designer-field-primitives-Crn464Qg-Bi7q8s5J.js.map +1 -0
  137. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js} +4 -4
  138. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js.map → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js.map} +1 -1
  139. package/dist/designer.js +5 -5
  140. package/dist/{dist-6GRboBs-.js → dist-B2bW2Tru.js} +4 -4
  141. package/dist/{dist-6GRboBs-.js.map → dist-B2bW2Tru.js.map} +1 -1
  142. package/dist/{dist-BjLjFUy1.js → dist-CHK9BTXX.js} +3833 -3453
  143. package/dist/dist-CHK9BTXX.js.map +1 -0
  144. package/dist/engine.js +5 -5
  145. package/dist/{fragment-Y6YnW6wy.js → fragment-B-oP0Fru.js} +3 -3
  146. package/dist/{fragment-Y6YnW6wy.js.map → fragment-B-oP0Fru.js.map} +1 -1
  147. package/dist/host-kit.js +3963 -187
  148. package/dist/host-kit.js.map +1 -1
  149. package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js → host-resource-selection-CWrPLVOc-DPDq3jau.js} +5 -5
  150. package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js.map → host-resource-selection-CWrPLVOc-DPDq3jau.js.map} +1 -1
  151. package/dist/index.js +10 -10
  152. package/dist/legibility-CS28ivEz.js +12 -0
  153. package/dist/legibility-CS28ivEz.js.map +1 -0
  154. package/dist/{level-scale-BzUjE31V.js → level-scale-CwHqFEVd.js} +2 -2
  155. package/dist/{level-scale-BzUjE31V.js.map → level-scale-CwHqFEVd.js.map} +1 -1
  156. package/dist/{manager-Ch0RTu_i.js → manager-CeB4Jnr9.js} +3 -3
  157. package/dist/{manager-Ch0RTu_i.js.map → manager-CeB4Jnr9.js.map} +1 -1
  158. package/dist/{material-UbSfiuZq.js → material-DeVkzSoT.js} +2 -2
  159. package/dist/{material-UbSfiuZq.js.map → material-DeVkzSoT.js.map} +1 -1
  160. package/dist/material-auto-register.js +1 -1
  161. package/dist/material.js +2 -2
  162. package/dist/{migrate-document-D3HhCVlZ.js → migrate-document-BM888PtC.js} +2 -2
  163. package/dist/{migrate-document-D3HhCVlZ.js.map → migrate-document-BM888PtC.js.map} +1 -1
  164. package/dist/{parse-AOTE9WnD.js → parse-Ji7kE9ZT.js} +9 -4
  165. package/dist/parse-Ji7kE9ZT.js.map +1 -0
  166. package/dist/{parse-B1OD1teS.js → parse-aZat9tAS.js} +3 -3
  167. package/dist/{parse-B1OD1teS.js.map → parse-aZat9tAS.js.map} +1 -1
  168. package/dist/{parse-parts-BNrpdG5o.js → parse-parts-qzl4suzk.js} +2 -2
  169. package/dist/{parse-parts-BNrpdG5o.js.map → parse-parts-qzl4suzk.js.map} +1 -1
  170. package/dist/{plugin-DHgh9uHh.js → plugin-CstHQ5ws.js} +4 -4
  171. package/dist/{plugin-DHgh9uHh.js.map → plugin-CstHQ5ws.js.map} +1 -1
  172. package/dist/plugin-core.js +2 -2
  173. package/dist/plugin-manager.js +1 -1
  174. package/dist/plugin-package-DWifuHi1.js +4206 -0
  175. package/dist/plugin-package-DWifuHi1.js.map +1 -0
  176. package/dist/{plugin-registration-rsmb4GvS.js → plugin-registration-DTwBvnHX.js} +2 -2
  177. package/dist/{plugin-registration-rsmb4GvS.js.map → plugin-registration-DTwBvnHX.js.map} +1 -1
  178. package/dist/plugin-sdk.js +6 -6
  179. package/dist/{plugins-DGRHgREK.js → plugins-QDL0yIql.js} +2 -2
  180. package/dist/{plugins-DGRHgREK.js.map → plugins-QDL0yIql.js.map} +1 -1
  181. package/dist/plugins.js +8 -8
  182. package/dist/renderer.js +1 -1
  183. package/dist/{runtime-dispatch-BfnRDtMe.js → runtime-dispatch-C0gyIrTv.js} +2 -2
  184. package/dist/{runtime-dispatch-BfnRDtMe.js.map → runtime-dispatch-C0gyIrTv.js.map} +1 -1
  185. package/dist/runtime-simulate-aSYO9yDX.js +147 -0
  186. package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
  187. package/dist/{src-Bm7u11mN-_0u6cMEw.js → src-Bm7u11mN-Bi1hDVkh.js} +39 -39
  188. package/dist/{src-Bm7u11mN-_0u6cMEw.js.map → src-Bm7u11mN-Bi1hDVkh.js.map} +1 -1
  189. package/dist/state-preset-DtpygJOH.js +22 -0
  190. package/dist/state-preset-DtpygJOH.js.map +1 -0
  191. package/dist/{text-BNksUr5J.js → text-BSTz0pFQ.js} +87 -34
  192. package/dist/text-BSTz0pFQ.js.map +1 -0
  193. package/dist/{value-ref-BG_MV9C-.js → value-ref-XkLuckGV.js} +2 -2
  194. package/dist/{value-ref-BG_MV9C-.js.map → value-ref-XkLuckGV.js.map} +1 -1
  195. package/dist/{viewer-CrJupI8I-D9dVcNw4.js → viewer-CrJupI8I-BJiz1cvW.js} +4 -4
  196. package/dist/{viewer-CrJupI8I-D9dVcNw4.js.map → viewer-CrJupI8I-BJiz1cvW.js.map} +1 -1
  197. package/dist/viewer-auto-register.js +2 -2
  198. package/dist/viewer.js +2 -2
  199. package/dist/{viewport-CiCKeAQH.js → viewport-BNIRWjiT.js} +354 -155
  200. package/dist/viewport-BNIRWjiT.js.map +1 -0
  201. package/package.json +12 -12
  202. package/dist/designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js.map +0 -1
  203. package/dist/designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js.map +0 -1
  204. package/dist/designer-field-primitives-KBZuWN_D-B3h4jpYe.js.map +0 -1
  205. package/dist/dist-BjLjFUy1.js.map +0 -1
  206. package/dist/parse-AOTE9WnD.js.map +0 -1
  207. package/dist/plugin-package-Dr5ro6h6.js +0 -1221
  208. package/dist/plugin-package-Dr5ro6h6.js.map +0 -1
  209. package/dist/text-BNksUr5J.js.map +0 -1
  210. package/dist/viewport-CiCKeAQH.js.map +0 -1
@@ -0,0 +1,4206 @@
1
+ import { i as e, r as t } from "./image-url-D6mUcjY1.js";
2
+ import { Nt as n } from "./parse-Ji7kE9ZT.js";
3
+ import { t as r } from "./equality-DjZ9cv4u.js";
4
+ import { u as i } from "./plugin-CstHQ5ws.js";
5
+ import { t as a } from "./material-schema-CLoDx-Tl.js";
6
+ import { r as o, t as s } from "./fragment-B-oP0Fru.js";
7
+ import { i as c } from "./material-theme-C91eus78.js";
8
+ import { r as l, t as u } from "./material-manifest-B1XatGPx.js";
9
+ import { a as d, o as f, r as p } from "./contrast-DRPezUIl.js";
10
+ import { n as m } from "./legibility-CS28ivEz.js";
11
+ import { a as h, i as g, n as _, r as v } from "./material-definition-BeW34dJr.js";
12
+ import { n as y, r as b, t as x } from "./material-state-view-Bw7xIkEg.js";
13
+ import { n as S } from "./plugin-registration-DTwBvnHX.js";
14
+ //#region ../plugin-sdk/dist/authoring-finding.js
15
+ function C(e) {
16
+ return [...e.filter((e) => e.severity === "error"), ...e.filter((e) => e.severity === "warning")];
17
+ }
18
+ function ee(e) {
19
+ return e.some((e) => e.severity === "error");
20
+ }
21
+ //#endregion
22
+ //#region ../plugin-sdk/dist/fragment-audit.js
23
+ var te = 8, ne = 2, w = .9, re = /* @__PURE__ */ new Set(["base.rectangle", "base.container"]);
24
+ function ie(e, t) {
25
+ let n = o(e);
26
+ if (!n.ok) return n.diagnostics.map((e) => ({
27
+ rule: "SPEC",
28
+ severity: "error",
29
+ message: e.message,
30
+ path: e.path
31
+ }));
32
+ let r = n.value, i = [];
33
+ return t !== void 0 && ae(r, t, i), oe(r, i), se(r, i), ce(r, i), r.nodes.forEach((e, t) => {
34
+ (e.name === void 0 || e.name.trim() === "") && i.push({
35
+ rule: "F9",
36
+ severity: "warning",
37
+ message: `节点 ${e.key} 没有名称:插入后图层里只显示物料名。`,
38
+ path: [
39
+ "nodes",
40
+ t,
41
+ "name"
42
+ ]
43
+ });
44
+ }), C(i);
45
+ }
46
+ function ae(e, t, n) {
47
+ let r = [...e.shell === void 0 ? [] : [[e.shell, ["shell"]]], ...e.nodes.map((e, t) => [e, ["nodes", t]])];
48
+ for (let [i, a] of r) {
49
+ let r = t.get(i.materialType)?.manifest;
50
+ if (r === void 0) {
51
+ n.push({
52
+ rule: "F8",
53
+ severity: "error",
54
+ message: `引用的物料 ${i.materialType} 不在物料目录里。`,
55
+ path: [...a, "materialType"]
56
+ });
57
+ continue;
58
+ }
59
+ r.libraryVisible === !1 && n.push({
60
+ rule: "F8",
61
+ severity: "warning",
62
+ message: `「${r.name}」已下架:已有组合仍可插入,但新作者在物料库里找不到它。`,
63
+ path: [...a, "materialType"]
64
+ }), i === e.shell && r.designCapabilities.children !== !0 && n.push({
65
+ rule: "F8",
66
+ severity: "error",
67
+ message: `外壳「${r.name}」不接受子节点,改用容器。`,
68
+ path: [...a, "materialType"]
69
+ });
70
+ }
71
+ }
72
+ function oe(e, t) {
73
+ if (e.shell !== void 0 || e.nodes.length < 2) return;
74
+ let [n, ...r] = e.nodes;
75
+ if (n === void 0 || !re.has(n.materialType)) return;
76
+ let i = le(n), a = r.map(le).filter((e) => e !== void 0);
77
+ i !== void 0 && a.length !== 0 && a.filter((e) => ue(e, i) >= w).length === a.length && t.push({
78
+ rule: "F2",
79
+ severity: "warning",
80
+ message: "底板由外壳承担:把这块矩形换成容器,其余节点放进容器后整体存为组合,卡片才能整体移动、缩放。",
81
+ path: ["nodes", 0]
82
+ });
83
+ }
84
+ function se(e, t) {
85
+ let n = e.nodes.flatMap((e) => e.dataSource === void 0 || e.dataSource === null ? [] : [e.dataSource]);
86
+ for (let e = 0; e < n.length; e += 1) {
87
+ let i = n[e];
88
+ if (i.type !== "dataset" && i.type !== "host-resource") continue;
89
+ let a = (e) => e.type === i.type && r(de(e), de(i));
90
+ if (!n.slice(0, e).some(a) && n.slice(e + 1).some(a)) {
91
+ t.push({
92
+ rule: "F4",
93
+ severity: "warning",
94
+ message: "多个节点各自查询同一个数据源:改为共享文档级数据源,一次查询、多处读取。",
95
+ path: ["nodes"]
96
+ });
97
+ return;
98
+ }
99
+ }
100
+ }
101
+ function ce(e, t) {
102
+ e.nodes.length > te && t.push({
103
+ rule: "F6",
104
+ severity: "warning",
105
+ message: `组合有 ${e.nodes.length} 个节点(建议不超过 ${te} 个):更像页面模板,考虑拆成几个组合。`,
106
+ path: ["nodes"]
107
+ });
108
+ let n = new Map(e.nodes.map((e) => [e.key, e.parent])), r = (e, t = 0) => e === void 0 || t > 64 ? t : r(n.get(e), t + 1), i = Math.max(0, ...e.nodes.map((e) => r(e.key)));
109
+ i > ne && t.push({
110
+ rule: "F6",
111
+ severity: "warning",
112
+ message: `组合嵌套 ${i} 层(建议不超过 ${ne} 层)。`,
113
+ path: ["nodes"]
114
+ });
115
+ }
116
+ function le(e) {
117
+ if (e.size !== void 0) return {
118
+ x: e.offset?.x ?? 0,
119
+ y: e.offset?.y ?? 0,
120
+ width: e.size.width,
121
+ height: e.size.height
122
+ };
123
+ }
124
+ function ue(e, t) {
125
+ let n = Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x), r = Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y), i = e.width * e.height;
126
+ return n <= 0 || r <= 0 || i <= 0 ? 0 : n * r / i;
127
+ }
128
+ function de(e) {
129
+ let { binding: t, ...n } = e;
130
+ return n;
131
+ }
132
+ //#endregion
133
+ //#region ../plugin-sdk/dist/fragment-definition.js
134
+ function fe(e) {
135
+ let t = o(e);
136
+ if (!t.ok) return t;
137
+ let n = {
138
+ kind: "fragment",
139
+ ...t.value
140
+ };
141
+ return {
142
+ ok: !0,
143
+ value: Object.freeze(n),
144
+ diagnostics: []
145
+ };
146
+ }
147
+ //#endregion
148
+ //#region ../plugin-sdk/dist/material-config-groups.js
149
+ var pe = 16, me = 6;
150
+ function he(e = {}) {
151
+ let t = Math.min(Math.max(Math.trunc(e.maxDecimals ?? 4), 0), me), n = Math.min(Math.max(Math.trunc(e.decimals ?? 0), 0), t), r = {}, i = {}, a = [], o = ["decimals"], s = ge(e.prefix);
152
+ s !== void 0 && (r.prefix = {
153
+ kind: "string",
154
+ maxLength: pe
155
+ }, i.prefix = s, a.push(T("prefix", "前缀")));
156
+ let c = ge(e.unit);
157
+ return c !== void 0 && (r.unit = {
158
+ kind: "string",
159
+ maxLength: pe
160
+ }, i.unit = c, a.push(T("unit", "单位"))), r.decimals = {
161
+ kind: "number",
162
+ minimum: 0,
163
+ maximum: t
164
+ }, i.decimals = n, a.push(T("decimals", "小数位")), e.thousandsSeparator !== void 0 && (r.thousandsSeparator = { kind: "boolean" }, i.thousandsSeparator = e.thousandsSeparator, o.push("thousandsSeparator"), a.push(T("thousandsSeparator", "显示千分位"))), {
165
+ id: "number-format",
166
+ properties: r,
167
+ required: o,
168
+ defaults: i,
169
+ fields: a
170
+ };
171
+ }
172
+ function ge(e) {
173
+ return typeof e == "string" ? [...e].slice(0, pe).join("") : e === !0 ? "" : void 0;
174
+ }
175
+ function _e() {
176
+ return {
177
+ id: "chart-title",
178
+ properties: { titleText: { kind: "string" } },
179
+ required: ["titleText"],
180
+ defaults: { titleText: "" },
181
+ fields: [T("titleText", "标题", { placeholder: "留空不显示" })]
182
+ };
183
+ }
184
+ function ve(e = {}) {
185
+ return {
186
+ id: "chart-legend",
187
+ properties: { showLegend: { kind: "boolean" } },
188
+ required: ["showLegend"],
189
+ defaults: { showLegend: e.showLegend ?? !0 },
190
+ fields: [T("showLegend", "显示图例")]
191
+ };
192
+ }
193
+ function ye(e) {
194
+ let t = {}, n = {}, r = [];
195
+ for (let i of e) {
196
+ for (let [e, n] of Object.entries(i.properties)) {
197
+ if (Object.hasOwn(t, e)) throw Error(`Material config groups overlap on props key "${e}".`);
198
+ t[e] = n;
199
+ }
200
+ Object.assign(n, i.defaults), r.push(...i.required);
201
+ }
202
+ return {
203
+ properties: t,
204
+ required: r,
205
+ defaults: n
206
+ };
207
+ }
208
+ function T(e, t, n = {}) {
209
+ return {
210
+ id: e,
211
+ target: "props",
212
+ path: [e],
213
+ label: t,
214
+ ...n
215
+ };
216
+ }
217
+ //#endregion
218
+ //#region ../plugin-sdk/dist/material-editor-audit.js
219
+ var be = 12, xe = 12, Se = /* @__PURE__ */ new Set([
220
+ "array",
221
+ "repeatable-array",
222
+ "reorderable-array"
223
+ ]);
224
+ function Ce(e) {
225
+ let t = [], n = (n, r, i) => {
226
+ t.push({
227
+ rule: n,
228
+ materialType: e.type,
229
+ ...i === void 0 ? {} : { field: i.id },
230
+ message: r
231
+ });
232
+ };
233
+ ((e.propertyPanel ?? []).length > 0 || (e.stylePanel ?? []).length > 0) && n("R12", "仍声明扁平 propertyPanel / stylePanel;改为 editorDescriptor。");
234
+ let r = e.editorDescriptor;
235
+ for (let e of r?.appearance ?? []) e.id === "motion" && e.advanced !== !0 && n("R15", "「动效」分区应标 advanced:动效属于仅全量可见的效果类设置。"), e.id !== "motion" && e.advanced === !0 && n("R15", `分区「${e.label}」不能标 advanced:物料分区里只有动效仅全量可见。`);
236
+ let i = [
237
+ r?.appearance,
238
+ r?.data,
239
+ r?.interaction
240
+ ];
241
+ for (let t of i) for (let r of t ?? []) for (let t of r.fields) {
242
+ we(t, Oe(e, t), n);
243
+ let r = ke(e, t);
244
+ for (let i of t.itemFields ?? []) we(i, i.target === "interaction" ? i.projection === "style" ? e.styleSchema : e.propsSchema : i.target === "props" || i.target === "style" ? r : void 0, n);
245
+ }
246
+ let a = (r?.appearance ?? []).flatMap((e) => Ae(e));
247
+ return a.length > be && n("R9", `基础密度下可见字段 ${a.length} 个,超过 ${be} 个。`), Ee(e, n), t;
248
+ }
249
+ function we(e, t, n) {
250
+ let r = t === void 0 ? void 0 : c(e.path, t);
251
+ e.advanced === !0 && n("R15", `字段「${e.label}」不能单独标 advanced;整段隐藏或保持可见。`, e);
252
+ let i = l(e, r);
253
+ i !== void 0 && !Te(e.control, i, r) && n("R11", `控件是 ${e.control},按字段语义应为 ${i}(可省略 control)。`, e);
254
+ let a = e.label;
255
+ je(a) > xe && n("R13", `标签「${a}」超过 6 个汉字。`, e), a.includes("是否") && n("R13", `标签「${a}」不写「是否」。`, e), /[(())]|\b(?:px|ms)\b|%/.test(a) && n("R13", `标签「${a}」不带括号或单位,单位写进 unit。`, e), e.control === "color" && !a.endsWith("色") && n("R13", `颜色字段「${a}」应以「色」结尾。`, e), e.control === "boolean" && /^(?:不|禁用|隐藏)/.test(a) && n("R13", `开关「${a}」用正向表述。`, e);
256
+ }
257
+ function Te(e, t, n) {
258
+ return e === t || e === "custom" || e === "json" || e === "group" || Se.has(e) && n?.kind === "array" || n?.kind === "string" && (e === "text" || e === "color" || e === "field-selector") ? !0 : n?.kind === "enum" && e === "segmented" && n.values.length <= 3;
259
+ }
260
+ function Ee(e, t) {
261
+ let n = (e.editorDescriptor?.appearance ?? []).flatMap((e) => e.fields);
262
+ for (let [r, i] of De) {
263
+ let a = e.propsSchema.properties[r];
264
+ if (a === void 0) continue;
265
+ if (a.kind !== i.schema.kind) {
266
+ t("R14", `props.${r} 是配置组「${i.group}」的键,类型应为 ${i.schema.kind}。`);
267
+ continue;
268
+ }
269
+ let o = n.find((e) => e.target === "props" && e.path.length === 1 && e.path[0] === r);
270
+ o === void 0 ? t("R14", `props.${r} 属于配置组「${i.group}」,检查器里缺少该字段。`) : o.label !== i.label && t("R14", `props.${r} 的标签应为配置组的「${i.label}」。`, o);
271
+ }
272
+ }
273
+ var De = new Map([
274
+ he({
275
+ prefix: !0,
276
+ unit: !0,
277
+ thousandsSeparator: !0
278
+ }),
279
+ _e(),
280
+ ve()
281
+ ].flatMap((e) => e.fields.map((t) => {
282
+ let n = String(t.path[0]), r = e.properties[n];
283
+ return [n, {
284
+ group: e.id,
285
+ label: t.label,
286
+ schema: r
287
+ }];
288
+ })));
289
+ function Oe(e, t) {
290
+ let n = t.target === "interaction" ? t.projection : t.target;
291
+ if (n === "props") return e.propsSchema;
292
+ if (n === "style") return e.styleSchema;
293
+ }
294
+ function ke(e, t) {
295
+ let n = Oe(e, t), r = n === void 0 ? void 0 : c(t.path, n);
296
+ return r?.kind === "array" && r.items.kind === "object" ? r.items : void 0;
297
+ }
298
+ function Ae(e) {
299
+ return e.collapsed === !0 || e.advanced === !0 ? [] : e.fields.filter((e) => e.advanced !== !0);
300
+ }
301
+ function je(e) {
302
+ let t = 0;
303
+ for (let n of e) t += (n.codePointAt(0) ?? 0) > 11904 ? 2 : 1;
304
+ return t;
305
+ }
306
+ //#endregion
307
+ //#region ../plugin-sdk/dist/material-isolated-csp.js
308
+ var Me = [
309
+ "default-src 'none'",
310
+ "style-src 'unsafe-inline'",
311
+ "img-src data: blob:",
312
+ "font-src data:",
313
+ "base-uri 'none'",
314
+ "form-action 'none'"
315
+ ], Ne = /^'sha256-[A-Za-z0-9+/]{43}='$/, Pe = /^[0-9a-f]{64}$/, Fe = 16;
316
+ function Ie(e) {
317
+ return Array.isArray(e) && e.length > 0 && e.length <= 16 && e.every((e) => typeof e == "string" && Ne.test(e));
318
+ }
319
+ function Le(e) {
320
+ return [
321
+ Me[0],
322
+ `script-src ${e.join(" ")}`,
323
+ ...Me.slice(1)
324
+ ].join("; ");
325
+ }
326
+ function Re(e, t) {
327
+ if (Ie(e) && !(t.trim() === "" || /[;,\r\n]/.test(t))) return [
328
+ "sandbox allow-scripts",
329
+ Le(e),
330
+ `frame-ancestors ${t.trim()}`
331
+ ].join("; ");
332
+ }
333
+ var ze = {
334
+ "Content-Type": "text/html; charset=utf-8",
335
+ "X-Content-Type-Options": "nosniff",
336
+ "Referrer-Policy": "no-referrer",
337
+ "Cache-Control": "public, max-age=31536000, immutable",
338
+ "Cross-Origin-Resource-Policy": "same-site"
339
+ };
340
+ //#endregion
341
+ //#region ../plugin-sdk/dist/material-isolated-runtime.js
342
+ function Be(e) {
343
+ let t = globalThis, n = /* @__PURE__ */ new Map(), r = 1e3 / e.maxFps - 1, i = null, a = typeof window.name == "string" ? window.name : "";
344
+ try {
345
+ window.name = "";
346
+ } catch {}
347
+ let o = (e, t) => String(e).slice(0, t), s = [], c = (e, t = []) => {
348
+ if (i === null) {
349
+ let t = e?.type;
350
+ (t === "error" || t === "csp") && s.length < 20 && s.push(e);
351
+ return;
352
+ }
353
+ try {
354
+ i.postMessage(e, t);
355
+ } catch {}
356
+ }, l = (e, t) => {
357
+ let n = o(t?.message ?? t, 200);
358
+ c(e === void 0 ? {
359
+ type: "error",
360
+ message: n
361
+ } : {
362
+ type: "error",
363
+ id: e,
364
+ message: n
365
+ });
366
+ };
367
+ document.addEventListener("securitypolicyviolation", (e) => {
368
+ c({
369
+ type: "csp",
370
+ directive: o(e.effectiveDirective, 64),
371
+ uri: o(e.blockedURI, 200)
372
+ });
373
+ }), window.addEventListener("error", (e) => l(void 0, e.message)), window.addEventListener("unhandledrejection", (e) => l(void 0, e.reason)), window.addEventListener("message", (e) => {
374
+ if (i !== null || e.source !== window.parent) return;
375
+ let t = e.data;
376
+ if (!(typeof t != "object" || !t || t.type !== "bs-connect") && a !== "" && t.token === a && e.ports.length === 1) {
377
+ i = e.ports[0], i.onmessage = (e) => {
378
+ try {
379
+ p(e.data);
380
+ } catch (e) {
381
+ l(void 0, e);
382
+ }
383
+ }, c({ type: "ready" });
384
+ for (let e of s.splice(0)) c(e);
385
+ }
386
+ });
387
+ let u = () => {
388
+ let n = {};
389
+ for (let [r, i] of e.libraries) n[r] = t[i];
390
+ return Object.freeze(n);
391
+ };
392
+ function d(e) {
393
+ return Object.freeze({
394
+ size: Object.freeze({
395
+ width: e.w,
396
+ height: e.h
397
+ }),
398
+ dpr: e.dpr,
399
+ props: e.props,
400
+ style: e.style,
401
+ mode: e.mode,
402
+ value: e.value,
403
+ rows: e.rows,
404
+ interactive: e.interactive
405
+ });
406
+ }
407
+ function f(e) {
408
+ let t = Math.max(1, Math.round(e.state.w * e.state.dpr)), n = Math.max(1, Math.round(e.state.h * e.state.dpr));
409
+ e.canvas.width !== t && (e.canvas.width = t), e.canvas.height !== n && (e.canvas.height = n), e.container !== null && (e.container.style.width = `${e.state.w}px`, e.container.style.height = `${e.state.h}px`);
410
+ }
411
+ function p(e) {
412
+ if (typeof e != "object" || !e) return;
413
+ if (e.type === "tick") {
414
+ h(e.now, Array.isArray(e.ids) ? e.ids : []);
415
+ return;
416
+ }
417
+ if (e.type === "mount") {
418
+ m(e.id, e.state);
419
+ return;
420
+ }
421
+ let t = n.get(e.id);
422
+ if (t !== void 0) {
423
+ if (e.type === "update") {
424
+ let n = t.state;
425
+ if (t.state = e.state, (n.w !== e.state.w || n.h !== e.state.h || n.dpr !== e.state.dpr) && f(t), t.updated = !0, t.impl === null) return;
426
+ try {
427
+ t.impl.update?.(d(e.state));
428
+ } catch (t) {
429
+ l(e.id, t);
430
+ }
431
+ return;
432
+ }
433
+ if (e.type === "pointer") {
434
+ try {
435
+ t.impl?.click?.(e.x, e.y);
436
+ } catch (t) {
437
+ l(e.id, t);
438
+ }
439
+ return;
440
+ }
441
+ if (e.type === "unmount") {
442
+ try {
443
+ t.impl?.dispose?.();
444
+ } catch {}
445
+ t.container?.remove(), n.delete(e.id);
446
+ }
447
+ }
448
+ }
449
+ function m(e, r) {
450
+ let i = {
451
+ id: e,
452
+ state: r,
453
+ canvas: new OffscreenCanvas(1, 1),
454
+ container: null,
455
+ impl: null,
456
+ updated: !0,
457
+ shipping: !1,
458
+ lastShip: -Infinity
459
+ };
460
+ f(i), n.set(e, i);
461
+ let a = t.__bsCreate;
462
+ if (typeof a != "function") {
463
+ l(e, "组件代码没有导出 create(env)。");
464
+ return;
465
+ }
466
+ let s = d(r), p = Object.freeze({
467
+ ...s,
468
+ canvas: i.canvas,
469
+ libraries: u(),
470
+ formatNumber: (e) => t.__bsFormat(e, i.state.props),
471
+ emit: (t, n) => c({
472
+ type: "event",
473
+ id: e,
474
+ name: o(t, 128),
475
+ payload: n
476
+ }),
477
+ createContainer: () => {
478
+ if (i.container === null) {
479
+ let e = document.createElement("div");
480
+ e.style.cssText = "position:absolute;left:0;top:0;overflow:hidden", document.body.appendChild(e), i.container = e, f(i);
481
+ }
482
+ return i.container;
483
+ }
484
+ });
485
+ try {
486
+ let t = a(p);
487
+ if (typeof t != "object" || !t || typeof t.frame != "function") {
488
+ l(e, "create(env) 必须返回带 frame(now) 的对象。");
489
+ return;
490
+ }
491
+ i.impl = t;
492
+ } catch (t) {
493
+ l(e, t);
494
+ }
495
+ }
496
+ function h(e, t) {
497
+ let i = [];
498
+ for (let a of t) {
499
+ let t = n.get(a);
500
+ if (t !== void 0 && t.impl !== null) {
501
+ if (!t.shipping && e - t.lastShip >= r) {
502
+ let n = !1;
503
+ try {
504
+ n = t.impl.frame(e) !== !1;
505
+ } catch (e) {
506
+ l(a, e);
507
+ continue;
508
+ }
509
+ (n || t.updated) && g(t, e);
510
+ }
511
+ t.updated && i.push(a);
512
+ }
513
+ }
514
+ c({
515
+ type: "tock",
516
+ pending: i
517
+ });
518
+ }
519
+ function g(e, t) {
520
+ let r = e.canvas;
521
+ try {
522
+ r = e.impl.surface?.() ?? e.canvas;
523
+ } catch (t) {
524
+ l(e.id, t);
525
+ return;
526
+ }
527
+ r != null && r.width !== 0 && r.height !== 0 && (e.shipping = !0, e.updated = !1, e.lastShip = t, createImageBitmap(r).then((t) => {
528
+ if (e.shipping = !1, !n.has(e.id)) {
529
+ t.close();
530
+ return;
531
+ }
532
+ c({
533
+ type: "bitmap",
534
+ id: e.id,
535
+ bitmap: t
536
+ }, [t]);
537
+ }, (t) => {
538
+ e.shipping = !1, e.updated = !0, l(e.id, t);
539
+ }));
540
+ }
541
+ }
542
+ //#endregion
543
+ //#region ../plugin-sdk/dist/material-template-expression.js
544
+ var E = {
545
+ sourceLength: 400,
546
+ depth: 16,
547
+ nodes: 64,
548
+ concatLength: 256
549
+ }, Ve = 2e4, He = {
550
+ min: {
551
+ min: 2,
552
+ max: 8
553
+ },
554
+ max: {
555
+ min: 2,
556
+ max: 8
557
+ },
558
+ clamp: {
559
+ min: 3,
560
+ max: 3
561
+ },
562
+ abs: {
563
+ min: 1,
564
+ max: 1
565
+ },
566
+ round: {
567
+ min: 1,
568
+ max: 2
569
+ },
570
+ floor: {
571
+ min: 1,
572
+ max: 1
573
+ },
574
+ ceil: {
575
+ min: 1,
576
+ max: 1
577
+ },
578
+ sqrt: {
579
+ min: 1,
580
+ max: 1
581
+ },
582
+ sin: {
583
+ min: 1,
584
+ max: 1
585
+ },
586
+ cos: {
587
+ min: 1,
588
+ max: 1
589
+ },
590
+ scale: {
591
+ min: 5,
592
+ max: 5
593
+ },
594
+ pct: {
595
+ min: 1,
596
+ max: 3
597
+ },
598
+ format: {
599
+ min: 1,
600
+ max: 1
601
+ },
602
+ fixed: {
603
+ min: 2,
604
+ max: 2
605
+ },
606
+ concat: {
607
+ min: 1,
608
+ max: 8
609
+ },
610
+ pick: {
611
+ min: 4,
612
+ max: 24,
613
+ even: !0
614
+ },
615
+ len: {
616
+ min: 1,
617
+ max: 1
618
+ },
619
+ charAt: {
620
+ min: 2,
621
+ max: 2
622
+ },
623
+ maxOf: {
624
+ min: 2,
625
+ max: 2,
626
+ aggregate: !0
627
+ },
628
+ minOf: {
629
+ min: 2,
630
+ max: 2,
631
+ aggregate: !0
632
+ },
633
+ sumOf: {
634
+ min: 2,
635
+ max: 2,
636
+ aggregate: !0
637
+ }
638
+ }, Ue = Object.keys(He), We = [
639
+ "==",
640
+ "!=",
641
+ "<=",
642
+ ">=",
643
+ "&&",
644
+ "||",
645
+ "<",
646
+ ">",
647
+ "+",
648
+ "-",
649
+ "*",
650
+ "/",
651
+ "%",
652
+ "!",
653
+ "?",
654
+ ":",
655
+ "(",
656
+ ")",
657
+ ",",
658
+ "."
659
+ ];
660
+ function Ge(e) {
661
+ let t = [], n = 0;
662
+ for (; n < e.length;) {
663
+ let r = e[n];
664
+ if (r === " " || r === " " || r === "\n" || r === "\r") {
665
+ n += 1;
666
+ continue;
667
+ }
668
+ if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(e[n + 1] ?? "")) {
669
+ let r = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(n));
670
+ if (r === null) return `第 ${n + 1} 个字符不是合法的数字。`;
671
+ t.push({
672
+ t: "num",
673
+ v: Number(r[0])
674
+ }), n += r[0].length;
675
+ continue;
676
+ }
677
+ if (r === "'" || r === "\"") {
678
+ let i = n + 1, a = "";
679
+ for (; i < e.length && e[i] !== r;) {
680
+ if (e[i] === "\\") return "字符串里不支持转义。";
681
+ a += e[i], i += 1;
682
+ }
683
+ if (i >= e.length) return "字符串缺少结束引号。";
684
+ t.push({
685
+ t: "str",
686
+ v: a
687
+ }), n = i + 1;
688
+ continue;
689
+ }
690
+ if (/[A-Za-z_]/.test(r)) {
691
+ let r = /^[A-Za-z_][A-Za-z0-9_]*/.exec(e.slice(n));
692
+ t.push({
693
+ t: "id",
694
+ v: r[0]
695
+ }), n += r[0].length;
696
+ continue;
697
+ }
698
+ let i = We.find((t) => e.startsWith(t, n));
699
+ if (i === void 0) return `不认识的符号「${r}」。`;
700
+ t.push({
701
+ t: "op",
702
+ v: i
703
+ }), n += i.length;
704
+ }
705
+ return t.push({ t: "end" }), t;
706
+ }
707
+ var D = class extends Error {}, Ke = {
708
+ "||": 1,
709
+ "&&": 2,
710
+ "==": 3,
711
+ "!=": 3,
712
+ "<": 4,
713
+ "<=": 4,
714
+ ">": 4,
715
+ ">=": 4,
716
+ "+": 5,
717
+ "-": 5,
718
+ "*": 6,
719
+ "/": 6,
720
+ "%": 6
721
+ }, qe = class {
722
+ tokens;
723
+ scope;
724
+ #e = 0;
725
+ #t = 0;
726
+ constructor(e, t) {
727
+ this.tokens = e, this.scope = t;
728
+ }
729
+ parse() {
730
+ let e = this.#s(0);
731
+ if (this.#n().t !== "end") throw new D("表达式结尾有多余内容。");
732
+ return e;
733
+ }
734
+ #n() {
735
+ return this.tokens[this.#e];
736
+ }
737
+ #r() {
738
+ let e = this.tokens[this.#e];
739
+ return this.#e += 1, e;
740
+ }
741
+ #i(e) {
742
+ let t = this.#n();
743
+ return t.t === "op" && t.v === e;
744
+ }
745
+ #a(e) {
746
+ if (!this.#i(e)) throw new D(`缺少「${e}」。`);
747
+ this.#e += 1;
748
+ }
749
+ #o(e, t) {
750
+ if (this.#t += 1, this.#t > E.nodes) throw new D(`表达式过长(最多 ${E.nodes} 个节点)。`);
751
+ if (t > E.depth) throw new D(`表达式嵌套过深(最多 ${E.depth} 层)。`);
752
+ return e;
753
+ }
754
+ #s(e) {
755
+ let t = this.#c(1, e);
756
+ if (!this.#i("?")) return t;
757
+ this.#e += 1;
758
+ let n = this.#s(e + 1);
759
+ this.#a(":");
760
+ let r = this.#s(e + 1);
761
+ return this.#o({
762
+ k: "cond",
763
+ t,
764
+ a: n,
765
+ b: r
766
+ }, e);
767
+ }
768
+ #c(e, t) {
769
+ let n = this.#l(t + 1);
770
+ for (;;) {
771
+ let r = this.#n();
772
+ if (r.t !== "op") return n;
773
+ let i = Ke[r.v];
774
+ if (i === void 0 || i < e) return n;
775
+ this.#e += 1;
776
+ let a = this.#c(i + 1, t + 1);
777
+ n = this.#o({
778
+ k: "bin",
779
+ op: r.v,
780
+ a: n,
781
+ b: a
782
+ }, t);
783
+ }
784
+ }
785
+ #l(e) {
786
+ if (this.#i("-") || this.#i("!")) {
787
+ let t = this.#r().v;
788
+ return this.#o({
789
+ k: "un",
790
+ op: t,
791
+ a: this.#l(e + 1)
792
+ }, e);
793
+ }
794
+ return this.#u(e);
795
+ }
796
+ #u(e) {
797
+ let t = this.#r();
798
+ if (t.t === "num" || t.t === "str") return this.#o({
799
+ k: "lit",
800
+ v: t.v
801
+ }, e);
802
+ if (t.t === "op" && t.v === "(") {
803
+ let t = this.#s(e + 1);
804
+ return this.#a(")"), t;
805
+ }
806
+ if (t.t === "id") return t.v === "true" || t.v === "false" ? this.#o({
807
+ k: "lit",
808
+ v: t.v === "true"
809
+ }, e) : t.v === "null" ? this.#o({
810
+ k: "lit",
811
+ v: null
812
+ }, e) : this.#i("(") ? this.#d(t.v, e) : this.#p(t.v, e);
813
+ throw new D("表达式不完整。");
814
+ }
815
+ #d(e, t) {
816
+ let n = He[e];
817
+ if (n === void 0) throw new D(`不支持函数 ${e}(可用:${Ue.join("、")})。`);
818
+ this.#a("(");
819
+ let r = [];
820
+ if (!this.#i(")")) for (; n.aggregate === !0 && r.length === 0 ? r.push(this.#f(e, t + 1)) : r.push(this.#s(t + 1)), this.#i(",");) this.#e += 1;
821
+ if (this.#a(")"), r.length < n.min || r.length > n.max) throw new D(n.min === n.max ? `${e} 需要 ${n.min} 个参数。` : `${e} 需要 ${n.min}–${n.max} 个参数。`);
822
+ if (n.even === !0 && r.length % 2 != 0) throw new D(`${e} 的参数是「取值, 键1, 值1, …, 缺省值」,个数应为偶数。`);
823
+ if (n.aggregate === !0) {
824
+ let t = r[1];
825
+ if (t?.k !== "lit" || typeof t.v != "string" || !this.scope.roles.has(t.v)) throw new D(`${e} 的第二个参数必须是已声明的数据角色名(用引号写)。`);
826
+ }
827
+ return this.#o({
828
+ k: "call",
829
+ fn: e,
830
+ args: r
831
+ }, t);
832
+ }
833
+ #f(e, t) {
834
+ let n = this.#r();
835
+ if (n.t !== "id" || n.v !== "rows") throw new D(`${e} 的第一个参数必须是 rows。`);
836
+ if (this.scope.data !== "rows") throw new D("组件不是多行数据,不能读 rows。");
837
+ return this.#o({
838
+ k: "ref",
839
+ root: "rows"
840
+ }, t);
841
+ }
842
+ #p(e, t) {
843
+ let n;
844
+ if (this.#i(".")) {
845
+ this.#e += 1;
846
+ let t = this.#r();
847
+ if (t.t !== "id") throw new D(`${e}. 后面缺少字段名。`);
848
+ if (n = t.v, this.#i(".")) throw new D("引用只能有一层(如 props.showLabel)。");
849
+ }
850
+ let r = this.scope;
851
+ switch (e) {
852
+ case "value":
853
+ if (n !== void 0) throw new D("value 后面不能再接字段。");
854
+ if (r.data !== "scalar") throw new D("组件不是单值数据,不能读 value。");
855
+ return this.#o({
856
+ k: "ref",
857
+ root: "value"
858
+ }, t);
859
+ case "index":
860
+ case "count":
861
+ if (n !== void 0) throw new D(`${e} 后面不能再接字段。`);
862
+ if (!r.inRepeat) throw new D(`${e} 只能用在 repeat 里。`);
863
+ return this.#o({
864
+ k: "ref",
865
+ root: e
866
+ }, t);
867
+ case "rows": throw new D("rows 只能交给 maxOf / minOf / sumOf。");
868
+ case "row":
869
+ if (!r.inRowRepeat) throw new D("row 只能用在遍历 rows 的 repeat 里。");
870
+ if (n === void 0 || !r.roles.has(n)) throw new D(`row.${n ?? ""} 不是已声明的数据角色。`);
871
+ return this.#o({
872
+ k: "ref",
873
+ root: "row",
874
+ key: n
875
+ }, t);
876
+ case "props":
877
+ case "style": {
878
+ let i = e === "props" ? r.props : r.style;
879
+ if (n === void 0 || !i.has(n)) throw new D(`${e}.${n ?? ""} 不是规格里声明的${e === "props" ? "参数" : "样式"}字段。`);
880
+ return this.#o({
881
+ k: "ref",
882
+ root: e,
883
+ key: n
884
+ }, t);
885
+ }
886
+ case "size":
887
+ if (n !== "width" && n !== "height") throw new D("size 只有 width / height。");
888
+ return this.#o({
889
+ k: "ref",
890
+ root: "size",
891
+ key: n
892
+ }, t);
893
+ default: throw new D(`不认识的名字 ${e}(可用:value、row.<角色>、index、count、props.<键>、style.<键>、size.width / height)。`);
894
+ }
895
+ }
896
+ };
897
+ function Je(e, t) {
898
+ if (e.length > E.sourceLength) return {
899
+ ok: !1,
900
+ message: `表达式最多 ${E.sourceLength} 个字符。`
901
+ };
902
+ let n = Ge(e);
903
+ if (typeof n == "string") return {
904
+ ok: !1,
905
+ message: n
906
+ };
907
+ try {
908
+ return {
909
+ ok: !0,
910
+ value: new qe(n, t).parse()
911
+ };
912
+ } catch (e) {
913
+ if (e instanceof D) return {
914
+ ok: !1,
915
+ message: e.message
916
+ };
917
+ throw e;
918
+ }
919
+ }
920
+ var Ye = class extends Error {
921
+ constructor() {
922
+ super("模板求值超出步数上限。"), this.name = "BaseScreenMaterialTemplateBudgetError";
923
+ }
924
+ };
925
+ function O(e, t) {
926
+ if (--t.budget.steps, t.budget.steps < 0) throw new Ye();
927
+ switch (e.k) {
928
+ case "lit": return e.v;
929
+ case "ref": return Xe(e.root, e.key, t);
930
+ case "un": {
931
+ let n = O(e.a, t);
932
+ return e.op === "-" ? -j(n) : !M(n);
933
+ }
934
+ case "cond": return M(O(e.t, t)) ? O(e.a, t) : O(e.b, t);
935
+ case "bin": return Ze(e, t);
936
+ case "call": return Qe(e.fn, e.args, t);
937
+ }
938
+ }
939
+ function Xe(e, t, n) {
940
+ switch (e) {
941
+ case "value": return n.value;
942
+ case "index": return n.index ?? null;
943
+ case "count": return n.count ?? null;
944
+ case "row": return k(t === void 0 ? void 0 : n.row?.[t]);
945
+ case "props": return k(t === void 0 ? void 0 : n.props[t]);
946
+ case "style": return k(t === void 0 ? void 0 : n.style[t]);
947
+ case "size": return t === "height" ? n.size.height : n.size.width;
948
+ case "rows": return null;
949
+ }
950
+ }
951
+ function Ze(e, t) {
952
+ if (e.op === "&&") {
953
+ let n = O(e.a, t);
954
+ return M(n) ? O(e.b, t) : n;
955
+ }
956
+ if (e.op === "||") {
957
+ let n = O(e.a, t);
958
+ return M(n) ? n : O(e.b, t);
959
+ }
960
+ let n = O(e.a, t), r = O(e.b, t);
961
+ switch (e.op) {
962
+ case "==": return et(n, r);
963
+ case "!=": return !et(n, r);
964
+ case "<": return j(n) < j(r);
965
+ case "<=": return j(n) <= j(r);
966
+ case ">": return j(n) > j(r);
967
+ case ">=": return j(n) >= j(r);
968
+ case "+": return j(n) + j(r);
969
+ case "-": return j(n) - j(r);
970
+ case "*": return j(n) * j(r);
971
+ case "/": return j(n) / j(r);
972
+ case "%": return j(n) % j(r);
973
+ }
974
+ }
975
+ function Qe(e, t, n) {
976
+ if (e === "maxOf" || e === "minOf" || e === "sumOf") {
977
+ let r = t[1].v, i = n.rows.map((e) => j(k(e[r]))).filter(Number.isFinite);
978
+ if (n.budget.steps -= n.rows.length, n.budget.steps < 0) throw new Ye();
979
+ return i.length === 0 ? null : e === "sumOf" ? i.reduce((e, t) => e + t, 0) : e === "maxOf" ? Math.max(...i) : Math.min(...i);
980
+ }
981
+ if (e === "pick") {
982
+ let e = O(t[0], n);
983
+ for (let r = 1; r <= t.length - 3; r += 2) if (et(e, O(t[r], n))) return O(t[r + 1], n);
984
+ return O(t[t.length - 1], n);
985
+ }
986
+ let r = t.map((e) => O(e, n)), i = (e) => j(r[e] ?? null);
987
+ switch (e) {
988
+ case "min": return Math.min(...r.map((e) => j(e)));
989
+ case "max": return Math.max(...r.map((e) => j(e)));
990
+ case "clamp": return Math.min(Math.max(i(0), i(1)), i(2));
991
+ case "abs": return Math.abs(i(0));
992
+ case "round": {
993
+ let e = 10 ** (r.length > 1 ? Math.max(0, Math.min(6, Math.trunc(i(1)))) : 0);
994
+ return Math.round(i(0) * e) / e;
995
+ }
996
+ case "floor": return Math.floor(i(0));
997
+ case "ceil": return Math.ceil(i(0));
998
+ case "sqrt": return Math.sqrt(i(0));
999
+ case "sin": return Math.sin(i(0) * Math.PI / 180);
1000
+ case "cos": return Math.cos(i(0) * Math.PI / 180);
1001
+ case "scale": {
1002
+ let [e, t, n, r, a] = [
1003
+ i(0),
1004
+ i(1),
1005
+ i(2),
1006
+ i(3),
1007
+ i(4)
1008
+ ];
1009
+ return n === t ? r : r + (e - t) / (n - t) * (a - r);
1010
+ }
1011
+ case "pct": {
1012
+ let e = r.length > 1 ? i(1) : 0, t = r.length > 2 ? i(2) : 100;
1013
+ return t === e ? 0 : Math.min(1, Math.max(0, (i(0) - e) / (t - e)));
1014
+ }
1015
+ case "format": return n.formatNumber(r[0]);
1016
+ case "fixed": {
1017
+ let e = i(0);
1018
+ return Number.isFinite(e) ? e.toFixed(Math.max(0, Math.min(6, Math.trunc(i(1))))) : "--";
1019
+ }
1020
+ case "concat": return r.map((e) => e === null ? "" : String(e)).join("").slice(0, E.concatLength);
1021
+ case "len": return r[0] === null ? 0 : [...String(r[0])].length;
1022
+ case "charAt": return (r[0] === null ? [] : [...String(r[0])])[Math.trunc(i(1))] ?? "";
1023
+ default: return null;
1024
+ }
1025
+ }
1026
+ function k(e) {
1027
+ return e == null ? null : typeof e == "number" || typeof e == "string" || typeof e == "boolean" ? e : null;
1028
+ }
1029
+ function A(e) {
1030
+ return j(e);
1031
+ }
1032
+ function j(e) {
1033
+ return typeof e == "number" ? e : typeof e == "boolean" ? +!!e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
1034
+ }
1035
+ function $e(e) {
1036
+ return M(e);
1037
+ }
1038
+ function M(e) {
1039
+ return typeof e == "number" ? e !== 0 && !Number.isNaN(e) : e !== null && e !== !1 && e !== "";
1040
+ }
1041
+ function et(e, t) {
1042
+ return typeof e == typeof t ? e === t : typeof e == "number" && typeof t == "string" || typeof e == "string" && typeof t == "number" ? j(e) === j(t) : !1;
1043
+ }
1044
+ //#endregion
1045
+ //#region ../plugin-sdk/dist/material-template.js
1046
+ var N = {
1047
+ nodes: 300,
1048
+ repeat: 200,
1049
+ animations: 8,
1050
+ events: 4,
1051
+ gradients: 8,
1052
+ pathCommands: 64,
1053
+ dash: 6,
1054
+ minDuration: 100,
1055
+ maxDuration: 2e4
1056
+ }, tt = [
1057
+ "g",
1058
+ "repeat",
1059
+ "when",
1060
+ "clip",
1061
+ "rect",
1062
+ "circle",
1063
+ "ellipse",
1064
+ "line",
1065
+ "polyline",
1066
+ "path",
1067
+ "text",
1068
+ "arc",
1069
+ "ticks",
1070
+ "wave"
1071
+ ], P = {
1072
+ g: [
1073
+ "x",
1074
+ "y",
1075
+ "scale",
1076
+ "rotate"
1077
+ ],
1078
+ repeat: [],
1079
+ when: [],
1080
+ clip: [],
1081
+ rect: [
1082
+ "x",
1083
+ "y",
1084
+ "width",
1085
+ "height",
1086
+ "rx"
1087
+ ],
1088
+ circle: [
1089
+ "cx",
1090
+ "cy",
1091
+ "r"
1092
+ ],
1093
+ ellipse: [
1094
+ "cx",
1095
+ "cy",
1096
+ "rx",
1097
+ "ry"
1098
+ ],
1099
+ line: [
1100
+ "x1",
1101
+ "y1",
1102
+ "x2",
1103
+ "y2"
1104
+ ],
1105
+ polyline: [],
1106
+ path: [],
1107
+ text: [
1108
+ "x",
1109
+ "y",
1110
+ "fontSize"
1111
+ ],
1112
+ arc: [
1113
+ "cx",
1114
+ "cy",
1115
+ "r",
1116
+ "thickness",
1117
+ "start",
1118
+ "end"
1119
+ ],
1120
+ ticks: [
1121
+ "cx",
1122
+ "cy",
1123
+ "r",
1124
+ "length",
1125
+ "count",
1126
+ "start",
1127
+ "end"
1128
+ ],
1129
+ wave: [
1130
+ "x",
1131
+ "y",
1132
+ "width",
1133
+ "height",
1134
+ "amplitude",
1135
+ "wavelength",
1136
+ "phase"
1137
+ ]
1138
+ }, nt = {
1139
+ rect: [
1140
+ "x",
1141
+ "y",
1142
+ "width",
1143
+ "height"
1144
+ ],
1145
+ circle: [
1146
+ "cx",
1147
+ "cy",
1148
+ "r"
1149
+ ],
1150
+ ellipse: [
1151
+ "cx",
1152
+ "cy",
1153
+ "rx",
1154
+ "ry"
1155
+ ],
1156
+ line: [
1157
+ "x1",
1158
+ "y1",
1159
+ "x2",
1160
+ "y2"
1161
+ ],
1162
+ text: [
1163
+ "x",
1164
+ "y",
1165
+ "fontSize"
1166
+ ],
1167
+ arc: [
1168
+ "cx",
1169
+ "cy",
1170
+ "r",
1171
+ "thickness",
1172
+ "start",
1173
+ "end"
1174
+ ],
1175
+ ticks: [
1176
+ "cx",
1177
+ "cy",
1178
+ "r",
1179
+ "length",
1180
+ "count",
1181
+ "start",
1182
+ "end"
1183
+ ],
1184
+ wave: [
1185
+ "x",
1186
+ "y",
1187
+ "width",
1188
+ "height",
1189
+ "amplitude",
1190
+ "wavelength"
1191
+ ]
1192
+ }, rt = /* @__PURE__ */ new Set([
1193
+ "rect",
1194
+ "circle",
1195
+ "ellipse",
1196
+ "line",
1197
+ "polyline",
1198
+ "path",
1199
+ "text",
1200
+ "arc",
1201
+ "ticks",
1202
+ "wave"
1203
+ ]), it = /* @__PURE__ */ new Set([
1204
+ "rect",
1205
+ "circle",
1206
+ "ellipse",
1207
+ "path"
1208
+ ]), at = /* @__PURE__ */ new Set([
1209
+ "g",
1210
+ "repeat",
1211
+ "when",
1212
+ "clip"
1213
+ ]), ot = /* @__PURE__ */ new Set([
1214
+ "rect",
1215
+ "circle",
1216
+ "ellipse",
1217
+ "path",
1218
+ "wave",
1219
+ "polyline"
1220
+ ]), st = {
1221
+ g: ["children", "opacity"],
1222
+ repeat: ["source", "children"],
1223
+ when: ["test", "children"],
1224
+ clip: ["shape", "children"],
1225
+ rect: [],
1226
+ circle: [],
1227
+ ellipse: [],
1228
+ line: [],
1229
+ polyline: ["points", "closed"],
1230
+ path: ["d"],
1231
+ text: [
1232
+ "content",
1233
+ "fontWeight",
1234
+ "anchor",
1235
+ "baseline",
1236
+ "backdrop"
1237
+ ],
1238
+ arc: ["linecap"],
1239
+ ticks: [],
1240
+ wave: []
1241
+ }, ct = [
1242
+ "fill",
1243
+ "stroke",
1244
+ "strokeWidth",
1245
+ "strokeDasharray",
1246
+ "strokeLinecap",
1247
+ "opacity",
1248
+ "on"
1249
+ ], lt = /^[a-z][A-Za-z0-9-]{0,39}$/, ut = /^[a-z][A-Za-z0-9]{0,31}$/, dt = /^[a-z][A-Za-z0-9]{0,31}$/, F = /^(?:#[0-9a-fA-F]{3,4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}|(?:rgb|rgba|hsl|hsla)\([0-9.,%\s/deg]*\)|transparent|none|currentColor)$/, ft = {
1250
+ M: 2,
1251
+ L: 2,
1252
+ H: 1,
1253
+ V: 1,
1254
+ C: 6,
1255
+ Q: 4,
1256
+ A: 7,
1257
+ Z: 0
1258
+ }, pt = /* @__PURE__ */ new Set([
1259
+ "translateX",
1260
+ "translateY",
1261
+ "rotate",
1262
+ "scale",
1263
+ "opacity"
1264
+ ]), mt = /* @__PURE__ */ new Set([
1265
+ "linear",
1266
+ "ease",
1267
+ "ease-in",
1268
+ "ease-out",
1269
+ "ease-in-out"
1270
+ ]), ht = /* @__PURE__ */ new Set([
1271
+ "start",
1272
+ "middle",
1273
+ "end"
1274
+ ]), gt = /* @__PURE__ */ new Set([
1275
+ "auto",
1276
+ "middle",
1277
+ "hanging"
1278
+ ]), _t = /* @__PURE__ */ new Set([
1279
+ "butt",
1280
+ "round",
1281
+ "square"
1282
+ ]), vt = /* @__PURE__ */ new Set([
1283
+ 400,
1284
+ 500,
1285
+ 600,
1286
+ 700
1287
+ ]), yt = (e, t) => `${e}:${t}`;
1288
+ function I(e, t) {
1289
+ let n = new bt(t), r = n.compile(e);
1290
+ return n.diagnostics.length > 0 || r === void 0 ? {
1291
+ ok: !1,
1292
+ diagnostics: n.diagnostics
1293
+ } : {
1294
+ ok: !0,
1295
+ value: r,
1296
+ diagnostics: []
1297
+ };
1298
+ }
1299
+ var bt = class {
1300
+ context;
1301
+ diagnostics = [];
1302
+ #e = /* @__PURE__ */ new Map();
1303
+ #t = /* @__PURE__ */ new Set();
1304
+ #n = /* @__PURE__ */ new Set();
1305
+ #r;
1306
+ #i;
1307
+ #a;
1308
+ #o;
1309
+ #s;
1310
+ #c;
1311
+ #l = 0;
1312
+ constructor(e) {
1313
+ this.context = e, this.#r = /* @__PURE__ */ new Set(), this.#i = /* @__PURE__ */ new Set(), this.#o = /* @__PURE__ */ new Set(), this.#s = /* @__PURE__ */ new Set();
1314
+ for (let t of e.fields) (e.sectionTarget(t.section) === "props" ? this.#r : this.#i).add(t.key), t.kind === "color" && this.#o.add(t.key), t.kind === "number" && this.#s.add(t.key);
1315
+ this.#a = new Set(e.data.kind === "rows" ? e.data.roles.map((e) => e.id) : []), this.#c = new Map((e.events ?? []).map((e) => [e.name, e]));
1316
+ }
1317
+ #u(e, t, n) {
1318
+ this.diagnostics.push({
1319
+ severity: "error",
1320
+ code: "PLUGIN_CORE_MANIFEST_FIELD_INVALID",
1321
+ path: ["template", ...t],
1322
+ message: yt(e, n)
1323
+ });
1324
+ }
1325
+ compile(e) {
1326
+ if (!L(e)) {
1327
+ this.#u("TPL4", [], "模板必须是对象。");
1328
+ return;
1329
+ }
1330
+ for (let t of Object.keys(e)) [
1331
+ "viewBox",
1332
+ "fit",
1333
+ "defs",
1334
+ "nodes",
1335
+ "animations"
1336
+ ].includes(t) || this.#u("TPL1", [t], `模板没有字段 ${t}。`);
1337
+ let t = e.viewBox, n = Array.isArray(t) && t.length === 4 && t.every((e) => typeof e == "number" && Number.isFinite(e)) && t[2] > 0 && t[3] > 0;
1338
+ n || this.#u("TPL4", ["viewBox"], "viewBox 必须是 [x, y, 宽, 高] 四个数字,宽高大于 0。");
1339
+ let r = e.fit ?? "contain";
1340
+ r !== "contain" && r !== "cover" && r !== "stretch" && this.#u("TPL4", ["fit"], "fit 只能是 contain / cover / stretch。");
1341
+ let i = this.#d(e.defs), a = {
1342
+ props: this.#r,
1343
+ style: this.#i,
1344
+ roles: this.#a,
1345
+ data: this.context.data.kind,
1346
+ inRepeat: !1,
1347
+ inRowRepeat: !1
1348
+ };
1349
+ if (!Array.isArray(e.nodes) || e.nodes.length === 0) {
1350
+ this.#u("TPL4", ["nodes"], "nodes 必须是非空数组。");
1351
+ return;
1352
+ }
1353
+ let o = this.#p(e.nodes, ["nodes"], a);
1354
+ this.#_();
1355
+ let s = this.#x(e.animations, a);
1356
+ if (n) return {
1357
+ viewBox: t,
1358
+ fit: r,
1359
+ gradients: i,
1360
+ nodes: o,
1361
+ animations: s,
1362
+ index: this.#e
1363
+ };
1364
+ }
1365
+ #d(e) {
1366
+ if (e === void 0) return [];
1367
+ if (!Array.isArray(e)) return this.#u("TPL4", ["defs"], "defs 必须是数组。"), [];
1368
+ e.length > N.gradients && this.#u("TPL3", ["defs"], `渐变最多 ${N.gradients} 个。`);
1369
+ let t = [];
1370
+ return e.forEach((e, n) => {
1371
+ let r = ["defs", n];
1372
+ if (!L(e) || e.kind !== "linearGradient" && e.kind !== "radialGradient") {
1373
+ this.#u("TPL1", r, "defs 里只能是 linearGradient / radialGradient。");
1374
+ return;
1375
+ }
1376
+ let i = e.kind === "linearGradient" ? [
1377
+ "x1",
1378
+ "y1",
1379
+ "x2",
1380
+ "y2"
1381
+ ] : [
1382
+ "cx",
1383
+ "cy",
1384
+ "r"
1385
+ ];
1386
+ for (let t of Object.keys(e)) [
1387
+ "kind",
1388
+ "id",
1389
+ "stops",
1390
+ ...i
1391
+ ].includes(t) || this.#u("TPL1", [...r, t], `${e.kind} 没有字段 ${t}。`);
1392
+ let a = e.id;
1393
+ if (typeof a != "string" || !lt.test(a)) {
1394
+ this.#u("TPL4", [...r, "id"], "id 为小写字母开头的字母、数字、连字符(≤ 40)。");
1395
+ return;
1396
+ }
1397
+ this.#n.has(a) && this.#u("TPL4", [...r, "id"], `渐变 id ${a} 重复。`), this.#n.add(a);
1398
+ let o = e.kind === "linearGradient" ? {
1399
+ x1: 0,
1400
+ y1: 0,
1401
+ x2: 0,
1402
+ y2: 1
1403
+ } : {
1404
+ cx: .5,
1405
+ cy: .5,
1406
+ r: .5
1407
+ }, s = {};
1408
+ for (let t of i) {
1409
+ let n = e[t] ?? o[t];
1410
+ typeof n != "number" || !Number.isFinite(n) || n < -1 || n > 2 ? this.#u("TPL4", [...r, t], `${t} 是 -1 到 2 之间的数字(相对图形包围盒的比例)。`) : s[t] = n;
1411
+ }
1412
+ let c = [];
1413
+ !Array.isArray(e.stops) || e.stops.length < 2 || e.stops.length > 8 ? this.#u("TPL4", [...r, "stops"], "stops 是 2–8 个色标。") : e.stops.forEach((e, t) => {
1414
+ let n = [
1415
+ ...r,
1416
+ "stops",
1417
+ t
1418
+ ];
1419
+ if (!L(e)) {
1420
+ this.#u("TPL4", n, "色标必须是对象。");
1421
+ return;
1422
+ }
1423
+ for (let t of Object.keys(e)) [
1424
+ "offset",
1425
+ "color",
1426
+ "opacity"
1427
+ ].includes(t) || this.#u("TPL1", [...n, t], `色标没有字段 ${t}。`);
1428
+ let i = e.offset;
1429
+ (typeof i != "number" || i < 0 || i > 1) && this.#u("TPL4", [...n, "offset"], "offset 是 0–1 的数字。");
1430
+ let a = e.opacity ?? 1;
1431
+ (typeof a != "number" || a < 0 || a > 1) && this.#u("TPL4", [...n, "opacity"], "opacity 是 0–1 的数字。");
1432
+ let o = this.#w(e.color, [...n, "color"], this.#f(), !1);
1433
+ o !== void 0 && typeof i == "number" && typeof a == "number" && c.push({
1434
+ offset: i,
1435
+ color: o,
1436
+ opacity: a
1437
+ });
1438
+ }), t.push({
1439
+ kind: e.kind,
1440
+ id: a,
1441
+ geometry: s,
1442
+ stops: c
1443
+ });
1444
+ }), t;
1445
+ }
1446
+ #f() {
1447
+ return {
1448
+ props: this.#r,
1449
+ style: this.#i,
1450
+ roles: this.#a,
1451
+ data: this.context.data.kind,
1452
+ inRepeat: !1,
1453
+ inRowRepeat: !1
1454
+ };
1455
+ }
1456
+ #p(e, t, n) {
1457
+ let r = [];
1458
+ return e.forEach((e, i) => {
1459
+ let a = this.#m(e, [...t, i], n);
1460
+ a !== void 0 && r.push(a);
1461
+ }), r;
1462
+ }
1463
+ #m(e, t, n) {
1464
+ if (this.#l += 1, this.#l === N.nodes + 1 && this.#u("TPL3", t, `模板节点最多 ${N.nodes} 个。`), !L(e)) {
1465
+ this.#u("TPL4", t, "节点必须是对象。");
1466
+ return;
1467
+ }
1468
+ let r = e.kind;
1469
+ if (typeof r != "string" || !tt.includes(r)) {
1470
+ this.#u("TPL1", [...t, "kind"], `不支持的节点 ${String(r)}(可用:${tt.join("、")};不支持 foreignObject、image、use、script、style、filter)。`);
1471
+ return;
1472
+ }
1473
+ let i = r, a = e.id;
1474
+ if (typeof a != "string" || !lt.test(a)) {
1475
+ this.#u("TPL4", [...t, "id"], "每个节点都要有 id:小写字母开头的字母、数字、连字符(≤ 40)。");
1476
+ return;
1477
+ }
1478
+ this.#t.has(a) && this.#u("TPL4", [...t, "id"], `节点 id ${a} 重复。`), this.#t.add(a);
1479
+ let o = /* @__PURE__ */ new Set([
1480
+ "kind",
1481
+ "id",
1482
+ ...P[i],
1483
+ ...st[i],
1484
+ ...rt.has(i) ? ct : []
1485
+ ]);
1486
+ for (let n of Object.keys(e)) if (!o.has(n)) {
1487
+ let e = /^on[A-Z]|^href$|^xlink|^style$|^class$|^filter$/.test(n) ? "(不支持事件属性、外部引用、样式字符串与滤镜)" : "";
1488
+ this.#u("TPL1", [...t, n], `${i} 没有字段 ${n}${e}。`);
1489
+ }
1490
+ let s = {};
1491
+ for (let r of P[i]) {
1492
+ if (e[r] === void 0) continue;
1493
+ let i = this.#C(e[r], [...t, r], n);
1494
+ i !== void 0 && (s[r] = i);
1495
+ }
1496
+ for (let n of nt[i] ?? []) e[n] === void 0 && this.#u("TPL4", [...t, n], `${i} 缺少 ${n}。`);
1497
+ let c = {
1498
+ kind: i,
1499
+ id: a,
1500
+ path: t,
1501
+ num: s
1502
+ };
1503
+ if (rt.has(i) && this.#h(e, i, t, n, c, s), i === "g" && e.opacity !== void 0) {
1504
+ let r = this.#C(e.opacity, [...t, "opacity"], n);
1505
+ r !== void 0 && (s.opacity = r);
1506
+ }
1507
+ switch (i) {
1508
+ case "text":
1509
+ this.#g(e, t, n, c, s);
1510
+ break;
1511
+ case "repeat": {
1512
+ let r = this.#b(e.source, [...t, "source"], n);
1513
+ r !== void 0 && (c.source = r);
1514
+ break;
1515
+ }
1516
+ case "when": {
1517
+ let r = this.#S(e.test, [...t, "test"], n);
1518
+ r !== void 0 && (c.test = r);
1519
+ break;
1520
+ }
1521
+ case "clip": {
1522
+ let r = e.shape;
1523
+ if (!L(r) || typeof r.kind != "string" || !it.has(r.kind)) this.#u("TPL4", [...t, "shape"], "clip.shape 必须是一个 rect / circle / ellipse / path 节点。");
1524
+ else {
1525
+ let e = this.#m(r, [...t, "shape"], n);
1526
+ e !== void 0 && (c.clipShape = e);
1527
+ }
1528
+ break;
1529
+ }
1530
+ case "polyline":
1531
+ this.#v(e, t, n, c);
1532
+ break;
1533
+ case "path":
1534
+ this.#y(e.d, [...t, "d"], n, c);
1535
+ break;
1536
+ case "arc": e.linecap !== void 0 && (typeof e.linecap != "string" || !_t.has(e.linecap) ? this.#u("TPL4", [...t, "linecap"], "linecap 只能是 butt / round / square。") : c.linecap = e.linecap);
1537
+ }
1538
+ if (at.has(i)) {
1539
+ let r = i === "repeat" ? {
1540
+ ...n,
1541
+ inRepeat: !0,
1542
+ inRowRepeat: n.inRowRepeat || c.source?.k === "rows"
1543
+ } : n;
1544
+ Array.isArray(e.children) ? c.children = this.#p(e.children, [...t, "children"], r) : this.#u("TPL4", [...t, "children"], `${i} 需要 children 数组。`);
1545
+ }
1546
+ let l = c;
1547
+ return this.#e.set(a, l), l;
1548
+ }
1549
+ #h(e, t, n, r, i, a) {
1550
+ if (e.fill !== void 0) {
1551
+ let t = this.#w(e.fill, [...n, "fill"], r, !0);
1552
+ t !== void 0 && (i.fill = t);
1553
+ }
1554
+ if (e.stroke !== void 0) {
1555
+ let t = this.#w(e.stroke, [...n, "stroke"], r, !0);
1556
+ t !== void 0 && (i.stroke = t);
1557
+ }
1558
+ for (let t of ["strokeWidth", "opacity"]) {
1559
+ if (e[t] === void 0) continue;
1560
+ let i = this.#C(e[t], [...n, t], r);
1561
+ i !== void 0 && (a[t] = i);
1562
+ }
1563
+ if (e.strokeDasharray !== void 0) {
1564
+ let t = e.strokeDasharray;
1565
+ !Array.isArray(t) || t.length === 0 || t.length > N.dash ? this.#u("TPL4", [...n, "strokeDasharray"], `strokeDasharray 是 1–${N.dash} 个数字。`) : i.dash = t.map((e, t) => this.#C(e, [
1566
+ ...n,
1567
+ "strokeDasharray",
1568
+ t
1569
+ ], r)).filter((e) => e !== void 0);
1570
+ }
1571
+ if (e.strokeLinecap !== void 0 && (typeof e.strokeLinecap != "string" || !_t.has(e.strokeLinecap) ? this.#u("TPL4", [...n, "strokeLinecap"], "strokeLinecap 只能是 butt / round / square。") : i.linecap = e.strokeLinecap), e.on !== void 0) {
1572
+ let t = e.on, a = typeof t == "string" ? this.#c.get(t) : void 0;
1573
+ if (a === void 0) this.#u("TPL2", [...n, "on"], `on 必须是规格 events 里声明的事件名(当前:${[...this.#c.keys()].join("、") || "无"})。`);
1574
+ else {
1575
+ let e = [];
1576
+ for (let [t, i] of Object.entries(a.payload ?? {})) {
1577
+ let a = this.#S(i.value, [
1578
+ ...n,
1579
+ "on",
1580
+ t
1581
+ ], r);
1582
+ a !== void 0 && e.push({
1583
+ key: t,
1584
+ type: i.type,
1585
+ value: a
1586
+ });
1587
+ }
1588
+ i.on = {
1589
+ name: a.name,
1590
+ payload: e
1591
+ };
1592
+ }
1593
+ }
1594
+ }
1595
+ #g(e, t, n, r, i) {
1596
+ let a = this.#S(e.content, [...t, "content"], n, "文字内容是表达式:字面文字要加引号,如 \"'℃'\";读数用 format(value)。");
1597
+ a !== void 0 && (r.content = a);
1598
+ let o = i.fontSize;
1599
+ o !== void 0 && !this.#E(o) && this.#u("TPL5", [...t, "fontSize"], "字号只能是数字,或 props / style 数字字段的四则运算(不能随数据变化),体检才能检查最小字号。"), e.fontWeight !== void 0 && (typeof e.fontWeight != "number" || !vt.has(e.fontWeight) ? this.#u("TPL4", [...t, "fontWeight"], "fontWeight 只能是 400 / 500 / 600 / 700。") : r.fontWeight = e.fontWeight);
1600
+ for (let [n, i] of [["anchor", ht], ["baseline", gt]]) {
1601
+ let a = e[n];
1602
+ a !== void 0 && (typeof a != "string" || !i.has(a) ? this.#u("TPL4", [...t, n], `${n} 只能是 ${[...i].join(" / ")}。`) : r[n] = a);
1603
+ }
1604
+ let s = e.backdrop;
1605
+ typeof s != "string" || s === "" ? this.#u("TPL6", [...t, "backdrop"], "文字必须声明底板 backdrop:某个填充节点的 id,或 container(组件背景)。") : r.backdrop = s;
1606
+ }
1607
+ #_() {
1608
+ for (let e of this.#e.values()) {
1609
+ if (e.kind !== "text" || e.backdrop === void 0 || e.backdrop === "container") continue;
1610
+ let t = this.#e.get(e.backdrop);
1611
+ (t === void 0 || !ot.has(t.kind) || t.fill === void 0) && this.#u("TPL6", [...e.path, "backdrop"], `backdrop「${e.backdrop}」必须是带 fill 的填充节点,或 container。`);
1612
+ }
1613
+ }
1614
+ #v(e, t, n, r) {
1615
+ let i = e.points;
1616
+ if (!L(i)) {
1617
+ this.#u("TPL4", [...t, "points"], "polyline.points 是 { source, x, y }:对每行(或每个序号)求一个点。");
1618
+ return;
1619
+ }
1620
+ for (let e of Object.keys(i)) [
1621
+ "source",
1622
+ "x",
1623
+ "y"
1624
+ ].includes(e) || this.#u("TPL1", [
1625
+ ...t,
1626
+ "points",
1627
+ e
1628
+ ], `points 没有字段 ${e}。`);
1629
+ let a = this.#b(i.source, [
1630
+ ...t,
1631
+ "points",
1632
+ "source"
1633
+ ], n);
1634
+ if (a === void 0) return;
1635
+ let o = {
1636
+ ...n,
1637
+ inRepeat: !0,
1638
+ inRowRepeat: n.inRowRepeat || a.k === "rows"
1639
+ }, s = this.#C(i.x, [
1640
+ ...t,
1641
+ "points",
1642
+ "x"
1643
+ ], o), c = this.#C(i.y, [
1644
+ ...t,
1645
+ "points",
1646
+ "y"
1647
+ ], o);
1648
+ s !== void 0 && c !== void 0 && (r.points = {
1649
+ source: a,
1650
+ x: s,
1651
+ y: c
1652
+ }), e.closed !== void 0 && (typeof e.closed == "boolean" ? r.closed = e.closed : this.#u("TPL4", [...t, "closed"], "closed 必须是布尔值。"));
1653
+ }
1654
+ #y(e, t, n, r) {
1655
+ if (!Array.isArray(e) || e.length === 0 || e.length > N.pathCommands) {
1656
+ this.#u("TPL4", t, `path.d 是 1–${N.pathCommands} 条命令,每条形如 ["L", x, y]。`);
1657
+ return;
1658
+ }
1659
+ let i = [];
1660
+ e.forEach((e, r) => {
1661
+ let a = [...t, r];
1662
+ if (!Array.isArray(e) || typeof e[0] != "string" || ft[e[0]] === void 0) {
1663
+ this.#u("TPL4", a, "路径命令只能是 M / L / H / V / C / Q / A / Z(绝对坐标)。");
1664
+ return;
1665
+ }
1666
+ let o = e[0], s = ft[o];
1667
+ if (e.length - 1 !== s) {
1668
+ this.#u("TPL4", a, `${o} 需要 ${s} 个参数。`);
1669
+ return;
1670
+ }
1671
+ let c = e.slice(1).map((e, t) => this.#C(e, [...a, t + 1], n)).filter((e) => e !== void 0);
1672
+ c.length === s && i.push([o, c]);
1673
+ }), r.d = i;
1674
+ }
1675
+ #b(e, t, n) {
1676
+ if (e === "rows") {
1677
+ if (this.context.data.kind !== "rows") {
1678
+ this.#u("TPL2", t, "组件不是多行数据,不能遍历 rows。");
1679
+ return;
1680
+ }
1681
+ return { k: "rows" };
1682
+ }
1683
+ if (L(e) && Object.keys(e).length === 1 && e.range !== void 0) {
1684
+ if (typeof e.range == "number" && e.range > N.repeat) {
1685
+ this.#u("TPL3", [...t, "range"], `repeat 最多 ${N.repeat} 次。`);
1686
+ return;
1687
+ }
1688
+ let r = this.#C(e.range, [...t, "range"], n);
1689
+ return r === void 0 ? void 0 : {
1690
+ k: "range",
1691
+ n: r
1692
+ };
1693
+ }
1694
+ this.#u("TPL4", t, "source 只能是 \"rows\" 或 { \"range\": 次数 }。");
1695
+ }
1696
+ #x(e, t) {
1697
+ if (e === void 0) return [];
1698
+ if (!Array.isArray(e)) return this.#u("TPL4", ["animations"], "animations 必须是数组。"), [];
1699
+ e.length > N.animations && this.#u("TPL3", ["animations"], `动画最多 ${N.animations} 个。`);
1700
+ let n = [];
1701
+ return e.forEach((e, r) => {
1702
+ let i = ["animations", r];
1703
+ if (!L(e) || e.kind !== "loop" && e.kind !== "change") {
1704
+ this.#u("TPL1", i, "动画只有 loop(循环)与 change(读数变化过渡)两种。");
1705
+ return;
1706
+ }
1707
+ let a = e.kind === "loop" ? [
1708
+ "kind",
1709
+ "target",
1710
+ "property",
1711
+ "from",
1712
+ "to",
1713
+ "duration",
1714
+ "easing",
1715
+ "alternate",
1716
+ "enabledBy"
1717
+ ] : [
1718
+ "kind",
1719
+ "target",
1720
+ "attributes",
1721
+ "duration",
1722
+ "easing"
1723
+ ];
1724
+ for (let t of Object.keys(e)) a.includes(t) || this.#u("TPL1", [...i, t], `${e.kind} 动画没有字段 ${t}。`);
1725
+ let o = typeof e.target == "string" ? this.#e.get(e.target) : void 0;
1726
+ if (o === void 0) {
1727
+ this.#u("TPL4", [...i, "target"], "target 必须是模板里某个节点的 id。");
1728
+ return;
1729
+ }
1730
+ let s = e.duration;
1731
+ if (typeof s != "number" || s < N.minDuration || s > N.maxDuration) {
1732
+ this.#u("TPL4", [...i, "duration"], `duration 是 ${N.minDuration}–${N.maxDuration} 毫秒。`);
1733
+ return;
1734
+ }
1735
+ let c = e.easing ?? (e.kind === "loop" ? "linear" : "ease-out");
1736
+ if (typeof c != "string" || !mt.has(c)) {
1737
+ this.#u("TPL4", [...i, "easing"], `easing 只能是 ${[...mt].join(" / ")}。`);
1738
+ return;
1739
+ }
1740
+ if (e.kind === "loop") {
1741
+ if (typeof e.property != "string" || !pt.has(e.property)) {
1742
+ this.#u("TPL4", [...i, "property"], `循环动画只能改 ${[...pt].join(" / ")}(只动组件内部,不动外框)。`);
1743
+ return;
1744
+ }
1745
+ let r = this.#C(e.from, [...i, "from"], t), a = this.#C(e.to, [...i, "to"], t);
1746
+ e.alternate !== void 0 && typeof e.alternate != "boolean" && this.#u("TPL4", [...i, "alternate"], "alternate 必须是布尔值。");
1747
+ let l = e.enabledBy === void 0 ? void 0 : this.#S(e.enabledBy, [...i, "enabledBy"], t);
1748
+ if (r === void 0 || a === void 0) return;
1749
+ n.push({
1750
+ kind: "loop",
1751
+ target: o.id,
1752
+ property: e.property,
1753
+ from: r,
1754
+ to: a,
1755
+ duration: s,
1756
+ easing: c,
1757
+ alternate: e.alternate === !0,
1758
+ ...l === void 0 ? {} : { enabledBy: l }
1759
+ });
1760
+ return;
1761
+ }
1762
+ let l = P[o.kind];
1763
+ if (!Array.isArray(e.attributes) || e.attributes.length === 0 || e.attributes.some((e) => typeof e != "string" || !l.includes(e))) {
1764
+ this.#u("TPL4", [...i, "attributes"], `${o.kind} 能补间的参数:${l.join("、") || "无"}。`);
1765
+ return;
1766
+ }
1767
+ n.push({
1768
+ kind: "change",
1769
+ target: o.id,
1770
+ attributes: e.attributes,
1771
+ duration: s,
1772
+ easing: c
1773
+ });
1774
+ }), n;
1775
+ }
1776
+ #S(e, t, n, r) {
1777
+ if (typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return {
1778
+ k: "lit",
1779
+ v: e
1780
+ };
1781
+ if (typeof e != "string") {
1782
+ this.#u("TPL4", t, `需要一个表达式字符串${r === void 0 ? "" : `:${r}`}`);
1783
+ return;
1784
+ }
1785
+ let i = Je(e, n);
1786
+ if (!i.ok) {
1787
+ this.#u("TPL2", t, `${i.message}${r === void 0 ? "" : ` ${r}`}`);
1788
+ return;
1789
+ }
1790
+ return i.value;
1791
+ }
1792
+ #C(e, t, n) {
1793
+ if (typeof e == "number") {
1794
+ if (!Number.isFinite(e)) {
1795
+ this.#u("TPL4", t, "数值必须是有限数字。");
1796
+ return;
1797
+ }
1798
+ return {
1799
+ k: "lit",
1800
+ v: e
1801
+ };
1802
+ }
1803
+ if (typeof e == "string") return this.#S(e, t, n);
1804
+ this.#u("TPL4", t, "数值参数写数字或表达式字符串。");
1805
+ }
1806
+ #w(e, t, n, r) {
1807
+ if (L(e) && Object.keys(e).length === 1 && typeof e.gradient == "string") {
1808
+ if (!r || !this.#n.has(e.gradient)) {
1809
+ this.#u("TPL4", t, `渐变「${e.gradient}」没有在 defs 里声明。`);
1810
+ return;
1811
+ }
1812
+ return {
1813
+ k: "gradient",
1814
+ id: e.gradient
1815
+ };
1816
+ }
1817
+ if (typeof e != "string") {
1818
+ this.#u("TPL5", t, "颜色写字面量(#rrggbb、rgba(...)、none)、style.<颜色字段>,或 { \"gradient\": \"渐变 id\" }。");
1819
+ return;
1820
+ }
1821
+ if (F.test(e.trim())) return {
1822
+ k: "color",
1823
+ v: e.trim()
1824
+ };
1825
+ if (/url\s*\(/i.test(e)) {
1826
+ this.#u("TPL1", t, "颜色里不能写 url(...):渐变用 { \"gradient\": \"id\" } 引用。");
1827
+ return;
1828
+ }
1829
+ let i = this.#S(e, t, n);
1830
+ if (i !== void 0) {
1831
+ if (!this.#T(i)) {
1832
+ this.#u("TPL5", t, "颜色表达式只能在字面量颜色与 style.<颜色字段> 之间选择(pick / 三元),不能由数据算出颜色;语义色请声明成样式字段,值可写 theme:danger。");
1833
+ return;
1834
+ }
1835
+ return {
1836
+ k: "expr",
1837
+ e: i
1838
+ };
1839
+ }
1840
+ }
1841
+ #T(e) {
1842
+ switch (e.k) {
1843
+ case "lit": return typeof e.v == "string" && F.test(e.v);
1844
+ case "ref": return e.root === "style" && e.key !== void 0 && this.#o.has(e.key);
1845
+ case "cond": return this.#T(e.a) && this.#T(e.b);
1846
+ case "call": return e.fn === "pick" && e.args.every((t, n) => n === 0 || n % 2 == 1 && n !== e.args.length - 1 || this.#T(t));
1847
+ default: return !1;
1848
+ }
1849
+ }
1850
+ #E(e) {
1851
+ switch (e.k) {
1852
+ case "lit": return typeof e.v == "number";
1853
+ case "ref": return (e.root === "props" || e.root === "style") && e.key !== void 0 && this.#s.has(e.key);
1854
+ case "un": return e.op === "-" && this.#E(e.a);
1855
+ case "bin": return [
1856
+ "+",
1857
+ "-",
1858
+ "*",
1859
+ "/"
1860
+ ].includes(e.op) && this.#E(e.a) && this.#E(e.b);
1861
+ case "call": return [
1862
+ "min",
1863
+ "max",
1864
+ "clamp",
1865
+ "round"
1866
+ ].includes(e.fn) && e.args.every((e) => this.#E(e));
1867
+ default: return !1;
1868
+ }
1869
+ }
1870
+ };
1871
+ function L(e) {
1872
+ return typeof e == "object" && !!e && !Array.isArray(e);
1873
+ }
1874
+ function xt(e, t) {
1875
+ if (e === void 0) return;
1876
+ if (!Array.isArray(e) || e.length > N.events) {
1877
+ t(["events"], `events 是最多 ${N.events} 个事件的数组。`);
1878
+ return;
1879
+ }
1880
+ let n = /* @__PURE__ */ new Set();
1881
+ e.forEach((e, r) => {
1882
+ let i = ["events", r];
1883
+ if (!L(e)) {
1884
+ t(i, "事件必须是对象。");
1885
+ return;
1886
+ }
1887
+ for (let n of Object.keys(e)) [
1888
+ "name",
1889
+ "label",
1890
+ "payload"
1891
+ ].includes(n) || t([...i, n], `未知字段 ${n}。`);
1892
+ if (typeof e.name != "string" || !ut.test(e.name) ? t([...i, "name"], "事件名为小驼峰 ASCII(如 valueClick)。") : n.has(e.name) ? t([...i, "name"], `事件 ${e.name} 重复。`) : n.add(e.name), (typeof e.label != "string" || e.label.trim() === "" || [...e.label].length > 16) && t([...i, "label"], "事件标签为 1–16 个字符。"), e.payload !== void 0) {
1893
+ if (!L(e.payload) || Object.keys(e.payload).length > 6) {
1894
+ t([...i, "payload"], "payload 是最多 6 项的对象:{ 键: { type, value } }。");
1895
+ return;
1896
+ }
1897
+ for (let [n, r] of Object.entries(e.payload)) dt.test(n) || t([
1898
+ ...i,
1899
+ "payload",
1900
+ n
1901
+ ], "负载键为小驼峰 ASCII。"), (!L(r) || r.type !== "number" && r.type !== "string" && r.type !== "boolean" || typeof r.value != "string" || Object.keys(r).some((e) => e !== "type" && e !== "value")) && t([
1902
+ ...i,
1903
+ "payload",
1904
+ n
1905
+ ], "负载项写 { \"type\": \"number\" | \"string\" | \"boolean\", \"value\": \"表达式\" }。");
1906
+ }
1907
+ });
1908
+ }
1909
+ //#endregion
1910
+ //#region ../plugin-sdk/dist/material-spec.js
1911
+ var R = [
1912
+ {
1913
+ id: "format",
1914
+ label: "读数格式",
1915
+ target: "props"
1916
+ },
1917
+ {
1918
+ id: "structure",
1919
+ label: "结构",
1920
+ target: "props"
1921
+ },
1922
+ {
1923
+ id: "text",
1924
+ label: "文字",
1925
+ target: "style"
1926
+ },
1927
+ {
1928
+ id: "surface",
1929
+ label: "填充与描边",
1930
+ target: "style"
1931
+ },
1932
+ {
1933
+ id: "semantic",
1934
+ label: "语义色",
1935
+ target: "style",
1936
+ collapsed: !0
1937
+ },
1938
+ {
1939
+ id: "motion",
1940
+ label: "动效",
1941
+ target: "props",
1942
+ advanced: !0
1943
+ }
1944
+ ], St = new Set(R.map((e) => e.id)), Ct = /* @__PURE__ */ new Set([
1945
+ "number",
1946
+ "text",
1947
+ "boolean",
1948
+ "color",
1949
+ "choice"
1950
+ ]), wt = /* @__PURE__ */ new Set([
1951
+ "type",
1952
+ "name",
1953
+ "category",
1954
+ "keywords",
1955
+ "defaultSize",
1956
+ "rotate",
1957
+ "numberFormat",
1958
+ "fields",
1959
+ "data",
1960
+ "template",
1961
+ "isolated",
1962
+ "events",
1963
+ "statePresetKeys"
1964
+ ]), Tt = /* @__PURE__ */ new Set([
1965
+ "key",
1966
+ "label",
1967
+ "section",
1968
+ "kind",
1969
+ "default",
1970
+ "min",
1971
+ "max",
1972
+ "step",
1973
+ "unit",
1974
+ "options",
1975
+ "allowGradient",
1976
+ "visibleWhen",
1977
+ "help"
1978
+ ]), Et = /* @__PURE__ */ new Set([
1979
+ "decimals",
1980
+ "maxDecimals",
1981
+ "thousandsSeparator",
1982
+ "prefix",
1983
+ "unit",
1984
+ "visibleWhen"
1985
+ ]), Dt = /* @__PURE__ */ new Set([
1986
+ "decimals",
1987
+ "prefix",
1988
+ "unit",
1989
+ "thousandsSeparator"
1990
+ ]), Ot = /^[a-z][A-Za-z0-9]{0,39}$/, kt = 24, At = 16, jt = 6, Mt = 200, Nt = 12, z = 64, B = 32, Pt = 200, Ft = 8, It = 512, Lt = 8, Rt = 4096;
1991
+ function V(e) {
1992
+ let n = [], r = (e, t) => {
1993
+ n.push({
1994
+ severity: "error",
1995
+ code: "PLUGIN_CORE_MANIFEST_FIELD_INVALID",
1996
+ path: e,
1997
+ message: t
1998
+ });
1999
+ };
2000
+ if (!K(e)) return r([], "组件规格必须是对象。"), {
2001
+ ok: !1,
2002
+ diagnostics: n
2003
+ };
2004
+ for (let t of Object.keys(e)) wt.has(t) || r([t], `未知字段 ${t}。`);
2005
+ t(e.type) || r(["type"], "物料类型不合法(形如 host.online.gauge-1a2b)。"), s(e.name, z) || r(["name"], `名称为 1–${z} 个字符。`), s(e.category, z) || r(["category"], `分类为 1–${z} 个字符。`), (!Array.isArray(e.keywords) || e.keywords.length > At || e.keywords.some((e) => !s(e, B))) && r(["keywords"], `关键词最多 ${At} 个,每个 1–${B} 个字符。`);
2006
+ let i = e.defaultSize;
2007
+ (!K(i) || !tn(i.width) || !tn(i.height) || Object.keys(i).some((e) => e !== "width" && e !== "height")) && r(["defaultSize"], `默认尺寸的宽高为 ${Lt}–${Rt} 的数字。`), e.rotate !== void 0 && typeof e.rotate != "boolean" && r(["rotate"], "rotate 必须是布尔值。");
2008
+ let a = Array.isArray(e.fields) ? e.fields : void 0;
2009
+ if (a === void 0 ? r(["fields"], "fields 必须是数组。") : a.length > kt ? r(["fields"], `字段最多 ${kt} 个。`) : Bt(a, r), e.numberFormat !== void 0 && zt(e.numberFormat, a ?? [], r), Ht(e.data, r), xt(e.events, r), e.statePresetKeys !== void 0) {
2010
+ let t = new Set((a ?? []).flatMap((e) => K(e) && typeof e.key == "string" && typeof e.section == "string" && R.find((t) => t.id === e.section)?.target === "style" ? [e.key] : []));
2011
+ (!Array.isArray(e.statePresetKeys) || e.statePresetKeys.length > 8 || e.statePresetKeys.some((e) => typeof e != "string" || !t.has(e))) && r(["statePresetKeys"], "statePresetKeys 最多 8 个,每个都要是样式分区里声明的字段。");
2012
+ }
2013
+ if (e.isolated !== void 0) {
2014
+ let t = e.isolated, n = K(t) ? t.libraries : void 0;
2015
+ (!K(t) || Object.keys(t).some((e) => e !== "libraries") || n !== void 0 && (!Array.isArray(n) || n.length > 4 || new Set(n).size !== n.length || n.some((e) => typeof e != "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(e)))) && r(["isolated"], "isolated 只能有 libraries:最多 4 个不重复的预置库名。"), e.template !== void 0 && r(["isolated"], "MATERIAL_ISOLATED_CONFLICT:template 与 isolated 互斥(L2 与 L3 只能二选一)。");
2016
+ }
2017
+ if (e.template !== void 0 && n.length === 0) {
2018
+ let t = e, r = I(e.template, {
2019
+ fields: t.fields,
2020
+ data: t.data,
2021
+ ...t.events === void 0 ? {} : { events: t.events },
2022
+ sectionTarget: (e) => Kt(e)
2023
+ });
2024
+ r.ok || n.push(...r.diagnostics);
2025
+ }
2026
+ return n.length > 0 ? {
2027
+ ok: !1,
2028
+ diagnostics: n
2029
+ } : {
2030
+ ok: !0,
2031
+ value: e,
2032
+ diagnostics: []
2033
+ };
2034
+ }
2035
+ function zt(e, t, n) {
2036
+ if (!K(e)) {
2037
+ n(["numberFormat"], "numberFormat 必须是对象。");
2038
+ return;
2039
+ }
2040
+ if (e.visibleWhen !== void 0) {
2041
+ let r = e.visibleWhen, i = t.find((e) => K(e) && K(r) && e.key === r.key);
2042
+ (!K(r) || Object.keys(r).some((e) => e !== "key" && e !== "equals") || i === void 0 || i.section !== "format" || i.kind !== "boolean" && i.kind !== "choice" || !en(i, r.equals)) && n(["numberFormat", "visibleWhen"], "visibleWhen 只能引用读数格式分区里的开关或选项字段,equals 取该字段的合法值。");
2043
+ }
2044
+ for (let t of Object.keys(e)) Et.has(t) || n(["numberFormat", t], `未知字段 ${t}。`);
2045
+ for (let t of ["decimals", "maxDecimals"]) {
2046
+ let r = e[t];
2047
+ r !== void 0 && (!Number.isInteger(r) || r < 0 || r > 6) && n(["numberFormat", t], `${t} 是 0–6 的整数。`);
2048
+ }
2049
+ e.thousandsSeparator !== void 0 && typeof e.thousandsSeparator != "boolean" && n(["numberFormat", "thousandsSeparator"], "thousandsSeparator 必须是布尔值。");
2050
+ for (let t of ["prefix", "unit"]) {
2051
+ let r = e[t];
2052
+ r !== void 0 && typeof r != "boolean" && (typeof r != "string" || [...r].length > 16) && n(["numberFormat", t], `${t} 是布尔值,或不超过 16 个字符的默认值。`);
2053
+ }
2054
+ }
2055
+ function Bt(e, t) {
2056
+ let n = /* @__PURE__ */ new Map(), r = new Set(Object.keys(a));
2057
+ e.forEach((e, i) => {
2058
+ let a = ["fields", i];
2059
+ if (!K(e)) {
2060
+ t(a, "字段必须是对象。");
2061
+ return;
2062
+ }
2063
+ for (let n of Object.keys(e)) Tt.has(n) || t([...a, n], `未知字段 ${n}。`);
2064
+ let o = e.key;
2065
+ typeof o != "string" || !Ot.test(o) ? t([...a, "key"], "键名为小驼峰 ASCII(字母开头,最多 40 个字符)。") : n.has(o) ? t([...a, "key"], `键名 ${o} 重复。`) : r.has(o) ? t([...a, "key"], `${o} 是引擎保留样式(公共区统一提供),物料不再声明(ADR-0099 R6)。`) : Dt.has(o) && t([...a, "key"], `${o} 属于读数格式配置组:开启 numberFormat,不要手写同名字段(ADR-0102 R14)。`), s(e.label, B) || t([...a, "label"], "标签为 1–32 个字符。"), (typeof e.section != "string" || !St.has(e.section)) && t([...a, "section"], "分区只能是 format / structure / text / surface / semantic / motion。");
2066
+ let c = e.kind;
2067
+ if (typeof c != "string" || !Ct.has(c) ? t([...a, "kind"], "类型只能是 number / text / boolean / color / choice。") : Vt(e, c, a, t), e.help !== void 0 && !s(e.help, Pt) && t([...a, "help"], `说明最多 ${Pt} 个字符。`), e.visibleWhen !== void 0) {
2068
+ let r = e.visibleWhen, i = K(r) && typeof r.key == "string" ? n.get(r.key) : void 0;
2069
+ (!K(r) || Object.keys(r).some((e) => e !== "key" && e !== "equals") || i === void 0 || i.kind !== "boolean" && i.kind !== "choice" || !en(i, r.equals)) && t([...a, "visibleWhen"], "visibleWhen 只能引用更早声明的开关或选项字段,equals 取该字段的合法值。");
2070
+ }
2071
+ typeof o == "string" && !n.has(o) && n.set(o, e);
2072
+ });
2073
+ }
2074
+ function Vt(e, t, n, r) {
2075
+ let i = e.default, a = (i, a) => {
2076
+ for (let o of i) e[o] !== void 0 && t !== a && r([...n, o], `${o} 只用于 ${a} 字段。`);
2077
+ };
2078
+ switch (a([
2079
+ "min",
2080
+ "max",
2081
+ "step",
2082
+ "unit"
2083
+ ], "number"), a(["options"], "choice"), a(["allowGradient"], "color"), t) {
2084
+ case "number": {
2085
+ for (let t of [
2086
+ "min",
2087
+ "max",
2088
+ "step"
2089
+ ]) e[t] !== void 0 && !G(e[t]) && r([...n, t], `${t} 必须是数字。`);
2090
+ let t = e.min, a = e.max;
2091
+ t !== void 0 && a !== void 0 && t >= a && r([...n, "max"], "max 必须大于 min。"), e.step !== void 0 && e.step <= 0 && r([...n, "step"], "step 必须大于 0。"), e.unit !== void 0 && !s(e.unit, Ft) && r([...n, "unit"], `单位最多 ${Ft} 个字符。`), (!G(i) || t !== void 0 && i < t || a !== void 0 && i > a) && r([...n, "default"], "默认值必须是范围内的数字。");
2092
+ return;
2093
+ }
2094
+ case "boolean":
2095
+ typeof i != "boolean" && r([...n, "default"], "默认值必须是布尔值。");
2096
+ return;
2097
+ case "text":
2098
+ case "color":
2099
+ (typeof i != "string" || [...i].length > It) && r([...n, "default"], `默认值必须是不超过 ${It} 个字符的字符串。`), e.allowGradient !== void 0 && typeof e.allowGradient != "boolean" && r([...n, "allowGradient"], "allowGradient 必须是布尔值。");
2100
+ return;
2101
+ case "choice": {
2102
+ let t = e.options;
2103
+ !Array.isArray(t) || t.length < 2 || t.length > Nt || t.some((e) => !s(e, B)) || new Set(t).size !== t.length ? r([...n, "options"], `选项为 2–${Nt} 个互不相同的字符串。`) : (typeof i != "string" || !t.includes(i)) && r([...n, "default"], "默认值必须是选项之一。");
2104
+ }
2105
+ }
2106
+ }
2107
+ function Ht(e, t) {
2108
+ if (!K(e)) {
2109
+ t(["data"], "data 必须是对象。");
2110
+ return;
2111
+ }
2112
+ let n = (n) => {
2113
+ for (let r of Object.keys(e)) n.includes(r) || t(["data", r], `未知字段 ${r}。`);
2114
+ };
2115
+ switch (e.kind) {
2116
+ case "none":
2117
+ n(["kind"]);
2118
+ return;
2119
+ case "scalar":
2120
+ n([
2121
+ "kind",
2122
+ "valueType",
2123
+ "sample"
2124
+ ]), e.valueType !== "number" && e.valueType !== "string" ? t(["data", "valueType"], "单值类型只能是 number 或 string。") : (e.valueType === "number" ? !G(e.sample) : typeof e.sample != "string") && t(["data", "sample"], "示例值的类型须与单值类型一致。");
2125
+ return;
2126
+ case "rows": {
2127
+ n([
2128
+ "kind",
2129
+ "roles",
2130
+ "sample"
2131
+ ]);
2132
+ let r = e.roles, i = /* @__PURE__ */ new Set();
2133
+ !Array.isArray(r) || r.length === 0 || r.length > jt ? t(["data", "roles"], `角色为 1–${jt} 个。`) : (r.forEach((e, n) => {
2134
+ let r = [
2135
+ "data",
2136
+ "roles",
2137
+ n
2138
+ ];
2139
+ if (!K(e) || Object.keys(e).some((e) => ![
2140
+ "id",
2141
+ "label",
2142
+ "valueType",
2143
+ "optional"
2144
+ ].includes(e))) {
2145
+ t(r, "角色只包含 id / label / valueType / optional。");
2146
+ return;
2147
+ }
2148
+ typeof e.id != "string" || !Ot.test(e.id) || i.has(e.id) ? t([...r, "id"], "角色 id 为互不相同的小驼峰 ASCII。") : i.add(e.id), s(e.label, B) || t([...r, "label"], "角色名为 1–32 个字符。"), e.valueType !== "number" && e.valueType !== "string" && t([...r, "valueType"], "角色类型只能是 number 或 string。"), e.optional !== void 0 && typeof e.optional != "boolean" && t([...r, "optional"], "optional 必须是布尔值。");
2149
+ }), r.every((e) => K(e) && e.optional === !0) && t(["data", "roles"], "至少有一个必填角色。"));
2150
+ let a = e.sample;
2151
+ !Array.isArray(a) || a.length > Mt || a.some((e) => !K(e)) ? t(["data", "sample"], `示例行是最多 ${Mt} 个对象的数组。`) : a.forEach((e, n) => {
2152
+ for (let [r, a] of Object.entries(e)) i.has(r) ? a !== null && typeof a != "string" && !G(a) && t([
2153
+ "data",
2154
+ "sample",
2155
+ n,
2156
+ r
2157
+ ], "示例单元格只能是字符串、数字或 null。") : t([
2158
+ "data",
2159
+ "sample",
2160
+ n,
2161
+ r
2162
+ ], `示例行的键 ${r} 不是角色 id。`);
2163
+ });
2164
+ return;
2165
+ }
2166
+ default: t(["data", "kind"], "数据形状只能是 none / scalar / rows。");
2167
+ }
2168
+ }
2169
+ function H(e, t) {
2170
+ let n = V(e);
2171
+ if (!n.ok) return n;
2172
+ let r = n.value, i = r.numberFormat === void 0 ? void 0 : he(Wt(r.numberFormat)), a = { ...i?.properties }, o = {}, s = { ...i?.defaults }, c = {}, l = /* @__PURE__ */ new Map();
2173
+ for (let e of r.fields) {
2174
+ let t = Kt(e.section);
2175
+ l.set(e.key, t), (t === "props" ? a : o)[e.key] = qt(e), (t === "props" ? s : c)[e.key] = e.default;
2176
+ }
2177
+ let d = [];
2178
+ for (let e of R) {
2179
+ let t = [...r.fields.filter((t) => t.section === e.id).map((t) => Jt(t, e.target, l)), ...e.id === "format" ? Gt(i?.fields ?? [], r.numberFormat) : []];
2180
+ t.length !== 0 && d.push({
2181
+ id: e.id,
2182
+ label: e.label,
2183
+ fields: t,
2184
+ ...e.collapsed === !0 ? { collapsed: !0 } : {},
2185
+ ...e.advanced === !0 ? { advanced: !0 } : {}
2186
+ });
2187
+ }
2188
+ let f = {
2189
+ type: r.type,
2190
+ tagName: t.tagName,
2191
+ name: r.name,
2192
+ category: r.category,
2193
+ keywords: [...r.keywords],
2194
+ defaultSize: {
2195
+ width: r.defaultSize.width,
2196
+ height: r.defaultSize.height
2197
+ },
2198
+ defaultProps: s,
2199
+ defaultStyle: c,
2200
+ propsSchema: {
2201
+ kind: "object",
2202
+ properties: a,
2203
+ required: Object.keys(a)
2204
+ },
2205
+ propertyPanel: [],
2206
+ styleSchema: {
2207
+ kind: "object",
2208
+ properties: o,
2209
+ required: Object.keys(o)
2210
+ },
2211
+ stylePanel: [],
2212
+ ...d.length === 0 && (r.events ?? []).length === 0 ? {} : { editorDescriptor: {
2213
+ ...d.length === 0 ? {} : { appearance: d },
2214
+ ...(r.events ?? []).length === 0 ? {} : { events: (r.events ?? []).map(Ut) }
2215
+ } },
2216
+ events: (r.events ?? []).map((e) => e.name),
2217
+ ...r.statePresetKeys === void 0 || r.statePresetKeys.length === 0 ? {} : { statePresetKeys: [...r.statePresetKeys] },
2218
+ designCapabilities: {
2219
+ resize: !0,
2220
+ rotate: r.rotate ?? !0,
2221
+ children: !1
2222
+ },
2223
+ ...Yt(r.data),
2224
+ ...t.libraryVisible === !1 ? { libraryVisible: !1 } : {},
2225
+ ...t.cover === void 0 ? {} : { cover: t.cover }
2226
+ };
2227
+ return u(f);
2228
+ }
2229
+ function Ut(e) {
2230
+ return {
2231
+ name: e.name,
2232
+ label: e.label,
2233
+ maxPayloadBytes: 4096,
2234
+ triggerContexts: ["blueprint"],
2235
+ requiredCapability: n,
2236
+ payloadSchema: {
2237
+ kind: "object",
2238
+ properties: Object.fromEntries(Object.entries(e.payload ?? {}).map(([e, t]) => [e, { kind: t.type }])),
2239
+ required: []
2240
+ }
2241
+ };
2242
+ }
2243
+ function Wt(e) {
2244
+ let { visibleWhen: t, ...n } = e;
2245
+ return n;
2246
+ }
2247
+ function Gt(e, t) {
2248
+ let n = t?.visibleWhen;
2249
+ return n === void 0 ? e : e.map((e) => ({
2250
+ ...e,
2251
+ when: [{
2252
+ path: [n.key],
2253
+ operator: "eq",
2254
+ value: n.equals
2255
+ }]
2256
+ }));
2257
+ }
2258
+ function Kt(e) {
2259
+ return R.find((t) => t.id === e)?.target ?? "props";
2260
+ }
2261
+ function qt(e) {
2262
+ switch (e.kind) {
2263
+ case "number": return {
2264
+ kind: "number",
2265
+ ...e.min === void 0 ? {} : { minimum: e.min },
2266
+ ...e.max === void 0 ? {} : { maximum: e.max }
2267
+ };
2268
+ case "boolean": return { kind: "boolean" };
2269
+ case "choice": return {
2270
+ kind: "enum",
2271
+ values: [...e.options ?? []]
2272
+ };
2273
+ case "text":
2274
+ case "color": return {
2275
+ kind: "string",
2276
+ maxLength: It
2277
+ };
2278
+ }
2279
+ }
2280
+ function Jt(e, t, n) {
2281
+ let r = e.visibleWhen, i = r === void 0 ? void 0 : n.get(r.key);
2282
+ return {
2283
+ id: e.key,
2284
+ target: t,
2285
+ path: [e.key],
2286
+ label: e.label,
2287
+ ...e.kind === "color" ? { control: "color" } : {},
2288
+ ...e.kind === "color" && e.allowGradient === !0 ? { allowGradient: !0 } : {},
2289
+ ...e.unit === void 0 ? {} : { unit: e.unit },
2290
+ ...e.step === void 0 ? {} : { step: e.step },
2291
+ ...e.help === void 0 ? {} : { help: e.help },
2292
+ ...r === void 0 ? {} : { when: [{
2293
+ ...i !== void 0 && i !== t ? { target: i } : {},
2294
+ path: [r.key],
2295
+ operator: "eq",
2296
+ value: r.equals
2297
+ }] }
2298
+ };
2299
+ }
2300
+ function Yt(e) {
2301
+ switch (e.kind) {
2302
+ case "none": return { dataCapabilities: [] };
2303
+ case "scalar": return {
2304
+ dataCapabilities: [
2305
+ "static",
2306
+ "variable",
2307
+ "dataset"
2308
+ ],
2309
+ staticData: {
2310
+ kind: "scalar",
2311
+ valueType: e.valueType
2312
+ },
2313
+ defaultData: e.sample,
2314
+ dataBinding: { roles: [{
2315
+ id: Xt,
2316
+ minFields: 1,
2317
+ maxFields: 1,
2318
+ valueTypes: e.valueType === "number" ? ["number", "string"] : [
2319
+ "string",
2320
+ "number",
2321
+ "date"
2322
+ ]
2323
+ }] }
2324
+ };
2325
+ case "rows": return {
2326
+ dataCapabilities: ["static", "dataset"],
2327
+ staticData: {
2328
+ kind: "tabular",
2329
+ defaultBinding: { fields: Object.fromEntries(e.roles.map((e) => [e.id, [e.id]])) }
2330
+ },
2331
+ defaultData: Zt(e),
2332
+ dataBinding: { roles: e.roles.map((e) => ({
2333
+ id: e.id,
2334
+ minFields: e.optional === !0 ? 0 : 1,
2335
+ maxFields: 1,
2336
+ valueTypes: e.valueType === "number" ? ["number"] : [
2337
+ "string",
2338
+ "number",
2339
+ "date",
2340
+ "boolean"
2341
+ ]
2342
+ })) }
2343
+ };
2344
+ }
2345
+ }
2346
+ var Xt = "value";
2347
+ function Zt(e) {
2348
+ return {
2349
+ fields: e.roles.map((e) => ({
2350
+ id: e.id,
2351
+ label: e.label,
2352
+ valueType: e.valueType,
2353
+ nullable: e.optional === !0
2354
+ })),
2355
+ rows: e.sample.map((t) => Object.fromEntries(e.roles.map((e) => [e.id, t[e.id] ?? null])))
2356
+ };
2357
+ }
2358
+ function Qt(e) {
2359
+ if (e.kind !== "none") return e.kind === "scalar" ? { adapt({ dataset: t, fields: n }) {
2360
+ let r = n[Xt]?.[0], i = t.rows[0];
2361
+ return r === void 0 ? $t("单值组件需要绑定一列。") : i === void 0 ? {
2362
+ ok: !0,
2363
+ value: null,
2364
+ diagnostics: []
2365
+ } : {
2366
+ ok: !0,
2367
+ value: W(i[r.id], e.valueType),
2368
+ diagnostics: []
2369
+ };
2370
+ } } : { adapt({ dataset: t, fields: n }) {
2371
+ for (let t of e.roles) if (t.optional !== !0 && (n[t.id]?.length ?? 0) === 0) return $t(`角色「${t.label}」需要绑定一列。`);
2372
+ let r = t.rows.map((t) => Object.fromEntries(e.roles.map((e) => {
2373
+ let r = n[e.id]?.[0];
2374
+ return [e.id, r === void 0 ? null : W(t[r.id], e.valueType)];
2375
+ })));
2376
+ return {
2377
+ ok: !0,
2378
+ value: {
2379
+ rows: r,
2380
+ total: r.length
2381
+ },
2382
+ diagnostics: []
2383
+ };
2384
+ } };
2385
+ }
2386
+ function U(e, t) {
2387
+ return e.kind === "none" ? {
2388
+ value: null,
2389
+ rows: []
2390
+ } : e.kind === "scalar" ? {
2391
+ value: W(t, e.valueType),
2392
+ rows: []
2393
+ } : {
2394
+ value: null,
2395
+ rows: (K(t) && Array.isArray(t.rows) ? t.rows : Array.isArray(t) ? t : []).filter(K).map((t) => Object.fromEntries(e.roles.map((e) => [e.id, W(t[e.id], e.valueType)])))
2396
+ };
2397
+ }
2398
+ function W(e, t) {
2399
+ if (e == null) return null;
2400
+ if (t === "number") {
2401
+ let t = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
2402
+ return Number.isFinite(t) ? t : null;
2403
+ }
2404
+ return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : null;
2405
+ }
2406
+ function $t(e) {
2407
+ return {
2408
+ ok: !1,
2409
+ diagnostics: [{
2410
+ severity: "error",
2411
+ code: "HOST_DATASET_BINDING_INVALID",
2412
+ path: [],
2413
+ message: e
2414
+ }]
2415
+ };
2416
+ }
2417
+ function en(e, t) {
2418
+ return e.kind === "boolean" ? typeof t == "boolean" : Array.isArray(e.options) && typeof t == "string" && e.options.includes(t);
2419
+ }
2420
+ function tn(e) {
2421
+ return G(e) && e >= Lt && e <= Rt;
2422
+ }
2423
+ function G(e) {
2424
+ return typeof e == "number" && Number.isFinite(e);
2425
+ }
2426
+ function K(e) {
2427
+ return typeof e == "object" && !!e && !Array.isArray(e);
2428
+ }
2429
+ //#endregion
2430
+ //#region ../plugin-sdk/dist/material-template-render.js
2431
+ var q = "http://www.w3.org/2000/svg", nn = 0;
2432
+ function rn(e) {
2433
+ nn += 1;
2434
+ let t = `tpl${nn.toString(36)}`, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = new Map(e.animations.filter((e) => e.kind === "loop").map((e) => [e.target, !0])), o = new Map(e.animations.flatMap((e) => e.kind === "change" ? [[e.target, e]] : []));
2435
+ return (s) => {
2436
+ let c = {
2437
+ value: s.value,
2438
+ rows: s.rows,
2439
+ props: s.props,
2440
+ style: s.style,
2441
+ size: s.size,
2442
+ formatNumber: s.formatNumber,
2443
+ budget: { steps: Ve }
2444
+ }, l = s.document, [u, d, f, p] = e.viewBox, m = l.createElementNS(q, "svg");
2445
+ m.setAttribute("viewBox", `${u} ${d} ${f} ${p}`), m.setAttribute("preserveAspectRatio", e.fit === "cover" ? "xMidYMid slice" : e.fit === "stretch" ? "none" : "xMidYMid meet"), m.setAttribute("width", "100%"), m.setAttribute("height", "100%"), m.style.display = "block", m.style.overflow = "hidden";
2446
+ let h = Math.max(1, s.size.width), g = Math.max(1, s.size.height), _ = e.fit === "cover" ? Math.min(f / h, p / g) : e.fit === "stretch" ? p / g : Math.max(f / h, p / g), v = s.interactive && !(l.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1), y = l.createElementNS(q, "defs");
2447
+ m.appendChild(y);
2448
+ for (let n of e.gradients) {
2449
+ let e = l.createElementNS(q, n.kind);
2450
+ e.setAttribute("id", `${t}-${n.id}`), e.setAttribute("gradientUnits", "objectBoundingBox");
2451
+ for (let [t, r] of Object.entries(n.geometry)) e.setAttribute(t, Y(r));
2452
+ for (let r of n.stops) {
2453
+ let n = sn(r.color, c, t);
2454
+ if (n === void 0) continue;
2455
+ let i = l.createElementNS(q, "stop");
2456
+ i.setAttribute("offset", Y(r.offset)), i.setAttribute("stop-color", n), r.opacity < 1 && i.setAttribute("stop-opacity", Y(r.opacity)), e.appendChild(i);
2457
+ }
2458
+ y.appendChild(e);
2459
+ }
2460
+ let b = [], x = [], S = (e, n, r, i) => {
2461
+ let a = i === "" ? e.id : `${e.id}#${i}`;
2462
+ switch (e.kind) {
2463
+ case "repeat": {
2464
+ let t = e.children ?? [], a = an(e, n, s.rows.length);
2465
+ for (let o = 0; o < a; o += 1) {
2466
+ let c = {
2467
+ ...n,
2468
+ index: o,
2469
+ count: a,
2470
+ ...e.source?.k === "rows" ? { row: s.rows[o] } : {}
2471
+ };
2472
+ for (let e of t) S(e, c, r, i === "" ? `${o}` : `${i}.${o}`);
2473
+ }
2474
+ return;
2475
+ }
2476
+ case "when":
2477
+ if (e.test === void 0 || !$e(w(e.test, n))) return;
2478
+ for (let t of e.children ?? []) S(t, n, r, i);
2479
+ return;
2480
+ case "clip": {
2481
+ let o = `${t}-${e.id}${i === "" ? "" : `-${i.replace(/\./g, "-")}`}`, s = l.createElementNS(q, "clipPath");
2482
+ if (s.setAttribute("id", o), e.clipShape !== void 0) {
2483
+ let t = te(e.clipShape, n);
2484
+ t !== void 0 && s.appendChild(t.element);
2485
+ }
2486
+ y.appendChild(s);
2487
+ let c = l.createElementNS(q, "g");
2488
+ c.setAttribute("clip-path", `url(#${o})`), C(e, c, r, a, n);
2489
+ for (let t of e.children ?? []) S(t, n, c, i);
2490
+ return;
2491
+ }
2492
+ case "g": {
2493
+ let t = l.createElementNS(q, "g"), o = re(e, n), s = (e) => cn(t, e);
2494
+ s(o), Number.isFinite(o.opacity) && t.setAttribute("opacity", Y(vn(o.opacity))), ee(e, a, o, s), C(e, t, r, a, n);
2495
+ for (let r of e.children ?? []) S(r, n, t, i);
2496
+ return;
2497
+ }
2498
+ default: {
2499
+ let t = te(e, n);
2500
+ if (t === void 0) return;
2501
+ ee(e, a, t.params, t.apply), C(e, t.element, r, a, n);
2502
+ }
2503
+ }
2504
+ }, C = (e, t, n, r, o) => {
2505
+ if (t.setAttribute("data-template-node", e.id), e.on !== void 0 && s.interactive) {
2506
+ let n = e.on, r = {};
2507
+ for (let e of n.payload) {
2508
+ let t = w(e.value, o);
2509
+ r[e.key] = e.type === "number" ? _n(A(t)) : e.type === "boolean" ? $e(t) : t === null ? "" : String(t);
2510
+ }
2511
+ t.style.cursor = "pointer", t.addEventListener("click", () => {
2512
+ t.dispatchEvent(new CustomEvent(i, {
2513
+ bubbles: !0,
2514
+ composed: !0,
2515
+ detail: {
2516
+ name: n.name,
2517
+ payload: r
2518
+ }
2519
+ }));
2520
+ });
2521
+ }
2522
+ if (a.has(e.id)) {
2523
+ let r = l.createElementNS(q, "g");
2524
+ r.appendChild(t), n.appendChild(r), x.push({
2525
+ element: r,
2526
+ target: e.id,
2527
+ env: o
2528
+ });
2529
+ return;
2530
+ }
2531
+ n.appendChild(t);
2532
+ }, ee = (e, t, i, a) => {
2533
+ let s = o.get(e.id);
2534
+ if (s === void 0) return;
2535
+ let c = {};
2536
+ for (let e of s.attributes) {
2537
+ let t = i[e];
2538
+ t !== void 0 && Number.isFinite(t) && (c[e] = t);
2539
+ }
2540
+ let u = n.get(t);
2541
+ if (n.set(t, c), !v || u === void 0) {
2542
+ r.delete(t);
2543
+ return;
2544
+ }
2545
+ let d = l.defaultView?.performance.now() ?? 0, f = r.get(t), p = f !== void 0 && d < f.start + f.duration;
2546
+ if (!Object.keys(c).some((e) => u[e] !== void 0 && u[e] !== c[e])) {
2547
+ if (p && f !== void 0) {
2548
+ let e = {
2549
+ ...i,
2550
+ ...f.from
2551
+ };
2552
+ a(fn(e, i, dn(f, d, s.easing))), b.push({
2553
+ apply: a,
2554
+ from: e,
2555
+ to: i,
2556
+ start: f.start,
2557
+ duration: f.duration,
2558
+ easing: s.easing
2559
+ });
2560
+ } else r.delete(t);
2561
+ return;
2562
+ }
2563
+ let m = p && f !== void 0 ? fn({
2564
+ ...i,
2565
+ ...f.from
2566
+ }, {
2567
+ ...i,
2568
+ ...f.to
2569
+ }, dn(f, d, s.easing)) : {
2570
+ ...i,
2571
+ ...u
2572
+ };
2573
+ a(m);
2574
+ let h = {
2575
+ from: m,
2576
+ to: i,
2577
+ start: d,
2578
+ duration: s.duration
2579
+ };
2580
+ r.set(t, h), b.push({
2581
+ apply: a,
2582
+ ...h,
2583
+ easing: s.easing
2584
+ });
2585
+ }, te = (e, t) => {
2586
+ let n = re(e, t), r, i;
2587
+ switch (e.kind) {
2588
+ case "rect":
2589
+ r = l.createElementNS(q, "rect"), i = (e) => {
2590
+ J(r, "x", e.x), J(r, "y", e.y), J(r, "width", Math.max(0, e.width ?? 0)), J(r, "height", Math.max(0, e.height ?? 0)), e.rx !== void 0 && J(r, "rx", Math.max(0, e.rx));
2591
+ };
2592
+ break;
2593
+ case "circle":
2594
+ r = l.createElementNS(q, "circle"), i = (e) => {
2595
+ J(r, "cx", e.cx), J(r, "cy", e.cy), J(r, "r", Math.max(0, e.r ?? 0));
2596
+ };
2597
+ break;
2598
+ case "ellipse":
2599
+ r = l.createElementNS(q, "ellipse"), i = (e) => {
2600
+ J(r, "cx", e.cx), J(r, "cy", e.cy), J(r, "rx", Math.max(0, e.rx ?? 0)), J(r, "ry", Math.max(0, e.ry ?? 0));
2601
+ };
2602
+ break;
2603
+ case "line":
2604
+ r = l.createElementNS(q, "line"), i = (e) => {
2605
+ J(r, "x1", e.x1), J(r, "y1", e.y1), J(r, "x2", e.x2), J(r, "y2", e.y2);
2606
+ };
2607
+ break;
2608
+ case "polyline": {
2609
+ r = l.createElementNS(q, e.closed === !0 ? "polygon" : "polyline");
2610
+ let n = [];
2611
+ if (e.points !== void 0) {
2612
+ let r = on(e.points.source, t, s.rows.length);
2613
+ for (let i = 0; i < r; i += 1) {
2614
+ let a = {
2615
+ ...t,
2616
+ index: i,
2617
+ count: r,
2618
+ ...e.points.source.k === "rows" ? { row: s.rows[i] } : {}
2619
+ }, o = A(w(e.points.x, a)), c = A(w(e.points.y, a));
2620
+ Number.isFinite(o) && Number.isFinite(c) && n.push(`${Y(o)},${Y(c)}`);
2621
+ }
2622
+ }
2623
+ r.setAttribute("points", n.join(" ")), e.fill === void 0 && e.closed !== !0 && r.setAttribute("fill", "none"), i = () => {};
2624
+ break;
2625
+ }
2626
+ case "path": {
2627
+ r = l.createElementNS(q, "path");
2628
+ let n = [];
2629
+ for (let [r, i] of e.d ?? []) {
2630
+ let e = i.map((e) => A(w(e, t)));
2631
+ e.some((e) => !Number.isFinite(e)) || n.push(r === "Z" ? "Z" : `${r}${e.map(Y).join(" ")}`);
2632
+ }
2633
+ r.setAttribute("d", n.join(" ")), i = () => {};
2634
+ break;
2635
+ }
2636
+ case "arc":
2637
+ r = l.createElementNS(q, "path"), r.setAttribute("fill", "none"), r.setAttribute("stroke-linecap", e.linecap ?? "round"), i = (e) => {
2638
+ r.setAttribute("d", mn(e.cx ?? 0, e.cy ?? 0, e.r ?? 0, e.start ?? 0, e.end ?? 0)), J(r, "stroke-width", Math.max(0, e.thickness ?? 0));
2639
+ };
2640
+ break;
2641
+ case "ticks":
2642
+ r = l.createElementNS(q, "path"), r.setAttribute("fill", "none"), i = (e) => r.setAttribute("d", hn(e));
2643
+ break;
2644
+ case "wave":
2645
+ r = l.createElementNS(q, "path"), i = (e) => r.setAttribute("d", gn(e));
2646
+ break;
2647
+ case "text": {
2648
+ r = l.createElementNS(q, "text");
2649
+ let n = e.content === void 0 ? null : w(e.content, t);
2650
+ r.textContent = n === null ? "" : String(n).slice(0, 256), r.setAttribute("text-anchor", e.anchor ?? "start"), r.setAttribute("dominant-baseline", e.baseline === "middle" ? "central" : e.baseline === "hanging" ? "hanging" : "auto"), r.setAttribute("font-weight", String(e.fontWeight ?? 400)), r.style.fontFamily = "inherit", r.style.fontVariantNumeric = "tabular-nums", i = (e) => {
2651
+ J(r, "x", e.x), J(r, "y", e.y), J(r, "font-size", Math.max(0, (e.fontSize ?? 0) * _));
2652
+ };
2653
+ break;
2654
+ }
2655
+ default: return;
2656
+ }
2657
+ if (i(n), ne(r, "fill", e.fill, t), ne(r, "stroke", e.stroke, t), e.kind === "text" && e.fill === void 0 && r.setAttribute("fill", "currentColor"), e.kind === "ticks" && e.stroke === void 0 && r.setAttribute("stroke", "currentColor"), Number.isFinite(n.strokeWidth) && e.kind !== "arc" && J(r, "stroke-width", Math.max(0, n.strokeWidth)), Number.isFinite(n.opacity) && r.setAttribute("opacity", Y(vn(n.opacity))), e.dash !== void 0) {
2658
+ let n = e.dash.map((e) => A(w(e, t)));
2659
+ n.every((e) => Number.isFinite(e) && e >= 0) && r.setAttribute("stroke-dasharray", n.map(Y).join(" "));
2660
+ }
2661
+ return e.linecap !== void 0 && e.kind !== "arc" && r.setAttribute("stroke-linecap", e.linecap), {
2662
+ element: r,
2663
+ params: n,
2664
+ apply: i
2665
+ };
2666
+ }, ne = (e, n, r, i) => {
2667
+ if (r === void 0) return;
2668
+ let a = sn(r, i, t);
2669
+ a !== void 0 && e.setAttribute(n, a);
2670
+ }, w = (e, t) => O(e, t), re = (e, t) => {
2671
+ let n = {};
2672
+ for (let [r, i] of Object.entries(e.num)) n[r] = A(w(i, t));
2673
+ return n;
2674
+ };
2675
+ for (let t of e.nodes) S(t, c, m, "");
2676
+ if (s.root.replaceChildren(m), v) {
2677
+ for (let e of b) pn(l, e);
2678
+ for (let t of x) for (let n of e.animations) {
2679
+ if (n.kind !== "loop" || n.target !== t.target || n.enabledBy !== void 0 && !$e(w(n.enabledBy, t.env))) continue;
2680
+ let e = A(w(n.from, t.env)), r = A(w(n.to, t.env));
2681
+ !Number.isFinite(e) || !Number.isFinite(r) || ((n.property === "rotate" || n.property === "scale") && (t.element.style.transformBox = "fill-box", t.element.style.transformOrigin = "center"), t.element.animate([ln(n.property, e), ln(n.property, r)], {
2682
+ duration: n.duration,
2683
+ iterations: Infinity,
2684
+ easing: n.easing,
2685
+ direction: n.alternate ? "alternate" : "normal"
2686
+ }));
2687
+ }
2688
+ }
2689
+ };
2690
+ }
2691
+ function an(e, t, n) {
2692
+ return e.source === void 0 ? 0 : on(e.source, t, n);
2693
+ }
2694
+ function on(e, t, n) {
2695
+ let r = e.k === "rows" ? n : A(O(e.n, t));
2696
+ return Number.isFinite(r) ? Math.max(0, Math.min(N.repeat, Math.trunc(r))) : 0;
2697
+ }
2698
+ function sn(e, t, n) {
2699
+ if (e.k === "color") return e.v;
2700
+ if (e.k === "gradient") return `url(#${n}-${e.id})`;
2701
+ let r = O(e.e, t);
2702
+ return typeof r == "string" && F.test(r.trim()) ? r.trim() : void 0;
2703
+ }
2704
+ function cn(e, t) {
2705
+ let n = [];
2706
+ (Number.isFinite(t.x) || Number.isFinite(t.y)) && n.push(`translate(${Y(X(t.x))} ${Y(X(t.y))})`), Number.isFinite(t.rotate) && n.push(`rotate(${Y(t.rotate)})`), Number.isFinite(t.scale) && n.push(`scale(${Y(t.scale)})`), n.length > 0 && e.setAttribute("transform", n.join(" "));
2707
+ }
2708
+ function ln(e, t) {
2709
+ switch (e) {
2710
+ case "translateX": return { transform: `translateX(${Y(t)}px)` };
2711
+ case "translateY": return { transform: `translateY(${Y(t)}px)` };
2712
+ case "rotate": return { transform: `rotate(${Y(t)}deg)` };
2713
+ case "scale": return { transform: `scale(${Y(t)})` };
2714
+ default: return { opacity: vn(t) };
2715
+ }
2716
+ }
2717
+ var un = {
2718
+ linear: (e) => e,
2719
+ ease: (e) => e * e * (3 - 2 * e),
2720
+ "ease-in": (e) => e * e,
2721
+ "ease-out": (e) => 1 - (1 - e) * (1 - e),
2722
+ "ease-in-out": (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2
2723
+ };
2724
+ function dn(e, t, n) {
2725
+ let r = Math.min(1, Math.max(0, (t - e.start) / e.duration));
2726
+ return (un[n] ?? ((e) => e))(r);
2727
+ }
2728
+ function fn(e, t, n) {
2729
+ let r = { ...t };
2730
+ for (let [i, a] of Object.entries(t)) {
2731
+ let t = e[i];
2732
+ t !== void 0 && Number.isFinite(t) && Number.isFinite(a) && (r[i] = t + (a - t) * n);
2733
+ }
2734
+ return r;
2735
+ }
2736
+ function pn(e, t) {
2737
+ let n = e.defaultView;
2738
+ if (n === null) {
2739
+ t.apply(t.to);
2740
+ return;
2741
+ }
2742
+ let r = (e) => {
2743
+ t.apply(fn(t.from, t.to, dn(t, e, t.easing))), e < t.start + t.duration && n.requestAnimationFrame(r);
2744
+ };
2745
+ n.requestAnimationFrame(r);
2746
+ }
2747
+ function mn(e, t, n, r, i) {
2748
+ if (!Number.isFinite(e + t + n + r + i) || n <= 0) return "";
2749
+ let a = i - r;
2750
+ if (Math.abs(a) < .001) return "";
2751
+ let o = (r) => {
2752
+ let i = r * Math.PI / 180;
2753
+ return `${Y(e + n * Math.sin(i))} ${Y(t - n * Math.cos(i))}`;
2754
+ };
2755
+ if (Math.abs(a) >= 359.999) return `M${o(r)} A${Y(n)} ${Y(n)} 0 1 1 ${o(r + 180)} A${Y(n)} ${Y(n)} 0 1 1 ${o(r + 359.99)}`;
2756
+ let s = +(Math.abs(a) > 180), c = +(a > 0);
2757
+ return `M${o(r)} A${Y(n)} ${Y(n)} 0 ${s} ${c} ${o(i)}`;
2758
+ }
2759
+ function hn(e) {
2760
+ let t = Math.max(0, Math.min(N.repeat, Math.trunc(X(e.count)))), n = X(e.cx), r = X(e.cy), i = X(e.r), a = X(e.length), o = X(e.start), s = X(e.end);
2761
+ if (t === 0) return "";
2762
+ let c = [];
2763
+ for (let e = 0; e < t; e += 1) {
2764
+ let l = (t === 1 ? o : o + (s - o) * e / (t - 1)) * Math.PI / 180, u = [n + i * Math.sin(l), r - i * Math.cos(l)], d = [n + (i - a) * Math.sin(l), r - (i - a) * Math.cos(l)];
2765
+ c.push(`M${Y(u[0])} ${Y(u[1])} L${Y(d[0])} ${Y(d[1])}`);
2766
+ }
2767
+ return c.join(" ");
2768
+ }
2769
+ function gn(e) {
2770
+ let t = X(e.x), n = X(e.y), r = X(e.width), i = X(e.height), a = X(e.amplitude), o = Math.max(1, X(e.wavelength)), s = X(e.phase);
2771
+ if (r <= 0) return "";
2772
+ let c = o / 2, l = t - (s % o + o) % o, u = [`M${Y(l)} ${Y(n)}`], d = l, f = !0, p = 0;
2773
+ for (; d < t + r && p < 400;) {
2774
+ let e = d + c;
2775
+ u.push(`Q${Y(d + c / 2)} ${Y(n + (f ? -a : a))} ${Y(e)} ${Y(n)}`), d = e, f = !f, p += 1;
2776
+ }
2777
+ return u.push(`L${Y(d)} ${Y(n + i)} L${Y(l)} ${Y(n + i)} Z`), u.join(" ");
2778
+ }
2779
+ function J(e, t, n) {
2780
+ if (n === void 0 || !Number.isFinite(n)) {
2781
+ e.removeAttribute(t);
2782
+ return;
2783
+ }
2784
+ e.setAttribute(t, Y(n));
2785
+ }
2786
+ function Y(e) {
2787
+ return String(Math.round(e * 1e3) / 1e3);
2788
+ }
2789
+ function X(e) {
2790
+ return e !== void 0 && Number.isFinite(e) ? e : 0;
2791
+ }
2792
+ function _n(e) {
2793
+ return Number.isFinite(e) ? e : null;
2794
+ }
2795
+ function vn(e) {
2796
+ return Math.min(1, Math.max(0, e));
2797
+ }
2798
+ //#endregion
2799
+ //#region ../plugin-sdk/dist/material-rendered-element.js
2800
+ var yn = ":host{contain:content}.frame{position:relative;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}.frame>*{box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0}", bn = 160;
2801
+ function xn(e, t) {
2802
+ let n = e.ownerDocument, r = n.createElement("style");
2803
+ r.textContent = yn;
2804
+ let i = n.createElement("div");
2805
+ i.className = "frame", i.setAttribute("part", "frame"), e.replaceChildren(r, i);
2806
+ let a = !1, o = (e, t) => {
2807
+ i.replaceChildren(...e === void 0 ? [] : [e]), a = t;
2808
+ }, s = (e, r) => {
2809
+ let i = U(t.data, r);
2810
+ if (t.data.kind === "rows" && i.rows.length === 0) {
2811
+ o(x(n), !1);
2812
+ return;
2813
+ }
2814
+ let a = n.createElement("div");
2815
+ a.setAttribute("data-base-screen-material-root", "");
2816
+ try {
2817
+ t.render({
2818
+ document: n,
2819
+ root: a,
2820
+ props: e.props,
2821
+ style: e.style,
2822
+ size: e.size,
2823
+ mode: e.mode,
2824
+ value: i.value,
2825
+ rows: i.rows,
2826
+ formatNumber: (t) => Sn(t, e.props)
2827
+ });
2828
+ } catch (e) {
2829
+ let t = e instanceof Error ? e.message : String(e);
2830
+ o(y(n, "HOST_DATASET_INVALID", `组件渲染失败:${t}`.slice(0, bn)), !1);
2831
+ return;
2832
+ }
2833
+ o(a, !0);
2834
+ };
2835
+ return { update(e) {
2836
+ let r = e.dataState;
2837
+ if (t.data.kind === "none") {
2838
+ s(e, void 0);
2839
+ return;
2840
+ }
2841
+ if (r.status === "ready") {
2842
+ s(e, r.value);
2843
+ return;
2844
+ }
2845
+ if (a && r.status !== "error") return;
2846
+ let i = b(n, r);
2847
+ o(i, !1);
2848
+ } };
2849
+ }
2850
+ function Sn(e, t) {
2851
+ let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
2852
+ if (!Number.isFinite(n)) return "--";
2853
+ let r = typeof t.decimals == "number" ? t.decimals : 0, i = Math.min(6, Math.max(0, Math.trunc(r))), a = t.thousandsSeparator === !0 ? n.toLocaleString("en-US", {
2854
+ minimumFractionDigits: i,
2855
+ maximumFractionDigits: i
2856
+ }) : n.toFixed(i);
2857
+ return `${typeof t.prefix == "string" ? t.prefix : ""}${a}${typeof t.unit == "string" ? t.unit : ""}`;
2858
+ }
2859
+ function Cn(e) {
2860
+ let t = globalThis.HTMLElement ?? class {}, n = () => ({
2861
+ data: e.data,
2862
+ render: e.renderPerInstance === !0 ? e.render() : e.render
2863
+ });
2864
+ class r extends t {
2865
+ #e;
2866
+ #t;
2867
+ get model() {
2868
+ if (this.#e === void 0) throw Error("Material model has not been set.");
2869
+ return this.#e;
2870
+ }
2871
+ set model(e) {
2872
+ this.#e = e, this.setAttribute("data-base-screen-data-state", e.dataState.status), this.#n();
2873
+ }
2874
+ connectedCallback() {
2875
+ this.#n();
2876
+ }
2877
+ #n() {
2878
+ let e = this.#e;
2879
+ e === void 0 || !this.isConnected || (this.#t ??= xn(this.shadowRoot ?? this.attachShadow({ mode: "open" }), n()), this.#t.update(e));
2880
+ }
2881
+ }
2882
+ Object.defineProperty(r, "manifest", {
2883
+ value: e.manifest,
2884
+ configurable: !0
2885
+ });
2886
+ let i = Qt(e.data);
2887
+ return i !== void 0 && Object.defineProperty(r, "tabularDataAdapter", { value: i }), r;
2888
+ }
2889
+ function wn(e) {
2890
+ let t = Tn(e);
2891
+ if (!t.ok) return t;
2892
+ let n = t.value;
2893
+ return {
2894
+ ok: !0,
2895
+ value: () => {
2896
+ let e = rn(n);
2897
+ return (t) => e({
2898
+ document: t.document,
2899
+ root: t.root,
2900
+ props: t.props,
2901
+ style: t.style,
2902
+ size: t.size,
2903
+ interactive: t.mode !== "design",
2904
+ value: t.value,
2905
+ rows: t.rows,
2906
+ formatNumber: t.formatNumber
2907
+ });
2908
+ },
2909
+ diagnostics: []
2910
+ };
2911
+ }
2912
+ function Tn(e) {
2913
+ return e.template === void 0 ? v("PLUGIN_CORE_LIFECYCLE_INVALID", ["template"], "规格没有 template。") : I(e.template, {
2914
+ fields: e.fields,
2915
+ data: e.data,
2916
+ ...e.events === void 0 ? {} : { events: e.events },
2917
+ sectionTarget: (e) => e === "text" || e === "surface" || e === "semantic" ? "style" : "props"
2918
+ });
2919
+ }
2920
+ function En(e) {
2921
+ let t = V(e.spec);
2922
+ if (!t.ok) return t;
2923
+ if (t.value.isolated !== void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["spec", "isolated"], "MATERIAL_ISOLATED_CONFLICT:规格带 isolated 时用 createBaseScreenIsolatedMaterialDefinition 注册。");
2924
+ let n = t.value.template !== void 0;
2925
+ if (n && e.render !== void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["render"], "MATERIAL_TEMPLATE_RENDER_CONFLICT:规格带 template 时不能再给渲染函数。");
2926
+ if (!n && typeof e.render != "function") return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["render"], "渲染函数必须是函数。");
2927
+ let r = H(t.value, {
2928
+ tagName: e.tagName,
2929
+ ...e.libraryVisible === void 0 ? {} : { libraryVisible: e.libraryVisible },
2930
+ ...e.cover === void 0 ? {} : { cover: e.cover }
2931
+ });
2932
+ if (!r.ok) return r;
2933
+ if (n) {
2934
+ let e = wn(t.value);
2935
+ if (!e.ok) return e;
2936
+ let n = Cn({
2937
+ manifest: r.value,
2938
+ data: t.value.data,
2939
+ render: e.value,
2940
+ renderPerInstance: !0
2941
+ });
2942
+ return _({
2943
+ manifest: r.value,
2944
+ element: n
2945
+ });
2946
+ }
2947
+ let i = Cn({
2948
+ manifest: r.value,
2949
+ data: t.value.data,
2950
+ render: e.render
2951
+ });
2952
+ return _({
2953
+ manifest: r.value,
2954
+ element: i
2955
+ });
2956
+ }
2957
+ //#endregion
2958
+ //#region ../plugin-sdk/dist/material-isolated.js
2959
+ var Dn = 204800, On = 65536, kn = 60, An = 5e3, jn = 2e3, Mn = 20, Nn = 3, Pn = 20, Fn = 1e4, In = 500, Ln = /^[a-z][a-z0-9-]{0,31}$/, Rn = /^[A-Za-z_$][A-Za-z0-9_$]{0,63}$/, zn = ":host{contain:content}.frame{position:relative;box-sizing:border-box;width:100%;height:100%;overflow:hidden}.frame>*{box-sizing:border-box;width:100%;height:100%}canvas{display:block}";
2960
+ function Bn(e) {
2961
+ let t = V(e.spec);
2962
+ if (!t.ok) return t;
2963
+ let n = t.value.isolated;
2964
+ if (n === void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["spec", "isolated"], "MATERIAL_ISOLATED_REQUIRED:隔离代码物料的规格必须带 isolated。");
2965
+ if (typeof e.source != "string" || e.source.trim() === "" || new TextEncoder().encode(e.source).byteLength > 204800) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["source"], `组件代码必须是非空文本,最多 ${Dn / 1024} KB。`);
2966
+ let r = new Map((e.libraries ?? []).map((e) => [e.name, e])), i = [];
2967
+ for (let [e, t] of (n.libraries ?? []).entries()) {
2968
+ let n = r.get(t);
2969
+ if (n === void 0 || !Ln.test(n.name) || !Rn.test(n.global) || typeof n.source != "string") return v("PLUGIN_CORE_LIFECYCLE_INVALID", [
2970
+ "spec",
2971
+ "isolated",
2972
+ "libraries",
2973
+ e
2974
+ ], `宿主没有提供预置库 ${t}。`);
2975
+ i.push(n);
2976
+ }
2977
+ let a = e.maxFps ?? kn;
2978
+ if (!Number.isFinite(a) || a < 1 || a > 120) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["maxFps"], "maxFps 必须在 1–120 之间。");
2979
+ if (e.sandbox !== void 0 && typeof e.sandbox.resolve != "function") return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["sandbox"], "sandbox.resolve 必须是函数。");
2980
+ let o = H(t.value, {
2981
+ tagName: e.tagName,
2982
+ ...e.libraryVisible === void 0 ? {} : { libraryVisible: e.libraryVisible },
2983
+ ...e.cover === void 0 ? {} : { cover: e.cover }
2984
+ });
2985
+ if (!o.ok) return o;
2986
+ let s = fr({
2987
+ manifest: o.value,
2988
+ data: t.value.data,
2989
+ bundle: new nr(e.source, i, a),
2990
+ tagName: e.tagName,
2991
+ ...e.onAudit === void 0 ? {} : { onAudit: e.onAudit },
2992
+ ...e.onFrame === void 0 ? {} : { onFrame: e.onFrame },
2993
+ ...e.sandbox === void 0 ? {} : { sandbox: e.sandbox }
2994
+ });
2995
+ return _({
2996
+ manifest: o.value,
2997
+ element: s
2998
+ });
2999
+ }
3000
+ function Vn(e) {
3001
+ return new nr(e.source, e.libraries ?? [], e.maxFps ?? kn).document();
3002
+ }
3003
+ function Z(e) {
3004
+ return e.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--");
3005
+ }
3006
+ var Hn = /* @__PURE__ */ new Map();
3007
+ function Un(e) {
3008
+ let t = new TextEncoder().encode(e), n = globalThis.crypto?.subtle;
3009
+ return n === void 0 ? Promise.resolve(Kn(t)) : n.digest("SHA-256", t).then((e) => new Uint8Array(e));
3010
+ }
3011
+ function Wn(e) {
3012
+ let t = Hn.get(e);
3013
+ return t === void 0 && (t = Un(e).then((e) => {
3014
+ let t = "";
3015
+ for (let n of e) t += String.fromCharCode(n);
3016
+ return `'sha256-${btoa(t)}'`;
3017
+ }), Hn.size > 64 && Hn.clear(), Hn.set(e, t)), t;
3018
+ }
3019
+ var Gn = new Uint32Array([
3020
+ 1116352408,
3021
+ 1899447441,
3022
+ 3049323471,
3023
+ 3921009573,
3024
+ 961987163,
3025
+ 1508970993,
3026
+ 2453635748,
3027
+ 2870763221,
3028
+ 3624381080,
3029
+ 310598401,
3030
+ 607225278,
3031
+ 1426881987,
3032
+ 1925078388,
3033
+ 2162078206,
3034
+ 2614888103,
3035
+ 3248222580,
3036
+ 3835390401,
3037
+ 4022224774,
3038
+ 264347078,
3039
+ 604807628,
3040
+ 770255983,
3041
+ 1249150122,
3042
+ 1555081692,
3043
+ 1996064986,
3044
+ 2554220882,
3045
+ 2821834349,
3046
+ 2952996808,
3047
+ 3210313671,
3048
+ 3336571891,
3049
+ 3584528711,
3050
+ 113926993,
3051
+ 338241895,
3052
+ 666307205,
3053
+ 773529912,
3054
+ 1294757372,
3055
+ 1396182291,
3056
+ 1695183700,
3057
+ 1986661051,
3058
+ 2177026350,
3059
+ 2456956037,
3060
+ 2730485921,
3061
+ 2820302411,
3062
+ 3259730800,
3063
+ 3345764771,
3064
+ 3516065817,
3065
+ 3600352804,
3066
+ 4094571909,
3067
+ 275423344,
3068
+ 430227734,
3069
+ 506948616,
3070
+ 659060556,
3071
+ 883997877,
3072
+ 958139571,
3073
+ 1322822218,
3074
+ 1537002063,
3075
+ 1747873779,
3076
+ 1955562222,
3077
+ 2024104815,
3078
+ 2227730452,
3079
+ 2361852424,
3080
+ 2428436474,
3081
+ 2756734187,
3082
+ 3204031479,
3083
+ 3329325298
3084
+ ]);
3085
+ function Kn(e) {
3086
+ let t = e.length, n = Math.ceil((t + 9) / 64), r = new Uint8Array(n * 64);
3087
+ r.set(e), r[t] = 128;
3088
+ let i = new DataView(r.buffer);
3089
+ i.setUint32(r.length - 8, Math.floor(t / 536870912), !1), i.setUint32(r.length - 4, t * 8 >>> 0, !1);
3090
+ let a = new Uint32Array([
3091
+ 1779033703,
3092
+ 3144134277,
3093
+ 1013904242,
3094
+ 2773480762,
3095
+ 1359893119,
3096
+ 2600822924,
3097
+ 528734635,
3098
+ 1541459225
3099
+ ]), o = /* @__PURE__ */ new Uint32Array(64), s = (e, t) => e >>> t | e << 32 - t;
3100
+ for (let e = 0; e < n; e++) {
3101
+ for (let t = 0; t < 16; t++) o[t] = i.getUint32(e * 64 + t * 4, !1);
3102
+ for (let e = 16; e < 64; e++) {
3103
+ let t = o[e - 15], n = o[e - 2], r = s(t, 7) ^ s(t, 18) ^ t >>> 3, i = s(n, 17) ^ s(n, 19) ^ n >>> 10;
3104
+ o[e] = o[e - 16] + r + o[e - 7] + i >>> 0;
3105
+ }
3106
+ let [t, n, r, c, l, u, d, f] = a;
3107
+ for (let e = 0; e < 64; e++) {
3108
+ let i = s(l, 6) ^ s(l, 11) ^ s(l, 25), a = l & u ^ ~l & d, p = f + i + a + Gn[e] + o[e] >>> 0, m = (s(t, 2) ^ s(t, 13) ^ s(t, 22)) + (t & n ^ t & r ^ n & r) >>> 0;
3109
+ f = d, d = u, u = l, l = c + p >>> 0, c = r, r = n, n = t, t = p + m >>> 0;
3110
+ }
3111
+ a[0] = a[0] + t >>> 0, a[1] = a[1] + n >>> 0, a[2] = a[2] + r >>> 0, a[3] = a[3] + c >>> 0, a[4] = a[4] + l >>> 0, a[5] = a[5] + u >>> 0, a[6] = a[6] + d >>> 0, a[7] = a[7] + f >>> 0;
3112
+ }
3113
+ let c = /* @__PURE__ */ new Uint8Array(32), l = new DataView(c.buffer);
3114
+ for (let e = 0; e < 8; e++) l.setUint32(e * 4, a[e], !1);
3115
+ return c;
3116
+ }
3117
+ function qn() {
3118
+ let e = /* @__PURE__ */ new Uint8Array(16);
3119
+ return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
3120
+ }
3121
+ var Jn = 1500, Yn = /* @__PURE__ */ new WeakMap();
3122
+ function Xn(e) {
3123
+ let t = Yn.get(e);
3124
+ if (t !== void 0) return t;
3125
+ let n = (async () => {
3126
+ let t = e.defaultView;
3127
+ if (t === null) return !1;
3128
+ let n = qn(), r = Z(`parent.postMessage({ type: 'bs-sandbox-probe', token: ${JSON.stringify(n)} }, '*');`), i = await Wn(r);
3129
+ return new Promise((a) => {
3130
+ let o = e.createElement("iframe");
3131
+ o.setAttribute("sandbox", "allow-scripts"), o.setAttribute("aria-hidden", "true"), o.setAttribute("tabindex", "-1"), o.setAttribute("data-base-screen-isolated-probe", ""), o.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none";
3132
+ let s = !1, c = (e) => {
3133
+ s || (s = !0, t.removeEventListener("message", l), clearTimeout(u), o.remove(), a(e));
3134
+ }, l = (e) => {
3135
+ let t = e.data;
3136
+ e.source === o.contentWindow && typeof t == "object" && t && t.type === "bs-sandbox-probe" && t.token === n && c(!0);
3137
+ };
3138
+ t.addEventListener("message", l);
3139
+ let u = setTimeout(() => c(!1), Jn);
3140
+ o.srcdoc = [
3141
+ "<!doctype html><html><head><meta charset=\"utf-8\">",
3142
+ `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src ${i}">`,
3143
+ `</head><body><script>${r}<\/script></body></html>`
3144
+ ].join(""), (e.body ?? e.documentElement).appendChild(o);
3145
+ });
3146
+ })();
3147
+ return Yn.set(e, n), n;
3148
+ }
3149
+ function Zn(e) {
3150
+ let t = [];
3151
+ for (let n of e.querySelectorAll("meta[http-equiv]")) {
3152
+ if (n.getAttribute("http-equiv")?.trim().toLowerCase() !== "content-security-policy") continue;
3153
+ let e = n.getAttribute("content")?.trim();
3154
+ e !== void 0 && e !== "" && t.push(e);
3155
+ }
3156
+ return t.length === 0 ? void 0 : t.join(" | ");
3157
+ }
3158
+ var Qn = "宿主页面的 CSP 挡住了沙箱脚本(srcdoc 沙箱会继承宿主页面的 CSP),需要改用带独立 CSP 的沙箱路由。", $n = "组件代码加载后一直没有结束(可能在顶层死循环或执行过久)。", er = "沙箱握手超时:沙箱脚本没有回应。", tr = "沙箱握手超时:沙箱路由可能没有返回这份文档,或响应头里的 CSP 挡住了脚本。", nr = class {
3159
+ #e;
3160
+ #t;
3161
+ #n;
3162
+ #r;
3163
+ constructor(e, t, n) {
3164
+ this.#e = e, this.#t = t, this.#n = {
3165
+ libraries: t.map((e) => [e.name, e.global]),
3166
+ maxFps: n
3167
+ };
3168
+ }
3169
+ document() {
3170
+ return this.#r ??= this.#i(), this.#r;
3171
+ }
3172
+ async #i() {
3173
+ let e = [
3174
+ Z(`(${String(Be)})(${JSON.stringify(this.#n)});`),
3175
+ ...this.#t.map((e) => Z(e.source)),
3176
+ Z(`globalThis.__bsFormat = (${String(Sn)});`)
3177
+ ], t = Z(`${this.#e}\n;globalThis.__bsCreate = typeof create === 'function' ? create : undefined;\n`), n = await Promise.all([...e, t].map(Wn)), r = [
3178
+ "<!doctype html><html><head><meta charset=\"utf-8\">",
3179
+ `<meta http-equiv="Content-Security-Policy" content="${Le(n)}">`,
3180
+ "<style>html,body{margin:0;overflow:hidden;background:transparent}</style>",
3181
+ "</head><body>",
3182
+ ...e.map((e) => `<script>${e}<\/script>`),
3183
+ `<script type="module">${t}<\/script>`,
3184
+ "</body></html>"
3185
+ ].join(""), i = await Un(r);
3186
+ return {
3187
+ html: r,
3188
+ hash: Array.from(i, (e) => e.toString(16).padStart(2, "0")).join(""),
3189
+ scriptHashes: n
3190
+ };
3191
+ }
3192
+ };
3193
+ function Q(e, t, n = []) {
3194
+ let r = Object.keys(e);
3195
+ return t.every((e) => r.includes(e)) && r.every((e) => t.includes(e) || n.includes(e));
3196
+ }
3197
+ var $ = (e, t) => typeof e == "string" && e.length <= t;
3198
+ function rr(t) {
3199
+ if (typeof t != "object" || !t || Array.isArray(t)) return;
3200
+ let n = t;
3201
+ if (n.type === "bitmap") return Q(n, [
3202
+ "type",
3203
+ "id",
3204
+ "bitmap"
3205
+ ]) && $(n.id, 64) && n.bitmap instanceof ImageBitmap ? {
3206
+ type: "bitmap",
3207
+ id: n.id,
3208
+ bitmap: n.bitmap
3209
+ } : void 0;
3210
+ let r = e(t, { maxBytes: On });
3211
+ if (!r.ok || r.value === null || typeof r.value != "object" || Array.isArray(r.value)) return;
3212
+ let i = r.value;
3213
+ switch (i.type) {
3214
+ case "ready": return Q(i, ["type"]) ? { type: "ready" } : void 0;
3215
+ case "tock": return Q(i, ["type", "pending"]) && Array.isArray(i.pending) && i.pending.length <= 1024 && i.pending.every((e) => $(e, 64)) ? {
3216
+ type: "tock",
3217
+ pending: i.pending
3218
+ } : void 0;
3219
+ case "event": return Q(i, [
3220
+ "type",
3221
+ "id",
3222
+ "name",
3223
+ "payload"
3224
+ ]) && $(i.id, 64) && $(i.name, 128) ? {
3225
+ type: "event",
3226
+ id: i.id,
3227
+ name: i.name,
3228
+ payload: i.payload
3229
+ } : void 0;
3230
+ case "error": return Q(i, ["type", "message"], ["id"]) && $(i.message, 200) && (i.id === void 0 || $(i.id, 64)) ? {
3231
+ type: "error",
3232
+ message: i.message,
3233
+ ...i.id === void 0 ? {} : { id: i.id }
3234
+ } : void 0;
3235
+ case "csp": return Q(i, [
3236
+ "type",
3237
+ "directive",
3238
+ "uri"
3239
+ ]) && $(i.directive, 64) && $(i.uri, 200) ? {
3240
+ type: "csp",
3241
+ directive: i.directive,
3242
+ uri: i.uri
3243
+ } : void 0;
3244
+ default: return;
3245
+ }
3246
+ }
3247
+ function ir(e, t) {
3248
+ if (typeof e != "string" || e.trim() === "") throw Error("沙箱路由没有返回地址。");
3249
+ let n = new URL(e, t.baseURI);
3250
+ if (n.protocol !== "https:" && n.protocol !== "http:") throw Error(`沙箱路由返回的地址不是 http(s):${n.protocol}`);
3251
+ return n;
3252
+ }
3253
+ function ar(e, t) {
3254
+ try {
3255
+ let n = new URL(e);
3256
+ return n.origin === t.origin && (n.pathname === t.pathname || n.pathname === "/");
3257
+ } catch {
3258
+ return !1;
3259
+ }
3260
+ }
3261
+ var or = class {
3262
+ #e;
3263
+ #t;
3264
+ #n = /* @__PURE__ */ new Map();
3265
+ #r = /* @__PURE__ */ new Set();
3266
+ #i = [];
3267
+ #a;
3268
+ #o;
3269
+ #s = !1;
3270
+ #c;
3271
+ #l;
3272
+ #u;
3273
+ #d;
3274
+ #f = 0;
3275
+ #p = 0;
3276
+ #m = !1;
3277
+ #h;
3278
+ #g;
3279
+ #_ = 0;
3280
+ #v;
3281
+ constructor(e, t, n) {
3282
+ this.#e = e, this.#t = t, this.#v = n, this.#y();
3283
+ }
3284
+ get failed() {
3285
+ return this.#c;
3286
+ }
3287
+ async #y() {
3288
+ let e = qn(), t;
3289
+ try {
3290
+ t = await this.#e.bundle.document();
3291
+ } catch (e) {
3292
+ this.fail(`沙箱文档生成失败:${String(e?.message ?? e)}`);
3293
+ return;
3294
+ }
3295
+ if (this.#c !== void 0) return;
3296
+ let n = this.#e.sandbox;
3297
+ if (n !== void 0) {
3298
+ try {
3299
+ this.#h = ir(await n.resolve(t), this.#t);
3300
+ } catch (e) {
3301
+ this.fail(`沙箱文档没能交给宿主的沙箱路由:${String(e?.message ?? e)}`.slice(0, 200), "sandbox-route");
3302
+ return;
3303
+ }
3304
+ if (this.#c !== void 0) return;
3305
+ }
3306
+ let r = this.#t.createElement("iframe");
3307
+ r.setAttribute("sandbox", "allow-scripts"), r.setAttribute("referrerpolicy", "no-referrer"), r.setAttribute("aria-hidden", "true"), r.setAttribute("tabindex", "-1"), r.setAttribute("data-base-screen-isolated-package", this.#e.tagName), r.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none", r.name = e, this.#h === void 0 ? r.srcdoc = t.html : (this.#x(this.#h), r.src = this.#h.href), r.addEventListener("load", () => {
3308
+ this.#m = !0, this.#S(e);
3309
+ }, { once: !0 }), this.#a = r, (this.#t.body ?? this.#t.documentElement).appendChild(r), this.#u = setTimeout(() => {
3310
+ this.#s || this.#b();
3311
+ }, An);
3312
+ }
3313
+ async #b() {
3314
+ if (!this.#m) {
3315
+ this.fail($n, "startup");
3316
+ return;
3317
+ }
3318
+ if (this.#h !== void 0) {
3319
+ this.fail(tr, "handshake", ` 沙箱地址:${this.#h.href.slice(0, 160)}`);
3320
+ return;
3321
+ }
3322
+ let e = await Xn(this.#t);
3323
+ if (this.#s || this.#c !== void 0) return;
3324
+ if (e) {
3325
+ this.fail(er, "handshake");
3326
+ return;
3327
+ }
3328
+ let t = Zn(this.#t);
3329
+ this.fail(Qn, "host-csp", t === void 0 ? "宿主页面没有 <meta> CSP,挡住沙箱的 CSP 多半在 HTTP 响应头里。" : `宿主页面的 <meta> CSP:${t.slice(0, 200)}`);
3330
+ }
3331
+ #x(e) {
3332
+ let t = (t) => {
3333
+ if (this.#s || this.#c !== void 0) return;
3334
+ let n = t.effectiveDirective;
3335
+ (n === "frame-src" || n === "child-src" || n === "default-src") && ar(t.blockedURI, e) && this.fail(`宿主页面的 CSP 没有放行沙箱路由(${n}),需要在宿主 CSP 的 frame-src 里放行 ${e.origin}。`, "host-csp", ` 被拦地址:${String(t.blockedURI).slice(0, 160)}`);
3336
+ };
3337
+ this.#t.addEventListener("securitypolicyviolation", t), this.#g = () => this.#t.removeEventListener("securitypolicyviolation", t);
3338
+ }
3339
+ #S(e) {
3340
+ let t = this.#a?.contentWindow;
3341
+ if (t == null || this.#c !== void 0) return;
3342
+ let n = new MessageChannel();
3343
+ this.#o = n.port1, this.#o.onmessage = (e) => this.#w(e.data), t.postMessage({
3344
+ type: "bs-connect",
3345
+ token: e
3346
+ }, "*", [n.port2]);
3347
+ }
3348
+ #C(e, t, n, r) {
3349
+ this.#e.onAudit?.({
3350
+ kind: e,
3351
+ tagName: this.#e.tagName,
3352
+ message: t,
3353
+ ...n === void 0 ? {} : { componentId: n },
3354
+ ...r === void 0 ? {} : { cause: r }
3355
+ });
3356
+ }
3357
+ #w(e) {
3358
+ if (this.#c !== void 0) return;
3359
+ let t = rr(e);
3360
+ if (t === void 0) {
3361
+ typeof e == "object" && e && e.bitmap instanceof ImageBitmap && e.bitmap.close(), this.#_ += 1, this.#C("protocol", "沙箱消息格式不合法,已丢弃。"), this.#_ > Pn && this.fail("沙箱消息格式反复不合法。", "protocol");
3362
+ return;
3363
+ }
3364
+ switch (t.type) {
3365
+ case "ready":
3366
+ if (this.#s) return;
3367
+ this.#s = !0, this.#u !== void 0 && clearTimeout(this.#u), this.#g?.(), this.#g = void 0;
3368
+ for (let [e, t] of this.#i.splice(0)) this.#o?.postMessage(e, t);
3369
+ cr(this.#t).add(this);
3370
+ return;
3371
+ case "tock":
3372
+ this.#l = void 0;
3373
+ for (let e of t.pending) this.#n.has(e) && this.#r.add(e);
3374
+ return;
3375
+ case "bitmap": {
3376
+ let e = this.#n.get(t.id);
3377
+ e === void 0 ? t.bitmap.close() : e.receiveBitmap(t.bitmap);
3378
+ return;
3379
+ }
3380
+ case "event":
3381
+ this.#n.get(t.id)?.dispatchMaterialEvent(t.name, t.payload);
3382
+ return;
3383
+ case "error": {
3384
+ let e = t.id === void 0 ? void 0 : this.#n.get(t.id);
3385
+ this.#C("error", t.message, e?.componentId), e?.receiveError(t.message);
3386
+ return;
3387
+ }
3388
+ case "csp":
3389
+ this.#C("csp", `${t.directive} ${t.uri}`);
3390
+ return;
3391
+ }
3392
+ }
3393
+ post(e, t = []) {
3394
+ this.#c === void 0 && (this.#s && this.#o !== void 0 ? this.#o.postMessage(e, t) : this.#i.push([e, t]));
3395
+ }
3396
+ join(e, t) {
3397
+ if (this.#d !== void 0 && (clearTimeout(this.#d), this.#d = void 0), this.#c !== void 0) {
3398
+ e.shutdown(this.#c);
3399
+ return;
3400
+ }
3401
+ this.#n.set(e.instanceId, e), this.#r.add(e.instanceId), this.post({
3402
+ type: "mount",
3403
+ id: e.instanceId,
3404
+ state: t
3405
+ });
3406
+ }
3407
+ update(e, t) {
3408
+ this.#n.has(e.instanceId) && (this.#r.add(e.instanceId), this.post({
3409
+ type: "update",
3410
+ id: e.instanceId,
3411
+ state: t
3412
+ }));
3413
+ }
3414
+ leave(e) {
3415
+ this.#n.delete(e.instanceId) && (this.#r.delete(e.instanceId), this.post({
3416
+ type: "unmount",
3417
+ id: e.instanceId
3418
+ }), this.#n.size === 0 && (this.#d = setTimeout(() => {
3419
+ this.#n.size === 0 && this.dispose();
3420
+ }, Fn)));
3421
+ }
3422
+ tick(e) {
3423
+ if (!this.#s || this.#c !== void 0) return;
3424
+ let t = performance.now(), n = this.#p !== 0 && e - this.#p > 500;
3425
+ if (this.#p = e, this.#l !== void 0) {
3426
+ n ? this.#l = t : t - this.#l > jn && this.fail("组件代码长时间没有响应(疑似死循环)。", "stall");
3427
+ return;
3428
+ }
3429
+ if (t - this.#f > In) {
3430
+ this.#f = t;
3431
+ for (let e of this.#n.values()) {
3432
+ let t = e.recheckDpr();
3433
+ t !== void 0 && this.update(e, t);
3434
+ }
3435
+ }
3436
+ let r = [];
3437
+ for (let e of this.#n.values()) (e.continuous() || this.#r.has(e.instanceId)) && r.push(e.instanceId);
3438
+ this.#r.clear(), r.length !== 0 && (this.#l = t, this.#o?.postMessage({
3439
+ type: "tick",
3440
+ now: e,
3441
+ ids: r
3442
+ }));
3443
+ }
3444
+ fail(e, t, n) {
3445
+ if (this.#c === void 0) {
3446
+ this.#c = e, this.#C("circuit", n === void 0 ? e : `${e}${n}`, void 0, t);
3447
+ for (let t of this.#n.values()) t.shutdown(e);
3448
+ this.#T();
3449
+ }
3450
+ }
3451
+ dispose() {
3452
+ this.#T(), this.#v();
3453
+ }
3454
+ #T() {
3455
+ cr(this.#t).delete(this), this.#g?.(), this.#g = void 0, this.#u !== void 0 && clearTimeout(this.#u), this.#d !== void 0 && clearTimeout(this.#d), this.#o?.close(), this.#o = void 0, this.#a?.remove(), this.#a = void 0, this.#i.length = 0;
3456
+ }
3457
+ }, sr = /* @__PURE__ */ new WeakMap();
3458
+ function cr(e) {
3459
+ let t = sr.get(e);
3460
+ if (t !== void 0) return t;
3461
+ let n = /* @__PURE__ */ new Set(), r = e.defaultView, i = !1, a = (e) => {
3462
+ if (n.size === 0) {
3463
+ i = !1;
3464
+ return;
3465
+ }
3466
+ for (let t of n) t.tick(e);
3467
+ r?.requestAnimationFrame(a);
3468
+ }, o = {
3469
+ add(e) {
3470
+ n.add(e), !i && r !== null && (i = !0, r.requestAnimationFrame(a));
3471
+ },
3472
+ delete(e) {
3473
+ n.delete(e);
3474
+ }
3475
+ };
3476
+ return sr.set(e, o), o;
3477
+ }
3478
+ var lr = /* @__PURE__ */ new WeakMap();
3479
+ function ur(e, t) {
3480
+ let n = lr.get(t);
3481
+ n === void 0 && (n = /* @__PURE__ */ new Map(), lr.set(t, n));
3482
+ let r = n.get(e.tagName);
3483
+ if (r !== void 0) return r;
3484
+ let i = new or(e, t, () => {
3485
+ n.get(e.tagName) === i && n.delete(e.tagName);
3486
+ });
3487
+ return n.set(e.tagName, i), i;
3488
+ }
3489
+ var dr = 0;
3490
+ function fr(e) {
3491
+ let t = globalThis.HTMLElement ?? class {}, n = new Set(e.manifest.events);
3492
+ class r extends t {
3493
+ instanceId = `i${++dr}`;
3494
+ #e;
3495
+ #t;
3496
+ #n;
3497
+ #r;
3498
+ #i = null;
3499
+ #a;
3500
+ #o = !1;
3501
+ #s = !0;
3502
+ #c;
3503
+ #l = 0;
3504
+ #u = 0;
3505
+ #d = 0;
3506
+ #f;
3507
+ #p;
3508
+ get componentId() {
3509
+ return this.#e?.componentId ?? "";
3510
+ }
3511
+ get model() {
3512
+ if (this.#e === void 0) throw Error("Material model has not been set.");
3513
+ return this.#e;
3514
+ }
3515
+ set model(e) {
3516
+ this.#e = e, this.setAttribute("data-base-screen-data-state", e.dataState.status), this.#y();
3517
+ }
3518
+ connectedCallback() {
3519
+ typeof IntersectionObserver == "function" && this.#c === void 0 && (this.#c = new IntersectionObserver((e) => {
3520
+ let t = e[e.length - 1];
3521
+ t !== void 0 && (this.#s = t.isIntersecting);
3522
+ }), this.#c.observe(this)), this.#y();
3523
+ }
3524
+ disconnectedCallback() {
3525
+ this.#c?.disconnect(), this.#c = void 0, this.#t?.leave(this), this.#t = void 0, this.#a = void 0, this.#o = !1;
3526
+ }
3527
+ #m() {
3528
+ if (this.#n !== void 0) return this.#n;
3529
+ let e = this.shadowRoot ?? this.attachShadow({ mode: "open" }), t = this.ownerDocument.createElement("style");
3530
+ t.textContent = zn;
3531
+ let n = this.ownerDocument.createElement("div");
3532
+ return n.className = "frame", n.setAttribute("part", "frame"), e.replaceChildren(t, n), this.#n = n, n;
3533
+ }
3534
+ #h(e) {
3535
+ this.#m().replaceChildren(...e === void 0 ? [] : [e]);
3536
+ }
3537
+ #g() {
3538
+ if (this.#r !== void 0) return this.#r;
3539
+ let t = this.ownerDocument.createElement("canvas");
3540
+ return t.setAttribute("role", "img"), t.setAttribute("aria-label", e.manifest.name), t.addEventListener("click", (e) => {
3541
+ let t = this.#e;
3542
+ t === void 0 || t.mode === "design" || !t.interactive || this.#t?.post({
3543
+ type: "pointer",
3544
+ id: this.instanceId,
3545
+ x: e.offsetX,
3546
+ y: e.offsetY
3547
+ });
3548
+ }), this.#i = t.getContext("bitmaprenderer"), this.#r = t, t;
3549
+ }
3550
+ #_(e) {
3551
+ let t = this.getBoundingClientRect(), n = t.width > 0 && e.size.width > 0 ? Math.max(t.width / e.size.width, t.height / Math.max(1, e.size.height)) : 1, r = (this.ownerDocument.defaultView?.devicePixelRatio ?? 1) * n;
3552
+ return Math.round(Math.min(3, Math.max(.5, r)) * 100) / 100;
3553
+ }
3554
+ #v(t, n) {
3555
+ let r = U(e.data, n), i = this.#a, a = i !== void 0 && i.w === t.size.width && i.h === t.size.height ? i.dpr : this.#_(t);
3556
+ return {
3557
+ w: t.size.width,
3558
+ h: t.size.height,
3559
+ dpr: a,
3560
+ props: t.props,
3561
+ style: t.style,
3562
+ mode: t.mode,
3563
+ value: r.value,
3564
+ rows: r.rows,
3565
+ interactive: t.interactive
3566
+ };
3567
+ }
3568
+ #y() {
3569
+ let t = this.#e;
3570
+ if (t === void 0 || !this.isConnected || (this.#m(), this.#f !== void 0)) return;
3571
+ let n = t.dataState.status;
3572
+ if (e.data.kind !== "none" && n !== "ready") {
3573
+ if (this.#o && n !== "error") return;
3574
+ this.#o = !1, this.#h(b(this.ownerDocument, t.dataState));
3575
+ return;
3576
+ }
3577
+ let r = t.dataState.status === "ready" ? t.dataState.value : void 0, i = this.#v(t, r);
3578
+ if (e.data.kind === "rows" && i.rows.length === 0) {
3579
+ this.#o = !1, this.#h(x(this.ownerDocument));
3580
+ return;
3581
+ }
3582
+ this.#o || this.#h(b(this.ownerDocument, { status: "loading" }));
3583
+ let a = this.#a === void 0;
3584
+ this.#a = i, a ? (this.#t = ur(e, this.ownerDocument), this.#t.join(this, i)) : this.#t?.update(this, i);
3585
+ }
3586
+ continuous() {
3587
+ let e = this.#e;
3588
+ return e === void 0 || e.mode === "design" || !this.#s ? !1 : (this.#p === void 0 && (this.#p = this.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)") ?? null), this.#p?.matches !== !0);
3589
+ }
3590
+ recheckDpr() {
3591
+ let e = this.#e, t = this.#a;
3592
+ if (e === void 0 || t === void 0) return;
3593
+ let n = this.#_(e);
3594
+ if (!(Math.abs(n - t.dpr) / t.dpr < .1)) return this.#a = {
3595
+ ...t,
3596
+ dpr: n
3597
+ }, this.#a;
3598
+ }
3599
+ receiveBitmap(t) {
3600
+ let n = this.#a, r = Math.max(1, n?.dpr ?? 1), i = Math.ceil((n?.w ?? 0) * r * 1.1) + 2, a = Math.ceil((n?.h ?? 0) * r * 1.1) + 2;
3601
+ if (n === void 0 || this.#f !== void 0 || t.width > i || t.height > a) {
3602
+ t.close();
3603
+ return;
3604
+ }
3605
+ let o = this.#g();
3606
+ o.width !== t.width && (o.width = t.width), o.height !== t.height && (o.height = t.height), this.#i?.transferFromImageBitmap(t), this.#l = 0, (!this.#o || this.#n?.firstChild !== o) && this.#h(o), this.#o = !0, e.onFrame?.(this.componentId);
3607
+ }
3608
+ receiveError(e) {
3609
+ if (this.#l += 1, this.#l >= Nn) {
3610
+ this.#t?.fail(`组件代码连续出错:${e}`, "errors");
3611
+ return;
3612
+ }
3613
+ this.#o = !1, this.#h(y(this.ownerDocument, "HOST_DATASET_INVALID", `组件渲染失败:${e}`.slice(0, 160)));
3614
+ }
3615
+ dispatchMaterialEvent(t, r) {
3616
+ if (!n.has(t)) {
3617
+ e.onAudit?.({
3618
+ kind: "protocol",
3619
+ tagName: e.tagName,
3620
+ componentId: this.componentId,
3621
+ message: `事件 ${t} 不在组件声明里,已丢弃。`
3622
+ });
3623
+ return;
3624
+ }
3625
+ let a = performance.now();
3626
+ if (a - this.#u >= 1e3 && (this.#u = a, this.#d = 0), this.#d += 1, this.#d > Mn) {
3627
+ this.#d === 21 && e.onAudit?.({
3628
+ kind: "rate",
3629
+ tagName: e.tagName,
3630
+ componentId: this.componentId,
3631
+ message: `事件超过每秒 ${Mn} 条,多余的已丢弃。`
3632
+ });
3633
+ return;
3634
+ }
3635
+ this.dispatchEvent(new CustomEvent(i, {
3636
+ bubbles: !0,
3637
+ composed: !0,
3638
+ detail: {
3639
+ name: t,
3640
+ payload: r
3641
+ }
3642
+ }));
3643
+ }
3644
+ shutdown(e) {
3645
+ this.#f = e, this.#o = !1, this.isConnected && this.#h(y(this.ownerDocument, "HOST_DATASET_INVALID", `组件已停用:${e}`.slice(0, 160)));
3646
+ }
3647
+ }
3648
+ Object.defineProperty(r, "manifest", {
3649
+ value: e.manifest,
3650
+ configurable: !0
3651
+ });
3652
+ let a = Qt(e.data);
3653
+ return a !== void 0 && Object.defineProperty(r, "tabularDataAdapter", { value: a }), r;
3654
+ }
3655
+ //#endregion
3656
+ //#region ../plugin-sdk/dist/material-package.js
3657
+ var pr = 512;
3658
+ function mr(e) {
3659
+ let t = e;
3660
+ if (typeof t != "object" || !t || Array.isArray(t)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", [], "Material package options must be an object.");
3661
+ let n = t, r, i;
3662
+ try {
3663
+ r = n.id, i = n.materials;
3664
+ } catch {
3665
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", [], "Material package options cannot be safely read.");
3666
+ }
3667
+ if (!_r(r)) return v("PLUGIN_CORE_IDENTITY_INVALID", ["id"], "Material package id must be an ASCII identifier.");
3668
+ if (!Array.isArray(i) || i.length === 0) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Material package must declare at least one material.");
3669
+ if (i.length > pr) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Material package exceeds the material count limit.");
3670
+ let a = [], o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
3671
+ for (let e = 0; e < i.length; e++) {
3672
+ let t;
3673
+ try {
3674
+ let n = i[e];
3675
+ if (typeof n != "object" || !n || Array.isArray(n)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", ["materials", e], "Material package entry must be an object.");
3676
+ t = _(n);
3677
+ } catch {
3678
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials", e], "Material package entry cannot be safely read.");
3679
+ }
3680
+ if (!t.ok) return g(t.diagnostics, ["materials", e]);
3681
+ let n = t.value.manifest;
3682
+ if (o.has(n.type)) return v("PLUGIN_CORE_IDENTITY_CONFLICT", [
3683
+ "materials",
3684
+ e,
3685
+ "type"
3686
+ ], "Material package contains a duplicate material type.");
3687
+ if (s.has(n.tagName)) return v("PLUGIN_CORE_IDENTITY_CONFLICT", [
3688
+ "materials",
3689
+ e,
3690
+ "tagName"
3691
+ ], "Material package contains a duplicate tag name.");
3692
+ o.add(n.type), s.add(n.tagName), a.push(t.value);
3693
+ }
3694
+ let c = Object.freeze(a);
3695
+ return {
3696
+ ok: !0,
3697
+ value: {
3698
+ id: n.id,
3699
+ materials: c,
3700
+ define: () => hr(c)
3701
+ },
3702
+ diagnostics: []
3703
+ };
3704
+ }
3705
+ function hr(e) {
3706
+ let t = [];
3707
+ for (let n = 0; n < e.length; n++) {
3708
+ let r = gr(e[n]);
3709
+ r !== void 0 && t.push({
3710
+ ...r,
3711
+ path: [
3712
+ "materials",
3713
+ n,
3714
+ "tagName"
3715
+ ]
3716
+ });
3717
+ }
3718
+ if (t.length > 0) return {
3719
+ ok: !1,
3720
+ diagnostics: h(t)
3721
+ };
3722
+ let n = [];
3723
+ for (let t = 0; t < e.length; t++) {
3724
+ let r = e[t].define();
3725
+ if (!r.ok) return {
3726
+ ok: !1,
3727
+ diagnostics: h(r.diagnostics.map((e) => ({
3728
+ ...e,
3729
+ path: [
3730
+ "materials",
3731
+ t,
3732
+ ...e.path
3733
+ ]
3734
+ })))
3735
+ };
3736
+ n.push(r.value);
3737
+ }
3738
+ return {
3739
+ ok: !0,
3740
+ value: Object.freeze(n),
3741
+ diagnostics: []
3742
+ };
3743
+ }
3744
+ function gr(e) {
3745
+ let t = globalThis.customElements;
3746
+ if (t === void 0) return;
3747
+ let n;
3748
+ try {
3749
+ n = t.get(e.manifest.tagName);
3750
+ } catch {
3751
+ return;
3752
+ }
3753
+ if (n !== void 0 && n !== e.element) return {
3754
+ severity: "error",
3755
+ code: "PLUGIN_CORE_IDENTITY_CONFLICT",
3756
+ path: [],
3757
+ message: "Tag name is already bound to a different constructor."
3758
+ };
3759
+ }
3760
+ function _r(e) {
3761
+ return typeof e == "string" && e.length > 0 && e.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e);
3762
+ }
3763
+ //#endregion
3764
+ //#region ../plugin-sdk/dist/material-style-keys.js
3765
+ var vr = /* @__PURE__ */ new Set(/* @__PURE__ */ "fill.backgroundColor.color.labelColor.accentColor.fontSize.labelFontSize.borderColor.borderWidth.borderRadius.strokeColor.strokeWidth.fontWeight.textAlign.verticalAlign.letterSpacing.lineHeight.lineSpacing.shadowColor.shadowBlur.shadowOffsetX.shadowOffsetY.criticalColor.warningColor.infoColor.runningColor.standbyColor.faultColor.offlineColor.unknownColor.positiveColor.negativeColor".split(".")), yr = /* @__PURE__ */ new Set([
3766
+ "accent",
3767
+ "background",
3768
+ "connectorColor",
3769
+ "connectorWidth",
3770
+ "dash",
3771
+ "fillColor",
3772
+ "fillGlow",
3773
+ "gridColor",
3774
+ "headerBackgroundColor",
3775
+ "headerColor",
3776
+ "lineWidth",
3777
+ "nodeBackground",
3778
+ "nodeBorderColor",
3779
+ "objectFit",
3780
+ "rowHeight",
3781
+ "seriesColor",
3782
+ "thickness",
3783
+ "tileGap",
3784
+ "tileRadius",
3785
+ "trackColor",
3786
+ "valueColor",
3787
+ "waterColor",
3788
+ "waveColor"
3789
+ ]), br = [
3790
+ "title",
3791
+ "caption",
3792
+ "description",
3793
+ "subtitle",
3794
+ "showTitle",
3795
+ "titleText"
3796
+ ];
3797
+ //#endregion
3798
+ //#region ../plugin-sdk/dist/material-template-audit.js
3799
+ function xr(e) {
3800
+ if (e.template === void 0) return [];
3801
+ let t = I(e.template, {
3802
+ fields: e.fields,
3803
+ data: e.data,
3804
+ ...e.events === void 0 ? {} : { events: e.events },
3805
+ sectionTarget: (e) => e === "text" || e === "surface" || e === "semantic" ? "style" : "props"
3806
+ });
3807
+ if (!t.ok) return [];
3808
+ let n = H(e, { tagName: "base-screen-template-audit" });
3809
+ if (!n.ok) return [];
3810
+ let r = n.value.defaultProps ?? {}, i = n.value.defaultStyle ?? {}, a = e.data.kind === "scalar" ? e.data.sample : e.data.kind === "rows" ? Zt(e.data) : void 0, o = U(e.data, a), s = {
3811
+ value: o.value,
3812
+ rows: o.rows,
3813
+ props: r,
3814
+ style: i,
3815
+ size: e.defaultSize,
3816
+ formatNumber: (e) => Sn(e, r),
3817
+ budget: { steps: Ve }
3818
+ };
3819
+ return new Sr(t.value, i).run(s);
3820
+ }
3821
+ var Sr = class {
3822
+ template;
3823
+ style;
3824
+ #e = [];
3825
+ #t = /* @__PURE__ */ new Map();
3826
+ #n = /* @__PURE__ */ new Set();
3827
+ #r = /* @__PURE__ */ new Set();
3828
+ constructor(e, t) {
3829
+ this.template = e, this.style = t;
3830
+ }
3831
+ run(e) {
3832
+ try {
3833
+ for (let t of this.template.nodes) this.#a(t, e, !1);
3834
+ } catch (e) {
3835
+ this.#e.push({
3836
+ rule: "TPL9",
3837
+ severity: "error",
3838
+ message: `示例数据下模板渲染失败:${e instanceof Error ? e.message : String(e)}`,
3839
+ path: ["template"]
3840
+ });
3841
+ }
3842
+ this.#c();
3843
+ for (let e of this.#n) {
3844
+ let t = this.template.index.get(e);
3845
+ this.#e.push({
3846
+ rule: "TPL10",
3847
+ severity: "warning",
3848
+ message: `节点 ${e} 在示例数据下超出 viewBox,会被裁掉(需要溢出时放进 clip)。`,
3849
+ ...t === void 0 ? {} : { path: ["template", ...t.path] }
3850
+ });
3851
+ }
3852
+ return this.#e;
3853
+ }
3854
+ #i(e, t, n, r) {
3855
+ let i = A(O(e, t));
3856
+ return !Number.isFinite(i) && !this.#r.has(`${n.id}.${r}`) && (this.#r.add(`${n.id}.${r}`), this.#e.push({
3857
+ rule: "TPL9",
3858
+ severity: "error",
3859
+ message: `示例数据下 ${n.id}.${r} 求不出数字(结果为 NaN 或无穷):检查除零、空数据与引号。`,
3860
+ path: [
3861
+ "template",
3862
+ ...n.path,
3863
+ r
3864
+ ]
3865
+ })), i;
3866
+ }
3867
+ #a(e, t, n) {
3868
+ switch (e.kind) {
3869
+ case "repeat": {
3870
+ let r = e.source;
3871
+ if (r === void 0) return;
3872
+ let i = r.k === "rows" ? t.rows.length : this.#i(r.n, t, e, "source"), a = Math.max(0, Math.min(N.repeat, Math.trunc(Number.isFinite(i) ? i : 0)));
3873
+ for (let i = 0; i < a; i += 1) {
3874
+ let o = {
3875
+ ...t,
3876
+ index: i,
3877
+ count: a,
3878
+ ...r.k === "rows" ? { row: t.rows[i] } : {}
3879
+ };
3880
+ for (let t of e.children ?? []) this.#a(t, o, n);
3881
+ }
3882
+ return;
3883
+ }
3884
+ case "when":
3885
+ e.test !== void 0 && O(e.test, t);
3886
+ for (let r of e.children ?? []) this.#a(r, t, n);
3887
+ return;
3888
+ case "clip":
3889
+ for (let n of e.children ?? []) this.#a(n, t, !0);
3890
+ return;
3891
+ case "g": {
3892
+ let r = e.num.x !== void 0 || e.num.y !== void 0 || e.num.rotate !== void 0 || e.num.scale !== void 0;
3893
+ for (let [n, r] of Object.entries(e.num)) this.#i(r, t, e, n);
3894
+ for (let i of e.children ?? []) this.#a(i, t, n || r);
3895
+ return;
3896
+ }
3897
+ }
3898
+ let r = {};
3899
+ for (let [n, i] of Object.entries(e.num)) r[n] = this.#i(i, t, e, n);
3900
+ e.content !== void 0 && O(e.content, t);
3901
+ for (let n of e.on?.payload ?? []) O(n.value, t);
3902
+ if (e.points !== void 0) {
3903
+ let r = e.points.source, i = r.k === "rows" ? t.rows.length : Math.max(0, Math.min(N.repeat, Math.trunc(this.#i(r.n, t, e, "points"))));
3904
+ for (let a = 0; a < i; a += 1) {
3905
+ let o = {
3906
+ ...t,
3907
+ index: a,
3908
+ count: i,
3909
+ ...r.k === "rows" ? { row: t.rows[a] } : {}
3910
+ }, s = this.#i(e.points.x, o, e, "points.x"), c = this.#i(e.points.y, o, e, "points.y");
3911
+ n || this.#s(e, [s, s], [c, c]);
3912
+ }
3913
+ }
3914
+ for (let [, n] of e.d ?? []) for (let r of n) this.#i(r, t, e, "d");
3915
+ if (e.kind === "text") {
3916
+ let t = this.#t.get(e.id), n = r.fontSize ?? 0;
3917
+ (t === void 0 || n < t.fontSize) && this.#t.set(e.id, {
3918
+ node: e,
3919
+ fontSize: n,
3920
+ fontWeight: e.fontWeight ?? 400
3921
+ });
3922
+ }
3923
+ n || this.#o(e, r);
3924
+ }
3925
+ #o(e, t) {
3926
+ let n = (e) => t[e] ?? 0;
3927
+ switch (e.kind) {
3928
+ case "rect":
3929
+ this.#s(e, [n("x"), n("x") + n("width")], [n("y"), n("y") + n("height")]);
3930
+ return;
3931
+ case "circle":
3932
+ this.#s(e, [n("cx") - n("r"), n("cx") + n("r")], [n("cy") - n("r"), n("cy") + n("r")]);
3933
+ return;
3934
+ case "ellipse":
3935
+ this.#s(e, [n("cx") - n("rx"), n("cx") + n("rx")], [n("cy") - n("ry"), n("cy") + n("ry")]);
3936
+ return;
3937
+ case "line":
3938
+ this.#s(e, [Math.min(n("x1"), n("x2")), Math.max(n("x1"), n("x2"))], [Math.min(n("y1"), n("y2")), Math.max(n("y1"), n("y2"))]);
3939
+ return;
3940
+ case "arc": {
3941
+ let t = n("r") + n("thickness") / 2;
3942
+ this.#s(e, [n("cx") - t, n("cx") + t], [n("cy") - t, n("cy") + t]);
3943
+ return;
3944
+ }
3945
+ case "text":
3946
+ this.#s(e, [n("x"), n("x")], [n("y"), n("y")]);
3947
+ return;
3948
+ default: return;
3949
+ }
3950
+ }
3951
+ #s(e, t, n) {
3952
+ let [r, i, a, o] = this.template.viewBox, s = .5;
3953
+ (!Number.isFinite(t[0] + t[1] + n[0] + n[1]) || t[0] < r - s || n[0] < i - s || t[1] > r + a + s || n[1] > i + o + s) && this.#n.add(e.id);
3954
+ }
3955
+ #c() {
3956
+ let e = m(1920);
3957
+ for (let t of this.#t.values()) {
3958
+ let n = ["template", ...t.node.path];
3959
+ t.fontSize < e - .01 && this.#e.push({
3960
+ rule: "TPL7",
3961
+ severity: "error",
3962
+ message: `文字 ${t.node.id} 的字号 ${Cr(t.fontSize)}px 低于下限 ${Cr(e)}px(1920 宽画布 16px 等比)。`,
3963
+ path: [...n, "fontSize"]
3964
+ });
3965
+ let r = t.node.backdrop;
3966
+ if (r === void 0 || r === "container") continue;
3967
+ let i = this.template.index.get(r);
3968
+ if (i === void 0) continue;
3969
+ let a = this.#l(t.node.fill), o = this.#l(i.fill);
3970
+ if (a.length === 0 || o.length === 0) continue;
3971
+ let s = d(t.fontSize, t.fontWeight), c;
3972
+ for (let e of a) for (let t of o) {
3973
+ let n = f(e), r = f(t);
3974
+ if (n === void 0 || r === void 0) continue;
3975
+ let i = p(n, r);
3976
+ (c === void 0 || i < c.ratio) && (c = {
3977
+ ratio: i,
3978
+ text: e,
3979
+ back: t
3980
+ });
3981
+ }
3982
+ c !== void 0 && c.ratio < s && this.#e.push({
3983
+ rule: "TPL8",
3984
+ severity: "warning",
3985
+ message: `文字 ${t.node.id}(${c.text})在底板 ${r}(${c.back})上的对比度 ${c.ratio.toFixed(2)},低于 ${s}。`,
3986
+ path: [...n, "fill"]
3987
+ });
3988
+ }
3989
+ }
3990
+ #l(e) {
3991
+ return e === void 0 ? [] : e.k === "color" ? [e.v] : e.k === "gradient" ? (this.template.gradients.find((t) => t.id === e.id)?.stops ?? []).flatMap((e) => this.#l(e.color)) : this.#u(e.e);
3992
+ }
3993
+ #u(e) {
3994
+ switch (e.k) {
3995
+ case "lit": return typeof e.v == "string" ? [e.v] : [];
3996
+ case "ref": {
3997
+ if (e.root !== "style" || e.key === void 0) return [];
3998
+ let t = this.style[e.key];
3999
+ return typeof t == "string" && F.test(t) ? [t] : [];
4000
+ }
4001
+ case "cond": return [...this.#u(e.a), ...this.#u(e.b)];
4002
+ case "call": return e.args.flatMap((t, n) => n === 0 || n % 2 == 1 && n !== e.args.length - 1 ? [] : this.#u(t));
4003
+ default: return [];
4004
+ }
4005
+ }
4006
+ };
4007
+ function Cr(e) {
4008
+ return Math.round(e * 10) / 10;
4009
+ }
4010
+ //#endregion
4011
+ //#region ../plugin-sdk/dist/material-spec-audit.js
4012
+ var wr = "base-screen-spec-audit", Tr = /* @__PURE__ */ new Set([...br, "label"]), Er = /标题|副标题|说明|描述|备注|注释/, Dr = /^(?:empty|loading|error)(?:Text|Label|Message)$/, Or = 1920, kr = 1080, Ar = /^(TPL\d+):/;
4013
+ function jr(e, t = {}) {
4014
+ let n = V(e);
4015
+ if (!n.ok) return C(n.diagnostics.map((e) => {
4016
+ let t = Ar.exec(e.message)?.[1];
4017
+ return {
4018
+ rule: t ?? "SPEC",
4019
+ severity: "error",
4020
+ message: t === void 0 ? e.message : e.message.slice(t.length + 1),
4021
+ path: e.path
4022
+ };
4023
+ }));
4024
+ let r = n.value, i = [];
4025
+ r.fields.forEach((e, t) => Mr(e, t, i));
4026
+ let a = H(r, { tagName: wr });
4027
+ if (a.ok) for (let e of Ce(a.value)) i.push({
4028
+ rule: e.rule,
4029
+ severity: e.rule === "R9" ? "warning" : "error",
4030
+ message: e.message,
4031
+ ...e.field === void 0 ? {} : { path: Ir(r, e.field) }
4032
+ });
4033
+ else for (let e of a.diagnostics) i.push({
4034
+ rule: "SPEC",
4035
+ severity: "error",
4036
+ message: e.message,
4037
+ path: e.path
4038
+ });
4039
+ return r.data.kind === "rows" && r.data.sample.length === 0 && i.push({
4040
+ rule: "D1",
4041
+ severity: "warning",
4042
+ message: "多行组件没有示例行:预览与新插入的组件只能显示空态。",
4043
+ path: ["data", "sample"]
4044
+ }), (r.defaultSize.width > Or || r.defaultSize.height > kr) && i.push({
4045
+ rule: "S1",
4046
+ severity: "warning",
4047
+ message: "默认尺寸超过一整屏:组件是设计稿上的一块,通常在 600×300 以内。",
4048
+ path: ["defaultSize"]
4049
+ }), r.template === void 0 ? t.renderSource !== void 0 && Pr(t.renderSource, r, i) : (i.push(...xr(r)), t.renderSource !== void 0 && t.renderSource.trim() !== "" && i.push({
4050
+ rule: "TPL1",
4051
+ severity: "error",
4052
+ message: "规格带 template 时不能再写渲染代码:L2 物料只有数据(ADR-0116 D1)。",
4053
+ path: ["template"]
4054
+ })), C(i);
4055
+ }
4056
+ function Mr(e, t, n) {
4057
+ let r = ["fields", t];
4058
+ (Tr.has(e.key) || Er.test(e.label)) && n.push({
4059
+ rule: "T4",
4060
+ severity: "error",
4061
+ message: `「${e.label}」是描述性文案:组件只呈现读数,标题与说明用相邻的文本组件组合。`,
4062
+ path: r
4063
+ }), /(?:Column|Field)$/.test(e.key) && n.push({
4064
+ rule: "R7",
4065
+ severity: "error",
4066
+ message: `${e.key} 像是在手填列名:改成多行数据的一个角色,由数据面板绑定列。`,
4067
+ path: [...r, "key"]
4068
+ }), Dr.test(e.key) && n.push({
4069
+ rule: "R8",
4070
+ severity: "error",
4071
+ message: `${e.key} 是状态文案:空态 / 加载态 / 错误态由 SDK 状态视图统一提供。`,
4072
+ path: [...r, "key"]
4073
+ });
4074
+ let i = R.find((t) => t.id === e.section)?.target;
4075
+ e.kind === "color" && i === "props" && n.push({
4076
+ rule: "P2",
4077
+ severity: "error",
4078
+ message: `颜色「${e.label}」是视觉量,放进文字 / 填充与描边 / 语义色分区,告警与主题才能改变它。`,
4079
+ path: [...r, "section"]
4080
+ }), i === "style" && !vr.has(e.key) && !yr.has(e.key) && n.push({
4081
+ rule: "R4",
4082
+ severity: "warning",
4083
+ message: `${e.key} 不在样式键词典里:能复用 color / fillColor / trackColor 等通用键时优先复用。`,
4084
+ path: [...r, "key"]
4085
+ });
4086
+ }
4087
+ var Nr = [
4088
+ {
4089
+ pattern: /\bfetch\s*\(|\bXMLHttpRequest\b|\bWebSocket\b|\bEventSource\b|\bsendBeacon\b|\bimport\s*\(/,
4090
+ severity: "error",
4091
+ message: "渲染代码不自行取数或加载代码:数据经数据源进入 value / rows。"
4092
+ },
4093
+ {
4094
+ pattern: /\blocalStorage\b|\bsessionStorage\b|\bindexedDB\b|document\.cookie/,
4095
+ severity: "error",
4096
+ message: "渲染代码不读写浏览器存储:组件状态只来自 props / style / 数据。"
4097
+ },
4098
+ {
4099
+ pattern: /getRootNode\s*\(|\.host\b|ownerDocument\.body|document\.(?:body|head|documentElement)/,
4100
+ severity: "error",
4101
+ message: "只在 root 里绘制:宿主元素与页面归渲染器所有(物料渲染盒不变式)。"
4102
+ },
4103
+ {
4104
+ pattern: /\bsetInterval\s*\(|\brequestAnimationFrame\s*\(/,
4105
+ severity: "warning",
4106
+ message: "每次数据或配置变化都会整体重绘:定时器与动画帧不会随之清理,动画请用 CSS。"
4107
+ },
4108
+ {
4109
+ pattern: /\b(?:innerHTML|outerHTML)\s*=|insertAdjacentHTML\s*\(/,
4110
+ severity: "warning",
4111
+ message: "用 textContent 呈现数据,避免把读数当作 HTML 解释。"
4112
+ }
4113
+ ];
4114
+ function Pr(e, t, n) {
4115
+ let r = Fr(e);
4116
+ for (let e of Nr) e.pattern.test(r) && n.push({
4117
+ rule: "RENDER",
4118
+ severity: e.severity,
4119
+ message: e.message
4120
+ });
4121
+ r.trim() === "" && n.push({
4122
+ rule: "RENDER",
4123
+ severity: "error",
4124
+ message: "渲染代码为空。"
4125
+ }), t.data.kind === "none" && /\b(?:value|rows)\b/.test(r) && n.push({
4126
+ rule: "RENDER",
4127
+ severity: "warning",
4128
+ message: "组件声明为无数据,渲染代码却读了 value / rows:它们恒为空。"
4129
+ }), t.numberFormat !== void 0 && !/\bformatNumber\b/.test(r) && n.push({
4130
+ rule: "RENDER",
4131
+ severity: "warning",
4132
+ message: "开启了读数格式,但渲染代码没有调用 formatNumber:检查器里的小数位、单位不会生效。"
4133
+ });
4134
+ }
4135
+ function Fr(e) {
4136
+ return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
4137
+ }
4138
+ function Ir(e, t) {
4139
+ let n = e.fields.findIndex((e) => e.key === t);
4140
+ return n < 0 ? ["numberFormat"] : ["fields", n];
4141
+ }
4142
+ //#endregion
4143
+ //#region ../plugin-sdk/dist/plugin-package.js
4144
+ function Lr(e) {
4145
+ let t = e;
4146
+ if (typeof t != "object" || !t || Array.isArray(t)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", [], "Plugin package options must be an object.");
4147
+ let n, r, i;
4148
+ try {
4149
+ n = t.id, r = t.plugin, i = t.materials;
4150
+ } catch {
4151
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", [], "Plugin package options cannot be safely read.");
4152
+ }
4153
+ if (!zr(n)) return v("PLUGIN_CORE_IDENTITY_INVALID", ["id"], "Plugin package id must be an ASCII identifier.");
4154
+ if (typeof r != "object" || !r || Array.isArray(r)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", ["plugin"], "Plugin package runtime must be an object.");
4155
+ let a = S(r);
4156
+ if (!a.ok) return g(a.diagnostics, ["plugin"]);
4157
+ let o;
4158
+ if (i !== void 0) {
4159
+ if (!Array.isArray(i)) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Plugin package materials must be an array.");
4160
+ if (i.length > 0) {
4161
+ let e = mr({
4162
+ id: n,
4163
+ materials: i
4164
+ });
4165
+ if (!e.ok) return e;
4166
+ o = e.value;
4167
+ }
4168
+ }
4169
+ let s = o?.materials ?? Object.freeze([]);
4170
+ return {
4171
+ ok: !0,
4172
+ value: {
4173
+ id: n,
4174
+ plugin: a.value,
4175
+ materials: s,
4176
+ define: () => Rr(a.value, o)
4177
+ },
4178
+ diagnostics: []
4179
+ };
4180
+ }
4181
+ function Rr(e, t) {
4182
+ if (t === void 0) return {
4183
+ ok: !0,
4184
+ value: {
4185
+ runtime: e,
4186
+ materials: Object.freeze([])
4187
+ },
4188
+ diagnostics: []
4189
+ };
4190
+ let n = t.define();
4191
+ return n.ok ? {
4192
+ ok: !0,
4193
+ value: {
4194
+ runtime: e,
4195
+ materials: n.value
4196
+ },
4197
+ diagnostics: []
4198
+ } : n;
4199
+ }
4200
+ function zr(e) {
4201
+ return typeof e == "string" && e.length > 0 && e.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e);
4202
+ }
4203
+ //#endregion
4204
+ export { ee as $, xt as A, Fe as B, U as C, tt as D, N as E, O as F, Re as G, ze as H, $e as I, _e as J, Ce as K, Je as L, Ue as M, Ve as N, P as O, Ye as P, ie as Q, A as R, Zt as S, F as T, Ne as U, Me as V, Le as W, ye as X, he as Y, fe as Z, mn as _, yr as a, H as b, Dn as c, Kn as d, C as et, wn as f, Sn as g, En as h, br as i, E as j, I as k, Vn as l, xn as m, jr as n, vr as o, Cn as p, ve as q, xr as r, mr as s, Lr as t, Bn as u, rn as v, V as w, Qt as x, R as y, Pe as z };
4205
+
4206
+ //# sourceMappingURL=plugin-package-DWifuHi1.js.map