allyhub 0.12.0 → 0.13.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/CHANGELOG.md +8 -0
- package/dist/commands/frames/report.js +1 -1
- package/dist/commands/frames.js +11 -11
- package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/package.json +1 -1
- package/dist/node_modules/@allyhub/build/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/build/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
- package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
- package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/call.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/records.d.ts +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/uploads.d.ts +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/uploads.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +1 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/server.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
- package/dist/node_modules/@allyhub/export/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +130 -0
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
- package/dist/node_modules/@allyhub/image-render/package.json +1 -1
- package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/jobs/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/dist/run.d.ts +6 -1
- package/dist/node_modules/@allyhub/media/dist/run.js +2 -2
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
- package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
- package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +35 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +19 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +73 -10
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +9 -9
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/package.json +1 -1
- package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +1 -1
- package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +3 -3
- package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +29 -1
- package/dist/node_modules/@allyhub/report-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +11 -4
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +6 -2
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +1 -1
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +3 -1
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/workspace.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/audio-icon.js +2 -0
- package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +3 -3
- package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/import/script.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/chart.js +2 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/index.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/table.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/timing.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/table-styles.js +2 -0
- package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/theme.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/timing.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
- package/dist/node_modules/@allyhub/slides-runtime/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/ink.js +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
- package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/stage/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +101 -49
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/errors.js +2 -0
- package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/inspect/timeline-text.js +1 -1
- package/dist/node_modules/@allyhub/video-extension/package.json +3 -3
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +12 -12
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-BKmMA6gn.js → abnfDiagram-WEYOIA3C-D70jg8mE.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-BEFBgb4k.js → architecture-WOLXFQ4H-CrXS3E8e.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-_u5YfCjY.js → architectureDiagram-ZHVYKT53-JrBljCOx.js} +1 -1
- package/editor-web/assets/arrow-down-DzZjFrBL.js +1 -0
- package/editor-web/assets/arrow-up-hdmh9LVD.js +1 -0
- package/editor-web/assets/{article-BUmD3xtR.js → article-BWrfVMRA.js} +6 -6
- package/editor-web/assets/article-hxHjqzV1.js +7 -0
- package/editor-web/assets/{audio-lines-CzuzsGjI.js → audio-lines-1s1eRs4Q.js} +1 -1
- package/editor-web/assets/{blockDiagram-RJAE7QA3-DybfaO3Z.js → blockDiagram-RJAE7QA3-BzfC1xTS.js} +1 -1
- package/editor-web/assets/{bookmark-Dsd3kHJJ.js → bookmark-Dfji3syX.js} +1 -1
- package/editor-web/assets/{button-eGxLxbv9.js → button-EftXSfev.js} +1 -1
- package/editor-web/assets/{c4Diagram-XDPPPE54-BfqLHB5i.js → c4Diagram-XDPPPE54-s2TpXKgH.js} +1 -1
- package/editor-web/assets/calc-worker-jImBXoeb.js +45 -0
- package/editor-web/assets/channel-BFbXY6R0.js +1 -0
- package/editor-web/assets/chart-BC3kUUDD.js +2 -0
- package/editor-web/assets/{chart-no-axes-column-BVkeF_Mr.js → chart-no-axes-column-CJmeYOSo.js} +1 -1
- package/editor-web/assets/{chunk-2E7WHVMD-BVp1I_d0.js → chunk-2E7WHVMD-DyE9v6UX.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-CTdgWEMr.js → chunk-4EMNKR2T-CCunMMcT.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-7pnsxeaP.js → chunk-55XCU76K-CZgJYrN4.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-Dc0Dvkq7.js → chunk-7S6XSTFO-B01FlTFf.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-VAILIsfx.js → chunk-AQDTSKZB-latWUvVu.js} +1 -1
- package/editor-web/assets/{chunk-DSNLSHJZ-CUDx1Rv5.js → chunk-DSNLSHJZ-BHFiQInN.js} +1 -1
- package/editor-web/assets/{chunk-HAGFOTED-DAoEe-dJ.js → chunk-HAGFOTED-C4hR36ab.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-g0akya12.js → chunk-HNE4Q36P-CNrxiD2Q.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-hTGjzXdJ.js → chunk-NQOKRVIF-DpyEHKEY.js} +1 -1
- package/editor-web/assets/{chunk-UHW7PFBP-BgLV8BIJ.js → chunk-UHW7PFBP-SIEJdixh.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-Bw19OOSD.js → chunk-VQ5W62QI-CxWnQRxx.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-CMST9dyE.js → chunk-WQQL4CDK-CbRuCBm6.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-Bbpu36XF.js → chunk-YZO67HFG-Cgu-EQvs.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-C48Ri0Gs.js → chunk-ZAUX2LTX-pAl5CV3o.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-DN1g01Oe.js → chunk-ZCHMQSOR-Du5hY-FP.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-U6jbPr2d.js → classDiagram-v2-4MYWR3UA-CevU94T6.js} +1 -1
- package/editor-web/assets/{collaborator-B1u2td9m.js → collaborator-C6IJkcGR.js} +1 -1
- package/editor-web/assets/copy-DvOiv9Ra.js +1 -0
- package/editor-web/assets/{createLucideIcon-GFZ_fxLc.js → createLucideIcon-REX213UO.js} +1 -1
- package/editor-web/assets/{cynefin-EF2NZ3EQ-gzkai_7-.js → cynefin-EF2NZ3EQ-DBHwpMRJ.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-DtSekSr6.js → cynefinDiagram-WF24UDRP-CxUzpjvG.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-CiUwYVT6.js → dagre-NK4GIZVX-BAJNBDYO.js} +1 -1
- package/editor-web/assets/{diagram-CBK3MWTC-r9XHCV-k.js → diagram-CBK3MWTC-BQW9Fbw-.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-DxVsDZ34.js → diagram-I5XIIV2D-DQBROUfn.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-B0eNQoHV.js → diagram-ODIL2UCW-DEoK31qy.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-C7f2MfJT.js → diagram-PFBEJUXE-BTCa2We1.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-CSXcnvct.js → diagram-RJA3I4VV-DNM8qWC3.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-DXzOD_ii.js → diagram-TYUNFSNR-BcKpED4d.js} +1 -1
- package/editor-web/assets/dist-90dg0B0d.js +2 -0
- package/editor-web/assets/dist-BSPs7tZR.js +1 -0
- package/editor-web/assets/dist-CP9XwbBS.js +45 -0
- package/editor-web/assets/dist-CRxtC7DG.js +24 -0
- package/editor-web/assets/{dist-CC7OeU1e.js → dist-Cmnq14RO.js} +3 -3
- package/editor-web/assets/dist-CrZwqOm2.js +1 -0
- package/editor-web/assets/dist-CzUWTcvC.js +38 -0
- package/editor-web/assets/dist-D2a_y4AE.js +1 -0
- package/editor-web/assets/{dist-DDv_SbKw.js → dist-DMZ1VHPK.js} +1 -1
- package/editor-web/assets/dist-DYnXIW8F.js +16 -0
- package/editor-web/assets/{dist-BuWaZ3Y4.js → dist-Dpet39Yp.js} +30 -30
- package/editor-web/assets/dist-Dre4Cwpz.js +1 -0
- package/editor-web/assets/dist-RkxskWGK.js +5 -0
- package/editor-web/assets/dist-aANR6S2I.js +3 -0
- package/editor-web/assets/{dist-Gz6NDS0J.js → dist-qSuFWuVB.js} +3 -3
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-Cs4YRvDD.js → ebnfDiagram-V4P3TTPT-D-1x27Eh.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-Bh3LZ9WI.js → elk-QONTBCTQ-BJSCxiTH.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-C4vYTYXp.js → erDiagram-KYQIGQAA-C7Q357iD.js} +1 -1
- package/editor-web/assets/{eventmodeling-K75KTNOO-BN1kkHWS.js → eventmodeling-K75KTNOO-kXrQLSF5.js} +1 -1
- package/editor-web/assets/flowDiagram-IUGLLWBU-GSC4btef.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-CA1LkkC5.js → ganttDiagram-R7GPNTJY-Bt3SRgK7.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-Dy5tA7dG.js → gitGraph-VSP46ZUC-DS4CkhfK.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-hJIB8EkH.js → gitGraphDiagram-PDYL7XHY-BgfmSVdI.js} +1 -1
- package/editor-web/assets/group-pebHQTdP.js +1 -0
- package/editor-web/assets/{hint-B8JpEypy.js → hint-BmRKl2nL.js} +1 -1
- package/editor-web/assets/index-D8qc_ipi.js +28 -0
- package/editor-web/assets/index-DDtZpLDF.css +2 -0
- package/editor-web/assets/{info-OHQRW6UA-DvzSf7rQ.js → info-OHQRW6UA-BZjctF3x.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-BjIMm4Af.js → infoDiagram-MVDRKAX5-BAp5oUXk.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Bpz71S40.js → ishikawaDiagram-HPEHV2GE-DGL7ZfUu.js} +1 -1
- package/editor-web/assets/{italic-D10w8n6C.js → italic-CtlNOXN9.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-DAB-pZjD.js → journeyDiagram-BOSHW7O7-DOOoBGx-.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-cYeyh3P6.js → kanban-definition-FNSA4HC5-lbLuUiMW.js} +1 -1
- package/editor-web/assets/katex-UWCZofcd.js +257 -0
- package/editor-web/assets/{link-BC5xK1-1.js → link-CW2KxKT_.js} +1 -1
- package/editor-web/assets/{mermaid-parser.core-req5LE0X.js → mermaid-parser.core-RkCFmJcg.js} +3 -3
- package/editor-web/assets/{mermaid.core-zFwZug4C.js → mermaid.core-BVUl-afX.js} +4 -4
- package/editor-web/assets/{mindmap-definition-6OY57UG3-TStWb7DG.js → mindmap-definition-6OY57UG3-C3DC4T1J.js} +1 -1
- package/editor-web/assets/minus-D1tgAHbU.js +1 -0
- package/editor-web/assets/{packet-JDAUHWVQ-smFhVKcB.js → packet-JDAUHWVQ-Bkd6YpX8.js} +1 -1
- package/editor-web/assets/{palette-BIOudGkm.js → palette-INFK0Zsr.js} +1 -1
- package/editor-web/assets/{pegDiagram-ECIUJNBX-DvSNRv0-.js → pegDiagram-ECIUJNBX-B5Seh4Oe.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-qjaGsBZG.js → pie-XZMESJXO-BNbb4Q8k.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-Dd9P-Pdc.js → pieDiagram-GNMPY74T-_hnbUloZ.js} +1 -1
- package/editor-web/assets/play-DvMyq5xW.js +1 -0
- package/editor-web/assets/{progress-DE4C5_3x.js → progress-D6wSFdpY.js} +1 -1
- package/editor-web/assets/props-form-BfwEi6jW.js +1 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-h2IIKUUA.js → quadrantDiagram-D57K4MC3-1rbqW-KO.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-DlVrSA1d.js → radar-ABXABTNO-BWSnhBSp.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-nFbuLAtc.js → railroad-I3PHUGI6-BNB-OKs1.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-Daj8h2iV.js → railroad-abnf-LNEFI6M7-BKgidf_B.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-eYJyl5PH.js → railroad-ebnf-DWYD2UWJ-CNCnxtHp.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-BTRhKZQq.js → railroad-peg-JR7BVNR7-CyBW6_0o.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-CeLGUjdp.js → railroadDiagram-Y72NRBL7-Cud3SJ7O.js} +1 -1
- package/editor-web/assets/{react-WA6wlt8S.js → react-Bk7NnOLX.js} +1 -1
- package/editor-web/assets/{repeat-2-VQP1EVOZ.js → repeat-2-DfPmKp4w.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dmk9XRM5.js → requirementDiagram-EQYSW5RA-BrSCcpqV.js} +1 -1
- package/editor-web/assets/{row-BRlEWRrK.js → row-VwyPfa1b.js} +1 -1
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-Yn4zlrAM.js → sankeyDiagram-SY24JHO5-rJV4dJFn.js} +1 -1
- package/editor-web/assets/scissors-D9WmgvNP.js +1 -0
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-BTRnp_PW.js → sequenceDiagram-BLEHNHQU-CEUuD2n6.js} +1 -1
- package/editor-web/assets/{session-Do9AqS38.js → session-DE0fvAcs.js} +1 -1
- package/editor-web/assets/sigma-CY2Chbro.js +1 -0
- package/editor-web/assets/slides-BgacyjJW.js +1 -0
- package/editor-web/assets/{snapshots-BUGlKQIB.js → snapshots-D8TtZp1x.js} +1 -1
- package/editor-web/assets/{sound-Bj3o9_Fa.js → sound-DUCxe9eC.js} +1 -1
- package/editor-web/assets/split-Cx2MMnC_.js +3 -0
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-kstrRKv2.js → stateDiagram-v2-A6IESKWZ-BRE_C2he.js} +1 -1
- package/editor-web/assets/sticky-note-C5qUDHhC.js +1 -0
- package/editor-web/assets/{strikethrough-CfXx6IYH.js → strikethrough-DP-7tMz0.js} +1 -1
- package/editor-web/assets/svg-nJtFNJ-7.js +1 -0
- package/editor-web/assets/{swatch-WeJD41aW.js → swatch-lxK4C8fD.js} +1 -1
- package/editor-web/assets/{swimlanes-B3ENRKFQ-DaZsZkeP.js → swimlanes-B3ENRKFQ-BEPqWgVe.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DAcNszZ6.js +8 -0
- package/editor-web/assets/{switch-N0G_sbqt.js → switch-DaG6OuAi.js} +1 -1
- package/editor-web/assets/{syntax-oWsKBWFw.js → syntax-9LD8MzGy.js} +1 -1
- package/editor-web/assets/{syntax-BVsgRJ4I.js → syntax-CLaCSmoi.js} +1 -1
- package/editor-web/assets/{table-B6hVZAMi.js → table-CTjNpE4W.js} +1 -1
- package/editor-web/assets/tabs-DjhzblAG.js +1 -0
- package/editor-web/assets/{textarea-tEWvBY9p.js → textarea-DBwRbOyF.js} +1 -1
- package/editor-web/assets/{timeline-definition-JXYKGLGB-CLCvY-Yf.js → timeline-definition-JXYKGLGB-p8Qeg4pS.js} +1 -1
- package/editor-web/assets/{trash-2-BP6nqpg2.js → trash-2-DrnRa91l.js} +1 -1
- package/editor-web/assets/{treeView-D4JQ5SDB-BmN0gwdC.js → treeView-D4JQ5SDB-C9FTdXKq.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-DN29G_E_.js → treemap-SAJKECNS-XAeLVOtI.js} +1 -1
- package/editor-web/assets/{undo-2-CHR0nvWL.js → undo-2-DUGGyBdX.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-DTRS54cB.js → usecaseDiagram-WPOLBNNX-BV3AMRuH.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-DAAc11Hx.js → vennDiagram-Q3Y3IDCW-CJdKcYyA.js} +1 -1
- package/editor-web/assets/{video-BlvmR8BK.js → video-He8p6dr6.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-B-UYkmdB.js → wardley-7MLQ67FV-DZh6Mf22.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-BmbwCaky.js → wardleyDiagram-IVAIDKWA-XtvKSX-m.js} +1 -1
- package/editor-web/assets/{words-D_4T9Adq.js → words-CPHp_0tt.js} +1 -1
- package/editor-web/assets/{words-WgdEQdYP.js → words-CjW-1tZI.js} +1 -1
- package/editor-web/assets/{xychartDiagram-4URNHDU4-ChAfAq1U.js → xychartDiagram-4URNHDU4-CGkL42sz.js} +1 -1
- package/editor-web/assets/zoom-in-C4lxmIDE.js +1 -0
- package/editor-web/index.html +6 -6
- package/package.json +2 -2
- package/editor-web/assets/arrow-up-B5rJbBv0.js +0 -1
- package/editor-web/assets/article-DNioBb3p.js +0 -7
- package/editor-web/assets/calc-worker-D2pGis6e.js +0 -45
- package/editor-web/assets/channel-TNPgFDrw.js +0 -1
- package/editor-web/assets/chart-C37xvZT2.js +0 -1
- package/editor-web/assets/dist-BGRwhCQO.js +0 -1
- package/editor-web/assets/dist-BW4X7BrF.js +0 -1
- package/editor-web/assets/dist-BgDRE85b.js +0 -2
- package/editor-web/assets/dist-Blq5nJnU.js +0 -24
- package/editor-web/assets/dist-C1emZ9wX.js +0 -37
- package/editor-web/assets/dist-CX-fiPSn.js +0 -38
- package/editor-web/assets/dist-C_VvG-_9.js +0 -5
- package/editor-web/assets/dist-Ce7HrBxv.js +0 -3
- package/editor-web/assets/dist-D2k6w-_a.js +0 -1
- package/editor-web/assets/dist-DEoEO4zs.js +0 -1
- package/editor-web/assets/dist-DlDxxPIP.js +0 -16
- package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +0 -1
- package/editor-web/assets/index-CgB5osVc.js +0 -28
- package/editor-web/assets/index-Daytem9N.css +0 -2
- package/editor-web/assets/katex-5Z2zF-9g.js +0 -257
- package/editor-web/assets/minus-DaWs5i8B.js +0 -1
- package/editor-web/assets/play-CrMmPghG.js +0 -1
- package/editor-web/assets/props-form-CsmDBqzy.js +0 -1
- package/editor-web/assets/schemas-VikZYZIK.js +0 -1
- package/editor-web/assets/slides-diTEQ3C5.js +0 -1
- package/editor-web/assets/split-CNU1RHcX.js +0 -3
- package/editor-web/assets/svg-Cx50MpxK.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +0 -8
- package/editor-web/assets/tabs-DIFDqj-l.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{colorFile as
|
|
3
|
-
`)??"";return r.length===9&&
|
|
4
|
-
`)===l)?[`for (const level of ${e}) {`,...(r[0]??[]).map(a=>` ${a}`),"}"]:i.flatMap((a,c)=>j(`${e}[${String(c)}]`,a,!0,o[c]))}const P={margin_left:M.left,margin_top:M.top,margin_right:M.right,margin_bottom:M.bottom};export const MADE={placeholder:e=>({...le(e),...P}),textbox:{vertical_anchor:"t",...de,...P},autoshape:{vertical_anchor:O.vertical_anchor,word_wrap:!0,auto_size:"none",...P}},FILE_TEXTBOX={...MADE.textbox,...ae};export function bodyLines(e,n,o={},i=[]){if(!n)return[];const r=s=>n[s]===void 0||n[s]===o[s]?void 0:n[s],l=r("vertical_anchor"),a=r("auto_size"),c=r("word_wrap");return[...l===void 0?[]:[`${e}.vertical_anchor = ${ue[l]};`],...a===void 0?[]:[`${e}.auto_size = ${_e[a]};`],...c===void 0?[]:[`${e}.word_wrap = ${String(c)};`],...["margin_left","margin_top","margin_right","margin_bottom"].flatMap(s=>{const f=r(s);return f===void 0?[]:[`${e}.${s} = ${emu(f)};`]}),...levelLines(`${e}.list_style`,n.levels,i)]}export const sameColor=(e,n)=>JSON.stringify(e)===JSON.stringify(n);function G(e,n,o){return n===void 0||sameColor(n,o)?[]:n===null?[`${e}.fill.background();`]:[`${e}.fill.solid();`,...colorLines(`${e}.fill.fore_color`,n)]}function k(e,n,o){return[...n.line===void 0||sameColor(n.line,o.line)?[]:n.line===null?[`${e}.line.fill.background();`]:colorLines(`${e}.line.color`,n.line),...n.line_width===void 0||n.line===null||n.line_width===o.line_width?[]:[`${e}.line.width = ${emu(n.line_width)};`],...n.line_dash===void 0?[]:[`${e}.line.dash_style = ${str(n.line_dash)};`],...n.line_begin===void 0?[]:[`${e}.line.begin_arrow = ${str(n.line_begin)};`],...n.line_end===void 0?[]:[`${e}.line.end_arrow = ${str(n.line_end)};`],...["begin","end"].flatMap(i=>{const r=i==="begin"?n.line_begin_size:n.line_end_size;return[...r?.w===void 0?[]:[`${e}.line.${i}_arrow_width = ${str(r.w)};`],...r?.len===void 0?[]:[`${e}.line.${i}_arrow_length = ${str(r.len)};`]]})]}export const lineFile=e=>({...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size}});function ye(e,n,o){const i=n.frame??{left:0,top:0,width:0,height:0},r=o.w===0?1:i.width/o.w,l=o.h===0?1:i.height/o.h,a=o.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),c=d=>Math.min(...a.map(t=>t[d]??0)),[s,...f]=o.steps,g=s?.op==="move"?`${String(s.x)}, ${String(s.y)}`:"0, 0",p=(s?.op==="move"?f:o.steps).map(d=>d.op==="close"?".add_line_segments([], true)":d.op==="move"?`.move_to(${String(d.x)}, ${String(d.y)})`:d.op==="line"?`.add_line_segments([[${String(d.x)}, ${String(d.y)}]], false)`:`.add_curve_segment(${[d.x1,d.y1,d.x2,d.y2,d.x,d.y].map(String).join(", ")})`);return`${e}.shapes.build_freeform(${g}, [${String(r)}, ${String(l)}])${p.join("")}.convert_to_shape(${emu(i.left-Math.round(c(0)*r))}, ${emu(i.top-Math.round(c(1)*l))})`}const C=(e,n)=>n.rotation===void 0?[]:[`${e}.rotation = ${String(Math.round(n.rotation*1e3)/1e3)};`];function Se(e){const n=e.text?.levels??[],o=e.text_color??"dk1";return e.kind!=="autoshape"||sameColor(o,O.font_color)?n:Array.from({length:9},(i,r)=>{const l=n[r]??{};return l.font?.color!==void 0?l:{...l,font:{...l.font,color:o}}})}function xe(e,n,o,i={}){return o.flatMap((r,l)=>{const a=`${e}_p${String(l)}`,c=[...r.level>0?[`${a}.level = ${String(r.level)};`]:[],...j(a,r,!1,l===0?i:{}),...r.runs.flatMap((s,f)=>s.text==="\v"?[`${a}.add_line_break();`]:s.font?[`const ${a}r${String(f)} = ${a}.add_run();`,`${a}r${String(f)}.text = ${str(s.text)};`,...U(`${a}r${String(f)}.font`,s.font),...s.font.link===void 0?[]:[`${a}r${String(f)}.hyperlink.address = ${str(s.font.link)};`]]:[`${a}.add_run().text = ${str(s.text)};`])];return l===0&&c.length===0?[]:[`const ${a} = ${l===0?`${n}.paragraphs[0]`:`${n}.add_paragraph()`};`,...c]})}const v=e=>`${emu(e.left)}, ${emu(e.top)}, ${emu(e.width)}, ${emu(e.height)}`;export class MediaFiles{files=new Map;byPart=new Map;bytes;taken;constructor(n,o=()=>!1){this.bytes=n,this.taken=o}path(n){const o=this.byPart.get(n);if(o)return o;const i=this.bytes(n);if(!i)return;const r=n.split("/").pop()??"file",l=r.lastIndexOf("."),[a,c]=l>0?[r.slice(0,l),r.slice(l)]:[r,""];let s=r;for(let f=2;this.files.has(s)||this.taken(s);f++)s=`${a}-${String(f)}${c}`;return this.files.set(s,i),this.byPart.set(n,`./${s}`),`./${s}`}}export const GLUE_MOVED="a glued connector is drawn with its ends on its shapes' sites, where the file has it off them";const X=e=>({left:A($(e.left)),top:A($(e.top)),width:A($(e.width)),height:A($(e.height))});export function placedGlue(e,n=()=>{}){const o=new Map(e.flatMap(i=>i.id===void 0?[]:[[i.id,i]]));return e.map(i=>{if(!i.glue||!i.frame)return i;const r=p=>p===void 0?void 0:{shape:p.id,site:p.site},l=r(i.glue.begin),a=r(i.glue.end),c=ce({frame:X(i.frame),flip:i.flip,rotation:i.rotation,connect:{...l?{begin:l}:{},...a?{end:a}:{}}},p=>{const d=o.get(p);return d?.frame?{frame:X(d.frame),geometry:d.geometry,adjustments:d.adjustments,flip:d.flip,rotation:d.rotation,path:d.path}:void 0}),s=i.frame,f=c.frame;(Math.abs(s.left-f.left)>64||Math.abs(s.top-f.top)>64||Math.abs(s.width-f.width)>64||Math.abs(s.height-f.height)>64||!!i.flip?.h!=!!c.flip?.h||!!i.flip?.v!=!!c.flip?.v)&&n(i);const g={...i,frame:c.frame};return c.flip?g.flip=c.flip:delete g.flip,g})}export function shapeCode(e,n,o,i,r){const l=placedGlue(n,t=>{i(t,"p:cNvCxnSpPr",GLUE_MOVED,"approximated")}),a=[],c=new Set,s=new Map,f=new Map,g=new Set(l.flatMap(t=>[t.glue?.begin?.id,t.glue?.end?.id].filter(S=>S!==void 0))),p=new Map,d=[];l.forEach((t,S)=>{const u=`${e}_s${String(S)}`,w=t.id!==void 0&&g.has(t.id);w&&t.id!==void 0&&p.set(t.id,u);let h=e;if(t.group!==void 0&&(h=f.get(t.group)??`${e}_g${String(f.size)}`,f.has(t.group)||(f.set(t.group,h),a.push(`const ${h} = ${e}.shapes.add_group_shape();`,`${h}.name = ${str(z(t.group,c,"group"))};`))),t.flip&&!F(t.geometry)&&i(t,"a:xfrm@flipH","a master's or a layout's shape mirrored: python-pptx's API has no flip"),t.kind==="placeholder"&&t.placeholder){const _=/^[A-Za-z0-9_-]+$/u.test(t.name)?z(t.name,c,"placeholder"):z(B[t.placeholder.type],c,"placeholder");s.set(t.placeholder.idx,_);const x=bodyLines(`${u}.text_frame`,t.text,r?MADE.placeholder(t.placeholder.type):{},se(t.placeholder.type));a.push(`${x.length>0||w?`const ${u} = `:""}${h}.placeholders.add(PP_PLACEHOLDER.${he[t.placeholder.type]}${t.frame?`, ${v(t.frame)}`:""}${_===B[t.placeholder.type]?"":`, { name: ${str(_)} }`});`,...x);return}const b=z(t.name,c,t.kind);if(!t.frame){i(t,"a:xfrm","a shape with no frame of its own is left out");return}if((t.kind==="picture"||t.kind==="movie")&&t.part){const _=o.path(t.part);if(!_){i(t,"p:pic","its file is not in the file");return}t.crop&&Object.values(t.crop).some(x=>x>0)&&i(t,"a:srcRect","a picture's crop on a master or a layout"),a.push(...t.rotation===void 0&&!w?[`${h}.shapes.${t.kind==="movie"?"add_movie":"add_picture"}(${str(_)}, ${v(t.frame)}).name = ${str(b)};`]:[`const ${u} = ${h}.shapes.${t.kind==="movie"?"add_movie":"add_picture"}(${str(_)}, ${v(t.frame)});`,`${u}.name = ${str(b)};`,...C(u,t)]);return}if(t.table||t.chart){i(t,t.table?"a:tbl":"c:chart","a table or a chart on a master or a layout: one goes on a slide");return}if(!t.path&&F(t.geometry)){const _=t.frame,[x,W]=t.flip?.h?[_.left+_.width,_.left]:[_.left,_.left+_.width],[V,q]=t.flip?.v?[_.top+_.height,_.top]:[_.top,_.top+_.height];a.push(`const ${u} = ${h}.shapes.add_connector(${$e(t.geometry??"line")}, ${emu(x)}, ${emu(V)}, ${emu(W)}, ${emu(q)});`,`${u}.name = ${str(b)};`,...D(u,t.adjustments),...C(u,t),...k(u,t,K)),t.glue&&d.push({v:u,s:t});return}const Z=t.path?ye(h,t,t.path):t.kind==="textbox"?`${h}.shapes.add_textbox(${v(t.frame)})`:`${h}.shapes.add_shape(${pe(t.geometry??"rect")}, ${v(t.frame)})`;a.push(`const ${u} = ${Z};`,`${u}.name = ${str(b)};`,...D(u,t.adjustments),...C(u,t),...t.kind==="textbox"?[...G(u,t.fill,null),...k(u,t,{line:null})]:[...G(u,t.fill,O.fill),...k(u,t,O)],...bodyLines(`${u}.text_frame`,t.text&&{...t.text,levels:Se(t)},MADE[t.kind==="textbox"?"textbox":"autoshape"]),...t.text?xe(u,`${u}.text_frame`,t.text.paragraphs,t.kind==="autoshape"?{alignment:O.alignment}:{}):[])});for(const{v:t,s:S}of d)for(const[u,w]of[["begin","a:stCxn"],["end","a:endCxn"]]){const h=S.glue?.[u];if(!h)continue;const b=p.get(h.id);b===void 0?i(S,w,"a connector's end glued to a shape that is left out: it stays where it is"):a.push(`${t}.${u}_connect(${b}, ${String(h.site)});`)}return{lines:a,names:s}}export const frameFile=e=>({x:$(e.left),y:$(e.top),w:$(e.width),h:$(e.height)});export{y as colorFile};const J=e=>({...e.minimum_scale===void 0?{}:{min:e.minimum_scale},...e.maximum_scale===void 0?{}:{max:e.maximum_scale},...e.major_unit===void 0?{}:{major:e.major_unit},...e.has_major_gridlines===void 0?{}:{gridlines:e.has_major_gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.number_format===void 0?{}:{format:e.number_format},...e.reverse_order===void 0?{}:{reverse:e.reverse_order},...e.gridline_color===void 0?{}:{gridline_color:y(e.gridline_color)},...e.line_color===void 0?{}:{line_color:y(e.line_color)}});function T(e,n){return Object.fromEntries(Object.entries(e).filter(([o,i])=>canonical(i)!==canonical(n[o])))}const Y=(e,n,o)=>{const i=n&&o(n);return i&&Object.keys(i).length>0?{[e]:i}:{}};function we(e){const n={gridline_color:{rgb:m.gridline},line_color:{rgb:m.axisLine}},o=e.font_size??m.fontSize,i=ee(e.type)&&R(e.type)!=="clustered",r=(ne(e.type)||te(e.type))&&Q(e.type),{value_axis:l,category_axis:a,labels:c,...s}=e;return{...T(s,{gap_width:m.gapWidth,hole_size:m.holeSize,vary_by_categories:H(e.type),category_colors:e.categories.map((f,g)=>I(g)),font_size:m.fontSize,title_size:Math.round(o*m.titleScale*100)/100,font_color:"dk1",...i?{overlap:100}:{}}),series:e.series.map((f,g)=>T(f,{color:I(g),line_width:r?m.lineWidth:f.line_width,marker_size:m.marker})),...Y("value_axis",l,f=>T(f,{...n,has_major_gridlines:!0,...R(e.type)==="percentStacked"?{number_format:"0%"}:{}})),...Y("category_axis",a,f=>T(f,{...n,has_major_gridlines:!1})),...c?{labels:T(c,{position:ie({type:e.type}),...H(e.type)?{color:"lt1"}:{}})}:{}}}export function chartFile(e){const n=we(e),o=n.labels;return{type:n.type,...n.categories.length===0&&n.series.some(i=>i.x)?{}:{categories:n.categories},series:n.series.map(i=>({name:i.name,values:i.values,...i.x===void 0?{}:{x:i.x},...i.color===void 0?{}:{color:y(i.color)},...i.number_format===void 0?{}:{format:i.number_format},...i.smooth===void 0?{}:{smooth:i.smooth},...i.line_width===void 0?{}:{line_width:i.line_width},...i.marker_size===void 0?{}:{marker_size:i.marker_size}})),...n.legend===void 0?{}:{legend:n.legend},...o?{labels:{...o.show_value===void 0?{}:{value:o.show_value},...o.show_percentage===void 0?{}:{percentage:o.show_percentage},...o.show_category_name===void 0?{}:{category:o.show_category_name},...o.show_series_name===void 0?{}:{series:o.show_series_name},...o.number_format===void 0?{}:{format:o.number_format},...o.position===void 0?{}:{position:o.position},...o.size===void 0?{}:{size:o.size},...o.color===void 0?{}:{color:y(o.color)}}}:{},...n.gap_width===void 0?{}:{gap_width:n.gap_width},...n.overlap===void 0?{}:{overlap:n.overlap},...n.vary_by_categories===void 0?{}:{vary_by_categories:n.vary_by_categories},...n.category_colors===void 0?{}:{category_colors:n.category_colors.map(y)},...n.hole_size===void 0?{}:{hole_size:n.hole_size},...n.value_axis?{value_axis:J(n.value_axis)}:{},...n.category_axis?{category_axis:J(n.category_axis)}:{},...n.font_size===void 0?{}:{size:n.font_size},...n.title_size===void 0?{}:{title_size:n.title_size},...n.font_color===void 0?{}:{color:y(n.font_color)}}}export const canonical=e=>JSON.stringify(e,(n,o)=>o&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).sort(([i],[r])=>i<r?-1:1)):o);
|
|
2
|
+
import{CHART_COMBINED_TYPES as oe,colorFile as m}from"@allyhub/formats";import{accentOf as X,AUTOSHAPE_STYLE as T,CHART_DEFAULTS as y,CONNECTOR_STYLE as re,groupingOf as Y,hasLines as ae,isBar as le,isConnectorGeometry as W,isLine as se,isRound as Z,isScatter as de,labelPositionOf as ce,MSO_CONNECTOR as fe,MSO_SHAPE as ue,NAME_OF_TYPE as V,DRAWN_TEXTBOX_FRAME as _e,placeholderFrame as pe,placeholderLevels as ge,TEXT_INSETS as z,TEXTBOX_FRAME as he,SHADOW_DEFAULTS as q,glued as $e,Pt as k,toPt as S}from"@allyhub/slides-core";import{nameOf as L}from"./names.js";const me={l:"PP_ALIGN.LEFT",ctr:"PP_ALIGN.CENTER",r:"PP_ALIGN.RIGHT",just:"PP_ALIGN.JUSTIFY"},ye={t:"MSO_ANCHOR.TOP",ctr:"MSO_ANCHOR.MIDDLE",b:"MSO_ANCHOR.BOTTOM"},be={none:"MSO_AUTO_SIZE.NONE",shape:"MSO_AUTO_SIZE.SHAPE_TO_FIT_TEXT",text:"MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE"},Se={title:"TITLE",ctrTitle:"CENTER_TITLE",subTitle:"SUBTITLE",body:"BODY",pic:"PICTURE",media:"MEDIA_CLIP",obj:"OBJECT",dt:"DATE",ftr:"FOOTER",sldNum:"SLIDE_NUMBER"},we=Object.fromEntries(Object.entries(ue).map(([e,n])=>[n,e])),Oe=e=>{const n=we[e];return n===void 0?str(e):`MSO_SHAPE.${n}`},xe=Object.fromEntries(Object.entries(fe).map(([e,n])=>[n,e])),Ee=e=>{const n=xe[e];return n===void 0?str(e):`MSO_CONNECTOR.${n}`},Me=(e,n)=>{const o=[...e===void 0?[]:[`name: ${str(e)}`],...n===void 0?[]:['orient: "vert"']];return o.length>0?`, { ${o.join(", ")} }`:""},K=(e,n=[])=>n.map((o,i)=>`${e}.adjustments[${String(i)}] = ${String(Math.round(o*1e5)/1e5)};`);export const emu=e=>`Emu(${String(Math.round(e))})`;const N=e=>`Pt(${String(Math.round(e/12700*100)/100)})`;export const str=e=>JSON.stringify(e);export function colorLines(e,n,o){const i=a=>`${e}.transforms = [${a.map(l=>`{ name: ${str(l.name)}, value: ${String(Math.round(l.value*1e5)/1e5)} }`).join(", ")}];`;if(typeof n=="object"&&"rgb"in n)return[`${e}.rgb = ${str(n.rgb)};`,...n.transforms?.length?[i(n.transforms)]:[]];if(typeof n=="object"&&"transforms"in n)return[`${e}.theme_color = ${str(n.theme_color)};`,...typeof o=="object"&&"brightness"in o?[`${e}.brightness = 0;`]:[],i(n.transforms)];const r=typeof n=="string"?0:n.brightness;return[`${e}.theme_color = ${str(typeof n=="string"?n:n.theme_color)};`,...r!==0||typeof o=="object"&&("brightness"in o||"transforms"in o)?[`${e}.brightness = ${String(Math.round(r*1e5)/1e5)};`]:[]]}function F(e,n,o,i){return Object.keys(i).flatMap(r=>{const a=n[r],l=i[r];return!l||canonical(a)===canonical(o[r])?[]:[`${e}.${r} = ${a==null?String(a):l(a)};`]})}const P=e=>String(e);function Q(e,n,o={}){const i=n??{},r=i.color;return[...F(e,i,o,{name:str,size:N,bold:P,italic:P,spacing:N,underline:a=>typeof a=="boolean"?P(a):str(a),strike:a=>typeof a=="boolean"?P(a):str(a),caps:str,baseline:a=>String(Math.round(a*1e3)/1e3),highlight:str}),...canonical(r)===canonical(o.color)?[]:r===void 0?[`${e}.color.theme_color = undefined;`]:colorLines(`${e}.color`,r,o.color)]}const Te=e=>"lines"in e?String(Math.round(e.lines*1e3)/1e3):N(e.fixed),ee=e=>typeof e=="number"?N(e):String(Math.round(e.lines*1e3)/1e3);function H(e,n,o,i={}){return[...F(e,n,i,{alignment:r=>me[r],line_spacing:Te,space_before:ee,space_after:ee}),...o?F(e,n,i,{bullet:str,bullet_font:str,numbered:str,start_at:String,bullet_size:r=>String(Math.round(r*1e3)/1e3),margin_left:emu,indent:emu}):[],...o&&canonical(n.bullet_color)!==canonical(i.bullet_color)?[`${e}.bullet_color = ${n.bullet_color===void 0||n.bullet_color===null?String(n.bullet_color):str(m(n.bullet_color))};`]:[],...Q(`${e}.font`,n.font,i.font)]}export function levelLines(e,n,o=[]){const i=Array.from({length:Math.max(n?.length??0,o.length)},(l,f)=>n?.[f]??{}),r=i.map((l,f)=>H("level",l,!0,o[f])),a=r[0]?.join(`
|
|
3
|
+
`)??"";return r.length===9&&a!==""&&r.every(l=>l.join(`
|
|
4
|
+
`)===a)?[`for (const level of ${e}) {`,...(r[0]??[]).map(l=>` ${l}`),"}"]:i.flatMap((l,f)=>H(`${e}[${String(f)}]`,l,!0,o[f]))}const B={margin_left:z.left,margin_top:z.top,margin_right:z.right,margin_bottom:z.bottom};export const MADE={placeholder:e=>({...pe(e),...B}),textbox:{vertical_anchor:"t",...he,...B},autoshape:{vertical_anchor:T.vertical_anchor,word_wrap:!0,auto_size:"none",...B}},FILE_TEXTBOX={...MADE.textbox,..._e};export function bodyLines(e,n,o={},i=[]){if(!n)return[];const r=_=>n[_]===void 0||n[_]===o[_]?void 0:n[_],a=r("vertical_anchor"),l=r("auto_size"),f=r("word_wrap"),s=r("orientation");return[...a===void 0?[]:[`${e}.vertical_anchor = ${ye[a]};`],...s===void 0?[]:[`${e}.orientation = ${str(s)};`],...l===void 0?[]:[`${e}.auto_size = ${be[l]};`],...f===void 0?[]:[`${e}.word_wrap = ${String(f)};`],...["margin_left","margin_top","margin_right","margin_bottom"].flatMap(_=>{const u=r(_);return u===void 0?[]:[`${e}.${_} = ${emu(u)};`]}),...levelLines(`${e}.list_style`,n.levels,i)]}export const sameColor=(e,n)=>JSON.stringify(e)===JSON.stringify(n);function U(e,n,o,i){const{fill:r,fill_transparency:a,gradient:l,pattern:f,picture_fill:s}=n,_=s&&i.path(s.part);if(s&&_){const u={...s.tile?{tile:s.tile}:{},...s.transparency===void 0?{}:{transparency:s.transparency}};return[`${e}.fill.picture(${str(_)}${Object.keys(u).length>0?`, ${JSON.stringify(u)}`:""});`]}return f?[`${e}.fill.patterned();`,`${e}.fill.pattern = ${str(f.preset)};`,...colorLines(`${e}.fill.fore_color`,f.fg),...colorLines(`${e}.fill.back_color`,f.bg)]:l?[`${e}.fill.gradient();`,...l.path===void 0?[`${e}.fill.gradient_angle = ${String(Math.round(l.angle*1e3)/1e3)};`]:[`${e}.fill.gradient_path = ${str(l.path)};`,...l.focus===void 0?[]:[`${e}.fill.gradient_focus = ${JSON.stringify(l.focus)};`]],`${e}.fill.gradient_stops = ${JSON.stringify(l.stops.map(u=>({at:Math.round(u.at*1e3)/1e3,color:m(u.color),...u.transparency===void 0?{}:{transparency:u.transparency}})))};`]:[...r===void 0||sameColor(r,o)?[]:r===null?[`${e}.fill.background();`]:[`${e}.fill.solid();`,...colorLines(`${e}.fill.fore_color`,r)],...a===void 0||r===null?[]:[`${e}.fill.transparency = ${String(a)};`]]}function C(e,n){return n===void 0?[]:n===null?[`${e}.shadow.inherit = false;`]:[`${e}.shadow.blur_radius = ${emu(n.blur)};`,`${e}.shadow.distance = ${emu(n.distance)};`,`${e}.shadow.angle = ${String(Math.round(n.angle*1e3)/1e3)};`,...n.transparency===q.transparency?[]:[`${e}.shadow.transparency = ${String(n.transparency)};`],...sameColor(n.color,q.color)?[]:colorLines(`${e}.shadow.color`,n.color)]}function I(e,n){const o=[],i=n.inner_shadow;i&&o.push(`${e}.inner_shadow.blur_radius = ${emu(i.blur)};`,`${e}.inner_shadow.distance = ${emu(i.distance)};`,`${e}.inner_shadow.angle = ${String(Math.round(i.angle*1e3)/1e3)};`,`${e}.inner_shadow.transparency = ${String(i.transparency)};`,...colorLines(`${e}.inner_shadow.color`,i.color));const r=n.glow;r&&o.push(`${e}.glow.radius = ${emu(r.size)};`,`${e}.glow.transparency = ${String(r.transparency)};`,...colorLines(`${e}.glow.color`,r.color)),n.soft_edges!==void 0&&o.push(`${e}.soft_edge.radius = ${emu(n.soft_edges)};`);const a=n.reflection;return a&&o.push(`${e}.reflection.transparency = ${String(a.transparency)};`,`${e}.reflection.size = ${String(a.size)};`,`${e}.reflection.offset = ${emu(a.distance)};`,`${e}.reflection.blur = ${emu(a.blur)};`),o}function v(e,n,o){return[...n.line===void 0||sameColor(n.line,o.line)?[]:n.line===null?[`${e}.line.fill.background();`]:colorLines(`${e}.line.color`,n.line),...n.line_width===void 0||n.line===null||n.line_width===o.line_width?[]:[`${e}.line.width = ${emu(n.line_width)};`],...n.line_dash===void 0?[]:[`${e}.line.dash_style = ${str(n.line_dash)};`],...n.line_cap===void 0?[]:[`${e}.line.cap_type = ${str(n.line_cap)};`],...n.line_join===void 0?[]:[`${e}.line.join_type = ${str(n.line_join)};`],...n.line_compound===void 0?[]:[`${e}.line.compound_type = ${str(n.line_compound)};`],...n.line_begin===void 0?[]:[`${e}.line.begin_arrow = ${str(n.line_begin)};`],...n.line_end===void 0?[]:[`${e}.line.end_arrow = ${str(n.line_end)};`],...["begin","end"].flatMap(i=>{const r=i==="begin"?n.line_begin_size:n.line_end_size;return[...r?.w===void 0?[]:[`${e}.line.${i}_arrow_width = ${str(r.w)};`],...r?.len===void 0?[]:[`${e}.line.${i}_arrow_length = ${str(r.len)};`]]})]}export const lineFile=e=>({...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_cap===void 0?{}:{line_cap:e.line_cap},...e.line_join===void 0?{}:{line_join:e.line_join},...e.line_compound===void 0?{}:{line_compound:e.line_compound},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size}});function Ae(e,n,o){const i=n.frame??{left:0,top:0,width:0,height:0},r=o.w===0?1:i.width/o.w,a=o.h===0?1:i.height/o.h,l=o.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),f=d=>Math.min(...l.map(t=>t[d]??0)),[s,..._]=o.steps,u=s?.op==="move"?`${String(s.x)}, ${String(s.y)}`:"0, 0",g=(s?.op==="move"?_:o.steps).map(d=>d.op==="close"?".add_line_segments([], true)":d.op==="move"?`.move_to(${String(d.x)}, ${String(d.y)})`:d.op==="line"?`.add_line_segments([[${String(d.x)}, ${String(d.y)}]], false)`:`.add_curve_segment(${[d.x1,d.y1,d.x2,d.y2,d.x,d.y].map(String).join(", ")})`);return`${e}.shapes.build_freeform(${u}, [${String(r)}, ${String(a)}])${g.join("")}.convert_to_shape(${emu(i.left-Math.round(f(0)*r))}, ${emu(i.top-Math.round(f(1)*a))})`}const R=(e,n)=>n.rotation===void 0?[]:[`${e}.rotation = ${String(Math.round(n.rotation*1e3)/1e3)};`];function je(e){const n=e.text?.levels??[],o=e.text_color??"dk1";return e.kind!=="autoshape"||sameColor(o,T.font_color)?n:Array.from({length:9},(i,r)=>{const a=n[r]??{};return a.font?.color!==void 0?a:{...a,font:{...a.font,color:o}}})}function ze(e,n,o,i={}){return o.flatMap((r,a)=>{const l=`${e}_p${String(a)}`,f=[...r.level>0?[`${l}.level = ${String(r.level)};`]:[],...H(l,r,!1,a===0?i:{}),...r.runs.flatMap((s,_)=>s.text==="\v"?[`${l}.add_line_break();`]:s.font?[`const ${l}r${String(_)} = ${l}.add_run();`,`${l}r${String(_)}.text = ${str(s.text)};`,...Q(`${l}r${String(_)}.font`,s.font),...s.font.link===void 0?[]:[`${l}r${String(_)}.hyperlink.address = ${str(s.font.link)};`]]:[`${l}.add_run().text = ${str(s.text)};`])];return a===0&&f.length===0?[]:[`const ${l} = ${a===0?`${n}.paragraphs[0]`:`${n}.add_paragraph()`};`,...f]})}const A=e=>`${emu(e.left)}, ${emu(e.top)}, ${emu(e.width)}, ${emu(e.height)}`;export class MediaFiles{files=new Map;byPart=new Map;bytes;taken;constructor(n,o=()=>!1){this.bytes=n,this.taken=o}path(n){const o=this.byPart.get(n);if(o)return o;const i=this.bytes(n);if(!i)return;const r=n.split("/").pop()??"file",a=r.lastIndexOf("."),[l,f]=a>0?[r.slice(0,a),r.slice(a)]:[r,""];let s=r;for(let _=2;this.files.has(s)||this.taken(s);_++)s=`${l}-${String(_)}${f}`;return this.files.set(s,i),this.byPart.set(n,`./${s}`),`./${s}`}}export const GLUE_MOVED="a glued connector is drawn with its ends on its shapes' sites, where the file has it off them";const ne=e=>({left:k(S(e.left)),top:k(S(e.top)),width:k(S(e.width)),height:k(S(e.height))});export function placedGlue(e,n=()=>{}){const o=new Map(e.flatMap(i=>i.id===void 0?[]:[[i.id,i]]));return e.map(i=>{if(!i.glue||!i.frame)return i;const r=g=>g===void 0?void 0:{shape:g.id,site:g.site},a=r(i.glue.begin),l=r(i.glue.end),f=$e({frame:ne(i.frame),flip:i.flip,rotation:i.rotation,connect:{...a?{begin:a}:{},...l?{end:l}:{}}},g=>{const d=o.get(g);return d?.frame?{frame:ne(d.frame),geometry:d.geometry,adjustments:d.adjustments,flip:d.flip,rotation:d.rotation,path:d.path}:void 0}),s=i.frame,_=f.frame;(Math.abs(s.left-_.left)>64||Math.abs(s.top-_.top)>64||Math.abs(s.width-_.width)>64||Math.abs(s.height-_.height)>64||!!i.flip?.h!=!!f.flip?.h||!!i.flip?.v!=!!f.flip?.v)&&n(i);const u={...i,frame:f.frame};return f.flip?u.flip=f.flip:delete u.flip,u})}export const CODE_UNMAPPED=!0;const te={picture:"add_picture",movie:"add_movie",audio:"add_audio"};export function shapeCode(e,n,o,i,r){const a=placedGlue(n,t=>{i(t,"p:cNvCxnSpPr",GLUE_MOVED,"approximated")}),l=[],f=new Set,s=new Map,_=new Map,u=new Set(a.flatMap(t=>[t.glue?.begin?.id,t.glue?.end?.id].filter(w=>w!==void 0))),g=new Map,d=[];a.forEach((t,w)=>{const c=`${e}_s${String(w)}`,M=t.id!==void 0&&u.has(t.id);M&&t.id!==void 0&&g.set(t.id,c);const O=p=>{const $=_.get(p);if($!==void 0)return $;const b=p.lastIndexOf("/"),D=b<0?e:O(p.slice(0,b)),x=`${e}_g${String(_.size)}`;return _.set(p,x),l.push(`const ${x} = ${D}.shapes.add_group_shape();`,`${x}.name = ${str(L(p.slice(b+1),f,"group"))};`),x},h=t.group===void 0?e:O(t.group);if(t.flip&&!W(t.geometry)&&i(t,"a:xfrm@flipH","a master's or a layout's shape mirrored: python-pptx's API has no flip"),t.locked&&i(t,"a:spLocks","a master's or a layout's shape locked"),t.link!==void 0&&i(t,"a:hlinkClick","a master's or a layout's shape's link"),t.playback&&i(t,"p:video","a master's or a layout's movie's playback"),t.alt!==void 0&&i(t,"p:cNvPr@descr","a master's or a layout's shape's alternative text"),(t.media||t.component)&&i(t,"p:sp","a master's or a layout's component or media"),t.kind==="placeholder"&&t.placeholder){const p=/^[A-Za-z0-9_-]+$/u.test(t.name)?L(t.name,f,"placeholder"):L(V[t.placeholder.type],f,"placeholder");s.set(t.placeholder.idx,p);const $=bodyLines(`${c}.text_frame`,t.text,r?MADE.placeholder(t.placeholder.type):{},ge(t.placeholder.type)),b=[...R(c,t),...U(c,t,void 0,o),...v(c,t,{line:void 0}),...C(c,t.shadow),...I(c,t)];t.geometry!==void 0&&t.geometry!=="rect"&&i(t,"a:prstGeom",`a master's or a layout's placeholder of its own shape (${t.geometry}): python-pptx's placeholders are rectangles`),l.push(`${$.length>0||b.length>0||M?`const ${c} = `:""}${h}.placeholders.add(PP_PLACEHOLDER.${Se[t.placeholder.type]}${t.frame?`, ${A(t.frame)}`:""}${Me(p===V[t.placeholder.type]?void 0:p,t.placeholder.orient)});`,...b,...$);return}const j=L(t.name,f,t.kind);if(!t.frame){i(t,"a:xfrm","a shape with no frame of its own is left out");return}if((t.kind==="picture"||t.kind==="movie"||t.kind==="audio")&&t.part){const p=o.path(t.part);if(!p){i(t,"p:pic","its file is not in the file");return}t.crop&&Object.values(t.crop).some($=>$>0)&&i(t,"a:srcRect","a picture's crop on a master or a layout"),l.push(...t.rotation===void 0&&t.shadow===void 0&&!M?[`${h}.shapes.${te[t.kind]}(${str(p)}, ${A(t.frame)}).name = ${str(j)};`]:[`const ${c} = ${h}.shapes.${te[t.kind]}(${str(p)}, ${A(t.frame)});`,`${c}.name = ${str(j)};`,...R(c,t),...C(c,t.shadow),...I(c,t)]);return}if(t.table||t.chart){i(t,t.table?"a:tbl":"c:chart","a table or a chart on a master or a layout: one goes on a slide");return}if(!t.path&&W(t.geometry)){const p=t.frame,[$,b]=t.flip?.h?[p.left+p.width,p.left]:[p.left,p.left+p.width],[D,x]=t.flip?.v?[p.top+p.height,p.top]:[p.top,p.top+p.height];l.push(`const ${c} = ${h}.shapes.add_connector(${Ee(t.geometry??"line")}, ${emu($)}, ${emu(D)}, ${emu(b)}, ${emu(x)});`,`${c}.name = ${str(j)};`,...K(c,t.adjustments),...R(c,t),...v(c,t,re),...C(c,t.shadow),...I(c,t)),t.glue&&d.push({v:c,s:t});return}const ie=t.path?Ae(h,t,t.path):t.kind==="textbox"?`${h}.shapes.add_textbox(${A(t.frame)})`:`${h}.shapes.add_shape(${Oe(t.geometry??"rect")}, ${A(t.frame)})`;l.push(`const ${c} = ${ie};`,`${c}.name = ${str(j)};`,...K(c,t.adjustments),...R(c,t),...t.kind==="textbox"?[...U(c,t,null,o),...v(c,t,{line:null})]:[...U(c,t,T.fill,o),...v(c,t,T)],...C(c,t.shadow),...I(c,t),...bodyLines(`${c}.text_frame`,t.text&&{...t.text,levels:je(t)},MADE[t.kind==="textbox"?"textbox":"autoshape"]),...t.text?ze(c,`${c}.text_frame`,t.text.paragraphs,t.kind==="autoshape"?{alignment:T.alignment}:{}):[])});for(const{v:t,s:w}of d)for(const[c,M]of[["begin","a:stCxn"],["end","a:endCxn"]]){const O=w.glue?.[c];if(!O)continue;const h=g.get(O.id);h===void 0?i(w,M,"a connector's end glued to a shape that is left out: it stays where it is"):l.push(`${t}.${c}_connect(${h}, ${String(O.site)});`)}return{lines:l,names:s}}export const frameFile=e=>({x:S(e.left),y:S(e.top),w:S(e.width),h:S(e.height)});export{m as colorFile};const G=e=>({...e.minimum_scale===void 0?{}:{min:e.minimum_scale},...e.maximum_scale===void 0?{}:{max:e.maximum_scale},...e.major_unit===void 0?{}:{major:e.major_unit},...e.has_major_gridlines===void 0?{}:{gridlines:e.has_major_gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.number_format===void 0?{}:{format:e.number_format},...e.reverse_order===void 0?{}:{reverse:e.reverse_order},...e.gridline_color===void 0?{}:{gridline_color:m(e.gridline_color)},...e.line_color===void 0?{}:{line_color:m(e.line_color)}});function E(e,n){return Object.fromEntries(Object.entries(e).filter(([o,i])=>canonical(i)!==canonical(n[o])))}const J=(e,n,o)=>{const i=n&&o(n);return i&&Object.keys(i).length>0?{[e]:i}:{}};function ke(e){const n={gridline_color:{rgb:y.gridline},line_color:{rgb:y.axisLine}},o=e.font_size??y.fontSize,i=le(e.type)&&Y(e.type)!=="clustered",r=u=>(se(u)||de(u))&&ae(u),{value_axis:a,category_axis:l,secondary_axis:f,labels:s,..._}=e;return{...E(_,{gap_width:y.gapWidth,hole_size:y.holeSize,vary_by_categories:Z(e.type),category_colors:e.categories.map((u,g)=>X(g)),font_size:y.fontSize,title_size:Math.round(o*y.titleScale*100)/100,font_color:"dk1",...i?{overlap:100}:{}}),series:e.series.map((u,g)=>E(u,{color:X(g),line_width:r(u.type??e.type)?y.lineWidth:u.line_width,marker_size:y.marker})),...J("value_axis",a,u=>E(u,{...n,has_major_gridlines:!0,...Y(e.type)==="percentStacked"?{number_format:"0%"}:{}})),...J("category_axis",l,u=>E(u,{...n,has_major_gridlines:!1})),...J("secondary_axis",f,u=>E(u,{...n,has_major_gridlines:!1})),...s?{labels:E(s,{position:ce({type:e.type}),...Z(e.type)?{color:"lt1"}:{}})}:{}}}const Le=e=>oe.includes(e);export function chartFile(e){const n=ke(e),o=n.labels;return{type:n.type,...n.categories.length===0&&n.series.some(i=>i.x)?{}:{categories:n.categories},series:n.series.map(i=>({name:i.name,values:i.values,...i.x===void 0?{}:{x:i.x},...i.color===void 0?{}:{color:m(i.color)},...i.number_format===void 0?{}:{format:i.number_format},...i.smooth===void 0?{}:{smooth:i.smooth},...i.line_width===void 0?{}:{line_width:i.line_width},...i.marker_size===void 0?{}:{marker_size:i.marker_size},...i.type===void 0||!Le(i.type)?{}:{type:i.type},...i.secondary===!0?{secondary:!0}:{}})),...n.legend===void 0?{}:{legend:n.legend},...o?{labels:{...o.show_value===void 0?{}:{value:o.show_value},...o.show_percentage===void 0?{}:{percentage:o.show_percentage},...o.show_category_name===void 0?{}:{category:o.show_category_name},...o.show_series_name===void 0?{}:{series:o.show_series_name},...o.number_format===void 0?{}:{format:o.number_format},...o.position===void 0?{}:{position:o.position},...o.size===void 0?{}:{size:o.size},...o.color===void 0?{}:{color:m(o.color)}}}:{},...n.gap_width===void 0?{}:{gap_width:n.gap_width},...n.overlap===void 0?{}:{overlap:n.overlap},...n.vary_by_categories===void 0?{}:{vary_by_categories:n.vary_by_categories},...n.category_colors===void 0?{}:{category_colors:n.category_colors.map(m)},...n.hole_size===void 0?{}:{hole_size:n.hole_size},...n.value_axis?{value_axis:G(n.value_axis)}:{},...n.category_axis?{category_axis:G(n.category_axis)}:{},...n.secondary_axis?{secondary_axis:G(n.secondary_axis)}:{},...n.font_size===void 0?{}:{size:n.font_size},...n.title_size===void 0?{}:{title_size:n.title_size},...n.font_color===void 0?{}:{color:m(n.font_color)}}}export const canonical=e=>JSON.stringify(e,(n,o)=>o&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).sort(([i],[r])=>i<r?-1:1)):o);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{stringify as
|
|
3
|
-
`)),o.set(`${O}.yaml`,ye({slides:A},{lineWidth:0})),o.set(`${O}.${d.lang}.yaml`,ye({...n.title?{title:n.title}:{},slides:M},{lineWidth:0}));for(const[i,h]of y.files)o.set(i,h);for(const[i,h]of y.byPart){const p=/\.(emf|wmf|tiff?)$/iu.exec(h)?.[1];p&&_.push({kind:"cannot-hold",part:i,what:"a:blip",detail:`a picture as ${p.toUpperCase()}, which the stage cannot draw (its export keeps it)`})}return{files:o,report:_,reasons:n.reasons}}const Je=new Set(["dt","ftr","sldNum"]);function We(n,d,O,_,y,$,u){const v=`slide ${String(d+1)}`,D=n.shapes.find(e=>e.placeholder?.type==="title"||e.placeholder?.type==="ctrTitle")?.text?.paragraphs.map(e=>e.runs.map(r=>r.text).join("")).join(" ")??"",A=n.name!==void 0&&/^[A-Za-z0-9_-]+$/u.test(n.name)&&!O.has(n.name)?oe(n.name,O,"slide"):oe(D,O,`slide-${String(d+1)}`),M=new Set(_.values()),o={},i={},h={},p=new Map,g=new Map,a=new Set,t=[],l=new Map,b=[],x=Ue(n.shapes,e=>{$.push({kind:"approximated",part:n.part,where:`${v} › "${e.name}"`,what:"p:cNvCxnSpPr",detail:Ge})});for(const e of x){const r=`${v} › "${e.name}"`,w=c=>(m,P)=>{$.push({kind:c,part:n.part,where:r,what:m,detail:P})},L=w("cannot-hold");if(e.placeholder){const c=_.get(e.placeholder.idx)??[..._.values()].find(P=>P===Ae[e.placeholder?.type??"body"]);if(!c){L("p:ph","its layout has no such placeholder; it is left out");continue}p.set(e.name,c),e.id!==void 0&&l.set(e.id,c),t.push({name:c,placeholder:!0});const m={};if(e.frame&&(m.frame=xe(e.frame)),Object.assign(m,Ee(e)),(e.kind==="picture"||e.kind==="movie")&&e.part){const P=y.path(e.part);P&&(m[e.kind==="movie"?"movie":"picture"]=P);const W=Se(e.crop);W&&(m.crop=W)}if(e.text&&e.placeholder.type!=="sldNum"){const P=ce(e.text.paragraphs,de(e.text.paragraphs),L);P!==void 0&&(i[c]=P);const W=fe(e.text.paragraphs,L,e.text.vertical_anchor);W&&(m.text=W)}e.fill&&(m.fill=T(e.fill)),e.line!==void 0&&(m.line=e.line===null?"none":T(e.line)),e.alt!==void 0&&(h[c]=e.alt),Je.has(e.placeholder.type)&&a.add(c),o[c]=m;continue}const S=oe(e.name,M,e.kind);if(p.set(e.name,S),!e.frame){L("a:xfrm","a shape with no frame is left out");continue}const R=Ye(e,S,y,w,i,u);if(R){if(e.id!==void 0&&l.set(e.id,S),e.glue&&b.push({name:S,at:r,glue:e.glue}),e.group!==void 0){const c=g.get(e.group)??oe(e.group,M,"group");g.set(e.group,c),R.group=c}e.alt!==void 0&&(h[S]=e.alt),o[S]=R,t.push({name:S,placeholder:!1})}}for(const e of b){const r={};for(const L of["begin","end"]){const S=e.glue[L];if(!S)continue;const R=l.get(S.id);R===void 0?$.push({kind:"cannot-hold",part:n.part,where:e.at,what:L==="begin"?"a:stCxn":"a:endCxn",detail:"a connector's end glued to a shape that is left out: it stays where it is"}):r[L]={shape:R,site:S.site}}const w=o[e.name];w&&Object.keys(r).length>0&&(w.connect=r)}const j=t.map(e=>e.placeholder).lastIndexOf(!0),z=t.findIndex(e=>e.placeholder),V=[..._.values()],B=t.filter(e=>e.placeholder).map(e=>V.indexOf(e.name)),G=t.some((e,r)=>!e.placeholder&&r>z&&r<j)||B.some((e,r)=>r>0&&e<(B[r-1]??-1));t.forEach((e,r)=>{const w=o[e.name]??(o[e.name]={});G?w.z=r-t.length:!e.placeholder&&z>=0&&r<z&&(w.z=-1)});const J=Object.fromEntries(Object.entries(o).filter(([e,r])=>Object.keys(r).length>0||a.has(e))),q=n.animations.flatMap(e=>{const r=p.get(e.shape);return r!==void 0?[{...e,shape:r}]:($.push({kind:"cannot-hold",part:n.part,where:v,what:"p:spTgt",detail:`an animation of ${e.shape}, which is left out`}),[])}),K=n.background?n.background.picture!==void 0?(()=>{const e=y.path(n.background.picture);return e===void 0?void 0:{picture:e}})():n.background.gradient?{gradient:ve(n.background.gradient)}:n.background.fill!==void 0?{fill:T(n.background.fill)}:void 0:void 0;return{slide:{id:A,layout:n.layout,...n.hidden?{hidden:!0}:{},...K?{background:K}:{},...Object.keys(J).length>0?{shapes:J}:{},...q.length>0?{animations:q}:{},...n.transition?{transition:n.transition}:{},...n.advance===void 0?{}:{advance_after:n.advance}},words:{id:A,...Object.keys(i).length>0?{text:i}:{},...Object.keys(h).length>0?{alt:h}:{},...n.notes===void 0?{}:{notes:n.notes}}}}function Ye(n,d,O,_,y,$){const u=_("cannot-hold"),{kind:v,frame:F,rotation:D,flip:A,locked:M,text:o,fill:i,fill_transparency:h,gradient:p,shadow:g,line:a,line_width:t,line_dash:l,line_begin:b,line_end:x,line_begin_size:j,line_end_size:z,geometry:V,path:B,table:G,chart:J,adjustments:q,part:K,crop:e,text_color:r}=n;if(!F)return;const w={frame:xe(F),...Ee({...D===void 0?{}:{rotation:D},...A?{flip:A}:{},...M?{locked:M}:{}})},L=q?{adjustments:q.map(C=>Math.round(C*1e5)/1e5)}:{},S={...p?{gradient:ve(p)}:{},...g?{shadow:le(g)}:{}};if(J)return J.title!==void 0&&(y[d]=J.title),{chart:ze(J),...w};if(G){const C=G.rows.reduce((s,k)=>s+k.height,0),Y=G.rows.filter(s=>s.height<=0).length,N=Y===0?0:Math.max(12700,(F.height-C)/Y),U=G.rows.map(s=>s.height>0?s:{...s,height:N}),X=U.reduce((s,k)=>s+k.height,0),ie=U.map(s=>({...s,height:X>0?s.height*F.height/X:s.height})),pe=G.columns.map(I),he=s=>Math.round(s.reduce((k,H)=>k+H,0)*100)/100,me=s=>{const k=s.map(H=>JSON.stringify(H??null));return k.every(H=>H===k[0])?s[0]:void 0},je={table:{columns:pe,rows:ie.map(s=>{const k=s.cells.filter(f=>!f.spanned).map(f=>f.fill),H=me(k);H===void 0&&k.some(f=>f!==void 0)&&_("approximated")("a:tcPr/a:solidFill","cells of a row filled differently take its first's");const ae=H??k.find(f=>f!=null),E=s.cells.map(f=>f.borders?.bottom?.color),Z=me(E)??E.find(f=>f!==void 0);s.cells.some(f=>f.borders?.left!==void 0||f.borders?.right!==void 0||f.borders?.top!==void 0)&&_("approximated")("a:tcPr/a:lnL","a cell's edges are its row's foot");const Q=fe(s.cells.flatMap(f=>f.text.paragraphs),u),ge=s.cells.flatMap(f=>f.text.paragraphs.flatMap(Pe=>Pe.runs)).filter(f=>f.text.trim()!==""),be=ge.length>0&&ge.every(f=>f.font?.bold===!0);return{height:I(s.height),...ae===void 0?{}:{fill:T(ae)},...Q??be?{text:{...Q,...be?{bold:!0}:{}}}:{},...Z===void 0?{}:{line:T(Z)}}})},...w,frame:{...w.frame,w:he(pe),h:he(ie.map(s=>I(s.height)))}};return ie.some(s=>s.cells.some(k=>k.spanned))&&u("a:tc@gridSpan","merged cells are apart"),y[d]=ie.map(s=>s.cells.map(k=>{const ae=s.cells.flatMap(E=>E.text.paragraphs.flatMap(Z=>Z.runs)).filter(E=>E.text.trim()!=="").every(E=>E.font?.bold===!0)?k.text.paragraphs.map(E=>({...E,runs:E.runs.map(Z=>{const Q={...Z.font};return delete Q.bold,{...Z,font:Q}})})):k.text.paragraphs;return ce(ae,de(s.cells.flatMap(E=>E.text.paragraphs)),u)??""})),je}if((v==="picture"||v==="movie")&&K){const C=O.path(K);if(!C)return;const Y=Se(e);return{[v==="movie"?"movie":"picture"]:C,...w,...Y?{crop:Y}:{},...g?{shadow:le(g)}:{}}}const R={...t===void 0||a===null?{}:{line_width:I(t)},...re({...l===void 0?{}:{line_dash:l},...b===void 0?{}:{line_begin:b},...x===void 0?{}:{line_end:x},...j===void 0?{}:{line_begin_size:j},...z===void 0?{}:{line_end_size:z}})};if(!B&&V!==void 0&&Fe(V))return{geometry:V,...L,...w,...a===void 0||se(a,_e.line)?{}:{line:a===null?"none":T(a)},...t===void 0||t===_e.line_width?{}:{line_width:I(t)},...re({...l===void 0?{}:{line_dash:l},...b===void 0?{}:{line_begin:b},...x===void 0?{}:{line_end:x},...j===void 0?{}:{line_begin_size:j},...z===void 0?{}:{line_end_size:z}}),...g?{shadow:le(g)}:{}};const c=v==="textbox",m=c?{textbox:!0,...w}:B?{path:{w:B.w,h:B.h,d:Le(B.steps)},...w}:{geometry:V??"rect",...L,...w},P=c?null:ee.fill;p?Object.assign(m,S):(i&&!se(i,P)&&(m.fill=T(i)),h!==void 0&&i&&(m.fill_transparency=h),i===null&&P!==null&&(m.fill="none"),g&&(m.shadow=le(g)));const W=c?null:ee.line;a!==void 0&&!se(a,W)&&(m.line=a===null?"none":T(a)),!c&&a!==null&&t!==void 0&&t!==ee.line_width?Object.assign(m,R):a!==null&&Object.assign(m,re({...l===void 0?{}:{line_dash:l},...b===void 0?{}:{line_begin:b},...x===void 0?{}:{line_end:x},...j===void 0?{}:{line_begin_size:j},...z===void 0?{}:{line_end_size:z}})),c&&a!==void 0&&a!==null&&t!==void 0&&(m.line_width=I(t));const te=c?De:Be.autoshape,Me=o?.vertical_anchor===void 0||o.vertical_anchor===te.vertical_anchor?void 0:o.vertical_anchor,ue=Ie("",o&&{...o,levels:[],...te.vertical_anchor===void 0?{}:{vertical_anchor:te.vertical_anchor}},te);if(ue.length>0&&u("a:bodyPr",`its text frame (${ue.map(C=>C.replace(/^\.(\w+) = .*$/u,"$1")).join(", ")}) is the basic ${c?"text box's":"shape's"}`),o){const C=ce(o.paragraphs,de(o.paragraphs),u);C!==void 0&&(y[d]=C);const Y=o.paragraphs.map(U=>({...U,alignment:U.alignment??o.levels[U.level]?.alignment??$[U.level]?.alignment??"l",runs:U.runs.map(X=>X.font?.color!==void 0||r===void 0?X:{...X,font:{...X.font,color:r}})})),N=fe(c?o.paragraphs:Y,u,Me);N&&!c&&N.color===T(ee.font_color)&&delete N.color,N&&!c&&N.align===ee.alignment&&delete N.align,N&&Object.keys(N).length>0&&(m.text=N)}return m}
|
|
2
|
+
import{stringify as Je}from"yaml";import{AUTOSHAPE_STYLE as he,CONNECTOR_STYLE as Ue,EAST_ASIAN_FONT as an,isConnectorGeometry as on,NAME_OF_TYPE as ln,OFFICE_TEXT_STYLES as we,pathText as rn,SHADOW_DEFAULTS as dn,SLIDE_SIZES as fn,styleKindOf as cn,toPt as I,tableStyleOf as un,TILE_DEFAULTS as Ee,INNER_SHADOW_DEFAULTS as Be,CHART_AXIS_WORDS as pn,chartScriptText as hn}from"@allyhub/slides-core";import{BODY_DEFAULTS as mn}from"../read/text.js";import{bodyLines as gn,chartFile as _n,colorFile as B,colorLines as Ye,emu as Ge,FILE_TEXTBOX as bn,frameFile as We,levelLines as yn,lineFile as Oe,MADE as wn,MediaFiles as On,placedGlue as kn,GLUE_MOVED as xn,sameColor as me,shapeCode as Xe,str as ge}from"./code.js";import{nameOf as ke}from"./names.js";import{lineOn as Ke,variesIn as je,wordsOf as Ae}from"./script.js";export const UNMAPPED=!0;const $n="{2D5ABB26-0587-4C30-8999-92F81FD0307C}",Ne=e=>({...e.angle===0||e.path!==void 0?{}:{angle:Math.round(e.angle*1e3)/1e3},...e.path===void 0?{}:{path:e.path},...e.focus===void 0?{}:{focus:e.focus},stops:e.stops.map(a=>({at:Math.round(a.at*1e3)/1e3,color:B(a.color),...a.transparency===void 0?{}:{transparency:a.transparency}}))}),pe=e=>({color:B(e.color),blur:I(e.blur),distance:I(e.distance),angle:Math.round(e.angle*1e3)/1e3,...e.transparency===dn.transparency?{}:{transparency:e.transparency}});function Ze(e,a,o,u){if(a){const c=o.path(a.part);if(c){const m=a.tile,r=m&&{...m.scale_x===Ee.scale_x?{}:{scale_x:m.scale_x},...m.scale_y===Ee.scale_y?{}:{scale_y:m.scale_y},...m.offset_x===0?{}:{x:I(m.offset_x)},...m.offset_y===0?{}:{y:I(m.offset_y)},...m.align===Ee.align?{}:{align:m.align}};return{picture_fill:{path:c,...r?{tile:r}:{},...a.transparency===void 0?{}:{transparency:a.transparency}}}}u("missing")("a:blipFill","its picture's file is not in the file")}if(e)return{pattern:{preset:e.preset,fg:B(e.fg),bg:B(e.bg)}}}function de(e){const a={},o=e.inner_shadow;o&&(a.inner_shadow={...me(o.color,Be.color)?{}:{color:B(o.color)},blur:I(o.blur),distance:I(o.distance),angle:Math.round(o.angle*1e3)/1e3,...o.transparency===Be.transparency?{}:{transparency:o.transparency}});const u=e.glow;u&&(a.glow={color:B(u.color),size:I(u.size),transparency:Math.round(u.transparency*1e3)/1e3}),e.soft_edges!==void 0&&(a.soft_edges=I(e.soft_edges));const c=e.reflection;return c&&(a.reflection={transparency:Math.round(c.transparency*1e3)/1e3,size:Math.round(c.size*1e3)/1e3,distance:I(c.distance),blur:I(c.blur)}),a}const Ve=e=>typeof e=="number"?I(e):{lines:Math.round(e.lines*1e5)/1e5};function qe(e){const a=Object.fromEntries(Object.entries(e??{}).filter(([,o])=>o>0));return Object.keys(a).length>0?a:void 0}const Qe=e=>({...e.locked?{locked:!0}:{},...e.link===void 0?{}:{link:e.link},...e.playback?{playback:e.playback}:{},...e.rotation===void 0?{}:{rotation:e.rotation},...e.flip?.h?{flip_h:!0}:{},...e.flip?.v?{flip_v:!0}:{}});function Fe(e,a,o,u=[],c){const m=e.flatMap(t=>t.runs.filter(b=>b.text!=="\v"&&b.text.trim()!==""));if(m.length===0)return c===void 0?void 0:{orientation:c};const r=(t,b)=>u.map(k=>k[t.level]?.[b]).find(k=>k!==void 0);for(const[t,b,k]of[["margin_left","a:pPr@marL","a paragraph's own left margin is its level's"],["indent","a:pPr@indent","a paragraph's own first-line indent is its level's"],["bullet_font","a:buFont","a bullet's own font is its level's"]])e.some(x=>x.runs.some(T=>T.text.trim()!=="")&&x[t]!==void 0&&x[t]!==r(x,t))&&a(b,k);const _=t=>{const b=m.map(t),k=b[0];return k!==void 0&&b.every(x=>x===k)?k:void 0},p=(t,b,k)=>{const x=e.map(T=>JSON.stringify(t(T)??null));if(x.every(T=>T===x[0]))return e[0]&&t(e[0]);a(b,k)},R=_(t=>t.font?.size),F=_(t=>t.font?.color===void 0?void 0:B(t.font.color)),S=_(t=>t.font?.name),Z=_(t=>Ke(t.font?.underline)===void 0?void 0:t.font?.underline),P=_(t=>Ke(t.font?.strike)===void 0?void 0:t.font?.strike),y=_(t=>t.font?.caps),s=e.every(t=>t.alignment===e[0]?.alignment)?e[0]?.alignment:void 0;s===void 0&&e.some(t=>t.alignment!==void 0)&&a("a:pPr@algn","paragraphs aligned differently take the first's");const h=e.every(t=>t.numbered===e[0]?.numbered)?e[0]?.numbered:void 0;h===void 0&&e.some(t=>t.numbered!==void 0)&&a("a:buAutoNum","paragraphs numbered and not, or numbered differently, take their levels'");const d=p(t=>t.line_spacing,"a:lnSpc","paragraphs with different line spacing take their levels'");d&&"fixed"in d&&a("a:lnSpc/a:spcPts","exact line spacing is its levels'");const L=p(t=>t.space_before,"a:spcBef","paragraphs with different space before take their levels'"),g=p(t=>t.space_after,"a:spcAft","paragraphs with different space after take their levels'"),f=h===void 0?p(t=>t.bullet,"a:buChar","paragraphs with different bullets take their levels'"):void 0;f!=null&&f.length>2&&a("a:buChar","a bullet of more than two characters is its levels'");const O=e.filter(t=>t.runs.some(b=>b.text.trim()!=="")),v=(t,b,k)=>{const x=O.map(i=>i[t]),T=x[0];if(x.every(i=>JSON.stringify(i)===JSON.stringify(T)))return T??void 0;a(b,k)},Y=v("bullet_color","a:buClr","paragraphs whose bullets differ in colour take their levels'"),V=v("bullet_size","a:buSzPct","paragraphs whose bullets differ in size take their levels'"),M=v("start_at","a:buAutoNum@startAt","lists that start at different numbers take their levels'"),G={...R===void 0?{}:{size:I(R)},...Z===void 0?{}:{underline:Z},...P===void 0?{}:{strike:P},...y===void 0?{}:{caps:y},...F===void 0?{}:{color:F},...S===void 0?{}:{font:S},...s===void 0?{}:{align:s},...d&&"lines"in d?{line_spacing:Math.round(d.lines*1e3)/1e3}:{},...L===void 0?{}:{space_before:Ve(L)},...g===void 0?{}:{space_after:Ve(g)},...o===void 0?{}:{anchor:o},...c===void 0?{}:{orientation:c},...f===void 0||f!==null&&f.length>2?{}:{bullet:f??!1},...h===void 0?{}:{numbered:h},...Y===void 0?{}:{bullet_color:B(Y)},...V===void 0?{}:{bullet_size:Math.min(4,Math.max(.25,Math.round(V*1e3)/1e3))},...M===void 0?{}:{start_at:Math.min(32767,Math.max(1,Math.round(M)))}};return Object.keys(G).length>0?G:void 0}export function flattened(e,a){return e.map(o=>{const u=a[o.level]??{},c=o.bullet!==void 0||o.numbered!==void 0,{font:m,bullet:r,numbered:_,...p}=u,R={...m,...o.font},F={...p,...c?{}:{...r===void 0?{}:{bullet:r},..._===void 0?{}:{numbered:_}},...o,runs:o.runs.map(S=>S.text==="\v"||Object.keys(R).length===0?S:{...S,font:{...R,...S.font}})};return Object.keys(R).length>0?F.font=R:delete F.font,F})}export function importDeck(e,a){const o=a.name??"deck",u=[...e.report],c=new On(e.bytes,a.taken),m=Object.entries(fn).find(([,[s,h]])=>s===e.width&&h===e.height)?.[0],r=[];Object.keys(e.theme).length>0&&r.push(`prs.theme.colors = ${JSON.stringify(e.theme)};`);const _=Object.fromEntries(Object.entries(e.fonts).filter(([s,h])=>!s.endsWith("_east_asian")||h!==an));Object.keys(_).length>0&&r.push(`prs.theme.fonts = ${JSON.stringify(_)};`);const p=new Map;e.masters.forEach((s,h)=>{const d=`master${String(h+1)}`,L=g=>(f,O,v,Y="cannot-hold")=>{u.push({kind:Y,part:"",where:f?`${g} › "${f.name}"`:g,what:O,detail:v})};r.push("",`const ${d} = prs.slide_masters.add(${ge(s.name)});`),s.color_map&&r.push(`${d}.color_map = ${JSON.stringify(s.color_map)};`),s.background&&!me(s.background,"bg1")&&r.push(`${d}.background.fill.solid();`,...Ye(`${d}.background.fill.fore_color`,s.background));for(const[g,f]of[["title","title_style"],["body","body_style"],["other","other_style"]])r.push(...yn(`${d}.text_styles.${f}`,s.text_styles[g],we[g]));r.push(...Xe(d,s.shapes,c,L(`master "${s.name}"`),!0).lines),s.layouts.forEach((g,f)=>{const O=`${d}_layout${String(f+1)}`;r.push("",`const ${O} = ${d}.slide_layouts.add(${ge(g.name)});`),g.display_master_shapes===!1&&r.push(`${O}.display_master_shapes = false;`),g.color_map&&r.push(`${O}.color_map = ${JSON.stringify(g.color_map)};`),g.background&&r.push(`${O}.background.fill.solid();`,...Ye(`${O}.background.fill.fore_color`,g.background));const v=Xe(O,g.shapes,c,L(`layout "${g.name}"`),!1);r.push(...v.lines),p.set(g.name,v.names)})});const R=new Set,F=[],S=[];e.slides.forEach((s,h)=>{const d=e.masters.find(O=>O.layouts.some(v=>v.name===s.layout)),L=d?.layouts.find(O=>O.name===s.layout),{slide:g,words:f}=vn(s,h,R,p.get(s.layout)??new Map,c,u,{...d?{master:d}:{},...L?{layout:L}:{}});F.push(g),S.push(f)});const Z=s=>{const h=F[Number(s)-1]?.id;return typeof h=="string"?h:void 0},P=s=>typeof s=="string"?s.replace(/(^|link=")#@(\d+)(?=["]|$)/gu,(h,d,L)=>{const g=Z(L);return g===void 0?h:`${d}#${g}`}):Array.isArray(s)?s.map(P):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([h,d])=>[h,P(d)])):s;F.splice(0,F.length,...F.map(P)),S.splice(0,S.length,...S.map(P));const y=new Map;y.set(`${o}.ts`,['import { Emu, MSO_ANCHOR, MSO_AUTO_SIZE, MSO_CONNECTOR, MSO_SHAPE, PP_ALIGN, PP_PLACEHOLDER, Pt, presentation } from "@allyhub/sdk/slides";',"",`// ${a.source}, imported by allyhub slides import: its masters and layouts.`,`export default presentation({ slides: ${ge(`./${o}.yaml`)}, script: ${ge(`./${o}.{locale}.yaml`)}, size: ${m?ge(m):`{ width: ${Ge(e.width)}, height: ${Ge(e.height)} }`} }, (prs) => {`,...r.map(s=>s===""?"":` ${s}`),"});",""].join(`
|
|
3
|
+
`)),y.set(`${o}.yaml`,Je({slides:F},{lineWidth:0})),y.set(`${o}.${a.lang}.yaml`,Je({...e.title?{title:e.title}:{},slides:S},{lineWidth:0}));for(const[s,h]of c.files)y.set(s,h);for(const[s,h]of c.byPart){const d=/\.(emf|wmf|tiff?)$/iu.exec(h)?.[1];d&&u.push({kind:"cannot-hold",part:s,what:"a:blip",detail:`a picture as ${d.toUpperCase()}, which the stage cannot draw (its export keeps it)`})}return{files:y,report:u,reasons:e.reasons}}const Sn=new Set(["dt","ftr","sldNum"]);function vn(e,a,o,u,c,m,r){const _=r.master?.text_styles.other??we.other,p=`slide ${String(a+1)}`,F=e.shapes.find(i=>i.placeholder?.type==="title"||i.placeholder?.type==="ctrTitle")?.text?.paragraphs.map(i=>i.runs.map(n=>n.text).join("")).join(" ")??"",S=e.name!==void 0&&/^[A-Za-z0-9_-]+$/u.test(e.name)&&!o.has(e.name)?ke(e.name,o,"slide"):ke(F,o,`slide-${String(a+1)}`),Z=new Set(u.values()),P={},y={},s={},h=new Map,d=new Map,L=i=>{const n=d.get(i);if(n!==void 0)return n;const E=i.lastIndexOf("/"),z=E<0?void 0:L(i.slice(0,E)),H=ke(i.slice(E+1),Z,"group"),j=z===void 0?H:`${z}/${H}`;return d.set(i,j),j},g=new Set,f=[],O=new Map,v=[],Y=kn(e.shapes,i=>{m.push({kind:"approximated",part:e.part,where:`${p} › "${i.name}"`,what:"p:cNvCxnSpPr",detail:xn})});for(const i of Y){let n=i;const E=`${p} › "${n.name}"`,z=C=>(ee,K)=>{m.push({kind:C,part:e.part,where:E,what:ee,detail:K})},H=z("cannot-hold"),j=n.placeholder,X=j?u.get(j.idx)??[...u.values()].find(C=>C===ln[j.type]):void 0;if(j&&X!==void 0&&P[X]!==void 0){const C=n.frame??en(j,r).shapes.find(K=>K.frame)?.frame;z("approximated")("p:ph",`its layout's placeholder "${X}" is another's on this slide, so it is a shape of its own, its text in the master's other text style`);const ee={...n,...C?{frame:C}:{}};delete ee.placeholder,n=ee}if(n.placeholder){const C=X;if(!C){H("p:ph","its layout has no such placeholder; it is left out");continue}h.set(n.name,C),n.id!==void 0&&O.set(n.id,C),f.push({name:C,placeholder:!0});const ee=jn(n,C,en(n.placeholder,r),c,z,y);n.alt!==void 0&&(s[C]=n.alt),Sn.has(n.placeholder.type)&&g.add(C),P[C]=ee;continue}const q=ke(n.name,Z,n.kind);if(h.set(n.name,q),!n.frame){H("a:xfrm","a shape with no frame is left out");continue}const le=An(n,q,c,z,y,_);le&&(n.id!==void 0&&O.set(n.id,q),n.glue&&v.push({name:q,at:E,glue:n.glue}),n.group!==void 0&&(le.group=L(n.group)),n.alt!==void 0&&(s[q]=n.alt),P[q]=le,f.push({name:q,placeholder:!1}))}for(const i of v){const n={};for(const z of["begin","end"]){const H=i.glue[z];if(!H)continue;const j=O.get(H.id);j===void 0?m.push({kind:"cannot-hold",part:e.part,where:i.at,what:z==="begin"?"a:stCxn":"a:endCxn",detail:"a connector's end glued to a shape that is left out: it stays where it is"}):n[z]={shape:j,site:H.site}}const E=P[i.name];E&&Object.keys(n).length>0&&(E.connect=n)}const V=f.map(i=>i.placeholder).lastIndexOf(!0),M=f.findIndex(i=>i.placeholder),G=[...u.values()],t=f.filter(i=>i.placeholder).map(i=>G.indexOf(i.name)),b=f.some((i,n)=>!i.placeholder&&n>M&&n<V)||t.some((i,n)=>n>0&&i<(t[n-1]??-1));f.forEach((i,n)=>{const E=P[i.name]??(P[i.name]={});b?E.z=n-f.length:!i.placeholder&&M>=0&&n<M&&(E.z=-1)});const k=Object.fromEntries(Object.entries(P).filter(([i,n])=>Object.keys(n).length>0||g.has(i))),x=e.animations.flatMap(i=>{const n=h.get(i.shape);return n!==void 0?[{...i,shape:n}]:(m.push({kind:"cannot-hold",part:e.part,where:p,what:"p:spTgt",detail:`an animation of ${i.shape}, which is left out`}),[])}),T=e.background?e.background.picture!==void 0?(()=>{const i=c.path(e.background.picture);return i===void 0?void 0:{picture:i}})():e.background.gradient?{gradient:Ne(e.background.gradient)}:e.background.fill!==void 0?{fill:B(e.background.fill)}:void 0:void 0;return{slide:{id:S,layout:e.layout,...e.hidden?{hidden:!0}:{},...T?{background:T}:{},...Object.keys(k).length>0?{shapes:k}:{},...x.length>0?{animations:x}:{},...e.transition?{transition:e.transition}:{},...e.advance===void 0?{}:{advance_after:e.advance},...e.section===void 0?{}:{section:e.section}},words:{id:S,...Object.keys(y).length>0?{text:y}:{},...Object.keys(s).length>0?{alt:s}:{},...e.notes===void 0?{}:{notes:e.notes}}}}const Mn=e=>e==="title"||e==="ctrTitle"?"title":e==="dt"||e==="ftr"||e==="sldNum"?e:"body";function en(e,a){const o=p=>(p??[]).filter(R=>R.placeholder!==void 0),u=o(a.layout?.shapes).find(p=>p.placeholder?.idx===e.idx)??o(a.layout?.shapes).find(p=>p.placeholder?.type===e.type),c=Mn(u?.placeholder?.type??e.type),m=o(a.master?.shapes).find(p=>p.placeholder?.type===c),r=cn(e.type),_=[u,m].filter(p=>p!==void 0);return{shapes:_,levels:[..._.map(p=>p.text?.levels??[]),a.master?.text_styles[r]??[],we[r]]}}export const PLACEHOLDER_UNMAPPED=!0;const En=["word_wrap","auto_size","margin_left","margin_top","margin_right","margin_bottom"];function jn(e,a,o,u,c,m){const r=c("cannot-hold"),{kind:_,placeholder:p,frame:R,rotation:F,flip:S,locked:Z,link:P,playback:y,part:s,crop:h,text:d,fill:L,fill_transparency:g,gradient:f,pattern:O,picture_fill:v,shadow:Y,inner_shadow:V,glow:M,soft_edges:G,reflection:t,line:b,line_width:k,line_dash:x,line_cap:T,line_join:i,line_compound:n,line_begin:E,line_end:z,line_begin_size:H,line_end_size:j,geometry:X,adjustments:q,group:le,path:C,table:ee,chart:K}=e,J={};if(R&&(J.frame=We(R)),Object.assign(J,Qe({...F===void 0?{}:{rotation:F},...S?{flip:S}:{},...Z?{locked:Z}:{},...P===void 0?{}:{link:P},...y?{playback:y}:{}})),(_==="picture"||_==="movie"||_==="audio")&&s){const A=u.path(s);A?J[_==="picture"?"picture":_]=A:c("missing")("p:pic","its file is not in the file");const $=qe(h);$&&(J.crop=$)}if(d&&p?.type!=="sldNum"){const A=flattened(d.paragraphs,d.levels),$=Ae(A,je(A),r);$!==void 0&&(m[a]=$);const se=o.shapes.map(oe=>oe.text?.orientation).find(oe=>oe!==void 0)??"horz",ae=Fe(A,r,d.vertical_anchor,o.levels,(d.orientation??se)===se?void 0:d.orientation);ae&&(J.text=ae)}if(d){const A=En.filter($=>{const se=d[$];if(se===void 0)return!1;const ae=o.shapes.map(oe=>oe.text?.[$]).find(oe=>oe!==void 0)??mn[$];return typeof se=="number"&&typeof ae=="number"?Math.abs(se-ae)>64:se!==ae});A.length>0&&r("a:bodyPr",`its text frame (${A.join(", ")}) is its layout's placeholder's`)}const _e=Ze(O,v,u,c);_e?Object.assign(J,_e):f?J.gradient=Ne(f):L!==void 0&&(J.fill=L===null?"none":B(L)),g!==void 0&&L&&(J.fill_transparency=g),Y&&(J.shadow=pe(Y)),Object.assign(J,de({inner_shadow:V,glow:M,soft_edges:G,reflection:t})),b!==void 0&&(J.line=b===null?"none":B(b)),b!==null&&(k!==void 0&&(J.line_width=I(k)),Object.assign(J,Oe({...x===void 0?{}:{line_dash:x},...T===void 0?{}:{line_cap:T},...i===void 0?{}:{line_join:i},...n===void 0?{}:{line_compound:n},...E===void 0?{}:{line_begin:E},...z===void 0?{}:{line_end:z},...H===void 0?{}:{line_begin_size:H},...j===void 0?{}:{line_end_size:j}})));const be=o.shapes.find(A=>A.geometry!==void 0);return X!==void 0&&(X!==(be?.geometry??"rect")||JSON.stringify(q??null)!==JSON.stringify(be?.adjustments??null))&&r("a:prstGeom",`a placeholder of its own shape (${X}) is its layout's`),le!==void 0&&c("approximated")("p:grpSp","a placeholder in a group is the slide's, not the group's"),(C||ee||K)&&r("p:ph","a placeholder of a freeform, a table or a chart"),J}function An(e,a,o,u,c,m){const r=u("cannot-hold"),{kind:_,frame:p,rotation:R,flip:F,locked:S,link:Z,playback:P,text:y,fill:s,fill_transparency:h,gradient:d,pattern:L,picture_fill:g,shadow:f,inner_shadow:O,glow:v,soft_edges:Y,reflection:V,line:M,line_width:G,line_dash:t,line_cap:b,line_join:k,line_compound:x,line_begin:T,line_end:i,line_begin_size:n,line_end_size:E,geometry:z,path:H,table:j,chart:X,adjustments:q,part:le,crop:C,text_color:ee}=e;if(!p)return;const K={frame:We(p),...Qe({...R===void 0?{}:{rotation:R},...F?{flip:F}:{},...S?{locked:S}:{},...Z===void 0?{}:{link:Z},...P?{playback:P}:{}})},J=q?{adjustments:q.map(W=>Math.round(W*1e5)/1e5)}:{},_e={...d?{gradient:Ne(d)}:{},...f?{shadow:pe(f)}:{},...de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V})};if(X){const W=hn({...X.title===void 0?{}:{title:X.title},...Object.fromEntries(pn.flatMap(ne=>{const fe=X[ne]?.title;return fe===void 0?[]:[[ne,fe]]}))});return W!==void 0&&(c[a]=W),{chart:_n(X),...K}}if(j){const W=j.rows.reduce((l,N)=>l+N.height,0),ne=j.rows.filter(l=>l.height<=0).length,fe=ne===0?0:Math.max(12700,(p.height-W)/ne),Q=j.rows.map(l=>l.height>0?l:{...l,height:fe}),re=Q.reduce((l,N)=>l+N.height,0),te=Q.map(l=>({...l,height:re>0?l.height*p.height/re:l.height})),Te=j.columns.map(I),Le=l=>Math.round(l.reduce((N,D)=>N+D,0)*100)/100,$e=l=>{const N=l.map(D=>JSON.stringify(D??null));return N.every(D=>D===N[0])?l[0]:void 0},ze=te.flatMap((l,N)=>l.cells.flatMap((D,ce)=>{const U=D.span_width??1,ie=D.span_height??1;return D.spanned||U*ie<2?[]:[{row:N,column:ce,...ie>1?{rows:ie}:{},...U>1?{columns:U}:{}}]})),Se={table:{columns:Te,rows:te.map(l=>{const N=l.cells.filter(w=>!w.spanned).map(w=>w.fill),D=$e(N);D===void 0&&N.some(w=>w!==void 0)&&u("approximated")("a:tcPr/a:solidFill","cells of a row filled differently take its first's");const ce=D??N.find(w=>w!=null),U=l.cells.map(w=>w.borders?.bottom?.color),ie=$e(U)??U.find(w=>w!==void 0);l.cells.some(w=>w.borders?.left!==void 0||w.borders?.right!==void 0||w.borders?.top!==void 0)&&u("approximated")("a:tcPr/a:lnL","a cell's edges are its row's foot");const ue=l.cells.filter(w=>!w.spanned).map(w=>w.text.vertical_anchor??"t"),Me=$e(ue);Me===void 0&&u("approximated")("a:tcPr@anchor","cells of a row whose text stands differently take its first's");const Ie=Fe(l.cells.flatMap(w=>w.text.paragraphs),r,(Me??ue[0])==="t"?void 0:Me??ue[0]),Re=l.cells.flatMap(w=>w.text.paragraphs.flatMap(sn=>sn.runs)).filter(w=>w.text.trim()!==""),He=Re.length>0&&Re.every(w=>w.font?.bold===!0);return{height:I(l.height),...ce===void 0?{}:{fill:B(ce)},...Ie??He?{text:{...Ie,...He?{bold:!0}:{}}}:{},...ie===void 0?{}:{line:B(ie)}}}),...ze.length>0?{merged:ze}:{}},...K,frame:{...K.frame,w:Le(Te),h:Le(te.map(l=>I(l.height)))}},Ce={margin_left:91440,margin_right:91440,margin_top:45720,margin_bottom:45720};te.some(l=>l.cells.some(N=>Object.keys(Ce).some(D=>N.text[D]!==void 0&&Math.abs((N.text[D]??0)-Ce[D])>64)))&&r("a:tcPr@marL","a cell's own margins: a table's cells have Office's"),te.some(l=>l.cells.some(N=>Object.values(N.borders??{}).some(D=>Math.abs(D.width-12700)>64)))&&u("approximated")("a:tcPr/a:ln@w","a cell's edge is a point wide");const De=["first_row","last_row","first_col","last_col","horz_banding","vert_banding"].filter(l=>j[l]===!0),ve=un(j.style);ve&&(ve.id!==$n||De.length>0)&&(Se.table.style=ve.name);for(const l of De)Se.table[l]=!0;return c[a]=te.map(l=>l.cells.map(N=>{const ce=l.cells.flatMap(U=>U.text.paragraphs.flatMap(ie=>ie.runs)).filter(U=>U.text.trim()!=="").every(U=>U.font?.bold===!0)?N.text.paragraphs.map(U=>({...U,runs:U.runs.map(ie=>{const ue={...ie.font};return delete ue.bold,{...ie,font:ue}})})):N.text.paragraphs;return Ae(ce,je(l.cells.flatMap(U=>U.text.paragraphs)),r)??""})),Se}if((_==="picture"||_==="movie"||_==="audio")&&le){const W=o.path(le);if(!W){u("missing")("p:pic","its file is not in the file: it is left out");return}const ne=_==="audio"?void 0:qe(C);return{[_]:W,...K,...ne?{crop:ne}:{},...f?{shadow:pe(f)}:{},...de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V}),...de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V})}}const be={...G===void 0||M===null?{}:{line_width:I(G)},...Oe({...t===void 0?{}:{line_dash:t},...b===void 0?{}:{line_cap:b},...k===void 0?{}:{line_join:k},...x===void 0?{}:{line_compound:x},...T===void 0?{}:{line_begin:T},...i===void 0?{}:{line_end:i},...n===void 0?{}:{line_begin_size:n},...E===void 0?{}:{line_end_size:E}})};if(!H&&z!==void 0&&on(z))return{geometry:z,...J,...K,...M===void 0||me(M,Ue.line)?{}:{line:M===null?"none":B(M)},...G===void 0||G===Ue.line_width?{}:{line_width:I(G)},...Oe({...t===void 0?{}:{line_dash:t},...b===void 0?{}:{line_cap:b},...k===void 0?{}:{line_join:k},...x===void 0?{}:{line_compound:x},...T===void 0?{}:{line_begin:T},...i===void 0?{}:{line_end:i},...n===void 0?{}:{line_begin_size:n},...E===void 0?{}:{line_end_size:E}}),...f?{shadow:pe(f)}:{},...de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V}),...de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V})};const A=_==="textbox",$=A?{textbox:!0,...K}:H?{path:{w:H.w,h:H.h,d:rn(H.steps)},...K}:{geometry:z??"rect",...J,...K},se=A?null:he.fill,ae=Ze(L,g,o,u);ae?Object.assign($,ae,f?{shadow:pe(f)}:{}):d?Object.assign($,_e):(s&&!me(s,se)&&($.fill=B(s)),h!==void 0&&s&&($.fill_transparency=h),s===null&&se!==null&&($.fill="none"),f&&($.shadow=pe(f))),Object.assign($,de({inner_shadow:O,glow:v,soft_edges:Y,reflection:V}));const oe=A?null:he.line;M!==void 0&&!me(M,oe)&&($.line=M===null?"none":B(M)),!A&&M!==null&&G!==void 0&&G!==he.line_width?Object.assign($,be):M!==null&&Object.assign($,Oe({...t===void 0?{}:{line_dash:t},...b===void 0?{}:{line_cap:b},...k===void 0?{}:{line_join:k},...x===void 0?{}:{line_compound:x},...T===void 0?{}:{line_begin:T},...i===void 0?{}:{line_end:i},...n===void 0?{}:{line_begin_size:n},...E===void 0?{}:{line_end_size:E}})),A&&M!==void 0&&M!==null&&G!==void 0&&($.line_width=I(G));const ye=A?bn:wn.autoshape,nn=y?.vertical_anchor===void 0||y.vertical_anchor===ye.vertical_anchor?void 0:y.vertical_anchor,tn=y?.orientation===void 0||y.orientation==="horz"?void 0:y.orientation,xe=y&&{...y,levels:[],...ye.vertical_anchor===void 0?{}:{vertical_anchor:ye.vertical_anchor}};xe&&delete xe.orientation;const Pe=gn("",xe,ye);if(Pe.length>0&&r("a:bodyPr",`its text frame (${Pe.map(W=>W.replace(/^\.(\w+) = .*$/u,"$1")).join(", ")}) is the basic ${A?"text box's":"shape's"}`),y){const W=flattened(y.paragraphs,y.levels),ne=Ae(W,je(W),r);ne!==void 0&&(c[a]=ne);const fe=W.map(re=>({...re,alignment:re.alignment??m[re.level]?.alignment??"l",runs:re.runs.map(te=>te.font?.color!==void 0||ee===void 0?te:{...te,font:{...te.font,color:ee}})})),Q=Fe(A?W:fe,r,nn,[m,we.other],tn);Q&&!A&&Q.color===B(he.font_color)&&delete Q.color,Q&&!A&&Q.align===he.alignment&&delete Q.align,Q&&Object.keys(Q).length>0&&($.text=Q)}return $}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{colorFile as
|
|
2
|
+
import{colorFile as m}from"@allyhub/formats";import{writeMarks as k}from"@allyhub/piece";import{EMU_PER_PT as p}from"@allyhub/slides-core";const d=e=>e.font?.color===void 0?void 0:m(e.font.color);export const lineOn=e=>e===!0?"true":typeof e=="string"?e:void 0;const l=e=>e.length>0&&(e[0]===void 0||e.some(s=>s!==e[0]));function x(e,s){const n=e.font,i=[],f=d(e);s.color&&f!==void 0&&i.push(`color="${f}"`),s.font&&n?.name!==void 0&&i.push(`font="${n.name}"`),s.size&&n?.size!==void 0&&i.push(`size="${String(Math.round(n.size/p*100)/100)}"`),n?.bold===!1&&i.push('bold="false"'),n?.italic===!1&&i.push('italic="false"');const t=lineOn(n?.underline);s.underline&&t!==void 0&&i.push(`underline="${t}"`),n?.link!==void 0&&i.push(`link="${n.link.replace(/"/gu,"%22")}"`),n?.highlight!==void 0&&i.push(`highlight="${n.highlight}"`),n?.baseline!==void 0&&n.baseline!==0&&i.push(`baseline="${String(Math.round(n.baseline*1e3)/1e3)}"`);const o=lineOn(n?.strike);return s.strike&&o!==void 0&&i.push(`strike="${o}"`),s.caps&&n?.caps!==void 0&&i.push(`caps="${n.caps}"`),n?.spacing!==void 0&&n.spacing!==0&&i.push(`spacing="${String(Math.round(n.spacing/p*100)/100)}"`),i.join(" ")}function c(e,s,n){const i=e.runs.flatMap(r=>r.text!=="\v"?[r]:(n("a:br","a line break inside a paragraph is a space"),[{text:" "}])),f=[];let t;const o=()=>{if(!t)return;const r=k(t.runs);f.push(t.span===""?r:`<span ${t.span}>${r}</span>`),t=void 0};for(const r of i){const u=r.text.trim()===""?t?.span??"":x(r,s);t?.span!==u&&o(),t??={span:u,runs:[]},t.runs.push({text:r.text,...r.font?.bold===!0?{strong:!0}:{},...r.font?.italic===!0?{em:!0}:{}})}return o(),f.join("")}export function wordsOf(e,s,n){const i=e.length===1&&!e.some(t=>t.runs.some(o=>o.text!==""))?[]:e;if(i.length===0)return;if(i.every(t=>t.level===0)){const t=i.map(o=>c(o,s,n));return t.length===1?t[0]:t}const f=(t,o)=>{const r=[];let u=t;for(;u<i.length;){const a=i[u];if(!a||a.level<o)break;if(a.level>o){const[h,g]=f(u,o+1);r.push(h),u=g;continue}r.push(c(a,s,n)),u++}return[r,u]};return f(0,0)[0]}export function variesIn(e){const s=e.flatMap(n=>n.runs).filter(n=>n.text.trim()!==""&&n.text!=="\v");return{color:new Set(s.map(n=>JSON.stringify(d(n)??null))).size>1,font:new Set(s.map(n=>n.font?.name??"")).size>1,size:new Set(s.map(n=>n.font?.size??0)).size>1,underline:l(s.map(n=>lineOn(n.font?.underline))),strike:l(s.map(n=>lineOn(n.font?.strike))),caps:l(s.map(n=>n.font?.caps))}}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{as as
|
|
2
|
+
import{as as Me}from"@allyhub/ooxml";import{accentOf as Ee,CHART_DEFAULTS as Te,EMU_PER_PT as je,isCombinable as Ue,isRound as We}from"@allyhub/slides-core";import{colorAt as I,say as c}from"./common.js";function Be(n,a){const r=n.find(s=>s.some(o=>o!==void 0));return r?{category_colors:Array.from({length:Math.max(a,r.length)},(s,o)=>r[o]??Ee(o))}:{}}const Ge=(n,a)=>n===void 0||n===""?a:n,l=n=>n===void 0?void 0:n.attr("val")??!0,X=n=>{n?.one("c:ptCount")?.attr("val");const a=[];for(const r of n?.all("c:pt")??[])a[r.attr("idx")??a.length]=r.one("c:v")?.text()??"";return Array.from(a,r=>r??"")};function se(n){return n?.one("c:f")?.skip("a series' formula into its workbook: the deck writes its own"),n?.one("c:strCache")}function q(n){return n?.one("c:f")?.skip("a series' formula into its workbook: the deck writes its own"),n?.one("c:numCache")}const Ke=["c:axId","c:crossAx","c:axPos","c:crosses","c:crossesAt","c:crossBetween","c:auto","c:lblAlgn","c:lblOffset","c:noMultiLvlLbl","c:majorTickMark","c:minorTickMark","c:tickLblPos","c:txPr"];function re(n){n?.one("a:bodyPr")?.skip("a chart text's body: the deck sets its own"),n?.one("a:lstStyle")?.skip("a chart text's list style");const a=n?.all("a:p")[0];return a?.one("a:endParaRPr")?.skip("the font of a paragraph's end"),a?.one("a:pPr")?.one("a:defRPr")}function De(n){const a=n?.one("c:tx")?.one("c:rich");a?.one("a:bodyPr")?.skip("a chart title's text body"),a?.one("a:lstStyle");const r=a?.all("a:p")??[];return{text:r.map(o=>o.all("a:r").map(P=>P.one("a:t")?.text()??"").join("")).join(`
|
|
3
|
+
`),size:r[0]?.all("a:r")[0]?.one("a:rPr")?.attr("sz")}}function ce(n,a,r=!0){for(const T of Ke)n.one(T)?.skip("an axis's id, place, ticks, crossing and label alignment: the deck draws its own");const s=n.one("c:scaling"),o=s?.one("c:min")?.attr("val"),P=s?.one("c:max")?.attr("val"),m=n.one("c:majorUnit")?.attr("val"),D=n.one("c:numFmt"),g=D?.attr("formatCode"),V=D?.attr("sourceLinked"),_=l(n.one("c:delete"))===!0,C=(T,N=!0)=>{const w=T?.one("a:ln"),E=w?.attr("w");return!_&&E!==void 0&&Math.abs(E-Te.gridWidth*je)>64&&c(a,"approximated","c:spPr/a:ln@w",`an axis's or its gridlines' width is the deck's own, ${String(Te.gridWidth)} pt`),w?.one("a:noFill")&&!_&&N&&c(a,"cannot-hold","c:spPr/a:ln/a:noFill","an axis or its gridlines with no line: a deck draws them"),w?.one("a:round")?.skip("a chart line's join"),I(w?.one("a:solidFill"),a,"c:spPr")?.color},F=n.one("c:majorGridlines"),$=C(F?.one("c:spPr")),p=C(n.one("c:spPr"),r),k=n.one("c:title"),{text:M}=De(k);return k?.one("c:overlay")?.attr("val"),k?.one("c:layout")?.skip("an axis title's own place"),k&&M===""&&c(a,"cannot-hold","c:title","an axis's automatic title: a deck's axis title is words of its own"),{...M===""?{}:{title:M},...o===void 0?{}:{minimum_scale:o},...P===void 0?{}:{maximum_scale:P},...m===void 0?{}:{major_unit:m},has_major_gridlines:F!==void 0,..._?{visible:!1}:{},...g===void 0||g==="General"||V===!0?{}:{number_format:g},...s?.one("c:orientation")?.attr("val")==="maxMin"?{reverse_order:!0}:{},...$===void 0?{}:{gridline_color:$},...p===void 0?{}:{line_color:p}}}export function chartOf(n,a){const r=a.read.pkg,s=r.open(n);if(!s)return"its part is not in the file";const o={...a,part:n};s.one("c:date1904")?.attr("val"),s.one("c:lang")?.skip("a chart's language"),s.one("c:style")?.skip("a chart's style number: its colours are read where it sets them"),s.one("c:roundedCorners")?.attr("val")===!0&&c(o,"cannot-hold","c:roundedCorners","a chart's rounded corners"),s.one("c:printSettings")?.skip("a chart's print settings");const P=s.one("c:externalData");if(P){const e=r.rel(n,P.attr("r:id"));e&&!e.external&&r.leave(e.target,"a chart's workbook: the deck writes one from its numbers"),P.one("c:autoUpdate")?.attr("val")}const m=s.one("c:chart"),D=l(m?.one("c:autoTitleDeleted"));m?.one("c:plotVisOnly")?.attr("val"),m?.one("c:showDLblsOverMax")?.skip("labels over a chart's maximum"),m?.one("c:dispBlanksAs")?.skip("how a chart draws a blank value");const g=m?.one("c:plotArea");g?.one("c:layout")?.skip("a chart's plot area's own layout");const V=e=>e?.kids().find(t=>t.key==="c:spPr");for(const e of[V(s),V(g)]){const t=e?.kids()??[];t.some(i=>i.key==="a:noFill")&&t.every(i=>i.key==="a:noFill"||i.key==="a:ln"&&i.kids().length===1&&i.kids()[0]?.key==="a:noFill")&&e?.consume()}const _=(g?.kids()??[]).filter(e=>e.key.endsWith("Chart")),C=e=>(s.consume(),e);if(_.length===0)return C("it has no plot");const F=e=>e.all("c:ser"),$=e=>{const t=e.key,h=F(e),i=e.one("c:grouping")?.attr("val"),y=i==="percentStacked"?"-stacked-100":i==="stacked"?"-stacked":"",u=h.map(x=>x.one("c:marker")?.one("c:symbol")?.attr("val")).some(x=>x!=="none");if(e.one("c:marker"),t==="c:barChart")return`${e.one("c:barDir")?.attr("val")==="bar"?"bar":"column"}${y===""?"-clustered":y}`;if(t==="c:lineChart")return y===""?u?"line-markers":"line":void 0;if(t==="c:areaChart")return`area${y}`;if(t==="c:pieChart")return"pie";if(t==="c:doughnutChart")return"doughnut";if(t==="c:scatterChart"){Me(e).one("c:scatterStyle")?.attr("val");const x=h.every(z=>z.one("c:spPr")?.one("a:ln")?.el.children.some(H=>H.local==="noFill")),K=h.every(z=>l(z.one("c:smooth"))===!0);return x?"scatter":K&&!u?"scatter-smooth":"scatter-lines"}};for(const e of _){e.use();for(const t of e.all("c:axId"))t.attr("val")}const p=g?.all("c:valAx")??[],k=g?.all("c:catAx")??[],M=e=>e.all("c:axId").map(t=>t.attr("val")),T=e=>e.one("c:axId")?.attr("val"),N=e=>t=>M(e).includes(T(t)??-1),w=_.length>1,E=e=>w&&p.some(t=>N(e)(t)&&t.one("c:axPos")?.attr("val")==="r"),L=_.map(e=>({plot:e,type:$(e),secondary:E(e)}));if(w&&L.some(e=>e.type===void 0||!Ue(e.type)))return C("it combines several kinds of chart, not columns, lines and areas");const ie=e=>Math.min(...F(e).map((t,h)=>t.one("c:order")?.attr("val")??h),1/0),J=L.filter(e=>!e.secondary).sort((e,t)=>ie(e.plot)-ie(t.plot))[0]??L[0];if(!J)return C("it has no plot");const f=J.plot,le=f.key,j=J.type;if(!j)return C(`a deck has no ${le.slice(2)} chart`);const de=L.flatMap(e=>F(e.plot).map(t=>({ser:t,of:e}))).map((e,t)=>({...e,order:e.ser.one("c:order")?.attr("val")??t})).sort((e,t)=>e.order-t.order),Q=de.map(e=>e.ser),ue=[];if(Q.length===0)return C("it has no series");const S=le==="c:scatterChart",[fe]=Q,he=S?void 0:fe?.one("c:cat"),Y=X(se(he?.one("c:strRef"))??q(he?.one("c:numRef"))),Ve=de.map(({ser:e,of:t})=>{const h=t.plot.key;if(e.one("c:idx")?.attr("val"),e.one("c:order")?.attr("val"),e!==fe&&!S){const b=e.one("c:cat");se(b?.one("c:strRef"))?.consume(),q(b?.one("c:numRef"))?.consume()}const i=Me(e),y=q((S?i.one("c:yVal"):e.one("c:val"))?.one("c:numRef")),u=y?.one("c:formatCode")?.text()??"",x=X(y),K=S?q(i.one("c:xVal")?.one("c:numRef")):void 0;K?.one("c:formatCode");const z=S?X(K):void 0,H=z?Math.max(z.length,x.length):Y.length,R=e.one("c:spPr"),Ae=I(R?.one("a:solidFill"),o,"c:spPr")?.color??I(R?.one("a:ln")?.one("a:solidFill"),o,"c:spPr")?.color,ze=l(e.one("c:smooth")),Ne=R?.one("a:ln")?.attr("w");R?.one("a:ln")?.one("a:noFill"),R?.one("a:ln")?.one("a:round")?.skip("a chart line's join"),We(j)&&R?.one("a:ln")?.consume();const Fe=e.one("c:marker"),Le=Fe?.one("c:size")?.attr("val");Fe?.one("c:spPr")?.consume(),l(e.one("c:invertIfNegative"))&&c(o,"cannot-hold","c:invertIfNegative","a bar of a negative value drawn in the inverse of its colour");const Re=[];for(const b of e.all("c:dPt")){const O=b.one("c:idx")?.attr("val"),v=b.one("c:spPr"),Ie=I(v?.one("a:solidFill"),o,"c:spPr")?.color;O===void 0||Ie===void 0||(Re[O]=Ie,l(b.one("c:invertIfNegative"))&&c(o,"cannot-hold","c:dPt/c:invertIfNegative","a bar of a negative value drawn in the inverse of its colour"),b.one("c:bubble3D")?.attr("val"),We(j)&&v?.one("a:ln")?.consume())}ue.push(Re);const Oe=e.one("c:tx");return{name:Ge(X(se(Oe?.one("c:strRef")))[0]??Oe?.one("c:v")?.text(),`Series ${String(Q.indexOf(e)+1)}`),values:Array.from({length:H},(b,O)=>{const v=x[O];return v===void 0||v===""?null:Number(v)}),...z?{x:Array.from({length:H},(b,O)=>{const v=z[O];return v===void 0||v===""?null:Number(v)})}:{},...u===""||u==="General"?{}:{number_format:u},...Ae===void 0?{}:{color:Ae},...ze===!0?{smooth:ze}:{},...Ne===void 0||h!=="c:lineChart"&&!S?{}:{line_width:Ne/je},...Le===void 0?{}:{marker_size:Le},...t.type!==void 0&&t.type!==j?{type:t.type}:{},...t.secondary?{secondary:!0}:{}}}),U=m?.one("c:title"),{text:Z,size:me}=De(U);U&&Z===""&&D!==!0&&c(o,"cannot-hold","c:title","a chart's automatic title (its series' name): a deck's chart title is words of its own"),l(U?.one("c:overlay"))===!0&&c(o,"cannot-hold","c:title/c:overlay","a chart's title drawn over its plot"),U?.one("c:layout")?.skip("a chart title's own place");const W=m?.one("c:legend"),B=W?.one("c:legendPos")?.attr("val");l(W?.one("c:overlay"))===!0&&c(o,"cannot-hold","c:legend/c:overlay","a chart's legend drawn over its plot"),W?.one("c:layout")?.skip("a legend's own place");const pe=re(W?.one("c:txPr"))?.attr("sz"),$e={b:"bottom",t:"top",l:"left",r:"right"}[B==="b"||B==="t"||B==="l"?B:"r"],A=f.one("c:dLbls"),d=e=>l(A?.one(e))===!0;l(A?.one("c:showLegendKey"))===!0&&c(o,"cannot-hold","c:showLegendKey","a chart's labels with their legend keys"),A?.one("c:showBubbleSize")?.attr("val"),l(A?.one("c:showLeaderLines"))===!0&&(d("c:showVal")||d("c:showPercent")||d("c:showCatName")||d("c:showSerName"))&&c(o,"cannot-hold","c:showLeaderLines","lines from a chart's labels to their points");const ve=A?.one("c:numFmt")?.attr("formatCode"),ge=A?.one("c:dLblPos")?.attr("val"),ke=re(A?.one("c:txPr")),we=ke?.attr("sz"),ye=I(ke?.one("a:solidFill"),o,"c:dLbls")?.color,ee=f.one("c:gapWidth")?.attr("val"),te=f.one("c:overlap")?.attr("val"),xe=f.one("c:holeSize")?.attr("val"),be=l(f.one("c:varyColors"));f.one("c:varyColors")?.attr("val");const ne=f.one("c:firstSliceAng")?.attr("val");ne!==void 0&&ne!==0&&c(o,"cannot-hold","c:firstSliceAng",`a round chart's first slice turned ${String(ne)}°`);const Pe=re(s.one("c:txPr")),oe=Pe?.attr("sz");pe!==void 0&&pe!==oe&&c(o,"cannot-hold","c:legend/c:txPr","a legend's own text size: a chart's text is one size");const _e=I(Pe?.one("a:solidFill"),o,"c:txPr")?.color;for(const{plot:e}of L){if(e===f)continue;const t=u=>e.one(u)?.attr("val");t("c:gapWidth")!==void 0&&t("c:gapWidth")!==ee&&c(o,"cannot-hold","c:gapWidth","a combination chart's plot's own gap width: its plots share the first's"),t("c:overlap")!==void 0&&t("c:overlap")!==te&&c(o,"cannot-hold","c:overlap","a combination chart's plot's own overlap: its plots share the first's"),e.one("c:varyColors")?.attr("val"),e.one("c:barDir")?.attr("val"),e.one("c:grouping")?.attr("val");const h=e.one("c:dLbls"),i=u=>l(h?.one(u))===!0,y=["c:showVal","c:showPercent","c:showCatName","c:showSerName"].some(u=>i(u)!==d(u));h?.consume(),y&&c(o,"cannot-hold","c:dLbls","a combination chart's plot's own data labels: its plots share the first's")}const Ce=S?p[1]:w?p.find(N(f))??p[0]:p[0],ae=S?p[0]:w?k.find(N(f))??k[0]:k[0],G=L.find(e=>e.secondary)?.plot,Se=G?p.find(e=>N(G)(e)&&e.one("c:axPos")?.attr("val")==="r"):void 0;for(const e of k)e===ae||!G||!N(G)(e)||(l(e.one("c:delete"))!==!0&&c(o,"cannot-hold","c:catAx","a second category axis that shows: a deck's second value axis crosses a hidden one"),e.consume());return{type:j,categories:Y,series:Ve,...Z===""?{}:{title:Z},...W?{legend:$e}:{},...A&&(d("c:showVal")||d("c:showPercent")||d("c:showCatName")||d("c:showSerName"))?{labels:{show_value:d("c:showVal"),show_percentage:d("c:showPercent"),show_category_name:d("c:showCatName"),show_series_name:d("c:showSerName"),...ve===void 0?{}:{number_format:ve},...ge===void 0?{}:{position:ge},...we===void 0?{}:{size:we/100},...ye===void 0?{}:{color:ye}}}:{},...ee===void 0?{}:{gap_width:Number(ee)},...te===void 0?{}:{overlap:Number(te)},...xe===void 0?{}:{hole_size:Number(xe)},...be===void 0?{}:{vary_by_categories:be},...Be(ue,Y.length),...Ce?{value_axis:ce(Ce,o,!1)}:{},...ae?{category_axis:ce(ae,o)}:{},...Se?{secondary_axis:ce(Se,o,!1)}:{},...oe===void 0?{}:{font_size:oe/100},...me===void 0?{}:{title_size:me/100},..._e===void 0?{}:{font_color:_e}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{as as f,colorIn as b}from"@allyhub/ooxml";export function say(t,e,n,a){t.read.pkg.entries.push({kind:e,part:t.part,where:t.where,what:n,...a===void 0?{}:{detail:a}})}const D=new Set(["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"]);export function modelColor(t,e,n){return t.scheme!==void 0&&D.has(t.scheme)?t.brightness===void 0?t.scheme:{theme_color:t.scheme,brightness:t.brightness}:(t.transformed&&say(e,"approximated",n,"a theme colour lightened, darkened or otherwise changed is kept as the colour it makes, no longer following the theme"),{rgb:t.rgb})}export function colorAt(t,e,n){const a=b(t,e.colors);return a?{color:modelColor(a,e,n),alpha:a.alpha}:void 0}export const transparencyOf=t=>t>=1?void 0:Math.round((1-t)*1e3)/1e3;export function gradientOf(t,e){const n=f(t),a=(n.one("a:gsLst")?.all("a:gs")??[]).flatMap(o=>{const l=colorAt(o,e,"a:gs");if(!l)return[];const r=transparencyOf(l.alpha);return[{at:Math.min(1,Math.max(0,(o.attr("pos")??0)/1e5)),color:l.color,...r===void 0?{}:{transparency:r}}]});if(a.length<2){say(e,"cannot-hold","a:gradFill","a gradient of fewer than two colours");return}const s=n.one("a:lin");return n.one("a:path")&&say(e,"approximated","a:gradFill/a:path","a radial or rectangular gradient is drawn along a line"),s?.ignore(["scaled"],"a linear gradient's scaling with its shape"),n.ignore(["rotWithShape"],"a gradient's turning with its shape"),n.one("a:tileRect"),{angle:(s?.attr("ang")??0)/6e4%360,stops:[...a].sort((o,l)=>o.at-l.at).slice(0,10)}}const O=["a:noFill","a:solidFill","a:gradFill","a:blipFill","a:pattFill","a:grpFill"];export function fillOf(t,e){const n=t&&f(t).choice(...O);return n?fillElement(n,e):void 0}export function fillElement(t,e){switch(t.use(),t.key){case"a:noFill":return{fill:null};case"a:solidFill":{const n=colorAt(t,e,"a:solidFill");if(!n)return;const a=transparencyOf(n.alpha);return{fill:n.color,...a===void 0?{}:{fill_transparency:a}}}case"a:gradFill":{const n=gradientOf(t,e);return n?{gradient:n}:void 0}case"a:pattFill":{const n=f(t);say(e,"approximated","a:pattFill",`a pattern (${n.attr("prst")??"pct5"}) is filled with its foreground colour`);const a=colorAt(n.one("a:fgClr"),e,"a:pattFill");return n.one("a:bgClr")?.consume(),a?{fill:a.color}:void 0}case"a:grpFill":return{group:!0};default:say(e,"cannot-hold",t.key,"a picture filling a shape"),t.consume();return}}const F=new Set(["solid","sysDash","sysDot","dash","dashDot","lgDash","lgDashDot","lgDashDotDot"]);export function lineOf(t,e){if(!t)return{};const n=f(t),a=fillOf(n,e);a?.gradient&&say(e,"approximated","a:ln/a:gradFill","a gradient line is drawn in its first colour"),a?.fill_transparency!==void 0&&say(e,"cannot-hold","a:ln/a:alpha","a line's transparency");const s=a?.fill!==void 0?a.fill:a?.gradient?a.gradient.stops[0]?.color:void 0,o=n.attr("w"),l=n.one("a:prstDash")?.attr("val"),r=l==="solid"?void 0:l;r!==void 0&&!F.has(r)&&say(e,"approximated","a:prstDash",`${r} is drawn as dashes`);const u=p=>{const c=p?.attr("type");return c===void 0||c==="none"?void 0:c},i=p=>{const c=p?.attr("w"),x=p?.attr("len"),_={...c===void 0||c==="med"?{}:{w:c},...x===void 0||x==="med"?{}:{len:x}};return Object.keys(_).length===0?void 0:_},d=n.one("a:headEnd"),m=n.one("a:tailEnd"),g=u(d),h=u(m),S=i(d),k=i(m),w=g===void 0?void 0:S,y=h===void 0?void 0:k;for(const p of["a:round","a:bevel","a:miter"])n.one(p)?.skip("a line's join (round, bevel, miter): the stage joins its own way");return{...s===void 0?{}:{line:s},...o===void 0?{}:{line_width:o},...r===void 0?{}:{line_dash:F.has(r)?r:"dash"},...g===void 0?{}:{line_begin:g},...h===void 0?{}:{line_end:h},...w===void 0?{}:{line_begin_size:w},...y===void 0?{}:{line_end_size:y}}}export function shadowOf(t,e){const n=t&&f(t).one("a:outerShdw");if(!n)return;const a=colorAt(n,e,"a:outerShdw");return n.ignore(["algn","rotWithShape"],"a shadow's alignment and turning with its shape"),((n.attr("sx")??1e5)!==1e5||(n.attr("sy")??1e5)!==1e5)&&say(e,"cannot-hold","a:outerShdw@sx","a shadow's scale"),n.attr("kx"),n.attr("ky"),{color:a?.color??"dk1",blur:n.attr("blurRad")??0,distance:n.attr("dist")??0,angle:(n.attr("dir")??0)/6e4%360,transparency:a?transparencyOf(a.alpha)??0:0}}export function styleOf(t,e){const n=t&&f(t);if(!n)return{};const a=i=>{if(!i)return;const d=b(i,e.colors);return{idx:i.attr("idx")??0,ctx:{...e,colors:{...e.colors,...d?{placeholder:d}:{}}}}},s={},o=a(n.one("a:fillRef"));if(o){const i=o.idx>=1001?e.read.matrix.background[o.idx-1001]:o.idx>0?e.read.matrix.fill[o.idx-1]:void 0,d=i?fillElement(i,o.ctx):{fill:null};Object.assign(s,d??{})}const l=a(n.one("a:lnRef"));if(l){const i=l.idx>0?e.read.matrix.line[l.idx-1]:void 0;Object.assign(s,i?lineOf(i,l.ctx):{line:null})}const r=a(n.one("a:effectRef"));if(r&&r.idx>0){const i=e.read.matrix.effect[r.idx-1],d=shadowOf(i&&f(i).one("a:effectLst"),r.ctx);d&&(s.shadow=d)}const u=n.one("a:fontRef");if(u){const i=colorAt(u,e,"a:fontRef");i&&(s.text_color=i.color);const d=u.attr("idx");d==="major"?s.font="+mj-lt":d==="minor"&&(s.font="+mn-lt")}return s}export const sameColor=(t,e)=>JSON.stringify(t)===JSON.stringify(e);
|
|
2
|
+
import{as as p,colorIn as L}from"@allyhub/ooxml";import{COLOR_NAMES as M,COLOR_TRANSFORMS as N,THEME_COLORS as v,LINE_DASHES as T,PATTERNS as j,TILE_ALIGNMENTS as C}from"@allyhub/formats";export const SLIDE_PLACE=/^#@(\d+)$/u;export function linkOf(t,i,e){const n=t.attr("action")??"",a=t.attr("r:id")??"",r=a===""?void 0:i.read.pkg.rel(i.part,a);if(t.ignore(["tooltip","history","highlightClick","endSnd","tgtFrame","invalidUrl"],"a link's tooltip and browser settings"),t.one("a:snd")?.skip("a sound a link plays"),t.one("a:extLst")?.skip("a link's extensions"),n===""&&r?.external)return r.target;if(n==="ppaction://hlinksldjump"&&r&&!r.external){const s=i.read.slides?.get(r.target);if(s!==void 0)return`#@${String(s)}`;say(i,"missing",e,"a link to a slide that is not in the file");return}if(/^ppaction:\/\/hlinkshowjump\?jump=(firstslide|lastslide|nextslide|previousslide|endshow)$/u.test(n))return n;n!==""?say(i,"cannot-hold",`${e}@action`,n):a!==""&&say(i,"missing",e,"a link whose target is not in the file")}export function say(t,i,e,n){t.read.pkg.entries.push({kind:i,part:t.part,where:t.where,what:e,...n===void 0?{}:{detail:n}})}const D=new Set(v),z=new Set(M),$=new Set(N),I=new Set(["hue","hueOff"]);function H(t){const i=[];for(const e of t)if(!e.name.startsWith("alpha")){if(!$.has(e.name)||e.val===void 0)return;i.push({name:e.name,value:e.val/(I.has(e.name)?6e4:1e5)})}return i}export function modelColor(t,i,e){const n=H(t.steps??[]);if(t.name!==void 0&&z.has(t.name)&&n){const a=i.colors.map[t.name]??t.name,r=i.named===!0?t.name:a;return n.length===0?r:t.brightness!==void 0?{theme_color:r,brightness:t.brightness}:{theme_color:r,transforms:n}}return t.name===void 0&&t.base!==void 0&&n?n.length===0?{rgb:t.base}:{rgb:t.base,transforms:n}:t.scheme!==void 0&&D.has(t.scheme)?t.brightness===void 0?t.scheme:{theme_color:t.scheme,brightness:t.brightness}:(t.transformed&&say(i,"approximated",e,"a colour inverted, greyed or changed by gamma or a channel is kept as the colour it makes, no longer following the theme"),{rgb:t.rgb})}export function withAlpha(t,i){if(i>=1)return t;const e={name:"alpha",value:Math.round(i*1e5)/1e5};if(typeof t=="string")return{theme_color:t,transforms:[e]};if("rgb"in t)return{rgb:t.rgb,transforms:[...t.transforms??[],e]};if("transforms"in t)return{theme_color:t.theme_color,transforms:[...t.transforms,e]};const n=t.brightness>0?[{name:"lumMod",value:1-t.brightness},{name:"lumOff",value:t.brightness}]:[{name:"lumMod",value:1+t.brightness}];return{theme_color:t.theme_color,transforms:[...n,e]}}export function colorAt(t,i,e){const n=L(t,i.colors);return n?{color:modelColor(n,i,e),alpha:n.alpha}:void 0}export const transparencyOf=t=>t>=1?void 0:Math.round((1-t)*1e3)/1e3;const P=new Set(j),W=new Set(C);function G(t,i){const e=p(t);e.ignore(["dpi","rotWithShape"],"a picture's resolution and turning with its fill");const n=e.one("a:blip");n?.ignore(["cstate"],"a picture's compression state");const a=i.read.pkg.rel(i.part,n?.attr("r:embed"));n?.attr("r:link")&&say(i,"missing","a:blip@r:link","a picture linked from outside the file");let r;for(const l of n?.kids()??[]){if(l.key==="a:extLst"){l.skip("a picture's extensions (its SVG, its own resolution)");continue}if(l.key==="a:alphaModFix"){l.use();const u=p(l).attr("amt")??1e5;r=transparencyOf(u/1e5);continue}l.use(),say(i,"cannot-hold",l.key,"a picture fill's own effect (recolouring, brightness)"),l.consume()}const s=e.one("a:srcRect");s&&["l","t","r","b"].some(l=>(s.attr(l)??0)!==0)&&say(i,"cannot-hold","a:srcRect","a picture fill's crop");const d=e.one("a:stretch")?.one("a:fillRect");d&&["l","t","r","b"].some(l=>(d.attr(l)??0)!==0)&&say(i,"approximated","a:fillRect","a stretched picture's insets: it fills the whole shape");const o=e.one("a:tile");if(o&&(o.attr("flip")??"none")!=="none"&&say(i,"approximated","a:tile@flip","a tiled picture's mirroring"),!a||a.external){say(i,"missing","a:blipFill","a picture filling a shape whose file is not in the file");return}i.read.pkg.bytes(a.target);const f=o?.attr("algn");return{part:a.target,...o?{tile:{scale_x:(o.attr("sx")??1e5)/1e5,scale_y:(o.attr("sy")??1e5)/1e5,offset_x:o.attr("tx")??0,offset_y:o.attr("ty")??0,align:f!==void 0&&W.has(f)?f:"tl"}}:{},...r===void 0?{}:{transparency:r}}}export function gradientOf(t,i){const e=p(t),n=(e.one("a:gsLst")?.all("a:gs")??[]).flatMap(l=>{const u=colorAt(l,i,"a:gs");if(!u)return[];const g=transparencyOf(u.alpha);return[{at:Math.min(1,Math.max(0,(l.attr("pos")??0)/1e5)),color:u.color,...g===void 0?{}:{transparency:g}}]});if(n.length<2){say(i,"cannot-hold","a:gradFill","a gradient of fewer than two colours");return}const a=e.one("a:lin"),r=e.one("a:path"),s=r?.attr("path"),c=r?.one("a:fillToRect"),d=l=>Math.round((c?.attr(l)??0)/1e5*1e5)/1e5,o=c?{left:d("l"),top:d("t"),right:d("r"),bottom:d("b")}:void 0;a?.ignore(["scaled"],"a linear gradient's scaling with its shape"),e.ignore(["rotWithShape"],"a gradient's turning with its shape");const f=e.one("a:tileRect");return f&&["l","t","r","b"].some(l=>f.attr(l))&&say(i,"cannot-hold","a:tileRect","a gradient tiled in a rectangle of its own"),n.length>10&&say(i,"approximated","a:gsLst",`a gradient of ${String(n.length)} colours keeps its first ten`),{angle:(a?.attr("ang")??0)/6e4%360,...s===void 0?{}:{path:s},...s===void 0||!o||o.left===.5&&o.top===.5&&o.right===.5&&o.bottom===.5?{}:{focus:o},stops:[...n].sort((l,u)=>l.at-u.at).slice(0,10)}}const J=["a:noFill","a:solidFill","a:gradFill","a:blipFill","a:pattFill","a:grpFill"];export function fillOf(t,i,e=!1){const n=t&&p(t).choice(...J);return n?fillElement(n,i,e):void 0}export function fillElement(t,i,e=!1){if(t.use(),!e&&t.key==="a:pattFill"){const n=p(t);say(i,"approximated","a:pattFill",`a pattern (${n.attr("prst")??"pct5"}) is filled with its foreground colour`);const a=colorAt(n.one("a:fgClr"),i,"a:pattFill");return n.one("a:bgClr")?.consume(),a?{fill:a.color}:void 0}if(!e&&t.key==="a:blipFill"){say(i,"cannot-hold",t.key,"a picture filling it"),t.consume();return}switch(t.key){case"a:noFill":return{fill:null};case"a:solidFill":{const n=colorAt(t,i,"a:solidFill");if(!n)return;const a=transparencyOf(n.alpha);return{fill:n.color,...a===void 0?{}:{fill_transparency:a}}}case"a:gradFill":{const n=gradientOf(t,i);return n?{gradient:n}:void 0}case"a:pattFill":{const n=p(t),a=n.attr("prst")??"pct5",r=(s,c)=>{const d=colorAt(n.one(s),i,"a:pattFill");return d?withAlpha(d.color,d.alpha):c};return{pattern:{preset:P.has(a)?a:"pct5",fg:r("a:fgClr","dk1"),bg:r("a:bgClr","lt1")}}}case"a:grpFill":return{group:!0};default:{const n=G(t,i);return n?{picture_fill:n}:void 0}}}const A=new Set(T);export function lineOf(t,i){if(!t)return{};const e=p(t),n=fillOf(e,i);n?.gradient&&say(i,"approximated","a:ln/a:gradFill","a gradient line is drawn in its first colour");const a=n?.fill!==void 0?n.fill===null||n.fill_transparency===void 0?n.fill:withAlpha(n.fill,1-n.fill_transparency):n?.gradient?n.gradient.stops[0]?.color:void 0,r=e.attr("w"),s=e.one("a:prstDash")?.attr("val"),c=s==="solid"?void 0:s;c!==void 0&&!A.has(c)&&say(i,"approximated","a:prstDash",`${c} is drawn as dashes`);const d=w=>{const m=w?.attr("type");return m===void 0||m==="none"?void 0:m},o=w=>{const m=w?.attr("w"),E=w?.attr("len"),R={...m===void 0||m==="med"?{}:{w:m},...E===void 0||E==="med"?{}:{len:E}};return Object.keys(R).length===0?void 0:R},f=e.one("a:headEnd"),l=e.one("a:tailEnd"),u=d(f),g=d(l),_=o(f),h=o(l),F=u===void 0?void 0:_,O=g===void 0?void 0:h,x=e.choice("a:round","a:bevel","a:miter");x?.use(),x?.key==="a:miter"&&p(x).attr("lim");const b=x?.key.slice(2),y=e.attr("cap"),S=e.attr("cmpd"),k=e.one("a:custDash");return k&&(say(i,"approximated","a:custDash","a line's own dashes are drawn as dashes"),k.consume()),{...a===void 0?{}:{line:a},...r===void 0?{}:{line_width:r},...c===void 0?k?{line_dash:"dash"}:{}:{line_dash:A.has(c)?c:"dash"},...y===void 0||y==="flat"?{}:{line_cap:y},...b===void 0||b==="miter"?{}:{line_join:b},...S===void 0||S==="sng"?{}:{line_compound:S},...u===void 0?{}:{line_begin:u},...g===void 0?{}:{line_end:g},...F===void 0?{}:{line_begin_size:F},...O===void 0?{}:{line_end_size:O}}}export function shadowOf(t,i){const e=t&&p(t).one("a:outerShdw");if(!e)return;const n=colorAt(e,i,"a:outerShdw");return e.ignore(["algn","rotWithShape"],"a shadow's alignment and turning with its shape"),((e.attr("sx")??1e5)!==1e5||(e.attr("sy")??1e5)!==1e5)&&say(i,"cannot-hold","a:outerShdw@sx","a shadow's scale"),((e.attr("kx")??0)!==0||(e.attr("ky")??0)!==0)&&say(i,"cannot-hold","a:outerShdw@kx","a shadow's skew"),{color:n?.color??"dk1",blur:e.attr("blurRad")??0,distance:e.attr("dist")??0,angle:(e.attr("dir")??0)/6e4%360,transparency:n?transparencyOf(n.alpha)??0:0}}export function effectsOf(t,i){const e=t&&p(t);if(!e)return{};const n={},a=e.one("a:innerShdw");if(a){const d=colorAt(a,i,"a:innerShdw");n.inner_shadow={color:d?.color??"dk1",blur:a.attr("blurRad")??0,distance:a.attr("dist")??0,angle:(a.attr("dir")??0)/6e4%360,transparency:d?transparencyOf(d.alpha)??0:0}}const r=e.one("a:glow");if(r){const d=colorAt(r,i,"a:glow");n.glow={color:d?.color??"accent1",size:r.attr("rad")??0,transparency:d?transparencyOf(d.alpha)??0:0}}const s=e.one("a:reflection");s&&(s.ignore(["algn","rotWithShape","stPos","fadeDir"],"a reflection's alignment, turning and where its fade starts"),(s.attr("endA")??0)>1e3&&say(i,"approximated","a:reflection@endA","a reflection fades to nothing"),((s.attr("dir")??54e5)!==54e5||(s.attr("sy")??1e5)!==-1e5||(s.attr("sx")??1e5)!==1e5||(s.attr("kx")??0)!==0||(s.attr("ky")??0)!==0)&&say(i,"approximated","a:reflection@dir","a reflection is mirrored under its shape"),n.reflection={transparency:1-(s.attr("stA")??1e5)/1e5,size:(s.attr("endPos")??1e5)/1e5,distance:s.attr("dist")??0,blur:s.attr("blurRad")??0});const c=e.one("a:softEdge");return c&&(n.soft_edges=c.attr("rad")??0),n}export function sayEffects(t,i){for(const e of t.effects??[])say(i,"cannot-hold",`p:style/a:effectRef/${e}`,`an effect of the theme's effect style (${e.slice(2)})`)}export function styleOf(t,i){const e=t&&p(t);if(!e)return{};const n=o=>{if(!o)return;const f=L(o,i.colors);return{idx:o.attr("idx")??0,ctx:{...i,colors:{...i.colors,...f?{placeholder:f}:{}}}}},a={},r=n(e.one("a:fillRef"));if(r){const o=r.idx>=1001?i.read.matrix.background[r.idx-1001]:r.idx>0?i.read.matrix.fill[r.idx-1]:void 0,f=o?fillElement(o,r.ctx,!0):{fill:null};Object.assign(a,f??{})}const s=n(e.one("a:lnRef"));if(s){const o=s.idx>0?i.read.matrix.line[s.idx-1]:void 0;Object.assign(a,o?lineOf(o,s.ctx):{line:null})}const c=n(e.one("a:effectRef"));if(c&&c.idx>0){const o=i.read.matrix.effect[c.idx-1],f=o&&p(o),l=f?.one("a:effectLst"),u=shadowOf(l,c.ctx);u&&(a.shadow=u),Object.assign(a,effectsOf(l,c.ctx));const g=new Set(["a:outerShdw","a:innerShdw","a:glow","a:reflection","a:softEdge"]),_=[...(l?.kids()??[]).filter(h=>!g.has(h.key)),...(f?.kids()??[]).filter(h=>h.key!=="a:effectLst"&&h.key!=="a:extLst")].map(h=>h.key);_.length>0&&(a.effects=_)}const d=e.one("a:fontRef");if(d){const o=colorAt(d,i,"a:fontRef");o&&(a.text_color=o.color);const f=d.attr("idx");f==="major"?a.font="+mj-lt":f==="minor"&&(a.font="+mn-lt")}return a}export const sameColor=(t,i)=>JSON.stringify(t)===JSON.stringify(i);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{unzipSync as xe}from"fflate";import{withinZip as Le}from"@allyhub/formats";import{DEFAULT_COLOR_MAP as N,Package as Pe,SCHEME_COLORS as Oe,colorIn as me}from"@allyhub/ooxml";import{OFFICE_TEXT_STYLES as ve}from"@allyhub/slides-core";import{colorAt as Me,fillElement as Te,fillOf as Ie,say as f}from"./common.js";import{shapesOf as ee}from"./shapes.js";import{levelsOf as X,paragraphsOf as Fe}from"./text.js";import{animationsOf as Ee,transitionOf as _e}from"./timing.js";const ue={presProps:"presentation properties (how a show runs, recent colours)",viewProps:"PowerPoint's view of the file (zoom, guides, the last slide shown)","extended-properties":"the application's statistics of the file",thumbnail:"a preview picture of the first slide",printerSettings:"printer settings",notesMaster:"the notes pages' master: a deck's notes are text",handoutMaster:"the handouts' master"};function he(s){if(!s)return N;const o={...N};for(const e of["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"]){const r=s.attr(e);r!==void 0&&(o[e]=r)}return s.one("a:extLst"),o}function ge(s,o){o?.one("a:masterClrMapping");const e=o?.one("a:overrideClrMapping");return e?he(e):s}function te(s,o){const e=s?.one("p:bg");if(!e)return;e.ignore(["bwMode"],"a background's black and white printing mode");const r=e.one("p:bgPr");if(r){r.ignore(["shadeToTitle"],"a background shaded to its title, a legacy option"),r.one("a:effectLst");const w=r.one("a:blipFill");if(w){w.ignore(["dpi","rotWithShape"],"a picture's resolution and turning with its fill");const b=o.read.pkg.rel(o.part,w.one("a:blip")?.ignore(["cstate"],"a picture's compression state").attr("r:embed"));if(w.one("a:srcRect"),w.one("a:stretch")?.consume(),w.one("a:tile")&&f(o,"approximated","a:tile","a tiled background picture is stretched"),b&&!b.external)return o.read.pkg.bytes(b.target),{picture:b.target};f(o,"missing","a:blip","a background picture whose file is not in the file");return}const v=Ie(r,o);return v?.fill===null?{fill:"lt1"}:v?.fill!==void 0?{fill:v.fill}:v?.gradient?{gradient:v.gradient}:void 0}const a=e.one("p:bgRef");if(!a)return;const c=a.attr("idx")??0,m=me(a,o.colors),u=c>=1001?o.read.matrix.background[c-1001]:c>0?o.read.matrix.fill[c-1]:void 0;if(!u)return m?{fill:Me(a,o,"p:bgRef")?.color??"lt1"}:void 0;const h=Te(u,{...o,colors:{...o.colors,...m?{placeholder:m}:{}}});if(h?.fill!==void 0&&h.fill!==null)return{fill:h.fill};if(h?.gradient)return{gradient:h.gradient}}function ye(s,o){if(s){if(s.fill!==void 0)return s.fill;if(s.gradient)return f(o,"approximated","p:bg/a:gradFill","a master's or a layout's gradient background is its first colour"),s.gradient.stops[0]?.color;f(o,"cannot-hold","p:bg/a:blipFill","a master's or a layout's picture background")}}function ke(s,o){for(const e of["p:transition","p:timing"]){const r=s.one(e);r&&(f(o,"cannot-hold",e,`a ${e==="p:transition"?"transition":"animation"} on a master or a layout`),r.consume())}s.one("p:hf")?.skip("which of date, footer and slide number new slides get: a deck's slide shows them where it says so")}function ne(s){for(const o of s?.all("p:ext")??[])for(const e of["p14:creationId","p14:modId"])o.one(e)?.skip("PowerPoint's ids of a part across versions")}export function readPptx(s,o){const e=new Pe(xe(s,{filter:Le(o)})),r=e.relOfType("","officeDocument")?.target??"ppt/presentation.xml";for(const t of e.rels("")){const n=ue[t.type.split("/").pop()??""];n!==void 0&&!t.external&&e.leave(t.target,n)}e.ignoreExtensions(["p14:creationId","p14:modId","a16:creationId","a16:colId","a16:rowId","a14:useLocalDpi","p15:sldGuideLst","p14:discardImageEditData","p14:defaultImageDpi","p15:chartTrackingRefBased"],"PowerPoint's ids and settings across versions");const a=e.open(r);if(!a)throw new Error(`it has no presentation (${r})`);for(const t of e.rels(r)){const n=ue[t.type.split("/").pop()??""];n!==void 0&&!t.external&&e.leave(t.target,n)}const c={read:{pkg:e,matrix:{fill:[],line:[],effect:[],background:[]},faces:new Set},part:r,colors:{scheme:{},map:N},where:"presentation"};a.ignore(["saveSubsetFonts","autoCompressPictures","strictFirstAndLastChars","embedTrueTypeFonts","removePersonalInfoOnSave","bookmarkIdSeed","serverZoom","compatMode","conformance","showSpecialPlsOnTitleSld"],"how PowerPoint saves and shows the file");const m=a.attrOr("firstSlideNum");m!==1&&f(c,"cannot-hold","p:presentation@firstSlideNum",`slides numbered from ${String(m)}`),a.attrOr("rtl")&&f(c,"cannot-hold","p:presentation@rtl","a right-to-left presentation");const u=a.one("p:sldSz");u?.ignore(["type"],"a slide size's name: its width and height are read"),a.one("p:notesSz")?.skip("the notes pages' size"),a.one("p:notesMasterIdLst")?.consume(),a.one("p:handoutMasterIdLst")?.consume();for(const t of["p:embeddedFontLst","p:custShowLst","p:photoAlbum","p:custDataLst","p:kinsoku","p:modifyVerifier"]){const n=a.one(t);n&&(f(c,"cannot-hold",t,t==="p:embeddedFontLst"?"fonts carried in the file":t==="p:custShowLst"?"custom shows":t.slice(2)),n.consume())}for(const t of a.one("p:extLst")?.all("p:ext")??[])for(const n of t.kids())n.key==="p15:sldGuideLst"&&n.skip("PowerPoint's guides");for(const t of e.rels(r))(t.type.endsWith("/fonts")||t.type.endsWith("/font"))&&e.leave(t.target,"a font carried in the file (said above)");const h=u?.attr("cx")??12192e3,w=u?.attr("cy")??6858e3,b=(a.one("p:sldMasterIdLst")?.all("p:sldMasterId")??[]).flatMap(t=>{t.attr("id");const n=e.rel(r,t.attr("r:id"));return n?[n.target]:[]}),_=b[0]?e.relOfType(b[0],"theme")?.target:void 0,M=_?e.open(_):void 0;M?.attr("name");const R=M?.one("a:themeElements"),oe=R?.one("a:clrScheme");oe?.attr("name");const se={},W={};for(const t of Oe){const n=me(oe?.one(`a:${t}`),{scheme:{},map:N});n&&(se[t]=n.rgb,W[t]=n.rgb)}const Z=R?.one("a:fontScheme");Z?.attr("name");const $={},H=(t,n)=>{const i=Z?.one(t)?.one(n);i?.ignore(["panose","pitchFamily","charset"],"a font's panose, pitch and character set: its name picks it");const g=i?.attr("typeface");return g===""?void 0:g},U=H("a:majorFont","a:latin"),V=H("a:minorFont","a:latin"),Y=H("a:majorFont","a:ea"),q=H("a:minorFont","a:ea");U&&($.major=U),V&&($.minor=V),Y&&($.major_east_asian=Y),q&&($.minor_east_asian=q);const K={...c,part:_??"",where:"theme"};for(const t of["a:majorFont","a:minorFont"]){const n=Z?.one(t),l=n?.one("a:cs");l?.ignore(["panose","pitchFamily","charset"],"a font's panose, pitch and character set: its name picks it"),l?.attr("typeface")&&f(K,"cannot-hold",`${t}/a:cs`,"the theme's complex script face (Arabic, Hebrew, Thai…)");const i=n?.all("a:font")??[],g=n?.one("a:ea")?.el.attrs.find(p=>p.key==="typeface")?.value;i.some(p=>(p.attr("typeface")??"")!==""&&p.attr("typeface")!==g)&&f(K,"cannot-hold",`${t}/a:font`,"the theme's faces for each script (one East Asian face is the deck's)");for(const p of i)p.consume()}const j=R?.one("a:fmtScheme"),we={fill:j?.one("a:fillStyleLst")?.kids()??[],line:j?.one("a:lnStyleLst")?.kids()??[],effect:j?.one("a:effectStyleLst")?.kids()??[],background:j?.one("a:bgFillStyleLst")?.kids()??[]};j?.skip("the theme's style matrix: read where a shape's style names an entry of it"),R?.one("a:extLst")?.skip("the theme's extensions"),M?.one("a:objectDefaults")?.skip("the defaults PowerPoint gives a shape a person adds"),M?.one("a:extraClrSchemeLst")?.skip("other colour schemes PowerPoint offers"),M?.one("a:extLst")?.skip("the theme's family, PowerPoint's bookkeeping");const re=M?.one("a:custClrLst");re&&(f(K,"cannot-hold","a:custClrLst","the theme's custom colours"),re.consume());const C={pkg:e,matrix:we,faces:new Set([U,V,Y,q].filter(t=>t!==void 0))};c.read=C;const ae=e.relOfType(r,"tableStyles");ae&&e.open(ae.target)?.skip("the table styles: read where a table names one");for(const t of e.rels(r))if(t.type.endsWith("/notesMaster")||t.type.endsWith("/handoutMaster")){const n=e.relOfType(t.target,"theme")?.target;n&&e.leave(n,"the notes or handout master's theme")}for(const t of b.slice(1)){const n=e.relOfType(t,"theme")?.target;n&&n!==_&&e.leave(n,"a second master's theme: a deck has one"),n&&n!==_&&f({...c,part:n,where:"theme"},"cannot-hold","a:theme","a second master's own theme")}const ie=a.one("p:defaultTextStyle"),be=X(ie,{...c,read:C}),J=new Map,B=new Map,ce=b.map((t,n)=>{const l=e.open(t),i=l?.one("p:cSld"),g=i?.attr("name"),p=g===void 0||g===""?`Master ${String(n+1)}`:g;l?.ignore(["preserve"],"whether PowerPoint keeps an unused master");const O=he(l?.one("p:clrMap"));B.set(t,O);const S={read:C,part:t,colors:{scheme:W,map:O},where:`master "${p}"`};l&&ke(l,S),ne(l?.one("p:extLst"));const Q=l?.one("p:sldLayoutIdLst")?.all("p:sldLayoutId").flatMap(I=>{I.attr("id");const P=e.rel(t,I.attr("r:id"))?.target;if(!P)return[];const k=e.open(P),F=k?.one("p:cSld"),z=F?.attr("name");let d=z===void 0||z===""?`Layout ${String(J.size+1)}`:z;for(;[...J.values()].includes(d);)d=`${d} (${String(n+1)})`;J.set(P,d),k?.ignore(["type","matchingName","preserve","userDrawn","showMasterPhAnim"],"a layout's kind and bookkeeping in PowerPoint's gallery");const E=ge(O,k?.one("p:clrMapOvr"));E!==O&&B.set(P,E);const G={read:C,part:P,colors:{scheme:W,map:E},where:`layout "${d}"`};k&&ke(k,G),ne(k?.one("p:extLst"));const fe=ye(te(F,G),G);return F?.one("p:extLst")?.skip("a layout's extensions"),[{name:d,...fe?{background:fe}:{},...k?.attrOr("showMasterSp")===!1?{display_master_shapes:!1}:{},shapes:ee(F?.one("p:spTree"),G)}]})??[],y=ye(te(i,S),S),x=l?.one("p:txStyles"),L={},A=x?.one("p:titleStyle"),D=x?.one("p:bodyStyle"),T=x?.one("p:otherStyle");return A&&(L.title=X(A,S)),D&&(L.body=X(D,S)),T&&(L.other=X(T,S)),n===0&&ie&&$e(be,L.other??[])&&f(c,"cannot-hold","p:defaultTextStyle","the presentation's default text differs from its first master's other text, which a deck takes for both"),i?.one("p:extLst")?.skip("a master's extensions"),{name:p,...y?{background:y}:{},text_styles:L,shapes:ee(i?.one("p:spTree"),S),layouts:Q}}),Se=(a.one("p:sldIdLst")?.all("p:sldId")??[]).flatMap((t,n)=>{t.attr("id"),je(t);const l=e.rel(r,t.attr("r:id"))?.target;if(!l)return[];const i=e.open(l);if(!i)return[];const g=`slide ${String(n+1)}`,p=e.relOfType(l,"slideLayout")?.target,O=p?e.relOfType(p,"slideMaster")?.target:void 0,S=(p===void 0?void 0:B.get(p))??(O===void 0?void 0:B.get(O))??N,Q=ge(S,i.one("p:clrMapOvr")),y={read:C,part:l,colors:{scheme:W,map:Q},where:g};i.attrOr("showMasterPhAnim"),i.attrOr("showMasterSp")||f(y,"cannot-hold","p:sld@showMasterSp","a slide that hides its master's shapes (its layout's say for all its slides)"),ne(i.one("p:extLst"));const x=i.one("p:cSld"),L=x?.attr("name");for(const d of["p:custDataLst","p:controls"]){const E=x?.one(d);E&&(f(y,"cannot-hold",d,d==="p:controls"?"ActiveX controls":"a slide's custom data"),E.consume())}x?.one("p:extLst")?.skip("a slide's extensions");const A=te(x,y),D=ee(x?.one("p:spTree"),y),T=e.relOfType(l,"notesSlide")?.target,I=T?Ce(T,{...y,part:T,where:`${g} notes`}):void 0,{transition:P,advance:k}=_e(i.one("p:transition"),y),F=new Map(D.flatMap(d=>d.id===void 0?[]:[[d.id,d.name.replace(/^!!/u,"")]])),z=Ee(i.one("p:timing"),F,{width:h,height:w},y);return[{...L?{name:L}:{},layout:(p?J.get(p):void 0)??ce[0]?.layouts[0]?.name??"",hidden:!i.attrOr("show"),...I!==void 0&&I.trim()!==""?{notes:I}:{},shapes:D.map(d=>({...d,name:d.name.replace(/^!!/u,"")})),...A?{background:A}:{},animations:z,...P?{transition:P}:{},...k===void 0?{}:{advance:k},part:l}]}),le=e.rels("").find(t=>t.type.endsWith("/core-properties"))?.target,de=le?e.open(le):void 0,pe=de?.el.children.find(t=>t.key==="dc:title")?.text.trim()??"";return de?.consume(),{width:h,height:w,...pe===""?{}:{title:pe},theme:se,fonts:$,masters:ce,slides:Se,report:e.report(),reasons:e.reasons(),bytes:t=>e.parts[t]}}function $e(s,o){return s.some((e,r)=>Object.entries(e).some(([a,c])=>{const m=o[r]?.[a],u=ve.other[r]?.[a],h=m??u;return h!==void 0&&JSON.stringify(h)!==JSON.stringify(c)&&JSON.stringify({...h,...c})!==JSON.stringify(h)}))}function je(s){s.one("p:extLst")?.skip("a slide id's extensions")}function Ce(s,o){const e=o.read.pkg.open(s);if(!e)return;const a=e.one("p:cSld")?.one("p:spTree")?.all("p:sp").find(m=>(m.one("p:nvSpPr")?.one("p:nvPr")?.one("p:ph")?.attr("type")??"obj")==="body"),c=Fe(a?.one("p:txBody"),o);return c.some(m=>m.runs.some(u=>u.font!==void 0))&&f(o,"approximated","p:notes","speaker notes keep their words, not their formatting"),e.consume(),c.map(m=>m.runs.map(u=>u.text==="\v"?`
|
|
3
|
-
`:
|
|
2
|
+
import{unzipSync as Ie}from"fflate";import{withinZip as _e}from"@allyhub/formats";import{DEFAULT_COLOR_MAP as C,Package as Ee,SCHEME_COLORS as Fe,colorIn as ye}from"@allyhub/ooxml";import{EAST_ASIAN_FONT as $e,OFFICE_TEXT_STYLES as je}from"@allyhub/slides-core";import{colorAt as Ae,fillElement as Re,fillOf as Ce,say as l,withAlpha as we}from"./common.js";import{shapesOf as se}from"./shapes.js";import{levelsOf as Y,paragraphsOf as Ne}from"./text.js";import{animationsOf as De,playbacksOf as ze,transitionOf as We}from"./timing.js";const be={presProps:"presentation properties (how a show runs, recent colours)",viewProps:"PowerPoint's view of the file (zoom, guides, the last slide shown)","extended-properties":"the application's statistics of the file",thumbnail:"a preview picture of the first slide",printerSettings:"printer settings",notesMaster:"the notes pages' master: a deck's notes are text",handoutMaster:"the handouts' master"};function xe(a){if(!a)return C;const o={...C};for(const e of["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"]){const s=a.attr(e);s!==void 0&&(o[e]=s)}return a.one("a:extLst"),o}function ae(a,o){const e=Object.fromEntries(Object.entries(a).filter(([s,c])=>o[s]!==c));return Object.keys(e).length>0?e:void 0}const Ge=(a,o)=>ae(a,o)===void 0;function Se(a,o){o?.one("a:masterClrMapping");const e=o?.one("a:overrideClrMapping");return e?xe(e):a}function re(a,o){const e=a?.one("p:bg");if(!e)return;e.ignore(["bwMode"],"a background's black and white printing mode");const s=e.one("p:bgPr");if(s){s.ignore(["shadeToTitle"],"a background shaded to its title, a legacy option");for(const P of s.one("a:effectLst")?.kids()??[])l(o,"cannot-hold",`p:bg/${P.key}`,"an effect on a background"),P.consume();s.one("a:effectDag")?.consume();const d=s.one("a:blipFill");if(d){d.ignore(["dpi","rotWithShape"],"a picture's resolution and turning with its fill");const P=d.one("a:blip")?.ignore(["cstate"],"a picture's compression state"),v=o.read.pkg.rel(o.part,P?.attr("r:embed"));for(const y of P?.kids()??[])y.key!=="a:extLst"&&(l(o,"cannot-hold",`p:bg/${y.key}`,"a background picture's own effect (transparency, recolouring, brightness)"),y.consume());const T=y=>["l","t","r","b"].some(F=>(y?.attr(F)??0)!==0);if(T(d.one("a:srcRect"))&&l(o,"cannot-hold","p:bg/a:srcRect","a background picture's crop: it is stretched over the slide whole"),T(d.one("a:stretch")?.one("a:fillRect"))&&l(o,"cannot-hold","p:bg/a:fillRect","a background picture stretched to a part of the slide: it is stretched over the whole"),d.one("a:tile")&&l(o,"approximated","a:tile","a tiled background picture is stretched"),v&&!v.external&&o.read.pkg.bytes(v.target))return{picture:v.target};l(o,"missing","a:blip","a background picture whose file is not in the file");return}const g=Ce(s,o);return g?.fill===null?{fill:"lt1"}:g?.fill!==void 0?{fill:Le(g.fill,g)}:g?.gradient?{gradient:g.gradient}:void 0}const c=e.one("p:bgRef");if(!c)return;const i=c.attr("idx")??0,h=ye(c,o.colors),b=i>=1001?o.read.matrix.background[i-1001]:i>0?o.read.matrix.fill[i-1]:void 0;if(!b){const d=h?Ae(c,o,"p:bgRef"):void 0;return h?{fill:d?we(d.color,d.alpha):"lt1"}:void 0}const r=Re(b,{...o,colors:{...o.colors,...h?{placeholder:h}:{}}});if(r?.fill!==void 0&&r.fill!==null)return{fill:Le(r.fill,r)};if(r?.gradient)return{gradient:r.gradient}}const Le=(a,o)=>o.fill_transparency===void 0?a:we(a,1-o.fill_transparency);function Oe(a,o){if(a){if(a.fill!==void 0)return a.fill;if(a.gradient)return l(o,"approximated","p:bg/a:gradFill","a master's or a layout's gradient background is its first colour"),a.gradient.stops[0]?.color;l(o,"cannot-hold","p:bg/a:blipFill","a master's or a layout's picture background")}}function Pe(a,o){for(const e of["p:transition","p:timing"]){const s=a.one(e);s&&(l(o,"cannot-hold",e,`a ${e==="p:transition"?"transition":"animation"} on a master or a layout`),s.consume())}a.one("p:hf")?.skip("which of date, footer and slide number new slides get: a deck's slide shows them where it says so")}function ie(a){for(const o of a?.all("p:ext")??[])for(const e of["p14:creationId","p14:modId"])o.one(e)?.skip("PowerPoint's ids of a part across versions")}export function readPptx(a,o){const e=new Ee(Ie(a,{filter:_e(o)})),s=e.relOfType("","officeDocument")?.target??"ppt/presentation.xml";for(const t of e.rels("")){const n=be[t.type.split("/").pop()??""];n!==void 0&&!t.external&&e.leave(t.target,n)}e.ignoreExtensions(["p14:creationId","p14:modId","a16:creationId","a16:colId","a16:rowId","a14:useLocalDpi","p15:sldGuideLst","p14:discardImageEditData","p14:defaultImageDpi","p15:chartTrackingRefBased"],"PowerPoint's ids and settings across versions");const c=e.open(s);if(!c)throw new Error(`it has no presentation (${s})`);for(const t of e.rels(s)){const n=be[t.type.split("/").pop()??""];n!==void 0&&!t.external&&e.leave(t.target,n)}const i={read:{pkg:e,matrix:{fill:[],line:[],effect:[],background:[]},faces:new Set},part:s,colors:{scheme:{},map:C},where:"presentation"};c.ignore(["saveSubsetFonts","autoCompressPictures","strictFirstAndLastChars","embedTrueTypeFonts","removePersonalInfoOnSave","bookmarkIdSeed","serverZoom","compatMode","conformance","showSpecialPlsOnTitleSld"],"how PowerPoint saves and shows the file");const h=c.attrOr("firstSlideNum");h!==1&&l(i,"cannot-hold","p:presentation@firstSlideNum",`slides numbered from ${String(h)}`),c.attrOr("rtl")&&l(i,"cannot-hold","p:presentation@rtl","a right-to-left presentation");const b=c.one("p:sldSz");b?.ignore(["type"],"a slide size's name: its width and height are read"),c.one("p:notesSz")?.skip("the notes pages' size"),c.one("p:notesMasterIdLst")?.consume(),c.one("p:handoutMasterIdLst")?.consume();for(const t of["p:embeddedFontLst","p:custShowLst","p:photoAlbum","p:custDataLst","p:kinsoku","p:modifyVerifier"]){const n=c.one(t);n&&(l(i,"cannot-hold",t,t==="p:embeddedFontLst"?"fonts carried in the file":t==="p:custShowLst"?"custom shows":t.slice(2)),n.consume())}let r;for(const t of c.one("p:extLst")?.all("p:ext")??[])for(const n of t.kids())n.key==="p15:sldGuideLst"?n.skip("PowerPoint's guides"):n.key==="p14:sectionLst"&&(r=n);for(const t of e.rels(s))(t.type.endsWith("/fonts")||t.type.endsWith("/font"))&&e.leave(t.target,"a font carried in the file (said above)");const d=b?.attr("cx")??12192e3,g=b?.attr("cy")??6858e3,v=(c.one("p:sldMasterIdLst")?.all("p:sldMasterId")??[]).flatMap(t=>{t.attr("id");const n=e.rel(s,t.attr("r:id"));return n?[n.target]:[]}),T=v[0]?e.relOfType(v[0],"theme")?.target:void 0,y=T?e.open(T):void 0;y?.attr("name");const F=y?.one("a:themeElements"),ce=F?.one("a:clrScheme");ce?.attr("name");const de={},J={};for(const t of Fe){const n=ye(ce?.one(`a:${t}`),{scheme:{},map:C});n&&(de[t]=n.rgb,J[t]=n.rgb)}const q=F?.one("a:fontScheme");q?.attr("name");const N={},B=(t,n)=>{const m=q?.one(t)?.one(n);m?.ignore(["panose","pitchFamily","charset"],"a font's panose, pitch and character set: its name picks it");const p=m?.attr("typeface");return p===""?void 0:p},K=B("a:majorFont","a:latin"),Q=B("a:minorFont","a:latin"),ee=B("a:majorFont","a:ea"),te=B("a:minorFont","a:ea");K&&(N.major=K),Q&&(N.minor=Q),ee&&(N.major_east_asian=ee),te&&(N.minor_east_asian=te);const X={...i,part:T??"",where:"theme"};for(const t of["a:majorFont","a:minorFont"]){const n=q?.one(t),u=n?.one("a:cs");u?.ignore(["panose","pitchFamily","charset"],"a font's panose, pitch and character set: its name picks it"),u?.attr("typeface")&&l(X,"cannot-hold",`${t}/a:cs`,"the theme's complex script face (Arabic, Hebrew, Thai…)");const m=n?.all("a:font")??[],p=n?.one("a:ea")?.el.attrs.find(w=>w.key==="typeface")?.value;m.some(w=>(w.attr("typeface")??"")!==""&&w.attr("typeface")!==p)?l(X,"cannot-hold",`${t}/a:font`,"the theme's faces for each script (one East Asian face is the deck's)"):n&&(p??"")===""&&l(X,"approximated",`${t}/a:ea`,`the theme names no East Asian face, so East Asian text is in the deck's (${$e})`);for(const w of m)w.consume()}const D=F?.one("a:fmtScheme"),ve={fill:D?.one("a:fillStyleLst")?.kids()??[],line:D?.one("a:lnStyleLst")?.kids()??[],effect:D?.one("a:effectStyleLst")?.kids()??[],background:D?.one("a:bgFillStyleLst")?.kids()??[]};D?.skip("the theme's style matrix: read where a shape's style names an entry of it"),F?.one("a:extLst")?.skip("the theme's extensions"),y?.one("a:objectDefaults")?.skip("the defaults PowerPoint gives a shape a person adds"),y?.one("a:extraClrSchemeLst")?.skip("other colour schemes PowerPoint offers"),y?.one("a:extLst")?.skip("the theme's family, PowerPoint's bookkeeping");const pe=y?.one("a:custClrLst");pe&&(l(X,"cannot-hold","a:custClrLst","the theme's custom colours"),pe.consume());const z={pkg:e,matrix:ve,faces:new Set([K,Q,ee,te].filter(t=>t!==void 0)),slides:new Map((c.one("p:sldIdLst")?.all("p:sldId")??[]).flatMap((t,n)=>{const u=e.rel(s,t.attr("r:id"))?.target;return u===void 0?[]:[[u,n+1]]}))};i.read=z;const le=e.relOfType(s,"tableStyles");le&&e.open(le.target)?.skip("the table styles: read where a table names one");for(const t of e.rels(s))if(t.type.endsWith("/notesMaster")||t.type.endsWith("/handoutMaster")){const n=e.relOfType(t.target,"theme")?.target;n&&e.leave(n,"the notes or handout master's theme")}for(const t of v.slice(1)){const n=e.relOfType(t,"theme")?.target;n&&n!==T&&e.leave(n,"a second master's theme: a deck has one"),n&&n!==T&&l({...i,part:n,where:"theme"},"cannot-hold","a:theme","a second master's own theme")}const fe=c.one("p:defaultTextStyle"),Me=Y(fe,{...i,read:z,named:!0}),Z=new Map,U=new Map,ue=v.map((t,n)=>{const u=e.open(t),m=u?.one("p:cSld"),p=m?.attr("name"),w=p===void 0||p===""?`Master ${String(n+1)}`:p;u?.ignore(["preserve"],"whether PowerPoint keeps an unused master");const k=xe(u?.one("p:clrMap"));U.set(t,k);const S={read:z,part:t,colors:{scheme:J,map:k},named:!0,where:`master "${w}"`},W=ae(k,C);u&&Pe(u,S),ie(u?.one("p:extLst"));const V=u?.one("p:sldLayoutIdLst")?.all("p:sldLayoutId").flatMap(A=>{A.attr("id");const _=e.rel(t,A.attr("r:id"))?.target;if(!_)return[];const O=e.open(_),R=O?.one("p:cSld"),H=R?.attr("name");let E=H===void 0||H===""?`Layout ${String(Z.size+1)}`:H;for(;[...Z.values()].includes(E);)E=`${E} (${String(n+1)})`;Z.set(_,E),O?.ignore(["type","matchingName","preserve","userDrawn","showMasterPhAnim"],"a layout's kind and bookkeeping in PowerPoint's gallery");const f=Se(k,O?.one("p:clrMapOvr"));f!==k&&U.set(_,f);const x={read:z,part:_,colors:{scheme:J,map:f},named:!0,where:`layout "${E}"`},ge=ae(f,k);O&&Pe(O,x),ie(O?.one("p:extLst"));const ke=Oe(re(R,x),x);return R?.one("p:extLst")?.skip("a layout's extensions"),[{name:E,...ke?{background:ke}:{},...ge?{color_map:ge}:{},...O?.attrOr("showMasterSp")===!1?{display_master_shapes:!1}:{},shapes:se(R?.one("p:spTree"),x)}]})??[],L=Oe(re(m,S),S),M=u?.one("p:txStyles"),I={},G=M?.one("p:titleStyle"),$=M?.one("p:bodyStyle"),j=M?.one("p:otherStyle");return G&&(I.title=Y(G,S)),$&&(I.body=Y($,S)),j&&(I.other=Y(j,S)),n===0&&fe&&He(Me,I.other??[])&&l(i,"cannot-hold","p:defaultTextStyle","the presentation's default text differs from its first master's other text, which a deck takes for both"),m?.one("p:extLst")?.skip("a master's extensions"),{name:w,...L?{background:L}:{},...W?{color_map:W}:{},text_styles:I,shapes:se(m?.one("p:spTree"),S),layouts:V}}),ne=new Map,me=(c.one("p:sldIdLst")?.all("p:sldId")??[]).flatMap((t,n)=>{const u=t.attr("id");Je(t);const m=e.rel(s,t.attr("r:id"))?.target;if(!m)return[];const p=e.open(m);if(!p)return[];const w=`slide ${String(n+1)}`,k=e.relOfType(m,"slideLayout")?.target,S=k?e.relOfType(k,"slideMaster")?.target:void 0,W=(k===void 0?void 0:U.get(k))??(S===void 0?void 0:U.get(S))??C,V=Se(W,p.one("p:clrMapOvr")),L={read:z,part:m,colors:{scheme:J,map:V},named:Ge(V,W),where:w};p.attrOr("showMasterPhAnim"),p.attrOr("showMasterSp")||l(L,"cannot-hold","p:sld@showMasterSp","a slide that hides its master's shapes (its layout's say for all its slides)"),ie(p.one("p:extLst"));const M=p.one("p:cSld"),I=M?.attr("name");for(const f of["p:custDataLst","p:controls"]){const x=M?.one(f);x&&(l(L,"cannot-hold",f,f==="p:controls"?"ActiveX controls":"a slide's custom data"),x.consume())}M?.one("p:extLst")?.skip("a slide's extensions");const G=re(M,L),$=se(M?.one("p:spTree"),L),j=e.relOfType(m,"notesSlide")?.target,A=j?Ue(j,{...L,part:j,where:`${w} notes`}):void 0,{transition:_,advance:O}=We(p.one("p:transition"),L),R=new Map($.flatMap(f=>f.id===void 0?[]:[[f.id,f.name.replace(/^!!/u,"")]])),H=ze(p.one("p:timing"));for(const f of $){const x=f.id===void 0?void 0:H.get(f.id);f.kind!=="movie"&&f.kind!=="audio"||!x||Object.keys(x).length===0||(f.playback={...x,...f.playback?.trim?{trim:f.playback.trim}:{}})}const E=De(p.one("p:timing"),R,{width:d,height:g},L);return u!==void 0&&ne.set(u,ne.size),[{...I?{name:I}:{},layout:(k?Z.get(k):void 0)??ue[0]?.layouts[0]?.name??"",hidden:!p.attrOr("show"),...A!==void 0&&A.trim()!==""?{notes:A}:{},shapes:$.map(f=>({...f,name:f.name.replace(/^!!/u,"")})),...G?{background:G}:{},animations:E,..._?{transition:_}:{},...O===void 0?{}:{advance:O},part:m}]});if(r){r.use(),r.one("p14:extLst")?.skip("a section list's extensions");for(const t of r.all("p14:section")){t.attr("id"),t.one("p14:extLst")?.skip("a section's extensions");const n=t.attr("name")??"",u=(t.one("p14:sldIdLst")?.all("p14:sldId")??[]).map(p=>ne.get(p.attr("id")??-1)).find(p=>p!==void 0),m=u===void 0?void 0:me[u];m&&n.trim()!==""?m.section=n.trim():l({...i,part:s,where:"presentation"},"cannot-hold","p14:section",`a section with no slides${n===""?"":` (${n})`}`)}}const oe=e.rels("").find(t=>t.type.endsWith("/core-properties"))?.target,Te=oe?e.open(oe):void 0,he=Xe(Te,{...i,part:oe??""});return{width:d,height:g,...he===""?{}:{title:he},theme:de,fonts:N,masters:ue,slides:me,report:e.report(),reasons:e.reasons(),bytes:t=>e.parts[t]}}function He(a,o){return a.some((e,s)=>Object.entries(e).some(([c,i])=>{const h=o[s]?.[c],b=je.other[s]?.[c],r=h??b;return r!==void 0&&JSON.stringify(r)!==JSON.stringify(i)&&JSON.stringify({...r,...i})!==JSON.stringify(r)}))}function Je(a){a.one("p:extLst")?.skip("a slide id's extensions")}const Be={"dc:creator":"the document's author","dc:subject":"the document's subject","cp:keywords":"the document's keywords","dc:description":"the document's comments","cp:category":"the document's category","cp:contentStatus":"the document's status","dc:identifier":"the document's identifier","dc:language":"the document's language","cp:contentType":"the document's content type","cp:version":"the document's version"};function Xe(a,o){let e="";for(const s of a?.kids()??[]){const c=s.el.text.trim();if(s.key==="dc:title"){s.use(),e=c;continue}const i=Be[s.key];if(i!==void 0&&c!==""){s.consume(),l(o,"cannot-hold",s.key,i);continue}s.skip(i!==void 0?"an empty document property":"when, by whom and how often the file was saved, and the like: PowerPoint writes them again")}return e}const Ze=new Set(["sldImg","hdr","dt","ftr","sldNum"]);function Ue(a,o){const e=o.read.pkg.open(a);if(!e)return;e.ignore(["showMasterSp","showMasterPhAnim"],"a notes page's view of its master"),e.one("p:clrMapOvr")?.skip("a notes page's colour map: its words have no colour here"),e.one("p:extLst")?.skip("a notes page's extensions");const s=e.one("p:cSld");s?.ignore(["name"],"a notes page's name"),s?.one("p:bg")?.skip("a notes page's background: notes are words"),s?.one("p:extLst")?.skip("a notes page's extensions");const c=s?.one("p:spTree");let i;for(const r of c?.kids()??[]){if(r.key==="p:nvGrpSpPr"||r.key==="p:grpSpPr"){r.skip("a notes page's shape tree's own properties");continue}const d=r.key==="p:sp"?r:void 0,g=d?.one("p:nvSpPr")?.one("p:nvPr")?.one("p:ph"),P=g?.attr("type")??"obj";if(d&&g&&P==="body"&&!i){i=d.use();continue}if(d&&g&&Ze.has(P)){r.skip("a notes page's picture of its slide, header, date, footer and number: the notes master's");continue}r.use(),l(o,"cannot-hold",r.key,"a shape on a notes page besides its words: a deck's notes are words"),r.consume()}i?.one("p:nvSpPr")?.skip("the notes' placeholder"),i?.one("p:spPr")?.skip("the notes' place on the page"),i?.one("p:style")?.skip("the notes' style"),i?.one("p:extLst")?.skip("the notes' extensions");const h=i?.one("p:txBody");h?.one("a:bodyPr")?.skip("the notes' text frame"),h?.one("a:lstStyle")?.skip("the notes' list style");const b=Ne(h,o);b.some(r=>r.runs.some(d=>d.font!==void 0)||Object.keys(r).some(d=>d!=="runs"&&d!=="level"))&&l(o,"approximated","p:notes","speaker notes keep their words, not their formatting");for(const r of h?.all("a:p")??[])r.consume();return b.map(r=>r.runs.map(d=>d.text==="\v"?`
|
|
3
|
+
`:d.text).join("")).join(`
|
|
4
4
|
`)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{SHAPE_TYPES as ee}from"@allyhub/ooxml/enums";import{evaluate as te,presetAdjustments as ne}from"@allyhub/ooxml/geometry";import{as as I,parseXml as oe}from"@allyhub/ooxml";import{strFromU8 as ie}from"fflate";import{isConnectorGeometry as ae,pathSteps as re}from"@allyhub/slides-core";import{fillOf as B,lineOf as W,say as v,shadowOf as U,styleOf as V}from"./common.js";import{chartOf as se}from"./chart.js";import{tableOf as ce}from"./table.js";import{BODY_DEFAULTS as de,bodyOf as le}from"./text.js";const Z=new Set(["title","ctrTitle","subTitle","body","pic","media","obj","dt","ftr","sldNum"]),pe=new Set(ee),q={place:e=>e};function D(e){const a=e?.one("a:off"),n=e?.one("a:ext");if(!(!e||!a||!n))return{frame:{left:a.attr("x")??0,top:a.attr("y")??0,width:n.attr("cx")??0,height:n.attr("cy")??0},rotation:e.attrOr("rot")/6e4%360,flip:{h:e.attrOr("flipH"),v:e.attrOr("flipV")}}}function H(e){if(!e)return{};const a=Math.round((e.rotation%360+360)%360*1e3)/1e3;return{frame:{left:Math.round(e.frame.left),top:Math.round(e.frame.top),width:Math.round(e.frame.width),height:Math.round(e.frame.height)},...a===0||a===360?{}:{rotation:a},...e.flip.h||e.flip.v?{flip:{...e.flip.h?{h:!0}:{},...e.flip.v?{v:!0}:{}}}:{}}}function fe(e,a){const n=(r,u)=>e?.one(r)?.attr(u)??0,o=(r,u)=>e?.one(r)?.attr(u)??0,l=o("a:chExt","cx")===0?1:o("a:ext","cx")/o("a:chExt","cx"),t=o("a:chExt","cy")===0?1:o("a:ext","cy")/o("a:chExt","cy"),s=(e?.attrOr("rot")??0)/6e4%360,m=e?.attrOr("flipH")??!1,f=e?.attrOr("flipV")??!1,g=n("a:off","x")+o("a:ext","cx")/2,c=n("a:off","y")+o("a:ext","cy")/2;return r=>{const u=r.frame.width*l,w=r.frame.height*t;let p=n("a:off","x")+(r.frame.left-n("a:chOff","x"))*l+u/2,d=n("a:off","y")+(r.frame.top-n("a:chOff","y"))*t+w/2,i=r.rotation;const _={...r.flip};if(m&&(p=2*g-p,i=-i,_.h=!_.h),f&&(d=2*c-d,i=-i,_.v=!_.v),s!==0){const b=s*Math.PI/180,[S,h]=[p-g,d-c];p=g+S*Math.cos(b)-h*Math.sin(b),d=c+S*Math.sin(b)+h*Math.cos(b),i+=s}return a.place({frame:{left:p-u/2,top:d-w/2,width:u,height:w},rotation:i,flip:_})}}function ue(e,a,n){const o=i=>(i?.all("a:gd")??[]).map(_=>[_.attr("name")??"",_.attr("fmla")??""]),l=o(e.one("a:avLst")),t=o(e.one("a:gdLst"));e.one("a:ahLst")?.skip("a freeform's handles: editing aids"),e.one("a:cxnLst")?.skip("a freeform's connection sites: editing aids"),e.one("a:rect")?.skip("a freeform's text rectangle: its text takes the shape's box");const s=i=>I(i).all("a:pt").flatMap(_=>[String(_.attr("x")??"0"),String(_.attr("y")??"0")]),m={"a:moveTo":"M","a:lnTo":"L","a:quadBezTo":"Q","a:cubicBezTo":"C","a:close":"Z","a:arcTo":"A"},f=(e.one("a:pathLst")?.all("a:path")??[]).map(i=>{const _=i.kids().map(h=>{if(h.use(),h.key==="a:arcTo"){const P=h;return["A",...["wR","hR","stAng","swAng"].map(k=>String(P.attr(k)??"0"))].join(" ")}return[m[h.key]??"Z",...s(h)].join(" ")}),b=i.attr("fill"),S=i.attr("stroke");return i.attr("extrusionOk"),{...i.attr("w")?{w:i.attr("w")}:{},...i.attr("h")?{h:i.attr("h")}:{},...b===void 0||b==="norm"?{}:{fill:b},...S===!1?{stroke:!1}:{},d:_.join(" ")}});if(f.length===0)return;f.some(i=>i.fill!==void 0||i.stroke===!1)&&v(n,"approximated","a:path@fill","a freeform's paths are drawn alike: filled and outlined");const g=f[0]?.w??0,c=f[0]?.h??0,r=g>0&&c>0&&f.every(i=>(i.w??0)===g&&(i.h??0)===c),u=r?g:a&&a.width>0?a.width:g>0?g:1,w=r?c:a&&a.height>0?a.height:c>0?c:1,p=te({av:l,gd:t,paths:f.map(i=>({d:i.d,...i.w?{w:i.w}:{},...i.h?{h:i.h}:{}}))},u,w),d=re(p.paths.map(i=>i.d).join(" "));return d?{w:u,h:w,steps:d}:void 0}function he(e,a,n){const o=new Map((a?.all("a:gd")??[]).map(s=>[s.attr("name")??"",s.attr("fmla")??""]));if(o.size===0)return;const l=ne(e);for(const s of o.keys())l.some(m=>m.name===s)||v(n,"unread","a:gd@name",`${e} has no adjustment ${s}`);return l.map(s=>{const m=o.get(s.name),f=m===void 0?NaN:Number(/^val\s+(-?[\d.]+)$/u.exec(m.trim())?.[1]);return m!==void 0&&Number.isNaN(f)&&v(n,"approximated","a:gd@fmla",`an adjustment by a formula (${m}) is the preset's own`),(Number.isNaN(f)?s.value:f)/1e5})}function C(e,a){const n=e?.attr("name")??"",o=e?.attr("id"),l=e?.attr("descr");e?.attr("hidden")===!0&&v(a,"cannot-hold","p:cNvPr@hidden","a shape hidden on its slide"),e?.attr("title")&&v(a,"cannot-hold","p:cNvPr@title","an alternative text's title");for(const s of["a:hlinkClick","a:hlinkHover"]){const m=e?.one(s);if(m?.attr("action")==="ppaction://media"){m.consume();continue}m&&(v(a,"cannot-hold",s,"a link on a whole shape"),m.consume())}return{name:n,...o===void 0?{}:{id:String(o)},...l?{alt:l}:{}}}export function shapesOf(e,a,n=q){const o=[];if(!e)return o;for(const l of e.kids())switch(l.key){case"p:nvGrpSpPr":case"p:grpSpPr":n===q&&l.consume();break;case"p:sp":o.push(...be(l,a,n));break;case"p:cxnSp":o.push(...ve(l,a,n));break;case"p:pic":o.push(...K(l,a,n));break;case"p:graphicFrame":o.push(...we(l,a,n));break;case"p:grpSp":o.push(...ye(l,a,n));break;case"p:contentPart":l.use(),v(a,"cannot-hold","p:contentPart","ink"),l.consume();break;default:break}return o}const $=(e,a,n)=>{const o=`${e.where} › "${n||"unnamed"}"`;return a.label(o),{...e,where:o}},me=["noGrp","noUngrp","noSelect","noChangeAspect","noEditPoints","noAdjustHandles","noChangeArrowheads","noChangeShapeType","noTextEdit","noCrop","noDrilldown"];function G(e,a){if(!e)return!1;const n=I(e),o=e.key!=="a:graphicFrameLocks",l=n.attr("noMove")===!0,t=n.attr("noResize")===!0,s=o&&n.attr("noRot")===!0;return n.ignore(me,"locks against editing in PowerPoint"),I(e).one("a:extLst")?.skip("a lock's extensions"),l&&t?!0:((l||t||s)&&v(a,"cannot-hold",`${e.key}@${[l&&"noMove",t&&"noResize",s&&"noRot"].filter(Boolean).join(",")}`,"a shape locked against some changes and not others: a deck locks moving, sizing and turning together"),!1)}const ge={};function be(e,a,n){e.use();const o=e.one("p:nvSpPr"),l=o?.one("p:cNvPr"),t=$(a,e,l?.el.attrs.find(x=>x.key==="name")?.value??""),s=C(l,t),m=o?.one("p:cNvSpPr");G(m?.one("a:spLocks"),t)&&(s.locked=!0);const f=m?.attr("txBox")===!0,g=o?.one("p:nvPr");g?.ignore(["isPhoto","userDrawn"],"a shape's origin in PowerPoint");const c=g?.one("p:ph"),r=e.one("p:spPr");r?.ignore(["bwMode"],"a shape's black and white printing mode");const u=D(r?.one("a:xfrm")),w=H(u&&n.place(u)),p=r?.one("a:prstGeom"),d=p?.attr("prst"),i=B(r,t),_=r?.one("a:ln"),b=W(_,t),S=r?.one("a:effectLst"),h=c||f?{}:V(e.one("p:style"),t),P=S?U(S,t):h.shadow;(c||f)&&e.one("p:style")?.skip("a placeholder's or a text box's style: its own properties are what it shows");const k=i?.group?n.fill:i;i?.group&&!n.fill&&v(t,"approximated","a:grpFill","a group's fill outside a group is none");const L=e.one("p:txBody"),N=c!==void 0&&!t.part.includes("/slides/")&&(c.attr("type")??"obj")!=="sldNum",A=L?le(L,c&&!t.part.includes("/slideMasters/")?ge:de,t,N):void 0,T={...s,kind:"autoshape",...w,...k?.fill!==void 0?{fill:k.fill}:k?.gradient?{}:c?{}:f?{fill:null}:h.fill!==void 0?{fill:h.fill}:h.gradient?{}:{fill:null},...(k?.fill_transparency??(k?void 0:h.fill_transparency))===void 0?{}:{fill_transparency:k?.fill_transparency??h.fill_transparency??0},...k?.gradient??(k?void 0:h.gradient)?{gradient:k?.gradient??h.gradient}:{},...P?{shadow:P}:{},...b.line!==void 0?{line:b.line}:c?{}:f?{}:{line:h.line??null},...(b.line_width??(c?void 0:h.line_width))===void 0?{}:{line_width:b.line_width??h.line_width},...(b.line_dash??h.line_dash)===void 0?{}:{line_dash:b.line_dash??h.line_dash},...(b.line_begin??h.line_begin)===void 0?{}:{line_begin:b.line_begin??h.line_begin},...(b.line_end??h.line_end)===void 0?{}:{line_end:b.line_end??h.line_end},...b.line_begin_size===void 0?{}:{line_begin_size:b.line_begin_size},...b.line_end_size===void 0?{}:{line_end_size:b.line_end_size},...h.text_color===void 0?{}:{text_color:h.text_color},...A?{text:A}:{},...n.group===void 0?{}:{group:n.group}};if(c){const x=c.attr("type")??"obj",z=c.attr("idx")??0;if(c.ignore(["hasCustomPrompt"],"a placeholder's own prompt text"),c.attr("orient")==="vert"&&v(t,"cannot-hold","p:ph@orient","a vertical placeholder"),c.attr("sz"),x==="sldImg"||x==="hdr")return[];const F=Z.has(x)?x:x==="clipArt"||x==="chart"||x==="tbl"||x==="dgm"?"obj":"body";return Z.has(x)||v(t,"approximated","p:ph@type",`a ${x} placeholder is a${F==="obj"?"n object":" body"} placeholder`),d!==void 0&&d!=="rect"?[{...T,kind:"placeholder",placeholder:{type:F,idx:z},geometry:d,...Y(d,p?.one("a:avLst"),t)}]:(p?.one("a:avLst"),[{...T,kind:"placeholder",placeholder:{type:F,idx:z}}])}const j=r?.one("a:custGeom"),M=j?ue(j,w.frame,t):void 0;j&&!M&&v(t,"approximated","a:custGeom","a freeform with no outline is a rectangle");const R=d!==void 0&&pe.has(d)?d:"rect";return[{...T,kind:f?"textbox":"autoshape",...M?{path:M}:{geometry:R},...d===void 0||M?{}:Y(d,p?.one("a:avLst"),t)}]}const Y=(e,a,n)=>{const o=he(e,a,n);return o?{adjustments:o}:{}};function ve(e,a,n){e.use();const o=e.one("p:nvCxnSpPr"),l=o?.one("p:cNvPr"),t=$(a,e,l?.el.attrs.find(S=>S.key==="name")?.value??""),s=C(l,t),m=o?.one("p:cNvCxnSpPr");G(m?.one("a:cxnSpLocks"),t)&&(s.locked=!0);const f={};for(const[S,h]of[["begin","a:stCxn"],["end","a:endCxn"]]){const P=m?.one(h);if(!P)continue;const k=P.attr("id"),L=P.attr("idx");k!==void 0&&L!==void 0&&(f[S]={id:String(k),site:L}),P.consume()}o?.one("p:nvPr");const g=e.one("p:spPr");g?.ignore(["bwMode"],"a shape's black and white printing mode");const c=D(g?.one("a:xfrm")),r=g?.one("a:prstGeom"),u=r?.attr("prst")??"line",w=Y(u,r?.one("a:avLst"),t),p=V(e.one("p:style"),t),d=W(g?.one("a:ln"),t),i=g?.one("a:effectLst"),_=i?U(i,t):p.shadow,b=ae(u);return b||v(t,"approximated","a:prstGeom@prst",`a connector of the ${u} preset is a shape of it with no fill`),[{...s,kind:"autoshape",geometry:u,...w,...H(c&&n.place(c)),...b?{}:{fill:null},line:d.line??p.line??null,...(d.line_width??p.line_width)===void 0?{}:{line_width:d.line_width??p.line_width},...(d.line_dash??p.line_dash)===void 0?{}:{line_dash:d.line_dash??p.line_dash},...(d.line_begin??p.line_begin)===void 0?{}:{line_begin:d.line_begin??p.line_begin},...(d.line_end??p.line_end)===void 0?{}:{line_end:d.line_end??p.line_end},...d.line_begin_size===void 0?{}:{line_begin_size:d.line_begin_size},...d.line_end_size===void 0?{}:{line_end_size:d.line_end_size},..._?{shadow:_}:{},...n.group===void 0?{}:{group:n.group},...f.begin||f.end?{glue:f}:{}}]}function K(e,a,n){e.use();const o=e.one("p:nvPicPr"),l=o?.one("p:cNvPr"),t=$(a,e,l?.el.attrs.find(y=>y.key==="name")?.value??""),s=C(l,t),m=o?.one("p:cNvPicPr");G(m?.one("a:picLocks"),t)&&(s.locked=!0),m?.attr("preferRelativeResize");const f=o?.one("p:nvPr");f?.ignore(["isPhoto","userDrawn"],"a shape's origin in PowerPoint");const g=f?.one("p:ph"),c=f?.one("a:videoFile"),r=f?.choice("a:audioFile","a:wavAudioFile","a:audioCd","a:quickTimeFile"),u=f?.one("p:extLst")?.all("p:ext").flatMap(y=>{const O=y.one("p14:media");return O?[O]:[]})[0],w=t.read.pkg,p=w.rel(t.part,u?.attr("r:embed"))??w.rel(t.part,c?.attr("r:link"));if(u){u.attr("r:link");for(const y of["p14:trim","p14:fade","p14:bmkLst"]){const O=u.one(y);O&&(v(t,"cannot-hold",y,y==="p14:trim"?"a video's trim":y==="p14:fade"?"a video's fade in and out":"a video's bookmarks"),O.consume())}}r&&(v(t,"cannot-hold",r.key,"a sound"),r.consume());const d=e.one("p:blipFill");d?.ignore(["dpi","rotWithShape"],"a picture's resolution and turning with its fill");const i=d?.one("a:blip");i?.ignore(["cstate"],"a picture's compression state");const _=i?.one("a:extLst")?.all("a:ext").flatMap(y=>{const O=y.one("asvg:svgBlip");return y.one("a14:useLocalDpi")?.skip("a picture kept at its own resolution"),O?[O]:[]})[0],b=w.rel(t.part,_?.attr("r:embed"))??w.rel(t.part,i?.attr("r:embed"));i?.attr("r:link")&&v(t,"missing","a:blip@r:link","a picture linked from outside the file");for(const y of i?.kids()??[])y.key!=="a:extLst"&&(y.use(),v(t,"cannot-hold",y.key,"a picture's own effect (transparency, recolouring, brightness)"),y.consume());const h=d?.one("a:srcRect"),P=y=>(h?.attr(y)??0)/1e5,k=h?{left:P("l"),top:P("t"),right:P("r"),bottom:P("b")}:void 0;d?.one("a:stretch")?.consume();const L=d?.one("a:tile");L&&(v(t,"cannot-hold","a:tile","a picture tiled in its frame"),L.consume());const N=e.one("p:spPr");N?.ignore(["bwMode"],"a shape's black and white printing mode");const A=D(N?.one("a:xfrm")),T=N?.one("a:prstGeom"),j=T?.attr("prst");T?.one("a:avLst"),j!==void 0&&j!=="rect"&&v(t,"cannot-hold","a:prstGeom@prst",`a picture cut to a ${j}`);const M=N?.one("a:ln");M&&W(M,t).line&&v(t,"cannot-hold","p:pic/a:ln","a picture's outline");const R=U(N?.one("a:effectLst"),t),x=B(N,t);(x?.fill||x?.gradient)&&v(t,"cannot-hold","p:pic/p:spPr","a fill behind a picture"),e.one("p:style")?.skip("a picture's style");const z=c!==void 0||u!==void 0&&!r,E=z?p:b;if(!E||E.external)return v(t,"missing","p:pic","a picture or a video whose file is not in the file"),[];w.bytes(E.target),z&&(b&&w.bytes(b.target),c?.attr("r:link"));const F=s.alt!==void 0&&/^[^\s/\\]+\.[A-Za-z0-9]{2,5}$/u.test(s.alt);F&&l?.ignore(["descr"],"a picture's file name as its description (python-pptx's habit)");const J=s.alt===void 0||F?{}:{alt:s.alt};return[{name:s.name,...s.id===void 0?{}:{id:s.id},...s.locked?{locked:!0}:{},...J,kind:z?"movie":"picture",...g?{placeholder:{type:g.attr("type")??"pic",idx:g.attr("idx")??0}}:{},...H(A&&n.place(A)),part:E.target,...k&&!z?{crop:k}:{},...R?{shadow:R}:{},...n.group===void 0?{}:{group:n.group}}]}function we(e,a,n){e.use();const o=e.one("p:nvGraphicFramePr"),l=o?.one("p:cNvPr"),t=$(a,e,l?.el.attrs.find(p=>p.key==="name")?.value??""),s=C(l,t);G(o?.one("p:cNvGraphicFramePr")?.one("a:graphicFrameLocks"),t)&&(s.locked=!0);const m=o?.one("p:nvPr")?.one("p:ph");m&&(v(t,"approximated","p:ph","a table, a chart or an object in a placeholder is the slide's own, its placeholder left empty"),m.consume()),e.ignore(["bwMode"],"a shape's black and white printing mode");const f=D(e.one("p:xfrm")),g=H(f&&n.place(f)),c=e.one("a:graphic")?.one("a:graphicData"),r=c?.attr("uri")??"",u={...s,...g,...n.group===void 0?{}:{group:n.group}};if(r.endsWith("/table")){const p=c?.one("a:tbl");if(p)return[{...u,kind:"table",table:ce(p.use(),t)}]}if(r.endsWith("/chart")){const p=c?.one("c:chart");p?.use();const d=t.read.pkg.rel(t.part,p?.attr("r:id")),i=d?se(d.target,t):"its chart is not in the file";return typeof i=="string"?(v(t,"cannot-hold","c:chart",i),[]):[{...u,kind:"chart",chart:i}]}if(r.endsWith("/diagram"))return v(t,"cannot-hold","dgm:relIds","SmartArt"),c?.consume(),[];const w=c?.one("p:oleObj");if(w){w.use(),v(t,"approximated","p:oleObj",`an embedded ${w.attr("progId")??"object"} is its picture`),w.ignore(["spid","name","showAsIcon","r:id","imgW","imgH","progId"],"an embedded object's program and size"),w.one("p:embed")?.consume(),w.one("p:link")?.consume();const p=w.one("p:pic");if(p){const[i]=K(p,a,n);return i?[{...i,...s,...g,kind:"picture"}]:[]}const d=_e(w.el.attrs.find(i=>i.key==="spid")?.value,t);return d?[{...u,kind:"picture",part:d}]:(v(t,"missing","p:oleObj","an embedded object whose picture is not in the file"),[])}return v(t,"cannot-hold","a:graphicData",r||"a graphic frame"),c?.consume(),[]}const Q="urn:schemas-microsoft-com:vml",X="urn:schemas-microsoft-com:office:office";function _e(e,a){const n=a.read.pkg,o=n.relOfType(a.part,"vmlDrawing")?.target,l=o===void 0?void 0:n.bytes(o);if(o===void 0||!l||e===void 0)return;let t;try{t=oe(ie(l))}catch{return}const s=(r,u,w)=>r.attrs.find(p=>p.uri===u&&p.local===w)?.value,m=r=>[r,...r.children.flatMap(m)],g=m(t).find(r=>r.uri===Q&&(s(r,"","id")===e||s(r,X,"spid")===e))?.children.find(r=>r.uri===Q&&r.local==="imagedata"),c=n.rel(o,g&&s(g,X,"relid"));if(!(!c||c.external||!n.bytes(c.target)))return c.target}function ye(e,a,n){e.use();const o=e.one("p:nvGrpSpPr"),l=o?.one("p:cNvPr"),t=$(a,e,l?.el.attrs.find(u=>u.key==="name")?.value??""),s=C(l,t),m=G(o?.one("p:cNvGrpSpPr")?.one("a:grpSpLocks"),t);o?.one("p:nvPr");const f=e.one("p:grpSpPr");f?.ignore(["bwMode"],"a shape's black and white printing mode");const g=B(f,t),c=f?.one("a:effectLst");c&&(v(t,"cannot-hold","p:grpSpPr/a:effectLst","a group's own effects"),c.consume()),n.group!==void 0&&v(t,"approximated","p:grpSp",`a group in a group is one group, ${n.group}`);const r=shapesOf(e,t,{...g?{fill:g}:n.fill?{fill:n.fill}:{},group:n.group??s.name,place:fe(f?.one("a:xfrm"),n)});return m?r.map(u=>({...u,locked:!0})):r}
|
|
2
|
+
import{SHAPE_TYPES as pe}from"@allyhub/ooxml/enums";import{evaluate as ue,presetAdjustments as he}from"@allyhub/ooxml/geometry";import{as as W,parseXml as me}from"@allyhub/ooxml";import{strFromU8 as ge}from"fflate";import{AUDIO_ICON as _e}from"../audio-icon.js";const be=(e,i)=>e.length===i.length&&e.every((t,o)=>t===i[o]);import{isConnectorGeometry as ke,pathSteps as we}from"@allyhub/slides-core";import{effectsOf as K,fillOf as Q,lineOf as X,linkOf as ve,say as k,sayEffects as te,shadowOf as J,styleOf as oe}from"./common.js";import{chartOf as xe}from"./chart.js";import{tableOf as ye}from"./table.js";import{BODY_DEFAULTS as Pe,bodyOf as Le}from"./text.js";const ie=new Set(["title","ctrTitle","subTitle","body","pic","media","obj","dt","ftr","sldNum"]),Se=new Set(pe),ae={place:e=>e};function Y(e){const i=e?.one("a:off"),t=e?.one("a:ext");if(!(!e||!i||!t))return{frame:{left:i.attr("x")??0,top:i.attr("y")??0,width:t.attr("cx")??0,height:t.attr("cy")??0},rotation:e.attrOr("rot")/6e4%360,flip:{h:e.attrOr("flipH"),v:e.attrOr("flipV")}}}function V(e){if(!e)return{};const i=Math.round((e.rotation%360+360)%360*1e3)/1e3;return{frame:{left:Math.round(e.frame.left),top:Math.round(e.frame.top),width:Math.round(e.frame.width),height:Math.round(e.frame.height)},...i===0||i===360?{}:{rotation:i},...e.flip.h||e.flip.v?{flip:{...e.flip.h?{h:!0}:{},...e.flip.v?{v:!0}:{}}}:{}}}function Ne(e,i){const t=(s,_)=>e?.one(s)?.attr(_)??0,o=(s,_)=>e?.one(s)?.attr(_)??0,f=o("a:chExt","cx")===0?1:o("a:ext","cx")/o("a:chExt","cx"),n=o("a:chExt","cy")===0?1:o("a:ext","cy")/o("a:chExt","cy"),r=(e?.attrOr("rot")??0)/6e4%360,m=e?.attrOr("flipH")??!1,p=e?.attrOr("flipV")??!1,g=t("a:off","x")+o("a:ext","cx")/2,d=t("a:off","y")+o("a:ext","cy")/2;return s=>{const _=s.frame.width*f,h=s.frame.height*n;let l=t("a:off","x")+(s.frame.left-t("a:chOff","x"))*f+_/2,u=t("a:off","y")+(s.frame.top-t("a:chOff","y"))*n+h/2,a=s.rotation;const v={...s.flip};if(m&&(l=2*g-l,a=-a,v.h=!v.h),p&&(u=2*d-u,a=-a,v.v=!v.v),r!==0){const b=r*Math.PI/180,[P,c]=[l-g,u-d];l=g+P*Math.cos(b)-c*Math.sin(b),u=d+P*Math.sin(b)+c*Math.cos(b),a+=r}return i.place({frame:{left:l-_/2,top:u-h/2,width:_,height:h},rotation:a,flip:v})}}function Oe(e,i,t){const o=a=>(a?.all("a:gd")??[]).map(v=>[v.attr("name")??"",v.attr("fmla")??""]),f=o(e.one("a:avLst")),n=o(e.one("a:gdLst"));e.one("a:ahLst")?.skip("a freeform's handles: editing aids"),e.one("a:cxnLst")?.skip("a freeform's connection sites: editing aids"),e.one("a:rect")?.skip("a freeform's text rectangle: its text takes the shape's box");const r=a=>W(a).all("a:pt").flatMap(v=>[String(v.attr("x")??"0"),String(v.attr("y")??"0")]),m={"a:moveTo":"M","a:lnTo":"L","a:quadBezTo":"Q","a:cubicBezTo":"C","a:close":"Z","a:arcTo":"A"},p=(e.one("a:pathLst")?.all("a:path")??[]).map(a=>{const v=a.kids().map(c=>{if(c.use(),c.key==="a:arcTo"){const z=c;return["A",...["wR","hR","stAng","swAng"].map(S=>String(z.attr(S)??"0"))].join(" ")}return[m[c.key]??"Z",...r(c)].join(" ")}),b=a.attr("fill"),P=a.attr("stroke");return a.attr("extrusionOk"),{...a.attr("w")?{w:a.attr("w")}:{},...a.attr("h")?{h:a.attr("h")}:{},...b===void 0||b==="norm"?{}:{fill:b},...P===!1?{stroke:!1}:{},d:v.join(" ")}});if(p.length===0)return;p.some(a=>a.fill!==void 0||a.stroke===!1)&&k(t,"approximated","a:path@fill","a freeform's paths are drawn alike: filled and outlined");const g=p[0]?.w??0,d=p[0]?.h??0,s=g>0&&d>0&&p.every(a=>(a.w??0)===g&&(a.h??0)===d),_=s?g:i&&i.width>0?i.width:g>0?g:1,h=s?d:i&&i.height>0?i.height:d>0?d:1,l=ue({av:f,gd:n,paths:p.map(a=>({d:a.d,...a.w?{w:a.w}:{},...a.h?{h:a.h}:{}}))},_,h),u=we(l.paths.map(a=>a.d).join(" "));return u?{w:_,h,steps:u}:void 0}function je(e,i,t){const o=new Map((i?.all("a:gd")??[]).map(r=>[r.attr("name")??"",r.attr("fmla")??""]));if(o.size===0)return;const f=he(e);for(const r of o.keys())f.some(m=>m.name===r)||k(t,"unread","a:gd@name",`${e} has no adjustment ${r}`);return f.map(r=>{const m=o.get(r.name),p=m===void 0?NaN:Number(/^val\s+(-?[\d.]+)$/u.exec(m.trim())?.[1]);return m!==void 0&&Number.isNaN(p)&&k(t,"approximated","a:gd@fmla",`an adjustment by a formula (${m}) is the preset's own`),(Number.isNaN(p)?r.value:p)/1e5})}function D(e,i){const t=e?.attr("name")??"",o=e?.attr("id"),f=e?.attr("descr");e?.attr("hidden")===!0&&k(i,"cannot-hold","p:cNvPr@hidden","a shape hidden on its slide"),e?.attr("title")&&k(i,"cannot-hold","p:cNvPr@title","an alternative text's title");let r;const m=e?.one("a:hlinkClick");m?.attr("action")==="ppaction://media"?m.consume():m&&(r=ve(m,i,"a:hlinkClick"));const p=e?.one("a:hlinkHover");return p&&(k(i,"cannot-hold","a:hlinkHover","a link followed when the pointer is over a shape"),p.consume()),{name:t,...r===void 0?{}:{link:r},...o===void 0?{}:{id:String(o)},...f?{alt:f}:{}}}export function shapesOf(e,i,t=ae){const o=[];if(!e)return o;for(const f of e.kids())switch(f.key){case"p:nvGrpSpPr":case"p:grpSpPr":t===ae&&f.consume();break;case"p:sp":o.push(...ze(f,i,t));break;case"p:cxnSp":o.push(...Te(f,i,t));break;case"p:pic":o.push(...ce(f,i,t));break;case"p:graphicFrame":o.push(...Ae(f,i,t));break;case"p:grpSp":o.push(...Ee(f,i,t));break;case"p:contentPart":f.use(),k(i,"cannot-hold","p:contentPart","ink"),f.consume();break;default:break}return o}const H=(e,i,t)=>{const o=`${e.where} › "${t||"unnamed"}"`;return i.label(o),{...e,where:o}},Me=["noGrp","noUngrp","noSelect","noChangeAspect","noEditPoints","noAdjustHandles","noChangeArrowheads","noChangeShapeType","noTextEdit","noCrop","noDrilldown"];function I(e,i){if(!e)return!1;const t=W(e),o=e.key!=="a:graphicFrameLocks",f=t.attr("noMove")===!0,n=t.attr("noResize")===!0,r=o&&t.attr("noRot")===!0;return t.ignore(Me,"locks against editing in PowerPoint"),W(e).one("a:extLst")?.skip("a lock's extensions"),f&&n?!0:((f||n||r)&&k(i,"cannot-hold",`${e.key}@${[f&&"noMove",n&&"noResize",r&&"noRot"].filter(Boolean).join(",")}`,"a shape locked against some changes and not others: a deck locks moving, sizing and turning together"),!1)}const Fe={};function ze(e,i,t){e.use();const o=e.one("p:nvSpPr"),f=o?.one("p:cNvPr"),n=H(i,e,f?.el.attrs.find(y=>y.key==="name")?.value??""),r=D(f,n),m=o?.one("p:cNvSpPr");I(m?.one("a:spLocks"),n)&&(r.locked=!0);const p=m?.attr("txBox")===!0,g=o?.one("p:nvPr");g?.ignore(["isPhoto","userDrawn"],"a shape's origin in PowerPoint");const d=g?.one("p:ph"),s=e.one("p:spPr");s?.ignore(["bwMode"],"a shape's black and white printing mode");const _=Y(s?.one("a:xfrm")),h=V(_&&t.place(_)),l=s?.one("a:prstGeom"),u=l?.attr("prst"),a=Q(s,n,!0),v=s?.one("a:ln"),b=X(v,n),P=s?.one("a:effectLst"),c=d||p?{}:oe(e.one("p:style"),n),z=P?J(P,n):c.shadow,S=P?K(P,n):re(c);P||te(c,n),(d||p)&&e.one("p:style")?.skip("a placeholder's or a text box's style: its own properties are what it shows");const w=a?.group?t.fill:a;a?.group&&!t.fill&&k(n,"approximated","a:grpFill","a group's fill outside a group is none");const N=e.one("p:txBody"),B=d!==void 0&&!n.part.includes("/slides/")&&(d.attr("type")??"obj")!=="sldNum",L=N?Le(N,d&&!n.part.includes("/slideMasters/")?Fe:Pe,n,B):void 0;if(L&&c.font==="+mj-lt")for(const y of L.paragraphs)for(const O of y.runs)O.font?.name===void 0&&O.text!=="\v"&&(O.font={...O.font,name:"+mj-lt"});const A={...r,kind:"autoshape",...h,...w?.fill!==void 0?{fill:w.fill}:w?.gradient||w?.pattern||w?.picture_fill?{}:d?{}:p?{fill:null}:c.fill!==void 0?{fill:c.fill}:c.gradient||c.pattern||c.picture_fill?{}:{fill:null},...(w?.fill_transparency??(w?void 0:c.fill_transparency))===void 0?{}:{fill_transparency:w?.fill_transparency??c.fill_transparency??0},...w?.gradient??(w?void 0:c.gradient)?{gradient:w?.gradient??c.gradient}:{},...w?.pattern??(w?void 0:c.pattern)?{pattern:w?.pattern??c.pattern}:{},...w?.picture_fill??(w?void 0:c.picture_fill)?{picture_fill:w?.picture_fill??c.picture_fill}:{},...z?{shadow:z}:{},...S,...b.line!==void 0?{line:b.line}:d?{}:p?{}:{line:c.line??null},...(b.line_width??(d?void 0:c.line_width))===void 0?{}:{line_width:b.line_width??c.line_width},...(b.line_dash??c.line_dash)===void 0?{}:{line_dash:b.line_dash??c.line_dash},...se(b,c),...(b.line_begin??c.line_begin)===void 0?{}:{line_begin:b.line_begin??c.line_begin},...(b.line_end??c.line_end)===void 0?{}:{line_end:b.line_end??c.line_end},...b.line_begin_size===void 0?{}:{line_begin_size:b.line_begin_size},...b.line_end_size===void 0?{}:{line_end_size:b.line_end_size},...c.text_color===void 0?{}:{text_color:c.text_color},...L?{text:L}:{},...t.group===void 0?{}:{group:t.group}};if(d){const y=d.attr("type")??"obj",O=d.attr("idx")??0;d.ignore(["hasCustomPrompt"],"a placeholder's own prompt text");const $=d.attr("orient")==="vert"?{orient:"vert"}:{};if(d.attr("sz"),y==="sldImg"||y==="hdr")return[];const j=ie.has(y)?y:y==="clipArt"||y==="chart"||y==="tbl"||y==="dgm"?"obj":"body";return ie.has(y)||k(n,"approximated","p:ph@type",`a ${y} placeholder is a${j==="obj"?"n object":" body"} placeholder`),u!==void 0&&u!=="rect"?[{...A,kind:"placeholder",placeholder:{type:j,idx:O,...$},geometry:u,...ee(u,l?.one("a:avLst"),n)}]:(l?.one("a:avLst"),[{...A,kind:"placeholder",placeholder:{type:j,idx:O,...$}}])}const C=s?.one("a:custGeom"),M=C?Oe(C,h.frame,n):void 0;C&&!M&&k(n,"approximated","a:custGeom","a freeform with no outline is a rectangle");const U=u!==void 0&&Se.has(u)?u:"rect";return[{...A,kind:p?"textbox":"autoshape",...M?{path:M}:{geometry:U},...u===void 0||M?{}:ee(u,l?.one("a:avLst"),n)}]}const re=e=>({...e.inner_shadow?{inner_shadow:e.inner_shadow}:{},...e.glow?{glow:e.glow}:{},...e.reflection?{reflection:e.reflection}:{},...e.soft_edges===void 0?{}:{soft_edges:e.soft_edges}}),se=(e,i)=>({...(e.line_cap??i.line_cap)===void 0?{}:{line_cap:e.line_cap??i.line_cap},...(e.line_join??i.line_join)===void 0?{}:{line_join:e.line_join??i.line_join},...(e.line_compound??i.line_compound)===void 0?{}:{line_compound:e.line_compound??i.line_compound}}),ee=(e,i,t)=>{const o=je(e,i,t);return o?{adjustments:o}:{}};function Te(e,i,t){e.use();const o=e.one("p:nvCxnSpPr"),f=o?.one("p:cNvPr"),n=H(i,e,f?.el.attrs.find(c=>c.key==="name")?.value??""),r=D(f,n),m=o?.one("p:cNvCxnSpPr");I(m?.one("a:cxnSpLocks"),n)&&(r.locked=!0);const p={};for(const[c,z]of[["begin","a:stCxn"],["end","a:endCxn"]]){const S=m?.one(z);if(!S)continue;const w=S.attr("id"),N=S.attr("idx");w!==void 0&&N!==void 0&&(p[c]={id:String(w),site:N}),S.consume()}o?.one("p:nvPr");const g=e.one("p:spPr");g?.ignore(["bwMode"],"a shape's black and white printing mode");const d=Y(g?.one("a:xfrm")),s=g?.one("a:prstGeom"),_=s?.attr("prst")??"line",h=ee(_,s?.one("a:avLst"),n),l=oe(e.one("p:style"),n),u=X(g?.one("a:ln"),n),a=g?.one("a:effectLst"),v=a?J(a,n):l.shadow,b=a?K(a,n):re(l);a||te(l,n);const P=ke(_);return P||k(n,"approximated","a:prstGeom@prst",`a connector of the ${_} preset is a shape of it with no fill`),[{...r,kind:"autoshape",geometry:_,...h,...V(d&&t.place(d)),...P?{}:{fill:null},line:u.line??l.line??null,...(u.line_width??l.line_width)===void 0?{}:{line_width:u.line_width??l.line_width},...(u.line_dash??l.line_dash)===void 0?{}:{line_dash:u.line_dash??l.line_dash},...se(u,l),...(u.line_begin??l.line_begin)===void 0?{}:{line_begin:u.line_begin??l.line_begin},...(u.line_end??l.line_end)===void 0?{}:{line_end:u.line_end??l.line_end},...u.line_begin_size===void 0?{}:{line_begin_size:u.line_begin_size},...u.line_end_size===void 0?{}:{line_end_size:u.line_end_size},...v?{shadow:v}:{},...b,...t.group===void 0?{}:{group:t.group},...p.begin||p.end?{glue:p}:{}}]}function ce(e,i,t){e.use();const o=e.one("p:nvPicPr"),f=o?.one("p:cNvPr"),n=H(i,e,f?.el.attrs.find(x=>x.key==="name")?.value??""),r=D(f,n),m=o?.one("p:cNvPicPr");I(m?.one("a:picLocks"),n)&&(r.locked=!0),m?.attr("preferRelativeResize");const p=o?.one("p:nvPr");p?.ignore(["isPhoto","userDrawn"],"a shape's origin in PowerPoint");const g=p?.one("p:ph"),d=p?.one("a:videoFile"),s=p?.choice("a:audioFile","a:wavAudioFile","a:audioCd","a:quickTimeFile"),_=p?.one("p:extLst")?.all("p:ext").flatMap(x=>{const F=x.one("p14:media");return F?[F]:[]})[0],h=n.read.pkg,l=s?.key==="a:audioFile"?W(s):void 0,u=h.rel(n.part,_?.attr("r:embed"))??h.rel(n.part,d?.attr("r:link"))??h.rel(n.part,l?.attr("r:link"));let a;if(_){_.attr("r:link");const x=_.one("p14:trim"),F=T=>{const E=T===void 0||T===""?NaN:Number(T);return Number.isFinite(E)&&E>0?Math.round(E*1e3)/1e6:void 0},Z=F(x?.attr("st")),q=F(x?.attr("end"));(Z!==void 0||q!==void 0)&&(a={...Z===void 0?{}:{start:Z},...q===void 0?{}:{end:q}});for(const T of["p14:fade","p14:bmkLst"]){const E=_.one(T);E&&(k(n,"cannot-hold",T,T==="p14:fade"?"a video's fade in and out":"a video's bookmarks"),E.consume())}}l?(l.attr("r:link"),l.one("a:extLst")?.skip("a sound's extensions")):s&&(k(n,"cannot-hold",s.key,"a sound from a CD or of another kind"),s.consume());const v=e.one("p:blipFill");v?.ignore(["dpi","rotWithShape"],"a picture's resolution and turning with its fill");const b=v?.one("a:blip");b?.ignore(["cstate"],"a picture's compression state");const P=b?.one("a:extLst")?.all("a:ext").flatMap(x=>{const F=x.one("asvg:svgBlip");return x.one("a14:useLocalDpi")?.skip("a picture kept at its own resolution"),F?[F]:[]})[0],c=h.rel(n.part,P?.attr("r:embed"))??h.rel(n.part,b?.attr("r:embed"));b?.attr("r:link")&&k(n,"missing","a:blip@r:link","a picture linked from outside the file");for(const x of b?.kids()??[])x.key!=="a:extLst"&&(x.use(),k(n,"cannot-hold",x.key,"a picture's own effect (transparency, recolouring, brightness)"),x.consume());const S=v?.one("a:srcRect"),w=x=>(S?.attr(x)??0)/1e5,N=S?{left:w("l"),top:w("t"),right:w("r"),bottom:w("b")}:void 0;v?.one("a:stretch")?.consume();const B=v?.one("a:tile");B&&(k(n,"cannot-hold","a:tile","a picture tiled in its frame"),B.consume());const L=e.one("p:spPr");L?.ignore(["bwMode"],"a shape's black and white printing mode");const A=Y(L?.one("a:xfrm")),C=L?.one("a:prstGeom"),M=C?.attr("prst");C?.one("a:avLst"),M!==void 0&&M!=="rect"&&k(n,"cannot-hold","a:prstGeom@prst",`a picture cut to a ${M}`);const U=L?.one("a:ln");U&&X(U,n).line&&k(n,"cannot-hold","p:pic/a:ln","a picture's outline");const y=J(L?.one("a:effectLst"),n),O=K(L?.one("a:effectLst"),n),$=Q(L,n);($?.fill||$?.gradient)&&k(n,"cannot-hold","p:pic/p:spPr","a fill behind a picture"),e.one("p:style")?.skip("a picture's style");const j=l!==void 0,G=!j&&(d!==void 0||_!==void 0&&!s),R=G||j?u:c;if(!R||R.external)return k(n,"missing","p:pic","a picture or a video whose file is not in the file"),[];if(!h.bytes(R.target))return k(n,"missing","p:pic",`a picture or a video whose part (${R.target}) is not in the file`),[];if(G&&(c&&(h.bytes(c.target),k(n,"approximated","p:pic/p:blipFill","a video's own poster picture: a deck's video shows a moment of itself (its `poster`, the start unless said)")),N&&Object.values(N).some(x=>x!==0)&&k(n,"cannot-hold","a:srcRect","a video's crop"),d?.attr("r:link")),j&&c){const x=h.bytes(c.target);x&&!be(x,_e)&&k(n,"approximated","p:pic/p:blipFill","a sound's own icon: a deck draws a sound as its speaker")}const ne=r.alt!==void 0&&/^[^\s/\\]+\.[A-Za-z0-9]{2,5}$/u.test(r.alt);ne&&f?.ignore(["descr"],"a picture's file name as its description (python-pptx's habit)");const fe=r.alt===void 0||ne?{}:{alt:r.alt};return[{name:r.name,...r.id===void 0?{}:{id:r.id},...r.locked?{locked:!0}:{},...r.link===void 0?{}:{link:r.link},...(G||j)&&a?{playback:{trim:a}}:{},...fe,kind:j?"audio":G?"movie":"picture",...g?{placeholder:{type:g.attr("type")??"pic",idx:g.attr("idx")??0}}:{},...V(A&&t.place(A)),part:R.target,...N&&!G?{crop:N}:{},...y?{shadow:y}:{},...O,...t.group===void 0?{}:{group:t.group}}]}function Ae(e,i,t){e.use();const o=e.one("p:nvGraphicFramePr"),f=o?.one("p:cNvPr"),n=H(i,e,f?.el.attrs.find(l=>l.key==="name")?.value??""),r=D(f,n);I(o?.one("p:cNvGraphicFramePr")?.one("a:graphicFrameLocks"),n)&&(r.locked=!0);const m=o?.one("p:nvPr")?.one("p:ph");m&&(k(n,"approximated","p:ph","a table, a chart or an object in a placeholder is the slide's own, its placeholder left empty"),m.consume()),e.ignore(["bwMode"],"a shape's black and white printing mode");const p=Y(e.one("p:xfrm")),g=V(p&&t.place(p)),d=e.one("a:graphic")?.one("a:graphicData"),s=d?.attr("uri")??"",_={...r,...g,...t.group===void 0?{}:{group:t.group}};if(s.endsWith("/table")){const l=d?.one("a:tbl");if(l)return[{..._,kind:"table",table:ye(l.use(),n)}]}if(s.endsWith("/chart")){const l=d?.one("c:chart");l?.use();const u=n.read.pkg.rel(n.part,l?.attr("r:id")),a=u?xe(u.target,n):"its chart is not in the file";return typeof a=="string"?(k(n,"cannot-hold","c:chart",a),[]):[{..._,kind:"chart",chart:a}]}if(s.endsWith("/diagram"))return k(n,"cannot-hold","dgm:relIds","SmartArt"),d?.consume(),[];const h=d?.one("p:oleObj");if(h){h.use(),k(n,"approximated","p:oleObj",`an embedded ${h.attr("progId")??"object"} is its picture`),h.ignore(["spid","name","showAsIcon","r:id","imgW","imgH","progId"],"an embedded object's program and size"),h.one("p:embed")?.consume(),h.one("p:link")?.consume();const l=h.one("p:pic");if(l){const[a]=ce(l,i,t);return a?[{...a,...r,...g,kind:"picture"}]:[]}const u=Ce(h.el.attrs.find(a=>a.key==="spid")?.value,n);return u?[{..._,kind:"picture",part:u}]:(k(n,"missing","p:oleObj","an embedded object whose picture is not in the file"),[])}return k(n,"cannot-hold","a:graphicData",s||"a graphic frame"),d?.consume(),[]}const de="urn:schemas-microsoft-com:vml",le="urn:schemas-microsoft-com:office:office";function Ce(e,i){const t=i.read.pkg,o=t.relOfType(i.part,"vmlDrawing")?.target,f=o===void 0?void 0:t.bytes(o);if(o===void 0||!f||e===void 0)return;let n;try{n=me(ge(f))}catch{return}const r=(s,_,h)=>s.attrs.find(l=>l.uri===_&&l.local===h)?.value,m=s=>[s,...s.children.flatMap(m)],g=m(n).find(s=>s.uri===de&&(r(s,"","id")===e||r(s,le,"spid")===e))?.children.find(s=>s.uri===de&&s.local==="imagedata"),d=t.rel(o,g&&r(g,le,"relid"));if(!(!d||d.external||!t.bytes(d.target)))return d.target}function Ee(e,i,t){e.use();const o=e.one("p:nvGrpSpPr"),f=o?.one("p:cNvPr"),n=H(i,e,f?.el.attrs.find(h=>h.key==="name")?.value??""),r=D(f,n),m=I(o?.one("p:cNvGrpSpPr")?.one("a:grpSpLocks"),n);o?.one("p:nvPr");const p=e.one("p:grpSpPr");p?.ignore(["bwMode"],"a shape's black and white printing mode");const g=Q(p,n),d=p?.one("a:effectLst");d&&(k(n,"cannot-hold","p:grpSpPr/a:effectLst","a group's own effects"),d.consume());const s=r.name.replaceAll("/","-");return shapesOf(e,n,{...g&&!g.group?{fill:g}:t.fill?{fill:t.fill}:{},group:t.group===void 0?s:`${t.group}/${s}`,place:Ne(p?.one("a:xfrm"),t)}).map(h=>({...h,...m?{locked:!0}:{},...r.link!==void 0&&h.link===void 0?{link:r.link}:{}}))}
|