@agile-team/mach-report 2.17.0 → 2.18.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 (168) hide show
  1. package/README.md +18 -9
  2. package/dist/{ExcelBindingWizard-Bq6FYME6.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-Co1svTsw.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
  4. package/dist/ParamEditor-KzDQvbHY.js +732 -0
  5. package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
  6. package/dist/{ReportBatchPanel-uQh06usx.js → ReportBatchPanel-BJK7PvZ4.js} +39 -39
  7. package/dist/ReportBatchPanel-DnmNRssu.cjs +1 -0
  8. package/dist/ReportParamPanel-mQkeN70Q.js +1020 -0
  9. package/dist/ReportParamPanel-sOANVRz-.cjs +1 -0
  10. package/dist/ReportPreview-BxWWTUL5.js +5583 -0
  11. package/dist/ReportPreview-Yf99omi3.cjs +6 -0
  12. package/dist/{ReportTemplateLibrary-TIL_Oj2l.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
  13. package/dist/{ReportTemplateLibrary-CnP7_1pH.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
  14. package/dist/RuleEditor-CqxT1a-W.js +2337 -0
  15. package/dist/RuleEditor-D7YWigD9.cjs +1 -0
  16. package/dist/{TemplateOutlinePanel-BlLxRrfu.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
  17. package/dist/{TemplateOutlinePanel-BouxsuqQ.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
  18. package/dist/{TemplateReusePanel-yxsHSO40.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
  19. package/dist/{TemplateReusePanel-BEACLPaN.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
  20. package/dist/{TemplateReviewPanel-D9Cx0m2N.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
  21. package/dist/{TemplateReviewPanel-B1OGRY2i.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
  22. package/dist/analytics.cjs +1 -1
  23. package/dist/analytics.d.cts +100 -41
  24. package/dist/analytics.d.ts +100 -41
  25. package/dist/analytics.js +76 -141
  26. package/dist/artifact-integrity.json +108 -102
  27. package/dist/assets-2eC3mOcV.js +232 -0
  28. package/dist/assets-B0Hxn4l6.cjs +1 -0
  29. package/dist/{auto-DDHflI9v.cjs → auto-B0EZFIK1.cjs} +1 -1
  30. package/dist/{auto-BIOmtVhk.js → auto-BlchZ1b8.js} +19 -19
  31. package/dist/{batch-WzDIXJAt.js → batch-DGCt44XM.js} +1 -1
  32. package/dist/{batch-z6Aw5GEY.cjs → batch-DYcokH4v.cjs} +1 -1
  33. package/dist/charts-Dlv8j2AG.js +141 -0
  34. package/dist/charts-aCtoswXq.cjs +1 -0
  35. package/dist/codes.cjs +9 -9
  36. package/dist/codes.d.cts +54 -0
  37. package/dist/codes.d.ts +54 -0
  38. package/dist/codes.js +12097 -13668
  39. package/dist/column-visual-BpgQVWwT.js +238 -0
  40. package/dist/column-visual-CtYxnBCP.cjs +1 -0
  41. package/dist/component-tree-6TV7W6Yj.cjs +1 -0
  42. package/dist/component-tree-CvW4lzpv.js +67 -0
  43. package/dist/computed-4TnxzgIh.cjs +1 -0
  44. package/dist/computed-C8NRZQss.js +739 -0
  45. package/dist/data-bar-Ce38juRZ.cjs +1 -0
  46. package/dist/data-bar-PtjXhMgN.js +9 -0
  47. package/dist/designer--TKECSEc.cjs +2 -0
  48. package/dist/designer-d6hJS41w.js +5683 -0
  49. package/dist/designer.cjs +1 -1
  50. package/dist/designer.d.cts +710 -42
  51. package/dist/designer.d.ts +710 -42
  52. package/dist/designer.js +23 -20
  53. package/dist/{encoding-BFMFIc4r.cjs → encoding-B--eZpp1.cjs} +1 -1
  54. package/dist/{encoding-DP_Eaf0A.js → encoding-mctOLocI.js} +2 -2
  55. package/dist/{font-loader-7FWVlykp.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
  56. package/dist/{font-loader-CQZowp0I.js → font-loader-DW8tIaNp.js} +1 -1
  57. package/dist/index-CPh6tqge.js +1575 -0
  58. package/dist/index-CUNw7dL9.cjs +1 -0
  59. package/dist/index.cjs +7 -7
  60. package/dist/index.d.cts +361 -15
  61. package/dist/index.d.ts +361 -15
  62. package/dist/index.js +876 -835
  63. package/dist/json-snapshot-By4ZVVUt.js +1967 -0
  64. package/dist/json-snapshot-jiXff4lc.cjs +2 -0
  65. package/dist/matrix-0hywp0-F.cjs +1 -0
  66. package/dist/matrix-Dy-tyY7E.js +381 -0
  67. package/dist/param-validation-C-8sRJLq.cjs +1 -0
  68. package/dist/param-validation-CnDEd2l-.js +333 -0
  69. package/dist/{pdf-l3ea86di.js → pdf-CKROKygt.js} +1851 -1849
  70. package/dist/{pdf-B8JouyYv.cjs → pdf-DqyxJ96U.cjs} +46 -46
  71. package/dist/pdf.cjs +1 -1
  72. package/dist/pdf.d.cts +54 -0
  73. package/dist/pdf.d.ts +54 -0
  74. package/dist/pdf.js +2 -2
  75. package/dist/{plugin-BBp74CQZ.js → plugin-ByjF2kiV.js} +5 -5
  76. package/dist/{plugin-CtFX9PFG.cjs → plugin-DM1M2wlI.cjs} +1 -1
  77. package/dist/prefill-B8H9qwE4.js +371 -0
  78. package/dist/prefill-D7EswyTI.cjs +1 -0
  79. package/dist/{prepared-CARicKYh.js → prepared-BE-4jfX5.js} +2 -2
  80. package/dist/{prepared-Ch1x_Gog.cjs → prepared-CGVphji3.cjs} +1 -1
  81. package/dist/{protocol-B5A2uom4.cjs → protocol-ByRVzzQG.cjs} +1 -1
  82. package/dist/{protocol-BaiWjq5w.js → protocol-Cr81vFSQ.js} +3 -3
  83. package/dist/{record-bindings-D4TuMzHs.js → record-bindings-DEJtmo3p.js} +67 -107
  84. package/dist/record-bindings-ehjnCDHt.cjs +1 -0
  85. package/dist/{region-binding-workflow-BNasF5kz.js → region-binding-workflow-CBg0l_tj.js} +1 -1
  86. package/dist/{region-binding-workflow-O2Cni3mF.cjs → region-binding-workflow-D05tOYn3.cjs} +1 -1
  87. package/dist/report-encoding-worker.cjs +1 -1
  88. package/dist/report-encoding-worker.js +1 -1
  89. package/dist/{report-params-B1RzkhJj.js → report-params-D9tBuM9B.js} +1 -1
  90. package/dist/{report-params-WDGrA4oP.cjs → report-params-VTg8MoCp.cjs} +1 -1
  91. package/dist/runtime-CDA6d263.cjs +1 -0
  92. package/dist/runtime-CEMvybO7.js +170 -0
  93. package/dist/sbom.cdx.json +1 -1
  94. package/dist/server/node.d.cts +75 -7
  95. package/dist/server/node.d.ts +75 -7
  96. package/dist/server-node.cjs +4 -4
  97. package/dist/server-node.js +2692 -1990
  98. package/dist/server.cjs +1 -1
  99. package/dist/server.d.cts +243 -28
  100. package/dist/server.d.ts +243 -28
  101. package/dist/server.js +28 -28
  102. package/dist/sha256-BDQ1Qk7A.js +158 -0
  103. package/dist/sha256-DgZAKXqI.cjs +1 -0
  104. package/dist/style.css +1 -1
  105. package/dist/template-bindings-Cg5oBLFT.cjs +1 -0
  106. package/dist/template-bindings-TKnXM7ll.js +62 -0
  107. package/dist/{template-catalog-wT1fNeAP.js → template-catalog-CmbWOJqy.js} +16 -16
  108. package/dist/{template-catalog-Dua8h9ZA.cjs → template-catalog-Utu4GP09.cjs} +1 -1
  109. package/dist/{template-fragments-BajTajb4.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
  110. package/dist/{template-fragments-DmX5XK4N.js → template-fragments-DWgo9tlZ.js} +2 -2
  111. package/dist/{template-outline-BwRV_eRo.cjs → template-outline-DWkzZXVC.cjs} +1 -1
  112. package/dist/{template-outline-cnWfT_LK.js → template-outline-DiADphlq.js} +1 -1
  113. package/dist/{template-registry-u11fPd8D.js → template-registry-BIhIHOab.js} +319 -314
  114. package/dist/template-registry-DzWswQI5.cjs +1 -0
  115. package/dist/vue/async.d.cts +528 -33
  116. package/dist/vue/async.d.ts +528 -33
  117. package/dist/vue/index.d.cts +616 -64
  118. package/dist/vue/index.d.ts +616 -64
  119. package/dist/vue-async.cjs +1 -1
  120. package/dist/vue-async.js +3 -3
  121. package/dist/vue.cjs +1 -1
  122. package/dist/vue.js +94 -89
  123. package/dist/{workbook-session-DN5LSA5C.cjs → workbook-session-B94EwVa_.cjs} +1 -1
  124. package/dist/{workbook-session-B8pNW24X.js → workbook-session-BoScoOg-.js} +2 -2
  125. package/dist/worker.cjs +1 -1
  126. package/dist/worker.d.cts +75 -7
  127. package/dist/worker.d.ts +75 -7
  128. package/dist/worker.js +4 -4
  129. package/dist/xlsx.cjs +4 -4
  130. package/dist/xlsx.d.cts +120 -13
  131. package/dist/xlsx.d.ts +120 -13
  132. package/dist/xlsx.js +313 -279
  133. package/package.json +1 -1
  134. package/dist/ParamEditor-B5UZRgxv.cjs +0 -1
  135. package/dist/ParamEditor-DNNARyeB.js +0 -594
  136. package/dist/ReportBatchPanel-Ctvs2t_9.cjs +0 -1
  137. package/dist/ReportPreview-BdQawRh0.js +0 -4879
  138. package/dist/ReportPreview-CJC_-j2I.cjs +0 -6
  139. package/dist/RuleEditor-DkRjOLlr.js +0 -2141
  140. package/dist/RuleEditor-h5anGsDB.cjs +0 -1
  141. package/dist/assets-BIMVwjQe.js +0 -231
  142. package/dist/assets-Dfs2ElxI.cjs +0 -1
  143. package/dist/component-tree-Ca6YYfHq.js +0 -61
  144. package/dist/component-tree-DkGLEfZC.cjs +0 -1
  145. package/dist/computed-BW5a8QFk.js +0 -612
  146. package/dist/computed-C2GD3XcE.cjs +0 -1
  147. package/dist/config-Dg_o8e7m.cjs +0 -1
  148. package/dist/config-XQ4qrQ7Q.js +0 -844
  149. package/dist/designer-D9XAxqSc.js +0 -5178
  150. package/dist/designer-uCDo5XSK.cjs +0 -2
  151. package/dist/drill-ByN8COs_.cjs +0 -1
  152. package/dist/drill-CKW3Xtfa.js +0 -145
  153. package/dist/json-snapshot-D7PE1NsU.cjs +0 -2
  154. package/dist/json-snapshot-DYmEe3sO.js +0 -1779
  155. package/dist/matrix-JLAXlux-.js +0 -302
  156. package/dist/matrix-gTHpDTGm.cjs +0 -1
  157. package/dist/param-validation-C3HlcLLO.cjs +0 -1
  158. package/dist/param-validation-Do7Eg8Zv.js +0 -181
  159. package/dist/record-bindings-B86Sur_y.cjs +0 -1
  160. package/dist/runtime-DakRXui3.js +0 -170
  161. package/dist/runtime-dL5ygIfa.cjs +0 -1
  162. package/dist/sha256-BshdOkCC.cjs +0 -1
  163. package/dist/sha256-DTG-Gq8i.js +0 -157
  164. package/dist/template-bindings-C2SpvsMU.js +0 -58
  165. package/dist/template-bindings-CEtWyiLX.cjs +0 -1
  166. package/dist/template-registry-CpysHAxy.cjs +0 -1
  167. package/dist/tree-CLpxYbKa.cjs +0 -1
  168. package/dist/tree-DNJorJUf.js +0 -172
package/dist/pdf.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./font-loader-7FWVlykp.cjs"),t=require("./pdf-B8JouyYv.cjs");exports.clearFontCache=e.clearFontCache;exports.configureFontCache=e.configureFontCache;exports.getFontCacheStats=e.getFontCacheStats;exports.invalidateFontCache=e.invalidateFontCache;exports.loadFontWithCache=e.loadFontWithCache;exports.createFontBytesMeasurer=t.createFontBytesMeasurer;exports.renderPlanToPdf=t.renderPlanToPdf;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./font-loader-DBBJ5KE9.cjs"),t=require("./pdf-DqyxJ96U.cjs");exports.clearFontCache=e.clearFontCache;exports.configureFontCache=e.configureFontCache;exports.getFontCacheStats=e.getFontCacheStats;exports.invalidateFontCache=e.invalidateFontCache;exports.loadFontWithCache=e.loadFontWithCache;exports.createFontBytesMeasurer=t.createFontBytesMeasurer;exports.renderPlanToPdf=t.renderPlanToPdf;
package/dist/pdf.d.cts CHANGED
@@ -1,3 +1,13 @@
1
+ declare type AggregateOperation = "sum" | "count" | "avg" | "min" | "max" | "weightedAvg";
2
+
3
+ declare interface AggregateRequest {
4
+ op: AggregateOperation;
5
+ field?: string;
6
+ weightField?: string;
7
+ numeric?: "number" | "decimal";
8
+ digits?: number;
9
+ }
10
+
1
11
  declare interface AssetRenderBudget {
2
12
  /** Maximum newly rendered assets, default 1000. Existing imageData is kept unchanged. */
3
13
  maxAssets?: number;
@@ -146,6 +156,12 @@ export declare interface FontLoadOptions {
146
156
  export declare function getFontCacheStats(): FontCacheStats;
147
157
 
148
158
  declare interface GridCell {
159
+ /** Resolved visual only. Original value, text, editability and source are unchanged. */
160
+ dataBar?: {
161
+ start: number;
162
+ end: number;
163
+ color: string;
164
+ };
149
165
  /** Styled cell content; text remains a plain-text fallback. Imported rich cells are read-only. */
150
166
  richParagraphs?: RichParagraph[];
151
167
  text?: string;
@@ -263,6 +279,8 @@ export declare interface PdfRenderResult {
263
279
  }
264
280
 
265
281
  declare interface PlanComponent {
282
+ /** Template-only aggregate binding, expanded into shared primitives during layout. */
283
+ chartBinding?: ReportChartBinding;
266
284
  /** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
267
285
  code?: CodeOptions;
268
286
  /** Template-only binding; resolved and removed before constructing the output plan. */
@@ -351,6 +369,42 @@ declare interface ReportCellSource {
351
369
  sourceToken?: string;
352
370
  }
353
371
 
372
+ /** Serializable binding; data and authorization continue to come from the existing report source. */
373
+ declare interface ReportChartBinding {
374
+ dataset: string;
375
+ categoryField: string;
376
+ measures: readonly ReportChartMeasure[];
377
+ type: ReportChartOptions["type"];
378
+ sort?: "asc" | "desc";
379
+ title?: string;
380
+ showValues?: boolean;
381
+ maxRows?: number;
382
+ maxCategories?: number;
383
+ }
384
+
385
+ declare interface ReportChartMeasure extends AggregateRequest {
386
+ label?: string;
387
+ color?: string;
388
+ }
389
+
390
+ declare interface ReportChartOptions {
391
+ type: "bar" | "line" | "stackedBar" | "percentBar";
392
+ categories: readonly string[];
393
+ series: readonly ReportChartSeries[];
394
+ leftMm: number;
395
+ topMm: number;
396
+ widthMm: number;
397
+ heightMm: number;
398
+ title?: string;
399
+ showValues?: boolean;
400
+ }
401
+
402
+ declare interface ReportChartSeries {
403
+ name: string;
404
+ values: readonly (number | null)[];
405
+ color?: string;
406
+ }
407
+
354
408
  declare interface RichParagraph {
355
409
  segments: RichSegment[];
356
410
  align?: ComponentStyle["align"];
package/dist/pdf.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ declare type AggregateOperation = "sum" | "count" | "avg" | "min" | "max" | "weightedAvg";
2
+
3
+ declare interface AggregateRequest {
4
+ op: AggregateOperation;
5
+ field?: string;
6
+ weightField?: string;
7
+ numeric?: "number" | "decimal";
8
+ digits?: number;
9
+ }
10
+
1
11
  declare interface AssetRenderBudget {
2
12
  /** Maximum newly rendered assets, default 1000. Existing imageData is kept unchanged. */
3
13
  maxAssets?: number;
@@ -146,6 +156,12 @@ export declare interface FontLoadOptions {
146
156
  export declare function getFontCacheStats(): FontCacheStats;
147
157
 
148
158
  declare interface GridCell {
159
+ /** Resolved visual only. Original value, text, editability and source are unchanged. */
160
+ dataBar?: {
161
+ start: number;
162
+ end: number;
163
+ color: string;
164
+ };
149
165
  /** Styled cell content; text remains a plain-text fallback. Imported rich cells are read-only. */
150
166
  richParagraphs?: RichParagraph[];
151
167
  text?: string;
@@ -263,6 +279,8 @@ export declare interface PdfRenderResult {
263
279
  }
264
280
 
265
281
  declare interface PlanComponent {
282
+ /** Template-only aggregate binding, expanded into shared primitives during layout. */
283
+ chartBinding?: ReportChartBinding;
266
284
  /** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
267
285
  code?: CodeOptions;
268
286
  /** Template-only binding; resolved and removed before constructing the output plan. */
@@ -351,6 +369,42 @@ declare interface ReportCellSource {
351
369
  sourceToken?: string;
352
370
  }
353
371
 
372
+ /** Serializable binding; data and authorization continue to come from the existing report source. */
373
+ declare interface ReportChartBinding {
374
+ dataset: string;
375
+ categoryField: string;
376
+ measures: readonly ReportChartMeasure[];
377
+ type: ReportChartOptions["type"];
378
+ sort?: "asc" | "desc";
379
+ title?: string;
380
+ showValues?: boolean;
381
+ maxRows?: number;
382
+ maxCategories?: number;
383
+ }
384
+
385
+ declare interface ReportChartMeasure extends AggregateRequest {
386
+ label?: string;
387
+ color?: string;
388
+ }
389
+
390
+ declare interface ReportChartOptions {
391
+ type: "bar" | "line" | "stackedBar" | "percentBar";
392
+ categories: readonly string[];
393
+ series: readonly ReportChartSeries[];
394
+ leftMm: number;
395
+ topMm: number;
396
+ widthMm: number;
397
+ heightMm: number;
398
+ title?: string;
399
+ showValues?: boolean;
400
+ }
401
+
402
+ declare interface ReportChartSeries {
403
+ name: string;
404
+ values: readonly (number | null)[];
405
+ color?: string;
406
+ }
407
+
354
408
  declare interface RichParagraph {
355
409
  segments: RichSegment[];
356
410
  align?: ComponentStyle["align"];
package/dist/pdf.js CHANGED
@@ -1,5 +1,5 @@
1
- import { clearFontCache as t, configureFontCache as o, getFontCacheStats as r, invalidateFontCache as n, loadFontWithCache as c } from "./font-loader-CQZowp0I.js";
2
- import { c as F, r as s } from "./pdf-l3ea86di.js";
1
+ import { clearFontCache as t, configureFontCache as o, getFontCacheStats as r, invalidateFontCache as n, loadFontWithCache as c } from "./font-loader-DW8tIaNp.js";
2
+ import { c as F, r as s } from "./pdf-CKROKygt.js";
3
3
  export {
4
4
  t as clearFontCache,
5
5
  o as configureFontCache,
@@ -1,15 +1,15 @@
1
1
  import { defineAsyncComponent as c, computed as m } from "vue";
2
- import { b as i, c as l, a as s } from "./injection-keys-e85udZCp.js";
3
- import { g as d } from "./report-params-B1RzkhJj.js";
4
- const p = c(() => import("./ReportPreview-BdQawRh0.js").then((r) => r.s)), _ = {
2
+ import { b as i, c as l, a as d } from "./injection-keys-e85udZCp.js";
3
+ import { g as s } from "./report-params-D9tBuM9B.js";
4
+ const p = c(() => import("./ReportPreview-BxWWTUL5.js").then((r) => r.v)), _ = {
5
5
  install(r, e = {}) {
6
6
  let t = e.fetcher;
7
7
  if (!t && e.reports) {
8
8
  const f = e.reports;
9
9
  let n;
10
- t = async (o) => (n ??= import("@agile-team/mach-report").then(({ createReportSource: a }) => a(f)), (await n)(o)), t.getParamDefs = (o) => d(f, o);
10
+ t = async (o) => (n ??= import("@agile-team/mach-report").then(({ createReportSource: a }) => a(f)), (await n)(o)), t.getParamDefs = (o) => s(f, o);
11
11
  }
12
- t && r.provide(i, t), e.pdfExporter && r.provide(l, e.pdfExporter), r.provide(s, m(() => {
12
+ t && r.provide(i, t), e.pdfExporter && r.provide(l, e.pdfExporter), r.provide(d, m(() => {
13
13
  if (e.pdfFontUrl === void 0) return e.config ?? null;
14
14
  const f = e.config ?? { defaults: {}, presets: {} };
15
15
  return { ...f, defaults: { ...f.defaults, pdfFontUrl: e.pdfFontUrl } };
@@ -1 +1 @@
1
- "use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-WDGrA4oP.cjs"),s=l.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-CJC_-j2I.cjs")).then(r=>r.ReportPreview$1)),v={install(r,e={}){let t=e.fetcher;if(!t&&e.reports){const n=e.reports;let o;t=async c=>(o??=import("@agile-team/mach-report").then(({createReportSource:a})=>a(n)),(await o)(c)),t.getParamDefs=c=>h.getReportParamDefs(n,c)}t&&r.provide(i.MACH_REPORT_FETCHER_KEY,t),e.pdfExporter&&r.provide(i.MACH_REPORT_PDF_EXPORTER_KEY,e.pdfExporter),r.provide(i.MACH_REPORT_CONFIG_KEY,l.computed(()=>{if(e.pdfFontUrl===void 0)return e.config??null;const n=e.config??{defaults:{},presets:{}};return{...n,defaults:{...n.defaults,pdfFontUrl:e.pdfFontUrl}}})),e.globalComponent!==!1&&!r.component("MachReportPreview")&&r.component("MachReportPreview",s)}};exports.MachReportPreview=s;exports.machReportPlugin=v;
1
+ "use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-VTg8MoCp.cjs"),s=l.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-Yf99omi3.cjs")).then(r=>r.ReportPreview$1)),v={install(r,e={}){let t=e.fetcher;if(!t&&e.reports){const n=e.reports;let o;t=async c=>(o??=import("@agile-team/mach-report").then(({createReportSource:a})=>a(n)),(await o)(c)),t.getParamDefs=c=>h.getReportParamDefs(n,c)}t&&r.provide(i.MACH_REPORT_FETCHER_KEY,t),e.pdfExporter&&r.provide(i.MACH_REPORT_PDF_EXPORTER_KEY,e.pdfExporter),r.provide(i.MACH_REPORT_CONFIG_KEY,l.computed(()=>{if(e.pdfFontUrl===void 0)return e.config??null;const n=e.config??{defaults:{},presets:{}};return{...n,defaults:{...n.defaults,pdfFontUrl:e.pdfFontUrl}}})),e.globalComponent!==!1&&!r.component("MachReportPreview")&&r.component("MachReportPreview",s)}};exports.MachReportPreview=s;exports.machReportPlugin=v;
@@ -0,0 +1,371 @@
1
+ import { v as q, G as O, n as V, N as Z, O as T } from "./json-snapshot-By4ZVVUt.js";
2
+ import { r as B } from "./grid-geometry-BNptEcMm.js";
3
+ import { d as $, p as S, a as H, j as P, g as J } from "./computed-C8NRZQss.js";
4
+ function I(e) {
5
+ return Number.isFinite(e) ? Math.max(0, e) : 0;
6
+ }
7
+ function ce(e, t = 0) {
8
+ const r = e.length, o = I(t), n = new Array(r + 1);
9
+ n[0] = 0;
10
+ for (let i = 0; i < r; i++)
11
+ n[i + 1] = n[i] + I(e[i] ?? 0) + o;
12
+ const a = n[r];
13
+ function s(i) {
14
+ let c = 0, u = r - 1, p = 0;
15
+ for (; c <= u; ) {
16
+ const f = c + u >>> 1;
17
+ n[f] <= i ? (p = f, c = f + 1) : u = f - 1;
18
+ }
19
+ return p;
20
+ }
21
+ function l(i, c, u = 1) {
22
+ if (r === 0) return { start: 0, end: -1, padTopPx: 0, padBottomPx: 0 };
23
+ const p = Math.floor(I(u)), f = I(c), g = s(f), m = Math.max(0, g - p), b = f + I(i);
24
+ let w = g, x = r - 1, F = r - 1;
25
+ for (; w <= x; ) {
26
+ const R = w + x >>> 1;
27
+ n[R + 1] < b ? w = R + 1 : (F = R, x = R - 1);
28
+ }
29
+ const C = Math.min(r - 1, F + p);
30
+ return {
31
+ start: m,
32
+ end: C,
33
+ padTopPx: n[m],
34
+ padBottomPx: Math.max(0, a - n[C + 1])
35
+ };
36
+ }
37
+ return {
38
+ totalHeightPx: a,
39
+ pageAt: s,
40
+ offsetAt: (i) => n[Math.max(0, Math.min(r, Math.floor(i)))] ?? 0,
41
+ window: l
42
+ };
43
+ }
44
+ class h extends Error {
45
+ constructor(t) {
46
+ super(`Report drill: ${t}`), this.code = t, this.name = "ReportDrillError";
47
+ }
48
+ }
49
+ function v(e) {
50
+ return typeof e == "string" && e.trim().length > 0 && e.length <= 256;
51
+ }
52
+ function G(e) {
53
+ if (typeof e == "number" && Number.isFinite(e) || typeof e == "boolean") return String(e);
54
+ if (typeof e == "string" && e.length > 0 && e.length <= 4096) return e;
55
+ throw new h("missing-value");
56
+ }
57
+ function Q(e, t) {
58
+ return Object.getOwnPropertyDescriptor(e, t)?.value;
59
+ }
60
+ function L(e) {
61
+ if (!Array.isArray(e) || e.length > 64) throw new h("config");
62
+ const t = /* @__PURE__ */ new Set();
63
+ for (const r of e) {
64
+ if (!r || !v(r.id) || !v(r.label) || !r.target || !v(r.target.field) || t.has(r.id)) throw new h("config");
65
+ t.add(r.id);
66
+ const o = r.target;
67
+ if (o.datasetId !== void 0 && !v(o.datasetId) || o.reportScope !== void 0 && !v(o.reportScope)) throw new h("config");
68
+ if (o.roles !== void 0 && (!Array.isArray(o.roles) || o.roles.length > 16 || o.roles.some((n) => !v(n)))) throw new h("config");
69
+ X(r.params);
70
+ }
71
+ }
72
+ function X(e) {
73
+ if (e !== void 0) {
74
+ if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length > 32) throw new h("config");
75
+ for (const [t, r] of Object.entries(e)) {
76
+ if (!v(t) || ["__proto__", "constructor", "prototype"].includes(t) || !r || typeof r != "object") throw new h("config");
77
+ if ("value" in r)
78
+ try {
79
+ G(r.value);
80
+ } catch {
81
+ throw new h("config");
82
+ }
83
+ else if (!["value", "rowKey", "query", "field"].includes(r.from) || (r.from === "query" || r.from === "field") && !v(r.field)) throw new h("config");
84
+ }
85
+ }
86
+ }
87
+ function U(e, t, r) {
88
+ const { target: o } = r, n = t.source?.datasetId ?? t.component.table?.source?.datasetId;
89
+ return (t.source?.field ?? t.table?.columnKey) === o.field && (o.datasetId === void 0 || n === o.datasetId) && (o.reportScope === void 0 || e.pages[t.address.pageIndex]?.meta?.reportScope === o.reportScope) && (o.roles ? o.roles.includes(t.table?.role ?? "") : t.table?.role !== "header");
90
+ }
91
+ function le(e, t, r) {
92
+ L(r);
93
+ const o = q(e, t);
94
+ return o ? r.filter((n) => U(e, o, n)) : [];
95
+ }
96
+ function Y(e, t, r, o) {
97
+ if ("value" in e) return e.value;
98
+ switch (e.from) {
99
+ case "value":
100
+ return r.value;
101
+ case "rowKey":
102
+ return r.source?.rowKey;
103
+ case "query":
104
+ return Q(o, e.field);
105
+ case "field": {
106
+ const n = r.component.table?.columnKeys.indexOf(e.field) ?? -1;
107
+ return n < 0 ? void 0 : q(t, { ...r.address, columnIndex: n })?.value;
108
+ }
109
+ }
110
+ }
111
+ function de(e, t, r, o = {}) {
112
+ L([r]);
113
+ const n = q(e, t);
114
+ if (!n || !U(e, n, r)) throw new h("target");
115
+ const a = Object.fromEntries(Object.entries(r.params ?? {}).map(([i, c]) => [i, G(Y(c, e, n, o))])), s = Object.entries(o);
116
+ if (s.length > 128 || s.some(([i, c]) => !v(i) || typeof c != "string" || c.length > 4096)) throw new h("config");
117
+ const l = e.pages[t.pageIndex]?.meta?.reportScope;
118
+ return Object.freeze({ actionId: r.id, params: Object.freeze(a), returnState: Object.freeze({
119
+ params: Object.freeze(Object.fromEntries(s)),
120
+ address: Object.freeze({ ...t }),
121
+ ...typeof l == "string" ? { reportScope: l } : {},
122
+ ...n.source ? { source: Object.freeze({ sourceScope: n.source.sourceScope, datasetId: n.source.datasetId, rowKey: n.source.rowKey, field: n.source.field }) } : {}
123
+ }) });
124
+ }
125
+ function ue(e, t) {
126
+ if (!t.source) return e.pages[t.address.pageIndex]?.meta?.reportScope === t.reportScope && q(e, t.address) ? { ...t.address } : null;
127
+ const r = V(e), o = O({ address: t.address, source: t.source });
128
+ for (const [n, a] of e.pages.entries())
129
+ if (!(t.reportScope !== void 0 && a.meta?.reportScope !== t.reportScope)) {
130
+ for (const [s, l] of a.components.entries())
131
+ if (l.grid)
132
+ for (const i of B(l.grid, l.widthMm, l.heightMm).cells) {
133
+ const c = { pageIndex: n, componentIndex: s, rowIndex: i.ri, columnIndex: i.ci }, u = r(c);
134
+ if (u?.source && O(u) === o) return c;
135
+ }
136
+ }
137
+ return null;
138
+ }
139
+ class d extends Error {
140
+ constructor(t, r) {
141
+ super(r), this.code = t, this.name = "ReportDataError";
142
+ }
143
+ }
144
+ function y(e, t, r) {
145
+ const o = e ?? t;
146
+ if (!Number.isSafeInteger(o) || o < 1 || o > r) throw new d("limit", "Invalid report data budget");
147
+ return o;
148
+ }
149
+ function z(e) {
150
+ if (typeof e == "string" && e.length > 0 && e.length <= 2048) return `s:${e}`;
151
+ if (typeof e == "number" && Number.isSafeInteger(e)) return `n:${Object.is(e, -0) ? 0 : e}`;
152
+ throw new d("identity", "A stable string or safe integer business key is required");
153
+ }
154
+ function D(e) {
155
+ if (typeof e.datasetId != "string" || !e.datasetId.trim() || e.datasetId.length > 2048) throw new d("identity", "A dataset identity is required");
156
+ if (e.sourceScope !== void 0 && (typeof e.sourceScope != "string" || !e.sourceScope.trim() || e.sourceScope.length > 2048)) throw new d("identity", "Invalid source scope");
157
+ }
158
+ function j(e, t = 256) {
159
+ if (!Array.isArray(e) || !e.length || e.length > t) throw new d("limit", "A bounded explicit field allowlist is required");
160
+ const r = /* @__PURE__ */ new Set();
161
+ for (const o of e) {
162
+ if (typeof o != "string" || !o.trim() || o.length > 2048 || ["__proto__", "constructor", "prototype"].includes(o)) throw new d("identity", "Invalid report field");
163
+ if (r.has(o)) throw new d("duplicate", "Duplicate report field");
164
+ r.add(o);
165
+ }
166
+ }
167
+ function K(e, t) {
168
+ const r = Object.getOwnPropertyDescriptor(e.values, t);
169
+ if (!r) return;
170
+ if (!("value" in r)) throw new d("value", "Report values must be plain scalar data");
171
+ const o = r.value;
172
+ if (o === null || typeof o == "boolean" || typeof o == "string" || typeof o == "number" && Number.isFinite(o)) return o;
173
+ throw new d("value", "Report values must be finite scalar data");
174
+ }
175
+ function ee(e) {
176
+ if (!e || typeof e != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(e))) throw new d("value", "Report records must be plain data");
177
+ const t = Object.getOwnPropertyDescriptor(e, "rowKey"), r = Object.getOwnPropertyDescriptor(e, "values");
178
+ if (!t || !("value" in t) || !r || !("value" in r) || !r.value || typeof r.value != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(r.value))) throw new d("value", "Report records require own scalar keys and plain values");
179
+ return { rowKey: t.value, values: r.value };
180
+ }
181
+ function A(e, t, r = {}) {
182
+ const o = y(r.maxRows, 5e4, 1e5), n = y(r.maxCells, 1e6, 2e6);
183
+ if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length > o || e.length * t.length > n) throw new d("limit", "Report data exceeds its budget");
184
+ const a = /* @__PURE__ */ new Map();
185
+ for (let s = 0; s < e.length; s++) {
186
+ const l = Object.getOwnPropertyDescriptor(e, s);
187
+ if (!l || !("value" in l)) throw new d("value", "Sparse or accessor report records are unsupported");
188
+ const i = ee(l.value), c = z(i.rowKey);
189
+ if (a.has(c)) throw new d("duplicate", "Duplicate business row key");
190
+ const u = /* @__PURE__ */ Object.create(null);
191
+ for (const p of t) {
192
+ const f = K(i, p);
193
+ f !== void 0 && (u[p] = f);
194
+ }
195
+ a.set(c, { rowKey: i.rowKey, values: u });
196
+ }
197
+ return a;
198
+ }
199
+ function k(e) {
200
+ return e == null || e === "";
201
+ }
202
+ function E(e, t) {
203
+ return k(e) ? t.missing === "zero" ? S(0) : void 0 : S(e);
204
+ }
205
+ function te(e) {
206
+ return { coefficient: -e.coefficient, scale: e.scale };
207
+ }
208
+ function re(e, t, r, o) {
209
+ const n = E(e, r), a = Object.is(e, t) ? n : E(t, r);
210
+ if (!n || !a) return { equal: W(e, t, r), ratioUnavailable: "missing" };
211
+ const s = H(a, te(n)), l = { ...s, coefficient: s.coefficient < 0n ? -s.coefficient : s.coefficient }, i = $(l, r.toleranceValue) <= 0;
212
+ return i && !o ? { equal: i } : n.coefficient === 0n ? { equal: i, delta: P(s), ...s.coefficient === 0n && r.zeroDenominator === "zero-if-equal" ? { changeRatio: "0" } : { ratioUnavailable: "zero-denominator" } } : { equal: i, delta: P(s), changeRatio: P(J(s, n, r.ratioDigits ?? 12)) };
213
+ }
214
+ function W(e, t, r) {
215
+ return r.missing === "empty-equivalent" && k(e) && k(t) || Object.is(e, t);
216
+ }
217
+ function oe(e) {
218
+ j(e.fields.map((t) => t.field), y(e.maxFields, 256, 1024));
219
+ for (const t of e.fields) {
220
+ if (t.type !== void 0 && !["decimal", "value"].includes(t.type)) throw new d("value", "Invalid comparison field type");
221
+ if (t.missing && !["distinct", "empty-equivalent", "zero"].includes(t.missing)) throw new d("value", "Invalid missing-value policy");
222
+ if (t.zeroDenominator && !["omit", "zero-if-equal"].includes(t.zeroDenominator)) throw new d("value", "Invalid zero-denominator policy");
223
+ if (t.missing === "zero" && t.type !== "decimal") throw new d("value", "Zero missing-value policy requires a decimal field");
224
+ if (t.tolerance !== void 0 && (t.type !== "decimal" || $(S(t.tolerance), S(0)) < 0)) throw new d("value", "Tolerance requires a non-negative decimal");
225
+ if (t.ratioDigits !== void 0 && (!Number.isInteger(t.ratioDigits) || t.ratioDigits < 0 || t.ratioDigits > 100)) throw new d("value", "Invalid ratio precision");
226
+ }
227
+ return e.fields.map((t) => ({ ...t, toleranceValue: S(t.tolerance ?? "0") }));
228
+ }
229
+ function _(e, t, r, o, n) {
230
+ let a = !1;
231
+ for (const s of r) {
232
+ const l = e ? K(e, s.field) : void 0, i = t ? K(t, s.field) : void 0, c = s.type === "decimal" ? re(l, i, s, !e || !t) : { equal: W(l, i, s) };
233
+ if (e && t && c.equal) continue;
234
+ if (a = !0, o.length >= n) throw new d("limit", "Report differences exceed their budget");
235
+ const { equal: u, ...p } = c;
236
+ o.push({ rowKey: (t ?? e).rowKey, kind: e ? t ? "changed" : "removed" : "added", field: s.field, label: s.label ?? s.field, before: l, after: i, ...p });
237
+ }
238
+ return a;
239
+ }
240
+ function fe(e, t, r) {
241
+ D(e), D(t);
242
+ const o = oe(r);
243
+ if (e.datasetId !== t.datasetId || e.sourceScope !== t.sourceScope) throw new d("identity", "Comparison requires the same business dataset and source scope");
244
+ const n = r.fields.map((u) => u.field), a = A(e.rows, n, r), s = A(t.rows, n, r), l = y(r.maxDifferences, 2e4, 1e5), i = [], c = { added: 0, removed: 0, changed: 0, unchanged: 0, cells: 0 };
245
+ for (const [u, p] of a) {
246
+ const f = s.get(u), g = _(p, f, o, i, l);
247
+ f ? g ? c.changed++ : c.unchanged++ : c.removed++;
248
+ }
249
+ for (const [u, p] of s) a.has(u) || (_(void 0, p, o, i, l), c.added++);
250
+ return c.cells = i.length, { sourceScope: t.sourceScope, datasetId: t.datasetId, differences: i, counts: c };
251
+ }
252
+ function M(e, t) {
253
+ D(t), j(t.fields, y(t.maxFields, 256, 1024));
254
+ const r = y(t.maxCells, 1e6, 2e6), o = new Set(t.fields), n = /* @__PURE__ */ new Map(), a = V(e);
255
+ let s = 0;
256
+ for (const [l, i] of e.pages.entries()) for (const [c, u] of i.components.entries()) {
257
+ if (!u.grid) continue;
258
+ for (const f of u.grid.cells)
259
+ if (s += f.length, s > r) throw new d("limit", "Report cell scan exceeds its budget");
260
+ const p = B(u.grid, u.widthMm, u.heightMm).cells;
261
+ for (const f of p) {
262
+ const g = a({ pageIndex: l, componentIndex: c, rowIndex: f.ri, columnIndex: f.ci }), m = g?.source;
263
+ if (!g || !m || m.datasetId !== t.datasetId || m.sourceScope !== t.sourceScope || !o.has(m.field)) continue;
264
+ z(m.rowKey);
265
+ const b = O(g), w = n.get(b);
266
+ w ? (!Object.is(w.context.value, g.value) || w.context.source?.revision !== m.revision || w.context.source?.sourceToken !== m.sourceToken || w.context.editable !== g.editable) && (w.ambiguous = !0) : n.set(b, { context: g, ambiguous: !1 });
267
+ }
268
+ }
269
+ return n;
270
+ }
271
+ function pe(e, t) {
272
+ const r = M(e, t), o = /* @__PURE__ */ new Map(), n = y(t.maxRows, 5e4, 1e5);
273
+ for (const { context: a, ambiguous: s } of r.values()) {
274
+ if (s) throw new d("conflict", "Repeated report cells disagree for the same business field");
275
+ const l = a.source, i = z(l.rowKey);
276
+ let c = o.get(i);
277
+ if (!c) {
278
+ if (o.size >= n) throw new d("limit", "Report row extraction exceeds its budget");
279
+ c = { rowKey: l.rowKey, values: /* @__PURE__ */ Object.create(null) }, o.set(i, c);
280
+ }
281
+ c.values[l.field] = a.value;
282
+ }
283
+ return { sourceScope: t.sourceScope, datasetId: t.datasetId, rows: [...o.values()] };
284
+ }
285
+ function N(e) {
286
+ return e == null || e === "";
287
+ }
288
+ function ne(e, t, r) {
289
+ if (!t) {
290
+ e.reason = "missing-target";
291
+ return;
292
+ }
293
+ const { context: o, ambiguous: n } = t;
294
+ if (e.before = o.value, n) {
295
+ e.status = "conflict", e.reason = "ambiguous";
296
+ return;
297
+ }
298
+ if (!o.editable || r.canEdit?.(o) === !1) {
299
+ e.reason = "readonly";
300
+ return;
301
+ }
302
+ if (N(e.after)) {
303
+ e.reason = "missing-source";
304
+ return;
305
+ }
306
+ if (Object.is(o.value, e.after)) {
307
+ e.status = "matched", e.reason = "unchanged";
308
+ return;
309
+ }
310
+ if (r.mode !== "replace" && !N(o.value)) {
311
+ e.reason = "occupied";
312
+ return;
313
+ }
314
+ try {
315
+ const a = T(o, e.after);
316
+ if (Object.is(a.value, a.previousValue)) {
317
+ e.status = "matched", e.reason = "unchanged";
318
+ return;
319
+ }
320
+ return e.after = a.value, e.status = "changed", a;
321
+ } catch {
322
+ e.status = "conflict", e.reason = "invalid";
323
+ return;
324
+ }
325
+ }
326
+ function ge(e, t) {
327
+ if (D(t), t.mode !== void 0 && t.mode !== "empty" && t.mode !== "replace") throw new d("value", "Invalid prefill policy");
328
+ const r = y(t.maxFields, 256, 1024), o = t.fields.map((f) => f.field), n = [...new Set(t.fields.map((f) => f.sourceField ?? f.field))];
329
+ j(o, r), j(n, r);
330
+ const a = A(t.rows, n, t), s = M(e, { ...t, fields: o }), l = y(t.maxChanges, 1e4, 1e4), i = y(t.maxCells, 1e6, 2e6);
331
+ if (a.size * o.length > i) throw new d("limit", "Prefill review exceeds its budget");
332
+ const c = [], u = [], p = { matched: 0, changed: 0, skipped: 0, conflict: 0 };
333
+ for (const f of a.values()) for (const g of t.fields) {
334
+ const m = { sourceScope: t.sourceScope, datasetId: t.datasetId, rowKey: f.rowKey, field: g.field }, b = { source: m, label: g.label ?? g.field, status: "skipped", after: K(f, g.sourceField ?? g.field) }, w = O({ address: { pageIndex: 0, componentIndex: 0, rowIndex: 0, columnIndex: 0 }, source: m }), x = ne(b, s.get(w), t);
335
+ if (x) {
336
+ if (u.length >= l) throw new d("limit", "Prefill changes exceed the atomic edit budget");
337
+ u.push(x);
338
+ }
339
+ p[b.status]++, c.push(b);
340
+ }
341
+ return { sourceScope: t.sourceScope, datasetId: t.datasetId, items: c, counts: p, edits: u };
342
+ }
343
+ function me(e, t, r) {
344
+ if (t.counts.conflict > 0) throw new d("conflict", "Resolve prefill conflicts before applying");
345
+ if (t.edits.length > 1e4) throw new d("limit", "Prefill changes exceed the atomic edit budget");
346
+ if (!t.edits.length) return [];
347
+ const o = [...new Set(t.edits.map((s) => s.source.field))], n = M(e, { sourceScope: t.sourceScope, datasetId: t.datasetId, fields: o }), a = /* @__PURE__ */ new Set();
348
+ return t.edits.map((s) => {
349
+ if (!s.source || s.source.datasetId !== t.datasetId || s.source.sourceScope !== t.sourceScope) throw new d("identity", "Prefill identity changed");
350
+ const l = O(s), i = n.get(l);
351
+ if (a.has(l)) throw new d("duplicate", "Duplicate prefill target");
352
+ if (a.add(l), !i || i.ambiguous || Z(i.context, s) || !Object.is(i.context.value, s.previousValue)) throw new d("conflict", "Prefill target changed; reload the preview");
353
+ if (!i.context.editable || r?.(i.context) === !1) throw new d("conflict", "Prefill target is read-only");
354
+ return { address: { ...i.context.address }, value: T(i.context, s.value).value };
355
+ });
356
+ }
357
+ export {
358
+ d as R,
359
+ h as a,
360
+ fe as b,
361
+ ce as c,
362
+ de as d,
363
+ ge as e,
364
+ me as f,
365
+ ue as g,
366
+ y as h,
367
+ M as i,
368
+ le as m,
369
+ pe as r,
370
+ L as v
371
+ };
@@ -0,0 +1 @@
1
+ "use strict";const g=require("./json-snapshot-jiXff4lc.cjs"),N=require("./grid-geometry-CZ_cYB6O.cjs"),y=require("./computed-4TnxzgIh.cjs");function R(e){return Number.isFinite(e)?Math.max(0,e):0}function B(e,t=0){const r=e.length,o=R(t),n=new Array(r+1);n[0]=0;for(let i=0;i<r;i++)n[i+1]=n[i]+R(e[i]??0)+o;const c=n[r];function s(i){let a=0,u=r-1,p=0;for(;a<=u;){const f=a+u>>>1;n[f]<=i?(p=f,a=f+1):u=f-1}return p}function d(i,a,u=1){if(r===0)return{start:0,end:-1,padTopPx:0,padBottomPx:0};const p=Math.floor(R(u)),f=R(a),m=s(f),w=Math.max(0,m-p),I=f+R(i);let h=m,D=r-1,z=r-1;for(;h<=D;){const S=h+D>>>1;n[S+1]<I?h=S+1:(z=S,D=S-1)}const E=Math.min(r-1,z+p);return{start:w,end:E,padTopPx:n[w],padBottomPx:Math.max(0,c-n[E+1])}}return{totalHeightPx:c,pageAt:s,offsetAt:i=>n[Math.max(0,Math.min(r,Math.floor(i)))]??0,window:d}}class v extends Error{constructor(t){super(`Report drill: ${t}`),this.code=t,this.name="ReportDrillError"}}function x(e){return typeof e=="string"&&e.trim().length>0&&e.length<=256}function V(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean")return String(e);if(typeof e=="string"&&e.length>0&&e.length<=4096)return e;throw new v("missing-value")}function G(e,t){return Object.getOwnPropertyDescriptor(e,t)?.value}function A(e){if(!Array.isArray(e)||e.length>64)throw new v("config");const t=new Set;for(const r of e){if(!r||!x(r.id)||!x(r.label)||!r.target||!x(r.target.field)||t.has(r.id))throw new v("config");t.add(r.id);const o=r.target;if(o.datasetId!==void 0&&!x(o.datasetId)||o.reportScope!==void 0&&!x(o.reportScope))throw new v("config");if(o.roles!==void 0&&(!Array.isArray(o.roles)||o.roles.length>16||o.roles.some(n=>!x(n))))throw new v("config");$(r.params)}}function $(e){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).length>32)throw new v("config");for(const[t,r]of Object.entries(e)){if(!x(t)||["__proto__","constructor","prototype"].includes(t)||!r||typeof r!="object")throw new v("config");if("value"in r)try{V(r.value)}catch{throw new v("config")}else if(!["value","rowKey","query","field"].includes(r.from)||(r.from==="query"||r.from==="field")&&!x(r.field))throw new v("config")}}}function T(e,t,r){const{target:o}=r,n=t.source?.datasetId??t.component.table?.source?.datasetId;return(t.source?.field??t.table?.columnKey)===o.field&&(o.datasetId===void 0||n===o.datasetId)&&(o.reportScope===void 0||e.pages[t.address.pageIndex]?.meta?.reportScope===o.reportScope)&&(o.roles?o.roles.includes(t.table?.role??""):t.table?.role!=="header")}function U(e,t,r){A(r);const o=g.getReportCellContext(e,t);return o?r.filter(n=>T(e,o,n)):[]}function W(e,t,r,o){if("value"in e)return e.value;switch(e.from){case"value":return r.value;case"rowKey":return r.source?.rowKey;case"query":return G(o,e.field);case"field":{const n=r.component.table?.columnKeys.indexOf(e.field)??-1;return n<0?void 0:g.getReportCellContext(t,{...r.address,columnIndex:n})?.value}}}function Z(e,t,r,o={}){A([r]);const n=g.getReportCellContext(e,t);if(!n||!T(e,n,r))throw new v("target");const c=Object.fromEntries(Object.entries(r.params??{}).map(([i,a])=>[i,V(W(a,e,n,o))])),s=Object.entries(o);if(s.length>128||s.some(([i,a])=>!x(i)||typeof a!="string"||a.length>4096))throw new v("config");const d=e.pages[t.pageIndex]?.meta?.reportScope;return Object.freeze({actionId:r.id,params:Object.freeze(c),returnState:Object.freeze({params:Object.freeze(Object.fromEntries(s)),address:Object.freeze({...t}),...typeof d=="string"?{reportScope:d}:{},...n.source?{source:Object.freeze({sourceScope:n.source.sourceScope,datasetId:n.source.datasetId,rowKey:n.source.rowKey,field:n.source.field})}:{}})})}function H(e,t){if(!t.source)return e.pages[t.address.pageIndex]?.meta?.reportScope===t.reportScope&&g.getReportCellContext(e,t.address)?{...t.address}:null;const r=g.createReportCellResolver(e),o=g.reportCellEditKey({address:t.address,source:t.source});for(const[n,c]of e.pages.entries())if(!(t.reportScope!==void 0&&c.meta?.reportScope!==t.reportScope)){for(const[s,d]of c.components.entries())if(d.grid)for(const i of N.resolveGridLayout(d.grid,d.widthMm,d.heightMm).cells){const a={pageIndex:n,componentIndex:s,rowIndex:i.ri,columnIndex:i.ci},u=r(a);if(u?.source&&g.reportCellEditKey(u)===o)return a}}return null}class l extends Error{constructor(t,r){super(r),this.code=t,this.name="ReportDataError"}}function b(e,t,r){const o=e??t;if(!Number.isSafeInteger(o)||o<1||o>r)throw new l("limit","Invalid report data budget");return o}function k(e){if(typeof e=="string"&&e.length>0&&e.length<=2048)return`s:${e}`;if(typeof e=="number"&&Number.isSafeInteger(e))return`n:${Object.is(e,-0)?0:e}`;throw new l("identity","A stable string or safe integer business key is required")}function O(e){if(typeof e.datasetId!="string"||!e.datasetId.trim()||e.datasetId.length>2048)throw new l("identity","A dataset identity is required");if(e.sourceScope!==void 0&&(typeof e.sourceScope!="string"||!e.sourceScope.trim()||e.sourceScope.length>2048))throw new l("identity","Invalid source scope")}function j(e,t=256){if(!Array.isArray(e)||!e.length||e.length>t)throw new l("limit","A bounded explicit field allowlist is required");const r=new Set;for(const o of e){if(typeof o!="string"||!o.trim()||o.length>2048||["__proto__","constructor","prototype"].includes(o))throw new l("identity","Invalid report field");if(r.has(o))throw new l("duplicate","Duplicate report field");r.add(o)}}function C(e,t){const r=Object.getOwnPropertyDescriptor(e.values,t);if(!r)return;if(!("value"in r))throw new l("value","Report values must be plain scalar data");const o=r.value;if(o===null||typeof o=="boolean"||typeof o=="string"||typeof o=="number"&&Number.isFinite(o))return o;throw new l("value","Report values must be finite scalar data")}function J(e){if(!e||typeof e!="object"||![Object.prototype,null].includes(Object.getPrototypeOf(e)))throw new l("value","Report records must be plain data");const t=Object.getOwnPropertyDescriptor(e,"rowKey"),r=Object.getOwnPropertyDescriptor(e,"values");if(!t||!("value"in t)||!r||!("value"in r)||!r.value||typeof r.value!="object"||![Object.prototype,null].includes(Object.getPrototypeOf(r.value)))throw new l("value","Report records require own scalar keys and plain values");return{rowKey:t.value,values:r.value}}function q(e,t,r={}){const o=b(r.maxRows,5e4,1e5),n=b(r.maxCells,1e6,2e6);if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype||e.length>o||e.length*t.length>n)throw new l("limit","Report data exceeds its budget");const c=new Map;for(let s=0;s<e.length;s++){const d=Object.getOwnPropertyDescriptor(e,s);if(!d||!("value"in d))throw new l("value","Sparse or accessor report records are unsupported");const i=J(d.value),a=k(i.rowKey);if(c.has(a))throw new l("duplicate","Duplicate business row key");const u=Object.create(null);for(const p of t){const f=C(i,p);f!==void 0&&(u[p]=f)}c.set(a,{rowKey:i.rowKey,values:u})}return c}function P(e){return e==null||e===""}function F(e,t){return P(e)?t.missing==="zero"?y.parseDecimal(0):void 0:y.parseDecimal(e)}function Q(e){return{coefficient:-e.coefficient,scale:e.scale}}function X(e,t,r,o){const n=F(e,r),c=Object.is(e,t)?n:F(t,r);if(!n||!c)return{equal:L(e,t,r),ratioUnavailable:"missing"};const s=y.addDecimal(c,Q(n)),d={...s,coefficient:s.coefficient<0n?-s.coefficient:s.coefficient},i=y.compareDecimal(d,r.toleranceValue)<=0;return i&&!o?{equal:i}:n.coefficient===0n?{equal:i,delta:y.printDecimal(s),...s.coefficient===0n&&r.zeroDenominator==="zero-if-equal"?{changeRatio:"0"}:{ratioUnavailable:"zero-denominator"}}:{equal:i,delta:y.printDecimal(s),changeRatio:y.printDecimal(y.divideDecimal(s,n,r.ratioDigits??12))}}function L(e,t,r){return r.missing==="empty-equivalent"&&P(e)&&P(t)||Object.is(e,t)}function Y(e){j(e.fields.map(t=>t.field),b(e.maxFields,256,1024));for(const t of e.fields){if(t.type!==void 0&&!["decimal","value"].includes(t.type))throw new l("value","Invalid comparison field type");if(t.missing&&!["distinct","empty-equivalent","zero"].includes(t.missing))throw new l("value","Invalid missing-value policy");if(t.zeroDenominator&&!["omit","zero-if-equal"].includes(t.zeroDenominator))throw new l("value","Invalid zero-denominator policy");if(t.missing==="zero"&&t.type!=="decimal")throw new l("value","Zero missing-value policy requires a decimal field");if(t.tolerance!==void 0&&(t.type!=="decimal"||y.compareDecimal(y.parseDecimal(t.tolerance),y.parseDecimal(0))<0))throw new l("value","Tolerance requires a non-negative decimal");if(t.ratioDigits!==void 0&&(!Number.isInteger(t.ratioDigits)||t.ratioDigits<0||t.ratioDigits>100))throw new l("value","Invalid ratio precision")}return e.fields.map(t=>({...t,toleranceValue:y.parseDecimal(t.tolerance??"0")}))}function M(e,t,r,o,n){let c=!1;for(const s of r){const d=e?C(e,s.field):void 0,i=t?C(t,s.field):void 0,a=s.type==="decimal"?X(d,i,s,!e||!t):{equal:L(d,i,s)};if(e&&t&&a.equal)continue;if(c=!0,o.length>=n)throw new l("limit","Report differences exceed their budget");const{equal:u,...p}=a;o.push({rowKey:(t??e).rowKey,kind:e?t?"changed":"removed":"added",field:s.field,label:s.label??s.field,before:d,after:i,...p})}return c}function ee(e,t,r){O(e),O(t);const o=Y(r);if(e.datasetId!==t.datasetId||e.sourceScope!==t.sourceScope)throw new l("identity","Comparison requires the same business dataset and source scope");const n=r.fields.map(u=>u.field),c=q(e.rows,n,r),s=q(t.rows,n,r),d=b(r.maxDifferences,2e4,1e5),i=[],a={added:0,removed:0,changed:0,unchanged:0,cells:0};for(const[u,p]of c){const f=s.get(u),m=M(p,f,o,i,d);f?m?a.changed++:a.unchanged++:a.removed++}for(const[u,p]of s)c.has(u)||(M(void 0,p,o,i,d),a.added++);return a.cells=i.length,{sourceScope:t.sourceScope,datasetId:t.datasetId,differences:i,counts:a}}function K(e,t){O(t),j(t.fields,b(t.maxFields,256,1024));const r=b(t.maxCells,1e6,2e6),o=new Set(t.fields),n=new Map,c=g.createReportCellResolver(e);let s=0;for(const[d,i]of e.pages.entries())for(const[a,u]of i.components.entries()){if(!u.grid)continue;for(const f of u.grid.cells)if(s+=f.length,s>r)throw new l("limit","Report cell scan exceeds its budget");const p=N.resolveGridLayout(u.grid,u.widthMm,u.heightMm).cells;for(const f of p){const m=c({pageIndex:d,componentIndex:a,rowIndex:f.ri,columnIndex:f.ci}),w=m?.source;if(!m||!w||w.datasetId!==t.datasetId||w.sourceScope!==t.sourceScope||!o.has(w.field))continue;k(w.rowKey);const I=g.reportCellEditKey(m),h=n.get(I);h?(!Object.is(h.context.value,m.value)||h.context.source?.revision!==w.revision||h.context.source?.sourceToken!==w.sourceToken||h.context.editable!==m.editable)&&(h.ambiguous=!0):n.set(I,{context:m,ambiguous:!1})}}return n}function te(e,t){const r=K(e,t),o=new Map,n=b(t.maxRows,5e4,1e5);for(const{context:c,ambiguous:s}of r.values()){if(s)throw new l("conflict","Repeated report cells disagree for the same business field");const d=c.source,i=k(d.rowKey);let a=o.get(i);if(!a){if(o.size>=n)throw new l("limit","Report row extraction exceeds its budget");a={rowKey:d.rowKey,values:Object.create(null)},o.set(i,a)}a.values[d.field]=c.value}return{sourceScope:t.sourceScope,datasetId:t.datasetId,rows:[...o.values()]}}function _(e){return e==null||e===""}function re(e,t,r){if(!t){e.reason="missing-target";return}const{context:o,ambiguous:n}=t;if(e.before=o.value,n){e.status="conflict",e.reason="ambiguous";return}if(!o.editable||r.canEdit?.(o)===!1){e.reason="readonly";return}if(_(e.after)){e.reason="missing-source";return}if(Object.is(o.value,e.after)){e.status="matched",e.reason="unchanged";return}if(r.mode!=="replace"&&!_(o.value)){e.reason="occupied";return}try{const c=g.editFromContext(o,e.after);if(Object.is(c.value,c.previousValue)){e.status="matched",e.reason="unchanged";return}return e.after=c.value,e.status="changed",c}catch{e.status="conflict",e.reason="invalid";return}}function oe(e,t){if(O(t),t.mode!==void 0&&t.mode!=="empty"&&t.mode!=="replace")throw new l("value","Invalid prefill policy");const r=b(t.maxFields,256,1024),o=t.fields.map(f=>f.field),n=[...new Set(t.fields.map(f=>f.sourceField??f.field))];j(o,r),j(n,r);const c=q(t.rows,n,t),s=K(e,{...t,fields:o}),d=b(t.maxChanges,1e4,1e4),i=b(t.maxCells,1e6,2e6);if(c.size*o.length>i)throw new l("limit","Prefill review exceeds its budget");const a=[],u=[],p={matched:0,changed:0,skipped:0,conflict:0};for(const f of c.values())for(const m of t.fields){const w={sourceScope:t.sourceScope,datasetId:t.datasetId,rowKey:f.rowKey,field:m.field},I={source:w,label:m.label??m.field,status:"skipped",after:C(f,m.sourceField??m.field)},h=g.reportCellEditKey({address:{pageIndex:0,componentIndex:0,rowIndex:0,columnIndex:0},source:w}),D=re(I,s.get(h),t);if(D){if(u.length>=d)throw new l("limit","Prefill changes exceed the atomic edit budget");u.push(D)}p[I.status]++,a.push(I)}return{sourceScope:t.sourceScope,datasetId:t.datasetId,items:a,counts:p,edits:u}}function ne(e,t,r){if(t.counts.conflict>0)throw new l("conflict","Resolve prefill conflicts before applying");if(t.edits.length>1e4)throw new l("limit","Prefill changes exceed the atomic edit budget");if(!t.edits.length)return[];const o=[...new Set(t.edits.map(s=>s.source.field))],n=K(e,{sourceScope:t.sourceScope,datasetId:t.datasetId,fields:o}),c=new Set;return t.edits.map(s=>{if(!s.source||s.source.datasetId!==t.datasetId||s.source.sourceScope!==t.sourceScope)throw new l("identity","Prefill identity changed");const d=g.reportCellEditKey(s),i=n.get(d);if(c.has(d))throw new l("duplicate","Duplicate prefill target");if(c.add(d),!i||i.ambiguous||g.sourceChanged(i.context,s)||!Object.is(i.context.value,s.previousValue))throw new l("conflict","Prefill target changed; reload the preview");if(!i.context.editable||r?.(i.context)===!1)throw new l("conflict","Prefill target is read-only");return{address:{...i.context.address},value:g.editFromContext(i.context,s.value).value}})}exports.ReportDataError=l;exports.ReportDrillError=v;exports.compareReportData=ee;exports.createPageWindowIndex=B;exports.createReportDrillRequest=Z;exports.createReportPrefill=oe;exports.dataLimit=b;exports.indexReportDataCells=K;exports.matchReportDrillActions=U;exports.reportDataSnapshotFromPlan=te;exports.reportPrefillInputs=ne;exports.resolveReportDrillReturn=H;exports.validateReportDrillActions=A;
@@ -1,5 +1,5 @@
1
- import { R as n, u, s as y } from "./json-snapshot-DYmEe3sO.js";
2
- import { R as s, t as c, p as l } from "./sha256-DTG-Gq8i.js";
1
+ import { R as n, x as u, s as y } from "./json-snapshot-By4ZVVUt.js";
2
+ import { R as s, t as c, p as l } from "./sha256-BDQ1Qk7A.js";
3
3
  function F(e) {
4
4
  return e && { ...e };
5
5
  }
@@ -1 +1 @@
1
- "use strict";const i=require("./json-snapshot-D7PE1NsU.cjs"),a=require("./sha256-BshdOkCC.cjs");function y(r){return r&&{...r}}function g(r){if(!r)return;const t=e=>{if(!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new i.ReportSourceError("validate","字体应为 Uint8Array 或 ArrayBuffer");if(e.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return new Uint8Array(e instanceof Uint8Array?e:new Uint8Array(e))};if(r.customFontFaces){const e=r.customFontFaces;return{customFontName:r.customFontName,customFontFaces:{regular:t(e.regular),...e.bold?{bold:t(e.bold)}:{},...e.italic?{italic:t(e.italic)}:{},...e.boldItalic?{boldItalic:t(e.boldItalic)}:{}}}}return{customFontName:r.customFontName,...r.customFontBytes?{customFontBytes:t(r.customFontBytes)}:{}}}function f(r){const t=r?.customFontFaces??(r?.customFontBytes?{regular:r.customFontBytes}:void 0);if(!t)return;const e=["regular","bold","italic","boldItalic"].map(o=>{const n=t[o];if(!n)return[o,null];const s=n instanceof Uint8Array?n:new Uint8Array(n);if(s.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return[o,a.portableSha256Hex(s)]});return a.portableSha256Hex(new TextEncoder().encode(JSON.stringify(e)))}const d=new WeakMap;function w(r,t,e){const o=u(r,t,e);let n=!0;return{prepared:o,forward(){if(!n)throw new Error("报表快照只能交接一次");return n=!1,d.set(o,t),o}}}function u(r,t,e){if(a.throwIfAborted(e),!Number.isSafeInteger(t)||t<=0)throw new a.ReportRuntimeError("budget","快照预算应为正安全整数","$.budget.maxPreparedBytes");const o=d.get(r);if(d.delete(r),o!==void 0&&o<=t)return r;const n=i.snapshotReportJson(r,{maxBytes:t,maxNodes:t,check:()=>a.throwIfAborted(e),error:(s,c)=>s==="budget"?new a.ReportRuntimeError("budget",c,"$.budget.maxPreparedBytes"):new i.ReportSourceError("validate",c)});return l(n),n}function p(r){if(r===void 0)return!0;if(!Array.isArray(r))return!1;const t=new Set;return r.every(e=>!e||typeof e!="object"||Array.isArray(e)||typeof e.reportId!="string"||!e.reportId.trim()||!Number.isSafeInteger(e.reportIndex)||e.reportIndex<0||t.has(e.reportIndex)||typeof e.reportScope!="string"||!e.reportScope.trim()||e.reportScope.length>4096||e.revision!==void 0&&typeof e.revision!="string"||e.sourceToken!==void 0&&typeof e.sourceToken!="string"?!1:(t.add(e.reportIndex),!0))}function l(r){if(!p(r.sources))throw new i.ReportSourceError("validate","准备结果来源清单无效");if(!r?.stats||["rows","pages","cells"].some(t=>!Number.isSafeInteger(r.stats[t])||r.stats[t]<0)||!Number.isFinite(r.stats.durationMs)||r.stats.durationMs<0)throw new i.ReportSourceError("validate","准备结果统计无效");if(!Array.isArray(r.diagnostics)||r.diagnostics.some(t=>!t||typeof t.code!="string"||typeof t.message!="string"||!["info","warning","error"].includes(t.severity)||!i.hasValidDataExplanation(t)))throw new i.ReportSourceError("validate","准备结果诊断无效");if(!r.revisions||typeof r.revisions!="object"||Array.isArray(r.revisions)||Object.values(r.revisions).some(t=>!t||typeof t!="object"||t.revision!==void 0&&typeof t.revision!="string"||t.sourceToken!==void 0&&typeof t.sourceToken!="string"))throw new i.ReportSourceError("validate","准备结果修订无效");if(r.layout&&(!["heuristic","provided","font-bytes"].includes(r.layout.textMetrics)||r.layout.fontFingerprint!==void 0&&!/^[a-f0-9]{64}$/.test(r.layout.fontFingerprint)))throw new i.ReportSourceError("validate","准备结果字体度量标识无效")}function v(r){if(r.layoutPolicy!==void 0&&!["verify","preserve"].includes(r.layoutPolicy))throw new i.ReportSourceError("validate","无效的 layoutPolicy");if(r.format!=="pdf")return;if(r.layoutPolicy==="preserve"&&!r.prepared.layout?.fontFingerprint){r.prepared.diagnostics.push({code:"prepared-layout-preserved",severity:"info",message:"显式保持现有分页与几何;未验证排版字体身份,实际 PDF 输出仍遵循 fidelity 校验。"});return}const t=r.prepared.layout?.fontFingerprint,e=f(r.pdf);if(t===e&&(t!==void 0||r.prepared.layout?.textMetrics==="heuristic"&&!e))return;const o="已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";if(r.fidelity==="strict")throw new i.ReportSourceError("validate",o);r.prepared.diagnostics.push({code:"prepared-font-metrics",severity:"warning",message:o})}exports.capturePreparedHandoff=w;exports.checkPreparedFont=v;exports.reportFontFingerprint=f;exports.snapshotPdfFonts=g;exports.snapshotPreparedReport=u;exports.snapshotXlsxOptions=y;exports.validPreparedSources=p;exports.validatePreparedMetadata=l;
1
+ "use strict";const i=require("./json-snapshot-jiXff4lc.cjs"),a=require("./sha256-DgZAKXqI.cjs");function y(r){return r&&{...r}}function g(r){if(!r)return;const t=e=>{if(!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new i.ReportSourceError("validate","字体应为 Uint8Array 或 ArrayBuffer");if(e.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return new Uint8Array(e instanceof Uint8Array?e:new Uint8Array(e))};if(r.customFontFaces){const e=r.customFontFaces;return{customFontName:r.customFontName,customFontFaces:{regular:t(e.regular),...e.bold?{bold:t(e.bold)}:{},...e.italic?{italic:t(e.italic)}:{},...e.boldItalic?{boldItalic:t(e.boldItalic)}:{}}}}return{customFontName:r.customFontName,...r.customFontBytes?{customFontBytes:t(r.customFontBytes)}:{}}}function f(r){const t=r?.customFontFaces??(r?.customFontBytes?{regular:r.customFontBytes}:void 0);if(!t)return;const e=["regular","bold","italic","boldItalic"].map(o=>{const n=t[o];if(!n)return[o,null];const s=n instanceof Uint8Array?n:new Uint8Array(n);if(s.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return[o,a.portableSha256Hex(s)]});return a.portableSha256Hex(new TextEncoder().encode(JSON.stringify(e)))}const d=new WeakMap;function w(r,t,e){const o=u(r,t,e);let n=!0;return{prepared:o,forward(){if(!n)throw new Error("报表快照只能交接一次");return n=!1,d.set(o,t),o}}}function u(r,t,e){if(a.throwIfAborted(e),!Number.isSafeInteger(t)||t<=0)throw new a.ReportRuntimeError("budget","快照预算应为正安全整数","$.budget.maxPreparedBytes");const o=d.get(r);if(d.delete(r),o!==void 0&&o<=t)return r;const n=i.snapshotReportJson(r,{maxBytes:t,maxNodes:t,check:()=>a.throwIfAborted(e),error:(s,c)=>s==="budget"?new a.ReportRuntimeError("budget",c,"$.budget.maxPreparedBytes"):new i.ReportSourceError("validate",c)});return l(n),n}function p(r){if(r===void 0)return!0;if(!Array.isArray(r))return!1;const t=new Set;return r.every(e=>!e||typeof e!="object"||Array.isArray(e)||typeof e.reportId!="string"||!e.reportId.trim()||!Number.isSafeInteger(e.reportIndex)||e.reportIndex<0||t.has(e.reportIndex)||typeof e.reportScope!="string"||!e.reportScope.trim()||e.reportScope.length>4096||e.revision!==void 0&&typeof e.revision!="string"||e.sourceToken!==void 0&&typeof e.sourceToken!="string"?!1:(t.add(e.reportIndex),!0))}function l(r){if(!p(r.sources))throw new i.ReportSourceError("validate","准备结果来源清单无效");if(!r?.stats||["rows","pages","cells"].some(t=>!Number.isSafeInteger(r.stats[t])||r.stats[t]<0)||!Number.isFinite(r.stats.durationMs)||r.stats.durationMs<0)throw new i.ReportSourceError("validate","准备结果统计无效");if(!Array.isArray(r.diagnostics)||r.diagnostics.some(t=>!t||typeof t.code!="string"||typeof t.message!="string"||!["info","warning","error"].includes(t.severity)||!i.hasValidDataExplanation(t)))throw new i.ReportSourceError("validate","准备结果诊断无效");if(!r.revisions||typeof r.revisions!="object"||Array.isArray(r.revisions)||Object.values(r.revisions).some(t=>!t||typeof t!="object"||t.revision!==void 0&&typeof t.revision!="string"||t.sourceToken!==void 0&&typeof t.sourceToken!="string"))throw new i.ReportSourceError("validate","准备结果修订无效");if(r.layout&&(!["heuristic","provided","font-bytes"].includes(r.layout.textMetrics)||r.layout.fontFingerprint!==void 0&&!/^[a-f0-9]{64}$/.test(r.layout.fontFingerprint)))throw new i.ReportSourceError("validate","准备结果字体度量标识无效")}function v(r){if(r.layoutPolicy!==void 0&&!["verify","preserve"].includes(r.layoutPolicy))throw new i.ReportSourceError("validate","无效的 layoutPolicy");if(r.format!=="pdf")return;if(r.layoutPolicy==="preserve"&&!r.prepared.layout?.fontFingerprint){r.prepared.diagnostics.push({code:"prepared-layout-preserved",severity:"info",message:"显式保持现有分页与几何;未验证排版字体身份,实际 PDF 输出仍遵循 fidelity 校验。"});return}const t=r.prepared.layout?.fontFingerprint,e=f(r.pdf);if(t===e&&(t!==void 0||r.prepared.layout?.textMetrics==="heuristic"&&!e))return;const o="已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";if(r.fidelity==="strict")throw new i.ReportSourceError("validate",o);r.prepared.diagnostics.push({code:"prepared-font-metrics",severity:"warning",message:o})}exports.capturePreparedHandoff=w;exports.checkPreparedFont=v;exports.reportFontFingerprint=f;exports.snapshotPdfFonts=g;exports.snapshotPreparedReport=u;exports.snapshotXlsxOptions=y;exports.validPreparedSources=p;exports.validatePreparedMetadata=l;