ooxml-core 1.32.1 → 1.33.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.
- package/dist/{PptxHandler-TESZUH66.cjs → PptxHandler-MGKMIK22.cjs} +3 -3
- package/dist/PptxHandler-Q7CFNKOU.mjs +7 -0
- package/dist/PptxHandler-TEC7SWBU.mjs +4 -0
- package/dist/{PresentationBuilder-3CH5TR4W.mjs → PresentationBuilder-PJMQRZI6.mjs} +2 -2
- package/dist/{PresentationBuilder-S6HXHKEJ.mjs → PresentationBuilder-SADKXDWC.mjs} +4 -4
- package/dist/{PresentationBuilder-5NFBUP7Y.cjs → PresentationBuilder-VP2637RH.cjs} +5 -5
- package/dist/automation/index.cjs +4398 -2262
- package/dist/automation/index.mjs +4398 -2262
- package/dist/chart/funnel-geometry.d.ts +1 -1
- package/dist/chart/funnel-geometry.d.ts.map +1 -1
- package/dist/chart/index.cjs +5743 -3820
- package/dist/chart/index.mjs +5736 -3821
- package/dist/chart/region-map/alias.d.ts +12 -0
- package/dist/chart/region-map/alias.d.ts.map +1 -0
- package/dist/chart/region-map/cache.d.ts +20 -0
- package/dist/chart/region-map/cache.d.ts.map +1 -0
- package/dist/chart/region-map/colors.d.ts +4 -0
- package/dist/chart/region-map/colors.d.ts.map +1 -0
- package/dist/chart/region-map/data.d.ts +45 -0
- package/dist/chart/region-map/data.d.ts.map +1 -0
- package/dist/chart/region-map/geographic-projection.d.ts +4 -0
- package/dist/chart/region-map/geographic-projection.d.ts.map +1 -0
- package/dist/chart/region-map/geometry.d.ts +10 -0
- package/dist/chart/region-map/geometry.d.ts.map +1 -0
- package/dist/chart/region-map/index.cjs +892 -0
- package/dist/chart/region-map/index.d.ts +12 -0
- package/dist/chart/region-map/index.d.ts.map +1 -0
- package/dist/chart/region-map/index.mjs +870 -0
- package/dist/chart/region-map/projection.d.ts +19 -0
- package/dist/chart/region-map/projection.d.ts.map +1 -0
- package/dist/chart/region-map/types.d.ts +39 -0
- package/dist/chart/region-map/types.d.ts.map +1 -0
- package/dist/chart/region-map/value-color-positions.d.ts +4 -0
- package/dist/chart/region-map/value-color-positions.d.ts.map +1 -0
- package/dist/chart/region-map/value-colors.d.ts +4 -0
- package/dist/chart/region-map/value-colors.d.ts.map +1 -0
- package/dist/chart/region-map/world-regions.d.ts +22 -0
- package/dist/chart/region-map/world-regions.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-camera.d.ts +26 -0
- package/dist/chart/render/chart-3d-camera.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-layout.d.ts +27 -0
- package/dist/chart/render/chart-3d-layout.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-marks.d.ts +10 -0
- package/dist/chart/render/chart-3d-marks.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-mesh.d.ts +32 -0
- package/dist/chart/render/chart-3d-mesh.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-pie.d.ts +16 -0
- package/dist/chart/render/chart-3d-pie.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-projection.d.ts +37 -0
- package/dist/chart/render/chart-3d-projection.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-scene.d.ts +9 -0
- package/dist/chart/render/chart-3d-scene.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-shading.d.ts +10 -0
- package/dist/chart/render/chart-3d-shading.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-surface.d.ts +5 -0
- package/dist/chart/render/chart-3d-surface.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-svg.d.ts +7 -0
- package/dist/chart/render/chart-3d-svg.d.ts.map +1 -0
- package/dist/chart/render/chart-3d-walls.d.ts +13 -0
- package/dist/chart/render/chart-3d-walls.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-region-map.d.ts +4 -0
- package/dist/chart/render/chart-svg-region-map.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-text-metrics.d.ts +2 -0
- package/dist/chart/render/chart-svg-text-metrics.d.ts.map +1 -1
- package/dist/chart/render/chart-svg.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +5 -1
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/index.d.ts +5 -0
- package/dist/chart/render/index.d.ts.map +1 -1
- package/dist/chart/render/render-space.d.ts.map +1 -1
- package/dist/chart/render/summary-ex-formatting.d.ts +5 -0
- package/dist/chart/render/summary-ex-formatting.d.ts.map +1 -0
- package/dist/chart/render/summary-ex-series.d.ts.map +1 -1
- package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary.d.ts +5 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-Q6NM64J2.cjs → chunk-2LTIDUXH.cjs} +4791 -950
- package/dist/chunk-2N7RZQLC.mjs +8 -0
- package/dist/{chunk-NAWLWKOJ.mjs → chunk-3LMHYL4W.mjs} +2 -2
- package/dist/{chunk-O7SVHLD7.mjs → chunk-6LJW76BZ.mjs} +4756 -951
- package/dist/{chunk-X6VNUBES.cjs → chunk-BDZR4DZ6.cjs} +2058 -1748
- package/dist/{chunk-IOTGRLJH.mjs → chunk-BQGLWC6N.mjs} +867 -557
- package/dist/{chunk-N6424WKA.mjs → chunk-EBBWRRSB.mjs} +1 -1
- package/dist/{chunk-UYMSFJQZ.mjs → chunk-JQVOUS6B.mjs} +5 -5
- package/dist/{chunk-3H5UAJB3.mjs → chunk-QRXMYOVN.mjs} +870 -525
- package/dist/{chunk-54S5A5PZ.mjs → chunk-VDUNZTJC.mjs} +36 -1
- package/dist/{chunk-4R65YYAD.mjs → chunk-Y2RH4QWG.mjs} +4228 -1070
- package/dist/diagram/drawing-resolve.d.ts.map +1 -1
- package/dist/diagram/drawing-view.d.ts +6 -0
- package/dist/diagram/drawing-view.d.ts.map +1 -1
- package/dist/diagram/engine/engine-to-result.d.ts.map +1 -1
- package/dist/diagram/index.cjs +786 -145
- package/dist/diagram/index.d.ts +1 -0
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.mjs +783 -147
- package/dist/diagram/layout/smartart-layout-types.d.ts +7 -0
- package/dist/diagram/layout/smartart-layout-types.d.ts.map +1 -1
- package/dist/diagram/layout-preview.d.ts +4 -0
- package/dist/diagram/layout-preview.d.ts.map +1 -1
- package/dist/diagram/layout-role-style.d.ts +4 -0
- package/dist/diagram/layout-role-style.d.ts.map +1 -0
- package/dist/diagram/load.d.ts.map +1 -1
- package/dist/diagram/picture-layout.d.ts +23 -0
- package/dist/diagram/picture-layout.d.ts.map +1 -0
- package/dist/diagram/types.d.ts +6 -0
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/diagram/write/cache.d.ts +1 -0
- package/dist/diagram/write/cache.d.ts.map +1 -1
- package/dist/digest/crc32.d.ts +2 -0
- package/dist/digest/crc32.d.ts.map +1 -0
- package/dist/digest/index.cjs +11 -0
- package/dist/digest/index.d.ts +1 -0
- package/dist/digest/index.d.ts.map +1 -1
- package/dist/digest/index.mjs +11 -1
- package/dist/docx/diagram-cache.d.ts.map +1 -1
- package/dist/docx/diagram-save.d.ts.map +1 -1
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +882 -212
- package/dist/docx/embedded.mjs +882 -212
- package/dist/docx/index.cjs +3082 -866
- package/dist/docx/index.mjs +3082 -866
- package/dist/docx/inline-model.d.ts +4 -0
- package/dist/docx/inline-model.d.ts.map +1 -1
- package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/floats.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +2200 -438
- package/dist/docx/layout/index.mjs +2200 -438
- package/dist/docx/layout/input.d.ts +3 -0
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +3 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1311 -641
- package/dist/docx/load/index.mjs +1311 -641
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +2832 -842
- package/dist/docx/ui/index.mjs +2832 -842
- package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
- package/dist/docx/ui/run-adapter.d.ts.map +1 -1
- package/dist/docx/write-drawing.d.ts.map +1 -1
- package/dist/drawingml/index.cjs +707 -111
- package/dist/drawingml/index.d.ts +7 -0
- package/dist/drawingml/index.d.ts.map +1 -1
- package/dist/drawingml/index.mjs +697 -113
- package/dist/drawingml/picture-artistic.d.ts +14 -0
- package/dist/drawingml/picture-artistic.d.ts.map +1 -0
- package/dist/drawingml/picture-effects.d.ts +4 -1
- package/dist/drawingml/picture-effects.d.ts.map +1 -1
- package/dist/drawingml/picture-fill.d.ts.map +1 -1
- package/dist/drawingml/picture-hsl-pixels.d.ts +4 -0
- package/dist/drawingml/picture-hsl-pixels.d.ts.map +1 -0
- package/dist/drawingml/picture-layout.d.ts +25 -0
- package/dist/drawingml/picture-layout.d.ts.map +1 -0
- package/dist/drawingml/picture-standard-effects.d.ts +15 -0
- package/dist/drawingml/picture-standard-effects.d.ts.map +1 -0
- package/dist/drawingml/picture-transfer.d.ts +11 -0
- package/dist/drawingml/picture-transfer.d.ts.map +1 -0
- package/dist/drawingml/raster-image.d.ts +29 -0
- package/dist/drawingml/raster-image.d.ts.map +1 -0
- package/dist/drawingml/types.d.ts +1 -0
- package/dist/drawingml/types.d.ts.map +1 -1
- package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
- package/dist/geometry/index.cjs +38 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +36 -1
- package/dist/geometry/picture-tile.d.ts +29 -0
- package/dist/geometry/picture-tile.d.ts.map +1 -0
- package/dist/index.cjs +15164 -12669
- package/dist/index.mjs +15164 -12669
- package/dist/pptx/automation/index.cjs +7431 -2967
- package/dist/pptx/automation/index.d.ts +5 -5
- package/dist/pptx/automation/index.mjs +7 -7
- package/dist/pptx/chunks/{elements-mSCZ84Tc.d.ts → elements-f3UbFph-.d.ts} +7 -2
- package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DnWlmYCy.d.ts → index-BnH2QjYm.d.ts} +4 -4
- package/dist/pptx/chunks/{index-DnWlmYCy.d.ts.map → index-BnH2QjYm.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-D-FdgqrP.d.ts → index-Bp-1pGo1.d.ts} +4 -4
- package/dist/pptx/chunks/{index-D-FdgqrP.d.ts.map → index-Bp-1pGo1.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-DKybuHPT.d.ts → index-BuMPQDQb.d.ts} +27 -16
- package/dist/pptx/chunks/index-BuMPQDQb.d.ts.map +1 -0
- package/dist/pptx/chunks/{smart-art-DLumQo90.d.ts → smart-art-CmOrPLLQ.d.ts} +86 -2
- package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts → text-operations-D5sgspO6.d.ts} +2 -2
- package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts.map → text-operations-D5sgspO6.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +7196 -2732
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +6 -6
- package/dist/pptx/converter/index.cjs +3895 -503
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +3 -3
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
- package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
- package/dist/pptx/index.cjs +6828 -2969
- package/dist/pptx/index.d.ts +7 -7
- package/dist/pptx/index.mjs +7 -7
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.mjs +2 -2
- package/dist/teams/index.cjs +1964 -726
- package/dist/teams/index.mjs +1964 -726
- package/dist/visio/cell-formula.d.ts +5 -1
- package/dist/visio/cell-formula.d.ts.map +1 -1
- package/dist/visio/collab/index.cjs +3 -1
- package/dist/visio/collab/index.mjs +3 -1
- package/dist/visio/container-relationships.d.ts +19 -0
- package/dist/visio/container-relationships.d.ts.map +1 -0
- package/dist/visio/edit-container-fit.d.ts +19 -0
- package/dist/visio/edit-container-fit.d.ts.map +1 -0
- package/dist/visio/edit-container-members.d.ts +21 -0
- package/dist/visio/edit-container-members.d.ts.map +1 -0
- package/dist/visio/edit-delete.d.ts.map +1 -1
- package/dist/visio/edit-diagram-parts-commands.d.ts +23 -1
- package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -1
- package/dist/visio/edit-diagram-parts.d.ts +3 -2
- package/dist/visio/edit-diagram-parts.d.ts.map +1 -1
- package/dist/visio/edit-geometry.d.ts +4 -1
- package/dist/visio/edit-geometry.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts +13 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
- package/dist/visio/edit-recalculate.d.ts.map +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/formula-analyze.d.ts +2 -0
- package/dist/visio/formula-analyze.d.ts.map +1 -1
- package/dist/visio/formula-evaluate.d.ts.map +1 -1
- package/dist/visio/formula-master.d.ts +1 -0
- package/dist/visio/formula-master.d.ts.map +1 -1
- package/dist/visio/index.cjs +2771 -1312
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +2771 -1312
- package/dist/visio/media.d.ts +4 -23
- package/dist/visio/media.d.ts.map +1 -1
- package/dist/visio/package-common.d.ts +1 -1
- package/dist/visio/package-common.d.ts.map +1 -1
- package/dist/visio/shape-structure.d.ts +6 -3
- package/dist/visio/shape-structure.d.ts.map +1 -1
- package/dist/visio/ui/diagram-parts.d.ts +12 -1
- package/dist/visio/ui/diagram-parts.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +2679 -1201
- package/dist/visio/ui/index.mjs +2679 -1202
- package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-ex.d.ts +1 -0
- package/dist/xlsx/edit/chart-ex.d.ts.map +1 -1
- package/dist/xlsx/edit/filter.d.ts +5 -1
- package/dist/xlsx/edit/filter.d.ts.map +1 -1
- package/dist/xlsx/edit/index.d.ts +1 -0
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/session-calc.d.ts +5 -0
- package/dist/xlsx/edit/session-calc.d.ts.map +1 -1
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/text-columns.d.ts +21 -0
- package/dist/xlsx/edit/text-columns.d.ts.map +1 -0
- package/dist/xlsx/edit/types.d.ts +5 -1
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/embedded-chart-ex-space.d.ts +18 -0
- package/dist/xlsx/embedded-chart-ex-space.d.ts.map +1 -0
- package/dist/xlsx/filter-criteria.d.ts +22 -0
- package/dist/xlsx/filter-criteria.d.ts.map +1 -0
- package/dist/xlsx/filter-dynamic.d.ts +8 -0
- package/dist/xlsx/filter-dynamic.d.ts.map +1 -0
- package/dist/xlsx/filter-menu.d.ts +49 -0
- package/dist/xlsx/filter-menu.d.ts.map +1 -0
- package/dist/xlsx/filter-rows.d.ts +4 -4
- package/dist/xlsx/filter-rows.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +5856 -2934
- package/dist/xlsx/index.d.ts +4 -0
- package/dist/xlsx/index.d.ts.map +1 -1
- package/dist/xlsx/index.mjs +5839 -2934
- package/dist/xlsx/load/index.cjs +1871 -585
- package/dist/xlsx/load/index.mjs +1871 -585
- package/dist/xlsx/model-filter.d.ts +54 -0
- package/dist/xlsx/model-filter.d.ts.map +1 -0
- package/dist/xlsx/model.d.ts +42 -3
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/read/drawing.d.ts.map +1 -1
- package/dist/xlsx/read/filter-columns.d.ts +5 -0
- package/dist/xlsx/read/filter-columns.d.ts.map +1 -0
- package/dist/xlsx/read/shared-strings.d.ts +5 -3
- package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-props.d.ts +2 -2
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/filters.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/filters.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -1
- package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +7177 -4234
- package/dist/xlsx/ui/index.mjs +7177 -4234
- package/dist/xlsx/write/drawing.d.ts.map +1 -1
- package/dist/xlsx/write/filter-columns.d.ts +39 -0
- package/dist/xlsx/write/filter-columns.d.ts.map +1 -0
- package/dist/xlsx/write/shared-strings.d.ts +4 -4
- package/dist/xlsx/write/shared-strings.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-props.d.ts +2 -1
- package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/write/smart-art-cache.d.ts.map +1 -1
- package/dist/xlsx/write/smart-art.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +6 -1
- package/dist/PptxHandler-QY5VL3CY.mjs +0 -7
- package/dist/PptxHandler-SJ5ZUIUX.mjs +0 -4
- package/dist/chunk-3GXV5MPC.mjs +0 -41
- package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DKybuHPT.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +0 -1
package/dist/docx/ui/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var prosemirrorHistory = require('prosemirror-history');
|
|
|
5
5
|
var prosemirrorState = require('prosemirror-state');
|
|
6
6
|
var prosemirrorTransform = require('prosemirror-transform');
|
|
7
7
|
var prosemirrorModel = require('prosemirror-model');
|
|
8
|
+
var fflate = require('fflate');
|
|
8
9
|
var prosemirrorCollab = require('prosemirror-collab');
|
|
9
10
|
var Y2 = require('yjs');
|
|
10
11
|
var yProsemirror = require('y-prosemirror');
|
|
@@ -202,13 +203,13 @@ function updatedInlineRunAttributes(node, format) {
|
|
|
202
203
|
if (Object.hasOwn(desired, key)) metadata[key] = desired[key];
|
|
203
204
|
else delete metadata[key];
|
|
204
205
|
}
|
|
205
|
-
const
|
|
206
|
+
const attrs3 = {
|
|
206
207
|
...node.attrs,
|
|
207
208
|
format: Object.keys(metadata).length ? JSON.stringify(metadata) : null
|
|
208
209
|
};
|
|
209
210
|
for (const key of DIRECT_RUN_PROPERTY_KEYS)
|
|
210
|
-
|
|
211
|
-
return
|
|
211
|
+
attrs3[attributeName(key)] = JSON.stringify(base[key]) === JSON.stringify(desired[key]) ? null : JSON.stringify(desired[key] ?? null);
|
|
212
|
+
return attrs3;
|
|
212
213
|
}
|
|
213
214
|
function wordInlinePropertyCodec(schema) {
|
|
214
215
|
return Object.values(schema.nodes).some((type) => type.spec.attrs?.[attributeName("bold")]) ? schema.marks.inlineCommentAnchors ? "word-yjs-v3" : "word-yjs-v2" : "word-yjs-v1";
|
|
@@ -294,6 +295,8 @@ var NS = {
|
|
|
294
295
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
295
296
|
/** DrawingML main. */
|
|
296
297
|
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
298
|
+
/** Office 2016 extended charts (waterfall, histogram, funnel...; `cx:chartSpace`). */
|
|
299
|
+
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
297
300
|
/** DrawingML diagram (SmartArt) main. */
|
|
298
301
|
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
299
302
|
/** Relationships (`r:id`, `r:embed`). */
|
|
@@ -995,8 +998,8 @@ function cellContent(state, cell, text2) {
|
|
|
995
998
|
nodes.push(child3);
|
|
996
999
|
return;
|
|
997
1000
|
}
|
|
998
|
-
const
|
|
999
|
-
nodes.push(child3.type.create(
|
|
1001
|
+
const attrs3 = child3.attrs.contentControl ? { ...child3.attrs, contentControl: null } : child3.attrs;
|
|
1002
|
+
nodes.push(child3.type.create(attrs3, placed ? null : text2));
|
|
1000
1003
|
placed = true;
|
|
1001
1004
|
});
|
|
1002
1005
|
if (!placed) nodes.push(state.schema.nodes.paragraph.create(null, text2));
|
|
@@ -1682,16 +1685,16 @@ var RPR_ORDER = [
|
|
|
1682
1685
|
"rPrChange"
|
|
1683
1686
|
];
|
|
1684
1687
|
function orderChildren(parent, order) {
|
|
1685
|
-
const
|
|
1688
|
+
const elements3 = Array.from(parent.childNodes).filter(isElement);
|
|
1686
1689
|
const rankOf = (name) => order.findIndex((entry) => typeof entry === "string" ? entry === name : entry.includes(name));
|
|
1687
1690
|
let previousRank = -1;
|
|
1688
|
-
const ranked =
|
|
1691
|
+
const ranked = elements3.map((element3, index) => {
|
|
1689
1692
|
const rank2 = element3.namespaceURI === WORD_NS ? rankOf(element3.localName ?? "") : -1;
|
|
1690
1693
|
if (rank2 >= 0) previousRank = rank2;
|
|
1691
1694
|
return { element: element3, index, rank: rank2 >= 0 ? rank2 : previousRank + 0.5 };
|
|
1692
1695
|
});
|
|
1693
1696
|
const sorted = [...ranked].sort((a, b) => a.rank - b.rank || a.index - b.index);
|
|
1694
|
-
if (sorted.every((entry, index) => entry.element ===
|
|
1697
|
+
if (sorted.every((entry, index) => entry.element === elements3[index])) return;
|
|
1695
1698
|
for (const { element: element3 } of sorted) parent.appendChild(element3);
|
|
1696
1699
|
}
|
|
1697
1700
|
|
|
@@ -2318,9 +2321,9 @@ function parseRunProperties(props) {
|
|
|
2318
2321
|
if (themeColor2) {
|
|
2319
2322
|
result.colorTheme = { token: themeColor2 };
|
|
2320
2323
|
const tint = parseTintShade(getW(color, "themeTint"));
|
|
2321
|
-
const
|
|
2324
|
+
const shade2 = parseTintShade(getW(color, "themeShade"));
|
|
2322
2325
|
if (tint !== void 0) result.colorTheme.tint = tint;
|
|
2323
|
-
if (
|
|
2326
|
+
if (shade2 !== void 0) result.colorTheme.shade = shade2;
|
|
2324
2327
|
}
|
|
2325
2328
|
const spacing2 = parseSignedTwips(getW(first2(props, "spacing"), "val"));
|
|
2326
2329
|
if (spacing2 !== void 0) result.characterSpacingTwips = spacing2;
|
|
@@ -2338,9 +2341,9 @@ function parseRunProperties(props) {
|
|
|
2338
2341
|
if (shdTheme) {
|
|
2339
2342
|
result.shadingThemeFill = { token: shdTheme };
|
|
2340
2343
|
const tint = parseTintShade(getW(shd, "themeFillTint"));
|
|
2341
|
-
const
|
|
2344
|
+
const shade2 = parseTintShade(getW(shd, "themeFillShade"));
|
|
2342
2345
|
if (tint !== void 0) result.shadingThemeFill.tint = tint;
|
|
2343
|
-
if (
|
|
2346
|
+
if (shade2 !== void 0) result.shadingThemeFill.shade = shade2;
|
|
2344
2347
|
}
|
|
2345
2348
|
return result;
|
|
2346
2349
|
}
|
|
@@ -2412,166 +2415,6 @@ function setExtendedRunProperties(doc, props, run, base) {
|
|
|
2412
2415
|
}
|
|
2413
2416
|
}
|
|
2414
2417
|
|
|
2415
|
-
// opc/signature/xml-utils.ts
|
|
2416
|
-
function escapeXmlAttr(value) {
|
|
2417
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
|
-
// docx/watermark.ts
|
|
2421
|
-
var VML_NS = "urn:schemas-microsoft-com:vml";
|
|
2422
|
-
var OFFICE_NS = "urn:schemas-microsoft-com:office:office";
|
|
2423
|
-
var WORD10_NS = "urn:schemas-microsoft-com:office:word";
|
|
2424
|
-
var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
|
|
2425
|
-
function watermarkSizePt(spec) {
|
|
2426
|
-
const chars = Math.max(1, [...spec.text].length);
|
|
2427
|
-
const width = Math.min(spec.layout === "diagonal" ? 527 : 468, Math.max(150, chars * 44));
|
|
2428
|
-
return { width, height: Math.round(width / (chars * 0.55) * 100) / 100 };
|
|
2429
|
-
}
|
|
2430
|
-
var FORMULAS = [
|
|
2431
|
-
"sum #0 0 10800",
|
|
2432
|
-
"prod #0 2 1",
|
|
2433
|
-
"sum 21600 0 @1",
|
|
2434
|
-
"sum 0 0 @2",
|
|
2435
|
-
"sum 21600 0 @3",
|
|
2436
|
-
"if @0 @3 0",
|
|
2437
|
-
"if @0 21600 @1",
|
|
2438
|
-
"if @0 0 @2",
|
|
2439
|
-
"if @0 @4 21600",
|
|
2440
|
-
"mid @5 @6",
|
|
2441
|
-
"mid @8 @5",
|
|
2442
|
-
"mid @7 @8",
|
|
2443
|
-
"mid @6 @7",
|
|
2444
|
-
"sum @6 0 @5"
|
|
2445
|
-
];
|
|
2446
|
-
function buildWatermarkRun(doc, spec, uniqueId) {
|
|
2447
|
-
const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
|
|
2448
|
-
const run = makeW(doc, "r");
|
|
2449
|
-
const props = makeW(doc, "rPr");
|
|
2450
|
-
props.appendChild(makeW(doc, "noProof"));
|
|
2451
|
-
run.appendChild(props);
|
|
2452
|
-
const pict = makeW(doc, "pict");
|
|
2453
|
-
const type = v("shapetype");
|
|
2454
|
-
type.setAttribute("id", "_x0000_t136");
|
|
2455
|
-
type.setAttribute("coordsize", "21600,21600");
|
|
2456
|
-
type.setAttributeNS(OFFICE_NS, "o:spt", "136");
|
|
2457
|
-
type.setAttribute("adj", "10800");
|
|
2458
|
-
type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
|
|
2459
|
-
const formulas = v("formulas");
|
|
2460
|
-
for (const eqn of FORMULAS) {
|
|
2461
|
-
const f = v("f");
|
|
2462
|
-
f.setAttribute("eqn", eqn);
|
|
2463
|
-
formulas.appendChild(f);
|
|
2464
|
-
}
|
|
2465
|
-
const path = v("path");
|
|
2466
|
-
path.setAttribute("textpathok", "t");
|
|
2467
|
-
path.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
|
|
2468
|
-
path.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
|
|
2469
|
-
path.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
|
|
2470
|
-
const typePath = v("textpath");
|
|
2471
|
-
typePath.setAttribute("on", "t");
|
|
2472
|
-
typePath.setAttribute("fitshape", "t");
|
|
2473
|
-
const handles = v("handles");
|
|
2474
|
-
const handle = v("h");
|
|
2475
|
-
handle.setAttribute("position", "#0,bottomRight");
|
|
2476
|
-
handle.setAttribute("xrange", "6629,14971");
|
|
2477
|
-
handles.appendChild(handle);
|
|
2478
|
-
const lock = makeNS(doc, OFFICE_NS, "o:lock");
|
|
2479
|
-
lock.setAttributeNS(VML_NS, "v:ext", "edit");
|
|
2480
|
-
lock.setAttribute("text", "t");
|
|
2481
|
-
lock.setAttribute("shapetype", "t");
|
|
2482
|
-
for (const child3 of [formulas, path, typePath, handles, lock]) type.appendChild(child3);
|
|
2483
|
-
const size = watermarkSizePt(spec);
|
|
2484
|
-
const shape = v("shape");
|
|
2485
|
-
shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
|
|
2486
|
-
shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
|
|
2487
|
-
shape.setAttribute("type", "#_x0000_t136");
|
|
2488
|
-
shape.setAttribute(
|
|
2489
|
-
"style",
|
|
2490
|
-
`position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
|
|
2491
|
-
);
|
|
2492
|
-
shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
|
|
2493
|
-
shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
|
|
2494
|
-
shape.setAttribute("stroked", "f");
|
|
2495
|
-
const fill = v("fill");
|
|
2496
|
-
fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
|
|
2497
|
-
const text2 = v("textpath");
|
|
2498
|
-
text2.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
|
|
2499
|
-
text2.setAttribute("string", spec.text);
|
|
2500
|
-
const wrap = makeNS(doc, WORD10_NS, "w10:wrap");
|
|
2501
|
-
wrap.setAttribute("anchorx", "margin");
|
|
2502
|
-
wrap.setAttribute("anchory", "margin");
|
|
2503
|
-
for (const child3 of [fill, text2, wrap]) shape.appendChild(child3);
|
|
2504
|
-
pict.appendChild(type);
|
|
2505
|
-
pict.appendChild(shape);
|
|
2506
|
-
run.appendChild(pict);
|
|
2507
|
-
return run;
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
// docx/write-text-box.ts
|
|
2511
|
-
var A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
2512
|
-
var WP_NS = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
2513
|
-
var WPS_NS = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
2514
|
-
var W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
2515
|
-
var el = (doc, ns, name) => makeNS(doc, ns, name);
|
|
2516
|
-
var add = (parent, ...items) => {
|
|
2517
|
-
for (const item2 of items) parent.appendChild(item2);
|
|
2518
|
-
return parent;
|
|
2519
|
-
};
|
|
2520
|
-
var emu = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
|
|
2521
|
-
var descendants = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
|
|
2522
|
-
function paragraphsFor(doc, lines) {
|
|
2523
|
-
return (lines.length ? lines : [""]).map((line3) => {
|
|
2524
|
-
const paragraph = makeW(doc, "p");
|
|
2525
|
-
if (line3) {
|
|
2526
|
-
const run = makeW(doc, "r");
|
|
2527
|
-
const text2 = makeW(doc, "t");
|
|
2528
|
-
if (/^\s|\s$/.test(line3))
|
|
2529
|
-
text2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
|
|
2530
|
-
text2.textContent = line3;
|
|
2531
|
-
add(run, text2);
|
|
2532
|
-
add(paragraph, run);
|
|
2533
|
-
}
|
|
2534
|
-
return paragraph;
|
|
2535
|
-
});
|
|
2536
|
-
}
|
|
2537
|
-
function outline(doc, border) {
|
|
2538
|
-
const ln = el(doc, A_NS, "a:ln");
|
|
2539
|
-
if (!border) return add(ln, el(doc, A_NS, "a:noFill"));
|
|
2540
|
-
ln.setAttribute("w", "9525");
|
|
2541
|
-
const color = el(doc, A_NS, "a:srgbClr");
|
|
2542
|
-
color.setAttribute("val", "000000");
|
|
2543
|
-
return add(ln, add(el(doc, A_NS, "a:solidFill"), color));
|
|
2544
|
-
}
|
|
2545
|
-
function patchTextBox(doc, drawing, image, base) {
|
|
2546
|
-
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
2547
|
-
for (const node of [
|
|
2548
|
-
...descendants(drawing, WP_NS, "extent"),
|
|
2549
|
-
...descendants(drawing, A_NS, "ext").filter(
|
|
2550
|
-
(ext) => ext.parentNode?.localName === "xfrm"
|
|
2551
|
-
)
|
|
2552
|
-
]) {
|
|
2553
|
-
node.setAttribute("cx", emu(image.widthPx));
|
|
2554
|
-
node.setAttribute("cy", emu(image.heightPx));
|
|
2555
|
-
}
|
|
2556
|
-
if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
|
|
2557
|
-
const content = descendants(drawing, W_NS, "txbxContent")[0];
|
|
2558
|
-
if (content) {
|
|
2559
|
-
for (const child3 of Array.from(content.childNodes)) content.removeChild(child3);
|
|
2560
|
-
add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
|
|
2564
|
-
const spPr = descendants(drawing, WPS_NS, "spPr")[0];
|
|
2565
|
-
if (spPr) {
|
|
2566
|
-
for (const old of Array.from(spPr.childNodes).filter(
|
|
2567
|
-
(node) => isElement(node) && node.localName === "ln"
|
|
2568
|
-
))
|
|
2569
|
-
spPr.removeChild(old);
|
|
2570
|
-
spPr.appendChild(outline(doc, image.textBoxBorder !== false));
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
2418
|
// drawingml/dom.ts
|
|
2576
2419
|
function attributeReader(element3) {
|
|
2577
2420
|
return (name) => {
|
|
@@ -2600,7 +2443,7 @@ function booleanAttribute(element3, name) {
|
|
|
2600
2443
|
if (value === "0" || value === "false") return false;
|
|
2601
2444
|
return void 0;
|
|
2602
2445
|
}
|
|
2603
|
-
function
|
|
2446
|
+
function descendants(root, local) {
|
|
2604
2447
|
const result = [];
|
|
2605
2448
|
const visit = (node) => {
|
|
2606
2449
|
for (const child3 of Array.from(node.childNodes)) {
|
|
@@ -2613,6 +2456,94 @@ function descendants2(root, local) {
|
|
|
2613
2456
|
return result;
|
|
2614
2457
|
}
|
|
2615
2458
|
|
|
2459
|
+
// drawingml/picture-crop.ts
|
|
2460
|
+
var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
|
|
2461
|
+
function parsePictureCrop(blipFill) {
|
|
2462
|
+
const rect3 = first(blipFill, "srcRect", NS.a);
|
|
2463
|
+
if (!rect3) return void 0;
|
|
2464
|
+
const result = {};
|
|
2465
|
+
for (const [attr2, key] of Object.entries(SIDES)) {
|
|
2466
|
+
const raw = rect3.getAttribute(attr2);
|
|
2467
|
+
if (raw === null || !raw.trim()) continue;
|
|
2468
|
+
const percent = raw.endsWith("%");
|
|
2469
|
+
const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
|
|
2470
|
+
if (Number.isFinite(value)) result[key] = value;
|
|
2471
|
+
}
|
|
2472
|
+
return result;
|
|
2473
|
+
}
|
|
2474
|
+
function applyPictureCrop(blipFill, crop) {
|
|
2475
|
+
let rect3 = first(blipFill, "srcRect", NS.a);
|
|
2476
|
+
if (!rect3 && crop && Object.values(crop).some((value) => value !== void 0)) {
|
|
2477
|
+
rect3 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
|
|
2478
|
+
const blip = first(blipFill, "blip", NS.a);
|
|
2479
|
+
blipFill.insertBefore(rect3, blip?.nextSibling ?? blipFill.firstChild);
|
|
2480
|
+
}
|
|
2481
|
+
if (!rect3) return;
|
|
2482
|
+
for (const [attr2, key] of Object.entries(SIDES)) {
|
|
2483
|
+
const value = crop?.[key];
|
|
2484
|
+
if (value === void 0) rect3.removeAttribute(attr2);
|
|
2485
|
+
else {
|
|
2486
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
|
|
2487
|
+
rect3.setAttribute(attr2, String(Math.round(value * 1e5)));
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
// drawingml/picture-artistic.ts
|
|
2493
|
+
var ARTISTIC_PRIMARY_ATTRIBUTE = {
|
|
2494
|
+
artisticBlur: "radius",
|
|
2495
|
+
artisticCement: "crackSpacing",
|
|
2496
|
+
artisticChalkSketch: "pressure",
|
|
2497
|
+
artisticCrisscrossEtching: "pressure",
|
|
2498
|
+
artisticCutout: "numberOfShades",
|
|
2499
|
+
artisticFilmGrain: "grainSize",
|
|
2500
|
+
artisticGlass: "scaling",
|
|
2501
|
+
artisticGlowDiffused: "intensity",
|
|
2502
|
+
artisticGlowEdges: "smoothness",
|
|
2503
|
+
artisticLightScreen: "gridSize",
|
|
2504
|
+
artisticLineDrawing: "pencilSize",
|
|
2505
|
+
artisticMarker: "size",
|
|
2506
|
+
// Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
|
|
2507
|
+
artisticMosiaicBubbles: "pressure",
|
|
2508
|
+
artisticPaintBrush: "brushSize",
|
|
2509
|
+
artisticPaintStrokes: "intensity",
|
|
2510
|
+
artisticPastelsSmooth: "scaling",
|
|
2511
|
+
artisticPencilGrayscale: "pencilSize",
|
|
2512
|
+
artisticPencilSketch: "pressure",
|
|
2513
|
+
artisticPhotocopy: "detail",
|
|
2514
|
+
artisticPlasticWrap: "smoothness",
|
|
2515
|
+
artisticTexturizer: "scaling",
|
|
2516
|
+
artisticWatercolorSponge: "brushSize"
|
|
2517
|
+
};
|
|
2518
|
+
function parseArtisticPictureExtension(node) {
|
|
2519
|
+
if (node.namespaceURI !== NS.a || node.localName !== "extLst") return void 0;
|
|
2520
|
+
const found = [];
|
|
2521
|
+
const unhandled = [];
|
|
2522
|
+
const pending = [node];
|
|
2523
|
+
while (pending.length) {
|
|
2524
|
+
const item2 = pending.pop();
|
|
2525
|
+
if (item2 !== node && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
|
|
2526
|
+
unhandled.push(item2.localName);
|
|
2527
|
+
if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
|
|
2528
|
+
found.push(item2);
|
|
2529
|
+
pending.push(...elements(item2));
|
|
2530
|
+
}
|
|
2531
|
+
if (found.length !== 1) return void 0;
|
|
2532
|
+
const effect = found[0];
|
|
2533
|
+
const key = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
|
|
2534
|
+
if (!key) return void 0;
|
|
2535
|
+
const raw = key ? effect.getAttribute(key) : null;
|
|
2536
|
+
const n2 = raw === null ? 0 : Number(raw);
|
|
2537
|
+
if (!Number.isFinite(n2)) return void 0;
|
|
2538
|
+
return {
|
|
2539
|
+
kind: "artistic",
|
|
2540
|
+
name: effect.localName,
|
|
2541
|
+
radius: effect.localName === "artisticBlur" ? n2 : n2 / 1e3,
|
|
2542
|
+
baked: true,
|
|
2543
|
+
...unhandled.length ? { unhandled } : {}
|
|
2544
|
+
};
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2616
2547
|
// drawingml/ordered-color-transforms.ts
|
|
2617
2548
|
function orderedColorTransforms(channels, transforms) {
|
|
2618
2549
|
let { r, g, b } = channels;
|
|
@@ -2786,11 +2717,11 @@ function resolveDrawingColor(color, theme, options2) {
|
|
|
2786
2717
|
}
|
|
2787
2718
|
if (has("inv")) [r, g, b] = [255 - r, 255 - g, 255 - b];
|
|
2788
2719
|
if (has("gray")) r = g = b = Math.round(0.299 * r + 0.587 * g + 0.114 * b);
|
|
2789
|
-
const
|
|
2790
|
-
if (
|
|
2791
|
-
r = linearToSrgb255(srgb255ToLinear(r) *
|
|
2792
|
-
g = linearToSrgb255(srgb255ToLinear(g) *
|
|
2793
|
-
b = linearToSrgb255(srgb255ToLinear(b) *
|
|
2720
|
+
const shade2 = parseDrawingPercent(find("shade"));
|
|
2721
|
+
if (shade2 !== void 0) {
|
|
2722
|
+
r = linearToSrgb255(srgb255ToLinear(r) * shade2);
|
|
2723
|
+
g = linearToSrgb255(srgb255ToLinear(g) * shade2);
|
|
2724
|
+
b = linearToSrgb255(srgb255ToLinear(b) * shade2);
|
|
2794
2725
|
}
|
|
2795
2726
|
const tint = parseDrawingPercent(find("tint"));
|
|
2796
2727
|
if (tint !== void 0) {
|
|
@@ -2836,46 +2767,216 @@ function resolveDrawingColor(color, theme, options2) {
|
|
|
2836
2767
|
};
|
|
2837
2768
|
}
|
|
2838
2769
|
|
|
2839
|
-
// drawingml/
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2770
|
+
// drawingml/write-color.ts
|
|
2771
|
+
var ELEMENTS = {
|
|
2772
|
+
srgb: "srgbClr",
|
|
2773
|
+
scheme: "schemeClr",
|
|
2774
|
+
system: "sysClr",
|
|
2775
|
+
preset: "prstClr",
|
|
2776
|
+
scrgb: "scrgbClr",
|
|
2777
|
+
hsl: "hslClr"
|
|
2778
|
+
};
|
|
2779
|
+
function drawingColorXml(color) {
|
|
2780
|
+
const local = ELEMENTS[color.kind];
|
|
2781
|
+
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
2782
|
+
const root = doc.documentElement;
|
|
2783
|
+
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
2784
|
+
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
2785
|
+
const values = color.value.split(",");
|
|
2786
|
+
keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
|
|
2787
|
+
} else root.setAttribute("val", color.value);
|
|
2788
|
+
if (color.fallback !== void 0 && color.kind === "system")
|
|
2789
|
+
root.setAttribute("lastClr", color.fallback);
|
|
2790
|
+
for (const transform of color.transforms) {
|
|
2791
|
+
if (!/^[A-Za-z_][\w.-]*$/.test(transform.name))
|
|
2792
|
+
throw new Error(`Invalid DrawingML transform ${transform.name}`);
|
|
2793
|
+
const node = doc.createElementNS(NS.a, `a:${transform.name}`);
|
|
2794
|
+
if (transform.value !== "") node.setAttribute("val", transform.value);
|
|
2795
|
+
root.appendChild(node);
|
|
2796
|
+
}
|
|
2797
|
+
return buildXml(doc);
|
|
2846
2798
|
}
|
|
2847
2799
|
|
|
2848
|
-
// drawingml/
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
const
|
|
2852
|
-
if (!
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2800
|
+
// drawingml/patch-color.ts
|
|
2801
|
+
function patchDrawingColorIn(container, color) {
|
|
2802
|
+
const old = elements(container).find((node) => parseDrawingColor(node));
|
|
2803
|
+
const before = parseDrawingColorIn(container);
|
|
2804
|
+
if (!old || !before || before.kind !== color.kind) {
|
|
2805
|
+
const next = container.ownerDocument.importNode(
|
|
2806
|
+
parseXml(drawingColorXml(color)).documentElement,
|
|
2807
|
+
true
|
|
2808
|
+
);
|
|
2809
|
+
if (old) container.replaceChild(next, old);
|
|
2810
|
+
else container.insertBefore(next, container.firstChild);
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
if (before.value !== color.value) {
|
|
2814
|
+
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
2815
|
+
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
2816
|
+
const values = color.value.split(",");
|
|
2817
|
+
keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
|
|
2818
|
+
} else old.setAttribute("val", color.value);
|
|
2819
|
+
}
|
|
2820
|
+
if (before.fallback !== color.fallback && color.kind === "system") {
|
|
2821
|
+
if (color.fallback === void 0) old.removeAttribute("lastClr");
|
|
2822
|
+
else old.setAttribute("lastClr", color.fallback);
|
|
2823
|
+
}
|
|
2824
|
+
const originals = elements(old);
|
|
2825
|
+
color.transforms.forEach((transform, index) => {
|
|
2826
|
+
const source = originals[index];
|
|
2827
|
+
if (source?.localName === transform.name) {
|
|
2828
|
+
if (before.transforms[index]?.value !== transform.value) {
|
|
2829
|
+
if (transform.value === "") source.removeAttribute("val");
|
|
2830
|
+
else source.setAttribute("val", transform.value);
|
|
2831
|
+
}
|
|
2832
|
+
return;
|
|
2833
|
+
}
|
|
2834
|
+
if (!/^[A-Za-z_][\w.-]*$/u.test(transform.name))
|
|
2835
|
+
throw new Error("Invalid DrawingML colour transform");
|
|
2836
|
+
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform.name}`);
|
|
2837
|
+
if (transform.value !== "") next.setAttribute("val", transform.value);
|
|
2838
|
+
if (source) old.replaceChild(next, source);
|
|
2839
|
+
else old.appendChild(next);
|
|
2840
|
+
});
|
|
2841
|
+
for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
// drawingml/picture-standard-effects.ts
|
|
2845
|
+
var attrs = {
|
|
2846
|
+
biLevel: { threshold: "thresh" },
|
|
2847
|
+
alphaRepl: { amount: "a" },
|
|
2848
|
+
alphaBiLevel: { threshold: "thresh" },
|
|
2849
|
+
hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
|
|
2850
|
+
tint: { hue: "hue", amount: "amt" },
|
|
2851
|
+
blur: { radiusEmu: "rad" }
|
|
2852
|
+
};
|
|
2853
|
+
function parseStandardPictureEffect(node) {
|
|
2854
|
+
const name = node.localName;
|
|
2855
|
+
if (![
|
|
2856
|
+
"biLevel",
|
|
2857
|
+
"alphaInv",
|
|
2858
|
+
"alphaCeiling",
|
|
2859
|
+
"alphaFloor",
|
|
2860
|
+
"alphaRepl",
|
|
2861
|
+
"alphaBiLevel",
|
|
2862
|
+
"alphaMod",
|
|
2863
|
+
"duotone",
|
|
2864
|
+
"clrRepl",
|
|
2865
|
+
"clrChange",
|
|
2866
|
+
"hsl",
|
|
2867
|
+
"tint",
|
|
2868
|
+
"blur"
|
|
2869
|
+
].includes(name))
|
|
2870
|
+
return void 0;
|
|
2871
|
+
const values = {};
|
|
2872
|
+
for (const [key, attribute] of Object.entries(attrs[name] ?? {})) {
|
|
2873
|
+
const raw = node.getAttribute(attribute);
|
|
2874
|
+
if (raw === null) continue;
|
|
2857
2875
|
const percent = raw.endsWith("%");
|
|
2858
|
-
const
|
|
2859
|
-
if (Number.isFinite(
|
|
2876
|
+
const n2 = Number(percent ? raw.slice(0, -1) : raw) / (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : percent ? 100 : 1e5);
|
|
2877
|
+
if (!Number.isFinite(n2) || key === "hue" && (n2 < 0 || n2 >= 360) || key === "threshold" && (n2 < 0 || n2 > 1) || key === "radiusEmu" && (!Number.isSafeInteger(n2) || n2 < 0) || ["saturation", "luminance", "amount"].includes(key) && name !== "alphaMod" && (n2 < (name === "alphaRepl" ? 0 : -1) || n2 > 1))
|
|
2878
|
+
return void 0;
|
|
2879
|
+
values[key] = n2;
|
|
2860
2880
|
}
|
|
2861
|
-
|
|
2881
|
+
if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
|
|
2882
|
+
return void 0;
|
|
2883
|
+
if (name === "alphaRepl" && values.amount === void 0) return void 0;
|
|
2884
|
+
if (name === "alphaMod") {
|
|
2885
|
+
const cont = first(node, "cont", NS.a);
|
|
2886
|
+
const nested = cont ? elements(cont) : [];
|
|
2887
|
+
if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
|
|
2888
|
+
const raw = nested[0].getAttribute("amt") ?? "100000";
|
|
2889
|
+
const n2 = Number(raw.endsWith("%") ? raw.slice(0, -1) : raw) / (raw.endsWith("%") ? 100 : 1e5);
|
|
2890
|
+
if (!Number.isFinite(n2) || n2 < 0) return void 0;
|
|
2891
|
+
values.amount = n2;
|
|
2892
|
+
}
|
|
2893
|
+
let colors = [];
|
|
2894
|
+
if (name === "duotone") {
|
|
2895
|
+
const candidates = elements(node).filter(
|
|
2896
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
2897
|
+
);
|
|
2898
|
+
colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
|
|
2899
|
+
if (colors.length !== 2) return void 0;
|
|
2900
|
+
}
|
|
2901
|
+
if (name === "clrRepl") {
|
|
2902
|
+
const color = parseDrawingColorIn(node);
|
|
2903
|
+
if (!color) return void 0;
|
|
2904
|
+
colors = [color];
|
|
2905
|
+
}
|
|
2906
|
+
if (name === "clrChange") {
|
|
2907
|
+
const from = parseDrawingColorIn(first(node, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node, "clrTo", NS.a));
|
|
2908
|
+
if (!from || !to) return void 0;
|
|
2909
|
+
colors = [from, to];
|
|
2910
|
+
}
|
|
2911
|
+
if (name === "alphaInv") {
|
|
2912
|
+
const color = parseDrawingColorIn(node);
|
|
2913
|
+
if (color) colors = [color];
|
|
2914
|
+
}
|
|
2915
|
+
return {
|
|
2916
|
+
kind: "standard",
|
|
2917
|
+
name,
|
|
2918
|
+
...Object.keys(values).length ? { values } : {},
|
|
2919
|
+
...colors.length ? { colors } : {},
|
|
2920
|
+
...name === "clrChange" && node.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node.getAttribute("useA") ?? "") } : {},
|
|
2921
|
+
...name === "blur" && node.hasAttribute("grow") ? { grow: !["0", "false"].includes(node.getAttribute("grow") ?? "") } : {}
|
|
2922
|
+
};
|
|
2862
2923
|
}
|
|
2863
|
-
function
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2924
|
+
function applyStandardPictureEffect(node, effect) {
|
|
2925
|
+
const doc = node.ownerDocument, before = parseStandardPictureEffect(node);
|
|
2926
|
+
for (const [key, value] of Object.entries(effect.values ?? {})) {
|
|
2927
|
+
if (!Number.isFinite(value) || key === "hue" && (value < 0 || value >= 360) || key === "threshold" && (value < 0 || value > 1) || key === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
|
|
2928
|
+
throw new RangeError("Invalid picture effect values");
|
|
2929
|
+
}
|
|
2930
|
+
const count = effect.colors?.length ?? 0;
|
|
2931
|
+
if (["duotone", "clrChange"].includes(effect.name) && count !== 2 || effect.name === "clrRepl" && count !== 1 || effect.name === "alphaInv" && count > 1)
|
|
2932
|
+
throw new RangeError("Invalid picture effect colours");
|
|
2933
|
+
for (const [key, attribute] of Object.entries(attrs[effect.name] ?? {})) {
|
|
2934
|
+
const value = effect.values?.[key];
|
|
2935
|
+
if (value === before?.values?.[key]) continue;
|
|
2936
|
+
if (value === void 0) node.removeAttribute(attribute);
|
|
2937
|
+
else
|
|
2938
|
+
node.setAttribute(
|
|
2939
|
+
attribute,
|
|
2940
|
+
String(Math.round(value * (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : 1e5)))
|
|
2941
|
+
);
|
|
2869
2942
|
}
|
|
2870
|
-
if (
|
|
2871
|
-
|
|
2872
|
-
const
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2943
|
+
if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
|
|
2944
|
+
const cont = first(node, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
|
|
2945
|
+
const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
|
|
2946
|
+
fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
|
|
2947
|
+
if (!fix.parentNode) cont.appendChild(fix);
|
|
2948
|
+
if (!cont.parentNode) node.appendChild(cont);
|
|
2949
|
+
}
|
|
2950
|
+
if (effect.useAlpha !== before?.useAlpha) {
|
|
2951
|
+
if (effect.useAlpha === void 0) node.removeAttribute("useA");
|
|
2952
|
+
else node.setAttribute("useA", effect.useAlpha ? "1" : "0");
|
|
2953
|
+
}
|
|
2954
|
+
if (effect.grow !== before?.grow) {
|
|
2955
|
+
if (effect.grow === void 0) node.removeAttribute("grow");
|
|
2956
|
+
else node.setAttribute("grow", effect.grow ? "1" : "0");
|
|
2957
|
+
}
|
|
2958
|
+
if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
|
|
2959
|
+
if (effect.name === "duotone") {
|
|
2960
|
+
const old = elements(node).filter(
|
|
2961
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
2962
|
+
);
|
|
2963
|
+
for (let i = 0; i < (effect.colors?.length ?? 0); i++) {
|
|
2964
|
+
const holder = doc.createElementNS(NS.a, "a:holder");
|
|
2965
|
+
if (old[i]) holder.appendChild(doc.importNode(old[i], true));
|
|
2966
|
+
patchDrawingColorIn(holder, effect.colors[i]);
|
|
2967
|
+
const next = elements(holder)[0];
|
|
2968
|
+
if (old[i]) node.replaceChild(next, old[i]);
|
|
2969
|
+
else node.insertBefore(next, first(node, "extLst", NS.a) ?? null);
|
|
2970
|
+
}
|
|
2971
|
+
} else if (effect.name === "clrChange") {
|
|
2972
|
+
for (const [i, name] of ["clrFrom", "clrTo"].entries()) {
|
|
2973
|
+
const holder = first(node, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
|
|
2974
|
+
if (effect.colors?.[i]) patchDrawingColorIn(holder, effect.colors[i]);
|
|
2975
|
+
if (!holder.parentNode) node.insertBefore(holder, first(node, "extLst", NS.a) ?? null);
|
|
2976
|
+
}
|
|
2977
|
+
} else if (effect.colors?.[0]) patchDrawingColorIn(node, effect.colors[0]);
|
|
2878
2978
|
}
|
|
2979
|
+
if (!parseStandardPictureEffect(node)) throw new RangeError("Invalid picture effect values");
|
|
2879
2980
|
}
|
|
2880
2981
|
|
|
2881
2982
|
// drawingml/picture-effects.ts
|
|
@@ -2915,14 +3016,19 @@ function readPictureEffect(name, attribute) {
|
|
|
2915
3016
|
function parsePictureEffects(blip) {
|
|
2916
3017
|
if (!blip) return [];
|
|
2917
3018
|
return elements(blip).map((node) => ({
|
|
2918
|
-
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
3019
|
+
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) ?? parseStandardPictureEffect(node) ?? parseArtisticPictureExtension(node) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
2919
3020
|
sourceXml: buildXml(node)
|
|
2920
3021
|
}));
|
|
2921
3022
|
}
|
|
2922
3023
|
function applyPictureEffects(blip, effects) {
|
|
2923
3024
|
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
|
|
2924
3025
|
const nodes = effects.map((effect) => {
|
|
2925
|
-
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
|
|
3026
|
+
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
|
|
3027
|
+
if (effect.kind === "artistic") {
|
|
3028
|
+
const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
|
|
3029
|
+
if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
|
|
3030
|
+
throw new Error("Artistic authoring requires a host-generated baked picture cache");
|
|
3031
|
+
}
|
|
2926
3032
|
const source = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
|
|
2927
3033
|
if (effect.kind === "unsupported" && !source)
|
|
2928
3034
|
throw new Error("An unsupported picture effect needs source XML");
|
|
@@ -2949,12 +3055,124 @@ function applyPictureEffects(blip, effects) {
|
|
|
2949
3055
|
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
2950
3056
|
set("amt", effect.amount);
|
|
2951
3057
|
}
|
|
3058
|
+
if (effect.kind === "standard") applyStandardPictureEffect(node, effect);
|
|
2952
3059
|
return node;
|
|
2953
3060
|
});
|
|
2954
3061
|
for (const node of elements(blip)) blip.removeChild(node);
|
|
2955
3062
|
for (const node of nodes) blip.appendChild(node);
|
|
2956
3063
|
}
|
|
2957
3064
|
|
|
3065
|
+
// drawingml/picture-layout.ts
|
|
3066
|
+
function parsePictureLayout(fill) {
|
|
3067
|
+
const out = {};
|
|
3068
|
+
const rot = fill.getAttribute("rotWithShape");
|
|
3069
|
+
if (rot !== null) out.rotWithShape = rot !== "0" && rot !== "false";
|
|
3070
|
+
const dpi = Number(fill.getAttribute("dpi"));
|
|
3071
|
+
if (fill.hasAttribute("dpi") && Number.isFinite(dpi) && dpi > 0) out.dpi = dpi;
|
|
3072
|
+
const tile = first(fill, "tile", NS.a);
|
|
3073
|
+
if (tile) {
|
|
3074
|
+
const value = {};
|
|
3075
|
+
for (const [key, attr2] of [
|
|
3076
|
+
["scaleX", "sx"],
|
|
3077
|
+
["scaleY", "sy"]
|
|
3078
|
+
]) {
|
|
3079
|
+
const n2 = picturePercentage(tile.getAttribute(attr2));
|
|
3080
|
+
if (n2 !== void 0) value[key] = n2;
|
|
3081
|
+
}
|
|
3082
|
+
for (const [key, attr2] of [
|
|
3083
|
+
["offsetXEmu", "tx"],
|
|
3084
|
+
["offsetYEmu", "ty"]
|
|
3085
|
+
]) {
|
|
3086
|
+
const raw = tile.getAttribute(attr2);
|
|
3087
|
+
const n2 = raw === null ? NaN : Number(raw);
|
|
3088
|
+
if (Number.isSafeInteger(n2)) value[key] = n2;
|
|
3089
|
+
}
|
|
3090
|
+
const alignment = tile.getAttribute("algn");
|
|
3091
|
+
if (alignment) value.alignment = alignment;
|
|
3092
|
+
const flip = tile.getAttribute("flip");
|
|
3093
|
+
if (flip && ["none", "x", "y", "xy"].includes(flip))
|
|
3094
|
+
value.flip = flip;
|
|
3095
|
+
out.tile = value;
|
|
3096
|
+
}
|
|
3097
|
+
const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
|
|
3098
|
+
if (rect3)
|
|
3099
|
+
out.fillRect = {
|
|
3100
|
+
l: picturePercentage(rect3.getAttribute("l")) ?? 0,
|
|
3101
|
+
t: picturePercentage(rect3.getAttribute("t")) ?? 0,
|
|
3102
|
+
r: picturePercentage(rect3.getAttribute("r")) ?? 0,
|
|
3103
|
+
b: picturePercentage(rect3.getAttribute("b")) ?? 0
|
|
3104
|
+
};
|
|
3105
|
+
return out;
|
|
3106
|
+
}
|
|
3107
|
+
function applyPictureLayout(fill, layout) {
|
|
3108
|
+
const before = parsePictureLayout(fill);
|
|
3109
|
+
const attr2 = (node, name, value, old) => {
|
|
3110
|
+
if (value === old) return;
|
|
3111
|
+
if (value === void 0) node.removeAttribute(name);
|
|
3112
|
+
else node.setAttribute(name, String(value));
|
|
3113
|
+
};
|
|
3114
|
+
if (layout.rotWithShape !== before.rotWithShape)
|
|
3115
|
+
attr2(
|
|
3116
|
+
fill,
|
|
3117
|
+
"rotWithShape",
|
|
3118
|
+
layout.rotWithShape === void 0 ? void 0 : layout.rotWithShape ? "1" : "0",
|
|
3119
|
+
void 0
|
|
3120
|
+
);
|
|
3121
|
+
if (layout.dpi !== before.dpi) {
|
|
3122
|
+
if (layout.dpi !== void 0 && (!Number.isSafeInteger(layout.dpi) || layout.dpi <= 0))
|
|
3123
|
+
throw new RangeError("Invalid picture DPI");
|
|
3124
|
+
attr2(fill, "dpi", layout.dpi, void 0);
|
|
3125
|
+
}
|
|
3126
|
+
const make = (parent, name) => {
|
|
3127
|
+
const old = first(parent, name, NS.a);
|
|
3128
|
+
if (old) return old;
|
|
3129
|
+
const node = fill.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
3130
|
+
parent.insertBefore(node, first(parent, "extLst", NS.a) ?? null);
|
|
3131
|
+
return node;
|
|
3132
|
+
};
|
|
3133
|
+
if (layout.tile) {
|
|
3134
|
+
const stretch = first(fill, "stretch", NS.a);
|
|
3135
|
+
if (stretch) fill.removeChild(stretch);
|
|
3136
|
+
const tile = make(fill, "tile");
|
|
3137
|
+
for (const [key, name] of [
|
|
3138
|
+
["scaleX", "sx"],
|
|
3139
|
+
["scaleY", "sy"],
|
|
3140
|
+
["offsetXEmu", "tx"],
|
|
3141
|
+
["offsetYEmu", "ty"]
|
|
3142
|
+
]) {
|
|
3143
|
+
const n2 = layout.tile[key];
|
|
3144
|
+
if (n2 !== void 0 && (!Number.isFinite(n2) || (name === "sx" || name === "sy" ? n2 <= 0 : !Number.isSafeInteger(n2))))
|
|
3145
|
+
throw new RangeError("Invalid picture tile");
|
|
3146
|
+
if (n2 !== before.tile?.[key])
|
|
3147
|
+
attr2(
|
|
3148
|
+
tile,
|
|
3149
|
+
name,
|
|
3150
|
+
n2 === void 0 ? void 0 : Math.round(n2 * (name === "sx" || name === "sy" ? 1e5 : 1)),
|
|
3151
|
+
void 0
|
|
3152
|
+
);
|
|
3153
|
+
}
|
|
3154
|
+
if (layout.tile.alignment !== before.tile?.alignment) {
|
|
3155
|
+
if (layout.tile.alignment && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(layout.tile.alignment))
|
|
3156
|
+
throw new RangeError("Invalid picture tile alignment");
|
|
3157
|
+
attr2(tile, "algn", layout.tile.alignment, void 0);
|
|
3158
|
+
}
|
|
3159
|
+
if (layout.tile.flip !== void 0 && !["none", "x", "y", "xy"].includes(layout.tile.flip))
|
|
3160
|
+
throw new RangeError("Invalid picture tile flip");
|
|
3161
|
+
if (layout.tile.flip !== before.tile?.flip) attr2(tile, "flip", layout.tile.flip, void 0);
|
|
3162
|
+
} else if (before.tile || layout.fillRect) {
|
|
3163
|
+
const tile = first(fill, "tile", NS.a);
|
|
3164
|
+
if (tile) fill.removeChild(tile);
|
|
3165
|
+
const rect3 = make(make(fill, "stretch"), "fillRect");
|
|
3166
|
+
for (const key of ["l", "t", "r", "b"]) {
|
|
3167
|
+
const n2 = layout.fillRect?.[key];
|
|
3168
|
+
if (n2 !== void 0 && !Number.isFinite(n2))
|
|
3169
|
+
throw new RangeError("Invalid picture fill rectangle");
|
|
3170
|
+
if (n2 !== before.fillRect?.[key])
|
|
3171
|
+
attr2(rect3, key, n2 === void 0 ? void 0 : Math.round(n2 * 1e5), void 0);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
|
|
2958
3176
|
// drawingml/picture-fill.ts
|
|
2959
3177
|
function parseDrawingPictureFill(fill) {
|
|
2960
3178
|
const blip = first(fill, "blip", NS.a);
|
|
@@ -2962,13 +3180,32 @@ function parseDrawingPictureFill(fill) {
|
|
|
2962
3180
|
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
2963
3181
|
const crop = parsePictureCrop(fill);
|
|
2964
3182
|
const effects = parsePictureEffects(blip);
|
|
2965
|
-
const
|
|
2966
|
-
const
|
|
2967
|
-
const
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3183
|
+
const layout = parsePictureLayout(fill);
|
|
3184
|
+
const unsupported = [];
|
|
3185
|
+
const tile = first(fill, "tile", NS.a), stretch = first(fill, "stretch", NS.a);
|
|
3186
|
+
if (tile && stretch) unsupported.push("tile/stretch-choice");
|
|
3187
|
+
if (tile) {
|
|
3188
|
+
for (const [attr2, key] of [
|
|
3189
|
+
["sx", "scaleX"],
|
|
3190
|
+
["sy", "scaleY"],
|
|
3191
|
+
["tx", "offsetXEmu"],
|
|
3192
|
+
["ty", "offsetYEmu"]
|
|
3193
|
+
])
|
|
3194
|
+
if (tile.hasAttribute(attr2) && (layout.tile?.[key] === void 0 || (attr2 === "sx" || attr2 === "sy") && layout.tile[key] <= 0))
|
|
3195
|
+
unsupported.push(`tile:${attr2}`);
|
|
3196
|
+
if (tile.hasAttribute("algn") && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(tile.getAttribute("algn") ?? ""))
|
|
3197
|
+
unsupported.push("tile:algn");
|
|
3198
|
+
if (tile.hasAttribute("flip") && !layout.tile?.flip) unsupported.push("tile:flip");
|
|
3199
|
+
}
|
|
3200
|
+
const rect3 = first(stretch, "fillRect", NS.a);
|
|
3201
|
+
if (rect3)
|
|
3202
|
+
for (const key of ["l", "t", "r", "b"]) {
|
|
3203
|
+
const raw = rect3.getAttribute(key);
|
|
3204
|
+
if (raw !== null && !/^[-+]?(?:\d+\.?\d*|\.\d+)%?$/.test(raw))
|
|
3205
|
+
unsupported.push(`fillRect:${key}`);
|
|
3206
|
+
}
|
|
3207
|
+
if (fill.hasAttribute("rotWithShape") && !["0", "1", "true", "false"].includes(fill.getAttribute("rotWithShape") ?? ""))
|
|
3208
|
+
unsupported.push("rotWithShape");
|
|
2972
3209
|
return {
|
|
2973
3210
|
kind: "picture",
|
|
2974
3211
|
sourceXml: buildXml(fill),
|
|
@@ -2976,10 +3213,180 @@ function parseDrawingPictureFill(fill) {
|
|
|
2976
3213
|
...linkRelId ? { linkRelId } : {},
|
|
2977
3214
|
...crop ? { crop } : {},
|
|
2978
3215
|
...effects.length ? { effects } : {},
|
|
3216
|
+
...Object.keys(layout).length ? { layout } : {},
|
|
2979
3217
|
...unsupported.length ? { unsupportedPicture: unsupported } : {}
|
|
2980
3218
|
};
|
|
2981
3219
|
}
|
|
2982
3220
|
|
|
3221
|
+
// opc/signature/xml-utils.ts
|
|
3222
|
+
function escapeXmlAttr(value) {
|
|
3223
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
// docx/watermark.ts
|
|
3227
|
+
var VML_NS = "urn:schemas-microsoft-com:vml";
|
|
3228
|
+
var OFFICE_NS = "urn:schemas-microsoft-com:office:office";
|
|
3229
|
+
var WORD10_NS = "urn:schemas-microsoft-com:office:word";
|
|
3230
|
+
var WATERMARK_PREFIX = "PowerPlusWaterMarkObject";
|
|
3231
|
+
function watermarkSizePt(spec) {
|
|
3232
|
+
const chars = Math.max(1, [...spec.text].length);
|
|
3233
|
+
const width = Math.min(spec.layout === "diagonal" ? 527 : 468, Math.max(150, chars * 44));
|
|
3234
|
+
return { width, height: Math.round(width / (chars * 0.55) * 100) / 100 };
|
|
3235
|
+
}
|
|
3236
|
+
var FORMULAS = [
|
|
3237
|
+
"sum #0 0 10800",
|
|
3238
|
+
"prod #0 2 1",
|
|
3239
|
+
"sum 21600 0 @1",
|
|
3240
|
+
"sum 0 0 @2",
|
|
3241
|
+
"sum 21600 0 @3",
|
|
3242
|
+
"if @0 @3 0",
|
|
3243
|
+
"if @0 21600 @1",
|
|
3244
|
+
"if @0 0 @2",
|
|
3245
|
+
"if @0 @4 21600",
|
|
3246
|
+
"mid @5 @6",
|
|
3247
|
+
"mid @8 @5",
|
|
3248
|
+
"mid @7 @8",
|
|
3249
|
+
"mid @6 @7",
|
|
3250
|
+
"sum @6 0 @5"
|
|
3251
|
+
];
|
|
3252
|
+
function buildWatermarkRun(doc, spec, uniqueId) {
|
|
3253
|
+
const v = (name) => makeNS(doc, VML_NS, `v:${name}`);
|
|
3254
|
+
const run = makeW(doc, "r");
|
|
3255
|
+
const props = makeW(doc, "rPr");
|
|
3256
|
+
props.appendChild(makeW(doc, "noProof"));
|
|
3257
|
+
run.appendChild(props);
|
|
3258
|
+
const pict = makeW(doc, "pict");
|
|
3259
|
+
const type = v("shapetype");
|
|
3260
|
+
type.setAttribute("id", "_x0000_t136");
|
|
3261
|
+
type.setAttribute("coordsize", "21600,21600");
|
|
3262
|
+
type.setAttributeNS(OFFICE_NS, "o:spt", "136");
|
|
3263
|
+
type.setAttribute("adj", "10800");
|
|
3264
|
+
type.setAttribute("path", "m@7,l@8,m@5,21600l@6,21600e");
|
|
3265
|
+
const formulas = v("formulas");
|
|
3266
|
+
for (const eqn of FORMULAS) {
|
|
3267
|
+
const f = v("f");
|
|
3268
|
+
f.setAttribute("eqn", eqn);
|
|
3269
|
+
formulas.appendChild(f);
|
|
3270
|
+
}
|
|
3271
|
+
const path = v("path");
|
|
3272
|
+
path.setAttribute("textpathok", "t");
|
|
3273
|
+
path.setAttributeNS(OFFICE_NS, "o:connecttype", "custom");
|
|
3274
|
+
path.setAttributeNS(OFFICE_NS, "o:connectlocs", "@9,0;@10,10800;@11,21600;@12,10800");
|
|
3275
|
+
path.setAttributeNS(OFFICE_NS, "o:connectangles", "270,180,90,0");
|
|
3276
|
+
const typePath = v("textpath");
|
|
3277
|
+
typePath.setAttribute("on", "t");
|
|
3278
|
+
typePath.setAttribute("fitshape", "t");
|
|
3279
|
+
const handles = v("handles");
|
|
3280
|
+
const handle = v("h");
|
|
3281
|
+
handle.setAttribute("position", "#0,bottomRight");
|
|
3282
|
+
handle.setAttribute("xrange", "6629,14971");
|
|
3283
|
+
handles.appendChild(handle);
|
|
3284
|
+
const lock = makeNS(doc, OFFICE_NS, "o:lock");
|
|
3285
|
+
lock.setAttributeNS(VML_NS, "v:ext", "edit");
|
|
3286
|
+
lock.setAttribute("text", "t");
|
|
3287
|
+
lock.setAttribute("shapetype", "t");
|
|
3288
|
+
for (const child3 of [formulas, path, typePath, handles, lock]) type.appendChild(child3);
|
|
3289
|
+
const size = watermarkSizePt(spec);
|
|
3290
|
+
const shape = v("shape");
|
|
3291
|
+
shape.setAttribute("id", `${WATERMARK_PREFIX}${uniqueId}`);
|
|
3292
|
+
shape.setAttributeNS(OFFICE_NS, "o:spid", `_x0000_s${2048 + (Number(uniqueId) || 1)}`);
|
|
3293
|
+
shape.setAttribute("type", "#_x0000_t136");
|
|
3294
|
+
shape.setAttribute(
|
|
3295
|
+
"style",
|
|
3296
|
+
`position:absolute;margin-left:0;margin-top:0;width:${size.width}pt;height:${size.height}pt;${spec.layout === "diagonal" ? "rotation:315;" : ""}z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin`
|
|
3297
|
+
);
|
|
3298
|
+
shape.setAttributeNS(OFFICE_NS, "o:allowincell", "f");
|
|
3299
|
+
shape.setAttribute("fillcolor", spec.color.replace(/^#/, "").toLowerCase());
|
|
3300
|
+
shape.setAttribute("stroked", "f");
|
|
3301
|
+
const fill = v("fill");
|
|
3302
|
+
fill.setAttribute("opacity", spec.semitransparent ? ".5" : "1");
|
|
3303
|
+
const text2 = v("textpath");
|
|
3304
|
+
text2.setAttribute("style", `font-family:"${spec.fontFamily ?? "Calibri"}";font-size:1pt`);
|
|
3305
|
+
text2.setAttribute("string", spec.text);
|
|
3306
|
+
const wrap = makeNS(doc, WORD10_NS, "w10:wrap");
|
|
3307
|
+
wrap.setAttribute("anchorx", "margin");
|
|
3308
|
+
wrap.setAttribute("anchory", "margin");
|
|
3309
|
+
for (const child3 of [fill, text2, wrap]) shape.appendChild(child3);
|
|
3310
|
+
pict.appendChild(type);
|
|
3311
|
+
pict.appendChild(shape);
|
|
3312
|
+
run.appendChild(pict);
|
|
3313
|
+
return run;
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
// docx/write-text-box.ts
|
|
3317
|
+
var A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
3318
|
+
var WP_NS = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
3319
|
+
var WPS_NS = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
3320
|
+
var W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
3321
|
+
var el = (doc, ns, name) => makeNS(doc, ns, name);
|
|
3322
|
+
var add = (parent, ...items) => {
|
|
3323
|
+
for (const item2 of items) parent.appendChild(item2);
|
|
3324
|
+
return parent;
|
|
3325
|
+
};
|
|
3326
|
+
var emu = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
|
|
3327
|
+
var descendants2 = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
|
|
3328
|
+
function paragraphsFor(doc, lines) {
|
|
3329
|
+
return (lines.length ? lines : [""]).map((line4) => {
|
|
3330
|
+
const paragraph = makeW(doc, "p");
|
|
3331
|
+
if (line4) {
|
|
3332
|
+
const run = makeW(doc, "r");
|
|
3333
|
+
const text2 = makeW(doc, "t");
|
|
3334
|
+
if (/^\s|\s$/.test(line4))
|
|
3335
|
+
text2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
|
|
3336
|
+
text2.textContent = line4;
|
|
3337
|
+
add(run, text2);
|
|
3338
|
+
add(paragraph, run);
|
|
3339
|
+
}
|
|
3340
|
+
return paragraph;
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
function outline(doc, border) {
|
|
3344
|
+
const ln = el(doc, A_NS, "a:ln");
|
|
3345
|
+
if (!border) return add(ln, el(doc, A_NS, "a:noFill"));
|
|
3346
|
+
ln.setAttribute("w", "9525");
|
|
3347
|
+
const color = el(doc, A_NS, "a:srgbClr");
|
|
3348
|
+
color.setAttribute("val", "000000");
|
|
3349
|
+
return add(ln, add(el(doc, A_NS, "a:solidFill"), color));
|
|
3350
|
+
}
|
|
3351
|
+
function patchTextBox(doc, drawing, image, base) {
|
|
3352
|
+
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
3353
|
+
for (const node of [
|
|
3354
|
+
...descendants2(drawing, WP_NS, "extent"),
|
|
3355
|
+
...descendants2(drawing, A_NS, "ext").filter(
|
|
3356
|
+
(ext) => ext.parentNode?.localName === "xfrm"
|
|
3357
|
+
)
|
|
3358
|
+
]) {
|
|
3359
|
+
node.setAttribute("cx", emu(image.widthPx));
|
|
3360
|
+
node.setAttribute("cy", emu(image.heightPx));
|
|
3361
|
+
}
|
|
3362
|
+
if (JSON.stringify(image.textBoxText) !== JSON.stringify(base.textBoxText)) {
|
|
3363
|
+
const content = descendants2(drawing, W_NS, "txbxContent")[0];
|
|
3364
|
+
if (content) {
|
|
3365
|
+
for (const child3 of Array.from(content.childNodes)) content.removeChild(child3);
|
|
3366
|
+
add(content, ...paragraphsFor(doc, image.textBoxText ?? []));
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
if (image.textBoxBorder !== false !== (base.textBoxBorder !== false)) {
|
|
3370
|
+
const spPr = descendants2(drawing, WPS_NS, "spPr")[0];
|
|
3371
|
+
if (spPr) {
|
|
3372
|
+
for (const old of Array.from(spPr.childNodes).filter(
|
|
3373
|
+
(node) => isElement(node) && node.localName === "ln"
|
|
3374
|
+
))
|
|
3375
|
+
spPr.removeChild(old);
|
|
3376
|
+
spPr.appendChild(outline(doc, image.textBoxBorder !== false));
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
// drawingml/drawing-color-css.ts
|
|
3382
|
+
function drawingColorCss(value) {
|
|
3383
|
+
if (!value || value.alpha === 1) return value?.hex;
|
|
3384
|
+
const channels = [1, 3, 5].map(
|
|
3385
|
+
(offset) => Number.parseInt(value.hex.slice(offset, offset + 2), 16)
|
|
3386
|
+
);
|
|
3387
|
+
return `rgba(${channels.join(",")},${value.alpha})`;
|
|
3388
|
+
}
|
|
3389
|
+
|
|
2983
3390
|
// drawingml/drawing-fill.ts
|
|
2984
3391
|
var FILL_ELEMENTS = /* @__PURE__ */ new Set([
|
|
2985
3392
|
"noFill",
|
|
@@ -3058,22 +3465,22 @@ function parseDrawingFill(properties3) {
|
|
|
3058
3465
|
}
|
|
3059
3466
|
function parseDrawingLine(ln) {
|
|
3060
3467
|
if (!ln) return void 0;
|
|
3061
|
-
const
|
|
3468
|
+
const line4 = { sourceXml: buildXml(ln) };
|
|
3062
3469
|
const width = Number.parseInt(ln.getAttribute("w") ?? "", 10);
|
|
3063
|
-
if (Number.isFinite(width))
|
|
3470
|
+
if (Number.isFinite(width)) line4.widthEmu = width;
|
|
3064
3471
|
const fill = parseDrawingFill(ln);
|
|
3065
|
-
if (fill)
|
|
3472
|
+
if (fill) line4.fill = fill;
|
|
3066
3473
|
const dash = first(ln, "prstDash", NS.a)?.getAttribute("val");
|
|
3067
|
-
if (dash)
|
|
3474
|
+
if (dash) line4.dash = dash;
|
|
3068
3475
|
const cap = ln.getAttribute("cap");
|
|
3069
|
-
if (cap)
|
|
3476
|
+
if (cap) line4.cap = cap;
|
|
3070
3477
|
const compound = ln.getAttribute("cmpd");
|
|
3071
|
-
if (compound !== null)
|
|
3478
|
+
if (compound !== null) line4.compound = compound;
|
|
3072
3479
|
const alignment = ln.getAttribute("algn");
|
|
3073
|
-
if (alignment !== null)
|
|
3480
|
+
if (alignment !== null) line4.alignment = alignment;
|
|
3074
3481
|
const custom = first(ln, "custDash", NS.a);
|
|
3075
3482
|
if (custom && !dash) {
|
|
3076
|
-
|
|
3483
|
+
line4.customDash = children(custom, "ds", NS.a).flatMap((node) => {
|
|
3077
3484
|
const dash2 = drawingDashLength(node.getAttribute("d"));
|
|
3078
3485
|
const space = drawingDashLength(node.getAttribute("sp"));
|
|
3079
3486
|
return dash2 !== void 0 && space !== void 0 ? [{ dash: dash2, space, sourceXml: buildXml(node) }] : [];
|
|
@@ -3083,23 +3490,23 @@ function parseDrawingLine(ln) {
|
|
|
3083
3490
|
const join = first(ln, kind, NS.a);
|
|
3084
3491
|
if (!join) continue;
|
|
3085
3492
|
const limit = Number(join.getAttribute("lim"));
|
|
3086
|
-
|
|
3493
|
+
line4.join = { kind, ...join.hasAttribute("lim") && Number.isFinite(limit) ? { limit } : {} };
|
|
3087
3494
|
break;
|
|
3088
3495
|
}
|
|
3089
3496
|
for (const end of ["headEnd", "tailEnd"]) {
|
|
3090
3497
|
const node = first(ln, end, NS.a);
|
|
3091
3498
|
if (!node) continue;
|
|
3092
|
-
|
|
3499
|
+
line4[end] = {};
|
|
3093
3500
|
for (const [attribute, key] of [
|
|
3094
3501
|
["type", "type"],
|
|
3095
3502
|
["w", "width"],
|
|
3096
3503
|
["len", "length"]
|
|
3097
3504
|
]) {
|
|
3098
3505
|
const value = node.getAttribute(attribute);
|
|
3099
|
-
if (value !== null)
|
|
3506
|
+
if (value !== null) line4[end][key] = value;
|
|
3100
3507
|
}
|
|
3101
3508
|
}
|
|
3102
|
-
return
|
|
3509
|
+
return line4;
|
|
3103
3510
|
}
|
|
3104
3511
|
function drawingDashLength(value) {
|
|
3105
3512
|
if (!/^\d+$/u.test(value ?? "")) return void 0;
|
|
@@ -3295,80 +3702,6 @@ function evaluateGuides(guides, ctx, adjustments) {
|
|
|
3295
3702
|
return vars;
|
|
3296
3703
|
}
|
|
3297
3704
|
|
|
3298
|
-
// drawingml/write-color.ts
|
|
3299
|
-
var ELEMENTS = {
|
|
3300
|
-
srgb: "srgbClr",
|
|
3301
|
-
scheme: "schemeClr",
|
|
3302
|
-
system: "sysClr",
|
|
3303
|
-
preset: "prstClr",
|
|
3304
|
-
scrgb: "scrgbClr",
|
|
3305
|
-
hsl: "hslClr"
|
|
3306
|
-
};
|
|
3307
|
-
function drawingColorXml(color) {
|
|
3308
|
-
const local = ELEMENTS[color.kind];
|
|
3309
|
-
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
3310
|
-
const root = doc.documentElement;
|
|
3311
|
-
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
3312
|
-
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
3313
|
-
const values = color.value.split(",");
|
|
3314
|
-
keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
|
|
3315
|
-
} else root.setAttribute("val", color.value);
|
|
3316
|
-
if (color.fallback !== void 0 && color.kind === "system")
|
|
3317
|
-
root.setAttribute("lastClr", color.fallback);
|
|
3318
|
-
for (const transform of color.transforms) {
|
|
3319
|
-
if (!/^[A-Za-z_][\w.-]*$/.test(transform.name))
|
|
3320
|
-
throw new Error(`Invalid DrawingML transform ${transform.name}`);
|
|
3321
|
-
const node = doc.createElementNS(NS.a, `a:${transform.name}`);
|
|
3322
|
-
if (transform.value !== "") node.setAttribute("val", transform.value);
|
|
3323
|
-
root.appendChild(node);
|
|
3324
|
-
}
|
|
3325
|
-
return buildXml(doc);
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
|
-
// drawingml/patch-color.ts
|
|
3329
|
-
function patchDrawingColorIn(container, color) {
|
|
3330
|
-
const old = elements(container).find((node) => parseDrawingColor(node));
|
|
3331
|
-
const before = parseDrawingColorIn(container);
|
|
3332
|
-
if (!old || !before || before.kind !== color.kind) {
|
|
3333
|
-
const next = container.ownerDocument.importNode(
|
|
3334
|
-
parseXml(drawingColorXml(color)).documentElement,
|
|
3335
|
-
true
|
|
3336
|
-
);
|
|
3337
|
-
if (old) container.replaceChild(next, old);
|
|
3338
|
-
else container.insertBefore(next, container.firstChild);
|
|
3339
|
-
return;
|
|
3340
|
-
}
|
|
3341
|
-
if (before.value !== color.value) {
|
|
3342
|
-
if (color.kind === "scrgb" || color.kind === "hsl") {
|
|
3343
|
-
const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
3344
|
-
const values = color.value.split(",");
|
|
3345
|
-
keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
|
|
3346
|
-
} else old.setAttribute("val", color.value);
|
|
3347
|
-
}
|
|
3348
|
-
if (before.fallback !== color.fallback && color.kind === "system") {
|
|
3349
|
-
if (color.fallback === void 0) old.removeAttribute("lastClr");
|
|
3350
|
-
else old.setAttribute("lastClr", color.fallback);
|
|
3351
|
-
}
|
|
3352
|
-
const originals = elements(old);
|
|
3353
|
-
color.transforms.forEach((transform, index) => {
|
|
3354
|
-
const source = originals[index];
|
|
3355
|
-
if (source?.localName === transform.name) {
|
|
3356
|
-
if (before.transforms[index]?.value !== transform.value) {
|
|
3357
|
-
if (transform.value === "") source.removeAttribute("val");
|
|
3358
|
-
else source.setAttribute("val", transform.value);
|
|
3359
|
-
}
|
|
3360
|
-
return;
|
|
3361
|
-
}
|
|
3362
|
-
if (!/^[A-Za-z_][\w.-]*$/u.test(transform.name))
|
|
3363
|
-
throw new Error("Invalid DrawingML colour transform");
|
|
3364
|
-
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform.name}`);
|
|
3365
|
-
if (transform.value !== "") next.setAttribute("val", transform.value);
|
|
3366
|
-
if (source) old.replaceChild(next, source);
|
|
3367
|
-
else old.appendChild(next);
|
|
3368
|
-
});
|
|
3369
|
-
for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
|
|
3370
|
-
}
|
|
3371
|
-
|
|
3372
3705
|
// drawingml/write-pattern-picture.ts
|
|
3373
3706
|
function drawingPatternPictureXml(fill) {
|
|
3374
3707
|
const name = fill.kind === "pattern" ? "pattFill" : "blipFill";
|
|
@@ -3430,7 +3763,8 @@ function drawingPatternPictureXml(fill) {
|
|
|
3430
3763
|
applyPictureCrop(root, fill.crop);
|
|
3431
3764
|
if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
|
|
3432
3765
|
applyPictureEffects(blip, fill.effects ?? []);
|
|
3433
|
-
if (
|
|
3766
|
+
if (fill.layout !== void 0) applyPictureLayout(root, fill.layout);
|
|
3767
|
+
if (!fill.sourceXml && !fill.layout?.tile && !first(root, "stretch", NS.a)) {
|
|
3434
3768
|
const stretch = doc.createElementNS(NS.a, "a:stretch");
|
|
3435
3769
|
stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
|
|
3436
3770
|
root.appendChild(stretch);
|
|
@@ -3667,29 +4001,29 @@ function remove(host, names) {
|
|
|
3667
4001
|
for (const child3 of elements(host))
|
|
3668
4002
|
if (child3.namespaceURI === NS.a && names.includes(child3.localName)) host.removeChild(child3);
|
|
3669
4003
|
}
|
|
3670
|
-
function patchDrawingLine(ln,
|
|
3671
|
-
const before =
|
|
3672
|
-
const changed = (key) => !before || !same(before[key],
|
|
4004
|
+
function patchDrawingLine(ln, line4) {
|
|
4005
|
+
const before = line4.sourceXml ? parseDrawingLine(ln) : void 0;
|
|
4006
|
+
const changed = (key) => !before || !same(before[key], line4[key]);
|
|
3673
4007
|
for (const [key, attribute] of [
|
|
3674
4008
|
["widthEmu", "w"],
|
|
3675
4009
|
["cap", "cap"],
|
|
3676
4010
|
["compound", "cmpd"],
|
|
3677
4011
|
["alignment", "algn"]
|
|
3678
4012
|
]) {
|
|
3679
|
-
if (!changed(key) || (key === "compound" || key === "alignment") && !
|
|
4013
|
+
if (!changed(key) || (key === "compound" || key === "alignment") && !line4.sourceXml && !(key in line4))
|
|
3680
4014
|
continue;
|
|
3681
|
-
const value =
|
|
4015
|
+
const value = line4[key];
|
|
3682
4016
|
if (value === void 0) ln.removeAttribute(attribute);
|
|
3683
4017
|
else ln.setAttribute(attribute, String(typeof value === "number" ? Math.round(value) : value));
|
|
3684
4018
|
}
|
|
3685
4019
|
if (changed("fill")) {
|
|
3686
|
-
if (
|
|
4020
|
+
if (line4.fill?.kind === "picture")
|
|
3687
4021
|
throw new Error("Picture fills are not supported on DrawingML outlines");
|
|
3688
4022
|
const solid = first(ln, "solidFill", NS.a);
|
|
3689
|
-
if (solid &&
|
|
4023
|
+
if (solid && line4.fill?.kind === "solid") patchDrawingColorIn(solid, line4.fill.color);
|
|
3690
4024
|
else {
|
|
3691
|
-
const xml =
|
|
3692
|
-
if (xml || !
|
|
4025
|
+
const xml = line4.fill && drawingFillXml(line4.fill);
|
|
4026
|
+
if (xml || !line4.fill) remove(ln, FILLS);
|
|
3693
4027
|
if (xml) {
|
|
3694
4028
|
const child3 = importXml(ln, xml);
|
|
3695
4029
|
dropDrawingDeclarations(child3);
|
|
@@ -3697,21 +4031,21 @@ function patchDrawingLine(ln, line3) {
|
|
|
3697
4031
|
}
|
|
3698
4032
|
}
|
|
3699
4033
|
}
|
|
3700
|
-
if (changed("dash") || changed("customDash")) patchDash(ln,
|
|
3701
|
-
if ((
|
|
3702
|
-
const original =
|
|
4034
|
+
if (changed("dash") || changed("customDash")) patchDash(ln, line4);
|
|
4035
|
+
if ((line4.sourceXml || "join" in line4) && changed("join")) {
|
|
4036
|
+
const original = line4.join && first(ln, line4.join.kind, NS.a);
|
|
3703
4037
|
const node = original?.cloneNode(true);
|
|
3704
4038
|
remove(ln, ["round", "bevel", "miter"]);
|
|
3705
|
-
if (
|
|
3706
|
-
const next = node ?? ln.ownerDocument.createElementNS(NS.a, `a:${
|
|
3707
|
-
if (
|
|
3708
|
-
else next.setAttribute("lim", String(
|
|
4039
|
+
if (line4.join) {
|
|
4040
|
+
const next = node ?? ln.ownerDocument.createElementNS(NS.a, `a:${line4.join.kind}`);
|
|
4041
|
+
if (line4.join.limit === void 0) next.removeAttribute("lim");
|
|
4042
|
+
else next.setAttribute("lim", String(line4.join.limit));
|
|
3709
4043
|
insert(ln, next);
|
|
3710
4044
|
}
|
|
3711
4045
|
}
|
|
3712
4046
|
for (const key of ["headEnd", "tailEnd"]) {
|
|
3713
|
-
if (!
|
|
3714
|
-
const end =
|
|
4047
|
+
if (!line4.sourceXml && !(key in line4) || !changed(key)) continue;
|
|
4048
|
+
const end = line4[key];
|
|
3715
4049
|
const old = first(ln, key, NS.a);
|
|
3716
4050
|
if (!end) {
|
|
3717
4051
|
if (old) ln.removeChild(old);
|
|
@@ -3730,15 +4064,15 @@ function patchDrawingLine(ln, line3) {
|
|
|
3730
4064
|
if (!old) insert(ln, node);
|
|
3731
4065
|
}
|
|
3732
4066
|
}
|
|
3733
|
-
function patchDash(ln,
|
|
3734
|
-
if (
|
|
3735
|
-
remove(ln,
|
|
4067
|
+
function patchDash(ln, line4) {
|
|
4068
|
+
if (line4.dash === void 0 && line4.customDash === void 0) {
|
|
4069
|
+
remove(ln, line4.sourceXml ? ["prstDash", "custDash"] : ["prstDash"]);
|
|
3736
4070
|
return;
|
|
3737
4071
|
}
|
|
3738
|
-
if (
|
|
4072
|
+
if (line4.dash !== void 0) {
|
|
3739
4073
|
remove(ln, ["prstDash", "custDash"]);
|
|
3740
4074
|
const node2 = ln.ownerDocument.createElementNS(NS.a, "a:prstDash");
|
|
3741
|
-
node2.setAttribute("val",
|
|
4075
|
+
node2.setAttribute("val", line4.dash);
|
|
3742
4076
|
insert(ln, node2);
|
|
3743
4077
|
return;
|
|
3744
4078
|
}
|
|
@@ -3748,7 +4082,7 @@ function patchDash(ln, line3) {
|
|
|
3748
4082
|
const stops = elements(node).filter(
|
|
3749
4083
|
(stop) => stop.namespaceURI === NS.a && stop.localName === "ds" && drawingDashLength(stop.getAttribute("d")) !== void 0 && drawingDashLength(stop.getAttribute("sp")) !== void 0
|
|
3750
4084
|
);
|
|
3751
|
-
|
|
4085
|
+
line4.customDash?.forEach((stop, index) => {
|
|
3752
4086
|
if (drawingDashLength(String(stop.dash)) === void 0 || drawingDashLength(String(stop.space)) === void 0)
|
|
3753
4087
|
throw new Error("Invalid DrawingML custom dash length");
|
|
3754
4088
|
const next = stops[index] ?? (stop.sourceXml ? importXml(ln, stop.sourceXml) : ln.ownerDocument.createElementNS(NS.a, "a:ds"));
|
|
@@ -3756,15 +4090,15 @@ function patchDash(ln, line3) {
|
|
|
3756
4090
|
next.setAttribute("sp", String(stop.space));
|
|
3757
4091
|
if (!next.parentNode) node.appendChild(next);
|
|
3758
4092
|
});
|
|
3759
|
-
for (const stop of stops.slice(
|
|
4093
|
+
for (const stop of stops.slice(line4.customDash?.length ?? 0)) node.removeChild(stop);
|
|
3760
4094
|
remove(ln, ["prstDash", "custDash"]);
|
|
3761
4095
|
insert(ln, node);
|
|
3762
4096
|
}
|
|
3763
|
-
function drawingLineXml(
|
|
3764
|
-
const doc = parseXml(
|
|
4097
|
+
function drawingLineXml(line4) {
|
|
4098
|
+
const doc = parseXml(line4.sourceXml ?? `<a:ln xmlns:a="${NS.a}"/>`);
|
|
3765
4099
|
if (doc.documentElement.namespaceURI !== NS.a || doc.documentElement.localName !== "ln")
|
|
3766
4100
|
throw new Error("Invalid DrawingML outline source XML");
|
|
3767
|
-
patchDrawingLine(doc.documentElement,
|
|
4101
|
+
patchDrawingLine(doc.documentElement, line4);
|
|
3768
4102
|
return buildXml(doc);
|
|
3769
4103
|
}
|
|
3770
4104
|
|
|
@@ -4038,8 +4372,8 @@ function readChild(child3, out, extra) {
|
|
|
4038
4372
|
return;
|
|
4039
4373
|
}
|
|
4040
4374
|
if (name === "ln") {
|
|
4041
|
-
const
|
|
4042
|
-
if (
|
|
4375
|
+
const line4 = parseDrawingLine(child3);
|
|
4376
|
+
if (line4) out.line = line4;
|
|
4043
4377
|
out.lineSourceXml = outerXml(child3);
|
|
4044
4378
|
} else if (name in FONT_SLOTS) {
|
|
4045
4379
|
const font = parseDrawingFont(child3);
|
|
@@ -13929,7 +14263,7 @@ function isSpace(ch) {
|
|
|
13929
14263
|
return ch === " " || ch === " " || ch === "\n" || ch === "\r";
|
|
13930
14264
|
}
|
|
13931
14265
|
function parseAttributes(source) {
|
|
13932
|
-
const
|
|
14266
|
+
const attrs3 = {};
|
|
13933
14267
|
let i = 0;
|
|
13934
14268
|
const n2 = source.length;
|
|
13935
14269
|
while (i < n2) {
|
|
@@ -13964,9 +14298,9 @@ function parseAttributes(source) {
|
|
|
13964
14298
|
if (name === "xmlns" || name.startsWith("xmlns:")) {
|
|
13965
14299
|
continue;
|
|
13966
14300
|
}
|
|
13967
|
-
|
|
14301
|
+
attrs3[localName(name)] = decodeEntities(value);
|
|
13968
14302
|
}
|
|
13969
|
-
return
|
|
14303
|
+
return attrs3;
|
|
13970
14304
|
}
|
|
13971
14305
|
function tagEnd(xml, from) {
|
|
13972
14306
|
let quote = "";
|
|
@@ -14092,14 +14426,14 @@ function numOrNaN(value) {
|
|
|
14092
14426
|
function relation(value) {
|
|
14093
14427
|
return value === "ch" || value === "des" ? value : "self";
|
|
14094
14428
|
}
|
|
14095
|
-
function parseIterator(
|
|
14429
|
+
function parseIterator(attrs3) {
|
|
14096
14430
|
return {
|
|
14097
|
-
axis: list(
|
|
14098
|
-
ptType: list(
|
|
14099
|
-
hideLastTrans: list(
|
|
14100
|
-
st: numberList(
|
|
14101
|
-
cnt: numberList(
|
|
14102
|
-
step: numberList(
|
|
14431
|
+
axis: list(attrs3.axis),
|
|
14432
|
+
ptType: list(attrs3.ptType),
|
|
14433
|
+
hideLastTrans: list(attrs3.hideLastTrans).map((v) => v === "1" || v === "true"),
|
|
14434
|
+
st: numberList(attrs3.st),
|
|
14435
|
+
cnt: numberList(attrs3.cnt),
|
|
14436
|
+
step: numberList(attrs3.step)
|
|
14103
14437
|
};
|
|
14104
14438
|
}
|
|
14105
14439
|
function parseAlgorithm(element3) {
|
|
@@ -14130,41 +14464,41 @@ function parseShape(element3) {
|
|
|
14130
14464
|
adj
|
|
14131
14465
|
};
|
|
14132
14466
|
}
|
|
14133
|
-
function parseConstraint(
|
|
14134
|
-
const op =
|
|
14467
|
+
function parseConstraint(attrs3) {
|
|
14468
|
+
const op = attrs3.op;
|
|
14135
14469
|
return {
|
|
14136
|
-
type:
|
|
14137
|
-
for: relation(
|
|
14138
|
-
forName:
|
|
14139
|
-
ptType:
|
|
14140
|
-
refType:
|
|
14141
|
-
refFor: relation(
|
|
14142
|
-
refForName:
|
|
14143
|
-
refPtType:
|
|
14470
|
+
type: attrs3.type ?? "none",
|
|
14471
|
+
for: relation(attrs3.for),
|
|
14472
|
+
forName: attrs3.forName || void 0,
|
|
14473
|
+
ptType: attrs3.ptType ?? "all",
|
|
14474
|
+
refType: attrs3.refType ?? "none",
|
|
14475
|
+
refFor: relation(attrs3.refFor),
|
|
14476
|
+
refForName: attrs3.refForName || void 0,
|
|
14477
|
+
refPtType: attrs3.refPtType ?? "all",
|
|
14144
14478
|
op: op === "equ" || op === "gte" || op === "lte" ? op : "none",
|
|
14145
|
-
val: num(
|
|
14146
|
-
hasVal:
|
|
14147
|
-
fact: num(
|
|
14479
|
+
val: num(attrs3.val, 0),
|
|
14480
|
+
hasVal: attrs3.val !== void 0,
|
|
14481
|
+
fact: num(attrs3.fact, 1)
|
|
14148
14482
|
};
|
|
14149
14483
|
}
|
|
14150
|
-
function parseRule(
|
|
14484
|
+
function parseRule(attrs3) {
|
|
14151
14485
|
return {
|
|
14152
|
-
type:
|
|
14153
|
-
for: relation(
|
|
14154
|
-
forName:
|
|
14155
|
-
ptType:
|
|
14156
|
-
val: numOrNaN(
|
|
14157
|
-
fact: numOrNaN(
|
|
14158
|
-
max: numOrNaN(
|
|
14486
|
+
type: attrs3.type ?? "none",
|
|
14487
|
+
for: relation(attrs3.for),
|
|
14488
|
+
forName: attrs3.forName || void 0,
|
|
14489
|
+
ptType: attrs3.ptType ?? "all",
|
|
14490
|
+
val: numOrNaN(attrs3.val),
|
|
14491
|
+
fact: numOrNaN(attrs3.fact),
|
|
14492
|
+
max: numOrNaN(attrs3.max)
|
|
14159
14493
|
};
|
|
14160
14494
|
}
|
|
14161
|
-
function parseCondition(
|
|
14495
|
+
function parseCondition(attrs3) {
|
|
14162
14496
|
return {
|
|
14163
|
-
...parseIterator(
|
|
14164
|
-
func:
|
|
14165
|
-
arg:
|
|
14166
|
-
op:
|
|
14167
|
-
val:
|
|
14497
|
+
...parseIterator(attrs3),
|
|
14498
|
+
func: attrs3.func ?? "cnt",
|
|
14499
|
+
arg: attrs3.arg,
|
|
14500
|
+
op: attrs3.op ?? "equ",
|
|
14501
|
+
val: attrs3.val ?? ""
|
|
14168
14502
|
};
|
|
14169
14503
|
}
|
|
14170
14504
|
function parseBody(element3, state) {
|
|
@@ -15777,10 +16111,10 @@ function paragraphsHeight(text2, sizePt, availW, metrics) {
|
|
|
15777
16111
|
if (wrappedWidestLineWidth(p.text, widthPx, sizePx, table) > widthPx) {
|
|
15778
16112
|
return void 0;
|
|
15779
16113
|
}
|
|
15780
|
-
const
|
|
15781
|
-
height += wrappedLineCount(p.text, widthPx, sizePx, table) *
|
|
16114
|
+
const line4 = p.size * lineEm;
|
|
16115
|
+
height += wrappedLineCount(p.text, widthPx, sizePx, table) * line4 * SMARTART_LINE_SPACING_FACTOR;
|
|
15782
16116
|
if (i < paragraphs.length - 1) {
|
|
15783
|
-
height += p.spcAft *
|
|
16117
|
+
height += p.spcAft * line4;
|
|
15784
16118
|
}
|
|
15785
16119
|
}
|
|
15786
16120
|
return height + SMARTART_TEXT_BLOCK_EXTRA_EM * sizePt;
|
|
@@ -17667,14 +18001,14 @@ function arrangeSnake(node) {
|
|
|
17667
18001
|
const fromBottom = grDir === "bL" || grDir === "bR";
|
|
17668
18002
|
const reverseAlternate = params.contDir === "revDir";
|
|
17669
18003
|
cells.forEach((cell, i) => {
|
|
17670
|
-
const
|
|
17671
|
-
const inLine = Math.min(lineLen, n2 -
|
|
17672
|
-
const reversedLine = reverseAlternate &&
|
|
18004
|
+
const line4 = Math.floor(i / lineLen);
|
|
18005
|
+
const inLine = Math.min(lineLen, n2 - line4 * lineLen);
|
|
18006
|
+
const reversedLine = reverseAlternate && line4 % 2 === 1;
|
|
17673
18007
|
const pos = reversedLine ? lineLen - 1 - i % lineLen : i % lineLen;
|
|
17674
18008
|
const centre = params.off === "ctr" ? (lineLen - inLine) / 2 : 0;
|
|
17675
18009
|
const shortShift = reversedLine ? -centre : centre;
|
|
17676
|
-
let col = row ? pos + shortShift :
|
|
17677
|
-
let rowIdx = row ?
|
|
18010
|
+
let col = row ? pos + shortShift : line4;
|
|
18011
|
+
let rowIdx = row ? line4 : pos + shortShift;
|
|
17678
18012
|
if (fromRight) {
|
|
17679
18013
|
col = dims.cols - 1 - col;
|
|
17680
18014
|
}
|
|
@@ -18165,9 +18499,9 @@ function applyEngineFonts(collected, nodeById, fontName) {
|
|
|
18165
18499
|
};
|
|
18166
18500
|
for (const { node: renderedNode, rendered, textNode } of collected) {
|
|
18167
18501
|
const node = textNode ?? renderedNode;
|
|
18168
|
-
const
|
|
18502
|
+
const pt2 = sizes.get(node) ?? 18;
|
|
18169
18503
|
const text2 = texts.get(node);
|
|
18170
|
-
const { first: first3, secondary } = text2 ? paragraphSizesPt(text2,
|
|
18504
|
+
const { first: first3, secondary } = text2 ? paragraphSizesPt(text2, pt2) : { first: pt2, secondary: Math.round(pt2 * DESCENDANT_FONT_SCALE) };
|
|
18171
18505
|
rendered.fontSize = first3 * PX_PER_PT4;
|
|
18172
18506
|
rendered.descendantFontSize = hasDescendants(node) ? secondary * PX_PER_PT4 : void 0;
|
|
18173
18507
|
}
|
|
@@ -18265,7 +18599,13 @@ function buildRenderedNode(node, index, nodeById, palette, style, mergedSourceId
|
|
|
18265
18599
|
fontSize: 0,
|
|
18266
18600
|
textX: x + width / 2,
|
|
18267
18601
|
textY: y + height / 2,
|
|
18268
|
-
|
|
18602
|
+
// Picture roles often omit presOf: they present the current point's image, not its text.
|
|
18603
|
+
nodeId: primary?.id ?? (node.shape?.blipPhldr ? node.point.source?.id : void 0),
|
|
18604
|
+
picturePlaceholder: node.shape?.blipPhldr,
|
|
18605
|
+
layoutRole: node.name,
|
|
18606
|
+
contextNodeId: node.point.source?.id,
|
|
18607
|
+
textAlign: ["l", "ctr", "r"].includes(node.alg.params.parTxLTRAlign ?? "") ? node.alg.params.parTxLTRAlign : void 0,
|
|
18608
|
+
textVerticalAnchor: ["t", "ctr", "b"].includes(node.alg.params.txAnchorVert ?? "") ? node.alg.params.txAnchorVert : void 0,
|
|
18269
18609
|
rotation: transform.rotation === 0 ? void 0 : transform.rotation,
|
|
18270
18610
|
presetOverride: node.shape?.type ?? "roundRect",
|
|
18271
18611
|
foldedNodeIds: foldedNodeIds.length > 0 ? foldedNodeIds : void 0,
|
|
@@ -19540,7 +19880,7 @@ function connectionLabel(connection, transitionText) {
|
|
|
19540
19880
|
function textBodyParagraphs(body) {
|
|
19541
19881
|
if (!body) return [];
|
|
19542
19882
|
return children(body, "p", NS.a).map(
|
|
19543
|
-
(paragraph) =>
|
|
19883
|
+
(paragraph) => descendants(paragraph, "t").map((run) => run.textContent ?? "").join("")
|
|
19544
19884
|
);
|
|
19545
19885
|
}
|
|
19546
19886
|
function parsePoint(element3) {
|
|
@@ -19559,9 +19899,9 @@ function parsePoint(element3) {
|
|
|
19559
19899
|
};
|
|
19560
19900
|
const properties3 = first(element3, "spPr", NS.dgm);
|
|
19561
19901
|
const fill = parseDrawingFill(properties3);
|
|
19562
|
-
const
|
|
19902
|
+
const line4 = parseDrawingLine(first(properties3, "ln", NS.a));
|
|
19563
19903
|
if (fill) point.fill = fill;
|
|
19564
|
-
if (
|
|
19904
|
+
if (line4) point.line = line4;
|
|
19565
19905
|
const optional = [
|
|
19566
19906
|
["connectionId", stringAttribute(element3, "cxnId")],
|
|
19567
19907
|
["presAssocId", stringAttribute(prSet, "presAssocID")],
|
|
@@ -19628,15 +19968,15 @@ function parseDiagramDataModel(source, part) {
|
|
|
19628
19968
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
19629
19969
|
parentById.set(connection.destId, connection.sourceId);
|
|
19630
19970
|
}
|
|
19631
|
-
const ext =
|
|
19971
|
+
const ext = descendants(root, "dataModelExt")[0];
|
|
19632
19972
|
const drawingRelId = stringAttribute(ext, "relId");
|
|
19633
|
-
const generated2 =
|
|
19973
|
+
const generated2 = descendants(root, "generatedCache").find(
|
|
19634
19974
|
(node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
19635
19975
|
);
|
|
19636
19976
|
const generatedCacheDigest = generated2?.getAttribute("drawingSha256");
|
|
19637
19977
|
return {
|
|
19638
19978
|
points,
|
|
19639
|
-
...
|
|
19979
|
+
...descendants(root, "generatedCache").some(
|
|
19640
19980
|
(node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
19641
19981
|
) ? { generatedCache: true } : {},
|
|
19642
19982
|
...generatedCacheDigest ? { generatedCacheDigest } : {},
|
|
@@ -19698,11 +20038,11 @@ function styleRef(element3) {
|
|
|
19698
20038
|
}
|
|
19699
20039
|
function parseStyleReferences(style) {
|
|
19700
20040
|
const refs = {};
|
|
19701
|
-
const
|
|
20041
|
+
const line4 = styleRef(first(style, "lnRef", NS.a));
|
|
19702
20042
|
const fill = styleRef(first(style, "fillRef", NS.a));
|
|
19703
20043
|
const effect = styleRef(first(style, "effectRef", NS.a));
|
|
19704
20044
|
const font = styleRef(first(style, "fontRef", NS.a));
|
|
19705
|
-
if (
|
|
20045
|
+
if (line4) refs.line = line4;
|
|
19706
20046
|
if (fill) refs.fill = fill;
|
|
19707
20047
|
if (effect) refs.effect = effect;
|
|
19708
20048
|
if (font) refs.font = font;
|
|
@@ -19771,10 +20111,10 @@ function diagramDrawingFromViews(views, options2 = {}) {
|
|
|
19771
20111
|
text: {
|
|
19772
20112
|
anchor: "ctr",
|
|
19773
20113
|
text: text2,
|
|
19774
|
-
paragraphs: text2.split("\n").map((
|
|
20114
|
+
paragraphs: text2.split("\n").map((line4) => ({
|
|
19775
20115
|
runs: [
|
|
19776
20116
|
{
|
|
19777
|
-
text:
|
|
20117
|
+
text: line4,
|
|
19778
20118
|
sizePt: Math.round((view.fontSize ?? 12) * 0.75 * 10) / 10,
|
|
19779
20119
|
color: textColor
|
|
19780
20120
|
}
|
|
@@ -19848,6 +20188,57 @@ function approximateDiagramDrawingFromNodes(input) {
|
|
|
19848
20188
|
});
|
|
19849
20189
|
}
|
|
19850
20190
|
|
|
20191
|
+
// diagram/picture-layout.ts
|
|
20192
|
+
function applyDiagramPictureSources(drawing, nodes, source, issues, liveNodeIds) {
|
|
20193
|
+
if (!source?.pictures?.length) return;
|
|
20194
|
+
if (source.pictureParts) drawing.pictureParts = { ...source.pictureParts };
|
|
20195
|
+
const used = /* @__PURE__ */ new Set();
|
|
20196
|
+
nodes.forEach((node, index) => {
|
|
20197
|
+
if (!node.picturePlaceholder || !node.nodeId) return;
|
|
20198
|
+
const shape = drawing.shapes[index];
|
|
20199
|
+
if (!shape) return;
|
|
20200
|
+
const candidates = source.pictures.filter((picture2) => picture2.nodeId === node.nodeId);
|
|
20201
|
+
const matching = candidates.filter(
|
|
20202
|
+
(picture2) => picture2.role === node.layoutRole || !!picture2.styleLabel && picture2.styleLabel === node.styleLabel
|
|
20203
|
+
);
|
|
20204
|
+
const picture = matching.length === 1 ? matching[0] : candidates.length === 1 ? candidates[0] : void 0;
|
|
20205
|
+
if (picture) {
|
|
20206
|
+
shape.fill = structuredClone(picture.fill);
|
|
20207
|
+
delete shape.text;
|
|
20208
|
+
delete shape.body;
|
|
20209
|
+
used.add(picture);
|
|
20210
|
+
} else if (candidates.length)
|
|
20211
|
+
issues.push({
|
|
20212
|
+
code: "DIAGRAM_PICTURE_AMBIGUOUS",
|
|
20213
|
+
message: `Picture role ${node.layoutRole ?? node.key} has multiple source pictures; no arbitrary assignment was made.`
|
|
20214
|
+
});
|
|
20215
|
+
});
|
|
20216
|
+
if (source.pictures.some(
|
|
20217
|
+
(picture) => (!liveNodeIds || liveNodeIds.has(picture.nodeId)) && !used.has(picture)
|
|
20218
|
+
))
|
|
20219
|
+
issues.push({
|
|
20220
|
+
code: "DIAGRAM_PICTURE_LAYOUT_UNSUPPORTED",
|
|
20221
|
+
message: "Some retained pictures have no matching image placeholder in this layout. Their source associations are preserved for a compatible layout."
|
|
20222
|
+
});
|
|
20223
|
+
}
|
|
20224
|
+
|
|
20225
|
+
// diagram/layout-role-style.ts
|
|
20226
|
+
function applyDiagramRoleColors(shape, role, index, minorFont) {
|
|
20227
|
+
const at = (colors) => colors[index % colors.length];
|
|
20228
|
+
const fill = role && at(role.fill.colors);
|
|
20229
|
+
if (fill && shape.fill?.kind !== "none" && shape.fill?.kind !== "picture")
|
|
20230
|
+
shape.fill = { kind: "solid", color: structuredClone(fill) };
|
|
20231
|
+
const line4 = role && at(role.line.colors);
|
|
20232
|
+
if (line4 && shape.line) shape.line.fill = { kind: "solid", color: structuredClone(line4) };
|
|
20233
|
+
const text2 = role && at(role.textFill.colors);
|
|
20234
|
+
for (const paragraph of shape.text?.paragraphs ?? []) {
|
|
20235
|
+
for (const run of paragraph.runs) {
|
|
20236
|
+
if (!run.color && text2) run.color = structuredClone(text2);
|
|
20237
|
+
if (!run.typeface && minorFont) run.typeface = minorFont;
|
|
20238
|
+
}
|
|
20239
|
+
}
|
|
20240
|
+
}
|
|
20241
|
+
|
|
19851
20242
|
// diagram/layout-preview.ts
|
|
19852
20243
|
function diagramLayoutData(input) {
|
|
19853
20244
|
const original = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
|
|
@@ -19893,7 +20284,7 @@ function diagramLayoutData(input) {
|
|
|
19893
20284
|
data.layoutDefinition = { rootNode: {}, rawXmlText: input.source.layoutXml };
|
|
19894
20285
|
if (input.source?.dataXml) {
|
|
19895
20286
|
const root = parseXml(input.source.dataXml).documentElement;
|
|
19896
|
-
const vars =
|
|
20287
|
+
const vars = descendants(root, "presLayoutVars")[0];
|
|
19897
20288
|
const direction = first(vars, "dir", NS.dgm)?.getAttribute("val");
|
|
19898
20289
|
const values = {};
|
|
19899
20290
|
if (direction === "norm" || direction === "rev") values.direction = direction;
|
|
@@ -19951,7 +20342,7 @@ function previewDiagramLayout(input) {
|
|
|
19951
20342
|
const computed = runEngineLayout(data, box, data.nodes, palette, intensity);
|
|
19952
20343
|
if (computed) {
|
|
19953
20344
|
const result = applyCustomLayoutOverrides(computed, data.nodes, box);
|
|
19954
|
-
const declaresConnectors = input.source?.layoutXml &&
|
|
20345
|
+
const declaresConnectors = input.source?.layoutXml && descendants(parseXml(input.source.layoutXml).documentElement, "alg").some(
|
|
19955
20346
|
(algorithm) => algorithm.getAttribute("type") === "conn"
|
|
19956
20347
|
);
|
|
19957
20348
|
if (declaresConnectors && data.nodes.some((node) => node.parentId) && !result.nodes.some((node) => /connector|^line(?:Inv)?$/i.test(node.presetOverride ?? "")))
|
|
@@ -19993,6 +20384,8 @@ function previewDiagramLayout(input) {
|
|
|
19993
20384
|
];
|
|
19994
20385
|
});
|
|
19995
20386
|
const drawing2 = diagramDrawingFromViews(views);
|
|
20387
|
+
drawing2.extentEmu = { ...input.extentEmu };
|
|
20388
|
+
const colors = input.source?.colorsXml ? parseDiagramColors(input.source.colorsXml) : void 0;
|
|
19996
20389
|
const quickStyle = input.source?.quickStyleXml ? parseDiagramQuickStyle(input.source.quickStyleXml) : void 0;
|
|
19997
20390
|
const originalModel = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
|
|
19998
20391
|
result.nodes.forEach((node, index) => {
|
|
@@ -20003,7 +20396,9 @@ function previewDiagramLayout(input) {
|
|
|
20003
20396
|
shape.style = label;
|
|
20004
20397
|
shape.has3d = label.requires3d ?? label.hasShape3d;
|
|
20005
20398
|
}
|
|
20006
|
-
|
|
20399
|
+
const contextNodeId = node.nodeId ?? node.contextNodeId;
|
|
20400
|
+
if (contextNodeId) shape.sourceNodeId = contextNodeId;
|
|
20401
|
+
if (node.layoutRole) shape.sourceLayoutRole = node.layoutRole;
|
|
20007
20402
|
if (node.styleLabel) shape.sourceStyleLabel = node.styleLabel;
|
|
20008
20403
|
if (node.foldedNodeIds?.length) shape.foldedNodeIds = node.foldedNodeIds;
|
|
20009
20404
|
const sourceNode = data.nodes.find((entry) => entry.id === node.nodeId);
|
|
@@ -20016,15 +20411,36 @@ function previewDiagramLayout(input) {
|
|
|
20016
20411
|
if (fill) shape.fill = fill;
|
|
20017
20412
|
}
|
|
20018
20413
|
const direct = originalModel?.nodes.find((entry) => entry.modelId === node.nodeId);
|
|
20019
|
-
if (direct?.fill) shape.fill = direct.fill;
|
|
20020
|
-
if (direct?.line) shape.line = { ...shape.line, ...direct.line };
|
|
20021
20414
|
const sourceIds = [node.nodeId, ...node.foldedNodeIds ?? []];
|
|
20022
20415
|
const textNodes = sourceIds.flatMap((id) => {
|
|
20023
20416
|
const source = input.nodes.find((entry) => entry.id === id);
|
|
20024
20417
|
return source ? [source] : [];
|
|
20025
20418
|
});
|
|
20026
20419
|
if (textNodes.length) shape.text = diagramPreviewText(textNodes, node.fontSize);
|
|
20420
|
+
if (shape.text) {
|
|
20421
|
+
if (node.textVerticalAnchor) shape.text.anchor = node.textVerticalAnchor;
|
|
20422
|
+
for (const paragraph of shape.text.paragraphs)
|
|
20423
|
+
if (!paragraph.align && node.textAlign) paragraph.align = node.textAlign;
|
|
20424
|
+
}
|
|
20425
|
+
applyDiagramRoleColors(
|
|
20426
|
+
shape,
|
|
20427
|
+
colors?.labels.find((label2) => label2.name === node.styleLabel),
|
|
20428
|
+
Math.max(
|
|
20429
|
+
0,
|
|
20430
|
+
input.nodes.findIndex((entry) => entry.id === contextNodeId)
|
|
20431
|
+
),
|
|
20432
|
+
input.minorFont
|
|
20433
|
+
);
|
|
20434
|
+
if (direct?.fill && direct.fill.kind !== "picture") shape.fill = direct.fill;
|
|
20435
|
+
if (direct?.line) shape.line = { ...shape.line, ...direct.line };
|
|
20027
20436
|
});
|
|
20437
|
+
applyDiagramPictureSources(
|
|
20438
|
+
drawing2,
|
|
20439
|
+
result.nodes,
|
|
20440
|
+
input.source,
|
|
20441
|
+
issues,
|
|
20442
|
+
new Set(input.nodes.map((node) => node.id))
|
|
20443
|
+
);
|
|
20028
20444
|
return { drawing: drawing2, mode: "interpreted", issues };
|
|
20029
20445
|
}
|
|
20030
20446
|
} catch (error) {
|
|
@@ -20051,12 +20467,12 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
|
|
|
20051
20467
|
if (!refs) return shape;
|
|
20052
20468
|
const fill = !shape.fill && refs.fill?.index !== void 0 ? refs.fill.index === 0 ? { kind: "none" } : resolveThemeFillStyle(scheme2, refs.fill.index, refs.fill.color) : void 0;
|
|
20053
20469
|
const inheritedLine = refs.line?.index !== void 0 ? refs.line.index === 0 ? { fill: { kind: "none" } } : resolveThemeLineStyle(scheme2, refs.line.index, refs.line.color) : void 0;
|
|
20054
|
-
const
|
|
20470
|
+
const line4 = inheritedLine ? { ...inheritedLine, ...shape.line } : void 0;
|
|
20055
20471
|
const effects = !shape.effects && refs.effect?.index !== void 0 ? resolveThemeEffectStyle(scheme2, refs.effect.index, refs.effect.color) : void 0;
|
|
20056
20472
|
return {
|
|
20057
20473
|
...shape,
|
|
20058
20474
|
...fill ? { fill } : {},
|
|
20059
|
-
...
|
|
20475
|
+
...line4 ? { line: line4 } : {},
|
|
20060
20476
|
...effects ? { effects } : {}
|
|
20061
20477
|
};
|
|
20062
20478
|
})
|
|
@@ -20810,6 +21226,24 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
|
20810
21226
|
return out;
|
|
20811
21227
|
}
|
|
20812
21228
|
|
|
21229
|
+
// chart/style-palette.ts
|
|
21230
|
+
function hexToRgb2(hex) {
|
|
21231
|
+
const h = hex.replace("#", "");
|
|
21232
|
+
return [
|
|
21233
|
+
parseInt(h.substring(0, 2), 16),
|
|
21234
|
+
parseInt(h.substring(2, 4), 16),
|
|
21235
|
+
parseInt(h.substring(4, 6), 16)
|
|
21236
|
+
];
|
|
21237
|
+
}
|
|
21238
|
+
function rgbToHex(r, g, b) {
|
|
21239
|
+
const clamp4 = (v) => Math.max(0, Math.min(255, Math.round(v)));
|
|
21240
|
+
return `#${clamp4(r).toString(16).padStart(2, "0")}${clamp4(g).toString(16).padStart(2, "0")}${clamp4(b).toString(16).padStart(2, "0")}`;
|
|
21241
|
+
}
|
|
21242
|
+
function shade(hex, amount) {
|
|
21243
|
+
const [r, g, b] = hexToRgb2(hex);
|
|
21244
|
+
return rgbToHex(r * (1 - amount), g * (1 - amount), b * (1 - amount));
|
|
21245
|
+
}
|
|
21246
|
+
|
|
20813
21247
|
// chart/histogram-binning.ts
|
|
20814
21248
|
function binLabel(lower, upper, closed, format) {
|
|
20815
21249
|
return closed === "r" ? `(${format(lower)}, ${format(upper)}]` : `[${format(lower)}, ${format(upper)})`;
|
|
@@ -21316,11 +21750,11 @@ function resolveChartStyleDefinition(style, resolve) {
|
|
|
21316
21750
|
const value = source[key];
|
|
21317
21751
|
if (value !== void 0) Object.assign(entry, { [key]: value });
|
|
21318
21752
|
}
|
|
21319
|
-
const
|
|
21753
|
+
const line4 = fillColor(source.line?.fill) ?? (source.lineRef?.color && resolve(source.lineRef.color));
|
|
21320
21754
|
const fill = fillColor(source.fill) ?? (source.fillRef?.color && resolve(source.fillRef.color));
|
|
21321
21755
|
const color = (source.textColor && resolve(source.textColor)) ?? (source.fontRef?.color && resolve(source.fontRef.color));
|
|
21322
21756
|
if (color !== void 0) entry.color = color;
|
|
21323
|
-
if (
|
|
21757
|
+
if (line4 !== void 0) entry.lineColor = line4;
|
|
21324
21758
|
if (fill !== void 0) entry.fillColor = fill;
|
|
21325
21759
|
if (source.line?.widthEmu !== void 0 && source.line.widthEmu > 0)
|
|
21326
21760
|
entry.lineWidth = source.line.widthEmu / 12700;
|
|
@@ -21466,10 +21900,10 @@ function buildChartGradientDef(id, fill, bounds) {
|
|
|
21466
21900
|
stops
|
|
21467
21901
|
};
|
|
21468
21902
|
}
|
|
21469
|
-
const
|
|
21470
|
-
const span = fill.scaled ? Math.abs(Math.cos(
|
|
21471
|
-
const dx = Math.cos(
|
|
21472
|
-
const dy = Math.sin(
|
|
21903
|
+
const rad2 = (fill.angle ?? 0) * Math.PI / 180;
|
|
21904
|
+
const span = fill.scaled ? Math.abs(Math.cos(rad2)) + Math.abs(Math.sin(rad2)) : 1;
|
|
21905
|
+
const dx = Math.cos(rad2) * span / 2;
|
|
21906
|
+
const dy = Math.sin(rad2) * span / 2;
|
|
21473
21907
|
const round = (value) => Math.round(value * 1e4) / 1e4;
|
|
21474
21908
|
return {
|
|
21475
21909
|
kind: "linearGradient",
|
|
@@ -21597,23 +22031,23 @@ function buildMarkerPrimitive(input) {
|
|
|
21597
22031
|
return null;
|
|
21598
22032
|
}
|
|
21599
22033
|
const r = markerRadius(input.size, input.defaultRadius);
|
|
21600
|
-
const
|
|
22034
|
+
const outline3 = input.stroke ? {
|
|
21601
22035
|
stroke: input.stroke,
|
|
21602
22036
|
strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
|
|
21603
22037
|
} : void 0;
|
|
21604
|
-
const polygonStroke =
|
|
22038
|
+
const polygonStroke = outline3 ?? { stroke: fill, strokeWidth: 0 };
|
|
21605
22039
|
const lineStroke = input.stroke ?? fill;
|
|
21606
22040
|
switch (symbol) {
|
|
21607
22041
|
case "square":
|
|
21608
22042
|
case "dash": {
|
|
21609
22043
|
const h = symbol === "dash" ? r * 0.64 : r * 2;
|
|
21610
22044
|
const y = cy - h / 2;
|
|
21611
|
-
if (
|
|
22045
|
+
if (outline3) {
|
|
21612
22046
|
return {
|
|
21613
22047
|
kind: "polygon",
|
|
21614
22048
|
points: rectPolygon(cx - r, y, r * 2, h),
|
|
21615
22049
|
fill,
|
|
21616
|
-
...
|
|
22050
|
+
...outline3,
|
|
21617
22051
|
...part
|
|
21618
22052
|
};
|
|
21619
22053
|
}
|
|
@@ -21671,9 +22105,9 @@ function buildMarkerPrimitive(input) {
|
|
|
21671
22105
|
...part
|
|
21672
22106
|
};
|
|
21673
22107
|
case "dot":
|
|
21674
|
-
return { kind: "circle", cx, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...
|
|
22108
|
+
return { kind: "circle", cx, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline3 };
|
|
21675
22109
|
default:
|
|
21676
|
-
return { kind: "circle", cx, cy, r, fill, ...part, ...
|
|
22110
|
+
return { kind: "circle", cx, cy, r, fill, ...part, ...outline3 };
|
|
21677
22111
|
}
|
|
21678
22112
|
}
|
|
21679
22113
|
|
|
@@ -21950,6 +22384,18 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
21950
22384
|
showNegativeBubbles: group2.showNegativeBubbles === true
|
|
21951
22385
|
};
|
|
21952
22386
|
}
|
|
22387
|
+
if (group2?.is3D) {
|
|
22388
|
+
const v = chartSpace.view3D;
|
|
22389
|
+
summary.view3D = {
|
|
22390
|
+
...v?.rotX === void 0 ? {} : { rotX: v.rotX },
|
|
22391
|
+
...v?.rotY === void 0 ? {} : { rotY: v.rotY },
|
|
22392
|
+
...v?.perspective === void 0 ? {} : { perspective: v.perspective },
|
|
22393
|
+
...v?.rightAngleAxes === void 0 ? {} : { rAngAx: v.rightAngleAxes },
|
|
22394
|
+
...v?.depthPercent === void 0 ? {} : { depthPercent: v.depthPercent },
|
|
22395
|
+
...v?.heightPercent === void 0 ? {} : { hPercent: v.heightPercent },
|
|
22396
|
+
...group2.gapDepth === void 0 ? {} : { gapDepth: group2.gapDepth }
|
|
22397
|
+
};
|
|
22398
|
+
}
|
|
21953
22399
|
const grouping = group2?.grouping;
|
|
21954
22400
|
if (grouping && GROUPINGS.has(grouping))
|
|
21955
22401
|
summary.grouping = grouping;
|
|
@@ -21977,17 +22423,6 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
21977
22423
|
return summary;
|
|
21978
22424
|
}
|
|
21979
22425
|
|
|
21980
|
-
// chart/funnel-geometry.ts
|
|
21981
|
-
function computeFunnelGeometry(values, plot) {
|
|
21982
|
-
const max = Math.max(...values.map((v) => Math.abs(v)), 1);
|
|
21983
|
-
const height = plot.height / Math.max(1, values.length);
|
|
21984
|
-
const center = plot.x + plot.width / 2;
|
|
21985
|
-
return values.map((value, index) => {
|
|
21986
|
-
const width = Math.abs(value) / max * plot.width;
|
|
21987
|
-
return { index, x: center - width / 2, y: plot.y + index * height, width, height, center };
|
|
21988
|
-
});
|
|
21989
|
-
}
|
|
21990
|
-
|
|
21991
22426
|
// chart/render/theme-palette.ts
|
|
21992
22427
|
var THEME_SLOTS = [
|
|
21993
22428
|
"lt1",
|
|
@@ -22128,6 +22563,266 @@ function chartAppearance(chart, theme) {
|
|
|
22128
22563
|
return out;
|
|
22129
22564
|
}
|
|
22130
22565
|
|
|
22566
|
+
// chart/render/chart-title-text.ts
|
|
22567
|
+
function chartRunStyle(run) {
|
|
22568
|
+
return {
|
|
22569
|
+
...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
|
|
22570
|
+
...run.bold === void 0 ? {} : { bold: run.bold },
|
|
22571
|
+
...run.italic === void 0 ? {} : { italic: run.italic },
|
|
22572
|
+
...run.underline === void 0 ? {} : { underline: run.underline },
|
|
22573
|
+
...run.typeface === void 0 ? {} : { typeface: run.typeface },
|
|
22574
|
+
...run.color === void 0 ? {} : { textColor: run.color }
|
|
22575
|
+
};
|
|
22576
|
+
}
|
|
22577
|
+
function chartTitleText(chart, theme) {
|
|
22578
|
+
const formatting2 = chart.formatting;
|
|
22579
|
+
const entry = formatting2?.entries.title;
|
|
22580
|
+
const body = entry?.textBody;
|
|
22581
|
+
if (!formatting2 || !body || body.text !== chart.title) return void 0;
|
|
22582
|
+
if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
|
|
22583
|
+
return void 0;
|
|
22584
|
+
return {
|
|
22585
|
+
paragraphs: body.paragraphs.map((paragraph) => ({
|
|
22586
|
+
...paragraph.align ? { align: paragraph.align } : {},
|
|
22587
|
+
...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
|
|
22588
|
+
...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
|
|
22589
|
+
...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
|
|
22590
|
+
runs: paragraph.runs.map((run) => {
|
|
22591
|
+
const direct = {
|
|
22592
|
+
sourceXml: "",
|
|
22593
|
+
...entry.textBodyStyle,
|
|
22594
|
+
...chartRunStyle(paragraph.defaultProperties ?? {}),
|
|
22595
|
+
...chartRunStyle(run)
|
|
22596
|
+
};
|
|
22597
|
+
const appearance = chartAppearance(
|
|
22598
|
+
{
|
|
22599
|
+
...chart,
|
|
22600
|
+
formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
|
|
22601
|
+
},
|
|
22602
|
+
theme
|
|
22603
|
+
)?.title ?? {};
|
|
22604
|
+
return { text: run.text, appearance };
|
|
22605
|
+
})
|
|
22606
|
+
}))
|
|
22607
|
+
};
|
|
22608
|
+
}
|
|
22609
|
+
|
|
22610
|
+
// chart/render/chart-3d-camera.ts
|
|
22611
|
+
var OBLIQUE_DEPTH_SCALE = 0.5;
|
|
22612
|
+
var rad = (deg) => deg * Math.PI / 180;
|
|
22613
|
+
function fitTransform(raw, size, fit2) {
|
|
22614
|
+
const xs = [];
|
|
22615
|
+
const ys = [];
|
|
22616
|
+
for (const x of [0, size.w])
|
|
22617
|
+
for (const y of [0, size.h])
|
|
22618
|
+
for (const z of [0, size.d]) {
|
|
22619
|
+
const q = raw([x, y, z]);
|
|
22620
|
+
xs.push(q.x);
|
|
22621
|
+
ys.push(q.y);
|
|
22622
|
+
}
|
|
22623
|
+
const minX = Math.min(...xs);
|
|
22624
|
+
const maxX = Math.max(...xs);
|
|
22625
|
+
const minY = Math.min(...ys);
|
|
22626
|
+
const maxY = Math.max(...ys);
|
|
22627
|
+
const scale = Math.min(fit2.w / Math.max(1e-6, maxX - minX), fit2.h / Math.max(1e-6, maxY - minY));
|
|
22628
|
+
return {
|
|
22629
|
+
scale,
|
|
22630
|
+
ox: fit2.x + (fit2.w - (maxX - minX) * scale) / 2 - minX * scale,
|
|
22631
|
+
oy: fit2.y + (fit2.h - (maxY - minY) * scale) / 2 + maxY * scale
|
|
22632
|
+
};
|
|
22633
|
+
}
|
|
22634
|
+
function createChart3DCamera(projection, size, fit2) {
|
|
22635
|
+
if (projection.mode === "oblique") {
|
|
22636
|
+
const kx = projection.shearX * OBLIQUE_DEPTH_SCALE;
|
|
22637
|
+
const ky = projection.shearY * OBLIQUE_DEPTH_SCALE;
|
|
22638
|
+
const raw2 = (p) => ({ x: p[0] + p[2] * kx, y: p[1] - p[2] * ky });
|
|
22639
|
+
const t2 = fitTransform(raw2, size, fit2);
|
|
22640
|
+
return {
|
|
22641
|
+
project: (p) => {
|
|
22642
|
+
const q = raw2(p);
|
|
22643
|
+
return { x: t2.ox + q.x * t2.scale, y: t2.oy - q.y * t2.scale, depth: p[2] };
|
|
22644
|
+
},
|
|
22645
|
+
viewDir: () => [-kx, ky, 1],
|
|
22646
|
+
eye: void 0,
|
|
22647
|
+
order: (a, b) => b[2] - a[2] || (projection.shearX >= 0 ? a[0] - b[0] : b[0] - a[0]) || (projection.shearY <= 0 ? a[1] - b[1] : b[1] - a[1]),
|
|
22648
|
+
sideWallAtZero: projection.shearX >= 0
|
|
22649
|
+
};
|
|
22650
|
+
}
|
|
22651
|
+
const cx = size.w / 2;
|
|
22652
|
+
const cy = size.h / 2;
|
|
22653
|
+
const cz = size.d / 2;
|
|
22654
|
+
const [cosY, sinY] = [Math.cos(rad(projection.rotYDeg)), Math.sin(rad(projection.rotYDeg))];
|
|
22655
|
+
const [cosX, sinX] = [Math.cos(rad(projection.rotXDeg)), Math.sin(rad(projection.rotXDeg))];
|
|
22656
|
+
const radius = Math.hypot(size.w, size.h, size.d) / 2;
|
|
22657
|
+
const dist = radius / Math.tan(rad(projection.fovDeg) / 2);
|
|
22658
|
+
const rotate = (p) => {
|
|
22659
|
+
const x = p[0] - cx;
|
|
22660
|
+
const y = p[1] - cy;
|
|
22661
|
+
const z = p[2] - cz;
|
|
22662
|
+
const x1 = x * cosY + z * sinY;
|
|
22663
|
+
const z1 = -x * sinY + z * cosY;
|
|
22664
|
+
return [x1, y * cosX + z1 * sinX, -y * sinX + z1 * cosX];
|
|
22665
|
+
};
|
|
22666
|
+
const raw = (p) => {
|
|
22667
|
+
const r = rotate(p);
|
|
22668
|
+
const s = dist / (dist + r[2]);
|
|
22669
|
+
return { x: r[0] * s, y: r[1] * s, depth: r[2] };
|
|
22670
|
+
};
|
|
22671
|
+
const t = fitTransform(raw, size, fit2);
|
|
22672
|
+
const ey = dist * sinX;
|
|
22673
|
+
const ez1 = -dist * cosX;
|
|
22674
|
+
const eyeX = cx - ez1 * sinY;
|
|
22675
|
+
const eye = [eyeX, cy + ey, cz + ez1 * cosY];
|
|
22676
|
+
return {
|
|
22677
|
+
project: (p) => {
|
|
22678
|
+
const q = raw(p);
|
|
22679
|
+
return { x: t.ox + q.x * t.scale, y: t.oy - q.y * t.scale, depth: q.depth };
|
|
22680
|
+
},
|
|
22681
|
+
viewDir: (p) => [p[0] - eye[0], p[1] - eye[1], p[2] - eye[2]],
|
|
22682
|
+
eye,
|
|
22683
|
+
order: (a, b) => {
|
|
22684
|
+
const da = (a[0] - eyeX) ** 2 + (a[1] - eye[1]) ** 2 + (a[2] - eye[2]) ** 2;
|
|
22685
|
+
const db = (b[0] - eyeX) ** 2 + (b[1] - eye[1]) ** 2 + (b[2] - eye[2]) ** 2;
|
|
22686
|
+
return db - da;
|
|
22687
|
+
},
|
|
22688
|
+
sideWallAtZero: eyeX > cx
|
|
22689
|
+
};
|
|
22690
|
+
}
|
|
22691
|
+
|
|
22692
|
+
// chart/render/chart-spacing.ts
|
|
22693
|
+
function chartBarSpacing(chart) {
|
|
22694
|
+
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
22695
|
+
return {
|
|
22696
|
+
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
22697
|
+
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
22698
|
+
};
|
|
22699
|
+
}
|
|
22700
|
+
|
|
22701
|
+
// chart/render/chart-3d-layout.ts
|
|
22702
|
+
var DEFAULT_GAP_DEPTH = 150;
|
|
22703
|
+
var clamp2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
22704
|
+
function chart3DSeriesInDepth(model) {
|
|
22705
|
+
return model.type === "surface" || model.grouping === "standard";
|
|
22706
|
+
}
|
|
22707
|
+
function chart3DLayout(model, inner, view) {
|
|
22708
|
+
const horizontal = model.horizontal;
|
|
22709
|
+
const w = Math.max(1, inner.w);
|
|
22710
|
+
const h = Math.max(
|
|
22711
|
+
1,
|
|
22712
|
+
inner.h * (view.hPercent !== void 0 ? clamp2(view.hPercent, 5, 500) / 100 : 1)
|
|
22713
|
+
);
|
|
22714
|
+
const catLength = horizontal ? h : w;
|
|
22715
|
+
const valueLength = horizontal ? w : h;
|
|
22716
|
+
const cats = Math.max(1, model.categories.length);
|
|
22717
|
+
const band = catLength / cats;
|
|
22718
|
+
const rows2 = chart3DSeriesInDepth(model) ? Math.max(1, model.series.length) : 1;
|
|
22719
|
+
const isBar = model.type === "bar" || model.type === "column";
|
|
22720
|
+
const clustered = isBar && model.grouping === "clustered";
|
|
22721
|
+
const bars2 = isBar ? clusteredBarGeometry(
|
|
22722
|
+
band,
|
|
22723
|
+
clustered ? Math.max(1, model.series.length) : 1,
|
|
22724
|
+
chartBarSpacing(model)
|
|
22725
|
+
) : void 0;
|
|
22726
|
+
const depthScale = clamp2(view.depthPercent ?? 100, 20, 2e3) / 100;
|
|
22727
|
+
const gap = clamp2(view.gapDepth ?? DEFAULT_GAP_DEPTH, 0, 500) / 100;
|
|
22728
|
+
const wanted = (bars2?.singleBarWidth ?? band * 0.5) * depthScale;
|
|
22729
|
+
const wantedCell = rows2 === 1 ? wanted * 1.5 : wanted * (1 + gap);
|
|
22730
|
+
const depth = Math.min(rows2 * wantedCell, Math.max(w, h) * 0.9);
|
|
22731
|
+
const cell = depth / rows2;
|
|
22732
|
+
const scale = model.valueAxis;
|
|
22733
|
+
const span = scale ? scale.max - scale.min || 1 : 1;
|
|
22734
|
+
return {
|
|
22735
|
+
size: { w, h, d: depth },
|
|
22736
|
+
horizontal,
|
|
22737
|
+
catLength,
|
|
22738
|
+
valueLength,
|
|
22739
|
+
band,
|
|
22740
|
+
rows: rows2,
|
|
22741
|
+
cell,
|
|
22742
|
+
markDepth: rows2 === 1 ? cell / 1.5 : cell / (1 + gap),
|
|
22743
|
+
bars: bars2,
|
|
22744
|
+
value: (v) => (v - (scale?.min ?? 0)) / span * valueLength || 0,
|
|
22745
|
+
rowZ: (r) => {
|
|
22746
|
+
const mark = rows2 === 1 ? cell / 1.5 : cell / (1 + gap);
|
|
22747
|
+
const z0 = r * cell + (cell - mark) / 2;
|
|
22748
|
+
return [z0, z0 + mark];
|
|
22749
|
+
}
|
|
22750
|
+
};
|
|
22751
|
+
}
|
|
22752
|
+
|
|
22753
|
+
// chart/render/chart-3d-mesh.ts
|
|
22754
|
+
function faceKind(n2) {
|
|
22755
|
+
const [x, y, z] = n2;
|
|
22756
|
+
if (Math.abs(y) >= Math.abs(x) && Math.abs(y) >= Math.abs(z)) return y >= 0 ? "top" : "bottom";
|
|
22757
|
+
if (Math.abs(x) >= Math.abs(z)) return x >= 0 ? "right" : "left";
|
|
22758
|
+
return z < 0 ? "front" : "back";
|
|
22759
|
+
}
|
|
22760
|
+
function signedArea(outline3) {
|
|
22761
|
+
let sum = 0;
|
|
22762
|
+
for (let i = 0; i < outline3.length; i++) {
|
|
22763
|
+
const [x0, y0] = outline3[i];
|
|
22764
|
+
const [x1, y1] = outline3[(i + 1) % outline3.length];
|
|
22765
|
+
sum += x0 * y1 - x1 * y0;
|
|
22766
|
+
}
|
|
22767
|
+
return sum / 2;
|
|
22768
|
+
}
|
|
22769
|
+
function extrudeMesh(outline3, z0, z1, meta) {
|
|
22770
|
+
if (outline3.length < 3 || Math.abs(signedArea(outline3)) < 1e-6) return void 0;
|
|
22771
|
+
const ccw = signedArea(outline3) > 0 ? [...outline3] : [...outline3].reverse();
|
|
22772
|
+
const faces = [
|
|
22773
|
+
{ pts: ccw.map(([x, y]) => [x, y, z0]), normal: [0, 0, -1], kind: "front" },
|
|
22774
|
+
{ pts: ccw.map(([x, y]) => [x, y, z1]), normal: [0, 0, 1], kind: "back" }
|
|
22775
|
+
];
|
|
22776
|
+
for (let i = 0; i < ccw.length; i++) {
|
|
22777
|
+
const [ax, ay] = ccw[i];
|
|
22778
|
+
const [bx, by] = ccw[(i + 1) % ccw.length];
|
|
22779
|
+
const dx = bx - ax;
|
|
22780
|
+
const dy = by - ay;
|
|
22781
|
+
const len = Math.hypot(dx, dy);
|
|
22782
|
+
if (len < 1e-9) continue;
|
|
22783
|
+
const normal = [dy / len, -dx / len, 0];
|
|
22784
|
+
faces.push({
|
|
22785
|
+
pts: [
|
|
22786
|
+
[ax, ay, z0],
|
|
22787
|
+
[bx, by, z0],
|
|
22788
|
+
[bx, by, z1],
|
|
22789
|
+
[ax, ay, z1]
|
|
22790
|
+
],
|
|
22791
|
+
normal,
|
|
22792
|
+
kind: faceKind(normal)
|
|
22793
|
+
});
|
|
22794
|
+
}
|
|
22795
|
+
const xs = ccw.map((p) => p[0]);
|
|
22796
|
+
const ys = ccw.map((p) => p[1]);
|
|
22797
|
+
const center = [
|
|
22798
|
+
(Math.min(...xs) + Math.max(...xs)) / 2,
|
|
22799
|
+
(Math.min(...ys) + Math.max(...ys)) / 2,
|
|
22800
|
+
(z0 + z1) / 2
|
|
22801
|
+
];
|
|
22802
|
+
return { ...meta, center, faces };
|
|
22803
|
+
}
|
|
22804
|
+
function boxMesh(x0, x1, y0, y1, z0, z1, meta) {
|
|
22805
|
+
return extrudeMesh(
|
|
22806
|
+
[
|
|
22807
|
+
[Math.min(x0, x1), Math.min(y0, y1)],
|
|
22808
|
+
[Math.max(x0, x1), Math.min(y0, y1)],
|
|
22809
|
+
[Math.max(x0, x1), Math.max(y0, y1)],
|
|
22810
|
+
[Math.min(x0, x1), Math.max(y0, y1)]
|
|
22811
|
+
],
|
|
22812
|
+
Math.min(z0, z1),
|
|
22813
|
+
Math.max(z0, z1),
|
|
22814
|
+
meta
|
|
22815
|
+
);
|
|
22816
|
+
}
|
|
22817
|
+
|
|
22818
|
+
// chart/data-table-layout.ts
|
|
22819
|
+
function chartDataTableMetrics(fontSize, names, showKeys = true) {
|
|
22820
|
+
const rowH = Math.max(14, Math.round(fontSize * 1.45));
|
|
22821
|
+
const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
|
|
22822
|
+
const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
|
|
22823
|
+
return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
|
|
22824
|
+
}
|
|
22825
|
+
|
|
22131
22826
|
// chart/render/chart-svg-util.ts
|
|
22132
22827
|
var TEXT_COLOR = "#595959";
|
|
22133
22828
|
var GRID_COLOR = "#D9D9D9";
|
|
@@ -22138,18 +22833,18 @@ function esc(text2) {
|
|
|
22138
22833
|
}
|
|
22139
22834
|
var n = (value) => String(Math.round(value * 100) / 100);
|
|
22140
22835
|
var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
|
|
22141
|
-
function text(x, y, content,
|
|
22836
|
+
function text(x, y, content, attrs3 = {}) {
|
|
22142
22837
|
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
22143
|
-
parts.push(`font-size="${
|
|
22144
|
-
parts.push(`fill="${esc(
|
|
22145
|
-
if (
|
|
22146
|
-
if (
|
|
22147
|
-
if (
|
|
22148
|
-
if (
|
|
22149
|
-
if (
|
|
22150
|
-
if (
|
|
22151
|
-
if (
|
|
22152
|
-
parts.push(`text-decoration="${
|
|
22838
|
+
parts.push(`font-size="${attrs3.size ?? FONT_SIZE}"`);
|
|
22839
|
+
parts.push(`fill="${esc(attrs3.fill ?? TEXT_COLOR)}"`);
|
|
22840
|
+
if (attrs3.anchor && attrs3.anchor !== "start") parts.push(`text-anchor="${attrs3.anchor}"`);
|
|
22841
|
+
if (attrs3.weight) parts.push(`font-weight="${attrs3.weight}"`);
|
|
22842
|
+
if (attrs3.baseline) parts.push(`dominant-baseline="${attrs3.baseline}"`);
|
|
22843
|
+
if (attrs3.family) parts.push(`font-family="${esc(attrs3.family)}"`);
|
|
22844
|
+
if (attrs3.filter) parts.push(`filter="${esc(attrs3.filter)}"`);
|
|
22845
|
+
if (attrs3.italic !== void 0) parts.push(`font-style="${attrs3.italic ? "italic" : "normal"}"`);
|
|
22846
|
+
if (attrs3.underline !== void 0)
|
|
22847
|
+
parts.push(`text-decoration="${attrs3.underline ? "underline" : "none"}"`);
|
|
22153
22848
|
return `<text ${parts.join(" ")}>${esc(content)}</text>`;
|
|
22154
22849
|
}
|
|
22155
22850
|
var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
|
|
@@ -22265,162 +22960,13 @@ function chartAreaRect(model, part, area) {
|
|
|
22265
22960
|
return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
|
|
22266
22961
|
}
|
|
22267
22962
|
|
|
22268
|
-
// chart/render/chart-svg-funnel.ts
|
|
22269
|
-
function funnelSvg(model, area) {
|
|
22270
|
-
const series = model.series[0];
|
|
22271
|
-
if (!series || series.hidden) return "";
|
|
22272
|
-
const attrs2 = chartTextAttributes(model, "categoryAxis", 10);
|
|
22273
|
-
const width = Math.min(
|
|
22274
|
-
area.w * 0.3,
|
|
22275
|
-
Math.max(32, ...model.categories.map((s) => s.length * (attrs2.size ?? 10) * 0.55 + 8))
|
|
22276
|
-
);
|
|
22277
|
-
const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
|
|
22278
|
-
const out = [
|
|
22279
|
-
chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
|
|
22280
|
-
];
|
|
22281
|
-
for (const bar of computeFunnelGeometry(
|
|
22282
|
-
series.values.map((v) => v ?? 0),
|
|
22283
|
-
plot
|
|
22284
|
-
)) {
|
|
22285
|
-
const value = series.values[bar.index];
|
|
22286
|
-
if (value === null || value === void 0) continue;
|
|
22287
|
-
out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
|
|
22288
|
-
out.push(
|
|
22289
|
-
rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
|
|
22290
|
-
);
|
|
22291
|
-
const size = Math.min(10, bar.height * 0.4);
|
|
22292
|
-
const label = series.labels?.[bar.index];
|
|
22293
|
-
if (label)
|
|
22294
|
-
out.push(
|
|
22295
|
-
text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
|
|
22296
|
-
...chartTextAttributes(model, "dataLabel", size),
|
|
22297
|
-
size,
|
|
22298
|
-
anchor: "middle"
|
|
22299
|
-
})
|
|
22300
|
-
);
|
|
22301
|
-
out.push(
|
|
22302
|
-
text(
|
|
22303
|
-
plot.x - 8,
|
|
22304
|
-
bar.y + bar.height / 2 + (attrs2.size ?? 10) * 0.35,
|
|
22305
|
-
fit(model.categories[bar.index] ?? "", width - 8, attrs2.size ?? 10),
|
|
22306
|
-
{ ...attrs2, anchor: "end" }
|
|
22307
|
-
)
|
|
22308
|
-
);
|
|
22309
|
-
out.push("</g>");
|
|
22310
|
-
}
|
|
22311
|
-
return out.join("");
|
|
22312
|
-
}
|
|
22313
|
-
|
|
22314
|
-
// chart/box-distribution.ts
|
|
22315
|
-
function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
|
|
22316
|
-
const stats = computeBoxStats(values, method);
|
|
22317
|
-
if (!stats) return void 0;
|
|
22318
|
-
const iqr = stats.q3 - stats.q1;
|
|
22319
|
-
const lowerFence = stats.q1 - 1.5 * iqr;
|
|
22320
|
-
const upperFence = stats.q3 + 1.5 * iqr;
|
|
22321
|
-
const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
|
|
22322
|
-
return {
|
|
22323
|
-
stats,
|
|
22324
|
-
whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
|
|
22325
|
-
whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
|
|
22326
|
-
mean: values.reduce((a, b) => a + b, 0) / values.length
|
|
22327
|
-
};
|
|
22328
|
-
}
|
|
22329
|
-
function boxMeanMarkerPath(x, y, radius = 3) {
|
|
22330
|
-
return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
|
|
22331
|
-
}
|
|
22332
|
-
|
|
22333
|
-
// chart/render/chart-svg-box.ts
|
|
22334
|
-
function boxWhiskerSvg(model, frame2, out) {
|
|
22335
|
-
const visible = model.series.filter((s) => !s.hidden);
|
|
22336
|
-
const slot = frame2.bandSize / Math.max(1, visible.length);
|
|
22337
|
-
const width = slot * 0.7;
|
|
22338
|
-
visible.forEach((series, si) => {
|
|
22339
|
-
if (series.hidden) return;
|
|
22340
|
-
const groups = groupRowsByCategory(series.boxCategories ?? []);
|
|
22341
|
-
model.categories.forEach((category, ci) => {
|
|
22342
|
-
const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
|
|
22343
|
-
const value = series.values[row];
|
|
22344
|
-
return value === null || value === void 0 ? [] : [{ row, value }];
|
|
22345
|
-
});
|
|
22346
|
-
const options2 = series.boxWhisker;
|
|
22347
|
-
const rawMethod = options2?.statistics?.quartileMethod;
|
|
22348
|
-
const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
|
|
22349
|
-
const visibility = options2?.visibility;
|
|
22350
|
-
const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
|
|
22351
|
-
const distribution = boxWhiskerDistribution(
|
|
22352
|
-
observations.map((p) => p.value),
|
|
22353
|
-
method,
|
|
22354
|
-
trim
|
|
22355
|
-
);
|
|
22356
|
-
if (!distribution) return;
|
|
22357
|
-
const { stats, whiskerMin, whiskerMax, mean } = distribution;
|
|
22358
|
-
const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
|
|
22359
|
-
const mid = x + width / 2;
|
|
22360
|
-
const y = frame2.value;
|
|
22361
|
-
out.push(
|
|
22362
|
-
`<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
|
|
22363
|
-
);
|
|
22364
|
-
out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
|
|
22365
|
-
out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
|
|
22366
|
-
out.push(
|
|
22367
|
-
line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
|
|
22368
|
-
);
|
|
22369
|
-
out.push(
|
|
22370
|
-
line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
|
|
22371
|
-
);
|
|
22372
|
-
out.push(
|
|
22373
|
-
rect2(
|
|
22374
|
-
x,
|
|
22375
|
-
Math.min(y(stats.q1), y(stats.q3)),
|
|
22376
|
-
width,
|
|
22377
|
-
Math.abs(y(stats.q1) - y(stats.q3)),
|
|
22378
|
-
series.pointColors?.[ci] ?? series.color
|
|
22379
|
-
)
|
|
22380
|
-
);
|
|
22381
|
-
out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
|
|
22382
|
-
if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
|
|
22383
|
-
if (visibility?.meanMarker !== false)
|
|
22384
|
-
out.push(
|
|
22385
|
-
`<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
|
|
22386
|
-
);
|
|
22387
|
-
observations.forEach((point, index) => {
|
|
22388
|
-
const outlier = point.value < whiskerMin || point.value > whiskerMax;
|
|
22389
|
-
if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
|
|
22390
|
-
const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
|
|
22391
|
-
out.push(
|
|
22392
|
-
`<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
|
|
22393
|
-
);
|
|
22394
|
-
});
|
|
22395
|
-
out.push("</g>");
|
|
22396
|
-
});
|
|
22397
|
-
});
|
|
22398
|
-
}
|
|
22399
|
-
|
|
22400
|
-
// chart/data-table-layout.ts
|
|
22401
|
-
function chartDataTableMetrics(fontSize, names, showKeys = true) {
|
|
22402
|
-
const rowH = Math.max(14, Math.round(fontSize * 1.45));
|
|
22403
|
-
const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
|
|
22404
|
-
const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
|
|
22405
|
-
return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
|
|
22406
|
-
}
|
|
22407
|
-
|
|
22408
|
-
// chart/render/chart-spacing.ts
|
|
22409
|
-
function chartBarSpacing(chart) {
|
|
22410
|
-
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
22411
|
-
return {
|
|
22412
|
-
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
22413
|
-
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
22414
|
-
};
|
|
22415
|
-
}
|
|
22416
|
-
|
|
22417
22963
|
// chart/render/chart-svg-labels.ts
|
|
22418
22964
|
var GAP = 3;
|
|
22419
22965
|
var LINE = 1.2;
|
|
22420
22966
|
var NAMED_COLORS = /^(black|blue|cyan|green|magenta|red|white|yellow)$/iu;
|
|
22421
22967
|
function measure3(model, label) {
|
|
22422
|
-
const
|
|
22423
|
-
const size =
|
|
22968
|
+
const attrs3 = chartTextAttributes(model, "dataLabel", 10);
|
|
22969
|
+
const size = attrs3.size ?? 10;
|
|
22424
22970
|
const lines = label.text.split("\n");
|
|
22425
22971
|
return {
|
|
22426
22972
|
...model.frameSize ? { frame: model.frameSize } : {},
|
|
@@ -22428,15 +22974,15 @@ function measure3(model, label) {
|
|
|
22428
22974
|
size,
|
|
22429
22975
|
w: Math.max(...lines.map((l) => textWidth(l, size))),
|
|
22430
22976
|
h: lines.length * size * LINE,
|
|
22431
|
-
attrs:
|
|
22977
|
+
attrs: attrs3
|
|
22432
22978
|
};
|
|
22433
22979
|
}
|
|
22434
22980
|
function draw(m, label, x, y, anchor, out) {
|
|
22435
22981
|
if (m.frame) ({ x, y } = applyLabelManualLayout(label.layout, m.frame, { x, y }));
|
|
22436
22982
|
const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
|
|
22437
|
-
m.lines.forEach((
|
|
22983
|
+
m.lines.forEach((line4, k) => {
|
|
22438
22984
|
const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
|
|
22439
|
-
out.push(text(x, lineY,
|
|
22985
|
+
out.push(text(x, lineY, line4, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
|
|
22440
22986
|
});
|
|
22441
22987
|
}
|
|
22442
22988
|
function barLabels(model, marks, out) {
|
|
@@ -22737,13 +23283,13 @@ function chartDataTableSvg(model, plot) {
|
|
|
22737
23283
|
const bottom = top + height;
|
|
22738
23284
|
const cellW = plot.w / Math.max(1, model.categories.length);
|
|
22739
23285
|
const styled = { ...model, appearance: { ...model.appearance, dataLabel: table.text ?? {} } };
|
|
22740
|
-
const
|
|
23286
|
+
const attrs3 = chartTextAttributes(styled, "dataLabel", fontSize);
|
|
22741
23287
|
const out = ['<g data-chart-part="dataTable">'];
|
|
22742
23288
|
const border = (x1, y1, x2, y2) => out.push(
|
|
22743
23289
|
`<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${strokeAttributes(table.stroke)}/>`
|
|
22744
23290
|
);
|
|
22745
23291
|
const label = (x, y, value, width, anchor = "middle") => out.push(
|
|
22746
|
-
text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...
|
|
23292
|
+
text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs3, anchor })
|
|
22747
23293
|
);
|
|
22748
23294
|
if (table.fill) out.push(rect2(left, top, right - left, height, table.fill));
|
|
22749
23295
|
if (source.showOutline !== false) {
|
|
@@ -22995,8 +23541,8 @@ function chartDateAxis(model, plot, out) {
|
|
|
22995
23541
|
unit,
|
|
22996
23542
|
Math.max(1, axis.majorUnit ?? 1)
|
|
22997
23543
|
);
|
|
22998
|
-
const
|
|
22999
|
-
const size =
|
|
23544
|
+
const attrs3 = chartTextAttributes(model, "categoryAxis");
|
|
23545
|
+
const size = attrs3.size ?? 10;
|
|
23000
23546
|
const y = axis.position === "t" ? plot.y : plot.y + plot.h;
|
|
23001
23547
|
const paint2 = model.axes?.category?.line;
|
|
23002
23548
|
const stroke = { color: paint2?.color ?? "#BFBFBF", width: paint2?.width ?? 1 };
|
|
@@ -23028,13 +23574,13 @@ function chartDateAxis(model, plot, out) {
|
|
|
23028
23574
|
axis.numberFormat?.formatCode
|
|
23029
23575
|
);
|
|
23030
23576
|
if (model.horizontal)
|
|
23031
|
-
out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...
|
|
23577
|
+
out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...attrs3, anchor: "end" }));
|
|
23032
23578
|
else {
|
|
23033
23579
|
const above = axis.tickLabelPosition === "high" || axis.tickLabelPosition !== "low" && axis.position === "t";
|
|
23034
23580
|
const baseline = axis.tickLabelPosition === "high" ? plot.y : axis.tickLabelPosition === "low" ? plot.y + plot.h : y;
|
|
23035
23581
|
out.push(
|
|
23036
23582
|
text(position2(serial), baseline + (above ? -4 : size + 3), label, {
|
|
23037
|
-
...
|
|
23583
|
+
...attrs3,
|
|
23038
23584
|
anchor: "middle"
|
|
23039
23585
|
})
|
|
23040
23586
|
);
|
|
@@ -23090,11 +23636,11 @@ function smoothSegment(points, i) {
|
|
|
23090
23636
|
function chartLineSvg(points, series) {
|
|
23091
23637
|
if (points.length < 2) return "";
|
|
23092
23638
|
const stroke = series.stroke;
|
|
23093
|
-
const
|
|
23639
|
+
const attrs3 = strokeAttributes(
|
|
23094
23640
|
stroke ? { ...stroke, color: stroke.color === "none" ? "none" : series.color } : { color: series.color, width: 2.25 }
|
|
23095
23641
|
);
|
|
23096
23642
|
const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
|
|
23097
|
-
return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${
|
|
23643
|
+
return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs3} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs3} stroke-linejoin="round"${filter}/>`;
|
|
23098
23644
|
}
|
|
23099
23645
|
|
|
23100
23646
|
// chart/render/chart-svg-plot-layout.ts
|
|
@@ -23148,9 +23694,9 @@ function chartSeriesMarkerSvg(series, index, cx, cy, defaultRadius = 3) {
|
|
|
23148
23694
|
geometry2 = `points="${esc(primitive.points)}"`;
|
|
23149
23695
|
break;
|
|
23150
23696
|
}
|
|
23151
|
-
const
|
|
23697
|
+
const outline3 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
|
|
23152
23698
|
const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
|
|
23153
|
-
return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${
|
|
23699
|
+
return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline3}${filter}/>`;
|
|
23154
23700
|
}
|
|
23155
23701
|
|
|
23156
23702
|
// chart/line-dash.ts
|
|
@@ -23394,69 +23940,76 @@ function applyChartAxes(model, chart, color) {
|
|
|
23394
23940
|
model.axes = out;
|
|
23395
23941
|
}
|
|
23396
23942
|
|
|
23397
|
-
// chart/
|
|
23398
|
-
function
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
...run.color === void 0 ? {} : { textColor: run.color }
|
|
23406
|
-
};
|
|
23943
|
+
// chart/region-map/value-color-positions.ts
|
|
23944
|
+
function schemaPosition(node, end) {
|
|
23945
|
+
for (const kind of ["number", "percent"]) {
|
|
23946
|
+
const element3 = first(node, kind, NS.cx), raw = element3?.getAttribute("val");
|
|
23947
|
+
const value = raw === null || raw === void 0 || raw === "" ? NaN : Number(raw);
|
|
23948
|
+
if (Number.isFinite(value)) return { kind, value };
|
|
23949
|
+
}
|
|
23950
|
+
return end === "mid" ? { kind: "percent", value: 50 } : { kind: end };
|
|
23407
23951
|
}
|
|
23408
|
-
function
|
|
23409
|
-
|
|
23410
|
-
const
|
|
23411
|
-
const
|
|
23412
|
-
if (!
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
|
|
23428
|
-
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23437
|
-
|
|
23438
|
-
|
|
23952
|
+
function parseRegionValueColorPositions(xml) {
|
|
23953
|
+
if (!xml) return void 0;
|
|
23954
|
+
const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml}</cx:root>`).documentElement;
|
|
23955
|
+
const positions = first(root, "valueColorPositions", NS.cx);
|
|
23956
|
+
if (!positions) return void 0;
|
|
23957
|
+
const count = positions.getAttribute("count");
|
|
23958
|
+
const native = ["min", "mid", "max"].some((key) => first(positions, key, NS.cx));
|
|
23959
|
+
if (native || count !== null && children(positions, "pos", NS.cx).length === 0) {
|
|
23960
|
+
const keys = count === "3" || first(positions, "mid", NS.cx) ? ["min", "mid", "max"] : ["min", "max"];
|
|
23961
|
+
return keys.map((key) => schemaPosition(first(positions, key, NS.cx), key));
|
|
23962
|
+
}
|
|
23963
|
+
const legacy = children(positions, "pos", NS.cx).flatMap(
|
|
23964
|
+
(element3) => {
|
|
23965
|
+
const type = element3.getAttribute("type");
|
|
23966
|
+
if (type === "min" || type === "max") return [{ kind: type }];
|
|
23967
|
+
if (type !== "num" && type !== "percent") return [];
|
|
23968
|
+
const raw = element3.getAttribute("val"), value = raw === null || raw === "" ? NaN : Number(raw);
|
|
23969
|
+
return [
|
|
23970
|
+
{ kind: type === "num" ? "number" : type, ...Number.isFinite(value) ? { value } : {} }
|
|
23971
|
+
];
|
|
23972
|
+
}
|
|
23973
|
+
);
|
|
23974
|
+
return legacy.length ? legacy : void 0;
|
|
23975
|
+
}
|
|
23976
|
+
|
|
23977
|
+
// chart/region-map/value-colors.ts
|
|
23978
|
+
function resolveRegionValueColors(options2, color) {
|
|
23979
|
+
const result = { ...options2 };
|
|
23980
|
+
const xml = `<cx:root xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${options2.valueColorsXml ?? ""}${options2.valueColorPositionsXml ?? ""}</cx:root>`;
|
|
23981
|
+
const root = parseXml(xml).documentElement;
|
|
23982
|
+
if (options2.valueColorsXml) {
|
|
23983
|
+
const colors = Array.from(root.getElementsByTagName("*")).flatMap((node) => {
|
|
23984
|
+
const c = color(parseDrawingColorIn(node));
|
|
23985
|
+
return c ? [c] : [];
|
|
23986
|
+
});
|
|
23987
|
+
if (colors.length) result.valueColors = colors;
|
|
23988
|
+
}
|
|
23989
|
+
const positions = parseRegionValueColorPositions(options2.valueColorPositionsXml);
|
|
23990
|
+
if (positions) result.valueColorPositions = positions;
|
|
23991
|
+
return result;
|
|
23439
23992
|
}
|
|
23440
23993
|
|
|
23441
23994
|
// chart/render/chart-view-analysis.ts
|
|
23442
|
-
function strokeOf(
|
|
23443
|
-
if (
|
|
23444
|
-
const color = (
|
|
23445
|
-
const width =
|
|
23446
|
-
const dash =
|
|
23995
|
+
function strokeOf(line4, fallback, resolve) {
|
|
23996
|
+
if (line4?.fill?.kind === "none") return void 0;
|
|
23997
|
+
const color = (line4?.fill?.kind === "solid" ? resolve(line4.fill.color) : void 0) ?? fallback.color;
|
|
23998
|
+
const width = line4?.widthEmu === void 0 ? fallback.width : chartPointsToPixels(line4.widthEmu / 12700);
|
|
23999
|
+
const dash = line4?.dash ?? fallback.dash;
|
|
23447
24000
|
return { color, width, ...dash && dash !== "solid" ? { dash } : {} };
|
|
23448
24001
|
}
|
|
23449
24002
|
function analysisView(source, seriesColor, resolve) {
|
|
23450
24003
|
const plain = seriesColor === "none" || seriesColor.startsWith("url(") ? TEXT_COLOR : seriesColor;
|
|
23451
24004
|
const trendlines2 = (source.trendlines ?? []).flatMap((entry) => {
|
|
23452
|
-
const { name: _name, line:
|
|
24005
|
+
const { name: _name, line: line4, ...fit2 } = entry;
|
|
23453
24006
|
const fallback = { color: plain, width: chartPointsToPixels(1.5), dash: "sysDot" };
|
|
23454
|
-
const stroke = strokeOf(
|
|
24007
|
+
const stroke = strokeOf(line4, fallback, resolve);
|
|
23455
24008
|
return stroke ? [{ fit: fit2, stroke }] : [];
|
|
23456
24009
|
});
|
|
23457
24010
|
const errorBars = (source.errorBars ?? []).flatMap((entry) => {
|
|
23458
|
-
const { direction, barType, noEndCap, line:
|
|
23459
|
-
const stroke = strokeOf(
|
|
24011
|
+
const { direction, barType, noEndCap, line: line4, ...amount } = entry;
|
|
24012
|
+
const stroke = strokeOf(line4, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
|
|
23460
24013
|
return stroke ? [{ direction, barType, amount, endCap: noEndCap !== true, stroke }] : [];
|
|
23461
24014
|
});
|
|
23462
24015
|
return {
|
|
@@ -23640,10 +24193,10 @@ function paintOf(fill, ctx) {
|
|
|
23640
24193
|
return fill?.kind === "solid" ? ctx.drawingColor(fill.color) : void 0;
|
|
23641
24194
|
}
|
|
23642
24195
|
function lineOf(shape, ctx, color) {
|
|
23643
|
-
const
|
|
24196
|
+
const line4 = shape?.line;
|
|
23644
24197
|
return {
|
|
23645
|
-
color: paintOf(
|
|
23646
|
-
width:
|
|
24198
|
+
color: paintOf(line4?.fill, ctx) ?? color,
|
|
24199
|
+
width: line4?.widthEmu === void 0 ? 1 : Math.max(0.5, line4.widthEmu / EMU_PER_PX2)
|
|
23647
24200
|
};
|
|
23648
24201
|
}
|
|
23649
24202
|
function barOf(shape, ctx, fallback) {
|
|
@@ -23879,6 +24432,7 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
23879
24432
|
"treemap",
|
|
23880
24433
|
"sunburst",
|
|
23881
24434
|
"funnel",
|
|
24435
|
+
"regionMap",
|
|
23882
24436
|
"boxWhisker"
|
|
23883
24437
|
]);
|
|
23884
24438
|
function chartSummaryView(chart, theme, options2 = {}) {
|
|
@@ -23939,8 +24493,14 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
23939
24493
|
categories,
|
|
23940
24494
|
series: type === "boxWhisker" ? series.filter((s) => !s.hidden) : series,
|
|
23941
24495
|
horizontal: type === "bar",
|
|
23942
|
-
supported: SUPPORTED.has(type)
|
|
24496
|
+
supported: SUPPORTED.has(type) || type === "surface" && chart.view3D !== void 0
|
|
23943
24497
|
};
|
|
24498
|
+
if (chart.view3D) model.view3D = chart.view3D;
|
|
24499
|
+
if (chart.funnelGapWidth !== void 0) model.funnelGapWidth = chart.funnelGapWidth;
|
|
24500
|
+
if (chart.series[0]?.regionMap)
|
|
24501
|
+
model.regionMap = resolveRegionValueColors(chart.series[0].regionMap, ctx.drawingColor);
|
|
24502
|
+
if (model.regionMap && chart.series[0]?.fill?.kind === "solid" && series[0])
|
|
24503
|
+
model.regionMap.fixedColor = series[0].color;
|
|
23944
24504
|
const table = chartDataTableView(chart, theme, ctx.drawingColor);
|
|
23945
24505
|
if (table) model.dataTable = table;
|
|
23946
24506
|
if (chart.date1904 !== void 0) model.date1904 = chart.date1904;
|
|
@@ -24193,6 +24753,1414 @@ function linesAndAreas(model, frame2, out) {
|
|
|
24193
24753
|
pointLabels(model, marks, out);
|
|
24194
24754
|
}
|
|
24195
24755
|
|
|
24756
|
+
// chart/render/chart-3d-marks.ts
|
|
24757
|
+
var RIBBON_THICKNESS = 0.025;
|
|
24758
|
+
var stackedOf = (model) => model.grouping === "stacked" || model.grouping === "percentStacked";
|
|
24759
|
+
function chart3DBarMeshes(model, layout) {
|
|
24760
|
+
const bars2 = layout.bars;
|
|
24761
|
+
if (!bars2) return [];
|
|
24762
|
+
const values = plotted(model);
|
|
24763
|
+
const stacked = stackedOf(model);
|
|
24764
|
+
const clustered = model.grouping === "clustered";
|
|
24765
|
+
const inDepth = chart3DSeriesInDepth(model);
|
|
24766
|
+
const pos = new Array(model.categories.length).fill(0);
|
|
24767
|
+
const neg = new Array(model.categories.length).fill(0);
|
|
24768
|
+
const base = layout.value(0);
|
|
24769
|
+
const meshes = [];
|
|
24770
|
+
model.series.forEach((s, si) => {
|
|
24771
|
+
const slot = clustered ? si : 0;
|
|
24772
|
+
const [z0, z1] = layout.rowZ(inDepth ? si : 0);
|
|
24773
|
+
values[si]?.forEach((v, i) => {
|
|
24774
|
+
if (v === null || i >= model.categories.length) return;
|
|
24775
|
+
let from = 0;
|
|
24776
|
+
let to = v;
|
|
24777
|
+
if (stacked) {
|
|
24778
|
+
const acc = v >= 0 ? pos : neg;
|
|
24779
|
+
from = acc[i] ?? 0;
|
|
24780
|
+
to = from + v;
|
|
24781
|
+
acc[i] = to;
|
|
24782
|
+
}
|
|
24783
|
+
const a = stacked ? layout.value(from) : base;
|
|
24784
|
+
const b = layout.value(to);
|
|
24785
|
+
const centre = (i + 0.5) * layout.band;
|
|
24786
|
+
const meta = {
|
|
24787
|
+
series: s.sourceIndex ?? si,
|
|
24788
|
+
point: i,
|
|
24789
|
+
color: s.pointColors?.[i] ?? s.color
|
|
24790
|
+
};
|
|
24791
|
+
const mesh = layout.horizontal ? boxMesh(
|
|
24792
|
+
a,
|
|
24793
|
+
b,
|
|
24794
|
+
centre - (bars2.clusterWidth / 2 - bars2.singleBarWidth - slot * bars2.step) - bars2.singleBarWidth,
|
|
24795
|
+
centre - (bars2.clusterWidth / 2 - bars2.singleBarWidth - slot * bars2.step),
|
|
24796
|
+
z0,
|
|
24797
|
+
z1,
|
|
24798
|
+
meta
|
|
24799
|
+
) : boxMesh(
|
|
24800
|
+
centre - bars2.clusterWidth / 2 + slot * bars2.step,
|
|
24801
|
+
centre - bars2.clusterWidth / 2 + slot * bars2.step + bars2.singleBarWidth,
|
|
24802
|
+
a,
|
|
24803
|
+
b,
|
|
24804
|
+
z0,
|
|
24805
|
+
z1,
|
|
24806
|
+
meta
|
|
24807
|
+
);
|
|
24808
|
+
if (mesh) meshes.push(mesh);
|
|
24809
|
+
});
|
|
24810
|
+
});
|
|
24811
|
+
return meshes;
|
|
24812
|
+
}
|
|
24813
|
+
function chart3DLineMeshes(model, layout) {
|
|
24814
|
+
const values = plotted(model);
|
|
24815
|
+
const stacked = stackedOf(model);
|
|
24816
|
+
const inDepth = chart3DSeriesInDepth(model);
|
|
24817
|
+
const thick = layout.valueLength * RIBBON_THICKNESS;
|
|
24818
|
+
const acc = new Array(model.categories.length).fill(0);
|
|
24819
|
+
const meshes = [];
|
|
24820
|
+
model.series.forEach((s, si) => {
|
|
24821
|
+
const [z0, z1] = layout.rowZ(inDepth ? si : 0);
|
|
24822
|
+
const pts = (values[si] ?? []).map((v, i) => {
|
|
24823
|
+
if (v === null || i >= model.categories.length) return null;
|
|
24824
|
+
const top = stacked ? acc[i] = (acc[i] ?? 0) + v : v;
|
|
24825
|
+
return [(i + 0.5) * layout.band, layout.value(top)];
|
|
24826
|
+
});
|
|
24827
|
+
for (let i = 0; i + 1 < pts.length; i++) {
|
|
24828
|
+
const p = pts[i];
|
|
24829
|
+
const q = pts[i + 1];
|
|
24830
|
+
if (!p || !q) continue;
|
|
24831
|
+
const mesh = extrudeMesh([p, q, [q[0], q[1] - thick], [p[0], p[1] - thick]], z0, z1, {
|
|
24832
|
+
series: s.sourceIndex ?? si,
|
|
24833
|
+
point: i,
|
|
24834
|
+
color: s.color
|
|
24835
|
+
});
|
|
24836
|
+
if (mesh) meshes.push(mesh);
|
|
24837
|
+
}
|
|
24838
|
+
});
|
|
24839
|
+
return meshes;
|
|
24840
|
+
}
|
|
24841
|
+
function chart3DAreaMeshes(model, layout) {
|
|
24842
|
+
const values = plotted(model);
|
|
24843
|
+
const stacked = stackedOf(model);
|
|
24844
|
+
const inDepth = chart3DSeriesInDepth(model);
|
|
24845
|
+
const cats = model.categories.length;
|
|
24846
|
+
const x = (i) => cats > 1 ? i / (cats - 1) * layout.catLength : layout.catLength / 2;
|
|
24847
|
+
const base = layout.value(0);
|
|
24848
|
+
const acc = new Array(cats).fill(0);
|
|
24849
|
+
const meshes = [];
|
|
24850
|
+
model.series.forEach((s, si) => {
|
|
24851
|
+
const [z0, z1] = layout.rowZ(inDepth ? si : 0);
|
|
24852
|
+
const upper = [];
|
|
24853
|
+
const lower = [];
|
|
24854
|
+
for (let i = 0; i < cats; i++) {
|
|
24855
|
+
const v = values[si]?.[i] ?? 0;
|
|
24856
|
+
const below = stacked ? acc[i] ?? 0 : 0;
|
|
24857
|
+
if (stacked) acc[i] = below + v;
|
|
24858
|
+
upper.push([x(i), layout.value(below + v)]);
|
|
24859
|
+
lower.push([x(i), stacked ? layout.value(below) : base]);
|
|
24860
|
+
}
|
|
24861
|
+
const mesh = extrudeMesh([...upper, ...lower.reverse()], z0, z1, {
|
|
24862
|
+
series: s.sourceIndex ?? si,
|
|
24863
|
+
point: 0,
|
|
24864
|
+
color: s.color
|
|
24865
|
+
});
|
|
24866
|
+
if (mesh) meshes.push(mesh);
|
|
24867
|
+
});
|
|
24868
|
+
return meshes;
|
|
24869
|
+
}
|
|
24870
|
+
|
|
24871
|
+
// chart/render/chart-3d-projection.ts
|
|
24872
|
+
var DEFAULT_ROT_X = 15;
|
|
24873
|
+
var DEFAULT_ROT_Y = 20;
|
|
24874
|
+
var DEFAULT_PIE_ROT_X = 30;
|
|
24875
|
+
var DEFAULT_PIE_ROT_Y = 0;
|
|
24876
|
+
var DEFAULT_PERSPECTIVE_DEG = 30;
|
|
24877
|
+
var PERSPECTIVE_MAX_DEG = 120;
|
|
24878
|
+
var FOV_MIN = 15;
|
|
24879
|
+
var FOV_MAX = 75;
|
|
24880
|
+
var clamp3 = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
24881
|
+
function resolvePerspectiveFov(perspectiveDeg) {
|
|
24882
|
+
const perspective = clamp3(perspectiveDeg ?? DEFAULT_PERSPECTIVE_DEG, 0, PERSPECTIVE_MAX_DEG);
|
|
24883
|
+
return FOV_MIN + perspective / PERSPECTIVE_MAX_DEG * (FOV_MAX - FOV_MIN);
|
|
24884
|
+
}
|
|
24885
|
+
function resolveChart3DProjection(chartType, view3D) {
|
|
24886
|
+
const isPie = chartType === "pie3D";
|
|
24887
|
+
const rotXDeg = view3D?.rotX ?? (isPie ? DEFAULT_PIE_ROT_X : DEFAULT_ROT_X);
|
|
24888
|
+
const rotYDeg = view3D?.rotY ?? (isPie ? DEFAULT_PIE_ROT_Y : DEFAULT_ROT_Y);
|
|
24889
|
+
const rAngAx = view3D?.rAngAx ?? chartType === "bar3D";
|
|
24890
|
+
if (rAngAx) {
|
|
24891
|
+
const rx = rotXDeg * Math.PI / 180;
|
|
24892
|
+
const ry = rotYDeg * Math.PI / 180;
|
|
24893
|
+
return { mode: "oblique", shearX: Math.sin(ry), shearY: -Math.sin(rx), rotXDeg, rotYDeg };
|
|
24894
|
+
}
|
|
24895
|
+
return {
|
|
24896
|
+
mode: "perspective",
|
|
24897
|
+
rotXDeg,
|
|
24898
|
+
rotYDeg,
|
|
24899
|
+
fovDeg: resolvePerspectiveFov(view3D?.perspective)
|
|
24900
|
+
};
|
|
24901
|
+
}
|
|
24902
|
+
|
|
24903
|
+
// chart/render/chart-3d-shading.ts
|
|
24904
|
+
var FACE_SHADE_AMOUNT = {
|
|
24905
|
+
front: 0,
|
|
24906
|
+
top: 0.25,
|
|
24907
|
+
right: 0.36,
|
|
24908
|
+
left: 0.36,
|
|
24909
|
+
back: 0.36,
|
|
24910
|
+
bottom: 0.5
|
|
24911
|
+
};
|
|
24912
|
+
var HEX = /^#[0-9a-f]{6}$/i;
|
|
24913
|
+
function shadeChart3DFace(baseColor, face) {
|
|
24914
|
+
const amount = FACE_SHADE_AMOUNT[face];
|
|
24915
|
+
return amount === 0 || !HEX.test(baseColor) ? baseColor : shade(baseColor, amount);
|
|
24916
|
+
}
|
|
24917
|
+
|
|
24918
|
+
// chart/render/chart-3d-pie.ts
|
|
24919
|
+
var STEP = Math.PI / 45;
|
|
24920
|
+
function chart3DPieGeometry(area, view) {
|
|
24921
|
+
const tilt = resolveChart3DProjection("pie3D", view).rotXDeg;
|
|
24922
|
+
const sin = Math.min(1, Math.max(0.08, Math.sin(Math.abs(tilt) * Math.PI / 180)));
|
|
24923
|
+
const cos = Math.cos(Math.min(90, Math.abs(tilt)) * Math.PI / 180);
|
|
24924
|
+
const depth = Math.min(2e3, Math.max(20, view.depthPercent ?? 100)) / 100;
|
|
24925
|
+
const rx0 = Math.max(1, Math.min(area.w / 2, area.h / 2 / sin) - 4);
|
|
24926
|
+
const thickness = rx0 * 0.35 * cos * depth;
|
|
24927
|
+
const rx = Math.min(rx0, Math.max(1, (area.h - thickness) / 2 / sin));
|
|
24928
|
+
const ry = rx * sin;
|
|
24929
|
+
const thick = Math.min(thickness, Math.max(0, area.h - ry * 2));
|
|
24930
|
+
return {
|
|
24931
|
+
cx: area.x + area.w / 2,
|
|
24932
|
+
cy: area.y + (area.h - thick) / 2 + ry,
|
|
24933
|
+
rx,
|
|
24934
|
+
ry,
|
|
24935
|
+
thickness: thick
|
|
24936
|
+
};
|
|
24937
|
+
}
|
|
24938
|
+
var pt = (g, a, dy) => `${n(g.cx + g.rx * Math.cos(a))},${n(g.cy + g.ry * Math.sin(a) + dy)}`;
|
|
24939
|
+
function frontRanges(a0, a1) {
|
|
24940
|
+
const out = [];
|
|
24941
|
+
for (let k = Math.floor(a0 / (2 * Math.PI)) - 1; k <= Math.ceil(a1 / (2 * Math.PI)); k++) {
|
|
24942
|
+
const lo = Math.max(a0, k * 2 * Math.PI);
|
|
24943
|
+
const hi = Math.min(a1, k * 2 * Math.PI + Math.PI);
|
|
24944
|
+
if (hi - lo > 1e-6) out.push([lo, hi]);
|
|
24945
|
+
}
|
|
24946
|
+
return out;
|
|
24947
|
+
}
|
|
24948
|
+
function chart3DPieSvg(model, area, view) {
|
|
24949
|
+
const series = model.series[0];
|
|
24950
|
+
if (!series) return "";
|
|
24951
|
+
const total = series.values.reduce((sum, v) => sum + (v !== null && v > 0 ? v : 0), 0);
|
|
24952
|
+
if (total <= 0) return "";
|
|
24953
|
+
const g = chart3DPieGeometry(area, view);
|
|
24954
|
+
const walls = [];
|
|
24955
|
+
const tops = [];
|
|
24956
|
+
let angle = -Math.PI / 2;
|
|
24957
|
+
series.values.forEach((v, i) => {
|
|
24958
|
+
if (v === null || v <= 0) return;
|
|
24959
|
+
const sweep = v / total * Math.PI * 2;
|
|
24960
|
+
const a0 = angle;
|
|
24961
|
+
const a1 = angle + sweep;
|
|
24962
|
+
angle = a1;
|
|
24963
|
+
const color = series.pointColors?.[i] ?? series.color;
|
|
24964
|
+
const wall = shadeChart3DFace(color, "right");
|
|
24965
|
+
const top = color;
|
|
24966
|
+
const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
|
|
24967
|
+
for (const [lo, hi] of frontRanges(a0, a1)) {
|
|
24968
|
+
const steps = Math.max(2, Math.ceil((hi - lo) / STEP));
|
|
24969
|
+
const upper = [];
|
|
24970
|
+
const lower = [];
|
|
24971
|
+
for (let s = 0; s <= steps; s++) {
|
|
24972
|
+
const a = lo + (hi - lo) * s / steps;
|
|
24973
|
+
upper.push(pt(g, a, 0));
|
|
24974
|
+
lower.push(pt(g, a, g.thickness));
|
|
24975
|
+
}
|
|
24976
|
+
walls.push(
|
|
24977
|
+
`<polygon points="${[...upper, ...lower.reverse()].join(" ")}" fill="${wall}" stroke="${wall}" stroke-width="0.5" data-chart-series="0" data-chart-point="${i}"${filter}/>`
|
|
24978
|
+
);
|
|
24979
|
+
}
|
|
24980
|
+
const full = sweep >= Math.PI * 2 - 1e-6;
|
|
24981
|
+
const start = pt(g, a0, 0);
|
|
24982
|
+
const end = pt(g, a1, 0);
|
|
24983
|
+
const d = full ? `M${pt(g, a0, 0)} A${n(g.rx)},${n(g.ry)} 0 1 1 ${pt(g, a0 + Math.PI, 0)} A${n(g.rx)},${n(g.ry)} 0 1 1 ${start} Z` : `M${n(g.cx)},${n(g.cy)} L${start} A${n(g.rx)},${n(g.ry)} 0 ${sweep > Math.PI ? 1 : 0} 1 ${end} Z`;
|
|
24984
|
+
tops.push(
|
|
24985
|
+
`<path d="${d}" fill="${top}" stroke="#FFFFFF" stroke-width="1" data-chart-series="0" data-chart-point="${i}"${filter}/>`
|
|
24986
|
+
);
|
|
24987
|
+
});
|
|
24988
|
+
return walls.join("") + tops.join("");
|
|
24989
|
+
}
|
|
24990
|
+
|
|
24991
|
+
// chart/render/chart-3d-scene.ts
|
|
24992
|
+
var centroid = (pts) => {
|
|
24993
|
+
const sum = pts.reduce(
|
|
24994
|
+
(acc, p) => [acc[0] + p[0], acc[1] + p[1], acc[2] + p[2]],
|
|
24995
|
+
[0, 0, 0]
|
|
24996
|
+
);
|
|
24997
|
+
return [sum[0] / pts.length, sum[1] / pts.length, sum[2] / pts.length];
|
|
24998
|
+
};
|
|
24999
|
+
function chart3DFaceVisible(camera, face) {
|
|
25000
|
+
if (!face.normal) return true;
|
|
25001
|
+
const d = camera.viewDir(centroid(face.pts));
|
|
25002
|
+
return face.normal[0] * d[0] + face.normal[1] * d[1] + face.normal[2] * d[2] < 0;
|
|
25003
|
+
}
|
|
25004
|
+
function chart3DPolygon(camera, pts, fill, extra = "") {
|
|
25005
|
+
const points = pts.map((p) => {
|
|
25006
|
+
const q = camera.project(p);
|
|
25007
|
+
return `${n(q.x)},${n(q.y)}`;
|
|
25008
|
+
}).join(" ");
|
|
25009
|
+
return `<polygon points="${points}" fill="${fill}" stroke="${fill}" stroke-width="0.5" stroke-linejoin="round"${extra}/>`;
|
|
25010
|
+
}
|
|
25011
|
+
function chart3DMeshesSvg(camera, meshes) {
|
|
25012
|
+
const out = [];
|
|
25013
|
+
const ordered = [...meshes].sort((a, b) => camera.order(a.center, b.center));
|
|
25014
|
+
for (const mesh of ordered) {
|
|
25015
|
+
const faces = mesh.faces.filter((face) => chart3DFaceVisible(camera, face)).map((face) => ({ face, depth: camera.project(centroid(face.pts)).depth })).sort((a, b) => b.depth - a.depth);
|
|
25016
|
+
if (!faces.length) continue;
|
|
25017
|
+
out.push(`<g data-chart-series="${mesh.series}" data-chart-point="${mesh.point}">`);
|
|
25018
|
+
for (const { face } of faces)
|
|
25019
|
+
out.push(
|
|
25020
|
+
chart3DPolygon(camera, face.pts, face.fill ?? shadeChart3DFace(mesh.color, face.kind))
|
|
25021
|
+
);
|
|
25022
|
+
out.push("</g>");
|
|
25023
|
+
}
|
|
25024
|
+
return out.join("");
|
|
25025
|
+
}
|
|
25026
|
+
|
|
25027
|
+
// chart/render/chart-3d-surface.ts
|
|
25028
|
+
var LIGHT = (() => {
|
|
25029
|
+
const v = [-0.3, 0.8, -0.5];
|
|
25030
|
+
const len = Math.hypot(...v);
|
|
25031
|
+
return [v[0] / len, v[1] / len, v[2] / len];
|
|
25032
|
+
})();
|
|
25033
|
+
var HEX2 = /^#[0-9a-f]{6}$/i;
|
|
25034
|
+
var BAND_FALLBACK = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47"];
|
|
25035
|
+
function chart3DSurfaceMeshes(model, layout) {
|
|
25036
|
+
const cols = model.categories.length;
|
|
25037
|
+
const rows2 = model.series.length;
|
|
25038
|
+
const scale = model.valueAxis;
|
|
25039
|
+
if (cols < 2 || rows2 < 1 || !scale) return [];
|
|
25040
|
+
const zRows = rows2 === 1 ? 2 : rows2;
|
|
25041
|
+
const height = (r, c) => layout.value(model.series[Math.min(r, rows2 - 1)]?.values[c] ?? 0);
|
|
25042
|
+
const x = (c) => c / (cols - 1) * layout.catLength;
|
|
25043
|
+
const z = (r) => r / (zRows - 1) * layout.size.d;
|
|
25044
|
+
const meshes = [];
|
|
25045
|
+
for (let r = 0; r + 1 < zRows; r++)
|
|
25046
|
+
for (let c = 0; c + 1 < cols; c++) {
|
|
25047
|
+
const pts = [
|
|
25048
|
+
[x(c), height(r, c), z(r)],
|
|
25049
|
+
[x(c + 1), height(r, c + 1), z(r)],
|
|
25050
|
+
[x(c + 1), height(r + 1, c + 1), z(r + 1)],
|
|
25051
|
+
[x(c), height(r + 1, c), z(r + 1)]
|
|
25052
|
+
];
|
|
25053
|
+
const avg = pts.reduce((sum, p) => sum + p[1], 0) / 4;
|
|
25054
|
+
const band = Math.max(
|
|
25055
|
+
0,
|
|
25056
|
+
Math.min(
|
|
25057
|
+
Math.max(0, scale.ticks.length - 2),
|
|
25058
|
+
Math.floor(avg / layout.valueLength * Math.max(1, scale.ticks.length - 1))
|
|
25059
|
+
)
|
|
25060
|
+
);
|
|
25061
|
+
const color = model.series[band % rows2]?.color && HEX2.test(model.series[band % rows2].color) ? model.series[band % rows2].color : BAND_FALLBACK[band % BAND_FALLBACK.length] ?? "#4472C4";
|
|
25062
|
+
const [a, b, , d] = pts;
|
|
25063
|
+
const e1 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
|
25064
|
+
const e2 = [d[0] - a[0], d[1] - a[1], d[2] - a[2]];
|
|
25065
|
+
const nx = e1[1] * e2[2] - e1[2] * e2[1];
|
|
25066
|
+
const ny = e1[2] * e2[0] - e1[0] * e2[2];
|
|
25067
|
+
const nz = e1[0] * e2[1] - e1[1] * e2[0];
|
|
25068
|
+
const len = Math.hypot(nx, ny, nz) || 1;
|
|
25069
|
+
const lit = Math.abs((nx * LIGHT[0] + ny * LIGHT[1] + nz * LIGHT[2]) / len);
|
|
25070
|
+
meshes.push({
|
|
25071
|
+
series: Math.min(r, rows2 - 1),
|
|
25072
|
+
point: c,
|
|
25073
|
+
color,
|
|
25074
|
+
center: [(a[0] + b[0]) / 2, avg, (a[2] + d[2]) / 2],
|
|
25075
|
+
faces: [{ pts, normal: void 0, kind: "top", fill: shade(color, 0.35 * (1 - lit)) }]
|
|
25076
|
+
});
|
|
25077
|
+
}
|
|
25078
|
+
return meshes;
|
|
25079
|
+
}
|
|
25080
|
+
|
|
25081
|
+
// chart/render/chart-3d-walls.ts
|
|
25082
|
+
var LABEL_SIZE = 10;
|
|
25083
|
+
function line3(camera, a, b, color) {
|
|
25084
|
+
const p = camera.project(a);
|
|
25085
|
+
const q = camera.project(b);
|
|
25086
|
+
return `<line x1="${n(p.x)}" y1="${n(p.y)}" x2="${n(q.x)}" y2="${n(q.y)}" stroke="${color}" stroke-width="1"/>`;
|
|
25087
|
+
}
|
|
25088
|
+
function outline2(camera, pts, fill) {
|
|
25089
|
+
const points = pts.map((p) => {
|
|
25090
|
+
const q = camera.project(p);
|
|
25091
|
+
return `${n(q.x)},${n(q.y)}`;
|
|
25092
|
+
}).join(" ");
|
|
25093
|
+
return `<polygon points="${points}" fill="${fill}" stroke="${AXIS_COLOR}" stroke-width="1"/>`;
|
|
25094
|
+
}
|
|
25095
|
+
function chart3DLabelMargins(model) {
|
|
25096
|
+
const scale = model.valueAxis;
|
|
25097
|
+
const value = scale ? Math.max(
|
|
25098
|
+
...scale.ticks.map(
|
|
25099
|
+
(t) => textWidth(axisTickText(t, model.axes?.value, scale.percent), LABEL_SIZE)
|
|
25100
|
+
),
|
|
25101
|
+
8
|
|
25102
|
+
) + 6 : 8;
|
|
25103
|
+
const category = Math.max(...model.categories.map((c) => textWidth(c, LABEL_SIZE)), 8) + 6;
|
|
25104
|
+
return model.horizontal ? { left: Math.min(category, 120), bottom: LABEL_SIZE + 8 } : { left: Math.min(value, 80), bottom: LABEL_SIZE + 8 };
|
|
25105
|
+
}
|
|
25106
|
+
function chart3DWallsSvg(model, layout, camera) {
|
|
25107
|
+
const { w, h, d } = layout.size;
|
|
25108
|
+
const sx = camera.sideWallAtZero ? 0 : w;
|
|
25109
|
+
const out = [];
|
|
25110
|
+
out.push(
|
|
25111
|
+
outline2(
|
|
25112
|
+
camera,
|
|
25113
|
+
[
|
|
25114
|
+
[0, 0, 0],
|
|
25115
|
+
[w, 0, 0],
|
|
25116
|
+
[w, 0, d],
|
|
25117
|
+
[0, 0, d]
|
|
25118
|
+
],
|
|
25119
|
+
"#F2F2F2"
|
|
25120
|
+
)
|
|
25121
|
+
);
|
|
25122
|
+
out.push(
|
|
25123
|
+
outline2(
|
|
25124
|
+
camera,
|
|
25125
|
+
[
|
|
25126
|
+
[0, 0, d],
|
|
25127
|
+
[w, 0, d],
|
|
25128
|
+
[w, h, d],
|
|
25129
|
+
[0, h, d]
|
|
25130
|
+
],
|
|
25131
|
+
"none"
|
|
25132
|
+
)
|
|
25133
|
+
);
|
|
25134
|
+
out.push(
|
|
25135
|
+
outline2(
|
|
25136
|
+
camera,
|
|
25137
|
+
[
|
|
25138
|
+
[sx, 0, 0],
|
|
25139
|
+
[sx, 0, d],
|
|
25140
|
+
[sx, h, d],
|
|
25141
|
+
[sx, h, 0]
|
|
25142
|
+
],
|
|
25143
|
+
"none"
|
|
25144
|
+
)
|
|
25145
|
+
);
|
|
25146
|
+
for (const tick of model.valueAxis?.ticks ?? []) {
|
|
25147
|
+
const p = layout.value(tick);
|
|
25148
|
+
if (layout.horizontal) {
|
|
25149
|
+
out.push(line3(camera, [p, 0, d], [p, h, d], GRID_COLOR));
|
|
25150
|
+
out.push(line3(camera, [p, 0, 0], [p, 0, d], GRID_COLOR));
|
|
25151
|
+
} else {
|
|
25152
|
+
out.push(line3(camera, [0, p, d], [w, p, d], GRID_COLOR));
|
|
25153
|
+
out.push(line3(camera, [sx, p, 0], [sx, p, d], GRID_COLOR));
|
|
25154
|
+
}
|
|
25155
|
+
}
|
|
25156
|
+
return out.join("");
|
|
25157
|
+
}
|
|
25158
|
+
function chart3DLabelsSvg(model, layout, camera, catPos) {
|
|
25159
|
+
const { w } = layout.size;
|
|
25160
|
+
const sx = camera.sideWallAtZero ? 0 : w;
|
|
25161
|
+
const scale = model.valueAxis;
|
|
25162
|
+
const out = [];
|
|
25163
|
+
const anchor = sx === 0 ? "end" : "start";
|
|
25164
|
+
const dx = sx === 0 ? -4 : 4;
|
|
25165
|
+
for (const tick of scale?.ticks ?? []) {
|
|
25166
|
+
const label = axisTickText(tick, model.axes?.value, scale?.percent ?? false);
|
|
25167
|
+
const p = layout.value(tick);
|
|
25168
|
+
if (layout.horizontal) {
|
|
25169
|
+
const q = camera.project([p, 0, 0]);
|
|
25170
|
+
out.push(text(q.x, q.y + LABEL_SIZE + 3, label, { anchor: "middle", size: LABEL_SIZE }));
|
|
25171
|
+
} else {
|
|
25172
|
+
const q = camera.project([sx, p, 0]);
|
|
25173
|
+
out.push(text(q.x + dx, q.y + 3, label, { anchor, size: LABEL_SIZE }));
|
|
25174
|
+
}
|
|
25175
|
+
}
|
|
25176
|
+
const a = camera.project([0, 0, 0]);
|
|
25177
|
+
const b = camera.project(layout.horizontal ? [0, layout.band, 0] : [layout.band, 0, 0]);
|
|
25178
|
+
const bandPx = Math.max(1, layout.horizontal ? Math.abs(b.y - a.y) : Math.abs(b.x - a.x));
|
|
25179
|
+
const extent = layout.horizontal ? LABEL_SIZE + 2 : Math.max(...model.categories.map((c) => textWidth(c, LABEL_SIZE)), 1);
|
|
25180
|
+
const stride = Math.max(1, Math.ceil(extent / bandPx));
|
|
25181
|
+
model.categories.forEach((label, i) => {
|
|
25182
|
+
if (i % stride) return;
|
|
25183
|
+
if (layout.horizontal) {
|
|
25184
|
+
const q = camera.project([sx, catPos(i), 0]);
|
|
25185
|
+
out.push(text(q.x + dx, q.y + 3, label, { anchor, size: LABEL_SIZE }));
|
|
25186
|
+
} else {
|
|
25187
|
+
const q = camera.project([catPos(i), 0, 0]);
|
|
25188
|
+
out.push(text(q.x, q.y + LABEL_SIZE + 3, label, { anchor: "middle", size: LABEL_SIZE }));
|
|
25189
|
+
}
|
|
25190
|
+
});
|
|
25191
|
+
return out.join("");
|
|
25192
|
+
}
|
|
25193
|
+
|
|
25194
|
+
// chart/render/chart-3d-svg.ts
|
|
25195
|
+
var PROJECTION_TYPE = {
|
|
25196
|
+
bar: "bar3D",
|
|
25197
|
+
column: "bar3D",
|
|
25198
|
+
line: "line3D",
|
|
25199
|
+
area: "area3D",
|
|
25200
|
+
pie: "pie3D",
|
|
25201
|
+
surface: "surface"
|
|
25202
|
+
};
|
|
25203
|
+
function chart3DApplies(model) {
|
|
25204
|
+
return model.view3D !== void 0 && PROJECTION_TYPE[model.type] !== void 0;
|
|
25205
|
+
}
|
|
25206
|
+
function chart3DSvg(model, area) {
|
|
25207
|
+
const view = model.view3D ?? {};
|
|
25208
|
+
if (model.type === "pie")
|
|
25209
|
+
return chartAreaRect(model, "plotArea", area) + chart3DPieSvg(model, area, view);
|
|
25210
|
+
const projection = resolveChart3DProjection(PROJECTION_TYPE[model.type] ?? "bar3D", view);
|
|
25211
|
+
const margins = chart3DLabelMargins(model);
|
|
25212
|
+
const inner = {
|
|
25213
|
+
x: area.x + margins.left,
|
|
25214
|
+
y: area.y + 6,
|
|
25215
|
+
w: Math.max(1, area.w - margins.left - 8),
|
|
25216
|
+
h: Math.max(1, area.h - margins.bottom - 10)
|
|
25217
|
+
};
|
|
25218
|
+
const layout = chart3DLayout(model, inner, view);
|
|
25219
|
+
const camera = createChart3DCamera(projection, layout.size, inner);
|
|
25220
|
+
let meshes;
|
|
25221
|
+
if (model.type === "surface") meshes = chart3DSurfaceMeshes(model, layout);
|
|
25222
|
+
else if (model.type === "line") meshes = chart3DLineMeshes(model, layout);
|
|
25223
|
+
else if (model.type === "area") meshes = chart3DAreaMeshes(model, layout);
|
|
25224
|
+
else meshes = chart3DBarMeshes(model, layout);
|
|
25225
|
+
const edge = model.type === "area" || model.type === "surface";
|
|
25226
|
+
const cats = model.categories.length;
|
|
25227
|
+
const catPos = edge ? (i) => cats > 1 ? i / (cats - 1) * layout.catLength : layout.catLength / 2 : (i) => (i + 0.5) * layout.band;
|
|
25228
|
+
return [
|
|
25229
|
+
chartAreaRect(model, "plotArea", area),
|
|
25230
|
+
chart3DWallsSvg(model, layout, camera),
|
|
25231
|
+
chart3DMeshesSvg(camera, meshes),
|
|
25232
|
+
chart3DLabelsSvg(model, layout, camera, catPos)
|
|
25233
|
+
].join("");
|
|
25234
|
+
}
|
|
25235
|
+
|
|
25236
|
+
// chart/region-map/alias.ts
|
|
25237
|
+
var REGION_ALIAS_MAP = {
|
|
25238
|
+
us: "US",
|
|
25239
|
+
usa: "US",
|
|
25240
|
+
"united states": "US",
|
|
25241
|
+
"united states of america": "US",
|
|
25242
|
+
ca: "CA",
|
|
25243
|
+
can: "CA",
|
|
25244
|
+
canada: "CA",
|
|
25245
|
+
br: "BR",
|
|
25246
|
+
bra: "BR",
|
|
25247
|
+
brazil: "BR",
|
|
25248
|
+
gb: "GB",
|
|
25249
|
+
gbr: "GB",
|
|
25250
|
+
uk: "GB",
|
|
25251
|
+
"united kingdom": "GB",
|
|
25252
|
+
fr: "FR",
|
|
25253
|
+
fra: "FR",
|
|
25254
|
+
france: "FR",
|
|
25255
|
+
de: "DE",
|
|
25256
|
+
deu: "DE",
|
|
25257
|
+
germany: "DE",
|
|
25258
|
+
it: "IT",
|
|
25259
|
+
ita: "IT",
|
|
25260
|
+
italy: "IT",
|
|
25261
|
+
es: "ES",
|
|
25262
|
+
esp: "ES",
|
|
25263
|
+
spain: "ES",
|
|
25264
|
+
ru: "RU",
|
|
25265
|
+
rus: "RU",
|
|
25266
|
+
russia: "RU",
|
|
25267
|
+
cn: "CN",
|
|
25268
|
+
chn: "CN",
|
|
25269
|
+
china: "CN",
|
|
25270
|
+
in: "IN",
|
|
25271
|
+
ind: "IN",
|
|
25272
|
+
india: "IN",
|
|
25273
|
+
jp: "JP",
|
|
25274
|
+
jpn: "JP",
|
|
25275
|
+
japan: "JP",
|
|
25276
|
+
kr: "KR",
|
|
25277
|
+
kor: "KR",
|
|
25278
|
+
"south korea": "KR",
|
|
25279
|
+
korea: "KR",
|
|
25280
|
+
au: "AU",
|
|
25281
|
+
aus: "AU",
|
|
25282
|
+
australia: "AU",
|
|
25283
|
+
mx: "MX",
|
|
25284
|
+
mex: "MX",
|
|
25285
|
+
mexico: "MX",
|
|
25286
|
+
id: "ID",
|
|
25287
|
+
idn: "ID",
|
|
25288
|
+
indonesia: "ID",
|
|
25289
|
+
tr: "TR",
|
|
25290
|
+
tur: "TR",
|
|
25291
|
+
turkey: "TR",
|
|
25292
|
+
sa: "SA",
|
|
25293
|
+
sau: "SA",
|
|
25294
|
+
"saudi arabia": "SA",
|
|
25295
|
+
za: "ZA",
|
|
25296
|
+
zaf: "ZA",
|
|
25297
|
+
"south africa": "ZA",
|
|
25298
|
+
ar: "AR",
|
|
25299
|
+
arg: "AR",
|
|
25300
|
+
argentina: "AR",
|
|
25301
|
+
ng: "NG",
|
|
25302
|
+
nga: "NG",
|
|
25303
|
+
nigeria: "NG",
|
|
25304
|
+
eg: "EG",
|
|
25305
|
+
egy: "EG",
|
|
25306
|
+
egypt: "EG"
|
|
25307
|
+
};
|
|
25308
|
+
function resolveRegionCode(label) {
|
|
25309
|
+
const normalized = label.trim().toLowerCase();
|
|
25310
|
+
return REGION_ALIAS_MAP[normalized];
|
|
25311
|
+
}
|
|
25312
|
+
|
|
25313
|
+
// chart/region-map/data.ts
|
|
25314
|
+
function sourceIndices(indices, length) {
|
|
25315
|
+
return Array.from({ length }, (_, position2) => indices?.[position2] ?? position2);
|
|
25316
|
+
}
|
|
25317
|
+
function valueAtSource(values, indices, sourceIndex) {
|
|
25318
|
+
const position2 = indices.indexOf(sourceIndex);
|
|
25319
|
+
return position2 >= 0 ? values[position2] : void 0;
|
|
25320
|
+
}
|
|
25321
|
+
function cachedEntityName(cache, entityId) {
|
|
25322
|
+
if (!cache || typeof cache !== "object") {
|
|
25323
|
+
return void 0;
|
|
25324
|
+
}
|
|
25325
|
+
const record = cache;
|
|
25326
|
+
if (String(record["@_entityId"] ?? "") === entityId && record["@_entityName"] !== void 0) {
|
|
25327
|
+
return String(record["@_entityName"]);
|
|
25328
|
+
}
|
|
25329
|
+
for (const value of Object.values(record)) {
|
|
25330
|
+
if (Array.isArray(value)) {
|
|
25331
|
+
for (const item2 of value) {
|
|
25332
|
+
const name = cachedEntityName(item2, entityId);
|
|
25333
|
+
if (name) {
|
|
25334
|
+
return name;
|
|
25335
|
+
}
|
|
25336
|
+
}
|
|
25337
|
+
} else {
|
|
25338
|
+
const name = cachedEntityName(value, entityId);
|
|
25339
|
+
if (name) {
|
|
25340
|
+
return name;
|
|
25341
|
+
}
|
|
25342
|
+
}
|
|
25343
|
+
}
|
|
25344
|
+
return void 0;
|
|
25345
|
+
}
|
|
25346
|
+
function resolveRegionEntityCode(entityId, options2, resolveCode) {
|
|
25347
|
+
if (!entityId) {
|
|
25348
|
+
return void 0;
|
|
25349
|
+
}
|
|
25350
|
+
const direct = resolveCode(entityId);
|
|
25351
|
+
if (direct) {
|
|
25352
|
+
return direct;
|
|
25353
|
+
}
|
|
25354
|
+
const tokens = entityId.split(/[:/|._-]+/u).filter(Boolean);
|
|
25355
|
+
for (let index = tokens.length - 1; index >= 0; index--) {
|
|
25356
|
+
const resolved = resolveCode(tokens[index] ?? "");
|
|
25357
|
+
if (resolved) {
|
|
25358
|
+
return resolved;
|
|
25359
|
+
}
|
|
25360
|
+
}
|
|
25361
|
+
const cachedName = cachedEntityName(options2?.geographyCache, entityId);
|
|
25362
|
+
return cachedName ? resolveCode(cachedName) : void 0;
|
|
25363
|
+
}
|
|
25364
|
+
function buildRegionMapEntries(categories, values, options2, resolveCode) {
|
|
25365
|
+
const entityIds = options2?.entityIds ?? [];
|
|
25366
|
+
const categoryIndices = sourceIndices(options2?.categorySourceIndices, categories.length);
|
|
25367
|
+
const valueIndices = sourceIndices(options2?.valueSourceIndices, values.length);
|
|
25368
|
+
const entityIndices = sourceIndices(options2?.entityIdSourceIndices, entityIds.length);
|
|
25369
|
+
const indices = [.../* @__PURE__ */ new Set([...categoryIndices, ...valueIndices, ...entityIndices])].sort(
|
|
25370
|
+
(a, b) => a - b
|
|
25371
|
+
);
|
|
25372
|
+
return indices.flatMap((sourceIndex) => {
|
|
25373
|
+
const category = valueAtSource(categories, categoryIndices, sourceIndex) ?? "";
|
|
25374
|
+
const value = valueAtSource(values, valueIndices, sourceIndex);
|
|
25375
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return [];
|
|
25376
|
+
const entityId = valueAtSource(entityIds, entityIndices, sourceIndex);
|
|
25377
|
+
const code = resolveRegionEntityCode(entityId, options2, resolveCode) ?? resolveCode(category);
|
|
25378
|
+
return {
|
|
25379
|
+
sourceIndex,
|
|
25380
|
+
label: category || entityId || `Region ${sourceIndex + 1}`,
|
|
25381
|
+
value,
|
|
25382
|
+
...entityId ? { entityId } : {},
|
|
25383
|
+
...code ? { code } : {}
|
|
25384
|
+
};
|
|
25385
|
+
});
|
|
25386
|
+
}
|
|
25387
|
+
function shouldRenderRegionLabel(layout, projectedWidth, projectedHeight) {
|
|
25388
|
+
if (!layout || layout === "none") {
|
|
25389
|
+
return false;
|
|
25390
|
+
}
|
|
25391
|
+
if (layout === "bestFitOnly") {
|
|
25392
|
+
return projectedWidth >= 18 && projectedHeight >= 10;
|
|
25393
|
+
}
|
|
25394
|
+
return true;
|
|
25395
|
+
}
|
|
25396
|
+
function formatRegionMapValue(value, cultureLanguage) {
|
|
25397
|
+
if (!cultureLanguage) {
|
|
25398
|
+
return String(value);
|
|
25399
|
+
}
|
|
25400
|
+
try {
|
|
25401
|
+
return new Intl.NumberFormat(cultureLanguage, { maximumFractionDigits: 2 }).format(value);
|
|
25402
|
+
} catch {
|
|
25403
|
+
return String(value);
|
|
25404
|
+
}
|
|
25405
|
+
}
|
|
25406
|
+
function lerpColor(a, b, t) {
|
|
25407
|
+
const clamp4 = (v) => Math.max(0, Math.min(255, Math.round(v))), ha = a.replace("#", ""), hb = b.replace("#", ""), r1 = parseInt(ha.substring(0, 2), 16), g1 = parseInt(ha.substring(2, 4), 16), b1 = parseInt(ha.substring(4, 6), 16), r2 = parseInt(hb.substring(0, 2), 16), g2 = parseInt(hb.substring(2, 4), 16), b2 = parseInt(hb.substring(4, 6), 16), r = clamp4(r1 + (r2 - r1) * t), g = clamp4(g1 + (g2 - g1) * t), bl = clamp4(b1 + (b2 - b1) * t), toHex2 = (n2) => n2.toString(16).padStart(2, "0");
|
|
25408
|
+
return `#${toHex2(r)}${toHex2(g)}${toHex2(bl)}`;
|
|
25409
|
+
}
|
|
25410
|
+
function resolveValueColorStops(valueColors, valueColorPositions, minVal, maxVal) {
|
|
25411
|
+
if (!valueColors || valueColors.length < 2) {
|
|
25412
|
+
return void 0;
|
|
25413
|
+
}
|
|
25414
|
+
const span = maxVal - minVal || 1, count = valueColors.length, resolvePosition = (position2, index) => {
|
|
25415
|
+
if (position2?.kind === "min") {
|
|
25416
|
+
return 0;
|
|
25417
|
+
}
|
|
25418
|
+
if (position2?.kind === "max") {
|
|
25419
|
+
return 1;
|
|
25420
|
+
}
|
|
25421
|
+
if (position2?.kind === "number" && position2.value !== void 0) {
|
|
25422
|
+
return Math.min(1, Math.max(0, (position2.value - minVal) / span));
|
|
25423
|
+
}
|
|
25424
|
+
if (position2?.kind === "percent" && position2.value !== void 0) {
|
|
25425
|
+
return Math.min(1, Math.max(0, position2.value / 100));
|
|
25426
|
+
}
|
|
25427
|
+
return count === 1 ? 0 : index / (count - 1);
|
|
25428
|
+
};
|
|
25429
|
+
return valueColors.map((color, index) => ({
|
|
25430
|
+
color,
|
|
25431
|
+
position: resolvePosition(valueColorPositions?.[index], index)
|
|
25432
|
+
}));
|
|
25433
|
+
}
|
|
25434
|
+
function buildValueColorScale(stops) {
|
|
25435
|
+
const sorted = [...stops].sort((a, b) => a.position - b.position);
|
|
25436
|
+
return (t) => {
|
|
25437
|
+
const clamped = Math.max(0, Math.min(1, t)), first3 = sorted[0];
|
|
25438
|
+
if (!first3) {
|
|
25439
|
+
return "#94a3b8";
|
|
25440
|
+
}
|
|
25441
|
+
if (sorted.length === 1) {
|
|
25442
|
+
return first3.color;
|
|
25443
|
+
}
|
|
25444
|
+
for (let i = 0; i < sorted.length - 1; i++) {
|
|
25445
|
+
const a = sorted[i], b = sorted[i + 1];
|
|
25446
|
+
if (clamped >= a.position && clamped <= b.position) {
|
|
25447
|
+
return lerpColor(
|
|
25448
|
+
a.color,
|
|
25449
|
+
b.color,
|
|
25450
|
+
(clamped - a.position) / (b.position - a.position || 1)
|
|
25451
|
+
);
|
|
25452
|
+
}
|
|
25453
|
+
}
|
|
25454
|
+
const last = sorted[sorted.length - 1] ?? first3;
|
|
25455
|
+
return clamped <= first3.position ? first3.color : last.color;
|
|
25456
|
+
};
|
|
25457
|
+
}
|
|
25458
|
+
|
|
25459
|
+
// chart/region-map/colors.ts
|
|
25460
|
+
function sequentialColorScale(t, accent) {
|
|
25461
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
25462
|
+
if (accent && /^#[0-9a-f]{6}$/iu.test(accent))
|
|
25463
|
+
return lerpColor(lerpColor("#ffffff", accent, 0.2), accent, clamped);
|
|
25464
|
+
if (clamped <= 0.5) {
|
|
25465
|
+
return lerpColor("#dbeafe", "#3b82f6", clamped * 2);
|
|
25466
|
+
}
|
|
25467
|
+
return lerpColor("#3b82f6", "#1e3a5f", (clamped - 0.5) * 2);
|
|
25468
|
+
}
|
|
25469
|
+
function normalizeValue(value, min, max) {
|
|
25470
|
+
if (max === min) {
|
|
25471
|
+
return 0.5;
|
|
25472
|
+
}
|
|
25473
|
+
return (value - min) / (max - min);
|
|
25474
|
+
}
|
|
25475
|
+
|
|
25476
|
+
// chart/region-map/world-regions.ts
|
|
25477
|
+
var WORLD_REGIONS = [
|
|
25478
|
+
{
|
|
25479
|
+
code: "US",
|
|
25480
|
+
name: "United States",
|
|
25481
|
+
path: "M130,160 L250,155 265,170 270,190 260,210 230,215 200,220 170,215 145,205 130,195Z M280,175 L295,165 310,170 310,185 295,195 280,190Z",
|
|
25482
|
+
labelXY: [200, 190]
|
|
25483
|
+
},
|
|
25484
|
+
{
|
|
25485
|
+
code: "CA",
|
|
25486
|
+
name: "Canada",
|
|
25487
|
+
path: "M120,90 L280,85 290,100 295,130 280,150 250,155 200,155 160,155 130,155 115,140 110,115Z",
|
|
25488
|
+
labelXY: [200, 125]
|
|
25489
|
+
},
|
|
25490
|
+
{
|
|
25491
|
+
code: "MX",
|
|
25492
|
+
name: "Mexico",
|
|
25493
|
+
path: "M145,215 L200,220 210,235 200,255 185,265 165,260 150,245 140,230Z",
|
|
25494
|
+
labelXY: [175, 240]
|
|
25495
|
+
},
|
|
25496
|
+
{
|
|
25497
|
+
code: "BR",
|
|
25498
|
+
name: "Brazil",
|
|
25499
|
+
path: "M270,300 L310,280 335,290 340,320 330,355 310,370 285,365 265,345 260,320Z",
|
|
25500
|
+
labelXY: [300, 330]
|
|
25501
|
+
},
|
|
25502
|
+
{
|
|
25503
|
+
code: "AR",
|
|
25504
|
+
name: "Argentina",
|
|
25505
|
+
path: "M260,370 L280,365 290,380 285,410 275,435 260,445 250,425 248,395Z",
|
|
25506
|
+
labelXY: [268, 410]
|
|
25507
|
+
},
|
|
25508
|
+
{
|
|
25509
|
+
code: "GB",
|
|
25510
|
+
name: "United Kingdom",
|
|
25511
|
+
path: "M440,120 L448,110 455,115 455,135 448,142 440,138Z",
|
|
25512
|
+
labelXY: [448, 128]
|
|
25513
|
+
},
|
|
25514
|
+
{
|
|
25515
|
+
code: "FR",
|
|
25516
|
+
name: "France",
|
|
25517
|
+
path: "M450,145 L470,140 480,150 478,168 465,175 450,170 445,158Z",
|
|
25518
|
+
labelXY: [463, 158]
|
|
25519
|
+
},
|
|
25520
|
+
{
|
|
25521
|
+
code: "DE",
|
|
25522
|
+
name: "Germany",
|
|
25523
|
+
path: "M478,125 L498,120 505,130 502,148 490,152 478,148 475,138Z",
|
|
25524
|
+
labelXY: [490, 138]
|
|
25525
|
+
},
|
|
25526
|
+
{
|
|
25527
|
+
code: "IT",
|
|
25528
|
+
name: "Italy",
|
|
25529
|
+
path: "M490,155 L498,152 505,162 500,180 492,190 488,178 486,165Z",
|
|
25530
|
+
labelXY: [495, 172]
|
|
25531
|
+
},
|
|
25532
|
+
{
|
|
25533
|
+
code: "ES",
|
|
25534
|
+
name: "Spain",
|
|
25535
|
+
path: "M432,168 L460,165 465,175 460,188 442,192 430,185 428,175Z",
|
|
25536
|
+
labelXY: [448, 180]
|
|
25537
|
+
},
|
|
25538
|
+
{
|
|
25539
|
+
code: "RU",
|
|
25540
|
+
name: "Russia",
|
|
25541
|
+
path: "M510,60 L780,50 830,70 840,100 820,120 750,115 700,105 650,100 580,105 530,110 510,100 505,80Z",
|
|
25542
|
+
labelXY: [670, 85]
|
|
25543
|
+
},
|
|
25544
|
+
{
|
|
25545
|
+
code: "TR",
|
|
25546
|
+
name: "Turkey",
|
|
25547
|
+
path: "M530,165 L570,160 585,170 580,182 555,185 530,180Z",
|
|
25548
|
+
labelXY: [558, 175]
|
|
25549
|
+
},
|
|
25550
|
+
{
|
|
25551
|
+
code: "EG",
|
|
25552
|
+
name: "Egypt",
|
|
25553
|
+
path: "M530,200 L555,195 565,205 560,225 545,230 530,222Z",
|
|
25554
|
+
labelXY: [548, 215]
|
|
25555
|
+
},
|
|
25556
|
+
{
|
|
25557
|
+
code: "NG",
|
|
25558
|
+
name: "Nigeria",
|
|
25559
|
+
path: "M475,275 L500,270 510,280 505,298 490,302 475,295Z",
|
|
25560
|
+
labelXY: [492, 288]
|
|
25561
|
+
},
|
|
25562
|
+
{
|
|
25563
|
+
code: "ZA",
|
|
25564
|
+
name: "South Africa",
|
|
25565
|
+
path: "M520,380 L545,370 560,380 555,400 540,410 520,405 515,392Z",
|
|
25566
|
+
labelXY: [538, 392]
|
|
25567
|
+
},
|
|
25568
|
+
{
|
|
25569
|
+
code: "SA",
|
|
25570
|
+
name: "Saudi Arabia",
|
|
25571
|
+
path: "M565,220 L600,210 615,225 610,250 590,258 570,250 560,238Z",
|
|
25572
|
+
labelXY: [590, 238]
|
|
25573
|
+
},
|
|
25574
|
+
{
|
|
25575
|
+
code: "IN",
|
|
25576
|
+
name: "India",
|
|
25577
|
+
path: "M640,210 L665,195 685,210 688,240 678,268 660,278 645,265 635,240Z",
|
|
25578
|
+
labelXY: [662, 240]
|
|
25579
|
+
},
|
|
25580
|
+
{
|
|
25581
|
+
code: "CN",
|
|
25582
|
+
name: "China",
|
|
25583
|
+
path: "M700,120 L775,115 800,130 805,160 790,180 760,185 730,180 710,168 695,150 690,135Z",
|
|
25584
|
+
labelXY: [750, 155]
|
|
25585
|
+
},
|
|
25586
|
+
{
|
|
25587
|
+
code: "JP",
|
|
25588
|
+
name: "Japan",
|
|
25589
|
+
path: "M835,145 L845,135 852,140 850,158 842,165 835,160Z",
|
|
25590
|
+
labelXY: [843, 152]
|
|
25591
|
+
},
|
|
25592
|
+
{
|
|
25593
|
+
code: "KR",
|
|
25594
|
+
name: "South Korea",
|
|
25595
|
+
path: "M815,158 L825,152 830,160 827,170 818,172 813,165Z",
|
|
25596
|
+
labelXY: [822, 163]
|
|
25597
|
+
},
|
|
25598
|
+
{
|
|
25599
|
+
code: "ID",
|
|
25600
|
+
name: "Indonesia",
|
|
25601
|
+
path: "M740,295 L780,288 810,292 830,298 825,310 790,312 755,308 740,305Z",
|
|
25602
|
+
labelXY: [785, 302]
|
|
25603
|
+
},
|
|
25604
|
+
{
|
|
25605
|
+
code: "AU",
|
|
25606
|
+
name: "Australia",
|
|
25607
|
+
path: "M790,350 L850,340 880,355 885,385 870,405 840,410 810,400 790,380Z",
|
|
25608
|
+
labelXY: [838, 378]
|
|
25609
|
+
}
|
|
25610
|
+
];
|
|
25611
|
+
|
|
25612
|
+
// chart/region-map/projection.ts
|
|
25613
|
+
function regionBounds(region) {
|
|
25614
|
+
const coordinates = region.path.match(/-?\d+(?:\.\d+)?/gu)?.map(Number) ?? [];
|
|
25615
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
25616
|
+
for (let index = 0; index < coordinates.length; index += 2) {
|
|
25617
|
+
const x = coordinates[index] ?? 0, y = coordinates[index + 1] ?? 0;
|
|
25618
|
+
minX = Math.min(minX, x);
|
|
25619
|
+
maxX = Math.max(maxX, x);
|
|
25620
|
+
minY = Math.min(minY, y);
|
|
25621
|
+
maxY = Math.max(maxY, y);
|
|
25622
|
+
}
|
|
25623
|
+
return { minX, minY, maxX, maxY };
|
|
25624
|
+
}
|
|
25625
|
+
function regionViewBounds(viewedRegionType, regionValues, regions = WORLD_REGIONS) {
|
|
25626
|
+
if (!viewedRegionType || viewedRegionType === "world" || regionValues.size === 0) {
|
|
25627
|
+
return { minX: 0, minY: 0, maxX: 1e3, maxY: 500 };
|
|
25628
|
+
}
|
|
25629
|
+
const matched = regions.filter((region) => regionValues.has(region.code));
|
|
25630
|
+
const targets = viewedRegionType === "countryRegion" ? matched.slice(0, 1) : matched;
|
|
25631
|
+
if (targets.length === 0) {
|
|
25632
|
+
return { minX: 0, minY: 0, maxX: 1e3, maxY: 500 };
|
|
25633
|
+
}
|
|
25634
|
+
const bounds = targets.map(regionBounds);
|
|
25635
|
+
const padding = 10;
|
|
25636
|
+
return {
|
|
25637
|
+
minX: Math.max(0, Math.min(...bounds.map((item2) => item2.minX)) - padding),
|
|
25638
|
+
minY: Math.max(0, Math.min(...bounds.map((item2) => item2.minY)) - padding),
|
|
25639
|
+
maxX: Math.min(1e3, Math.max(...bounds.map((item2) => item2.maxX)) + padding),
|
|
25640
|
+
maxY: Math.min(500, Math.max(...bounds.map((item2) => item2.maxY)) + padding)
|
|
25641
|
+
};
|
|
25642
|
+
}
|
|
25643
|
+
function scalePathD(d, scale, dx, dy) {
|
|
25644
|
+
const tokens = d.match(/[A-Za-z]|-?\d+(?:\.\d+)?/gu) ?? [];
|
|
25645
|
+
const out = [];
|
|
25646
|
+
let i = 0;
|
|
25647
|
+
while (i < tokens.length) {
|
|
25648
|
+
const tok = tokens[i];
|
|
25649
|
+
if (tok === void 0) {
|
|
25650
|
+
i++;
|
|
25651
|
+
continue;
|
|
25652
|
+
}
|
|
25653
|
+
if (/^[A-Za-z]$/u.test(tok)) {
|
|
25654
|
+
out.push(tok);
|
|
25655
|
+
i++;
|
|
25656
|
+
continue;
|
|
25657
|
+
}
|
|
25658
|
+
const xRaw = parseFloat(tok);
|
|
25659
|
+
const yRaw = parseFloat(tokens[i + 1] ?? "");
|
|
25660
|
+
if (!Number.isNaN(xRaw) && !Number.isNaN(yRaw)) {
|
|
25661
|
+
out.push(`${(xRaw * scale + dx).toFixed(2)},${(yRaw * scale + dy).toFixed(2)}`);
|
|
25662
|
+
i += 2;
|
|
25663
|
+
} else {
|
|
25664
|
+
out.push(tok);
|
|
25665
|
+
i++;
|
|
25666
|
+
}
|
|
25667
|
+
}
|
|
25668
|
+
return out.join(" ");
|
|
25669
|
+
}
|
|
25670
|
+
var CX = "http://schemas.microsoft.com/office/drawing/2014/chartex";
|
|
25671
|
+
var LIMIT = 16 * 1024 * 1024;
|
|
25672
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
|
|
25673
|
+
function decodeGeoRing(encoded, limit = 1e6) {
|
|
25674
|
+
const out = [];
|
|
25675
|
+
let lat = 0, lon = 0, number = 0, shift = 0;
|
|
25676
|
+
for (const ch of encoded) {
|
|
25677
|
+
const value = ALPHABET.indexOf(ch);
|
|
25678
|
+
if (value < 0 || shift > 50) return void 0;
|
|
25679
|
+
number += (value & 31) * 2 ** shift;
|
|
25680
|
+
if (!Number.isSafeInteger(number)) return void 0;
|
|
25681
|
+
if (value >= 32) {
|
|
25682
|
+
shift += 5;
|
|
25683
|
+
continue;
|
|
25684
|
+
}
|
|
25685
|
+
const diagonal = Math.floor((Math.sqrt(8 * number + 1) - 1) / 2);
|
|
25686
|
+
const a = number - diagonal * (diagonal + 1) / 2, b = diagonal - a;
|
|
25687
|
+
lat += a % 2 ? -(a + 1) / 2 : a / 2;
|
|
25688
|
+
lon += b % 2 ? -(b + 1) / 2 : b / 2;
|
|
25689
|
+
if (Math.abs(lat) > 9e6 || Math.abs(lon) > 54e6 || out.length >= limit) return void 0;
|
|
25690
|
+
out.push({ latitude: lat / 1e5, longitude: lon / 1e5 });
|
|
25691
|
+
number = 0;
|
|
25692
|
+
shift = 0;
|
|
25693
|
+
}
|
|
25694
|
+
return shift || out.length < 3 ? void 0 : out;
|
|
25695
|
+
}
|
|
25696
|
+
function elements2(root, name) {
|
|
25697
|
+
return Array.from(root.getElementsByTagNameNS(CX, name));
|
|
25698
|
+
}
|
|
25699
|
+
function inflateGeoCache(binary, maxOutputBytes = LIMIT) {
|
|
25700
|
+
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || maxOutputBytes > LIMIT)
|
|
25701
|
+
throw new Error("Invalid geography cache output limit.");
|
|
25702
|
+
if (binary.length > 12 * 1024 * 1024) throw new Error("Geography cache input limit exceeded.");
|
|
25703
|
+
const bytes = Uint8Array.from(atob(binary.replace(/\s/gu, "")), (c) => c.charCodeAt(0));
|
|
25704
|
+
const chunks = [];
|
|
25705
|
+
let size = 0;
|
|
25706
|
+
const stream = new fflate.Inflate((chunk) => {
|
|
25707
|
+
size += chunk.length;
|
|
25708
|
+
if (size > maxOutputBytes) throw new Error("Geography cache output limit exceeded.");
|
|
25709
|
+
chunks.push(chunk);
|
|
25710
|
+
});
|
|
25711
|
+
for (let i = 0; i < bytes.length; i += 256)
|
|
25712
|
+
stream.push(bytes.subarray(i, i + 256), false);
|
|
25713
|
+
const out = new Uint8Array(size);
|
|
25714
|
+
let offset = 0;
|
|
25715
|
+
for (const chunk of chunks) {
|
|
25716
|
+
out.set(chunk, offset);
|
|
25717
|
+
offset += chunk.length;
|
|
25718
|
+
}
|
|
25719
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(out);
|
|
25720
|
+
}
|
|
25721
|
+
function readGeographyCache(xml, pointLimit = 1e6) {
|
|
25722
|
+
const result = { regions: [], issues: [] };
|
|
25723
|
+
if (!xml) return result;
|
|
25724
|
+
try {
|
|
25725
|
+
if (!Number.isSafeInteger(pointLimit) || pointLimit < 1 || pointLimit > 1e6)
|
|
25726
|
+
throw new Error("Invalid geography point limit.");
|
|
25727
|
+
if (xml.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
|
|
25728
|
+
let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml}</cx:root>`).documentElement;
|
|
25729
|
+
const binary = elements2(root, "binary")[0];
|
|
25730
|
+
if (binary) root = parseXml(inflateGeoCache(binary.textContent ?? "")).documentElement;
|
|
25731
|
+
let points = 0;
|
|
25732
|
+
for (const data of elements2(root, "geoData")) {
|
|
25733
|
+
const rings = [];
|
|
25734
|
+
for (const polygon of elements2(data, "geoPolygon")) {
|
|
25735
|
+
const parts = (polygon.getAttribute("pcaRings") ?? "").split(",");
|
|
25736
|
+
const version = Number(parts.shift());
|
|
25737
|
+
const expected = Number(polygon.getAttribute("numPoints"));
|
|
25738
|
+
if (version !== 1 || parts.length < 1 || !Number.isInteger(expected) || expected < 3) {
|
|
25739
|
+
result.issues.push("Invalid geography ring count.");
|
|
25740
|
+
continue;
|
|
25741
|
+
}
|
|
25742
|
+
const decoded = [];
|
|
25743
|
+
let polygonPoints2 = 0;
|
|
25744
|
+
for (const part of parts) {
|
|
25745
|
+
const ring = decodeGeoRing(
|
|
25746
|
+
part,
|
|
25747
|
+
Math.min(expected - polygonPoints2, pointLimit - points - polygonPoints2)
|
|
25748
|
+
);
|
|
25749
|
+
if (!ring) break;
|
|
25750
|
+
decoded.push(ring);
|
|
25751
|
+
polygonPoints2 += ring.length;
|
|
25752
|
+
}
|
|
25753
|
+
if (decoded.length !== parts.length) {
|
|
25754
|
+
result.issues.push("Invalid compressed geography polygon.");
|
|
25755
|
+
continue;
|
|
25756
|
+
}
|
|
25757
|
+
for (const ring of decoded) {
|
|
25758
|
+
rings.push(ring);
|
|
25759
|
+
points += ring.length;
|
|
25760
|
+
}
|
|
25761
|
+
}
|
|
25762
|
+
if (rings.length)
|
|
25763
|
+
result.regions.push({
|
|
25764
|
+
entityId: data.getAttribute("entityId") ?? "",
|
|
25765
|
+
name: data.getAttribute("entityName") ?? "",
|
|
25766
|
+
rings,
|
|
25767
|
+
copyright: elements2(data, "copyright").map((c) => c.textContent ?? "")
|
|
25768
|
+
});
|
|
25769
|
+
}
|
|
25770
|
+
} catch (error) {
|
|
25771
|
+
result.issues.push(error instanceof Error ? error.message : String(error));
|
|
25772
|
+
}
|
|
25773
|
+
return result;
|
|
25774
|
+
}
|
|
25775
|
+
|
|
25776
|
+
// chart/region-map/geographic-projection.ts
|
|
25777
|
+
var RAD = Math.PI / 180;
|
|
25778
|
+
var RX = [
|
|
25779
|
+
1,
|
|
25780
|
+
0.9986,
|
|
25781
|
+
0.9954,
|
|
25782
|
+
0.99,
|
|
25783
|
+
0.9822,
|
|
25784
|
+
0.973,
|
|
25785
|
+
0.96,
|
|
25786
|
+
0.9427,
|
|
25787
|
+
0.9216,
|
|
25788
|
+
0.8962,
|
|
25789
|
+
0.8679,
|
|
25790
|
+
0.835,
|
|
25791
|
+
0.7986,
|
|
25792
|
+
0.7597,
|
|
25793
|
+
0.7186,
|
|
25794
|
+
0.6732,
|
|
25795
|
+
0.6213,
|
|
25796
|
+
0.5722,
|
|
25797
|
+
0.5322
|
|
25798
|
+
];
|
|
25799
|
+
var RY = [
|
|
25800
|
+
0,
|
|
25801
|
+
0.062,
|
|
25802
|
+
0.124,
|
|
25803
|
+
0.186,
|
|
25804
|
+
0.248,
|
|
25805
|
+
0.31,
|
|
25806
|
+
0.372,
|
|
25807
|
+
0.434,
|
|
25808
|
+
0.4958,
|
|
25809
|
+
0.5571,
|
|
25810
|
+
0.6176,
|
|
25811
|
+
0.6769,
|
|
25812
|
+
0.7346,
|
|
25813
|
+
0.7903,
|
|
25814
|
+
0.8435,
|
|
25815
|
+
0.8936,
|
|
25816
|
+
0.9394,
|
|
25817
|
+
0.9761,
|
|
25818
|
+
1
|
|
25819
|
+
];
|
|
25820
|
+
function projectGeoPoint(point, projection = "mercator") {
|
|
25821
|
+
const lon = point.longitude * RAD, lat = Math.max(-89.999, Math.min(89.999, point.latitude)) * RAD;
|
|
25822
|
+
if (projection === "mercator")
|
|
25823
|
+
return [
|
|
25824
|
+
lon,
|
|
25825
|
+
-Math.log(
|
|
25826
|
+
Math.tan(Math.PI / 4 + Math.max(-85.05112878 * RAD, Math.min(85.05112878 * RAD, lat)) / 2)
|
|
25827
|
+
)
|
|
25828
|
+
];
|
|
25829
|
+
if (projection === "miller") return [lon, -1.25 * Math.log(Math.tan(Math.PI / 4 + 0.4 * lat))];
|
|
25830
|
+
if (projection === "robinson") {
|
|
25831
|
+
const index = Math.min(17, Math.floor(Math.abs(point.latitude) / 5)), t = Math.min(1, Math.abs(point.latitude) / 5 - index);
|
|
25832
|
+
return [
|
|
25833
|
+
0.8487 * lon * (RX[index] + (RX[index + 1] - RX[index]) * t),
|
|
25834
|
+
-1.3523 * Math.sign(lat) * (RY[index] + (RY[index + 1] - RY[index]) * t)
|
|
25835
|
+
];
|
|
25836
|
+
}
|
|
25837
|
+
if (projection === "albers") {
|
|
25838
|
+
const n2 = (Math.sin(20 * RAD) + Math.sin(50 * RAD)) / 2;
|
|
25839
|
+
const c = Math.cos(20 * RAD) ** 2 + 2 * n2 * Math.sin(20 * RAD);
|
|
25840
|
+
const rho = Math.sqrt(Math.max(0, c - 2 * n2 * Math.sin(lat))) / n2;
|
|
25841
|
+
return [rho * Math.sin(n2 * lon), rho * Math.cos(n2 * lon) - Math.sqrt(c) / n2];
|
|
25842
|
+
}
|
|
25843
|
+
return void 0;
|
|
25844
|
+
}
|
|
25845
|
+
|
|
25846
|
+
// chart/region-map/geometry.ts
|
|
25847
|
+
function regionMapGeometry(options2) {
|
|
25848
|
+
const cache = readGeographyCache(options2?.geographyCacheXml);
|
|
25849
|
+
if (!cache.regions.length)
|
|
25850
|
+
return { regions: WORLD_REGIONS, approximate: true, issues: cache.issues, copyright: [] };
|
|
25851
|
+
const projection = options2?.projectionType ?? "robinson";
|
|
25852
|
+
const projected = cache.regions.map((region) => ({
|
|
25853
|
+
region,
|
|
25854
|
+
rings: region.rings.map((ring) => ring.map((p) => projectGeoPoint(p, projection)))
|
|
25855
|
+
}));
|
|
25856
|
+
if (projected.some((r) => r.rings.some((ring) => ring.some((p) => !p))))
|
|
25857
|
+
return {
|
|
25858
|
+
regions: [],
|
|
25859
|
+
approximate: false,
|
|
25860
|
+
issues: [...cache.issues, "Unsupported geographic projection."],
|
|
25861
|
+
copyright: []
|
|
25862
|
+
};
|
|
25863
|
+
const all = projected.flatMap((r) => r.rings.flatMap((ring) => ring));
|
|
25864
|
+
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
25865
|
+
for (const [x, y] of all) {
|
|
25866
|
+
minX = Math.min(minX, x);
|
|
25867
|
+
maxX = Math.max(maxX, x);
|
|
25868
|
+
minY = Math.min(minY, y);
|
|
25869
|
+
maxY = Math.max(maxY, y);
|
|
25870
|
+
}
|
|
25871
|
+
const factor = Math.min(1e3 / Math.max(maxX - minX, 1e-12), 500 / Math.max(maxY - minY, 1e-12));
|
|
25872
|
+
const sx = factor, sy = factor, ox = (1e3 - (maxX - minX) * factor) / 2, oy = (500 - (maxY - minY) * factor) / 2;
|
|
25873
|
+
const regions = projected.map(({ region, rings }) => {
|
|
25874
|
+
const paths = rings.map(
|
|
25875
|
+
(ring) => ring.map((p) => {
|
|
25876
|
+
const [x2, y2] = p;
|
|
25877
|
+
return [(x2 - minX) * sx + ox, (y2 - minY) * sy + oy];
|
|
25878
|
+
})
|
|
25879
|
+
);
|
|
25880
|
+
const coords = paths.flat();
|
|
25881
|
+
let x = 0, y = 0;
|
|
25882
|
+
for (const p of coords) {
|
|
25883
|
+
x += p[0];
|
|
25884
|
+
y += p[1];
|
|
25885
|
+
}
|
|
25886
|
+
return {
|
|
25887
|
+
code: resolveRegionCode(region.name) ?? region.entityId,
|
|
25888
|
+
entityId: region.entityId,
|
|
25889
|
+
name: region.name,
|
|
25890
|
+
labelXY: [x / coords.length, y / coords.length],
|
|
25891
|
+
path: paths.map(
|
|
25892
|
+
(r) => r.map((p, i) => `${i ? "L" : "M"}${p[0].toFixed(3)},${p[1].toFixed(3)}`).join(" ") + "Z"
|
|
25893
|
+
).join(" ")
|
|
25894
|
+
};
|
|
25895
|
+
});
|
|
25896
|
+
return {
|
|
25897
|
+
regions,
|
|
25898
|
+
approximate: false,
|
|
25899
|
+
issues: cache.issues,
|
|
25900
|
+
copyright: [...new Set(cache.regions.flatMap((r) => r.copyright))]
|
|
25901
|
+
};
|
|
25902
|
+
}
|
|
25903
|
+
|
|
25904
|
+
// chart/render/chart-svg-region-map.ts
|
|
25905
|
+
function regionMapSvg(model, area, approximationLabel) {
|
|
25906
|
+
const series = model.series[0];
|
|
25907
|
+
if (!series || series.hidden) return "";
|
|
25908
|
+
const options2 = model.regionMap;
|
|
25909
|
+
const geometry2 = regionMapGeometry(options2);
|
|
25910
|
+
const resolve = (label) => geometry2.regions.find(
|
|
25911
|
+
(r) => r.entityId === label || r.code === label || r.name.toLowerCase() === label.toLowerCase()
|
|
25912
|
+
)?.code ?? resolveRegionCode(label);
|
|
25913
|
+
const entries = buildRegionMapEntries(model.categories, series.values, options2, resolve);
|
|
25914
|
+
const min = entries.length ? Math.min(...entries.map((e) => e.value)) : 0, max = entries.length ? Math.max(...entries.map((e) => e.value)) : 1;
|
|
25915
|
+
const stops = resolveValueColorStops(
|
|
25916
|
+
options2?.valueColors,
|
|
25917
|
+
options2?.valueColorPositions,
|
|
25918
|
+
min,
|
|
25919
|
+
max
|
|
25920
|
+
);
|
|
25921
|
+
const colors = stops ? buildValueColorScale(stops) : (t) => sequentialColorScale(t, series.color);
|
|
25922
|
+
const matched = new Map(entries.filter((e) => e.code).map((e) => [e.code, e]));
|
|
25923
|
+
const missing = entries.filter(
|
|
25924
|
+
(e) => !e.code || !geometry2.regions.some((r) => r.code === e.code)
|
|
25925
|
+
);
|
|
25926
|
+
const bounds = regionViewBounds(options2?.viewedRegionType, matched, geometry2.regions);
|
|
25927
|
+
const width = bounds.maxX - bounds.minX || 1, height = bounds.maxY - bounds.minY || 1;
|
|
25928
|
+
const reserve = (model.showLegend ? 46 : 12) + Math.min(missing.length, 5) * 14 + (geometry2.approximate && approximationLabel ? 14 : 0);
|
|
25929
|
+
const scale = Math.max(
|
|
25930
|
+
1e-5,
|
|
25931
|
+
Math.min(Math.max(1, area.w - 8) / width, Math.max(1, area.h - reserve) / height)
|
|
25932
|
+
);
|
|
25933
|
+
const dx = area.x + (area.w - width * scale) / 2 - bounds.minX * scale, dy = area.y - bounds.minY * scale;
|
|
25934
|
+
const out = [
|
|
25935
|
+
`<g data-chart-part="regionMap" data-map-geometry="${geometry2.approximate ? "approximate" : "cached"}"${geometry2.approximate ? ' data-map-report="approximate-country-outlines"' : ""}${geometry2.issues.length ? ' data-map-partial="true"' : ""}>`
|
|
25936
|
+
];
|
|
25937
|
+
out.push(
|
|
25938
|
+
`<svg x="${area.x}" y="${area.y}" width="${area.w}" height="${Math.max(1, area.h - reserve)}" viewBox="${area.x} ${area.y} ${area.w} ${Math.max(1, area.h - reserve)}" overflow="hidden">`
|
|
25939
|
+
);
|
|
25940
|
+
for (const region of geometry2.regions) {
|
|
25941
|
+
const entry = matched.get(region.code);
|
|
25942
|
+
out.push(
|
|
25943
|
+
`<path d="${scalePathD(region.path, scale, dx, dy)}" fill="${esc(options2?.fixedColor ?? (entry ? colors(normalizeValue(entry.value, min, max)) : "#e2e8f0"))}" stroke="${esc(series.stroke?.color ?? "none")}" stroke-width="${series.stroke?.width ?? 0}" fill-rule="evenodd"${entry ? ` data-chart-series="0" data-chart-point="${entry.sourceIndex}"` : ""}><title>${esc(region.name)}${entry ? ": " + esc(formatRegionMapValue(entry.value, options2?.cultureLanguage)) : ""}</title></path>`
|
|
25944
|
+
);
|
|
25945
|
+
const b = regionBounds(region);
|
|
25946
|
+
if (entry && shouldRenderRegionLabel(
|
|
25947
|
+
options2?.regionLabelLayout,
|
|
25948
|
+
(b.maxX - b.minX) * scale,
|
|
25949
|
+
(b.maxY - b.minY) * scale
|
|
25950
|
+
))
|
|
25951
|
+
out.push(
|
|
25952
|
+
text(region.labelXY[0] * scale + dx, region.labelXY[1] * scale + dy, region.name, {
|
|
25953
|
+
size: 8,
|
|
25954
|
+
anchor: "middle"
|
|
25955
|
+
})
|
|
25956
|
+
);
|
|
25957
|
+
const label = entry && series.labels?.[entry.sourceIndex];
|
|
25958
|
+
if (label)
|
|
25959
|
+
draw(
|
|
25960
|
+
measure3(model, label),
|
|
25961
|
+
label,
|
|
25962
|
+
region.labelXY[0] * scale + dx,
|
|
25963
|
+
region.labelXY[1] * scale + dy,
|
|
25964
|
+
"middle",
|
|
25965
|
+
out
|
|
25966
|
+
);
|
|
25967
|
+
}
|
|
25968
|
+
out.push("</svg>");
|
|
25969
|
+
const y = area.y + height * scale + 5, bar = Math.min(160, area.w * 0.4), left = area.x + (area.w - bar) / 2;
|
|
25970
|
+
if (model.showLegend) {
|
|
25971
|
+
const attrs3 = chartTextAttributes(model, "legend", 16), size = attrs3.size ?? 16;
|
|
25972
|
+
out.push(text(left - 8, y + size * 0.4, series.name, { ...attrs3, anchor: "end" }));
|
|
25973
|
+
for (let i = 0; i < 32; i++)
|
|
25974
|
+
out.push(rect2(left + i * bar / 32, y, bar / 32 + 0.1, 7, colors((i + 0.5) / 32)));
|
|
25975
|
+
out.push(
|
|
25976
|
+
text(left, y + 8 + size, String(min), attrs3),
|
|
25977
|
+
text(left + bar, y + 8 + size, String(max), { ...attrs3, anchor: "end" })
|
|
25978
|
+
);
|
|
25979
|
+
}
|
|
25980
|
+
let row = y + (model.showLegend ? 32 : 0);
|
|
25981
|
+
if (geometry2.approximate && approximationLabel) {
|
|
25982
|
+
out.push(text(area.x, row, approximationLabel, { size: 8 }));
|
|
25983
|
+
row += 14;
|
|
25984
|
+
}
|
|
25985
|
+
for (const entry of missing.slice(0, 5)) {
|
|
25986
|
+
out.push(
|
|
25987
|
+
text(
|
|
25988
|
+
area.x,
|
|
25989
|
+
row,
|
|
25990
|
+
`${entry.label}: ${formatRegionMapValue(entry.value, options2?.cultureLanguage)}`,
|
|
25991
|
+
{ size: 9 }
|
|
25992
|
+
)
|
|
25993
|
+
);
|
|
25994
|
+
row += 14;
|
|
25995
|
+
}
|
|
25996
|
+
const credits = [options2?.attribution, ...geometry2.copyright].filter(Boolean).join("; ");
|
|
25997
|
+
if (credits)
|
|
25998
|
+
out.push(
|
|
25999
|
+
`<title>${esc(credits)}</title>`,
|
|
26000
|
+
text(
|
|
26001
|
+
area.x,
|
|
26002
|
+
area.y + area.h - 1,
|
|
26003
|
+
credits.length > 180 ? credits.slice(0, 177) + "..." : credits,
|
|
26004
|
+
{ size: 6 }
|
|
26005
|
+
)
|
|
26006
|
+
);
|
|
26007
|
+
return out.join("") + "</g>";
|
|
26008
|
+
}
|
|
26009
|
+
|
|
26010
|
+
// chart/funnel-geometry.ts
|
|
26011
|
+
function computeFunnelGeometry(values, plot, gapWidth = 33) {
|
|
26012
|
+
const max = Math.max(...values.map((v) => Math.abs(v)), 1);
|
|
26013
|
+
const band = plot.height / Math.max(1, values.length);
|
|
26014
|
+
const gap = Number.isFinite(gapWidth) && gapWidth >= 0 ? gapWidth : 33;
|
|
26015
|
+
const height = band / (1 + gap / 100);
|
|
26016
|
+
const inset = (band - height) / 2;
|
|
26017
|
+
const center = plot.x + plot.width / 2;
|
|
26018
|
+
return values.map((value, index) => {
|
|
26019
|
+
const width = Math.abs(value) / max * plot.width;
|
|
26020
|
+
return {
|
|
26021
|
+
index,
|
|
26022
|
+
x: center - width / 2,
|
|
26023
|
+
y: plot.y + index * band + inset,
|
|
26024
|
+
width,
|
|
26025
|
+
height,
|
|
26026
|
+
center
|
|
26027
|
+
};
|
|
26028
|
+
});
|
|
26029
|
+
}
|
|
26030
|
+
|
|
26031
|
+
// chart/render/chart-svg-funnel.ts
|
|
26032
|
+
function funnelSvg(model, area) {
|
|
26033
|
+
const series = model.series[0];
|
|
26034
|
+
if (!series || series.hidden) return "";
|
|
26035
|
+
const attrs3 = chartTextAttributes(model, "categoryAxis", 10);
|
|
26036
|
+
const width = Math.min(
|
|
26037
|
+
area.w * 0.3,
|
|
26038
|
+
Math.max(32, ...model.categories.map((s) => s.length * (attrs3.size ?? 10) * 0.55 + 8))
|
|
26039
|
+
);
|
|
26040
|
+
const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
|
|
26041
|
+
const out = [
|
|
26042
|
+
chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
|
|
26043
|
+
];
|
|
26044
|
+
for (const bar of computeFunnelGeometry(
|
|
26045
|
+
series.values.map((v) => v ?? 0),
|
|
26046
|
+
plot,
|
|
26047
|
+
model.funnelGapWidth
|
|
26048
|
+
)) {
|
|
26049
|
+
const value = series.values[bar.index];
|
|
26050
|
+
if (value === null || value === void 0) continue;
|
|
26051
|
+
out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
|
|
26052
|
+
out.push(
|
|
26053
|
+
rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
|
|
26054
|
+
);
|
|
26055
|
+
const size = Math.min(10, bar.height * 0.4);
|
|
26056
|
+
const label = series.labels?.[bar.index];
|
|
26057
|
+
if (label)
|
|
26058
|
+
out.push(
|
|
26059
|
+
text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
|
|
26060
|
+
...chartTextAttributes(model, "dataLabel", size),
|
|
26061
|
+
size,
|
|
26062
|
+
anchor: "middle"
|
|
26063
|
+
})
|
|
26064
|
+
);
|
|
26065
|
+
out.push(
|
|
26066
|
+
text(
|
|
26067
|
+
plot.x - 8,
|
|
26068
|
+
bar.y + bar.height / 2 + (attrs3.size ?? 10) * 0.35,
|
|
26069
|
+
fit(model.categories[bar.index] ?? "", width - 8, attrs3.size ?? 10),
|
|
26070
|
+
{ ...attrs3, anchor: "end" }
|
|
26071
|
+
)
|
|
26072
|
+
);
|
|
26073
|
+
out.push("</g>");
|
|
26074
|
+
}
|
|
26075
|
+
return out.join("");
|
|
26076
|
+
}
|
|
26077
|
+
|
|
26078
|
+
// chart/box-distribution.ts
|
|
26079
|
+
function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
|
|
26080
|
+
const stats = computeBoxStats(values, method);
|
|
26081
|
+
if (!stats) return void 0;
|
|
26082
|
+
const iqr = stats.q3 - stats.q1;
|
|
26083
|
+
const lowerFence = stats.q1 - 1.5 * iqr;
|
|
26084
|
+
const upperFence = stats.q3 + 1.5 * iqr;
|
|
26085
|
+
const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
|
|
26086
|
+
return {
|
|
26087
|
+
stats,
|
|
26088
|
+
whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
|
|
26089
|
+
whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
|
|
26090
|
+
mean: values.reduce((a, b) => a + b, 0) / values.length
|
|
26091
|
+
};
|
|
26092
|
+
}
|
|
26093
|
+
function boxMeanMarkerPath(x, y, radius = 3) {
|
|
26094
|
+
return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
|
|
26095
|
+
}
|
|
26096
|
+
|
|
26097
|
+
// chart/render/chart-svg-box.ts
|
|
26098
|
+
function boxWhiskerSvg(model, frame2, out) {
|
|
26099
|
+
const visible = model.series.filter((s) => !s.hidden);
|
|
26100
|
+
const slot = frame2.bandSize / Math.max(1, visible.length);
|
|
26101
|
+
const width = slot * 0.7;
|
|
26102
|
+
visible.forEach((series, si) => {
|
|
26103
|
+
if (series.hidden) return;
|
|
26104
|
+
const groups = groupRowsByCategory(series.boxCategories ?? []);
|
|
26105
|
+
model.categories.forEach((category, ci) => {
|
|
26106
|
+
const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
|
|
26107
|
+
const value = series.values[row];
|
|
26108
|
+
return value === null || value === void 0 ? [] : [{ row, value }];
|
|
26109
|
+
});
|
|
26110
|
+
const options2 = series.boxWhisker;
|
|
26111
|
+
const rawMethod = options2?.statistics?.quartileMethod;
|
|
26112
|
+
const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
|
|
26113
|
+
const visibility = options2?.visibility;
|
|
26114
|
+
const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
|
|
26115
|
+
const distribution = boxWhiskerDistribution(
|
|
26116
|
+
observations.map((p) => p.value),
|
|
26117
|
+
method,
|
|
26118
|
+
trim
|
|
26119
|
+
);
|
|
26120
|
+
if (!distribution) return;
|
|
26121
|
+
const { stats, whiskerMin, whiskerMax, mean } = distribution;
|
|
26122
|
+
const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
|
|
26123
|
+
const mid = x + width / 2;
|
|
26124
|
+
const y = frame2.value;
|
|
26125
|
+
out.push(
|
|
26126
|
+
`<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
|
|
26127
|
+
);
|
|
26128
|
+
out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
|
|
26129
|
+
out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
|
|
26130
|
+
out.push(
|
|
26131
|
+
line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
|
|
26132
|
+
);
|
|
26133
|
+
out.push(
|
|
26134
|
+
line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
|
|
26135
|
+
);
|
|
26136
|
+
out.push(
|
|
26137
|
+
rect2(
|
|
26138
|
+
x,
|
|
26139
|
+
Math.min(y(stats.q1), y(stats.q3)),
|
|
26140
|
+
width,
|
|
26141
|
+
Math.abs(y(stats.q1) - y(stats.q3)),
|
|
26142
|
+
series.pointColors?.[ci] ?? series.color
|
|
26143
|
+
)
|
|
26144
|
+
);
|
|
26145
|
+
out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
|
|
26146
|
+
if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
|
|
26147
|
+
if (visibility?.meanMarker !== false)
|
|
26148
|
+
out.push(
|
|
26149
|
+
`<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
|
|
26150
|
+
);
|
|
26151
|
+
observations.forEach((point, index) => {
|
|
26152
|
+
const outlier = point.value < whiskerMin || point.value > whiskerMax;
|
|
26153
|
+
if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
|
|
26154
|
+
const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
|
|
26155
|
+
out.push(
|
|
26156
|
+
`<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
|
|
26157
|
+
);
|
|
26158
|
+
});
|
|
26159
|
+
out.push("</g>");
|
|
26160
|
+
});
|
|
26161
|
+
});
|
|
26162
|
+
}
|
|
26163
|
+
|
|
24196
26164
|
// chart/render/chart-svg-xy.ts
|
|
24197
26165
|
function scatter(model, area, out, size) {
|
|
24198
26166
|
const ys = model.valueAxis;
|
|
@@ -24755,26 +26723,26 @@ function sunburstSvg(model, area) {
|
|
|
24755
26723
|
|
|
24756
26724
|
// chart/render/chart-svg-text-metrics.ts
|
|
24757
26725
|
var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
|
|
24758
|
-
function cssFont(
|
|
24759
|
-
return `${
|
|
26726
|
+
function cssFont(attrs3) {
|
|
26727
|
+
return `${attrs3.italic ? "italic" : "normal"} ${attrs3.weight ?? "normal"} ${attrs3.size ?? 10}px ${attrs3.family ?? CHART_FONT_FAMILY}`;
|
|
24760
26728
|
}
|
|
24761
|
-
function chartFontMetrics(
|
|
24762
|
-
const metrics = options2.measureFont?.(cssFont(
|
|
26729
|
+
function chartFontMetrics(attrs3, options2) {
|
|
26730
|
+
const metrics = options2.measureFont?.(cssFont(attrs3));
|
|
24763
26731
|
return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
|
|
24764
26732
|
}
|
|
24765
|
-
function chartTextWidth(content,
|
|
24766
|
-
const width = options2.measureText?.(content, cssFont(
|
|
24767
|
-
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content,
|
|
26733
|
+
function chartTextWidth(content, attrs3, options2) {
|
|
26734
|
+
const width = options2.measureText?.(content, cssFont(attrs3));
|
|
26735
|
+
return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs3.size);
|
|
24768
26736
|
}
|
|
24769
|
-
function fitChartText(content, maxWidth,
|
|
24770
|
-
if (!options2.measureText) return fit(content, maxWidth,
|
|
24771
|
-
if (chartTextWidth(content,
|
|
26737
|
+
function fitChartText(content, maxWidth, attrs3, options2) {
|
|
26738
|
+
if (!options2.measureText) return fit(content, maxWidth, attrs3.size);
|
|
26739
|
+
if (chartTextWidth(content, attrs3, options2) <= maxWidth) return content;
|
|
24772
26740
|
const points = [...content];
|
|
24773
26741
|
let low = 0;
|
|
24774
26742
|
let high = points.length;
|
|
24775
26743
|
while (low < high) {
|
|
24776
26744
|
const mid = Math.ceil((low + high) / 2);
|
|
24777
|
-
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`,
|
|
26745
|
+
if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs3, options2) <= maxWidth) low = mid;
|
|
24778
26746
|
else high = mid - 1;
|
|
24779
26747
|
}
|
|
24780
26748
|
return `${points.slice(0, low).join("")}\u2026`;
|
|
@@ -24796,13 +26764,13 @@ function chartLegendSvg(model, area, frame2, options2) {
|
|
|
24796
26764
|
});
|
|
24797
26765
|
if (!manual) return { plot, markup: automatic.join(""), foreground: !!model.legendOverlay };
|
|
24798
26766
|
const entries = legendEntries(model);
|
|
24799
|
-
const
|
|
24800
|
-
const size =
|
|
24801
|
-
const font = chartFontMetrics(
|
|
26767
|
+
const attrs3 = chartTextAttributes(model, "legend");
|
|
26768
|
+
const size = attrs3.size ?? 10;
|
|
26769
|
+
const font = chartFontMetrics(attrs3, options2);
|
|
24802
26770
|
const keySize = size / 2;
|
|
24803
26771
|
const keyGap = size / 4;
|
|
24804
26772
|
const widths = entries.map(
|
|
24805
|
-
(entry) => chartTextWidth(entry.label,
|
|
26773
|
+
(entry) => chartTextWidth(entry.label, attrs3, options2) + keySize + keyGap
|
|
24806
26774
|
);
|
|
24807
26775
|
const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
|
|
24808
26776
|
const rowWidth = horizontal ? manual.width / entries.length : manual.width;
|
|
@@ -24818,13 +26786,13 @@ function chartLegendSvg(model, area, frame2, options2) {
|
|
|
24818
26786
|
const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
|
|
24819
26787
|
const widest = extentOf(widths).max;
|
|
24820
26788
|
entries.forEach((entry, i) => {
|
|
24821
|
-
const available = horizontal ? chartTextWidth(entry.label,
|
|
24822
|
-
const label = fitChartText(entry.label, available,
|
|
26789
|
+
const available = horizontal ? chartTextWidth(entry.label, attrs3, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
|
|
26790
|
+
const label = fitChartText(entry.label, available, attrs3, options2);
|
|
24823
26791
|
const contentWidth = Math.min(horizontal ? widths[i] ?? 0 : widest, rowWidth - size / 2);
|
|
24824
26792
|
const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
|
|
24825
26793
|
const centerY = manual.y + (horizontal ? 0 : i * rowHeight) + rowHeight / 2;
|
|
24826
26794
|
markup.push(rect2(x, centerY - keySize / 2, keySize, keySize, entry.color));
|
|
24827
|
-
markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label,
|
|
26795
|
+
markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label, attrs3));
|
|
24828
26796
|
if (horizontal) horizontalX += (widths[i] ?? 0) + horizontalGap;
|
|
24829
26797
|
});
|
|
24830
26798
|
return {
|
|
@@ -24863,12 +26831,12 @@ function automaticLegend(model, area, out, options2, bounds) {
|
|
|
24863
26831
|
const entries = legendEntries(model);
|
|
24864
26832
|
if (!model.showLegend || entries.length === 0) return area;
|
|
24865
26833
|
const pos = model.legendPosition;
|
|
24866
|
-
const
|
|
24867
|
-
const size =
|
|
26834
|
+
const attrs3 = chartTextAttributes(model, "legend");
|
|
26835
|
+
const size = attrs3.size ?? 10;
|
|
24868
26836
|
const rowH = Math.max(16, size * 1.4);
|
|
24869
26837
|
if (pos === "t" || pos === "b") {
|
|
24870
26838
|
const widths = entries.map(
|
|
24871
|
-
(e) => Math.min(chartTextWidth(e.label,
|
|
26839
|
+
(e) => Math.min(chartTextWidth(e.label, attrs3, options2) + 20, area.w / 2)
|
|
24872
26840
|
);
|
|
24873
26841
|
const total = widths.reduce((a, b) => a + b, 0);
|
|
24874
26842
|
let x2 = area.x + Math.max(0, (area.w - total) / 2);
|
|
@@ -24885,14 +26853,14 @@ function automaticLegend(model, area, out, options2, bounds) {
|
|
|
24885
26853
|
entries.forEach((e, i) => {
|
|
24886
26854
|
const w = widths[i] ?? 0;
|
|
24887
26855
|
out.push(rect2(x2, y, 8, 8, e.color));
|
|
24888
|
-
out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16,
|
|
26856
|
+
out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs3, options2), attrs3));
|
|
24889
26857
|
x2 += w;
|
|
24890
26858
|
});
|
|
24891
26859
|
return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
|
|
24892
26860
|
}
|
|
24893
26861
|
const width = Math.min(
|
|
24894
26862
|
area.w * 0.35,
|
|
24895
|
-
extentOf(entries.map((e) => chartTextWidth(e.label,
|
|
26863
|
+
extentOf(entries.map((e) => chartTextWidth(e.label, attrs3, options2))).max + 22
|
|
24896
26864
|
);
|
|
24897
26865
|
const height = entries.length * rowH;
|
|
24898
26866
|
const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
|
|
@@ -24910,7 +26878,7 @@ function automaticLegend(model, area, out, options2, bounds) {
|
|
|
24910
26878
|
const y = y0 + i * rowH;
|
|
24911
26879
|
if (y + rowH > area.y + area.h + 2) return;
|
|
24912
26880
|
out.push(rect2(x, y + 3, 8, 8, e.color));
|
|
24913
|
-
out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16,
|
|
26881
|
+
out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs3, options2), attrs3));
|
|
24914
26882
|
});
|
|
24915
26883
|
return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
|
|
24916
26884
|
}
|
|
@@ -24944,11 +26912,11 @@ function wrapStyledRuns(runs, maxWidth, measure4, options2 = {}) {
|
|
|
24944
26912
|
return sum + (Number.isFinite(advance) && advance >= 0 ? advance : 0);
|
|
24945
26913
|
}, 0);
|
|
24946
26914
|
const result = [];
|
|
24947
|
-
let
|
|
26915
|
+
let line4 = [];
|
|
24948
26916
|
let spaces = [];
|
|
24949
26917
|
const flush = () => {
|
|
24950
|
-
result.push(
|
|
24951
|
-
|
|
26918
|
+
result.push(line4.map((piece) => ({ ...piece.run, text: piece.text })));
|
|
26919
|
+
line4 = [];
|
|
24952
26920
|
spaces = [];
|
|
24953
26921
|
};
|
|
24954
26922
|
for (const group2 of groups) {
|
|
@@ -24960,20 +26928,20 @@ function wrapStyledRuns(runs, maxWidth, measure4, options2 = {}) {
|
|
|
24960
26928
|
spaces = group2.pieces;
|
|
24961
26929
|
continue;
|
|
24962
26930
|
}
|
|
24963
|
-
const separator =
|
|
26931
|
+
const separator = line4.length ? spaces : [];
|
|
24964
26932
|
const wordWidth = width(group2.pieces);
|
|
24965
|
-
if (
|
|
24966
|
-
else
|
|
26933
|
+
if (line4.length && width(merged(line4, [...separator, ...group2.pieces])) > maxWidth) flush();
|
|
26934
|
+
else line4 = merged(line4, separator);
|
|
24967
26935
|
spaces = [];
|
|
24968
26936
|
if (options2.breakWords && wordWidth > maxWidth) {
|
|
24969
26937
|
for (const piece of group2.pieces) {
|
|
24970
26938
|
for (const { segment: segment2 } of graphemes.segment(piece.text)) {
|
|
24971
26939
|
const next = { ...piece, text: segment2 };
|
|
24972
|
-
if (
|
|
24973
|
-
|
|
26940
|
+
if (line4.length && width(merged(line4, [next])) > maxWidth) flush();
|
|
26941
|
+
line4 = merged(line4, [next]);
|
|
24974
26942
|
}
|
|
24975
26943
|
}
|
|
24976
|
-
} else
|
|
26944
|
+
} else line4 = merged(line4, group2.pieces);
|
|
24977
26945
|
}
|
|
24978
26946
|
flush();
|
|
24979
26947
|
return result;
|
|
@@ -24996,25 +26964,25 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
24996
26964
|
];
|
|
24997
26965
|
const hardLines = [];
|
|
24998
26966
|
for (const paragraph of paragraphs) {
|
|
24999
|
-
let
|
|
26967
|
+
let line4 = {
|
|
25000
26968
|
...paragraph,
|
|
25001
26969
|
runs: []
|
|
25002
26970
|
};
|
|
25003
|
-
hardLines.push(
|
|
26971
|
+
hardLines.push(line4);
|
|
25004
26972
|
for (const run of paragraph.runs) {
|
|
25005
26973
|
const pieces = run.text.split("\n");
|
|
25006
26974
|
for (const [index, piece] of pieces.entries()) {
|
|
25007
26975
|
if (index) {
|
|
25008
|
-
|
|
25009
|
-
hardLines.push(
|
|
26976
|
+
line4 = { ...paragraph, runs: [] };
|
|
26977
|
+
hardLines.push(line4);
|
|
25010
26978
|
}
|
|
25011
|
-
if (piece)
|
|
26979
|
+
if (piece) line4.runs.push({ ...run, text: piece });
|
|
25012
26980
|
}
|
|
25013
26981
|
}
|
|
25014
26982
|
}
|
|
25015
|
-
const lines = hardLines.flatMap((
|
|
26983
|
+
const lines = hardLines.flatMap((line4) => {
|
|
25016
26984
|
const wrapped = wrapStyledRuns(
|
|
25017
|
-
|
|
26985
|
+
line4.runs,
|
|
25018
26986
|
capacity,
|
|
25019
26987
|
(content, run) => chartTextWidth(
|
|
25020
26988
|
content,
|
|
@@ -25027,7 +26995,7 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
25027
26995
|
),
|
|
25028
26996
|
{ breakWords: true }
|
|
25029
26997
|
);
|
|
25030
|
-
const { spaceBefore, spaceAfter, ...properties3 } =
|
|
26998
|
+
const { spaceBefore, spaceAfter, ...properties3 } = line4;
|
|
25031
26999
|
return wrapped.map((runs, index) => ({
|
|
25032
27000
|
...properties3,
|
|
25033
27001
|
runs,
|
|
@@ -25035,8 +27003,8 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
25035
27003
|
...index === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
25036
27004
|
}));
|
|
25037
27005
|
});
|
|
25038
|
-
const metrics = lines.map((
|
|
25039
|
-
const runs =
|
|
27006
|
+
const metrics = lines.map((line4) => {
|
|
27007
|
+
const runs = line4.runs.map((run) => ({
|
|
25040
27008
|
...run,
|
|
25041
27009
|
attrs: chartTextAttributes(
|
|
25042
27010
|
{ ...model, appearance: { title: run.appearance } },
|
|
@@ -25045,43 +27013,43 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
25045
27013
|
)
|
|
25046
27014
|
}));
|
|
25047
27015
|
return {
|
|
25048
|
-
...
|
|
27016
|
+
...line4,
|
|
25049
27017
|
runs,
|
|
25050
27018
|
width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
|
|
25051
27019
|
size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
|
|
25052
27020
|
fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
|
|
25053
|
-
(
|
|
27021
|
+
(attrs3) => chartFontMetrics(attrs3, options2)
|
|
25054
27022
|
)
|
|
25055
27023
|
};
|
|
25056
27024
|
});
|
|
25057
|
-
const measured = metrics.every((
|
|
25058
|
-
const vertical = metrics.map((
|
|
25059
|
-
const ascent = measured ? Math.max(...
|
|
25060
|
-
const descent = measured ? Math.max(...
|
|
27025
|
+
const measured = metrics.every((line4) => line4.fontMetrics.every((font) => font !== void 0));
|
|
27026
|
+
const vertical = metrics.map((line4) => {
|
|
27027
|
+
const ascent = measured ? Math.max(...line4.fontMetrics.map((font) => font.ascent)) : line4.size;
|
|
27028
|
+
const descent = measured ? Math.max(...line4.fontMetrics.map((font) => font.descent)) : line4.size * 0.4 + 4;
|
|
25061
27029
|
const natural = ascent + descent;
|
|
25062
|
-
const height2 = spacing(
|
|
27030
|
+
const height2 = spacing(line4.lineSpacing, natural, natural);
|
|
25063
27031
|
const leading = (height2 - natural) / 2;
|
|
25064
27032
|
return {
|
|
25065
27033
|
ascent: ascent + leading,
|
|
25066
27034
|
descent: descent + leading,
|
|
25067
27035
|
height: height2,
|
|
25068
|
-
before: spacing(
|
|
25069
|
-
after: spacing(
|
|
27036
|
+
before: spacing(line4.spaceBefore, natural, 0),
|
|
27037
|
+
after: spacing(line4.spaceAfter, natural, 0),
|
|
25070
27038
|
leading
|
|
25071
27039
|
};
|
|
25072
27040
|
});
|
|
25073
|
-
const boxWidth = Math.min(width - 16, Math.max(0, ...metrics.map((
|
|
27041
|
+
const boxWidth = Math.min(width - 16, Math.max(0, ...metrics.map((line4) => line4.width)) + 8);
|
|
25074
27042
|
const height = vertical.reduce(
|
|
25075
|
-
(sum,
|
|
27043
|
+
(sum, line4) => sum + line4.height + line4.before + line4.after,
|
|
25076
27044
|
measured ? 4 : 0
|
|
25077
27045
|
);
|
|
25078
27046
|
let baseline = 8 + (metrics[0]?.size ?? base.size ?? 14) + (vertical[0]?.before ?? 0) + (vertical[0]?.leading ?? 0);
|
|
25079
27047
|
const spans = [];
|
|
25080
|
-
for (const [index,
|
|
27048
|
+
for (const [index, line4] of metrics.entries()) {
|
|
25081
27049
|
if (index)
|
|
25082
27050
|
baseline += vertical[index - 1].descent + vertical[index - 1].after + vertical[index].before + vertical[index].ascent;
|
|
25083
|
-
let x =
|
|
25084
|
-
for (const run of
|
|
27051
|
+
let x = line4.align === "l" ? (width - boxWidth) / 2 + 4 : line4.align === "r" ? (width + boxWidth) / 2 - 4 - line4.width : (width - line4.width) / 2;
|
|
27052
|
+
for (const run of line4.runs) {
|
|
25085
27053
|
spans.push(
|
|
25086
27054
|
text(x, baseline, run.text, {
|
|
25087
27055
|
...run.attrs,
|
|
@@ -25135,11 +27103,11 @@ function renderChartSvg(model, width, height, options2 = {}) {
|
|
|
25135
27103
|
if (!model.titleOverlay)
|
|
25136
27104
|
area = { ...area, y: area.y + richTitle.height, h: area.h - richTitle.height };
|
|
25137
27105
|
} else if (model.title) {
|
|
25138
|
-
const
|
|
25139
|
-
const size =
|
|
25140
|
-
const label = fitChartText(model.title, w - 16,
|
|
25141
|
-
const titleWidth = Math.min(w - 16, chartTextWidth(label,
|
|
25142
|
-
const font = chartFontMetrics(
|
|
27106
|
+
const attrs3 = chartTextAttributes(model, "title", 14);
|
|
27107
|
+
const size = attrs3.size ?? 14;
|
|
27108
|
+
const label = fitChartText(model.title, w - 16, attrs3, options2);
|
|
27109
|
+
const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs3, options2) + 8);
|
|
27110
|
+
const font = chartFontMetrics(attrs3, options2);
|
|
25143
27111
|
const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
|
|
25144
27112
|
out.push(
|
|
25145
27113
|
chartAreaRect(model, "title", {
|
|
@@ -25153,7 +27121,7 @@ function renderChartSvg(model, width, height, options2 = {}) {
|
|
|
25153
27121
|
text(w / 2, 8 + size, label, {
|
|
25154
27122
|
anchor: "middle",
|
|
25155
27123
|
fill: "#404040",
|
|
25156
|
-
...
|
|
27124
|
+
...attrs3
|
|
25157
27125
|
})
|
|
25158
27126
|
);
|
|
25159
27127
|
if (!model.titleOverlay)
|
|
@@ -25167,11 +27135,14 @@ function renderChartSvg(model, width, height, options2 = {}) {
|
|
|
25167
27135
|
out.push("</svg>");
|
|
25168
27136
|
return out.join("");
|
|
25169
27137
|
}
|
|
25170
|
-
const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
27138
|
+
const legend = model.type === "regionMap" ? { plot: area, foreground: false, markup: "" } : chartLegendSvg(model, area, { width: w, height: h }, options2);
|
|
25171
27139
|
area = legend.plot;
|
|
25172
27140
|
if (!legend.foreground) out.push(legend.markup);
|
|
25173
27141
|
if (area.w > 4 && area.h > 4) {
|
|
25174
|
-
if (model
|
|
27142
|
+
if (chart3DApplies(model)) out.push(chart3DSvg(model, area));
|
|
27143
|
+
else if (model.type === "regionMap")
|
|
27144
|
+
out.push(regionMapSvg(model, area, options2.mapApproximationLabel));
|
|
27145
|
+
else if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
|
|
25175
27146
|
else if (model.type === "funnel") out.push(funnelSvg(model, area));
|
|
25176
27147
|
else if (model.type === "radar") out.push(radarSvg(model, area));
|
|
25177
27148
|
else if (model.type === "treemap") out.push(treemapSvg(model, area));
|
|
@@ -25201,6 +27172,7 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
|
25201
27172
|
"treemap",
|
|
25202
27173
|
"sunburst",
|
|
25203
27174
|
"funnel",
|
|
27175
|
+
"regionMap",
|
|
25204
27176
|
"boxWhisker"
|
|
25205
27177
|
]);
|
|
25206
27178
|
function chartThemePalette(theme, fonts = {}) {
|
|
@@ -25215,7 +27187,8 @@ function chartThemePalette(theme, fonts = {}) {
|
|
|
25215
27187
|
function chartSpaceKind(space) {
|
|
25216
27188
|
if (!space.plotArea.groups.length) return { drawn: false };
|
|
25217
27189
|
const type = chartSummaryFromSpace(space).chartType;
|
|
25218
|
-
|
|
27190
|
+
const summary3D = type === "surface" && chartSummaryFromSpace(space).view3D !== void 0;
|
|
27191
|
+
return { type, drawn: DRAWN_CHART_TYPES.has(type) || summary3D };
|
|
25219
27192
|
}
|
|
25220
27193
|
function renderChartSpaceSvg(space, options2) {
|
|
25221
27194
|
const { width, height, theme, fonts, formatting: formatting2, colorPalette, styleDefinition, ...svg } = options2;
|
|
@@ -25274,7 +27247,7 @@ var add2 = (parent, ...items) => {
|
|
|
25274
27247
|
};
|
|
25275
27248
|
var emu2 = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
|
|
25276
27249
|
var emuOffset = (px) => String(Math.round(px * EMU_PER_PIXEL));
|
|
25277
|
-
var
|
|
27250
|
+
var attrs2 = (element3, values) => {
|
|
25278
27251
|
for (const [name, value] of Object.entries(values)) element3.setAttribute(name, value);
|
|
25279
27252
|
return element3;
|
|
25280
27253
|
};
|
|
@@ -25302,13 +27275,13 @@ function explicitTextColor(spec) {
|
|
|
25302
27275
|
return light ? "000000" : void 0;
|
|
25303
27276
|
}
|
|
25304
27277
|
function textParagraphs(doc, lines, color) {
|
|
25305
|
-
return lines.map((
|
|
27278
|
+
return lines.map((line4) => {
|
|
25306
27279
|
const paragraph = makeW(doc, "p");
|
|
25307
27280
|
const props = makeW(doc, "pPr");
|
|
25308
27281
|
const jc = makeW(doc, "jc");
|
|
25309
27282
|
jc.setAttributeNS(W_NS2, "w:val", "center");
|
|
25310
27283
|
add2(paragraph, add2(props, jc));
|
|
25311
|
-
if (
|
|
27284
|
+
if (line4) {
|
|
25312
27285
|
const run = makeW(doc, "r");
|
|
25313
27286
|
if (color) {
|
|
25314
27287
|
const rPr = makeW(doc, "rPr");
|
|
@@ -25317,19 +27290,19 @@ function textParagraphs(doc, lines, color) {
|
|
|
25317
27290
|
add2(run, add2(rPr, c));
|
|
25318
27291
|
}
|
|
25319
27292
|
const t = makeW(doc, "t");
|
|
25320
|
-
if (/^\s|\s$/.test(
|
|
27293
|
+
if (/^\s|\s$/.test(line4))
|
|
25321
27294
|
t.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
|
|
25322
|
-
t.textContent =
|
|
27295
|
+
t.textContent = line4;
|
|
25323
27296
|
add2(paragraph, add2(run, t));
|
|
25324
27297
|
}
|
|
25325
27298
|
return paragraph;
|
|
25326
27299
|
});
|
|
25327
27300
|
}
|
|
25328
27301
|
function shapeStyle(doc) {
|
|
25329
|
-
const ref = (name, idx, scheme2,
|
|
25330
|
-
const node =
|
|
25331
|
-
const color =
|
|
25332
|
-
if (
|
|
27302
|
+
const ref = (name, idx, scheme2, shade2) => {
|
|
27303
|
+
const node = attrs2(el2(doc, A_NS2, `a:${name}`), { idx });
|
|
27304
|
+
const color = attrs2(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
|
|
27305
|
+
if (shade2) add2(color, attrs2(el2(doc, A_NS2, "a:shade"), { val: shade2 }));
|
|
25333
27306
|
return add2(node, color);
|
|
25334
27307
|
};
|
|
25335
27308
|
return add2(
|
|
@@ -25343,17 +27316,17 @@ function shapeStyle(doc) {
|
|
|
25343
27316
|
function wrapElement(doc, placement) {
|
|
25344
27317
|
switch (placement.wrap) {
|
|
25345
27318
|
case "square":
|
|
25346
|
-
return
|
|
27319
|
+
return attrs2(el2(doc, WP_NS2, "wp:wrapSquare"), { wrapText: "bothSides" });
|
|
25347
27320
|
case "tight":
|
|
25348
27321
|
case "through": {
|
|
25349
|
-
const wrap =
|
|
27322
|
+
const wrap = attrs2(
|
|
25350
27323
|
el2(doc, WP_NS2, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
|
|
25351
27324
|
{
|
|
25352
27325
|
wrapText: "bothSides"
|
|
25353
27326
|
}
|
|
25354
27327
|
);
|
|
25355
|
-
const polygon =
|
|
25356
|
-
const point = (name, x, y) =>
|
|
27328
|
+
const polygon = attrs2(el2(doc, WP_NS2, "wp:wrapPolygon"), { edited: "0" });
|
|
27329
|
+
const point = (name, x, y) => attrs2(el2(doc, WP_NS2, `wp:${name}`), { x, y });
|
|
25357
27330
|
return add2(
|
|
25358
27331
|
wrap,
|
|
25359
27332
|
add2(
|
|
@@ -25373,7 +27346,7 @@ function wrapElement(doc, placement) {
|
|
|
25373
27346
|
}
|
|
25374
27347
|
}
|
|
25375
27348
|
function position(doc, axis, relativeFrom, align, offsetPx) {
|
|
25376
|
-
const node =
|
|
27349
|
+
const node = attrs2(el2(doc, WP_NS2, `wp:position${axis}`), { relativeFrom });
|
|
25377
27350
|
if (align) {
|
|
25378
27351
|
const a = el2(doc, WP_NS2, "wp:align");
|
|
25379
27352
|
a.textContent = align;
|
|
@@ -25384,10 +27357,10 @@ function position(doc, axis, relativeFrom, align, offsetPx) {
|
|
|
25384
27357
|
return add2(node, offset);
|
|
25385
27358
|
}
|
|
25386
27359
|
function geometry(doc, spec) {
|
|
25387
|
-
const prst =
|
|
27360
|
+
const prst = attrs2(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
|
|
25388
27361
|
const avLst = el2(doc, A_NS2, "a:avLst");
|
|
25389
27362
|
for (const [name, value] of Object.entries(spec.adjustments ?? {}))
|
|
25390
|
-
add2(avLst,
|
|
27363
|
+
add2(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
|
|
25391
27364
|
const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add2(prst, avLst)];
|
|
25392
27365
|
if (spec.fill) {
|
|
25393
27366
|
const xml = drawingFillXml(spec.fill);
|
|
@@ -25403,7 +27376,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
25403
27376
|
const anchored = Boolean(image.anchored);
|
|
25404
27377
|
const holder = el2(doc, WP_NS2, anchored ? "wp:anchor" : "wp:inline");
|
|
25405
27378
|
if (anchored) {
|
|
25406
|
-
|
|
27379
|
+
attrs2(holder, {
|
|
25407
27380
|
distT: "0",
|
|
25408
27381
|
distB: "0",
|
|
25409
27382
|
distL: "114300",
|
|
@@ -25417,7 +27390,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
25417
27390
|
});
|
|
25418
27391
|
add2(
|
|
25419
27392
|
holder,
|
|
25420
|
-
|
|
27393
|
+
attrs2(el2(doc, WP_NS2, "wp:simplePos"), { x: "0", y: "0" }),
|
|
25421
27394
|
position(
|
|
25422
27395
|
doc,
|
|
25423
27396
|
"H",
|
|
@@ -25436,24 +27409,24 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
25436
27409
|
} else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
|
|
25437
27410
|
add2(
|
|
25438
27411
|
holder,
|
|
25439
|
-
|
|
25440
|
-
|
|
27412
|
+
attrs2(el2(doc, WP_NS2, "wp:extent"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) }),
|
|
27413
|
+
attrs2(el2(doc, WP_NS2, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
|
|
25441
27414
|
);
|
|
25442
27415
|
if (anchored) add2(holder, wrapElement(doc, placement ?? { wrap: "none" }));
|
|
25443
|
-
const docPr =
|
|
27416
|
+
const docPr = attrs2(el2(doc, WP_NS2, "wp:docPr"), {
|
|
25444
27417
|
id: identity.id,
|
|
25445
27418
|
name: identity.name ?? `Shape ${identity.id}`
|
|
25446
27419
|
});
|
|
25447
27420
|
if (identity.descr) docPr.setAttribute("descr", identity.descr);
|
|
25448
27421
|
if (identity.title) docPr.setAttribute("title", identity.title);
|
|
25449
|
-
const xfrm =
|
|
27422
|
+
const xfrm = attrs2(el2(doc, A_NS2, "a:xfrm"), {});
|
|
25450
27423
|
if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
|
|
25451
27424
|
if (spec.flipH) xfrm.setAttribute("flipH", "1");
|
|
25452
27425
|
if (spec.flipV) xfrm.setAttribute("flipV", "1");
|
|
25453
27426
|
add2(
|
|
25454
27427
|
xfrm,
|
|
25455
|
-
|
|
25456
|
-
|
|
27428
|
+
attrs2(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
|
|
27429
|
+
attrs2(el2(doc, A_NS2, "a:ext"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) })
|
|
25457
27430
|
);
|
|
25458
27431
|
const spPr = add2(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
|
|
25459
27432
|
const wsp = add2(
|
|
@@ -25469,7 +27442,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
25469
27442
|
);
|
|
25470
27443
|
add2(wsp, add2(el2(doc, WPS_NS2, "wps:txbx"), content));
|
|
25471
27444
|
}
|
|
25472
|
-
const body =
|
|
27445
|
+
const body = attrs2(el2(doc, WPS_NS2, "wps:bodyPr"), {
|
|
25473
27446
|
rot: "0",
|
|
25474
27447
|
vert: "horz",
|
|
25475
27448
|
wrap: "square",
|
|
@@ -25481,7 +27454,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
|
|
|
25481
27454
|
anchorCtr: "0"
|
|
25482
27455
|
});
|
|
25483
27456
|
add2(wsp, add2(body, el2(doc, A_NS2, "a:noAutofit")));
|
|
25484
|
-
const graphicData =
|
|
27457
|
+
const graphicData = attrs2(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
|
|
25485
27458
|
add2(
|
|
25486
27459
|
holder,
|
|
25487
27460
|
docPr,
|
|
@@ -25607,8 +27580,8 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
|
|
|
25607
27580
|
|
|
25608
27581
|
// docx/write-fallback.ts
|
|
25609
27582
|
var PT_PER_PX2 = 0.75;
|
|
25610
|
-
function setStyleSize(style, name,
|
|
25611
|
-
const value = `${Math.round(
|
|
27583
|
+
function setStyleSize(style, name, pt2) {
|
|
27584
|
+
const value = `${Math.round(pt2 * 100) / 100}pt`;
|
|
25612
27585
|
const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
|
|
25613
27586
|
return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
|
|
25614
27587
|
}
|
|
@@ -25666,6 +27639,10 @@ function diagramRun(doc, node, image, base, oldDrawing, oldContainer, allocator)
|
|
|
25666
27639
|
}
|
|
25667
27640
|
return void 0;
|
|
25668
27641
|
}
|
|
27642
|
+
|
|
27643
|
+
// docx/write-drawing.ts
|
|
27644
|
+
var A_NS6 = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
27645
|
+
var PIC_NS = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
25669
27646
|
function alternateContentDrawing(content) {
|
|
25670
27647
|
const choice = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Choice");
|
|
25671
27648
|
return choice && findDrawingChild(choice);
|
|
@@ -25742,6 +27719,16 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
25742
27719
|
throw new Error("Cannot insert a text box without an id allocator.");
|
|
25743
27720
|
}
|
|
25744
27721
|
if (base && oldDrawing && sameUnderlyingImage(base, image)) {
|
|
27722
|
+
if (image.pictureFill && JSON.stringify(image.pictureFill) !== JSON.stringify(base.pictureFill)) {
|
|
27723
|
+
const fill = oldDrawing.getElementsByTagNameNS(PIC_NS, "blipFill")[0];
|
|
27724
|
+
const blip = fill?.getElementsByTagNameNS(A_NS6, "blip")[0];
|
|
27725
|
+
if (fill && image.pictureFill.crop !== void 0)
|
|
27726
|
+
applyPictureCrop(fill, image.pictureFill.crop);
|
|
27727
|
+
if (blip && image.pictureFill.effects !== void 0)
|
|
27728
|
+
applyPictureEffects(blip, image.pictureFill.effects);
|
|
27729
|
+
if (fill && image.pictureFill.layout !== void 0)
|
|
27730
|
+
applyPictureLayout(fill, image.pictureFill.layout);
|
|
27731
|
+
}
|
|
25745
27732
|
if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
|
|
25746
27733
|
updateExtent(oldDrawing, image.widthPx, image.heightPx);
|
|
25747
27734
|
if (image.altText !== base.altText || image.title !== base.title)
|
|
@@ -26459,9 +28446,9 @@ function parseShadingThemeFill(shd) {
|
|
|
26459
28446
|
if (!theme) return void 0;
|
|
26460
28447
|
const ref = { token: theme };
|
|
26461
28448
|
const tint = parseTintShade(getW(shd, "themeFillTint"));
|
|
26462
|
-
const
|
|
28449
|
+
const shade2 = parseTintShade(getW(shd, "themeFillShade"));
|
|
26463
28450
|
if (tint !== void 0) ref.tint = tint;
|
|
26464
|
-
if (
|
|
28451
|
+
if (shade2 !== void 0) ref.shade = shade2;
|
|
26465
28452
|
return ref;
|
|
26466
28453
|
}
|
|
26467
28454
|
function parseParagraphBorders(pBdr) {
|
|
@@ -26544,8 +28531,8 @@ function parseFormatting(pPr) {
|
|
|
26544
28531
|
const value = enabled(first2(pPr, key));
|
|
26545
28532
|
if (value !== void 0) result[key] = value;
|
|
26546
28533
|
}
|
|
26547
|
-
const
|
|
26548
|
-
if (
|
|
28534
|
+
const outline3 = parseOutlineLevel(first2(pPr, "outlineLvl"));
|
|
28535
|
+
if (outline3 !== void 0) result.outlineLevel = outline3;
|
|
26549
28536
|
const borders = parseParagraphBorders(first2(pPr, "pBdr"));
|
|
26550
28537
|
if (borders) result.borders = borders;
|
|
26551
28538
|
const shading = parseShadingFill(first2(pPr, "shd"));
|
|
@@ -26553,17 +28540,17 @@ function parseFormatting(pPr) {
|
|
|
26553
28540
|
const spacing2 = first2(pPr, "spacing");
|
|
26554
28541
|
const before = twipValue(getW(spacing2, "before"));
|
|
26555
28542
|
const after = twipValue(getW(spacing2, "after"));
|
|
26556
|
-
const
|
|
28543
|
+
const line4 = signedTwipValue(getW(spacing2, "line"));
|
|
26557
28544
|
if (before !== void 0) result.spacingBeforeTwips = before;
|
|
26558
28545
|
if (after !== void 0) result.spacingAfterTwips = after;
|
|
26559
28546
|
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
26560
28547
|
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
26561
28548
|
if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
|
|
26562
28549
|
if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
|
|
26563
|
-
if (
|
|
28550
|
+
if (line4 !== void 0) result.lineSpacingTwips = line4;
|
|
26564
28551
|
const rule = getW(spacing2, "lineRule");
|
|
26565
28552
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
|
|
26566
|
-
else if (
|
|
28553
|
+
else if (line4 !== void 0) result.lineSpacingRule = "auto";
|
|
26567
28554
|
const ind = first2(pPr, "ind");
|
|
26568
28555
|
for (const [xml, key] of [
|
|
26569
28556
|
["left", "indentLeftTwips"],
|
|
@@ -27585,16 +29572,16 @@ function tableGrid(table) {
|
|
|
27585
29572
|
const cells = table.rows[row] ?? [];
|
|
27586
29573
|
if (!cells.length || sumSpans(cells) !== columns) return void 0;
|
|
27587
29574
|
const placed = [];
|
|
27588
|
-
const
|
|
29575
|
+
const line4 = new Array(columns);
|
|
27589
29576
|
let col = 0;
|
|
27590
29577
|
cells.forEach((cell, index) => {
|
|
27591
29578
|
const entry = { cell, row, index, col, span: spanOf(cell) };
|
|
27592
|
-
for (let k = 0; k < entry.span; k++)
|
|
29579
|
+
for (let k = 0; k < entry.span; k++) line4[col + k] = entry;
|
|
27593
29580
|
col += entry.span;
|
|
27594
29581
|
placed.push(entry);
|
|
27595
29582
|
});
|
|
27596
29583
|
rows2.push(placed);
|
|
27597
|
-
cover.push(
|
|
29584
|
+
cover.push(line4);
|
|
27598
29585
|
}
|
|
27599
29586
|
const grid = { columns, rows: rows2, cover };
|
|
27600
29587
|
for (const entry of rows2.flat())
|
|
@@ -28636,8 +30623,8 @@ function parseDirectParagraphProperties(props) {
|
|
|
28636
30623
|
const value = onOffElement(first2(props, key));
|
|
28637
30624
|
if (value !== void 0) paragraph[key] = value;
|
|
28638
30625
|
}
|
|
28639
|
-
const
|
|
28640
|
-
if (
|
|
30626
|
+
const outline3 = parseOutlineLevel(first2(props, "outlineLvl"));
|
|
30627
|
+
if (outline3 !== void 0) paragraph.outlineLevel = outline3;
|
|
28641
30628
|
const frame2 = first2(props, "framePr");
|
|
28642
30629
|
const dropCap = getW(frame2, "dropCap");
|
|
28643
30630
|
if (dropCap === "drop" || dropCap === "margin") {
|
|
@@ -28657,19 +30644,19 @@ function parseDirectParagraphProperties(props) {
|
|
|
28657
30644
|
const spacing2 = first2(props, "spacing");
|
|
28658
30645
|
const before = twipValue2(getW(spacing2, "before"));
|
|
28659
30646
|
const after = twipValue2(getW(spacing2, "after"));
|
|
28660
|
-
const
|
|
30647
|
+
const line4 = signedTwipValue2(getW(spacing2, "line"));
|
|
28661
30648
|
if (before !== void 0) paragraph.spacingBeforeTwips = before;
|
|
28662
30649
|
if (after !== void 0) paragraph.spacingAfterTwips = after;
|
|
28663
30650
|
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
28664
30651
|
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
28665
30652
|
if (beforeAuto !== void 0) paragraph.spacingBeforeAuto = beforeAuto;
|
|
28666
30653
|
if (afterAuto !== void 0) paragraph.spacingAfterAuto = afterAuto;
|
|
28667
|
-
if (
|
|
28668
|
-
paragraph.lineSpacingTwips =
|
|
30654
|
+
if (line4 !== void 0) {
|
|
30655
|
+
paragraph.lineSpacingTwips = line4;
|
|
28669
30656
|
}
|
|
28670
30657
|
const rule = getW(spacing2, "lineRule");
|
|
28671
30658
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") paragraph.lineSpacingRule = rule;
|
|
28672
|
-
else if (
|
|
30659
|
+
else if (line4 !== void 0) paragraph.lineSpacingRule = "auto";
|
|
28673
30660
|
const indent = first2(props, "ind");
|
|
28674
30661
|
const indentLeft = signedTwipValue2(getW(indent, "left"));
|
|
28675
30662
|
const indentRight = signedTwipValue2(getW(indent, "right"));
|
|
@@ -29246,17 +31233,17 @@ function twipsAttr(value) {
|
|
|
29246
31233
|
function signedTwipsAttr(value) {
|
|
29247
31234
|
return typeof value === "number" && Number.isFinite(value) ? roundSignedTwips(value) : void 0;
|
|
29248
31235
|
}
|
|
29249
|
-
function paragraphTwipsFromAttrs(
|
|
31236
|
+
function paragraphTwipsFromAttrs(attrs3) {
|
|
29250
31237
|
const result = {};
|
|
29251
|
-
const spacingBefore = twipsAttr(
|
|
29252
|
-
const spacingAfter = twipsAttr(
|
|
29253
|
-
const lineSpacing = signedTwipsAttr(
|
|
29254
|
-
const left = signedTwipsAttr(
|
|
29255
|
-
const right = signedTwipsAttr(
|
|
29256
|
-
const start = signedTwipsAttr(
|
|
29257
|
-
const end = signedTwipsAttr(
|
|
29258
|
-
const firstLine = twipsAttr(
|
|
29259
|
-
const hanging = twipsAttr(
|
|
31238
|
+
const spacingBefore = twipsAttr(attrs3.spacingBeforeTwips);
|
|
31239
|
+
const spacingAfter = twipsAttr(attrs3.spacingAfterTwips);
|
|
31240
|
+
const lineSpacing = signedTwipsAttr(attrs3.lineSpacingTwips);
|
|
31241
|
+
const left = signedTwipsAttr(attrs3.indentLeftTwips);
|
|
31242
|
+
const right = signedTwipsAttr(attrs3.indentRightTwips);
|
|
31243
|
+
const start = signedTwipsAttr(attrs3.indentStartTwips);
|
|
31244
|
+
const end = signedTwipsAttr(attrs3.indentEndTwips);
|
|
31245
|
+
const firstLine = twipsAttr(attrs3.firstLineTwips);
|
|
31246
|
+
const hanging = twipsAttr(attrs3.hangingTwips);
|
|
29260
31247
|
if (spacingBefore !== void 0) result.spacingBeforeTwips = spacingBefore;
|
|
29261
31248
|
if (spacingAfter !== void 0) result.spacingAfterTwips = spacingAfter;
|
|
29262
31249
|
if (lineSpacing !== void 0) result.lineSpacingTwips = lineSpacing;
|
|
@@ -29639,6 +31626,7 @@ function runToInlineNodes(run, schema, noteNumber) {
|
|
|
29639
31626
|
anchored: Boolean(run.image.anchored),
|
|
29640
31627
|
placement: run.image.placement ? JSON.stringify(run.image.placement) : null,
|
|
29641
31628
|
svgPartName: run.image.svgPartName ?? null,
|
|
31629
|
+
pictureFill: run.image.pictureFill ? JSON.stringify(run.image.pictureFill) : null,
|
|
29642
31630
|
unsupported: run.image.unsupported ?? null,
|
|
29643
31631
|
textBoxText: run.image.textBoxText ? JSON.stringify(run.image.textBoxText) : null,
|
|
29644
31632
|
textBoxEditable: run.image.textBoxEditable ?? null,
|
|
@@ -29726,6 +31714,7 @@ function appendInlineNode(runs, child3) {
|
|
|
29726
31714
|
...child3.attrs.title ? { title: child3.attrs.title } : {},
|
|
29727
31715
|
...child3.attrs.anchored ? { anchored: true } : {},
|
|
29728
31716
|
...child3.attrs.svgPartName ? { svgPartName: child3.attrs.svgPartName } : {},
|
|
31717
|
+
...typeof child3.attrs.pictureFill === "string" ? { pictureFill: JSON.parse(child3.attrs.pictureFill) } : {},
|
|
29729
31718
|
// Same key order as the parser's run: the writer compares an unchanged placeholder run by JSON.
|
|
29730
31719
|
...child3.attrs.unsupported ? { unsupported: child3.attrs.unsupported } : {},
|
|
29731
31720
|
...typeof child3.attrs.diagram === "string" ? { diagram: JSON.parse(child3.attrs.diagram) } : {},
|
|
@@ -29791,8 +31780,8 @@ var RUN_FORMAT_MARKS = /* @__PURE__ */ new Set([
|
|
|
29791
31780
|
function setInlineRunFormatting(tr, pos, run) {
|
|
29792
31781
|
const node = tr.doc.nodeAt(pos);
|
|
29793
31782
|
const projected = runToInlineNodes(run, tr.doc.type.schema)[0];
|
|
29794
|
-
const
|
|
29795
|
-
for (const [key, value] of Object.entries(
|
|
31783
|
+
const attrs3 = updatedInlineRunAttributes(node, projected.attrs.format);
|
|
31784
|
+
for (const [key, value] of Object.entries(attrs3))
|
|
29796
31785
|
if (node.attrs[key] !== value) tr.setNodeAttribute(pos, key, value);
|
|
29797
31786
|
for (const mark of node.marks)
|
|
29798
31787
|
if (RUN_FORMAT_MARKS.has(mark.type.name)) tr.removeMark(pos, pos + node.nodeSize, mark.type);
|
|
@@ -29925,33 +31914,33 @@ var PARAGRAPH_KEEP_KEYS = [
|
|
|
29925
31914
|
"contextualSpacing",
|
|
29926
31915
|
"suppressLineNumbers"
|
|
29927
31916
|
];
|
|
29928
|
-
function paragraphFromAttrs(
|
|
31917
|
+
function paragraphFromAttrs(attrs3, id, runs) {
|
|
29929
31918
|
return {
|
|
29930
31919
|
type: "paragraph",
|
|
29931
31920
|
id,
|
|
29932
31921
|
runs,
|
|
29933
|
-
...
|
|
29934
|
-
...
|
|
29935
|
-
...
|
|
29936
|
-
...
|
|
29937
|
-
...
|
|
29938
|
-
...
|
|
29939
|
-
...
|
|
29940
|
-
...
|
|
29941
|
-
...
|
|
29942
|
-
...paragraphTwipsFromAttrs(
|
|
29943
|
-
...
|
|
29944
|
-
...
|
|
29945
|
-
...
|
|
29946
|
-
...
|
|
31922
|
+
...attrs3.restoredParagraphPropertiesXml ? { restoredParagraphPropertiesXml: String(attrs3.restoredParagraphPropertiesXml) } : {},
|
|
31923
|
+
...attrs3.sourceParagraphPropertiesXml ? { sourceParagraphPropertiesXml: String(attrs3.sourceParagraphPropertiesXml) } : {},
|
|
31924
|
+
...attrs3.markRevision ? { markRevision: structuredClone(attrs3.markRevision) } : {},
|
|
31925
|
+
...attrs3.formatRevision ? { formatRevision: structuredClone(attrs3.formatRevision) } : {},
|
|
31926
|
+
...attrs3.align != null ? { align: attrs3.align } : {},
|
|
31927
|
+
...attrs3.justification != null ? { justification: attrs3.justification } : {},
|
|
31928
|
+
...attrs3.outlineLevel != null ? { outlineLevel: Number(attrs3.outlineLevel) } : {},
|
|
31929
|
+
...attrs3.direction != null ? { direction: attrs3.direction } : {},
|
|
31930
|
+
...attrs3.style ? { style: attrs3.style } : {},
|
|
31931
|
+
...paragraphTwipsFromAttrs(attrs3),
|
|
31932
|
+
...attrs3.lineSpacingRule != null ? { lineSpacingRule: attrs3.lineSpacingRule } : {},
|
|
31933
|
+
...attrs3.numId != null ? { numbering: { numId: attrs3.numId, level: attrs3.ilvl ?? 0 } } : {},
|
|
31934
|
+
...attrs3.pageBreakBefore != null ? { pageBreakBefore: Boolean(attrs3.pageBreakBefore) } : {},
|
|
31935
|
+
...attrs3.tabStops?.length ? { tabStops: structuredClone(attrs3.tabStops) } : {},
|
|
29947
31936
|
...Object.fromEntries(
|
|
29948
|
-
PARAGRAPH_KEEP_KEYS.filter((key) =>
|
|
31937
|
+
PARAGRAPH_KEEP_KEYS.filter((key) => attrs3[key] != null).map((key) => [key, attrs3[key]])
|
|
29949
31938
|
),
|
|
29950
|
-
...
|
|
29951
|
-
...
|
|
29952
|
-
...
|
|
29953
|
-
...
|
|
29954
|
-
...
|
|
31939
|
+
...attrs3.dropCap ? { dropCap: { ...attrs3.dropCap } } : {},
|
|
31940
|
+
...attrs3.borders ? { borders: structuredClone(attrs3.borders) } : {},
|
|
31941
|
+
...attrs3.shadingFill ? { shadingFill: attrs3.shadingFill } : {},
|
|
31942
|
+
...attrs3.bookmarks?.length ? { bookmarks: [...attrs3.bookmarks] } : {},
|
|
31943
|
+
...attrs3.contentControl ? { contentControl: structuredClone(attrs3.contentControl) } : {}
|
|
29955
31944
|
};
|
|
29956
31945
|
}
|
|
29957
31946
|
function paragraphAttrs(paragraph) {
|
|
@@ -30003,7 +31992,7 @@ function resolveParagraphFormatting(tr, pos, mode) {
|
|
|
30003
31992
|
if (!node) return;
|
|
30004
31993
|
const revision = paragraphFormattingRevision(node);
|
|
30005
31994
|
if (!revision) return;
|
|
30006
|
-
const
|
|
31995
|
+
const attrs3 = { ...node.attrs, formatRevision: null };
|
|
30007
31996
|
if (mode === "reject") {
|
|
30008
31997
|
const paragraph = {
|
|
30009
31998
|
type: "paragraph",
|
|
@@ -30015,14 +32004,14 @@ function resolveParagraphFormatting(tr, pos, mode) {
|
|
|
30015
32004
|
restoreParagraphFormatting(paragraph);
|
|
30016
32005
|
for (const key of PARAGRAPH_FORMAT_KEYS)
|
|
30017
32006
|
if (Object.hasOwn(node.attrs, key))
|
|
30018
|
-
|
|
30019
|
-
|
|
30020
|
-
|
|
30021
|
-
|
|
32007
|
+
attrs3[key] = paragraph[key] ?? node.type.spec.attrs?.[key]?.default ?? null;
|
|
32008
|
+
attrs3.numId = paragraph.numbering?.numId ?? null;
|
|
32009
|
+
attrs3.ilvl = paragraph.numbering?.level ?? null;
|
|
32010
|
+
attrs3.restoredParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
|
|
30022
32011
|
if (paragraph.sourceParagraphPropertiesXml)
|
|
30023
|
-
|
|
32012
|
+
attrs3.sourceParagraphPropertiesXml = paragraph.sourceParagraphPropertiesXml;
|
|
30024
32013
|
}
|
|
30025
|
-
tr.setNodeMarkup(pos, void 0,
|
|
32014
|
+
tr.setNodeMarkup(pos, void 0, attrs3);
|
|
30026
32015
|
}
|
|
30027
32016
|
|
|
30028
32017
|
// docx/ui/track-paragraph-formatting.ts
|
|
@@ -31957,9 +33946,9 @@ var WordYjsComments = class {
|
|
|
31957
33946
|
if (!id || this.records.has(id)) return null;
|
|
31958
33947
|
let added = null;
|
|
31959
33948
|
this.change(() => {
|
|
31960
|
-
const
|
|
33949
|
+
const elements3 = this.inlineEnabled() && this.inlineAnchors.add(view.state, id);
|
|
31961
33950
|
added = addComment(view, author, text2, () => id, false);
|
|
31962
|
-
if (!added &&
|
|
33951
|
+
if (!added && elements3) added = { id, author, text: text2, resolved: false };
|
|
31963
33952
|
if (added) this.records.set(id, added);
|
|
31964
33953
|
});
|
|
31965
33954
|
return added;
|
|
@@ -31992,8 +33981,8 @@ function removeSharedAnchor(fragment, id) {
|
|
|
31992
33981
|
let offset = 0;
|
|
31993
33982
|
for (const part of child3.toDelta()) {
|
|
31994
33983
|
const length = typeof part.insert === "string" ? part.insert.length : 1;
|
|
31995
|
-
for (const [key,
|
|
31996
|
-
if (key.startsWith("comment--") && Array.isArray(
|
|
33984
|
+
for (const [key, attrs3] of Object.entries(part.attributes ?? {})) {
|
|
33985
|
+
if (key.startsWith("comment--") && Array.isArray(attrs3.ids) && attrs3.ids.includes(id))
|
|
31997
33986
|
child3.format(offset, length, { [key]: null });
|
|
31998
33987
|
}
|
|
31999
33988
|
offset += length;
|
|
@@ -32050,10 +34039,10 @@ function guardDeletedNodeSelection(doc, view, binding) {
|
|
|
32050
34039
|
doc.on("beforeObserverCalls", guard);
|
|
32051
34040
|
return () => doc.off("beforeObserverCalls", guard);
|
|
32052
34041
|
}
|
|
32053
|
-
function wordYjsDocumentAttributes(
|
|
34042
|
+
function wordYjsDocumentAttributes(attrs3, canWrite) {
|
|
32054
34043
|
const patch = (state) => {
|
|
32055
34044
|
const tr = state.tr;
|
|
32056
|
-
for (const [key, value] of
|
|
34045
|
+
for (const [key, value] of attrs3.entries()) {
|
|
32057
34046
|
if (key !== "commentThreads" && key in (state.doc.type.spec.attrs ?? {}) && JSON.stringify(state.doc.attrs[key]) !== JSON.stringify(value))
|
|
32058
34047
|
tr.setDocAttribute(key, value);
|
|
32059
34048
|
}
|
|
@@ -32070,18 +34059,18 @@ function wordYjsDocumentAttributes(attrs2, canWrite) {
|
|
|
32070
34059
|
binding?.mux(() => view.dispatch(tr));
|
|
32071
34060
|
}
|
|
32072
34061
|
};
|
|
32073
|
-
|
|
34062
|
+
attrs3.observe(changed);
|
|
32074
34063
|
return {
|
|
32075
34064
|
update: (next, previous) => {
|
|
32076
34065
|
if (previous.doc.attrs === next.state.doc.attrs || !canWrite()) return;
|
|
32077
|
-
|
|
34066
|
+
attrs3.doc.transact((transaction) => {
|
|
32078
34067
|
transaction.meta.set("addToHistory", thisPlugin.getState(next.state));
|
|
32079
34068
|
for (const [key, value] of Object.entries(next.state.doc.attrs))
|
|
32080
|
-
if (key !== "commentThreads" && JSON.stringify(
|
|
32081
|
-
|
|
34069
|
+
if (key !== "commentThreads" && JSON.stringify(attrs3.get(key)) !== JSON.stringify(value))
|
|
34070
|
+
attrs3.set(key, value);
|
|
32082
34071
|
}, yProsemirror.ySyncPluginKey);
|
|
32083
34072
|
},
|
|
32084
|
-
destroy: () =>
|
|
34073
|
+
destroy: () => attrs3.unobserve(changed)
|
|
32085
34074
|
};
|
|
32086
34075
|
}
|
|
32087
34076
|
});
|
|
@@ -32742,10 +34731,10 @@ var insertWordHardBreak = (state, dispatch, view) => {
|
|
|
32742
34731
|
// docx/ui/chart-spec.ts
|
|
32743
34732
|
var SVG_NS2 = "http://www.w3.org/2000/svg";
|
|
32744
34733
|
function elementSpec(element3, root) {
|
|
32745
|
-
const
|
|
34734
|
+
const attrs3 = {};
|
|
32746
34735
|
for (const attr2 of Array.from(element3.attributes)) {
|
|
32747
34736
|
if (attr2.name === "xmlns" || attr2.name.startsWith("xmlns:") || /^on/i.test(attr2.name)) continue;
|
|
32748
|
-
|
|
34737
|
+
attrs3[attr2.name] = attr2.value;
|
|
32749
34738
|
}
|
|
32750
34739
|
const children3 = [];
|
|
32751
34740
|
for (const child3 of Array.from(element3.childNodes)) {
|
|
@@ -32753,7 +34742,7 @@ function elementSpec(element3, root) {
|
|
|
32753
34742
|
else if (child3.nodeType === 3 && child3.nodeValue) children3.push(child3.nodeValue);
|
|
32754
34743
|
}
|
|
32755
34744
|
const tag = root ? `${SVG_NS2} ${element3.localName}` : element3.localName;
|
|
32756
|
-
return [tag,
|
|
34745
|
+
return [tag, attrs3, ...children3];
|
|
32757
34746
|
}
|
|
32758
34747
|
function svgMarkupSpec(svg) {
|
|
32759
34748
|
return elementSpec(parseXml(svg, { label: "Chart SVG" }).documentElement, true);
|
|
@@ -32817,7 +34806,7 @@ function textBoxLines(value) {
|
|
|
32817
34806
|
if (typeof value !== "string") return [];
|
|
32818
34807
|
try {
|
|
32819
34808
|
const lines = JSON.parse(value);
|
|
32820
|
-
return Array.isArray(lines) ? lines.map((
|
|
34809
|
+
return Array.isArray(lines) ? lines.map((line4) => ["span", { class: "dve-textbox-line" }, String(line4)]) : [];
|
|
32821
34810
|
} catch {
|
|
32822
34811
|
return [];
|
|
32823
34812
|
}
|
|
@@ -32842,6 +34831,7 @@ var imageNodeSpec = {
|
|
|
32842
34831
|
placement: { default: null },
|
|
32843
34832
|
/** SVG original shown instead of the PNG fallback in `partName`. */
|
|
32844
34833
|
svgPartName: { default: null },
|
|
34834
|
+
pictureFill: { default: null },
|
|
32845
34835
|
unsupported: { default: null },
|
|
32846
34836
|
/** A text box's paragraphs as a JSON string array; shown read-only inside its placeholder. */
|
|
32847
34837
|
textBoxText: { default: null },
|
|
@@ -34375,12 +36365,12 @@ var markSpecs = {
|
|
|
34375
36365
|
}
|
|
34376
36366
|
],
|
|
34377
36367
|
toDOM: (mark) => {
|
|
34378
|
-
const
|
|
34379
|
-
if (mark.attrs.language)
|
|
36368
|
+
const attrs3 = {};
|
|
36369
|
+
if (mark.attrs.language) attrs3.lang = mark.attrs.language;
|
|
34380
36370
|
if (mark.attrs.eastAsiaLanguage)
|
|
34381
|
-
|
|
34382
|
-
if (mark.attrs.bidiLanguage)
|
|
34383
|
-
return ["span",
|
|
36371
|
+
attrs3["data-docx-east-asia-language"] = mark.attrs.eastAsiaLanguage;
|
|
36372
|
+
if (mark.attrs.bidiLanguage) attrs3["data-docx-bidi-language"] = mark.attrs.bidiLanguage;
|
|
36373
|
+
return ["span", attrs3, 0];
|
|
34384
36374
|
}
|
|
34385
36375
|
},
|
|
34386
36376
|
runRtl: {
|
|
@@ -34402,12 +36392,12 @@ var markSpecs = {
|
|
|
34402
36392
|
tag: "span",
|
|
34403
36393
|
getAttrs: (el5) => {
|
|
34404
36394
|
const style = el5.style;
|
|
34405
|
-
const
|
|
36395
|
+
const attrs3 = {
|
|
34406
36396
|
family: pastedFontFamily(style.fontFamily),
|
|
34407
36397
|
size: style.fontSize ? parseFontSize(style.fontSize) : null,
|
|
34408
36398
|
color: pastedColor(style.color)
|
|
34409
36399
|
};
|
|
34410
|
-
return
|
|
36400
|
+
return attrs3.family || attrs3.size || attrs3.color ? attrs3 : false;
|
|
34411
36401
|
}
|
|
34412
36402
|
}
|
|
34413
36403
|
],
|
|
@@ -34568,15 +36558,15 @@ function parseBordersJson(value) {
|
|
|
34568
36558
|
}
|
|
34569
36559
|
}
|
|
34570
36560
|
var twipsPx = (value) => Number.isSafeInteger(value) ? `${Number(value) / 15}px` : null;
|
|
34571
|
-
function tableStyle(
|
|
34572
|
-
const borders = parseBordersJson(
|
|
34573
|
-
const margins = marginValues(
|
|
36561
|
+
function tableStyle(attrs3) {
|
|
36562
|
+
const borders = parseBordersJson(attrs3.borders);
|
|
36563
|
+
const margins = marginValues(attrs3.cellMargins);
|
|
34574
36564
|
const declarations = [
|
|
34575
36565
|
"border-collapse:collapse",
|
|
34576
|
-
twipsPx(
|
|
34577
|
-
|
|
34578
|
-
|
|
34579
|
-
twipsPx(
|
|
36566
|
+
twipsPx(attrs3.widthTwips) && `width:${twipsPx(attrs3.widthTwips)}`,
|
|
36567
|
+
attrs3.alignment === "center" && "margin-left:auto;margin-right:auto",
|
|
36568
|
+
attrs3.alignment === "right" && "margin-left:auto",
|
|
36569
|
+
twipsPx(attrs3.indentTwips) && attrs3.alignment !== "center" && `margin-left:${twipsPx(attrs3.indentTwips)}`,
|
|
34580
36570
|
// Cells without their own resolved borders (e.g. a table inserted in the editor) draw the
|
|
34581
36571
|
// table's inside line; tables with no border information fall back to dashed gridlines.
|
|
34582
36572
|
borders && `--dve-cell-border:${cssBorderSide(borders.insideH ?? borders.top) ?? "none"}`,
|
|
@@ -34606,14 +36596,14 @@ function cellPadding(value) {
|
|
|
34606
36596
|
(side) => margins[side] === void 0 ? `var(--dve-cell-padding-${side}, ${DEFAULT_CELL_MARGINS[side] / 15}px)` : `${margins[side]}px`
|
|
34607
36597
|
).join(" ")}`;
|
|
34608
36598
|
}
|
|
34609
|
-
function tableCellStyle(
|
|
34610
|
-
const borders = parseBordersJson(
|
|
34611
|
-
const verticalAlign =
|
|
36599
|
+
function tableCellStyle(attrs3) {
|
|
36600
|
+
const borders = parseBordersJson(attrs3.borders);
|
|
36601
|
+
const verticalAlign = attrs3.verticalAlign === "center" ? "middle" : attrs3.verticalAlign === "bottom" ? "bottom" : "top";
|
|
34612
36602
|
const declarations = [
|
|
34613
|
-
cellPadding(
|
|
36603
|
+
cellPadding(attrs3.margins),
|
|
34614
36604
|
`vertical-align:${verticalAlign}`,
|
|
34615
|
-
twipsPx(
|
|
34616
|
-
typeof
|
|
36605
|
+
twipsPx(attrs3.widthTwips) && `width:${twipsPx(attrs3.widthTwips)}`,
|
|
36606
|
+
typeof attrs3.shadingFill === "string" && `background-color:${attrs3.shadingFill}`,
|
|
34617
36607
|
...["top", "bottom", "left", "right"].map(
|
|
34618
36608
|
(side) => borders && (cssBorderSide(borders[side]) ? `border-${side}:${cssBorderSide(borders[side])}` : `border-${side}-style:none`)
|
|
34619
36609
|
)
|
|
@@ -34624,10 +36614,10 @@ function paragraphBoxCss(borders, shadingFill) {
|
|
|
34624
36614
|
const parsed = typeof borders === "string" ? parseBordersJson(borders) : borders;
|
|
34625
36615
|
const css = [];
|
|
34626
36616
|
for (const side of ["top", "bottom", "left", "right"]) {
|
|
34627
|
-
const
|
|
34628
|
-
if (!
|
|
36617
|
+
const line4 = cssBorderSide(parsed?.[side]);
|
|
36618
|
+
if (!line4) continue;
|
|
34629
36619
|
css.push(
|
|
34630
|
-
`border-${side}:${
|
|
36620
|
+
`border-${side}:${line4}`,
|
|
34631
36621
|
`padding-${side}:${(parsed[side].spacePoints ?? 0) * 4 / 3}px`
|
|
34632
36622
|
);
|
|
34633
36623
|
}
|