@office-open/core 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/chart/index.d.mts +2 -2
  2. package/dist/chart/index.mjs +2 -2
  3. package/dist/{chart-Kf_utasF.mjs → chart-BAnjzVoe.mjs} +861 -287
  4. package/dist/chart-BAnjzVoe.mjs.map +1 -0
  5. package/dist/data-type-CZMKVaaT.d.mts.map +1 -1
  6. package/dist/descriptor/index.d.mts +1 -1
  7. package/dist/descriptor/index.mjs +1 -1
  8. package/dist/{descriptor-BX8xW8na.mjs → descriptor-BqaNZrrZ.mjs} +38 -10
  9. package/dist/{descriptor-BX8xW8na.mjs.map → descriptor-BqaNZrrZ.mjs.map} +1 -1
  10. package/dist/drawing/index.d.mts +2 -2
  11. package/dist/drawing/index.mjs +2 -2
  12. package/dist/{drawing-FBzd2I0m.mjs → drawing-BVwCkNXB.mjs} +3062 -3131
  13. package/dist/drawing-BVwCkNXB.mjs.map +1 -0
  14. package/dist/{generators-CElPsAhd.mjs → ext-uri-BHBcIrW7.mjs} +599 -343
  15. package/dist/ext-uri-BHBcIrW7.mjs.map +1 -0
  16. package/dist/index-BAxlDUQ1.d.mts +590 -0
  17. package/dist/index-BAxlDUQ1.d.mts.map +1 -0
  18. package/dist/{index-CLX7gU9J.d.mts → index-BQLIofaF.d.mts} +3 -2
  19. package/dist/index-BQLIofaF.d.mts.map +1 -0
  20. package/dist/{index-k8WKLXnA.d.mts → index-CaNwM5_e.d.mts} +19 -20
  21. package/dist/index-CaNwM5_e.d.mts.map +1 -0
  22. package/dist/{index-CnjCK-lF.d.mts → index-DPkf_CtG.d.mts} +566 -597
  23. package/dist/index-DPkf_CtG.d.mts.map +1 -0
  24. package/dist/{index-BsTUn4K1.d.mts → index-DcukVskh.d.mts} +9 -6
  25. package/dist/index-DcukVskh.d.mts.map +1 -0
  26. package/dist/{index-Cgz88FU0.d.mts → index-Di6XPdGl.d.mts} +26 -12
  27. package/dist/index-Di6XPdGl.d.mts.map +1 -0
  28. package/dist/{index-C0ClOhmZ.d.mts → index-L6AXewfV.d.mts} +11 -8
  29. package/dist/index-L6AXewfV.d.mts.map +1 -0
  30. package/dist/{index-DxwLMnBF.d.mts → index-k1h_t946.d.mts} +219 -99
  31. package/dist/index-k1h_t946.d.mts.map +1 -0
  32. package/dist/index.d.mts +161 -29
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +873 -87
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/{output-D_G_JR_8.d.mts → output-yyxdkG0C.d.mts} +2 -3
  37. package/dist/output-yyxdkG0C.d.mts.map +1 -0
  38. package/dist/patch/index.d.mts +2 -2
  39. package/dist/patch/index.mjs +2 -2
  40. package/dist/{patch-3KLx2yEP.mjs → patch-AkQY17CD.mjs} +71 -26
  41. package/dist/patch-AkQY17CD.mjs.map +1 -0
  42. package/dist/smartart/index.d.mts +2 -2
  43. package/dist/smartart/index.mjs +1 -1
  44. package/dist/{smartart-BxnkROOp.mjs → smartart-DV6ZcN5R.mjs} +27 -26
  45. package/dist/smartart-DV6ZcN5R.mjs.map +1 -0
  46. package/dist/{style-matrix-DAP6XrLv.mjs → style-matrix-DjhMuuQg.mjs} +4 -4
  47. package/dist/style-matrix-DjhMuuQg.mjs.map +1 -0
  48. package/dist/theme/index.d.mts +4 -4
  49. package/dist/theme/index.mjs +3 -2
  50. package/dist/{theme-OAuRcA9_.mjs → theme-Dx0Db9bX.mjs} +37 -71
  51. package/dist/theme-Dx0Db9bX.mjs.map +1 -0
  52. package/dist/{theme-options-BbWccl85.d.mts → theme-options-kO89NUEX.d.mts} +17 -17
  53. package/dist/theme-options-kO89NUEX.d.mts.map +1 -0
  54. package/dist/util/index.d.mts +3 -3
  55. package/dist/util/index.mjs +3 -3
  56. package/dist/{util-C94-JKtp.mjs → util-ptE16MEk.mjs} +69 -37
  57. package/dist/util-ptE16MEk.mjs.map +1 -0
  58. package/dist/{values-aVoirbWB.d.mts → values-BECDm4zr.d.mts} +15 -31
  59. package/dist/values-BECDm4zr.d.mts.map +1 -0
  60. package/dist/vector/index.d.mts +2 -2
  61. package/dist/vector/index.mjs +2 -2
  62. package/dist/{vector-TpjW6ZSc.mjs → vector-DhLGZjP5.mjs} +104 -147
  63. package/dist/vector-DhLGZjP5.mjs.map +1 -0
  64. package/package.json +3 -3
  65. package/dist/chart-Kf_utasF.mjs.map +0 -1
  66. package/dist/drawing-FBzd2I0m.mjs.map +0 -1
  67. package/dist/generators-CElPsAhd.mjs.map +0 -1
  68. package/dist/index-BsTUn4K1.d.mts.map +0 -1
  69. package/dist/index-C0ClOhmZ.d.mts.map +0 -1
  70. package/dist/index-CLX7gU9J.d.mts.map +0 -1
  71. package/dist/index-Cgz88FU0.d.mts.map +0 -1
  72. package/dist/index-CnjCK-lF.d.mts.map +0 -1
  73. package/dist/index-DpPeyf5f.d.mts +0 -316
  74. package/dist/index-DpPeyf5f.d.mts.map +0 -1
  75. package/dist/index-DxwLMnBF.d.mts.map +0 -1
  76. package/dist/index-k8WKLXnA.d.mts.map +0 -1
  77. package/dist/output-D_G_JR_8.d.mts.map +0 -1
  78. package/dist/patch-3KLx2yEP.mjs.map +0 -1
  79. package/dist/smartart-BxnkROOp.mjs.map +0 -1
  80. package/dist/style-matrix-DAP6XrLv.mjs.map +0 -1
  81. package/dist/theme-OAuRcA9_.mjs.map +0 -1
  82. package/dist/theme-options-BbWccl85.d.mts.map +0 -1
  83. package/dist/util-C94-JKtp.mjs.map +0 -1
  84. package/dist/values-aVoirbWB.d.mts.map +0 -1
  85. package/dist/vector-TpjW6ZSc.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawing-BVwCkNXB.mjs","names":["stringify","parse","stringifyXml","stringify","parse","parse","stringify","parse","stringifyXml","stringifyDesc","parseDesc","parse","stringify","parse","parse","parse","stringify","parse","stringifyXml"],"sources":["../src/drawing/color/color-transform.ts","../src/drawing/color/preset-color.ts","../src/drawing/color/scheme-color.ts","../src/drawing/color/system-color.ts","../src/drawing/color/color-descriptors.ts","../src/drawing/color/solid-fill.ts","../src/drawing/diagram/diagram-style.ts","../src/drawing/three-d/three-d-descriptors.ts","../src/drawing/color/rgb-color.ts","../src/drawing/color/hsl-color.ts","../src/drawing/color/sc-rgb-color.ts","../src/drawing/blip/blip-descriptors.ts","../src/drawing/blip/blip-effects.ts","../src/drawing/blip/source-rectangle.ts","../src/drawing/blip/tile.ts","../src/drawing/fill/fill-descriptors.ts","../src/drawing/fill/fill-options.ts","../src/drawing/fill/no-fill.ts","../src/drawing/fill/gradient-fill.ts","../src/drawing/fill/pattern-fill.ts","../src/drawing/fill/group-fill.ts","../src/drawing/outline/custom-dash.ts","../src/drawing/outline/line-end.ts","../src/drawing/outline/outline.ts","../src/drawing/outline/outline-descriptors.ts","../src/drawing/effects/fill-overlay.ts","../src/drawing/effects/glow.ts","../src/drawing/effects/inner-shadow.ts","../src/drawing/effects/outer-shadow.ts","../src/drawing/effects/preset-shadow.ts","../src/drawing/effects/reflection.ts","../src/drawing/effects/soft-edge.ts","../src/drawing/effects/effect-list.ts","../src/drawing/effects/effect-dag.ts","../src/drawing/three-d/scene-3d.ts","../src/drawing/three-d/bevel.ts","../src/drawing/three-d/shape-3d.ts","../src/drawing/geometry/adjustment-values.ts","../src/drawing/geometry/preset-geometry.ts","../src/drawing/geometry/custom-geometry.ts","../src/drawing/blip/blip-extensions.ts","../src/drawing/blip/blip.ts","../src/drawing/blip/blip-fill.ts","../src/drawing/blip/stretch.ts","../src/drawing/transform.ts","../src/drawing/table-style.ts","../src/drawing/locking/locking.ts","../src/drawing/connection.ts","../src/drawing/non-visual/drawing-properties.ts","../src/drawing/non-visual/content-part-properties.ts","../src/drawing/diagram/layout-vars.ts","../src/drawing/diagram/headers.ts","../src/drawing/diagram/diagram-rel.ts","../src/drawing/diagram/diagram-props.ts","../src/drawing/effects/effect-descriptors.ts","../src/drawing/locking/locking-descriptors.ts","../src/drawing/geometry/geometry-descriptors.ts","../src/drawing/transform-descriptors.ts","../src/drawing/shape-properties-desc.ts","../src/drawing/group-shape-properties-desc.ts","../src/drawing/text/types.ts","../src/drawing/text/body-properties.ts","../src/drawing/text/run-properties.ts","../src/drawing/text/run.ts","../src/drawing/text/paragraph.ts","../src/drawing/text/list-style.ts","../src/drawing/text/text-body.ts","../src/drawing/diagram/diagram-descriptors.ts"],"sourcesContent":["/**\n * Color transform elements for DrawingML colors.\n *\n * This module provides color transformation elements defined in EG_ColorTransform,\n * which can be applied as child elements to any color type (srgbClr, schemeClr, etc.).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, EG_ColorTransform\n *\n * @module\n */\n\nimport { emitAngle, emitPercent } from \"../../util/converters\";\n\n/**\n * Options for color transforms. Percent fields take integer percent (`40` =\n * 40%), angle fields (`hue`/`hueOff`) take degrees; the library applies the\n * XSD scaling. Booleans emit value-less switch elements.\n */\nexport interface ColorTransformOptions {\n /** Tint: moves color toward white (0-100, where 100 = full white) */\n tint?: number;\n /** Shade: moves color toward black (0-100, where 100 = full black) */\n shade?: number;\n /** Complement: inverts the color (no value) */\n comp?: boolean;\n /** Inverse: inverts the color (no value) */\n inv?: boolean;\n /** Grayscale: converts to grayscale (no value) */\n gray?: boolean;\n /** Alpha: sets transparency (0-100, where 0 = transparent) */\n alpha?: number;\n /** Alpha offset: adjusts alpha by fixed percent (-100 to 100) */\n alphaOff?: number;\n /** Alpha modulation: scales alpha by percent (0-100) */\n alphaMod?: number;\n /** Hue: sets hue angle in degrees (0-360). */\n hue?: number;\n /** Hue offset: adjusts hue angle in degrees (-90 to 90). */\n hueOff?: number;\n /** Hue modulation: scales hue by percent (0-100) */\n hueMod?: number;\n /** Saturation: sets saturation (-100 to 100) */\n sat?: number;\n /** Saturation offset: adjusts saturation (-100 to 100) */\n satOff?: number;\n /** Saturation modulation: scales saturation (0-100) */\n satMod?: number;\n /** Luminance: sets luminance (-100 to 100) */\n lum?: number;\n /** Luminance offset: adjusts luminance (-100 to 100) */\n lumOff?: number;\n /** Luminance modulation: scales luminance (0-100) */\n lumMod?: number;\n /** Red: sets red channel (-100 to 100) */\n red?: number;\n /** Red offset: adjusts red channel (-100 to 100) */\n redOff?: number;\n /** Red modulation: scales red channel (0-100) */\n redMod?: number;\n /** Green: sets green channel (-100 to 100) */\n green?: number;\n /** Green offset: adjusts green channel (-100 to 100) */\n greenOff?: number;\n /** Green modulation: scales green channel (0-100) */\n greenMod?: number;\n /** Blue: sets blue channel (-100 to 100) */\n blue?: number;\n /** Blue offset: adjusts blue channel (-100 to 100) */\n blueOff?: number;\n /** Blue modulation: scales blue channel (0-100) */\n blueMod?: number;\n /** Gamma correction (no value) */\n gamma?: boolean;\n /** Inverse gamma correction (no value) */\n invGamma?: boolean;\n}\n\ntype TransformKey = keyof ColorTransformOptions & string;\n\n/**\n * Transform keys classified by XSD unit — the single source of truth shared by\n * stringify and parse. Percent keys take integer percent (e.g. `50` = 50%,\n * scaled ×1000); angle keys take degrees (scaled ×60000); value-less boolean\n * keys (comp/inv/gray/gamma/invGamma) belong to neither set.\n */\nexport const PERCENT_TRANSFORMS: ReadonlySet<TransformKey> = new Set<TransformKey>([\n \"tint\",\n \"shade\",\n \"alpha\",\n \"alphaOff\",\n \"alphaMod\",\n \"hueMod\",\n \"sat\",\n \"satOff\",\n \"satMod\",\n \"lum\",\n \"lumOff\",\n \"lumMod\",\n \"red\",\n \"redOff\",\n \"redMod\",\n \"green\",\n \"greenOff\",\n \"greenMod\",\n \"blue\",\n \"blueOff\",\n \"blueMod\",\n]);\n\nexport const ANGLE_TRANSFORMS: ReadonlySet<TransformKey> = new Set<TransformKey>([\"hue\", \"hueOff\"]);\n\n/** Value-less switch transforms (empty elements — presence is the semantics). */\nexport const BOOLEAN_TRANSFORMS: ReadonlySet<TransformKey> = new Set<TransformKey>([\n \"comp\",\n \"inv\",\n \"gray\",\n \"gamma\",\n \"invGamma\",\n]);\n\n/** Scale a transform value to its XSD unit; non-percent/angle keys pass through. */\nexport function emitTransformValue(key: TransformKey, value: number): number {\n if (PERCENT_TRANSFORMS.has(key)) return emitPercent(value);\n if (ANGLE_TRANSFORMS.has(key)) return emitAngle(value);\n return value;\n}\n\n/**\n * Serialize color transforms, preserving the key order of the options object.\n *\n * EG_ColorTransform is an unordered XSD choice, but the sequence is\n * semantically significant (transforms compose left to right), so the caller's\n * key order is the emission order and round-trips come back in source order —\n * plain JS objects preserve insertion order.\n *\n * @example\n * ```typescript\n * // Lighten accent1 by 40%\n * createColorTransforms({ tint: 40 });\n * // Semi-transparent red with 50% alpha\n * createColorTransforms({ alpha: 50 });\n * ```\n */\nexport const createColorTransforms = (options: ColorTransformOptions): readonly string[] => {\n const t: string[] = [];\n\n for (const [name, value] of Object.entries(options)) {\n const key = name as TransformKey;\n if (value === undefined || value === false) continue;\n if (value === true) {\n t.push(`<a:${key}/>`);\n continue;\n }\n t.push(`<a:${key} val=\"${emitTransformValue(key, value)}\"/>`);\n }\n\n return t;\n};\n","/**\n * Preset color element for DrawingML.\n *\n * This module provides named preset colors (CSS named colors).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetColor / ST_PresetColorVal\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * Preset color values (CSS named colors).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PresetColorVal\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"aliceBlue\"/>\n * ...\n * <xsd:enumeration value=\"yellowGreen\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const PresetColor = {\n ALICE_BLUE: \"aliceBlue\",\n ANTIQUE_WHITE: \"antiqueWhite\",\n AQUA: \"aqua\",\n AQUAMARINE: \"aquamarine\",\n AZURE: \"azure\",\n BEIGE: \"beige\",\n BISQUE: \"bisque\",\n BLACK: \"black\",\n BLANCHED_ALMOND: \"blanchedAlmond\",\n BLUE: \"blue\",\n BLUE_VIOLET: \"blueViolet\",\n BROWN: \"brown\",\n BURLY_WOOD: \"burlyWood\",\n CADET_BLUE: \"cadetBlue\",\n CHARTREUSE: \"chartreuse\",\n CHOCOLATE: \"chocolate\",\n CORAL: \"coral\",\n CORNFLOWER_BLUE: \"cornflowerBlue\",\n CORNSILK: \"cornsilk\",\n CRIMSON: \"crimson\",\n CYAN: \"cyan\",\n DARK_BLUE: \"darkBlue\",\n DARK_CYAN: \"darkCyan\",\n DARK_GOLDENROD: \"darkGoldenrod\",\n DARK_GRAY: \"darkGray\",\n DARK_GREY: \"darkGrey\",\n DARK_GREEN: \"darkGreen\",\n DARK_KHAKI: \"darkKhaki\",\n DARK_MAGENTA: \"darkMagenta\",\n DARK_OLIVE_GREEN: \"darkOliveGreen\",\n DARK_ORANGE: \"darkOrange\",\n DARK_ORCHID: \"darkOrchid\",\n DARK_RED: \"darkRed\",\n DARK_SALMON: \"darkSalmon\",\n DARK_SEA_GREEN: \"darkSeaGreen\",\n DARK_SLATE_BLUE: \"darkSlateBlue\",\n DARK_SLATE_GRAY: \"darkSlateGray\",\n DARK_SLATE_GREY: \"darkSlateGrey\",\n DARK_TURQUOISE: \"darkTurquoise\",\n DARK_VIOLET: \"darkViolet\",\n DEEP_PINK: \"deepPink\",\n DEEP_SKY_BLUE: \"deepSkyBlue\",\n DIM_GRAY: \"dimGray\",\n DIM_GREY: \"dimGrey\",\n DODGER_BLUE: \"dodgerBlue\",\n FIREBRICK: \"firebrick\",\n FLORAL_WHITE: \"floralWhite\",\n FOREST_GREEN: \"forestGreen\",\n FUCHSIA: \"fuchsia\",\n GAINSBORO: \"gainsboro\",\n GHOST_WHITE: \"ghostWhite\",\n GOLD: \"gold\",\n GOLDENROD: \"goldenrod\",\n GRAY: \"gray\",\n GREY: \"grey\",\n GREEN: \"green\",\n GREEN_YELLOW: \"greenYellow\",\n HONEYDEW: \"honeydew\",\n HOT_PINK: \"hotPink\",\n INDIAN_RED: \"indianRed\",\n INDIGO: \"indigo\",\n IVORY: \"ivory\",\n KHAKI: \"khaki\",\n LAVENDER: \"lavender\",\n LAVENDER_BLUSH: \"lavenderBlush\",\n LAWN_GREEN: \"lawnGreen\",\n LEMON_CHIFFON: \"lemonChiffon\",\n LIGHT_BLUE: \"lightBlue\",\n LIGHT_CORAL: \"lightCoral\",\n LIGHT_CYAN: \"lightCyan\",\n LIGHT_GOLDENROD_YELLOW: \"lightGoldenrodYellow\",\n LIGHT_GRAY: \"lightGray\",\n LIGHT_GREY: \"lightGrey\",\n LIGHT_GREEN: \"lightGreen\",\n LIGHT_PINK: \"lightPink\",\n LIGHT_SALMON: \"lightSalmon\",\n LIGHT_SEA_GREEN: \"lightSeaGreen\",\n LIGHT_SKY_BLUE: \"lightSkyBlue\",\n LIGHT_SLATE_GRAY: \"lightSlateGray\",\n LIGHT_SLATE_GREY: \"lightSlateGrey\",\n LIGHT_STEEL_BLUE: \"lightSteelBlue\",\n LIGHT_YELLOW: \"lightYellow\",\n LIME: \"lime\",\n LIME_GREEN: \"limeGreen\",\n LINEN: \"linen\",\n MAGENTA: \"magenta\",\n MAROON: \"maroon\",\n MEDIUM_AQUAMARINE: \"mediumAquamarine\",\n MEDIUM_BLUE: \"mediumBlue\",\n MEDIUM_ORCHID: \"mediumOrchid\",\n MEDIUM_PURPLE: \"mediumPurple\",\n MEDIUM_SEA_GREEN: \"mediumSeaGreen\",\n MEDIUM_SLATE_BLUE: \"mediumSlateBlue\",\n MEDIUM_SPRING_GREEN: \"mediumSpringGreen\",\n MEDIUM_TURQUOISE: \"mediumTurquoise\",\n MEDIUM_VIOLET_RED: \"mediumVioletRed\",\n MIDNIGHT_BLUE: \"midnightBlue\",\n MINT_CREAM: \"mintCream\",\n MISTY_ROSE: \"mistyRose\",\n MOCCASIN: \"moccasin\",\n NAVAJO_WHITE: \"navajoWhite\",\n NAVY: \"navy\",\n OLD_LACE: \"oldLace\",\n OLIVE: \"olive\",\n OLIVE_DRAB: \"oliveDrab\",\n ORANGE: \"orange\",\n ORANGE_RED: \"orangeRed\",\n ORCHID: \"orchid\",\n PALE_GOLDENROD: \"paleGoldenrod\",\n PALE_GREEN: \"paleGreen\",\n PALE_TURQUOISE: \"paleTurquoise\",\n PALE_VIOLET_RED: \"paleVioletRed\",\n PAPAYA_WHIP: \"papayaWhip\",\n PEACH_PUFF: \"peachPuff\",\n PERU: \"peru\",\n PINK: \"pink\",\n PLUM: \"plum\",\n POWDER_BLUE: \"powderBlue\",\n PURPLE: \"purple\",\n RED: \"red\",\n ROSY_BROWN: \"rosyBrown\",\n ROYAL_BLUE: \"royalBlue\",\n SADDLE_BROWN: \"saddleBrown\",\n SALMON: \"salmon\",\n SANDY_BROWN: \"sandyBrown\",\n SEA_GREEN: \"seaGreen\",\n SEA_SHELL: \"seaShell\",\n SIENNA: \"sienna\",\n SILVER: \"silver\",\n SKY_BLUE: \"skyBlue\",\n SLATE_BLUE: \"slateBlue\",\n SLATE_GRAY: \"slateGray\",\n SLATE_GREY: \"slateGrey\",\n SNOW: \"snow\",\n SPRING_GREEN: \"springGreen\",\n STEEL_BLUE: \"steelBlue\",\n TAN: \"tan\",\n TEAL: \"teal\",\n THISTLE: \"thistle\",\n TOMATO: \"tomato\",\n TURQUOISE: \"turquoise\",\n VIOLET: \"violet\",\n WHEAT: \"wheat\",\n WHITE: \"white\",\n WHITE_SMOKE: \"whiteSmoke\",\n YELLOW: \"yellow\",\n YELLOW_GREEN: \"yellowGreen\",\n} as const;\n\n/**\n * Options for preset color.\n */\nexport interface PresetColorOptions {\n /** Preset color value */\n value: (typeof PresetColor)[keyof typeof PresetColor];\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n/**\n * Creates a preset color element as an XML string.\n *\n * Specifies a color using a named preset (CSS named color).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PresetColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"val\" type=\"ST_PresetColorVal\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createPresetColor = (options: PresetColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\"a:prstClr\", { val: options.value }, transforms);\n};\n","/**\n * Scheme color element for DrawingML shapes.\n *\n * This module provides scheme-based color support for solid fills,\n * allowing colors to be defined using theme color schemes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SchemeColor / ST_SchemeColorVal\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * Options for scheme color.\n */\nexport interface SchemeColorOptions {\n /** Scheme color value */\n value: (typeof SchemeColor)[keyof typeof SchemeColor];\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n// <xsd:simpleType name=\"ST_SchemeColorVal\">\n// <xsd:restriction base=\"xsd:string\">\n// <xsd:enumeration value=\"bg1\"/>\n// <xsd:enumeration value=\"tx1\"/>\n// <xsd:enumeration value=\"bg2\"/>\n// <xsd:enumeration value=\"tx2\"/>\n// <xsd:enumeration value=\"accent1\"/>\n// <xsd:enumeration value=\"accent2\"/>\n// <xsd:enumeration value=\"accent3\"/>\n// <xsd:enumeration value=\"accent4\"/>\n// <xsd:enumeration value=\"accent5\"/>\n// <xsd:enumeration value=\"accent6\"/>\n// <xsd:enumeration value=\"hlink\"/>\n// <xsd:enumeration value=\"folHlink\"/>\n// <xsd:enumeration value=\"dk1\"/>\n// <xsd:enumeration value=\"lt1\"/>\n// <xsd:enumeration value=\"dk2\"/>\n// <xsd:enumeration value=\"lt2\"/>\n// <xsd:enumeration value=\"phClr\"/>\n// </xsd:restriction>\n// </xsd:simpleType>\n\n// Cspell:ignore folHlink, phClr, hlink\n\n/**\n * Scheme color values for theme-based colors.\n *\n * These values reference colors defined in the document's color scheme/theme.\n */\nexport const SchemeColor = {\n /** Background color 1 */\n BG1: \"bg1\",\n /** Text color 1 */\n TX1: \"tx1\",\n /** Background color 2 */\n BG2: \"bg2\",\n /** Text color 2 */\n TX2: \"tx2\",\n /** Accent color 1 */\n ACCENT1: \"accent1\",\n /** Accent color 2 */\n ACCENT2: \"accent2\",\n /** Accent color 3 */\n ACCENT3: \"accent3\",\n /** Accent color 4 */\n ACCENT4: \"accent4\",\n /** Accent color 5 */\n ACCENT5: \"accent5\",\n /** Accent color 6 */\n ACCENT6: \"accent6\",\n /** Hyperlink color */\n HLINK: \"hlink\",\n /** Followed hyperlink color */\n FOLHLINK: \"folHlink\",\n /** Dark color 1 */\n DK1: \"dk1\",\n /** Light color 1 */\n LT1: \"lt1\",\n /** Dark color 2 */\n DK2: \"dk2\",\n /** Light color 2 */\n LT2: \"lt2\",\n /** Placeholder color */\n PHCLR: \"phClr\",\n} as const;\n\n/**\n * Creates a scheme color element as an XML string.\n *\n * Specifies a color using a theme color scheme reference.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SchemeColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"val\" type=\"ST_SchemeColorVal\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * const accentColor = createSchemeColor({ value: SchemeColor.ACCENT1 });\n * // With tint transform\n * const lightAccent = createSchemeColor({\n * value: SchemeColor.ACCENT1,\n * transforms: { tint: 40 },\n * });\n * ```\n */\nexport const createSchemeColor = (options: SchemeColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\"a:schemeClr\", { val: options.value }, transforms);\n};\n","/**\n * System color element for DrawingML.\n *\n * This module provides system color support, referencing OS-level UI colors.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SystemColor / ST_SystemColorVal\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { HexColor } from \"../../util/values\";\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * System color values referencing OS UI colors.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_SystemColorVal\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"scrollBar\"/>\n * <xsd:enumeration value=\"background\"/>\n * ...\n * <xsd:enumeration value=\"menuBar\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const SystemColor = {\n SCROLL_BAR: \"scrollBar\",\n BACKGROUND: \"background\",\n ACTIVE_CAPTION: \"activeCaption\",\n INACTIVE_CAPTION: \"inactiveCaption\",\n MENU: \"menu\",\n WINDOW: \"window\",\n WINDOW_FRAME: \"windowFrame\",\n MENU_TEXT: \"menuText\",\n WINDOW_TEXT: \"windowText\",\n CAPTION_TEXT: \"captionText\",\n ACTIVE_BORDER: \"activeBorder\",\n INACTIVE_BORDER: \"inactiveBorder\",\n APP_WORKSPACE: \"appWorkspace\",\n HIGHLIGHT: \"highlight\",\n HIGHLIGHT_TEXT: \"highlightText\",\n BTN_FACE: \"btnFace\",\n BTN_SHADOW: \"btnShadow\",\n GRAY_TEXT: \"grayText\",\n BTN_TEXT: \"btnText\",\n INACTIVE_CAPTION_TEXT: \"inactiveCaptionText\",\n BTN_HIGHLIGHT: \"btnHighlight\",\n THREE_D_DK_SHADOW: \"3dDkShadow\",\n THREE_D_LIGHT: \"3dLight\",\n INFO_TEXT: \"infoText\",\n INFO_BK: \"infoBk\",\n HOT_LIGHT: \"hotLight\",\n GRADIENT_ACTIVE_CAPTION: \"gradientActiveCaption\",\n GRADIENT_INACTIVE_CAPTION: \"gradientInactiveCaption\",\n MENU_HIGHLIGHT: \"menuHighlight\",\n MENU_BAR: \"menuBar\",\n} as const;\n\n/**\n * Options for system color.\n */\nexport interface SystemColorOptions {\n /** System color value */\n value: (typeof SystemColor)[keyof typeof SystemColor];\n /** Last known RGB color value (optional fallback) */\n lastClr?: HexColor;\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n/**\n * Creates a system color element as an XML string.\n *\n * References a system-defined UI color (e.g., window background, button face).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SystemColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"val\" type=\"ST_SystemColorVal\" use=\"required\"/>\n * <xsd:attribute name=\"lastClr\" type=\"s:ST_HexColorRGB\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createSystemColor = (options: SystemColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\"a:sysClr\", { val: options.value, lastClr: options.lastClr }, transforms);\n};\n","/**\n * Color descriptors for DrawingML.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport {\n emitAngle,\n emitPercent,\n parseAngle,\n parsePercent,\n parsePercentAttr,\n} from \"../../util/converters\";\nimport {\n ANGLE_TRANSFORMS,\n BOOLEAN_TRANSFORMS,\n createColorTransforms,\n PERCENT_TRANSFORMS,\n} from \"./color-transform\";\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport type { HslColorOptions } from \"./hsl-color\";\nimport type { PresetColorOptions } from \"./preset-color\";\nimport { PresetColor } from \"./preset-color\";\nimport type { RgbColorOptions } from \"./rgb-color\";\nimport type { ScRgbColorOptions } from \"./sc-rgb-color\";\nimport type { SchemeColorOptions } from \"./scheme-color\";\nimport { SchemeColor } from \"./scheme-color\";\nimport type { SolidFillOptions } from \"./solid-fill\";\nimport type { SystemColorOptions } from \"./system-color\";\nimport { SystemColor } from \"./system-color\";\n\n// ── Color transform helpers ──\n\n// The parse whitelist is the union of the three unit classes — the Sets in\n// color-transform.ts are the single source of truth for the full key space.\nconst TRANSFORM_KEYS: ReadonlySet<keyof ColorTransformOptions & string> = new Set([\n ...PERCENT_TRANSFORMS,\n ...ANGLE_TRANSFORMS,\n ...BOOLEAN_TRANSFORMS,\n]);\n\n// Transform key classification (percent vs angle) lives in color-transform.ts\n// so stringify and parse share one source of truth.\n\n// Parse an ST_Percentage channel that may arrive as either a 1/1000th integer\n// (\"50000\" = 50%) or a percent literal (\"50%\"); both are XSD-valid. Returns\n// the caller-facing integer percent.\nfunction parsePercentChannel(raw: string | number | undefined): number {\n return parsePercentAttr(raw) ?? 0;\n}\n\nfunction stringifyTransforms(opts: ColorTransformOptions): string {\n // Delegates to createColorTransforms so both paths emit in the caller's key\n // order (XSD transforms compose left to right — order is fidelity).\n return createColorTransforms(opts).join(\"\");\n}\n\nfunction readTransforms(el: XmlElement): ColorTransformOptions | undefined {\n if (!el.elements || el.elements.length === 0) return undefined;\n const result: ColorTransformOptions = {};\n for (const child of el.elements) {\n if (!child.name || !child.name.startsWith(\"a:\")) continue;\n const key = child.name.slice(2) as keyof ColorTransformOptions & string;\n if (!TRANSFORM_KEYS.has(key)) continue;\n const val = child.attributes?.[\"val\"];\n if (val !== undefined) {\n // ST_Percentage arrives as either a 1/1000th integer (\"50000\") or a\n // percent literal (\"65%\") — parsePercentAttr handles both; a plain\n // Number() yields NaN on the literal form. Angles are always plain\n // integers (÷60000).\n (result as Record<string, unknown>)[key] = PERCENT_TRANSFORMS.has(key)\n ? (parsePercentAttr(val) ?? 0)\n : ANGLE_TRANSFORMS.has(key)\n ? parseAngle(Number(val))\n : Number(val);\n } else {\n (result as Record<string, unknown>)[key] = true;\n }\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n// ── RgbColor descriptor ──\n\nexport const rgbColorDesc: CustomDescriptor<RgbColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n if (transforms) {\n return `<a:srgbClr val=\"${escapeXml(opts.value)}\">${transforms}</a:srgbClr>`;\n }\n return `<a:srgbClr val=\"${escapeXml(opts.value)}\"/>`;\n },\n parse(el, _ctx) {\n const result: RgbColorOptions = { value: String(el.attributes?.[\"val\"] ?? \"\") };\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── SchemeColor descriptor ──\n\nexport const schemeColorDesc: CustomDescriptor<SchemeColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n if (transforms) {\n return `<a:schemeClr val=\"${escapeXml(opts.value)}\">${transforms}</a:schemeClr>`;\n }\n return `<a:schemeClr val=\"${escapeXml(opts.value)}\"/>`;\n },\n parse(el, _ctx) {\n const result: SchemeColorOptions = {\n value: String(el.attributes?.[\"val\"] ?? \"\") as SchemeColorOptions[\"value\"],\n };\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── HslColor descriptor ──\n\nexport const hslColorDesc: CustomDescriptor<HslColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n const sat = emitPercent(opts.saturation);\n const lum = emitPercent(opts.luminance);\n const hue = emitAngle(opts.hue);\n if (transforms) {\n return `<a:hslClr hue=\"${hue}\" sat=\"${sat}\" lum=\"${lum}\">${transforms}</a:hslClr>`;\n }\n return `<a:hslClr hue=\"${hue}\" sat=\"${sat}\" lum=\"${lum}\"/>`;\n },\n parse(el, _ctx) {\n const result: HslColorOptions = {\n hue: parseAngle(Number(el.attributes?.[\"hue\"] ?? 0)),\n saturation: parsePercent(Number(el.attributes?.[\"sat\"] ?? 0)),\n luminance: parsePercent(Number(el.attributes?.[\"lum\"] ?? 0)),\n };\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── SystemColor descriptor ──\n\nexport const systemColorDesc: CustomDescriptor<SystemColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n const attrParts: string[] = [`val=\"${escapeXml(opts.value)}\"`];\n if (opts.lastClr) attrParts.push(`lastClr=\"${escapeXml(opts.lastClr)}\"`);\n const attrStr = attrParts.join(\" \");\n if (transforms) {\n return `<a:sysClr ${attrStr}>${transforms}</a:sysClr>`;\n }\n return `<a:sysClr ${attrStr}/>`;\n },\n parse(el, _ctx) {\n const result: SystemColorOptions = {\n value: String(el.attributes?.[\"val\"] ?? \"\") as SystemColorOptions[\"value\"],\n };\n const lastClr = el.attributes?.[\"lastClr\"];\n if (lastClr) result.lastClr = String(lastClr);\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── PresetColor descriptor ──\n\nexport const presetColorDesc: CustomDescriptor<PresetColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n if (transforms) {\n return `<a:prstClr val=\"${escapeXml(opts.value)}\">${transforms}</a:prstClr>`;\n }\n return `<a:prstClr val=\"${escapeXml(opts.value)}\"/>`;\n },\n parse(el, _ctx) {\n const result: PresetColorOptions = {\n value: String(el.attributes?.[\"val\"] ?? \"\") as PresetColorOptions[\"value\"],\n };\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── ScRgbColor descriptor ──\n\nexport const scRgbColorDesc: CustomDescriptor<ScRgbColorOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const transforms = opts.transforms ? stringifyTransforms(opts.transforms) : \"\";\n const r = emitPercent(opts.r);\n const g = emitPercent(opts.g);\n const b = emitPercent(opts.b);\n if (transforms) {\n return `<a:scrgbClr r=\"${r}\" g=\"${g}\" b=\"${b}\">${transforms}</a:scrgbClr>`;\n }\n return `<a:scrgbClr r=\"${r}\" g=\"${g}\" b=\"${b}\"/>`;\n },\n parse(el, _ctx) {\n const result: ScRgbColorOptions = {\n r: parsePercentChannel(el.attributes?.[\"r\"]),\n g: parsePercentChannel(el.attributes?.[\"g\"]),\n b: parsePercentChannel(el.attributes?.[\"b\"]),\n };\n const transforms = readTransforms(el);\n if (transforms) result.transforms = transforms;\n return result;\n },\n};\n\n// ── Color discrimination (SolidFillOptions) ──\n\nconst SYSTEM_COLOR_VALUES: ReadonlySet<string> = new Set(Object.values(SystemColor));\nconst PRESET_COLOR_VALUES: ReadonlySet<string> = new Set(Object.values(PresetColor));\nconst SCHEME_COLOR_VALUES: ReadonlySet<string> = new Set(Object.values(SchemeColor));\n\n// The six color descriptors ignore their write context (no media/rel side\n// effects), so the context-free emitter passes this placeholder.\nconst NO_WRITE_CTX = undefined as unknown as WriteContext;\n\n/** Emit an EG_ColorChoice element string (direct color element, no\n * `a:solidFill` wrapper). The single discrimination for all six color kinds —\n * gradient stops, fg/bg clr, effect colors, and the color factories all share\n * this path. */\nexport function emitColorChoice(color: SolidFillOptions): string {\n if (\"hue\" in color) return hslColorDesc.stringify(color, NO_WRITE_CTX) ?? \"\";\n if (\"r\" in color) return scRgbColorDesc.stringify(color, NO_WRITE_CTX) ?? \"\";\n // Remaining variants (rgb/scheme/system/preset) share a `value` key.\n const colorValue = (color as { value: string }).value;\n if (SYSTEM_COLOR_VALUES.has(colorValue))\n return systemColorDesc.stringify(color as SystemColorOptions, NO_WRITE_CTX) ?? \"\";\n if (PRESET_COLOR_VALUES.has(colorValue))\n return presetColorDesc.stringify(color as PresetColorOptions, NO_WRITE_CTX) ?? \"\";\n if (SCHEME_COLOR_VALUES.has(colorValue))\n return schemeColorDesc.stringify(color as SchemeColorOptions, NO_WRITE_CTX) ?? \"\";\n return rgbColorDesc.stringify(color as RgbColorOptions, NO_WRITE_CTX) ?? \"\";\n}\n\n/** Stringify an EG_ColorChoice (direct color element, no `a:solidFill` wrapper).\n * Used for gradient stops, fg/bg clr, and effect colors. Replaces the former\n * `getColorDescriptor` which returned a polymorphic `CustomDescriptor<any>`. */\nexport function stringifyColorChoice(color: SolidFillOptions, _ctx: WriteContext): string {\n return emitColorChoice(color);\n}\n\n/** True when the color is a bare srgbClr (no transforms, no secondary fields)\n * — safe for a caller to collapse to its hex string shorthand. */\nexport function isPlainRgbColor(color: SolidFillOptions): boolean {\n if (\"hue\" in color || \"r\" in color) return false;\n if (color.transforms !== undefined) return false;\n const value = (color as { value?: unknown }).value;\n return (\n typeof value === \"string\" &&\n !SYSTEM_COLOR_VALUES.has(value) &&\n !PRESET_COLOR_VALUES.has(value) &&\n !SCHEME_COLOR_VALUES.has(value)\n );\n}\n\n/**\n * Parse a single EG_ColorChoice element (a:srgbClr, a:schemeClr, …) into\n * options; returns undefined for any other element.\n */\nexport function parseColorChoiceElement(\n el: XmlElement,\n ctx: ReadContext,\n): SolidFillOptions | undefined {\n switch (el.name) {\n case \"a:srgbClr\":\n return rgbColorDesc.parse(el, ctx);\n case \"a:schemeClr\":\n return schemeColorDesc.parse(el, ctx);\n case \"a:hslClr\":\n return hslColorDesc.parse(el, ctx);\n case \"a:sysClr\":\n return systemColorDesc.parse(el, ctx);\n case \"a:prstClr\":\n return presetColorDesc.parse(el, ctx);\n case \"a:scrgbClr\":\n return scRgbColorDesc.parse(el, ctx);\n default:\n return undefined;\n }\n}\n\n/**\n * Parse an EG_ColorChoice from an element's direct children. Handles all six\n * color element kinds (srgbClr/schemeClr/hslClr/sysClr/prstClr/scrgbClr) —\n * used both by {@link solidFillDesc} (under a:solidFill) and by fill\n * descriptors reading direct colors under a:gs / a:fgClr / a:bgClr.\n */\nexport function parseColorChoice(el: XmlElement, ctx: ReadContext): SolidFillOptions {\n if (!el.elements) return {} as SolidFillOptions;\n for (const child of el.elements) {\n const color = parseColorChoiceElement(child, ctx);\n if (color) return color;\n }\n return {} as SolidFillOptions;\n}\n\n// ── SolidFill descriptor ──\n\nexport const solidFillDesc: CustomDescriptor<SolidFillOptions> = {\n kind: \"custom\",\n stringify(color, ctx) {\n const inner = stringifyColorChoice(color, ctx);\n if (!inner) return undefined;\n return `<a:solidFill>${inner}</a:solidFill>`;\n },\n parse(el, _ctx) {\n return parseColorChoice(el, _ctx);\n },\n};\n","/**\n * Solid fill element for DrawingML shapes.\n *\n * This module provides solid fill support for outlines and shapes,\n * supporting RGB, scheme, HSL, system, and preset colors.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SolidColorFillProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { emitColorChoice } from \"./color-descriptors\";\nimport type { HslColorOptions } from \"./hsl-color\";\nimport type { PresetColorOptions } from \"./preset-color\";\nimport type { RgbColorOptions } from \"./rgb-color\";\nimport type { ScRgbColorOptions } from \"./sc-rgb-color\";\nimport type { SchemeColorOptions } from \"./scheme-color\";\nimport type { SystemColorOptions } from \"./system-color\";\n\n/**\n * Union type for all color options supported by solid fill.\n *\n * Extends the original pattern with additional color types:\n * RGB, scheme, HSL, system, and preset colors.\n */\nexport type SolidFillOptions =\n | ScRgbColorOptions\n | RgbColorOptions\n | SchemeColorOptions\n | HslColorOptions\n | SystemColorOptions\n | PresetColorOptions;\n\n/**\n * Creates the color child element for a solid fill — thin delegate to the\n * single EG_ColorChoice discrimination in the color descriptors.\n */\nexport const createColorElement = (color: SolidFillOptions): string => emitColorChoice(color);\n\n/**\n * Creates a solid fill element as an XML string.\n *\n * Specifies a solid color fill using any supported color type.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SolidColorFillProperties\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_EffectProperties\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // RGB solid fill\n * const fill = createSolidFill({ value: \"FF0000\" });\n * // Scheme solid fill with tint\n * const schemeFill = createSolidFill({\n * value: SchemeColor.ACCENT1, transforms: { tint: 40 },\n * });\n * // HSL solid fill\n * const hslFill = createSolidFill({ hue: 120, saturation: 100, luminance: 50 });\n * ```\n */\nexport const createSolidFill = (options: SolidFillOptions): string =>\n element(\"a:solidFill\", undefined, [createColorElement(options)]);\n","/**\n * Diagram style, color list, and style label elements.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd\n * CT_Style, CT_StyleLabel, CT_Colors, CT_CTStyleLabel\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport { xsdHueDirection } from \"../../util/mappings\";\nimport { parseColorChoiceElement } from \"../color/color-descriptors\";\nimport { SchemeColor } from \"../color/scheme-color\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createColorElement } from \"../color/solid-fill\";\n\n// ---------------------------------------------------------------------------\n// dgm:style — diagram style (CT_ShapeStyle from dml-main.xsd)\n// ---------------------------------------------------------------------------\n\nexport type StyleMatrixIndex = \"subtle\" | \"moderate\" | \"intense\";\n\nexport const FontCollectionIndex = {\n MAJOR: \"major\",\n MINOR: \"minor\",\n NONE: \"none\",\n} as const;\n\n/** Reference into the theme style matrix (a:lnRef/fillRef/effectRef). */\nexport interface DiagramStyleReferenceOptions {\n /** Index into the theme style matrix (a:*Ref `@idx`) */\n idx: number;\n}\n\n/** Font reference (a:fontRef) — idx is a FontCollectionIndex (major/minor/none). */\nexport interface DiagramFontReferenceOptions {\n /** Font collection index (FontCollectionIndex.MAJOR/MINOR/NONE) */\n idx: string;\n}\n\nexport interface DiagramStyleOptions {\n /** Line reference (a:lnRef) */\n lineReference?: DiagramStyleReferenceOptions;\n /** Fill reference (a:fillRef) */\n fillReference?: DiagramStyleReferenceOptions;\n /** Effect reference (a:effectRef) */\n effectReference?: DiagramStyleReferenceOptions;\n /** Font reference (a:fontRef) */\n fontReference?: DiagramFontReferenceOptions;\n}\n\n/**\n * Creates a dgm:style element (a:CT_ShapeStyle).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_ShapeStyle\">\n * <xsd:sequence>\n * <xsd:element name=\"lnRef\" type=\"CT_StyleMatrixReference\"/>\n * <xsd:element name=\"fillRef\" type=\"CT_StyleMatrixReference\"/>\n * <xsd:element name=\"effectRef\" type=\"CT_StyleMatrixReference\"/>\n * <xsd:element name=\"fontRef\" type=\"CT_FontReference\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n */\nexport const createDiagramStyle = (options?: DiagramStyleOptions): string => {\n const children: string[] = [];\n\n children.push(\n element(\"a:lnRef\", { idx: options?.lineReference?.idx ?? 1 }, [\n createColorElement({ value: SchemeColor.ACCENT1 }),\n ]),\n );\n children.push(\n element(\"a:fillRef\", { idx: options?.fillReference?.idx ?? 1 }, [\n createColorElement({ value: SchemeColor.ACCENT1 }),\n ]),\n );\n children.push(\n element(\"a:effectRef\", { idx: options?.effectReference?.idx ?? 0 }, [\n createColorElement({ value: SchemeColor.ACCENT1 }),\n ]),\n );\n children.push(\n element(\"a:fontRef\", { idx: options?.fontReference?.idx ?? \"minor\" }, [\n createColorElement({ value: SchemeColor.TX1 }),\n ]),\n );\n\n return element(\"dgm:style\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// Color list elements (CT_Colors) — used for fillClrLst, linClrLst, etc.\n// ---------------------------------------------------------------------------\n\n/** How the color list maps onto shapes (ST_ColorMethod): \"span\" interpolate across the list, \"cycle\" repeat in order, \"repeat\" alternate. */\nexport type ColorMethod = \"span\" | \"cycle\" | \"repeat\";\n\n/** Hue rotation direction (ST_HueDir). */\nexport type HueDirection = \"clockwise\" | \"counterClockwise\";\n\nexport interface ColorListOptions {\n /** Color method (default: span) */\n meth?: ColorMethod;\n /** Hue direction (default: cw) */\n hueDir?: HueDirection;\n /** Colors (EG_ColorChoice items) */\n colors?: readonly SolidFillOptions[];\n}\n\n/** Creates a generic CT_Colors element with the given tag. */\nexport const createColorList = (tag: string, options?: ColorListOptions): string => {\n const children: string[] = [];\n if (options?.colors) {\n for (const c of options.colors) {\n children.push(createColorElement(c));\n }\n }\n\n const hasAttrs = options?.meth !== undefined || options?.hueDir !== undefined;\n const attrs: Record<string, string> = {};\n if (options?.meth) attrs.meth = options.meth;\n if (options?.hueDir) attrs.hueDir = xsdHueDirection.to(options.hueDir);\n\n return element(tag, hasAttrs ? attrs : undefined, children.length > 0 ? children : undefined);\n};\n\n/**\n * Parses a CT_Colors element (fillClrLst/linClrLst/…) back into options.\n * Colors parse in document order.\n */\nexport const parseColorList = (el: Element): ColorListOptions => {\n const result: ColorListOptions = {};\n if (el.attributes?.meth !== undefined) result.meth = el.attributes.meth as ColorMethod;\n if (el.attributes?.hueDir !== undefined)\n result.hueDir = xsdHueDirection.from(String(el.attributes.hueDir)) as HueDirection;\n const colors: SolidFillOptions[] = [];\n for (const child of el.elements ?? []) {\n const color = parseColorChoiceElement(child, NOOP_READ_CTX);\n if (color) colors.push(color);\n }\n if (colors.length) result.colors = colors;\n return result;\n};\n\n// Noop context: color elements never resolve relationships or parts.\nconst NOOP_READ_CTX = {\n resolveRelationship: () => undefined,\n getPart: () => undefined,\n getRaw: () => undefined,\n};\n\n// ---------------------------------------------------------------------------\n// dgm:fillClrLst / dgm:linClrLst / dgm:effectClrLst (used in CT_CTStyleLabel)\n// ---------------------------------------------------------------------------\n\nexport const createFillColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:fillClrLst\", options);\nexport const createLineColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:linClrLst\", options);\nexport const createEffectColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:effectClrLst\", options);\n\n// ---------------------------------------------------------------------------\n// dgm:txFillClrLst / dgm:txLinClrLst / dgm:txEffectClrLst (text color lists)\n// ---------------------------------------------------------------------------\n\nexport const createTextFillColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:txFillClrLst\", options);\n\nexport const createTextLineColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:txLinClrLst\", options);\n\nexport const createTextEffectColorList = (options?: ColorListOptions): string =>\n createColorList(\"dgm:txEffectClrLst\", options);\n\n// ---------------------------------------------------------------------------\n// dgm:styleLbl — color-transform style label (CT_CTStyleLabel)\n// ---------------------------------------------------------------------------\n\nexport interface ColorStyleLabelOptions {\n /** Label name referenced by dgm:layoutNode `@styleLbl` (required) */\n name: string;\n fillColorList?: ColorListOptions;\n lineColorList?: ColorListOptions;\n effectColorList?: ColorListOptions;\n textFillColorList?: ColorListOptions;\n textLineColorList?: ColorListOptions;\n textEffectColorList?: ColorListOptions;\n}\n\n/**\n * Creates a dgm:styleLbl element (CT_StyleLabel or CT_CTStyleLabel).\n *\n * ## XSD Schema (CT_CTStyleLabel, for color transforms)\n * ```xml\n * <xsd:complexType name=\"CT_CTStyleLabel\">\n * <xsd:sequence>\n * <xsd:element name=\"fillClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"linClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"effectClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"txLinClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"txFillClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"txEffectClrLst\" type=\"CT_Colors\" minOccurs=\"0\"/>\n * <xsd:element name=\"extLst\" type=\"a:CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * ## XSD Schema (CT_StyleLabel, for quick styles)\n * ```xml\n * <xsd:complexType name=\"CT_StyleLabel\">\n * <xsd:sequence>\n * <xsd:element name=\"scene3d\" type=\"a:CT_Scene3D\" minOccurs=\"0\"/>\n * <xsd:element name=\"sp3d\" type=\"a:CT_Shape3D\" minOccurs=\"0\"/>\n * <xsd:element name=\"txPr\" type=\"CT_TextProps\" minOccurs=\"0\"/>\n * <xsd:element name=\"style\" type=\"a:CT_ShapeStyle\" minOccurs=\"0\"/>\n * <xsd:element name=\"extLst\" type=\"a:CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createStyleLabel = (options: ColorStyleLabelOptions): string => {\n const children: string[] = [];\n if (options.fillColorList) children.push(createFillColorList(options.fillColorList));\n if (options.lineColorList) children.push(createLineColorList(options.lineColorList));\n if (options.effectColorList) children.push(createEffectColorList(options.effectColorList));\n if (options.textFillColorList) children.push(createTextFillColorList(options.textFillColorList));\n if (options.textLineColorList) children.push(createTextLineColorList(options.textLineColorList));\n if (options.textEffectColorList)\n children.push(createTextEffectColorList(options.textEffectColorList));\n\n return element(\"dgm:styleLbl\", { name: options.name }, children);\n};\n","/**\n * 3D descriptor for DrawingML shapes.\n *\n * @module\n */\n\nimport { escapeXml, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { stringify, parse } from \"../../descriptor\";\nimport { emitAngle, parseAngle } from \"../../util/converters\";\nimport { xsdLightRigDirection, xsdMaterialType } from \"../../util/mappings\";\nimport { parseColorChoice, stringifyColorChoice } from \"../color/color-descriptors\";\nimport type { BevelOptions } from \"./bevel\";\nimport type {\n Scene3DOptions,\n CameraOptions,\n LightRigOptions,\n SphereCoords,\n BackdropOptions,\n Point3D,\n Vector3D,\n} from \"./scene-3d\";\nimport type { Shape3DOptions } from \"./shape-3d\";\nimport type { PresetMaterial } from \"./shape-3d\";\n\n// ── SphereCoords helper ──\n\nfunction stringifySphereCoords(coords: SphereCoords): string {\n const lat = emitAngle(coords.lat);\n const lon = emitAngle(coords.lon);\n const rev = emitAngle(coords.rev);\n return `<a:rot lat=\"${lat}\" lon=\"${lon}\" rev=\"${rev}\"/>`;\n}\n\nfunction readSphereCoords(el: XmlElement): SphereCoords | undefined {\n const lat = el.attributes?.[\"lat\"];\n const lon = el.attributes?.[\"lon\"];\n const rev = el.attributes?.[\"rev\"];\n if (lat === undefined || lon === undefined || rev === undefined) return undefined;\n return {\n lat: parseAngle(Number(lat)),\n lon: parseAngle(Number(lon)),\n rev: parseAngle(Number(rev)),\n };\n}\n\n// ── Bevel descriptor (a:bevelT / a:bevelB) ──\n\nexport const bevelDesc: CustomDescriptor<BevelOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n if (opts.w !== undefined) attrParts.push(`w=\"${opts.w}\"`);\n if (opts.h !== undefined) attrParts.push(`h=\"${opts.h}\"`);\n if (opts.prst !== undefined) attrParts.push(`prst=\"${escapeXml(opts.prst)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n return `<a:bevel${attrStr}/>`;\n },\n parse(el, _ctx) {\n const result: BevelOptions = {};\n if (el.attributes?.[\"w\"] !== undefined) result.w = Number(el.attributes[\"w\"]);\n if (el.attributes?.[\"h\"] !== undefined) result.h = Number(el.attributes[\"h\"]);\n if (el.attributes?.[\"prst\"] !== undefined)\n result.prst = String(el.attributes[\"prst\"]) as BevelOptions[\"prst\"];\n return result;\n },\n};\n\n// ── Shape3D descriptor (a:sp3d) ──\n\nexport const shape3DDesc: CustomDescriptor<Shape3DOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Children\n if (opts.bevelT) {\n const bevelXml = stringify(bevelDesc, opts.bevelT, ctx);\n if (bevelXml) parts.push(bevelXml.replace(\"<a:bevel\", \"<a:bevelT\"));\n }\n if (opts.bevelB) {\n const bevelXml = stringify(bevelDesc, opts.bevelB, ctx);\n if (bevelXml) parts.push(bevelXml.replace(\"<a:bevel\", \"<a:bevelB\"));\n }\n if (opts.extrusionColor) {\n const colorXml = stringifyColorChoice(opts.extrusionColor, ctx);\n if (colorXml) parts.push(`<a:extrusionClr>${colorXml}</a:extrusionClr>`);\n }\n if (opts.contourColor) {\n const colorXml = stringifyColorChoice(opts.contourColor, ctx);\n if (colorXml) parts.push(`<a:contourClr>${colorXml}</a:contourClr>`);\n }\n\n // Attributes\n const attrParts: string[] = [];\n if (opts.z !== undefined) attrParts.push(`z=\"${opts.z}\"`);\n if (opts.extrusionH !== undefined) attrParts.push(`extrusionH=\"${opts.extrusionH}\"`);\n if (opts.contourW !== undefined) attrParts.push(`contourW=\"${opts.contourW}\"`);\n if (opts.prstMaterial !== undefined) {\n attrParts.push(`prstMaterial=\"${escapeXml(xsdMaterialType.to(opts.prstMaterial))}\"`);\n }\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const content = parts.join(\"\");\n if (!attrStr && !content) return undefined;\n if (!content) return `<a:sp3d${attrStr}/>`;\n return `<a:sp3d${attrStr}>${content}</a:sp3d>`;\n },\n parse(el, ctx) {\n const result: Shape3DOptions = {};\n\n // Attributes\n if (el.attributes?.[\"z\"] !== undefined) result.z = Number(el.attributes[\"z\"]);\n if (el.attributes?.[\"extrusionH\"] !== undefined)\n result.extrusionH = Number(el.attributes[\"extrusionH\"]);\n if (el.attributes?.[\"contourW\"] !== undefined)\n result.contourW = Number(el.attributes[\"contourW\"]);\n if (el.attributes?.[\"prstMaterial\"] !== undefined) {\n result.prstMaterial = xsdMaterialType.from(\n String(el.attributes[\"prstMaterial\"]),\n ) as Shape3DOptions[\"prstMaterial\"];\n }\n\n // Children\n const bevelT = findChild(el, \"a:bevelT\");\n if (bevelT) result.bevelT = parse(bevelDesc, bevelT, ctx);\n\n const bevelB = findChild(el, \"a:bevelB\");\n if (bevelB) result.bevelB = parse(bevelDesc, bevelB, ctx);\n\n const extrusionClr = findChild(el, \"a:extrusionClr\");\n if (extrusionClr) {\n const color = parseColorChoice(extrusionClr, ctx);\n if (color && Object.keys(color).length) result.extrusionColor = color;\n }\n\n const contourClr = findChild(el, \"a:contourClr\");\n if (contourClr) {\n const color = parseColorChoice(contourClr, ctx);\n if (color && Object.keys(color).length) result.contourColor = color;\n }\n\n return result;\n },\n};\n\n// ── Camera descriptor ──\n\nconst cameraDesc: CustomDescriptor<CameraOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n attrParts.push(`prst=\"${escapeXml(opts.preset)}\"`);\n if (opts.fov !== undefined) attrParts.push(`fov=\"${emitAngle(opts.fov)}\"`);\n if (opts.zoom !== undefined) attrParts.push(`zoom=\"${escapeXml(opts.zoom)}\"`);\n const attrStr = \" \" + attrParts.join(\" \");\n\n const parts: string[] = [];\n if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));\n\n const content = parts.join(\"\");\n if (!content) return `<a:camera${attrStr}/>`;\n return `<a:camera${attrStr}>${content}</a:camera>`;\n },\n parse(el, _ctx) {\n const result: Partial<CameraOptions> = {};\n if (el.attributes?.[\"prst\"] !== undefined)\n result.preset = String(el.attributes[\"prst\"]) as CameraOptions[\"preset\"];\n if (el.attributes?.[\"fov\"] !== undefined) result.fov = parseAngle(Number(el.attributes[\"fov\"]));\n if (el.attributes?.[\"zoom\"] !== undefined)\n result.zoom = String(el.attributes[\"zoom\"]) as CameraOptions[\"zoom\"];\n const rot = findChild(el, \"a:rot\");\n if (rot) result.rotation = readSphereCoords(rot);\n return result as CameraOptions;\n },\n};\n\n// ── LightRig descriptor ──\n\nconst lightRigDesc: CustomDescriptor<LightRigOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n attrParts.push(`rig=\"${escapeXml(opts.rig)}\"`);\n attrParts.push(`dir=\"${escapeXml(xsdLightRigDirection.to(opts.direction))}\"`);\n const attrStr = \" \" + attrParts.join(\" \");\n\n const parts: string[] = [];\n if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));\n\n const content = parts.join(\"\");\n if (!content) return `<a:lightRig${attrStr}/>`;\n return `<a:lightRig${attrStr}>${content}</a:lightRig>`;\n },\n parse(el, _ctx) {\n const result: Partial<LightRigOptions> = {};\n if (el.attributes?.[\"rig\"] !== undefined)\n result.rig = String(el.attributes[\"rig\"]) as LightRigOptions[\"rig\"];\n if (el.attributes?.[\"dir\"] !== undefined)\n result.direction = xsdLightRigDirection.from(\n String(el.attributes[\"dir\"]),\n ) as LightRigOptions[\"direction\"];\n const rot = findChild(el, \"a:rot\");\n if (rot) result.rotation = readSphereCoords(rot);\n return result as LightRigOptions;\n },\n};\n\n// ── Cell3D descriptor (a:cell3D — table cell bevel) ──\n\nexport interface Cell3DOptions {\n /** Cell bevel (required CT_Bevel) */\n bevel: BevelOptions;\n /** Light rig (CT_LightRig) */\n lightRig?: LightRigOptions;\n /** Preset material (`@prstMaterial`, default \"plastic\") */\n prstMaterial?: PresetMaterial;\n}\n\nexport const cell3DDesc: CustomDescriptor<Cell3DOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const attrParts: string[] = [];\n if (opts.prstMaterial !== undefined) attrParts.push(`prstMaterial=\"${opts.prstMaterial}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const parts: string[] = [];\n const bevelXml = stringify(bevelDesc, opts.bevel, ctx);\n if (bevelXml) parts.push(bevelXml);\n if (opts.lightRig) {\n const lightRigXml = stringify(lightRigDesc, opts.lightRig, ctx);\n if (lightRigXml) parts.push(lightRigXml);\n }\n return `<a:cell3D${attrStr}>${parts.join(\"\")}</a:cell3D>`;\n },\n parse(el, ctx) {\n const result: Partial<Cell3DOptions> = {};\n if (el.attributes?.[\"prstMaterial\"] !== undefined) {\n result.prstMaterial = String(el.attributes[\"prstMaterial\"]) as PresetMaterial;\n }\n const bevel = findChild(el, \"a:bevel\");\n if (bevel) result.bevel = parse(bevelDesc, bevel, ctx);\n const lightRig = findChild(el, \"a:lightRig\");\n if (lightRig) result.lightRig = parse(lightRigDesc, lightRig, ctx);\n return result as Cell3DOptions;\n },\n};\n\n// ── Scene3D descriptor (a:scene3d) ──\n\nexport const scene3DDesc: CustomDescriptor<Scene3DOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Camera (required)\n const cameraXml = stringify(cameraDesc, opts.camera, ctx);\n if (cameraXml) parts.push(cameraXml);\n\n // Light rig (required)\n const lightRigXml = stringify(lightRigDesc, opts.lightRig, ctx);\n if (lightRigXml) parts.push(lightRigXml);\n\n // Backdrop (optional)\n if (opts.backdrop) {\n parts.push(stringifyBackdrop(opts.backdrop));\n }\n\n const content = parts.join(\"\");\n if (!content) return undefined;\n return `<a:scene3d>${content}</a:scene3d>`;\n },\n parse(el, ctx) {\n const result: Partial<Scene3DOptions> = {};\n\n const camera = findChild(el, \"a:camera\");\n if (camera) result.camera = parse(cameraDesc, camera, ctx);\n\n const lightRig = findChild(el, \"a:lightRig\");\n if (lightRig) result.lightRig = parse(lightRigDesc, lightRig, ctx);\n\n const backdrop = findChild(el, \"a:backdrop\");\n if (backdrop) result.backdrop = readBackdrop(backdrop);\n\n return result as Scene3DOptions;\n },\n};\n\n// ── Backdrop helpers ──\n\nfunction stringifyPoint3D(name: string, point: Point3D): string {\n return `<${name} x=\"${point.x}\" y=\"${point.y}\" z=\"${point.z}\"/>`;\n}\n\nfunction stringifyVector3D(name: string, vector: Vector3D): string {\n return `<${name} dx=\"${vector.dx}\" dy=\"${vector.dy}\" dz=\"${vector.dz}\"/>`;\n}\n\nfunction stringifyBackdrop(opts: BackdropOptions): string {\n const content =\n stringifyPoint3D(\"a:anchor\", opts.anchor) +\n stringifyVector3D(\"a:norm\", opts.normal) +\n stringifyVector3D(\"a:up\", opts.up) +\n (opts.ext !== undefined ? `<a:extLst>${opts.ext}</a:extLst>` : \"\");\n return `<a:backdrop>${content}</a:backdrop>`;\n}\n\nfunction readPoint3D(el: XmlElement): Point3D | undefined {\n const x = el.attributes?.[\"x\"];\n const y = el.attributes?.[\"y\"];\n const z = el.attributes?.[\"z\"];\n if (x === undefined || y === undefined || z === undefined) return undefined;\n return { x: Number(x), y: Number(y), z: Number(z) };\n}\n\nfunction readVector3D(el: XmlElement): Vector3D | undefined {\n const dx = el.attributes?.[\"dx\"];\n const dy = el.attributes?.[\"dy\"];\n const dz = el.attributes?.[\"dz\"];\n if (dx === undefined || dy === undefined || dz === undefined) return undefined;\n return { dx: Number(dx), dy: Number(dy), dz: Number(dz) };\n}\n\nfunction readBackdrop(el: XmlElement): BackdropOptions | undefined {\n const anchor = findChild(el, \"a:anchor\");\n const norm = findChild(el, \"a:norm\");\n const up = findChild(el, \"a:up\");\n if (!anchor || !norm || !up) return undefined;\n const anchorPt = readPoint3D(anchor);\n const normVec = readVector3D(norm);\n const upVec = readVector3D(up);\n if (!anchorPt || !normVec || !upVec) return undefined;\n const result: BackdropOptions = { anchor: anchorPt, normal: normVec, up: upVec };\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) result.ext = stringifyXml(extLst);\n return result;\n}\n","/**\n * RGB color element for DrawingML shapes.\n *\n * This module provides RGB color support for solid fills.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SRgbColor\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { HexColor } from \"../../util/values\";\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * Options for RGB color.\n */\nexport interface RgbColorOptions {\n /** Hex color value (e.g., \"FF0000\" for red) */\n value: HexColor;\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n/**\n * Creates an sRGB color element as an XML string.\n *\n * Specifies a color using RGB hex values.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SRgbColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"val\" type=\"s:ST_HexColorRGB\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * const redColor = createRgbColor({ value: \"FF0000\" });\n * // With alpha transform\n * const semiRed = createRgbColor({ value: \"FF0000\", transforms: { alpha: 50 } });\n * ```\n */\nexport const createRgbColor = (options: RgbColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\"a:srgbClr\", { val: options.value }, transforms);\n};\n","/**\n * HSL color element for DrawingML.\n *\n * This module provides HSL (Hue, Saturation, Luminance) color support.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_HslColor\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * Options for HSL color.\n */\nexport interface HslColorOptions {\n /** Hue angle in degrees (0-360). */\n hue: number;\n /** Saturation as integer percent (0-100) */\n saturation: number;\n /** Luminance as integer percent (0-100) */\n luminance: number;\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n/**\n * Creates an HSL color element as an XML string.\n *\n * Specifies a color using Hue, Saturation, and Luminance values.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_HslColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"hue\" type=\"ST_PositiveFixedAngle\" use=\"required\"/>\n * <xsd:attribute name=\"sat\" type=\"ST_Percentage\" use=\"required\"/>\n * <xsd:attribute name=\"lum\" type=\"ST_Percentage\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createHslColor = (options: HslColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\n \"a:hslClr\",\n {\n hue: Math.round(options.hue * 60000),\n sat: Math.round(options.saturation * 1000),\n lum: Math.round(options.luminance * 1000),\n },\n transforms,\n );\n};\n","/**\n * ScRGB color element for DrawingML shapes.\n *\n * This module provides scRGB color support using percentage-based RGB values.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ScRgbColor\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { ColorTransformOptions } from \"./color-transform\";\nimport { createColorTransforms } from \"./color-transform\";\n\n/**\n * Options for scRGB color.\n */\nexport interface ScRgbColorOptions {\n /** Red as integer percent (0-100) */\n r: number;\n /** Green as integer percent (0-100) */\n g: number;\n /** Blue as integer percent (0-100) */\n b: number;\n /** Optional color transforms */\n transforms?: ColorTransformOptions;\n}\n\n/**\n * Creates an scRGB color element as an XML string.\n *\n * Specifies a color using percentage-based RGB values.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_ScRgbColor\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorTransform\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"r\" type=\"ST_Percentage\" use=\"required\"/>\n * <xsd:attribute name=\"g\" type=\"ST_Percentage\" use=\"required\"/>\n * <xsd:attribute name=\"b\" type=\"ST_Percentage\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * const redColor = createScRgbColor({ r: 100, g: 0, b: 0 });\n * // With alpha transform\n * const semiRed = createScRgbColor({ r: 100, g: 0, b: 0, transforms: { alpha: 50 } });\n * ```\n */\nexport const createScRgbColor = (options: ScRgbColorOptions): string => {\n const transforms = options.transforms ? createColorTransforms(options.transforms) : [];\n return element(\n \"a:scrgbClr\",\n {\n r: Math.round(options.r * 1000),\n g: Math.round(options.g * 1000),\n b: Math.round(options.b * 1000),\n },\n transforms,\n );\n};\n","/**\n * Blip descriptor for DrawingML pictures.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild, attr, stringifyElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport { stringify, parse } from \"../../descriptor\";\nimport { emitAngle, emitPercent, parseAngle, parsePercentAttr } from \"../../util/converters\";\nimport { extUriMatches } from \"../../util/ext-uri\";\nimport { xsdRectAlignment } from \"../../util/mappings\";\nimport { parseOnOff } from \"../../util/values\";\nimport {\n parseColorChoice,\n parseColorChoiceElement,\n stringifyColorChoice,\n} from \"../color/color-descriptors\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport type { BlipOptions } from \"./blip\";\nimport type {\n BlipEffectsOptions,\n LuminanceEffectOptions,\n HSLEffectOptions,\n TintEffectOptions,\n AlphaModulateFixedEffectOptions,\n ColorChangeEffectOptions,\n BlipBlurEffectOptions,\n} from \"./blip-effects\";\nimport type { BlipFillOptions } from \"./blip-fill\";\nimport type { SourceRectangleOptions } from \"./source-rectangle\";\nimport type { TileOptions } from \"./tile\";\n\n// ── Tile descriptor (a:tile) ──\n\nexport const tileDesc: CustomDescriptor<TileOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n if (opts.tx !== undefined) attrParts.push(`tx=\"${opts.tx}\"`);\n if (opts.ty !== undefined) attrParts.push(`ty=\"${opts.ty}\"`);\n if (opts.sx !== undefined) attrParts.push(`sx=\"${emitPercent(opts.sx)}\"`);\n if (opts.sy !== undefined) attrParts.push(`sy=\"${emitPercent(opts.sy)}\"`);\n if (opts.flip !== undefined) attrParts.push(`flip=\"${escapeXml(opts.flip)}\"`);\n if (opts.alignment !== undefined)\n attrParts.push(`algn=\"${escapeXml(xsdRectAlignment.to(opts.alignment))}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n return `<a:tile${attrStr}/>`;\n },\n parse(el, _ctx) {\n const result: TileOptions = {};\n if (el.attributes?.[\"tx\"] !== undefined) result.tx = Number(el.attributes[\"tx\"]);\n if (el.attributes?.[\"ty\"] !== undefined) result.ty = Number(el.attributes[\"ty\"]);\n if (el.attributes?.[\"sx\"] !== undefined) result.sx = parsePercentAttr(el.attributes[\"sx\"])!;\n if (el.attributes?.[\"sy\"] !== undefined) result.sy = parsePercentAttr(el.attributes[\"sy\"])!;\n if (el.attributes?.[\"flip\"] !== undefined)\n result.flip = String(el.attributes[\"flip\"]) as TileOptions[\"flip\"];\n if (el.attributes?.[\"algn\"] !== undefined)\n result.alignment = xsdRectAlignment.from(\n String(el.attributes[\"algn\"]),\n ) as TileOptions[\"alignment\"];\n return result;\n },\n};\n\n// ── SourceRectangle descriptor (a:srcRect) ──\n\nexport const sourceRectangleDesc: CustomDescriptor<SourceRectangleOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n if (opts.left !== undefined) attrParts.push(`l=\"${emitPercent(opts.left)}\"`);\n if (opts.top !== undefined) attrParts.push(`t=\"${emitPercent(opts.top)}\"`);\n if (opts.right !== undefined) attrParts.push(`r=\"${emitPercent(opts.right)}\"`);\n if (opts.bottom !== undefined) attrParts.push(`b=\"${emitPercent(opts.bottom)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n return `<a:srcRect${attrStr}/>`;\n },\n parse(el, _ctx) {\n const result: SourceRectangleOptions = {};\n if (el.attributes?.[\"l\"] !== undefined) result.left = parsePercentAttr(el.attributes[\"l\"])!;\n if (el.attributes?.[\"t\"] !== undefined) result.top = parsePercentAttr(el.attributes[\"t\"])!;\n if (el.attributes?.[\"r\"] !== undefined) result.right = parsePercentAttr(el.attributes[\"r\"])!;\n if (el.attributes?.[\"b\"] !== undefined) result.bottom = parsePercentAttr(el.attributes[\"b\"])!;\n return result;\n },\n};\n\n// ── Stretch descriptor (a:stretch) ──\n\nexport const stretchDesc: CustomDescriptor<SourceRectangleOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrParts: string[] = [];\n if (opts.left !== undefined) attrParts.push(`l=\"${opts.left}\"`);\n if (opts.top !== undefined) attrParts.push(`t=\"${opts.top}\"`);\n if (opts.right !== undefined) attrParts.push(`r=\"${opts.right}\"`);\n if (opts.bottom !== undefined) attrParts.push(`b=\"${opts.bottom}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n return `<a:stretch><a:fillRect${attrStr}/></a:stretch>`;\n },\n parse(el, _ctx) {\n const fillRect = findChild(el, \"a:fillRect\");\n if (!fillRect) return {};\n const result: SourceRectangleOptions = {};\n if (fillRect.attributes?.[\"l\"] !== undefined) result.left = Number(fillRect.attributes[\"l\"]);\n if (fillRect.attributes?.[\"t\"] !== undefined) result.top = Number(fillRect.attributes[\"t\"]);\n if (fillRect.attributes?.[\"r\"] !== undefined) result.right = Number(fillRect.attributes[\"r\"]);\n if (fillRect.attributes?.[\"b\"] !== undefined) result.bottom = Number(fillRect.attributes[\"b\"]);\n return result;\n },\n};\n\n// ── Blip effects helpers ──\n\n/** Serialize a:blip adjustment effects (a:lum, a:duotone, …) in public units. */\nexport function stringifyBlipEffects(opts: BlipEffectsOptions, ctx: WriteContext): string {\n const parts: string[] = [];\n\n if (opts.grayscale) {\n parts.push(\"<a:grayscl/>\");\n }\n\n if (opts.luminance) {\n const attrParts: string[] = [];\n if (opts.luminance.bright !== undefined)\n attrParts.push(`bright=\"${emitPercent(opts.luminance.bright)}\"`);\n if (opts.luminance.contrast !== undefined)\n attrParts.push(`contrast=\"${emitPercent(opts.luminance.contrast)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:lum${attrStr}/>`);\n }\n\n if (opts.hsl) {\n const attrParts: string[] = [];\n if (opts.hsl.hue !== undefined) attrParts.push(`hue=\"${emitAngle(opts.hsl.hue)}\"`);\n if (opts.hsl.saturation !== undefined)\n attrParts.push(`sat=\"${emitPercent(opts.hsl.saturation)}\"`);\n if (opts.hsl.luminance !== undefined)\n attrParts.push(`lum=\"${emitPercent(opts.hsl.luminance)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:hsl${attrStr}/>`);\n }\n\n if (opts.tint) {\n const attrParts: string[] = [];\n if (opts.tint.hue !== undefined) attrParts.push(`hue=\"${emitAngle(opts.tint.hue)}\"`);\n if (opts.tint.amount !== undefined) attrParts.push(`amt=\"${emitPercent(opts.tint.amount)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:tint${attrStr}/>`);\n }\n\n if (opts.duotone) {\n const c1 = stringifyColorChoice(opts.duotone.color1, ctx);\n const c2 = stringifyColorChoice(opts.duotone.color2, ctx);\n parts.push(`<a:duotone>${c1}${c2}</a:duotone>`);\n }\n\n if (opts.biLevel) {\n parts.push(`<a:biLevel thresh=\"${emitPercent(opts.biLevel.threshold)}\"/>`);\n }\n\n if (opts.alphaCeiling) {\n parts.push(\"<a:alphaCeiling/>\");\n }\n\n if (opts.alphaFloor) {\n parts.push(\"<a:alphaFloor/>\");\n }\n\n if (opts.alphaInverse !== undefined) {\n if (typeof opts.alphaInverse === \"boolean\") {\n parts.push(\"<a:alphaInv/>\");\n } else {\n parts.push(`<a:alphaInv>${stringifyColorChoice(opts.alphaInverse, ctx)}</a:alphaInv>`);\n }\n }\n\n if (opts.alphaModulateFixed) {\n const amt = emitPercent(opts.alphaModulateFixed.amount ?? 100);\n parts.push(`<a:alphaModFix amt=\"${amt}\"/>`);\n }\n\n if (opts.alphaReplace) {\n parts.push(`<a:alphaRepl a=\"${emitPercent(opts.alphaReplace.alpha)}\"/>`);\n }\n\n if (opts.alphaBiLevel) {\n parts.push(`<a:alphaBiLevel thresh=\"${emitPercent(opts.alphaBiLevel.threshold)}\"/>`);\n }\n\n if (opts.colorChange) {\n const fromXml = stringifyColorChoice(opts.colorChange.from, ctx);\n const toXml = stringifyColorChoice(opts.colorChange.to, ctx);\n const attrParts: string[] = [];\n if (opts.colorChange.useAlpha === false) attrParts.push('useA=\"0\"');\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(\n `<a:clrChange${attrStr}><a:clrFrom>${fromXml ?? \"\"}</a:clrFrom><a:clrTo>${toXml ?? \"\"}</a:clrTo></a:clrChange>`,\n );\n }\n\n if (opts.colorReplace) {\n parts.push(`<a:clrRepl>${stringifyColorChoice(opts.colorReplace.color, ctx)}</a:clrRepl>`);\n }\n\n if (opts.blur) {\n const attrParts: string[] = [];\n if (opts.blur.radius !== undefined) attrParts.push(`rad=\"${opts.blur.radius}\"`);\n if (opts.blur.grow === false) attrParts.push('grow=\"0\"');\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:blur${attrStr}/>`);\n }\n\n return parts.join(\"\");\n}\n\nfunction readBlipEffects(el: XmlElement, ctx: ReadContext): BlipEffectsOptions | undefined {\n const result: BlipEffectsOptions = {};\n\n if (findChild(el, \"a:grayscl\")) result.grayscale = true;\n\n const lum = findChild(el, \"a:lum\");\n if (lum) {\n const opts: LuminanceEffectOptions = {};\n const bright = parsePercentAttr(lum.attributes?.[\"bright\"]);\n if (bright !== undefined) opts.bright = bright;\n const contrast = parsePercentAttr(lum.attributes?.[\"contrast\"]);\n if (contrast !== undefined) opts.contrast = contrast;\n result.luminance = opts;\n }\n\n const hsl = findChild(el, \"a:hsl\");\n if (hsl) {\n const opts: HSLEffectOptions = {};\n if (hsl.attributes?.[\"hue\"] !== undefined) opts.hue = parseAngle(Number(hsl.attributes[\"hue\"]));\n const sat = parsePercentAttr(hsl.attributes?.[\"sat\"]);\n if (sat !== undefined) opts.saturation = sat;\n const l = parsePercentAttr(hsl.attributes?.[\"lum\"]);\n if (l !== undefined) opts.luminance = l;\n result.hsl = opts;\n }\n\n const tint = findChild(el, \"a:tint\");\n if (tint) {\n const opts: TintEffectOptions = {};\n if (tint.attributes?.[\"hue\"] !== undefined)\n opts.hue = parseAngle(Number(tint.attributes[\"hue\"]));\n const amt = parsePercentAttr(tint.attributes?.[\"amt\"]);\n if (amt !== undefined) opts.amount = amt;\n result.tint = opts;\n }\n\n const biLevel = findChild(el, \"a:biLevel\");\n if (biLevel?.attributes?.[\"thresh\"] !== undefined) {\n result.biLevel = { threshold: parsePercentAttr(biLevel.attributes[\"thresh\"])! };\n }\n\n if (findChild(el, \"a:alphaCeiling\")) result.alphaCeiling = true;\n if (findChild(el, \"a:alphaFloor\")) result.alphaFloor = true;\n\n const alphaInv = findChild(el, \"a:alphaInv\");\n if (alphaInv) {\n const color = parseColorChoice(alphaInv, ctx);\n result.alphaInverse = Object.keys(color).length > 0 ? color : ({} as SolidFillOptions);\n }\n\n const alphaModFix = findChild(el, \"a:alphaModFix\");\n if (alphaModFix) {\n const opts: AlphaModulateFixedEffectOptions = {};\n const amt = parsePercentAttr(alphaModFix.attributes?.[\"amt\"]);\n if (amt !== undefined) opts.amount = amt;\n result.alphaModulateFixed = opts;\n }\n\n const alphaRepl = findChild(el, \"a:alphaRepl\");\n if (alphaRepl?.attributes?.[\"a\"] !== undefined) {\n result.alphaReplace = { alpha: parsePercentAttr(alphaRepl.attributes[\"a\"])! };\n }\n\n const alphaBiLevel = findChild(el, \"a:alphaBiLevel\");\n if (alphaBiLevel?.attributes?.[\"thresh\"] !== undefined) {\n result.alphaBiLevel = { threshold: parsePercentAttr(alphaBiLevel.attributes[\"thresh\"])! };\n }\n\n const clrChange = findChild(el, \"a:clrChange\");\n if (clrChange) {\n const opts: Partial<ColorChangeEffectOptions> = {};\n if (clrChange.attributes?.[\"useA\"] !== undefined)\n opts.useAlpha = parseOnOff(clrChange.attributes[\"useA\"]) ?? true;\n const clrFrom = findChild(clrChange, \"a:clrFrom\");\n if (clrFrom) opts.from = parseColorChoice(clrFrom, ctx);\n const clrTo = findChild(clrChange, \"a:clrTo\");\n if (clrTo) opts.to = parseColorChoice(clrTo, ctx);\n result.colorChange = opts as ColorChangeEffectOptions;\n }\n\n const clrRepl = findChild(el, \"a:clrRepl\");\n if (clrRepl) {\n result.colorReplace = { color: parseColorChoice(clrRepl, ctx) as SolidFillOptions };\n }\n\n const blur = findChild(el, \"a:blur\");\n if (blur) {\n const opts: BlipBlurEffectOptions = {};\n if (blur.attributes?.[\"rad\"] !== undefined) opts.radius = Number(blur.attributes[\"rad\"]);\n if (blur.attributes?.[\"grow\"] !== undefined)\n opts.grow = parseOnOff(blur.attributes[\"grow\"]) ?? true;\n result.blur = opts;\n }\n\n const duotone = findChild(el, \"a:duotone\");\n if (duotone?.elements) {\n // CT_Duotone carries two bare EG_ColorChoice children (no solidFill\n // wrapper) — take the first two color elements in order.\n const fills: SolidFillOptions[] = [];\n for (const child of duotone.elements) {\n const color = parseColorChoiceElement(child, ctx);\n if (color) fills.push(color);\n }\n const [color1, color2] = fills;\n if (color1 && color2) {\n result.duotone = { color1, color2 };\n }\n }\n\n return Object.keys(result).length > 0 ? (result as BlipEffectsOptions) : undefined;\n}\n\n// ── Blip descriptor (a:blip) ──\n\n/** The a14:useLocalDpi extension uri (CT_Blip extLst). */\nconst USE_LOCAL_DPI_EXT_URI = \"{28A0092B-C50C-407E-A947-70E740481C1C}\";\n\n/** Input shape of blipDesc — BlipOptions plus round-trip-only blip content. */\nexport type BlipDescriptorOptions = BlipOptions & {\n blipEffects?: BlipEffectsOptions;\n /**\n * a14:useLocalDpi from the blip extension list — Office's local-DPI display\n * hint, the dominant non-SVG a:blip ext content.\n */\n useLocalDpi?: boolean;\n /**\n * Verbatim `a:extLst` inner XML for extensions beyond useLocalDpi (a14\n * imgProps artistic effects, …). Round-trip only: takes precedence over\n * {@link useLocalDpi}, which it subsumes when the source list carries both.\n */\n ext?: string;\n};\n\nexport const blipDesc: CustomDescriptor<BlipDescriptorOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n // Attribute order matches Office output: r:embed, cstate, r:link. Every\n // attribute is optional (CT_Blip) and omitted when unset — a linked-only\n // picture carries r:link alone.\n const attrParts: string[] = [];\n if (opts.referenceId !== undefined)\n attrParts.push(`r:embed=\"{${escapeXml(opts.referenceId)}}\"`);\n if (opts.compression !== undefined) attrParts.push(`cstate=\"${opts.compression}\"`);\n if (opts.linkReferenceId !== undefined)\n attrParts.push(`r:link=\"{${escapeXml(opts.linkReferenceId)}}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const parts: string[] = [];\n if (opts.blipEffects) {\n parts.push(stringifyBlipEffects(opts.blipEffects, ctx));\n }\n // The verbatim channel subsumes useLocalDpi when both would apply.\n if (opts.ext !== undefined) {\n parts.push(`<a:extLst>${opts.ext}</a:extLst>`);\n } else if (opts.useLocalDpi !== undefined) {\n parts.push(\n `<a:extLst><a:ext uri=\"${USE_LOCAL_DPI_EXT_URI}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"${opts.useLocalDpi ? 1 : 0}\"/></a:ext></a:extLst>`,\n );\n }\n\n const content = parts.join(\"\");\n if (!content) return `<a:blip${attrStr}/>`;\n return `<a:blip${attrStr}>${content}</a:blip>`;\n },\n parse(el, ctx) {\n const result: Partial<BlipDescriptorOptions> = {};\n const embed = el.attributes?.[\"r:embed\"];\n if (embed !== undefined) {\n // Strip { and } wrapper if present\n result.referenceId = String(embed).replace(/^\\{(.+)\\}$/, \"$1\");\n }\n const link = el.attributes?.[\"r:link\"];\n if (link !== undefined) {\n result.linkReferenceId = String(link).replace(/^\\{(.+)\\}$/, \"$1\");\n }\n const cstate = el.attributes?.[\"cstate\"];\n if (cstate !== undefined) result.compression = cstate as BlipDescriptorOptions[\"compression\"];\n const effects = readBlipEffects(el, ctx);\n if (effects) result.blipEffects = effects;\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) {\n // Extensions beyond useLocalDpi (a14 imgProps effects, …) have no\n // structured model — keep the whole list verbatim and skip the\n // useLocalDpi extraction so the two channels never double-emit.\n const hasUnmodeled = (extLst.elements ?? []).some(\n (ext) => ext.name === \"a:ext\" && !extUriMatches(attr(ext, \"uri\"), USE_LOCAL_DPI_EXT_URI),\n );\n if (hasUnmodeled) {\n const inner = (extLst.elements ?? []).map((e) => stringifyElement(e)).join(\"\");\n if (inner) result.ext = inner;\n } else {\n for (const ext of extLst.elements ?? []) {\n if (ext.name !== \"a:ext\" || !extUriMatches(attr(ext, \"uri\"), USE_LOCAL_DPI_EXT_URI))\n continue;\n const useLocalDpi = findChild(ext, \"a14:useLocalDpi\");\n if (useLocalDpi !== undefined)\n result.useLocalDpi = parseOnOff(attr(useLocalDpi, \"val\")) ?? true;\n }\n }\n }\n return result as BlipDescriptorOptions;\n },\n};\n\n// ── BlipFill descriptor (pic:blipFill / a:blipFill) ──\n\nexport const blipFillDesc: CustomDescriptor<\n BlipFillOptions & { referenceId?: string; blipEffects?: BlipEffectsOptions }\n> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const attrParts: string[] = [];\n if (opts.dpi !== undefined) attrParts.push(`dpi=\"${opts.dpi}\"`);\n if (opts.rotWithShape !== undefined)\n attrParts.push(`rotWithShape=\"${opts.rotWithShape ? 1 : 0}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const parts: string[] = [];\n\n // Blip child (uses referenceId from parent)\n if (opts.referenceId) {\n const blipOpts = { referenceId: opts.referenceId, blipEffects: opts.blipEffects };\n const blipXml = stringify(blipDesc, blipOpts, ctx);\n if (blipXml) parts.push(blipXml);\n }\n\n // Source rectangle\n if (opts.sourceRectangle) {\n const srcRectXml = stringify(sourceRectangleDesc, opts.sourceRectangle, ctx);\n if (srcRectXml) parts.push(srcRectXml);\n }\n\n // Tile or stretch\n if (opts.tile) {\n const tileXml = stringify(tileDesc, opts.tile, ctx);\n if (tileXml) parts.push(tileXml);\n } else {\n parts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n\n const content = parts.join(\"\");\n if (!attrStr && !content) return undefined;\n if (!content) return `<pic:blipFill${attrStr}/>`;\n return `<pic:blipFill${attrStr}>${content}</pic:blipFill>`;\n },\n parse(el, ctx) {\n const result: Partial<\n BlipFillOptions & { referenceId?: string; blipEffects?: BlipEffectsOptions }\n > = {};\n\n // Attributes\n if (el.attributes?.[\"dpi\"] !== undefined) result.dpi = Number(el.attributes[\"dpi\"]);\n if (el.attributes?.[\"rotWithShape\"] !== undefined)\n result.rotWithShape = parseOnOff(el.attributes[\"rotWithShape\"]) ?? true;\n\n // Blip child\n const blip = findChild(el, \"a:blip\");\n if (blip) {\n const blipResult = parse(blipDesc, blip, ctx);\n if (blipResult.referenceId) result.referenceId = blipResult.referenceId;\n if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;\n }\n\n // Source rectangle\n const srcRect = findChild(el, \"a:srcRect\");\n if (srcRect) result.sourceRectangle = parse(sourceRectangleDesc, srcRect, ctx);\n\n // Tile\n const tile = findChild(el, \"a:tile\");\n if (tile) result.tile = parse(tileDesc, tile, ctx);\n\n return result as BlipFillOptions & { referenceId?: string; blipEffects?: BlipEffectsOptions };\n },\n};\n","/**\n * Blip image adjustment effects for DrawingML.\n *\n * These effects are applied directly to the image data within the `<a:blip>` element,\n * corresponding to Word's \"Picture Format > Adjust\" features (brightness, contrast,\n * grayscale, tint, duotone, etc.).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Blip children\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { emitAngle, emitPercent } from \"../../util/converters\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\n\n// ─── Effect option interfaces ────────────────────────────────────────\n\n/**\n * Options for luminance (brightness/contrast) effect.\n *\n * ## XSD: CT_LuminanceEffect\n * ```xml\n * <xsd:attribute name=\"bright\" type=\"ST_FixedPercentage\" default=\"0%\"/>\n * <xsd:attribute name=\"contrast\" type=\"ST_FixedPercentage\" default=\"0%\"/>\n * ```\n */\nexport interface LuminanceEffectOptions {\n /** Brightness adjustment in percentage points (-100 to 100). Default 0. */\n bright?: number;\n /** Contrast adjustment in percentage points (-100 to 100). Default 0. */\n contrast?: number;\n}\n\n/**\n * Options for HSL effect.\n *\n * ## XSD: CT_HSLEffect\n * ```xml\n * <xsd:attribute name=\"hue\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"sat\" type=\"ST_FixedPercentage\" default=\"0%\"/>\n * <xsd:attribute name=\"lum\" type=\"ST_FixedPercentage\" default=\"0%\"/>\n * ```\n */\nexport interface HSLEffectOptions {\n /** Hue rotation in degrees. Default 0. */\n hue?: number;\n /** Saturation adjustment in percentage points (-100 to 100). Default 0. */\n saturation?: number;\n /** Luminance adjustment in percentage points (-100 to 100). Default 0. */\n luminance?: number;\n}\n\n/**\n * Options for tint effect.\n *\n * ## XSD: CT_TintEffect\n * ```xml\n * <xsd:attribute name=\"hue\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"amt\" type=\"ST_FixedPercentage\" default=\"0%\"/>\n * ```\n */\nexport interface TintEffectOptions {\n /** Hue in degrees. Default 0. */\n hue?: number;\n /** Amount in percentage points (0 to 100). Default 0. */\n amount?: number;\n}\n\n/**\n * Options for duotone effect.\n *\n * ## XSD: CT_DuotoneEffect\n * ```xml\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"2\" maxOccurs=\"2\"/>\n * ```\n */\nexport interface DuotoneEffectOptions {\n /** First color (dark). */\n color1: SolidFillOptions;\n /** Second color (light). */\n color2: SolidFillOptions;\n}\n\n/**\n * Options for biLevel (black & white threshold) effect.\n *\n * ## XSD: CT_BiLevelEffect\n * ```xml\n * <xsd:attribute name=\"thresh\" type=\"ST_PositiveFixedPercentage\" use=\"required\"/>\n * ```\n */\nexport interface BiLevelEffectOptions {\n /** Threshold percentage (0 to 100). Pixels above are white, below are black. */\n threshold: number;\n}\n\n/**\n * Options for alpha replace effect.\n *\n * ## XSD: CT_AlphaReplaceEffect\n * ```xml\n * <xsd:attribute name=\"a\" type=\"ST_PositiveFixedPercentage\" use=\"required\"/>\n * ```\n */\nexport interface AlphaReplaceEffectOptions {\n /** Alpha percentage (0 = fully transparent, 100 = fully opaque). Maps to `@a`. */\n alpha: number;\n}\n\n/**\n * Options for alpha bi-level effect.\n *\n * ## XSD: CT_AlphaBiLevelEffect\n * ```xml\n * <xsd:attribute name=\"thresh\" type=\"ST_PositiveFixedPercentage\" use=\"required\"/>\n * ```\n */\nexport interface AlphaBiLevelEffectOptions {\n /** Threshold percentage (0 to 100). Alpha above is fully opaque, below is fully transparent. */\n threshold: number;\n}\n\n/**\n * Options for alpha modulate fixed effect.\n *\n * ## XSD: CT_AlphaModulateFixedEffect\n * ```xml\n * <xsd:attribute name=\"amt\" type=\"ST_PositivePercentage\" default=\"100%\"/>\n * ```\n */\nexport interface AlphaModulateFixedEffectOptions {\n /** Alpha amount in percentage (0 to 100). Default 100. */\n amount?: number;\n}\n\n/**\n * Options for color change effect.\n *\n * ## XSD: CT_ColorChangeEffect\n * ```xml\n * <xsd:element name=\"clrFrom\" type=\"CT_Color\"/>\n * <xsd:element name=\"clrTo\" type=\"CT_Color\"/>\n * <xsd:attribute name=\"useA\" type=\"xsd:boolean\" default=\"true\"/>\n * ```\n */\nexport interface ColorChangeEffectOptions {\n /** Source color to change from. */\n from: SolidFillOptions;\n /** Target color to change to. */\n to: SolidFillOptions;\n /** Whether to use alpha channel. Default true. */\n useAlpha?: boolean;\n}\n\n/**\n * Options for color replace effect.\n *\n * ## XSD: CT_ColorReplaceEffect\n * ```xml\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * ```\n */\nexport interface ColorReplaceEffectOptions {\n /** Replacement color. */\n color: SolidFillOptions;\n}\n\n/**\n * Options for blur effect on blip.\n *\n * ## XSD: CT_BlurEffect\n * ```xml\n * <xsd:attribute name=\"rad\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"grow\" type=\"xsd:boolean\" default=\"true\"/>\n * ```\n */\nexport interface BlipBlurEffectOptions {\n /** Blur radius in EMUs. Default 0. */\n radius?: number;\n /** Whether to grow the blur boundary. Default true. */\n grow?: boolean;\n}\n\n/**\n * All blip image adjustment effects.\n */\nexport interface BlipEffectsOptions {\n /** Grayscale effect (no options needed). */\n grayscale?: boolean;\n /** Luminance (brightness/contrast) effect. */\n luminance?: LuminanceEffectOptions;\n /** HSL adjustment effect. */\n hsl?: HSLEffectOptions;\n /** Tint effect. */\n tint?: TintEffectOptions;\n /** Duotone effect (two-color mapping). */\n duotone?: DuotoneEffectOptions;\n /** Black & white threshold effect. */\n biLevel?: BiLevelEffectOptions;\n /** Alpha ceiling effect (no options needed). */\n alphaCeiling?: boolean;\n /** Alpha floor effect (no options needed). */\n alphaFloor?: boolean;\n /** Alpha inverse effect (with optional color). */\n alphaInverse?: SolidFillOptions;\n /** Alpha modulate fixed effect. */\n alphaModulateFixed?: AlphaModulateFixedEffectOptions;\n /** Alpha replace effect. */\n alphaReplace?: AlphaReplaceEffectOptions;\n /** Alpha bi-level effect. */\n alphaBiLevel?: AlphaBiLevelEffectOptions;\n /** Color change effect. */\n colorChange?: ColorChangeEffectOptions;\n /** Color replace effect. */\n colorReplace?: ColorReplaceEffectOptions;\n /** Blur effect on blip. */\n blur?: BlipBlurEffectOptions;\n}\n\n// ─── Factory functions ───────────────────────────────────────────────\n\n/**\n * Creates blip effect elements from BlipEffectsOptions.\n *\n * @returns Array of XML strings representing blip effects\n */\nexport const createBlipEffects = (options: BlipEffectsOptions): string[] => {\n const children: string[] = [];\n\n if (options.grayscale) {\n children.push(`<a:grayscl/>`);\n }\n\n if (options.luminance) {\n const attrs: Record<string, string | number | undefined> = {};\n if (options.luminance.bright !== undefined) {\n attrs.bright = `${emitPercent(options.luminance.bright)}`;\n }\n if (options.luminance.contrast !== undefined) {\n attrs.contrast = `${emitPercent(options.luminance.contrast)}`;\n }\n children.push(element(\"a:lum\", attrs));\n }\n\n if (options.hsl) {\n const attrs: Record<string, string | number | undefined> = {};\n if (options.hsl.hue !== undefined) {\n attrs.hue = `${emitAngle(options.hsl.hue)}`;\n }\n if (options.hsl.saturation !== undefined) {\n attrs.sat = `${emitPercent(options.hsl.saturation)}`;\n }\n if (options.hsl.luminance !== undefined) {\n attrs.lum = `${emitPercent(options.hsl.luminance)}`;\n }\n children.push(element(\"a:hsl\", attrs));\n }\n\n if (options.tint) {\n const attrs: Record<string, string | number | undefined> = {};\n if (options.tint.hue !== undefined) {\n attrs.hue = `${emitAngle(options.tint.hue)}`;\n }\n if (options.tint.amount !== undefined) {\n attrs.amt = `${emitPercent(options.tint.amount)}`;\n }\n children.push(element(\"a:tint\", attrs));\n }\n\n if (options.duotone) {\n children.push(\n element(\"a:duotone\", undefined, [\n createColorElement(options.duotone.color1),\n createColorElement(options.duotone.color2),\n ]),\n );\n }\n\n if (options.biLevel) {\n children.push(`<a:biLevel thresh=\"${emitPercent(options.biLevel.threshold)}\"/>`);\n }\n\n if (options.alphaCeiling) {\n children.push(`<a:alphaCeiling/>`);\n }\n\n if (options.alphaFloor) {\n children.push(`<a:alphaFloor/>`);\n }\n\n if (options.alphaInverse !== undefined) {\n if (typeof options.alphaInverse === \"boolean\") {\n children.push(`<a:alphaInv/>`);\n } else {\n children.push(element(\"a:alphaInv\", undefined, [createColorElement(options.alphaInverse)]));\n }\n }\n\n if (options.alphaModulateFixed) {\n const amt = emitPercent(options.alphaModulateFixed.amount ?? 100);\n children.push(`<a:alphaModFix amt=\"${amt}\"/>`);\n }\n\n if (options.alphaReplace) {\n children.push(`<a:alphaRepl a=\"${emitPercent(options.alphaReplace.alpha)}\"/>`);\n }\n\n if (options.alphaBiLevel) {\n children.push(`<a:alphaBiLevel thresh=\"${emitPercent(options.alphaBiLevel.threshold)}\"/>`);\n }\n\n if (options.colorChange) {\n const attrs: Record<string, string | number | undefined> = {};\n if (options.colorChange.useAlpha === false) {\n attrs.useA = \"0\";\n }\n children.push(\n element(\"a:clrChange\", attrs, [\n element(\"a:clrFrom\", undefined, [createColorElement(options.colorChange.from)]),\n element(\"a:clrTo\", undefined, [createColorElement(options.colorChange.to)]),\n ]),\n );\n }\n\n if (options.colorReplace) {\n children.push(\n element(\"a:clrRepl\", undefined, [createColorElement(options.colorReplace.color)]),\n );\n }\n\n if (options.blur) {\n const attrs: Record<string, string | number | undefined> = {};\n if (options.blur.radius !== undefined) {\n attrs.rad = options.blur.radius;\n }\n if (options.blur.grow === false) {\n attrs.grow = 0;\n }\n children.push(element(\"a:blur\", attrs));\n }\n\n return children;\n};\n","/**\n * Source rectangle module for blip fills.\n *\n * This module defines the portion of an image to use when filling a shape.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n/**\n * Options for source rectangle cropping.\n *\n * Each value is integer percent (10 = 10% crop from that edge of the image).\n */\nexport interface SourceRectangleOptions {\n /** Left inset as integer percent (10 = 10% crop from left) */\n left?: number;\n /** Top inset as integer percent (10 = 10% crop from top) */\n top?: number;\n /** Right inset as integer percent (10 = 10% crop from right) */\n right?: number;\n /** Bottom inset as integer percent (10 = 10% crop from bottom) */\n bottom?: number;\n}\n\n/**\n * Creates a source rectangle element for blip fill cropping.\n *\n * This element specifies a portion of the blip (image) to use as the fill.\n * When no options are provided, the entire blip is used.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_RelativeRect\">\n * <xsd:attribute name=\"l\" type=\"ST_Percentage\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"t\" type=\"ST_Percentage\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"r\" type=\"ST_Percentage\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"b\" type=\"ST_Percentage\" use=\"optional\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Crop 10% from left and right\n * createSourceRectangle({ left: 10, right: 10 });\n * ```\n */\nexport const createSourceRectangle = (\n options?: SourceRectangleOptions,\n tag: string = \"a:srcRect\",\n): string => {\n if (!options) {\n return element(tag);\n }\n\n const attrs: Record<string, string | number | undefined> = {};\n if (options.left !== undefined) attrs.l = Math.round(options.left * 1000);\n if (options.top !== undefined) attrs.t = Math.round(options.top * 1000);\n if (options.right !== undefined) attrs.r = Math.round(options.right * 1000);\n if (options.bottom !== undefined) attrs.b = Math.round(options.bottom * 1000);\n\n return element(tag, attrs);\n};\n","/**\n * Tile fill module for blip fills.\n *\n * This module defines how images are tiled (repeated) to fill shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdRectAlignment } from \"../../util/mappings\";\nimport type { UniversalMeasure } from \"../../util/values\";\n\n/**\n * Tile flip mode for tiling images.\n *\n * Specifies whether the image is flipped along the x-axis, y-axis,\n * both axes, or not at all when tiling.\n */\nexport type TileFlipMode = \"none\" | \"x\" | \"y\" | \"xy\";\n\n/**\n * Tile alignment within the shape.\n *\n * Specifies the anchor position of the first tile relative to the shape.\n */\nexport type TileAlignment =\n | \"topLeft\"\n | \"top\"\n | \"topRight\"\n | \"left\"\n | \"center\"\n | \"right\"\n | \"bottomLeft\"\n | \"bottom\"\n | \"bottomRight\";\n\n/**\n * Options for tile fill mode.\n *\n * Configures how an image is tiled (repeated) to fill a shape.\n */\nexport interface TileOptions {\n /** Horizontal offset for the tile origin in EMUs (number) or UniversalMeasure. */\n tx?: number | UniversalMeasure;\n /** Vertical offset for the tile origin in EMUs (number) or UniversalMeasure. */\n ty?: number | UniversalMeasure;\n /** Horizontal scale as integer percent (100 = 100%) */\n sx?: number;\n /** Vertical scale as integer percent (100 = 100%) */\n sy?: number;\n /** Flip mode for alternating tiles */\n flip?: TileFlipMode;\n /** Alignment of the first tile within the shape */\n alignment?: TileAlignment;\n}\n\n/**\n * Creates a tile fill mode element for blip fills.\n *\n * When a blip fill uses tile mode, the image is repeated (tiled) to fill\n * the shape instead of being stretched. This element controls the tiling\n * parameters such as offset, scale, flip, and alignment.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TileInfoProperties\">\n * <xsd:attribute name=\"tx\" type=\"ST_Coordinate\" use=\"optional\"/>\n * <xsd:attribute name=\"ty\" type=\"ST_Coordinate\" use=\"optional\"/>\n * <xsd:attribute name=\"sx\" type=\"ST_Percentage\" use=\"optional\"/>\n * <xsd:attribute name=\"sy\" type=\"ST_Percentage\" use=\"optional\"/>\n * <xsd:attribute name=\"flip\" type=\"ST_TileFlipMode\" default=\"none\"/>\n * <xsd:attribute name=\"algn\" type=\"ST_RectAlignment\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Tile with 50% scale\n * createTileInfo({ sx: 50, sy: 50 });\n * // Tile with flip and alignment\n * createTileInfo({ flip: \"xy\", alignment: \"center\" });\n * ```\n */\nexport const createTileInfo = (options?: TileOptions): string => {\n if (!options) {\n return `<a:tile/>`;\n }\n\n const attrs: Record<string, string | number | undefined> = {};\n if (options.tx !== undefined) attrs.tx = convertToEmu(options.tx);\n if (options.ty !== undefined) attrs.ty = convertToEmu(options.ty);\n if (options.sx !== undefined) attrs.sx = Math.round(options.sx * 1000);\n if (options.sy !== undefined) attrs.sy = Math.round(options.sy * 1000);\n if (options.flip !== undefined) attrs.flip = options.flip;\n if (options.alignment !== undefined) attrs.algn = xsdRectAlignment.to(options.alignment);\n\n return element(\"a:tile\", attrs);\n};\n","/**\n * Fill descriptors for DrawingML EG_FillProperties.\n *\n * @module\n */\n\nimport { element, escapeXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext } from \"../../descriptor\";\nimport { parse } from \"../../descriptor\";\nimport { emitAngle, emitPercent, parseAngle, parsePercent } from \"../../util/converters\";\nimport { toUint8Array } from \"../../util/data-type\";\nimport { uniqueId } from \"../../util/generators\";\nimport { imageTypeFromPath } from \"../../util/image-type\";\nimport { xsdPattern } from \"../../util/mappings\";\nimport { parseOnOff, stripColorHashPrefix } from \"../../util/values\";\nimport { blipFillDesc } from \"../blip/blip-descriptors\";\nimport { createBlipEffects } from \"../blip/blip-effects\";\nimport { createSourceRectangle } from \"../blip/source-rectangle\";\nimport { createTileInfo } from \"../blip/tile\";\nimport { solidFillDesc, parseColorChoice, emitColorChoice } from \"../color/color-descriptors\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport type { BlipFillConfigOptions, FillOptions } from \"./fill-options\";\nimport type {\n GradientFillOptions,\n GradientShadeOptions,\n LinearShadeOptions,\n PathShadeOptions,\n RelativeRect,\n} from \"./gradient-fill\";\nimport type { PatternFillOptions } from \"./pattern-fill\";\n\n// ── Gradient fill helpers ──\n\nfunction stringifyRelativeRect(tag: string, rect: RelativeRect): string {\n const parts: string[] = [];\n if (rect.left) parts.push(`l=\"${escapeXml(rect.left)}\"`);\n if (rect.top) parts.push(`t=\"${escapeXml(rect.top)}\"`);\n if (rect.right) parts.push(`r=\"${escapeXml(rect.right)}\"`);\n if (rect.bottom) parts.push(`b=\"${escapeXml(rect.bottom)}\"`);\n const attrStr = parts.length ? \" \" + parts.join(\" \") : \"\";\n return `<${tag}${attrStr}/>`;\n}\n\nfunction readRelativeRect(el: XmlElement): RelativeRect {\n const result: RelativeRect = {};\n if (el.attributes?.[\"l\"]) result.left = String(el.attributes[\"l\"]);\n if (el.attributes?.[\"t\"]) result.top = String(el.attributes[\"t\"]);\n if (el.attributes?.[\"r\"]) result.right = String(el.attributes[\"r\"]);\n if (el.attributes?.[\"b\"]) result.bottom = String(el.attributes[\"b\"]);\n return result as RelativeRect;\n}\n\nfunction stringifyShade(shade: GradientShadeOptions): string {\n if (\"angle\" in shade) {\n const parts: string[] = [];\n if (shade.angle !== undefined) parts.push(`ang=\"${emitAngle(shade.angle)}\"`);\n if (shade.scaled !== undefined) parts.push(`scaled=\"${shade.scaled ? 1 : 0}\"`);\n const attrStr = parts.length ? \" \" + parts.join(\" \") : \"\";\n return `<a:lin${attrStr}/>`;\n }\n const pathShade = shade as PathShadeOptions;\n const parts: string[] = [];\n if (pathShade.path) parts.push(`path=\"${escapeXml(pathShade.path)}\"`);\n const attrStr = parts.length ? \" \" + parts.join(\" \") : \"\";\n if (pathShade.fillToRectangle) {\n return `<a:path${attrStr}>${stringifyRelativeRect(\"a:fillToRect\", pathShade.fillToRectangle)}</a:path>`;\n }\n return `<a:path${attrStr}/>`;\n}\n\n// ── GradientFill descriptor ──\n\nexport const gradientFillDesc: CustomDescriptor<GradientFillOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n return emitGradientFillXml(opts);\n },\n parse(el, ctx) {\n const result: Partial<GradientFillOptions> = {};\n\n // Stops — a:gs contains EG_ColorChoice directly (no solidFill wrapper)\n const gsLst = findChild(el, \"a:gsLst\");\n if (gsLst?.elements) {\n result.stops = gsLst.elements\n .filter((c) => c.name === \"a:gs\")\n .map((gs) => {\n const pos = Number(gs.attributes?.[\"pos\"] ?? 0);\n const color = readDirectColor(gs, ctx);\n return { position: parsePercent(pos), color };\n });\n }\n\n // Shade (a:lin or a:path)\n const lin = findChild(el, \"a:lin\");\n if (lin) {\n const shade: LinearShadeOptions = {};\n if (lin.attributes?.[\"ang\"] !== undefined)\n shade.angle = parseAngle(Number(lin.attributes[\"ang\"]));\n if (lin.attributes?.[\"scaled\"] !== undefined)\n shade.scaled = parseOnOff(lin.attributes[\"scaled\"]) ?? true;\n result.shade = shade;\n } else {\n const path = findChild(el, \"a:path\");\n if (path) {\n const shade: PathShadeOptions = {};\n if (path.attributes?.[\"path\"] !== undefined)\n shade.path = String(path.attributes[\"path\"]) as PathShadeOptions[\"path\"];\n const fillToRectangle = findChild(path, \"a:fillToRect\");\n if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);\n result.shade = shade;\n }\n }\n\n // Flip\n if (el.attributes?.[\"flip\"] !== undefined)\n result.flip = String(el.attributes[\"flip\"]) as GradientFillOptions[\"flip\"];\n\n // Rotate with shape\n if (el.attributes?.[\"rotWithShape\"] !== undefined)\n result.rotateWithShape = parseOnOff(el.attributes[\"rotWithShape\"]) ?? true;\n\n // Tile rect\n const tileRectangle = findChild(el, \"a:tileRect\");\n if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);\n\n return result as GradientFillOptions;\n },\n};\n\n// ── PatternFill descriptor ──\n\nexport const patternFillDesc: CustomDescriptor<PatternFillOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n return emitPatternFillXml(opts);\n },\n parse(el, ctx) {\n const result: Partial<PatternFillOptions> = {};\n\n const prst = el.attributes?.[\"prst\"];\n if (prst) result.pattern = xsdPattern.from(String(prst)) as PatternFillOptions[\"pattern\"];\n\n const fgClr = findChild(el, \"a:fgClr\");\n if (fgClr) {\n result.foregroundColor = readDirectColor(fgClr, ctx);\n }\n\n const bgClr = findChild(el, \"a:bgClr\");\n if (bgClr) {\n result.backgroundColor = readDirectColor(bgClr, ctx);\n }\n\n return result as PatternFillOptions;\n },\n};\n\n// ── Fill (EG_FillProperties) descriptor ──\n\n// ── Fill (EG_FillProperties) serialization — single source ──\n\n/**\n * Serialize any FillOptions (string shorthand or object union, blip included)\n * without a write context. The blip variant takes the embed placeholder\n * directly — callers with a write context get it from `ctx.addMedia`.\n */\nexport function emitFillXml(options: FillOptions, embedPlaceholder?: string): string | undefined {\n // String shorthand → solid fill\n if (typeof options === \"string\") {\n return `<a:solidFill>${emitColorChoice({ value: stripColorHashPrefix(options) } as SolidFillOptions)}</a:solidFill>`;\n }\n\n switch (options.type) {\n case \"none\":\n return \"<a:noFill/>\";\n\n case \"solid\": {\n const color =\n typeof options.color === \"string\"\n ? ({ value: stripColorHashPrefix(options.color) } as SolidFillOptions)\n : options.color;\n return `<a:solidFill>${emitColorChoice(color)}</a:solidFill>`;\n }\n\n case \"gradient\": {\n // Core API variant; a one-stop gradient is skipped (gsLst needs >=2)\n if (\"options\" in options) {\n return emitGradientFillXml(options.options);\n }\n // Simplified API variant\n const gradOpts: GradientFillOptions = {\n stops: options.stops.map((stop) => ({\n position: stop.position,\n color:\n typeof stop.color === \"string\"\n ? ({ value: stripColorHashPrefix(stop.color) } as SolidFillOptions)\n : stop.color,\n })),\n };\n if (!options.path && options.angle !== undefined) {\n gradOpts.shade = { angle: options.angle, scaled: options.scaled ?? true };\n }\n if (options.path) {\n gradOpts.shade = { path: options.path };\n }\n return emitGradientFillXml(gradOpts);\n }\n\n case \"blip\":\n return emitBlipFill(options, embedPlaceholder);\n\n case \"pattern\": {\n const patternOpts: PatternFillOptions = {\n pattern: options.pattern as PatternFillOptions[\"pattern\"],\n ...(options.foregroundColor && {\n foregroundColor:\n typeof options.foregroundColor === \"string\"\n ? ({ value: stripColorHashPrefix(options.foregroundColor) } as SolidFillOptions)\n : options.foregroundColor,\n }),\n ...(options.backgroundColor && {\n backgroundColor:\n typeof options.backgroundColor === \"string\"\n ? ({ value: stripColorHashPrefix(options.backgroundColor) } as SolidFillOptions)\n : options.backgroundColor,\n }),\n };\n return emitPatternFillXml(patternOpts);\n }\n\n case \"group\":\n return \"<a:grpFill/>\";\n }\n}\n\n/** Serialize a:gradFill from full GradientFillOptions (descriptor emission). */\nfunction emitGradientFillXml(opts: GradientFillOptions): string | undefined {\n // a:gsLst requires at least two a:gs stops (CT_GradientStopList) — a single\n // stop cannot form a gradient, so the fill is skipped rather than emitted\n // as an illegal one-stop list.\n if (opts.stops.length < 2) return undefined;\n\n const parts: string[] = [];\n\n // Gradient stop list — a:gs expects EG_ColorChoice (direct color), NOT solidFill\n const stopsXml = opts.stops\n .map((stop) => {\n const colorXml = emitColorChoice(stop.color);\n if (!colorXml) return `<a:gs pos=\"${emitPercent(stop.position)}\"/>`;\n return `<a:gs pos=\"${emitPercent(stop.position)}\">${colorXml}</a:gs>`;\n })\n .join(\"\");\n parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);\n\n // Shade\n if (opts.shade) parts.push(stringifyShade(opts.shade));\n\n // Tile rect\n if (opts.tileRectangle) parts.push(stringifyRelativeRect(\"a:tileRect\", opts.tileRectangle));\n\n // Attributes\n const attrParts: string[] = [];\n if (opts.flip) attrParts.push(`flip=\"${escapeXml(opts.flip)}\"`);\n if (opts.rotateWithShape !== undefined)\n attrParts.push(`rotWithShape=\"${opts.rotateWithShape ? 1 : 0}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n return `<a:gradFill${attrStr}>${parts.join(\"\")}</a:gradFill>`;\n}\n\n/** Serialize a:pattFill from PatternFillOptions (descriptor emission). */\nfunction emitPatternFillXml(opts: PatternFillOptions): string {\n const parts: string[] = [];\n const prst = xsdPattern.to(opts.pattern);\n\n // a:fgClr/a:bgClr expect EG_ColorChoice (direct color), NOT solidFill\n if (opts.foregroundColor) {\n const colorXml = emitColorChoice(opts.foregroundColor);\n if (colorXml) parts.push(`<a:fgClr>${colorXml}</a:fgClr>`);\n }\n if (opts.backgroundColor) {\n const colorXml = emitColorChoice(opts.backgroundColor);\n if (colorXml) parts.push(`<a:bgClr>${colorXml}</a:bgClr>`);\n }\n\n const inner = parts.join(\"\");\n return `<a:pattFill prst=\"${escapeXml(prst)}\">${inner}</a:pattFill>`;\n}\n\n/** Serialize a:blipFill with the given embed reference (descriptor emission). */\nfunction emitBlipFill(options: BlipFillConfigOptions & { type: \"blip\" }, embed?: string): string {\n // Build a:blip with {fileName} placeholder — the packer's ImageReplacer\n // replaces `{fileName}` with `rId{N}` and creates the relationship. When the\n // caller supplies embed (a media reference already registered with the write\n // context, e.g. `{image1.png}`), use it verbatim so the emitted reference\n // matches the registration.\n const fileName = `${uniqueId()}.${options.imageType ?? \"png\"}`;\n const embedRef = embed ?? `{${fileName}}`;\n\n const blipChildren: string[] = [];\n if (options.blipEffects) {\n blipChildren.push(...createBlipEffects(options.blipEffects));\n }\n // noEmbed: the source blip carried no r:embed (an empty marker) — re-emit\n // it bare instead of fabricating a media reference.\n // The r: prefix is declared inline on the blip: hosts whose root declares\n // only the a: namespace (a theme's fmtScheme) still get well-formed XML.\n const R_NS = \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\";\n const blip = options.noEmbed\n ? element(\"a:blip\", undefined, blipChildren.length > 0 ? blipChildren : undefined)\n : element(\n \"a:blip\",\n { cstate: \"none\", \"xmlns:r\": R_NS, \"r:embed\": embedRef },\n blipChildren.length > 0 ? blipChildren : undefined,\n );\n\n const children: string[] = [blip];\n // a:srcRect is optional in CT_BlipFillProperties — emit it only when the\n // source carried one (round-trip); a bare <a:srcRect/> round-trips as {}.\n if (options.sourceRectangle !== undefined)\n children.push(createSourceRectangle(options.sourceRectangle));\n if (options.tile) {\n children.push(createTileInfo(options.tile));\n } else {\n children.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n const attrs: Record<string, string | number | undefined> = {};\n if (options.dpi !== undefined) attrs.dpi = options.dpi;\n if (options.rotWithShape !== undefined) attrs.rotWithShape = options.rotWithShape ? 1 : 0;\n return element(\"a:blipFill\", attrs, children);\n}\n\nexport const fillDesc: CustomDescriptor<FillOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n if (typeof opts !== \"string\" && opts.type === \"blip\") {\n // noEmbed: an empty-marker blip — nothing to register with the media\n // store; emit the bare a:blipFill shape (attrs, srcRect, stretch).\n if (opts.noEmbed) return emitBlipFill(opts);\n // Register the image media via the write context, then emit a:blipFill\n // with the returned {fileName} placeholder. The format-package compiler\n // replaces the placeholder with a relationship rId at pack time.\n const placeholder = ctx.addMedia(\n toUint8Array(opts.data!, { encoding: \"base64\" }),\n opts.imageType!,\n );\n return emitBlipFill(opts, placeholder);\n }\n return emitFillXml(opts);\n },\n parse(el, ctx) {\n // Resolve fill element — either el itself or its first fill child\n const fillEl = el.name !== undefined && FILL_TAGS.has(el.name) ? el : findFillChild(el);\n if (!fillEl) return { type: \"none\" };\n\n switch (fillEl.name) {\n case \"a:noFill\":\n return { type: \"none\" };\n\n case \"a:solidFill\":\n return { type: \"solid\", color: parse(solidFillDesc, fillEl, ctx) };\n\n case \"a:gradFill\":\n return {\n type: \"gradient\",\n options: parse(gradientFillDesc, fillEl, ctx) as GradientFillOptions,\n };\n\n case \"a:pattFill\":\n return { type: \"pattern\", ...(parse(patternFillDesc, fillEl, ctx) as PatternFillOptions) };\n\n case \"a:grpFill\":\n return { type: \"group\" };\n\n case \"a:blipFill\": {\n // Blip fill (image) — resolve r:embed to binary media via the read context\n const blipOpts = parse(blipFillDesc, fillEl, ctx);\n const mediaPath = blipOpts.referenceId\n ? ctx.resolveRelationship(blipOpts.referenceId)\n : undefined;\n const data = mediaPath ? ctx.getRaw(mediaPath) : undefined;\n if (mediaPath && data) {\n const blip: BlipFillConfigOptions & { type: \"blip\" } = {\n type: \"blip\",\n data,\n imageType: imageTypeFromPath(mediaPath),\n fileName: mediaPath.split(\"/\").pop(),\n };\n if (blipOpts.dpi !== undefined) blip.dpi = blipOpts.dpi;\n if (blipOpts.rotWithShape !== undefined) blip.rotWithShape = blipOpts.rotWithShape;\n if (blipOpts.blipEffects) blip.blipEffects = blipOpts.blipEffects;\n if (blipOpts.sourceRectangle) blip.sourceRectangle = blipOpts.sourceRectangle;\n if (blipOpts.tile) blip.tile = blipOpts.tile;\n return blip;\n }\n if (blipOpts.referenceId === undefined) {\n // Empty a:blip (no r:embed) — Word's pic:spPr duplicate of\n // pic:blipFill references no image of its own. Keep the fill shape\n // (attrs, srcRect, stretch) instead of degrading to noFill.\n const blip: BlipFillConfigOptions & { type: \"blip\" } = { type: \"blip\", noEmbed: true };\n if (blipOpts.dpi !== undefined) blip.dpi = blipOpts.dpi;\n if (blipOpts.rotWithShape !== undefined) blip.rotWithShape = blipOpts.rotWithShape;\n if (blipOpts.sourceRectangle) blip.sourceRectangle = blipOpts.sourceRectangle;\n if (blipOpts.tile) blip.tile = blipOpts.tile;\n return blip;\n }\n return { type: \"none\" };\n }\n\n default:\n return { type: \"none\" };\n }\n },\n};\n\n// ── Fill child discovery ──\n\nconst FILL_TAGS: ReadonlySet<string> = new Set([\n \"a:noFill\",\n \"a:solidFill\",\n \"a:gradFill\",\n \"a:pattFill\",\n \"a:grpFill\",\n \"a:blipFill\",\n]);\n\n/**\n * Find the first EG_FillProperties child of an element (any of the six fill\n * kinds) in a single scan — the shared existence probe for sites that only\n * parse a fill when one is present.\n */\nexport function findFillChild(el: XmlElement): XmlElement | undefined {\n for (const child of el.elements ?? []) {\n if (child.type === \"element\" && child.name !== undefined && FILL_TAGS.has(child.name)) {\n return child;\n }\n }\n return undefined;\n}\n\n// ── Helper: read EG_ColorChoice directly from an element ──\n\nfunction readDirectColor(el: XmlElement, ctx: ReadContext): SolidFillOptions {\n // Handles all six color kinds (srgbClr/schemeClr/hslClr/sysClr/prstClr/scrgbClr).\n const color = parseColorChoice(el, ctx);\n if (Object.keys(color).length > 0) return color;\n // Fallback: try solidFill wrapper (for backward compat with old-generated XML)\n const solidFill = findChild(el, \"a:solidFill\");\n if (solidFill) return parse(solidFillDesc, solidFill, ctx);\n return { value: \"\" };\n}\n","import { toUint8Array } from \"../../util/data-type\";\nimport type { DataType } from \"../../util/data-type\";\nimport { uniqueId } from \"../../util/generators\";\nimport type { HexColor } from \"../../util/values\";\nimport type { BlipEffectsOptions } from \"../blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"../blip/source-rectangle\";\nimport type { TileOptions } from \"../blip/tile\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { emitFillXml } from \"./fill-descriptors\";\nimport type { GradientFillOptions } from \"./gradient-fill\";\nimport type { PresetPattern } from \"./pattern-fill\";\n\n/**\n * Gradient stop options (simplified API).\n * Position is 0-100 (percentage), color is a hex string or SolidFillOptions.\n */\nexport interface GradientStopOptions {\n position: number;\n color: HexColor | SolidFillOptions;\n}\n\n/**\n * Blip fill options (image fill) for DrawingML shapes.\n */\nexport interface BlipFillConfigOptions {\n /**\n * An empty a:blip carrying no r:embed — Word emits this in a pic:spPr\n * duplicate of pic:blipFill (the spPr copy references no image of its\n * own). No media is registered; the blip re-emits empty. When set, data\n * and imageType are meaningless.\n */\n noEmbed?: true;\n /** Image data: raw bytes, ArrayBuffer, or a base64 data URL string. */\n data?: DataType;\n imageType?: \"png\" | \"jpg\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n /**\n * Source media file name, pinned on round-trip so re-emitting registers the\n * media under its original name instead of a re-derived one (jpeg→jpg\n * normalization would otherwise fork a second media part).\n */\n fileName?: string;\n /** DPI of the image */\n dpi?: number;\n /** Whether the fill rotates with the shape */\n rotWithShape?: boolean;\n /** Image adjustment effects (brightness, contrast, grayscale, etc.) */\n blipEffects?: BlipEffectsOptions;\n /** Source rectangle for cropping */\n sourceRectangle?: SourceRectangleOptions;\n /** Tile fill mode (if omitted, defaults to stretch) */\n tile?: TileOptions;\n}\n\n/**\n * Media data extracted from a blip fill, for registration with the document's media store.\n */\nexport interface BlipFillMediaData {\n fileName: string;\n data: Uint8Array;\n type: string;\n}\n\n/**\n * Fill options — discriminated union for DrawingML EG_FillProperties.\n *\n * Supports string shorthand for solid fill (most common case).\n * Color fields accept hex strings or advanced SolidFillOptions\n * (scheme color, HSL, etc.).\n *\n * @example\n * // Solid fill (shorthand)\n * fill: \"4472C4\"\n * // Solid fill with scheme color\n * fill: { type: \"solid\", color: { value: \"accent1\" } }\n * // No fill\n * fill: { type: \"none\" }\n * // Gradient fill — linear\n * fill: { type: \"gradient\", angle: 90, stops: [{ position: 0, color: \"4472C4\" }, { position: 100, color: \"ED7D31\" }] }\n * // Gradient fill — path (radial)\n * fill: { type: \"gradient\", path: \"circle\", stops: [{ position: 0, color: \"FFFFFF\" }, { position: 100, color: \"4472C4\" }] }\n * // Gradient fill (core API for advanced options)\n * fill: { type: \"gradient\", options: { stops: [...], shade: { angle: 90 } } }\n * // Blip fill (image)\n * fill: { type: \"blip\", data: imageBuffer, imageType: \"png\" }\n * // Pattern fill\n * fill: { type: \"pattern\", pattern: \"cross\", foregroundColor: \"FF0000\" }\n * // Group fill\n * fill: { type: \"group\" }\n */\nexport type FillOptions =\n | string\n | { type: \"solid\"; color: string | SolidFillOptions }\n | { type: \"none\" }\n | {\n type: \"gradient\";\n angle?: number;\n scaled?: boolean;\n path?: \"shape\" | \"circle\" | \"rect\";\n stops: readonly GradientStopOptions[];\n }\n | { type: \"gradient\"; options: GradientFillOptions }\n | ({ type: \"blip\" } & BlipFillConfigOptions)\n | {\n type: \"pattern\";\n /** Preset pattern (a:pattFill `@prst`, ST_PresetPatternVal). */\n pattern: PresetPattern;\n foregroundColor?: HexColor | SolidFillOptions;\n backgroundColor?: HexColor | SolidFillOptions;\n }\n | { type: \"group\" };\n\n/**\n * Extracts media data from a blip fill option, if present.\n * Returns undefined for non-blip fills.\n *\n * The returned data should be registered with the document's media store\n * during serialization so the packer can resolve the `{fileName}` placeholder.\n *\n * @param fill - Fill options to inspect\n * @param nameAllocator - Optional sequential name provider (e.g. a format\n * package's media counter). When omitted, falls back to a random id so the\n * function stays usable from contexts without a shared counter.\n */\nexport const extractBlipFillMedia = (\n fill: FillOptions,\n nameAllocator?: (type: string) => string,\n): BlipFillMediaData | undefined => {\n // A noEmbed blip fill carries no media of its own (empty a:blip marker).\n if (typeof fill === \"string\" || fill.type !== \"blip\" || !fill.data || !fill.imageType)\n return undefined;\n const raw = toUint8Array(fill.data);\n const fileName = nameAllocator\n ? nameAllocator(fill.imageType)\n : `${uniqueId()}.${fill.imageType}`;\n return { data: raw, fileName, type: fill.imageType };\n};\n\n/**\n * Builds a DrawingML fill XML string from a FillOptions config.\n * Thin delegate to the single serializer in the fill descriptors — kept as the\n * context-free public entry (blip fills mint a `{fileName}` embed placeholder\n * unless the caller supplies one).\n */\nexport const buildFill = (options: FillOptions, embedPlaceholder?: string): string | undefined =>\n emitFillXml(options, embedPlaceholder);\n","/**\n * No fill element for DrawingML shapes.\n *\n * This module provides the no-fill option for outline and shape fills.\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n/**\n * Creates a no-fill element.\n *\n * Specifies that the outline or shape should have no fill applied.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:element name=\"noFill\" type=\"CT_Empty\"/>\n * ```\n *\n * @example\n * ```typescript\n * const noFill = createNoFill();\n * ```\n */\nexport const createNoFill = (): string => element(\"a:noFill\");\n","/**\n * Gradient fill element for DrawingML shapes.\n *\n * This module provides gradient fill support with linear and path shading.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GradientFillProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { TileFlipMode } from \"../blip/tile\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createColorElement } from \"../color/solid-fill\";\n\n// Single home for the shared ST_TileFlipMode token set is blip/tile.ts;\n// re-exported here for gradient-fill consumers.\nexport type { TileFlipMode } from \"../blip/tile\";\n\n/**\n * Gradient stop position as integer percent (0-100).\n */\nexport interface GradientStop {\n /** Position of the color stop as integer percent (0-100). */\n position: number;\n /** Color at this stop */\n color: SolidFillOptions;\n}\n\n/**\n * Path shade type for radial gradients.\n */\nexport type PathShade = \"shape\" | \"circle\" | \"rect\";\n\n/**\n * Options for linear gradient shading.\n */\nexport interface LinearShadeOptions {\n /** Angle in degrees (e.g., 90 = 90°). */\n angle?: number;\n /** Whether the angle scales with the shape */\n scaled?: boolean;\n}\n\n/**\n * Relative rectangle (CT_RelativeRect) with percentage offsets.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_RelativeRect\">\n * <xsd:attribute name=\"l\" type=\"ST_Percentage\" default=\"0%\"/>\n * <xsd:attribute name=\"t\" type=\"ST_Percentage\" default=\"0%\"/>\n * <xsd:attribute name=\"r\" type=\"ST_Percentage\" default=\"0%\"/>\n * <xsd:attribute name=\"b\" type=\"ST_Percentage\" default=\"0%\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface RelativeRect {\n /** Left offset percentage (e.g., \"0%\") */\n left?: string;\n /** Top offset percentage (e.g., \"0%\") */\n top?: string;\n /** Right offset percentage (e.g., \"0%\") */\n right?: string;\n /** Bottom offset percentage (e.g., \"0%\") */\n bottom?: string;\n}\n\n/**\n * Options for path (radial) gradient shading.\n */\nexport interface PathShadeOptions {\n /** Path type */\n path?: PathShade;\n /**\n * Fill-to rectangle for path gradient.\n *\n * Defines the rectangle to which the gradient fills.\n */\n fillToRectangle?: RelativeRect;\n}\n\n/**\n * Gradient shade options (linear or path).\n */\nexport type GradientShadeOptions = LinearShadeOptions | PathShadeOptions;\n\n/**\n * Options for gradient fill.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_GradientFillProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"gsLst\" type=\"CT_GradientStopList\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_ShadeProperties\" minOccurs=\"0\"/>\n * <xsd:element name=\"tileRect\" type=\"CT_RelativeRect\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"flip\" type=\"ST_TileFlipMode\" use=\"optional\"/>\n * <xsd:attribute name=\"rotWithShape\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface GradientFillOptions {\n /** Gradient color stops (minimum 2) */\n stops: readonly GradientStop[];\n /** Shade type (linear or path) */\n shade?: GradientShadeOptions;\n /**\n * Tile flip mode.\n *\n * Controls how the gradient is flipped when tiled.\n */\n flip?: TileFlipMode;\n /**\n * Tile rectangle for gradient tiling.\n *\n * Defines the rectangle used for gradient tiling.\n */\n tileRectangle?: RelativeRect;\n /** Whether gradient rotates with the shape */\n rotateWithShape?: boolean;\n}\n\n/**\n * Creates a gradient stop element (a:gs).\n *\n * @example\n * ```typescript\n * createGradientStop({ position: 0, color: { value: \"FF0000\" } });\n * createGradientStop({ position: 100, color: { value: \"0000FF\" } });\n * ```\n */\nexport const createGradientStop = (stop: GradientStop): string =>\n element(\"a:gs\", { pos: Math.round(stop.position * 1000) }, [createColorElement(stop.color)]);\n\n/**\n * Creates a relative rect element.\n */\nconst createRelativeRect = (name: string, rect?: RelativeRect): string =>\n element(name, {\n l: rect?.left,\n t: rect?.top,\n r: rect?.right,\n b: rect?.bottom,\n });\n\n/**\n * Creates the shade element (a:lin or a:path).\n */\nconst createShadeElement = (shade: GradientShadeOptions): string => {\n if (\"angle\" in shade) {\n return element(\"a:lin\", {\n ang: shade.angle !== undefined ? Math.round(shade.angle * 60000) : undefined,\n scaled: shade.scaled,\n });\n }\n const pathShade = shade as PathShadeOptions;\n const children: string[] = [];\n\n if (pathShade.fillToRectangle) {\n children.push(createRelativeRect(\"a:fillToRect\", pathShade.fillToRectangle));\n }\n\n return element(\"a:path\", { path: pathShade.path }, children);\n};\n\n/**\n * Creates a gradient fill element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_GradientFillProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"gsLst\" type=\"CT_GradientStopList\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_ShadeProperties\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"rotWithShape\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Linear gradient from red to blue\n * createGradientFill({\n * stops: [\n * { position: 0, color: { value: \"FF0000\" } },\n * { position: 100, color: { value: \"0000FF\" } },\n * ],\n * shade: { angle: 90 },\n * });\n * ```\n */\nexport const createGradientFill = (options: GradientFillOptions): string => {\n const children: string[] = [];\n\n // Gradient stop list\n const stopElements = options.stops.map(createGradientStop);\n children.push(element(\"a:gsLst\", undefined, stopElements));\n\n // Shade properties (a:lin or a:path)\n if (options.shade) {\n children.push(createShadeElement(options.shade));\n }\n\n // Tile rectangle\n if (options.tileRectangle) {\n children.push(createRelativeRect(\"a:tileRect\", options.tileRectangle));\n }\n\n return element(\n \"a:gradFill\",\n {\n flip: options.flip,\n rotWithShape: options.rotateWithShape,\n },\n children,\n );\n};\n","/**\n * Pattern fill element for DrawingML shapes.\n *\n * This module provides pattern fill support with preset patterns and\n * optional foreground/background colors.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PatternFillProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdPattern } from \"../../util/mappings\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createColorElement } from \"../color/solid-fill\";\n\n/**\n * Preset pattern values for pattern fill.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PresetPatternVal\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"pct5\"/> ... <xsd:enumeration value=\"zigZag\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\n/**\n * Preset pattern values (a:pattFill `@prst`, ST_PresetPatternVal) — full\n * words; xsdPattern maps them to the abbreviated XSD tokens.\n */\nexport type PresetPattern =\n | \"percent5\"\n | \"percent10\"\n | \"percent20\"\n | \"percent25\"\n | \"percent30\"\n | \"percent40\"\n | \"percent50\"\n | \"percent60\"\n | \"percent70\"\n | \"percent75\"\n | \"percent80\"\n | \"percent90\"\n | \"horizontal\"\n | \"vertical\"\n | \"lightHorizontal\"\n | \"lightVertical\"\n | \"darkHorizontal\"\n | \"darkVertical\"\n | \"narrowHorizontal\"\n | \"narrowVertical\"\n | \"dashedHorizontal\"\n | \"dashedVertical\"\n | \"cross\"\n | \"downDiagonal\"\n | \"upDiagonal\"\n | \"lightDownDiagonal\"\n | \"lightUpDiagonal\"\n | \"darkDownDiagonal\"\n | \"darkUpDiagonal\"\n | \"wideDownDiagonal\"\n | \"wideUpDiagonal\"\n | \"dashedDownDiagonal\"\n | \"dashedUpDiagonal\"\n | \"diagonalCross\"\n | \"smallChecker\"\n | \"largeChecker\"\n | \"smallGrid\"\n | \"largeGrid\"\n | \"dotGrid\"\n | \"smallConfetti\"\n | \"largeConfetti\"\n | \"horizontalBrick\"\n | \"diagonalBrick\"\n | \"solidDiamond\"\n | \"openDiamond\"\n | \"dottedDiamond\"\n | \"plaid\"\n | \"sphere\"\n | \"weave\"\n | \"divot\"\n | \"shingle\"\n | \"wave\"\n | \"trellis\"\n | \"zigZag\";\n\n/**\n * Options for pattern fill.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PatternFillProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"fgClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * <xsd:element name=\"bgClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"prst\" type=\"ST_PresetPatternVal\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface PatternFillOptions {\n /** Preset pattern type */\n pattern: PresetPattern;\n foregroundColor?: SolidFillOptions;\n backgroundColor?: SolidFillOptions;\n}\n\n/**\n * Creates a pattern fill element (a:pattFill).\n *\n * Specifies a pattern fill using preset patterns with optional\n * foreground and background colors.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PatternFillProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"fgClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * <xsd:element name=\"bgClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"prst\" type=\"ST_PresetPatternVal\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Simple crosshatch pattern\n * createPatternFill({ pattern: PresetPattern.CROSS });\n * // Pattern with foreground color\n * createPatternFill({\n * pattern: PresetPattern.DIAG_CROSS,\n * foregroundColor: { value: \"FF0000\" },\n * });\n * // Pattern with foreground and background colors\n * createPatternFill({\n * pattern: PresetPattern.HORZ,\n * foregroundColor: { value: \"0000FF\" },\n * backgroundColor: { value: \"FFFF00\" },\n * });\n * ```\n */\nexport const createPatternFill = (options: PatternFillOptions): string => {\n const children: string[] = [];\n\n if (options.foregroundColor) {\n children.push(element(\"a:fgClr\", undefined, [createColorElement(options.foregroundColor)]));\n }\n\n if (options.backgroundColor) {\n children.push(element(\"a:bgClr\", undefined, [createColorElement(options.backgroundColor)]));\n }\n\n return element(\"a:pattFill\", { prst: xsdPattern.to(options.pattern) }, children);\n};\n","/**\n * Group fill element for DrawingML shapes.\n *\n * This module provides group fill support which inherits the fill\n * from the parent group shape.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GroupFillProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n/**\n * Creates a group fill element (a:grpFill).\n *\n * This element specifies that the shape should inherit its fill\n * from the parent group shape. This is useful when shapes are\n * grouped together and should share the same fill.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_GroupFillProperties\"/>\n * ```\n *\n * @example\n * ```typescript\n * // Shape inherits fill from parent group\n * createGroupFill();\n * ```\n */\nexport const createGroupFill = (): string => element(\"a:grpFill\");\n","/**\n * Custom dash pattern for DrawingML outlines.\n *\n * This module provides support for custom dash patterns defined by\n * a list of dash stops, each specifying dash and space lengths as\n * percentages relative to line width.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_DashStopList, CT_DashStop\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { PositivePercentage } from \"../../util/values\";\n\n/**\n * A single dash stop in a custom dash pattern.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_DashStop\">\n * <xsd:attribute name=\"d\" type=\"ST_PositivePercentage\" use=\"required\"/>\n * <xsd:attribute name=\"sp\" type=\"ST_PositivePercentage\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * `ST_PositivePercentage` is a string matching `[0-9]+(\\.[0-9]+)?%`\n * (e.g., `\"100%\"`, `\"500%\"`, `\"50.5%\"`).\n *\n * @example\n * ```typescript\n * // A dash stop with 500% dash length and 200% space length\n * { d: \"500%\", sp: \"200%\" }\n * ```\n */\nexport interface DashStop {\n /** Dash length as a percentage of line width (e.g., \"500%\") */\n d: PositivePercentage;\n /** Space length as a percentage of line width (e.g., \"200%\") */\n sp: PositivePercentage;\n}\n\n/**\n * Creates a custom dash element (a:custDash) for outlines.\n *\n * The custom dash element specifies a repeating pattern of dash and space\n * segments. Each segment is defined by a `DashStop` with dash (`d`) and\n * space (`sp`) lengths as positive percentages of the line width.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_DashStopList\">\n * <xsd:sequence>\n * <xsd:element name=\"ds\" type=\"CT_DashStop\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Simple dash pattern\n * createCustomDash([\n * { d: \"500%\", sp: \"200%\" },\n * ]);\n *\n * // Complex alternating pattern\n * createCustomDash([\n * { d: \"500%\", sp: \"200%\" },\n * { d: \"100%\", sp: \"200%\" },\n * ]);\n * ```\n */\nexport const createCustomDash = (stops: readonly DashStop[]): string => {\n const children: string[] = [];\n\n for (const stop of stops) {\n children.push(`<a:ds d=\"${stop.d}\" sp=\"${stop.sp}\"/>`);\n }\n\n return element(\"a:custDash\", undefined, children);\n};\n","/**\n * Line end (arrow) properties for DrawingML outlines.\n *\n * This module provides support for line end markers (arrows) on shape outlines.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineEndProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdLineEndSize } from \"../../util/mappings\";\n\n/**\n * Line end types (arrow head styles).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_LineEndType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"triangle\"/>\n * <xsd:enumeration value=\"stealth\"/>\n * <xsd:enumeration value=\"diamond\"/>\n * <xsd:enumeration value=\"oval\"/>\n * <xsd:enumeration value=\"arrow\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport type LineEndType = \"none\" | \"triangle\" | \"stealth\" | \"diamond\" | \"oval\" | \"arrow\";\n\n/**\n * Line end width options.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_LineEndWidth\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"sm\"/>\n * <xsd:enumeration value=\"med\"/>\n * <xsd:enumeration value=\"lg\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport type LineEndWidth = \"small\" | \"medium\" | \"large\";\n\n/**\n * Line end length options.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_LineEndLength\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"sm\"/>\n * <xsd:enumeration value=\"med\"/>\n * <xsd:enumeration value=\"lg\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport type LineEndLength = \"small\" | \"medium\" | \"large\";\n\n/**\n * Options for line end (arrow) properties.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_LineEndProperties\">\n * <xsd:attribute name=\"type\" type=\"ST_LineEndType\" use=\"optional\" default=\"none\"/>\n * <xsd:attribute name=\"w\" type=\"ST_LineEndWidth\" use=\"optional\"/>\n * <xsd:attribute name=\"len\" type=\"ST_LineEndLength\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface LineEndOptions {\n /** Arrow/head type (omitted in source means the OOXML default `none`). */\n type?: LineEndType;\n /** Arrow width */\n width?: LineEndWidth;\n /** Arrow length */\n length?: LineEndLength;\n}\n\n/**\n * Creates a line end element (a:headEnd or a:tailEnd).\n *\n * @example\n * ```typescript\n * // Stealth arrow at start, medium size\n * createLineEnd(\"a:headEnd\", { type: \"stealth\", width: \"medium\", length: \"medium\" });\n * // Triangle arrow at end\n * createLineEnd(\"a:tailEnd\", { type: \"triangle\" });\n * ```\n */\nexport const createLineEnd = (name: string, options: LineEndOptions): string =>\n element(name, {\n type: options.type,\n w: options.width ? xsdLineEndSize.to(options.width) : undefined,\n len: options.length ? xsdLineEndSize.to(options.length) : undefined,\n });\n","import { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdCompoundLine, xsdLineCap, xsdPenAlignment } from \"../../util/mappings\";\nimport { stripColorHashPrefix } from \"../../util/values\";\n/**\n * Outline (line) properties for DrawingML shapes.\n *\n * This module provides support for configuring outline properties including\n * width, cap style, compound line types, fill properties, dash, and join.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineProperties\n *\n * @module\n */\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createSolidFill } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createGradientFill } from \"../fill/gradient-fill\";\nimport type { GradientFillOptions } from \"../fill/gradient-fill\";\nimport { createNoFill } from \"../fill/no-fill\";\nimport { createPatternFill } from \"../fill/pattern-fill\";\nimport type { PatternFillOptions } from \"../fill/pattern-fill\";\nimport { createCustomDash } from \"./custom-dash\";\nimport type { DashStop } from \"./custom-dash\";\nimport { createLineEnd } from \"./line-end\";\nimport type { LineEndOptions } from \"./line-end\";\n\n// <xsd:complexType name=\"CT_LineProperties\">\n// <xsd:sequence>\n// <xsd:group ref=\"EG_LineFillProperties\" minOccurs=\"0\"/>\n// <xsd:group ref=\"EG_LineDashProperties\" minOccurs=\"0\"/>\n// <xsd:group ref=\"EG_LineJoinProperties\" minOccurs=\"0\"/>\n// </xsd:sequence>\n// <xsd:attribute name=\"w\" use=\"optional\" type=\"a:ST_LineWidth\"/>\n// <xsd:attribute name=\"cap\" use=\"optional\" type=\"ST_LineCap\"/>\n// <xsd:attribute name=\"cmpd\" use=\"optional\" type=\"ST_CompoundLine\"/>\n// <xsd:attribute name=\"algn\" use=\"optional\" type=\"ST_PenAlignment\"/>\n// </xsd:complexType>\n\n// <xsd:simpleType name=\"ST_LineCap\">\n// <xsd:restriction base=\"xsd:string\">\n// <xsd:enumeration value=\"rnd\"/>\n// <xsd:enumeration value=\"sq\"/>\n// <xsd:enumeration value=\"flat\"/>\n// </xsd:restriction>\n// </xsd:simpleType>\n\n/**\n * Line cap styles for outline endpoints.\n *\n * Defines how the ends of a line are rendered.\n */\nexport type LineCap = \"round\" | \"square\" | \"flat\";\n\n// <xsd:simpleType name=\"ST_CompoundLine\">\n// <xsd:restriction base=\"xsd:string\">\n// <xsd:enumeration value=\"sng\"/>\n// <xsd:enumeration value=\"dbl\"/>\n// <xsd:enumeration value=\"thickThin\"/>\n// <xsd:enumeration value=\"thinThick\"/>\n// <xsd:enumeration value=\"tri\"/>\n// </xsd:restriction>\n// </xsd:simpleType>\n\n/**\n * Compound line types for outlines.\n *\n * Defines the structure of compound lines (single, double, etc.).\n */\nexport type CompoundLine = \"single\" | \"double\" | \"thickThin\" | \"thinThick\" | \"triple\";\n\n// <xsd:simpleType name=\"ST_PenAlignment\">\n// <xsd:restriction base=\"xsd:string\">\n// <xsd:enumeration value=\"ctr\"/>\n// <xsd:enumeration value=\"in\"/>\n// </xsd:restriction>\n// </xsd:simpleType>\n\n/**\n * Pen alignment options for outline positioning.\n *\n * Defines how the outline is aligned relative to the shape edge.\n */\nexport type PenAlignment = \"center\" | \"inside\";\n\n/**\n * Preset dash styles for outlines.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PresetLineDashVal\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"solid\"/>\n * <xsd:enumeration value=\"dot\"/>\n * <xsd:enumeration value=\"dash\"/>\n * <xsd:enumeration value=\"lgDash\"/>\n * <xsd:enumeration value=\"dashDot\"/>\n * <xsd:enumeration value=\"lgDashDot\"/>\n * <xsd:enumeration value=\"lgDashDotDot\"/>\n * <xsd:enumeration value=\"sysDash\"/>\n * <xsd:enumeration value=\"sysDot\"/>\n * <xsd:enumeration value=\"sysDashDot\"/>\n * <xsd:enumeration value=\"sysDashDotDot\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport type PresetDash =\n | \"solid\"\n | \"dot\"\n | \"dash\"\n | \"lgDash\"\n | \"dashDot\"\n | \"lgDashDot\"\n | \"lgDashDotDot\"\n | \"sysDash\"\n | \"sysDot\"\n | \"sysDashDot\"\n | \"sysDashDotDot\";\n\n/**\n * Line join styles.\n */\nexport type LineJoin = \"round\" | \"bevel\" | \"miter\";\n\n/**\n * Attributes for configuring outline properties.\n */\nexport interface OutlineProperties {\n /** Line width in EMUs (English Metric Units) or universal measure (e.g., \"1pt\", \"2mm\") */\n width?: number | UniversalMeasure;\n /** Line cap style */\n cap?: LineCap;\n /** Compound line type */\n compoundLine?: CompoundLine;\n /** Pen alignment */\n alignment?: PenAlignment;\n /**\n * Preset dash style.\n *\n * Mutually exclusive with `customDash` — only one can be specified.\n */\n dash?: PresetDash;\n /**\n * Custom dash pattern (list of dash/space stops).\n *\n * Mutually exclusive with `dash` — only one can be specified.\n */\n customDash?: readonly DashStop[];\n /** Line join style */\n join?: LineJoin;\n /** Miter limit (only when join is MITER) */\n miterLimit?: number;\n /** Line start arrow/head */\n headEnd?: LineEndOptions;\n /** Line end arrow/tail */\n tailEnd?: LineEndOptions;\n /** Trailing a:extLst inner XML for line-property extensions. */\n ext?: string;\n}\n\n/**\n * Fill properties for outline (EG_LineFillProperties).\n *\n * Supports noFill, solidFill, gradFill, and pattFill per XSD.\n * blipFill and grpFill are not applicable to lines.\n */\nexport interface OutlineFillProperties {\n /** Fill type */\n type?: \"noFill\" | \"solidFill\" | \"gradFill\" | \"pattFill\";\n /**\n * Color definition (required when type is \"solidFill\"). A bare string is\n * sRGB hex sugar (`\"FF0000\"`); stringify coerces it to `{ value }` and\n * infers \"solidFill\"; parse always emits the normalized form.\n */\n color?: SolidFillOptions | string;\n /** Gradient fill options (required when type is \"gradFill\") */\n gradientFill?: GradientFillOptions;\n /** Pattern fill options (required when type is \"pattFill\") */\n patternFill?: PatternFillOptions;\n}\n\n/**\n * Complete outline configuration options.\n *\n * Combines outline attributes with fill properties.\n */\nexport type OutlineOptions = OutlineProperties & OutlineFillProperties;\n\n/**\n * Creates the fill child element for an outline.\n *\n * Returns null when no fill type is specified (OOXML allows outline without fill).\n */\nconst createOutlineFill = (options: OutlineOptions): string | null => {\n if (options.type === \"noFill\") {\n return createNoFill();\n }\n // Bare-string color is an sRGB hex sugar; coerce and infer solidFill.\n const resolvedColor =\n typeof options.color === \"string\"\n ? { value: stripColorHashPrefix(options.color) }\n : options.color;\n const fillType = options.type ?? (resolvedColor ? \"solidFill\" : undefined);\n if (fillType === \"solidFill\" && resolvedColor) {\n return createSolidFill(resolvedColor);\n }\n if (fillType === \"gradFill\" && options.gradientFill) {\n return createGradientFill(options.gradientFill);\n }\n if (fillType === \"pattFill\" && options.patternFill) {\n return createPatternFill(options.patternFill);\n }\n return null;\n};\n\n/**\n * Creates an outline element for DrawingML shapes.\n *\n * The outline element specifies the line properties for the shape border,\n * including width, cap style, compound line type, alignment, dash, join, and fill.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_LineProperties\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_FillProperties\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_LineDashProperties\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_LineJoinProperties\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"w\" use=\"optional\" type=\"a:ST_LineWidth\"/>\n * <xsd:attribute name=\"cap\" use=\"optional\" type=\"ST_LineCap\"/>\n * <xsd:attribute name=\"cmpd\" use=\"optional\" type=\"ST_CompoundLine\"/>\n * <xsd:attribute name=\"algn\" use=\"optional\" type=\"ST_PenAlignment\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Outline with RGB color and dash\n * const outline = createOutline({\n * width: 9525,\n * type: \"solidFill\",\n * color: { value: \"FF0000\" },\n * dash: \"dash\",\n * });\n * ```\n */\nexport const createOutline = (options: OutlineOptions): string => {\n const children: string[] = [];\n\n // Fill (optional per OOXML spec)\n const fill = createOutlineFill(options);\n if (fill) {\n children.push(fill);\n }\n\n // Dash (prstDash and custDash are mutually exclusive per XSD choice)\n if (options.customDash !== undefined) {\n children.push(createCustomDash(options.customDash));\n } else if (options.dash !== undefined) {\n children.push(`<a:prstDash val=\"${options.dash}\"/>`);\n }\n\n // Join\n if (options.join !== undefined) {\n if (options.join === \"miter\" && options.miterLimit !== undefined) {\n children.push(`<a:miter lim=\"${options.miterLimit}\"/>`);\n } else {\n children.push(`<a:${options.join}/>`);\n }\n }\n\n // Line end markers (arrows)\n if (options.headEnd) {\n children.push(createLineEnd(\"a:headEnd\", options.headEnd));\n }\n if (options.tailEnd) {\n children.push(createLineEnd(\"a:tailEnd\", options.tailEnd));\n }\n\n return element(\n \"a:ln\",\n {\n algn: options.alignment ? xsdPenAlignment.to(options.alignment) : undefined,\n cap: options.cap ? xsdLineCap.to(options.cap) : undefined,\n cmpd: options.compoundLine ? xsdCompoundLine.to(options.compoundLine) : undefined,\n w: options.width !== undefined ? convertToEmu(options.width) : undefined,\n },\n children,\n );\n};\n","/**\n * Outline descriptor for DrawingML shapes.\n *\n * @module\n */\n\nimport { escapeXml, findChild, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { stringify, parse } from \"../../descriptor\";\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdCompoundLine, xsdLineCap, xsdLineEndSize, xsdPenAlignment } from \"../../util/mappings\";\nimport { stripColorHashPrefix } from \"../../util/values\";\nimport { solidFillDesc } from \"../color/color-descriptors\";\nimport { gradientFillDesc, patternFillDesc } from \"../fill/fill-descriptors\";\nimport type { DashStop } from \"./custom-dash\";\nimport type { LineEndOptions } from \"./line-end\";\nimport type { OutlineOptions } from \"./outline\";\n\n// ── LineEnd helpers ──\n\nfunction stringifyLineEnd(tag: string, opts: LineEndOptions): string {\n const parts: string[] = [];\n if (opts.type) parts.push(`type=\"${escapeXml(opts.type)}\"`);\n if (opts.width) parts.push(`w=\"${escapeXml(xsdLineEndSize.to(opts.width))}\"`);\n if (opts.length) parts.push(`len=\"${escapeXml(xsdLineEndSize.to(opts.length))}\"`);\n const attrStr = parts.length ? \" \" + parts.join(\" \") : \"\";\n return `<${tag}${attrStr}/>`;\n}\n\nfunction readLineEnd(el: XmlElement): LineEndOptions {\n const result: Partial<LineEndOptions> = {};\n if (el.attributes?.[\"type\"])\n result.type = String(el.attributes[\"type\"]) as LineEndOptions[\"type\"];\n if (el.attributes?.[\"w\"])\n result.width = xsdLineEndSize.from(String(el.attributes[\"w\"])) as LineEndOptions[\"width\"];\n if (el.attributes?.[\"len\"])\n result.length = xsdLineEndSize.from(String(el.attributes[\"len\"])) as LineEndOptions[\"length\"];\n return result as LineEndOptions;\n}\n\n// ── Custom dash helper ──\n\nfunction stringifyCustomDash(stops: readonly DashStop[]): string {\n const inner = stops.map((s) => `<a:ds d=\"${escapeXml(s.d)}\" sp=\"${escapeXml(s.sp)}\"/>`).join(\"\");\n return `<a:custDash>${inner}</a:custDash>`;\n}\n\n// ── Outline descriptor ──\n\n/**\n * Serialize CT_LineProperties content under an arbitrary root tag. Shared by\n * a:ln and the text-underline line element a:uLn (same complex type).\n */\nexport function stringifyLineProperties(\n tag: string,\n opts: OutlineOptions,\n ctx: Parameters<CustomDescriptor<OutlineOptions>[\"stringify\"]>[1],\n): string | undefined {\n const parts: string[] = [];\n\n // Attributes\n const attrParts: string[] = [];\n // ST_LineWidth is EMU (integer) or a universal measure; normalize so the\n // descriptor path matches createOutline (outline.ts) and stays XSD-valid.\n if (opts.width !== undefined) attrParts.push(`w=\"${convertToEmu(opts.width)}\"`);\n // Map full-word enums to XSD tokens (rnd/sng/ctr), matching createOutline.\n if (opts.cap !== undefined) attrParts.push(`cap=\"${escapeXml(xsdLineCap.to(opts.cap))}\"`);\n if (opts.compoundLine !== undefined)\n attrParts.push(`cmpd=\"${escapeXml(xsdCompoundLine.to(opts.compoundLine))}\"`);\n if (opts.alignment !== undefined)\n attrParts.push(`algn=\"${escapeXml(xsdPenAlignment.to(opts.alignment))}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n // Fill. A bare-string color is an sRGB hex sugar; coerce to { value } and\n // infer \"solidFill\" when type is omitted (mirrors the fill descriptor's\n // own string-sugar handling).\n const resolvedColor =\n typeof opts.color === \"string\" ? { value: stripColorHashPrefix(opts.color) } : opts.color;\n const fillType = opts.type ?? (resolvedColor ? \"solidFill\" : undefined);\n if (fillType === \"noFill\") {\n parts.push(\"<a:noFill/>\");\n } else if (fillType === \"solidFill\" && resolvedColor) {\n const fillXml = stringify(solidFillDesc, resolvedColor, ctx);\n if (fillXml) parts.push(fillXml);\n } else if (fillType === \"gradFill\" && opts.gradientFill) {\n const gradXml = stringify(gradientFillDesc, opts.gradientFill, ctx);\n if (gradXml) parts.push(gradXml);\n } else if (fillType === \"pattFill\" && opts.patternFill) {\n const pattXml = stringify(patternFillDesc, opts.patternFill, ctx);\n if (pattXml) parts.push(pattXml);\n }\n\n // Dash\n if (opts.customDash) {\n parts.push(stringifyCustomDash(opts.customDash));\n } else if (opts.dash) {\n parts.push(`<a:prstDash val=\"${escapeXml(opts.dash)}\"/>`);\n }\n\n // Join\n if (opts.join) {\n if (opts.join === \"miter\" && opts.miterLimit !== undefined) {\n parts.push(`<a:miter lim=\"${opts.miterLimit}\"/>`);\n } else {\n parts.push(`<a:${opts.join}/>`);\n }\n }\n\n // Line ends\n if (opts.headEnd) parts.push(stringifyLineEnd(\"a:headEnd\", opts.headEnd));\n if (opts.tailEnd) parts.push(stringifyLineEnd(\"a:tailEnd\", opts.tailEnd));\n\n if (opts.ext !== undefined) parts.push(`<a:extLst>${opts.ext}</a:extLst>`);\n\n // An empty object emits the bare element — sources often carry a bare\n // <a:ln/> (or <a:uLn/>) that must survive a round-trip.\n if (parts.length === 0 && !attrStr) return `<${tag}/>`;\n if (parts.length === 0) return `<${tag}${attrStr}/>`;\n return `<${tag}${attrStr}>${parts.join(\"\")}</${tag}>`;\n}\n\nexport const outlineDesc: CustomDescriptor<OutlineOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n return stringifyLineProperties(\"a:ln\", opts, ctx);\n },\n parse(el, _ctx) {\n const result: OutlineOptions = {};\n\n // Attributes\n if (el.attributes) {\n if (el.attributes[\"w\"] !== undefined) result.width = Number(el.attributes[\"w\"]);\n // Reverse-map XSD tokens back to full-word enums so the parsed Options\n // match the user-facing type (round/single/center), not raw tokens.\n if (el.attributes[\"cap\"] !== undefined)\n result.cap = xsdLineCap.from(String(el.attributes[\"cap\"])) as OutlineOptions[\"cap\"];\n if (el.attributes[\"cmpd\"] !== undefined)\n result.compoundLine = xsdCompoundLine.from(\n String(el.attributes[\"cmpd\"]),\n ) as OutlineOptions[\"compoundLine\"];\n if (el.attributes[\"algn\"] !== undefined)\n result.alignment = xsdPenAlignment.from(\n String(el.attributes[\"algn\"]),\n ) as OutlineOptions[\"alignment\"];\n }\n\n // Fill\n const solidFill = findChild(el, \"a:solidFill\");\n if (solidFill) {\n result.type = \"solidFill\";\n result.color = parse(solidFillDesc, solidFill, _ctx);\n }\n if (findChild(el, \"a:noFill\")) {\n result.type = \"noFill\";\n }\n const gradFill = findChild(el, \"a:gradFill\");\n if (gradFill) {\n result.type = \"gradFill\";\n result.gradientFill = parse(gradientFillDesc, gradFill, _ctx);\n }\n const pattFill = findChild(el, \"a:pattFill\");\n if (pattFill) {\n result.type = \"pattFill\";\n result.patternFill = parse(patternFillDesc, pattFill, _ctx);\n }\n\n // Dash\n const prstDash = findChild(el, \"a:prstDash\");\n if (prstDash?.attributes?.[\"val\"])\n result.dash = String(prstDash.attributes[\"val\"]) as OutlineOptions[\"dash\"];\n const custDash = findChild(el, \"a:custDash\");\n if (custDash?.elements) {\n result.customDash = custDash.elements\n .filter((c) => c.name === \"a:ds\")\n .map(\n (c) =>\n ({\n d: String(c.attributes?.[\"d\"] ?? \"\"),\n sp: String(c.attributes?.[\"sp\"] ?? \"\"),\n }) as DashStop,\n );\n }\n\n // Join\n if (findChild(el, \"a:round\")) result.join = \"round\";\n else if (findChild(el, \"a:bevel\")) result.join = \"bevel\";\n else {\n const miter = findChild(el, \"a:miter\");\n if (miter) {\n result.join = \"miter\";\n if (miter.attributes?.[\"lim\"]) result.miterLimit = Number(miter.attributes[\"lim\"]);\n }\n }\n\n // Line ends\n const headEnd = findChild(el, \"a:headEnd\");\n if (headEnd) result.headEnd = readLineEnd(headEnd);\n const tailEnd = findChild(el, \"a:tailEnd\");\n if (tailEnd) result.tailEnd = readLineEnd(tailEnd);\n\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) result.ext = stringifyXml(extLst);\n\n return result;\n },\n};\n","/**\n * Fill overlay effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_FillOverlayEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdBlendMode } from \"../../util/mappings\";\nimport { createSolidFill } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createGradientFill } from \"../fill/gradient-fill\";\nimport type { GradientFillOptions } from \"../fill/gradient-fill\";\nimport { createGroupFill } from \"../fill/group-fill\";\nimport { createNoFill } from \"../fill/no-fill\";\nimport { createPatternFill } from \"../fill/pattern-fill\";\nimport type { PatternFillOptions } from \"../fill/pattern-fill\";\n\n/**\n * Blend modes for fill overlay effect.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_BlendMode\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"over\"/>\n * <xsd:enumeration value=\"mult\"/>\n * <xsd:enumeration value=\"screen\"/>\n * <xsd:enumeration value=\"darken\"/>\n * <xsd:enumeration value=\"lighten\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const BlendMode = {\n /** Over blend mode */\n OVER: \"over\",\n /** Multiply blend mode */\n MULTIPLY: \"multiply\",\n /** Screen blend mode */\n SCREEN: \"screen\",\n /** Darken blend mode */\n DARKEN: \"darken\",\n /** Lighten blend mode */\n LIGHTEN: \"lighten\",\n} as const;\n\n/**\n * Options for fill overlay effect.\n */\nexport interface FillOverlayEffectOptions {\n /** Blend mode (required) */\n blend: (typeof BlendMode)[keyof typeof BlendMode];\n /** Solid fill color */\n solidFill?: SolidFillOptions;\n gradientFill?: GradientFillOptions;\n patternFill?: PatternFillOptions;\n /** Group fill (inherit from parent) */\n groupFill?: boolean;\n noFill?: boolean;\n}\n\n/**\n * Creates a fill overlay effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FillOverlayEffect\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_FillProperties\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"blend\" type=\"ST_BlendMode\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Solid fill overlay\n * const fillOverlay = createFillOverlayEffect({\n * blend: BlendMode.MULTIPLY,\n * solidFill: { value: \"FF0000\" },\n * });\n *\n * // Gradient fill overlay\n * const fillOverlay = createFillOverlayEffect({\n * blend: BlendMode.SCREEN,\n * gradientFill: { type: \"linear\", stops: [...] },\n * });\n * ```\n */\nexport const createFillOverlayEffect = (options: FillOverlayEffectOptions): string => {\n let fillElement: string;\n\n if (options.noFill) {\n fillElement = createNoFill();\n } else if (options.solidFill) {\n fillElement = createSolidFill(options.solidFill);\n } else if (options.gradientFill) {\n fillElement = createGradientFill(options.gradientFill);\n } else if (options.patternFill) {\n fillElement = createPatternFill(options.patternFill);\n } else if (options.groupFill) {\n fillElement = createGroupFill();\n } else {\n // Default to solid fill if nothing specified\n fillElement = createSolidFill({ value: \"000000\" });\n }\n\n return element(\"a:fillOverlay\", { blend: xsdBlendMode.to(options.blend) }, [fillElement]);\n};\n","/**\n * Glow effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GlowEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\n\n/**\n * Options for glow effect.\n */\nexport interface GlowEffectOptions {\n /** Glow radius in EMUs (number) or UniversalMeasure (mm/cm/in/pt/pc/pi/px). */\n radius?: number | UniversalMeasure;\n /** Glow color */\n color: SolidFillOptions;\n}\n\n/**\n * Creates a glow effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_GlowEffect\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"rad\" type=\"ST_PositiveCoordinate\" use=\"optional\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createGlowEffect = (options: GlowEffectOptions): string => {\n const colorChild = createColorElement(options.color);\n if (options.radius === undefined) {\n return element(\"a:glow\", undefined, [colorChild]);\n }\n\n return element(\"a:glow\", { rad: convertToEmu(options.radius) }, [colorChild]);\n};\n","/**\n * Inner shadow effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_InnerShadowEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\n\n/**\n * Options for inner shadow effect.\n */\nexport interface InnerShadowEffectOptions {\n /** Blur radius in EMUs (number) or UniversalMeasure (mm/cm/in/pt/pc/pi/px). */\n blurRadius?: number | UniversalMeasure;\n /** Distance from shape edge in EMUs (number) or UniversalMeasure. */\n distance?: number | UniversalMeasure;\n /** Direction angle in degrees (0–360). */\n direction?: number;\n /** Shadow color */\n color: SolidFillOptions;\n}\n\n/**\n * Creates an inner shadow effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_InnerShadowEffect\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"blurRad\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dist\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dir\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createInnerShadowEffect = (options: InnerShadowEffectOptions): string => {\n const colorChild = createColorElement(options.color);\n\n const attrs: Record<string, number> = {};\n if (options.blurRadius !== undefined) attrs.blurRad = convertToEmu(options.blurRadius);\n if (options.distance !== undefined) attrs.dist = convertToEmu(options.distance);\n if (options.direction !== undefined) attrs.dir = Math.round(options.direction * 60000);\n\n const hasAttributes = Object.keys(attrs).length > 0;\n\n return element(\"a:innerShdw\", hasAttributes ? attrs : undefined, [colorChild]);\n};\n","/**\n * Outer shadow effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_OuterShadowEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdRectAlignment } from \"../../util/mappings\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\n\n/**\n * Rectangle alignment for shadow positioning.\n */\nexport type RectAlignment =\n | \"topLeft\"\n | \"top\"\n | \"topRight\"\n | \"left\"\n | \"center\"\n | \"right\"\n | \"bottomLeft\"\n | \"bottom\"\n | \"bottomRight\";\n\n/**\n * Options for outer shadow effect.\n */\nexport interface OuterShadowEffectOptions {\n /** Blur radius in EMUs (number) or UniversalMeasure (mm/cm/in/pt/pc/pi/px). */\n blurRadius?: number | UniversalMeasure;\n /** Distance from shape in EMUs (number) or UniversalMeasure. */\n distance?: number | UniversalMeasure;\n /** Direction angle in degrees (0–360). */\n direction?: number;\n /** Horizontal scale as integer percent (100 = 100%) */\n scaleX?: number;\n /** Vertical scale as integer percent */\n scaleY?: number;\n /** Horizontal skew angle in degrees. */\n skewX?: number;\n /** Vertical skew angle in degrees. */\n skewY?: number;\n /** Shadow alignment */\n alignment?: RectAlignment;\n /** Whether shadow rotates with shape */\n rotWithShape?: boolean;\n /** Shadow color */\n color: SolidFillOptions;\n}\n\n/**\n * Creates an outer shadow effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_OuterShadowEffect\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"blurRad\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dist\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dir\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"sx\" type=\"ST_Percentage\" default=\"100%\"/>\n * <xsd:attribute name=\"sy\" type=\"ST_Percentage\" default=\"100%\"/>\n * <xsd:attribute name=\"kx\" type=\"ST_FixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"ky\" type=\"ST_FixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"algn\" type=\"ST_RectAlignment\" default=\"b\"/>\n * <xsd:attribute name=\"rotWithShape\" type=\"xsd:boolean\" default=\"true\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createOuterShadowEffect = (options: OuterShadowEffectOptions): string => {\n const attrs: Record<string, string | number> = {};\n\n if (options.blurRadius !== undefined) attrs.blurRad = convertToEmu(options.blurRadius);\n if (options.distance !== undefined) attrs.dist = convertToEmu(options.distance);\n if (options.direction !== undefined) attrs.dir = Math.round(options.direction * 60000);\n if (options.scaleX !== undefined) attrs.sx = Math.round(options.scaleX * 1000);\n if (options.scaleY !== undefined) attrs.sy = Math.round(options.scaleY * 1000);\n if (options.skewX !== undefined) attrs.kx = Math.round(options.skewX * 60000);\n if (options.skewY !== undefined) attrs.ky = Math.round(options.skewY * 60000);\n if (options.alignment !== undefined) attrs.algn = xsdRectAlignment.to(options.alignment);\n if (options.rotWithShape === false) attrs.rotWithShape = 0;\n\n return element(\"a:outerShdw\", attrs, [createColorElement(options.color)]);\n};\n","/**\n * Preset shadow effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetShadowEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdPresetShadow } from \"../../util/mappings\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\n\n/**\n * Preset shadow types (20 variations).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetShadowVal\n */\nexport type PresetShadow =\n | \"shadow1\"\n | \"shadow2\"\n | \"shadow3\"\n | \"shadow4\"\n | \"shadow5\"\n | \"shadow6\"\n | \"shadow7\"\n | \"shadow8\"\n | \"shadow9\"\n | \"shadow10\"\n | \"shadow11\"\n | \"shadow12\"\n | \"shadow13\"\n | \"shadow14\"\n | \"shadow15\"\n | \"shadow16\"\n | \"shadow17\"\n | \"shadow18\"\n | \"shadow19\"\n | \"shadow20\";\n\n/**\n * Options for preset shadow effect.\n */\nexport interface PresetShadowEffectOptions {\n /** Preset shadow type (required) */\n preset: PresetShadow;\n /** Distance from shape in EMUs (number) or UniversalMeasure. */\n distance?: number | UniversalMeasure;\n /** Direction angle in degrees (0–360). */\n direction?: number;\n /** Shadow color */\n color: SolidFillOptions;\n}\n\n/**\n * Creates a preset shadow effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PresetShadowEffect\">\n * <xsd:sequence>\n * <xsd:group ref=\"EG_ColorChoice\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"prst\" type=\"ST_PresetShadowVal\" use=\"required\"/>\n * <xsd:attribute name=\"dist\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dir\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createPresetShadowEffect = (options: PresetShadowEffectOptions): string => {\n const attrs: Record<string, string | number> = {\n prst: xsdPresetShadow.to(options.preset),\n };\n\n if (options.distance !== undefined) attrs.dist = convertToEmu(options.distance);\n if (options.direction !== undefined) attrs.dir = Math.round(options.direction * 60000);\n\n return element(\"a:prstShdw\", attrs, [createColorElement(options.color)]);\n};\n","/**\n * Reflection effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ReflectionEffect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdRectAlignment } from \"../../util/mappings\";\nimport type { UniversalMeasure } from \"../../util/values\";\n\n/**\n * Options for reflection effect.\n *\n * All properties are optional with XSD defaults.\n */\nexport interface ReflectionEffectOptions {\n /** Blur radius in EMUs (number) or UniversalMeasure (mm/cm/in/pt/pc/pi/px). */\n blurRadius?: number | UniversalMeasure;\n /** Start opacity as integer percent (100 = fully opaque) */\n startAlpha?: number;\n /** Start position as integer percent (0-100) */\n startPosition?: number;\n /** End opacity as integer percent */\n endAlpha?: number;\n /** End position as integer percent (0-100) */\n endPosition?: number;\n /** Distance from shape in EMUs (number) or UniversalMeasure. */\n distance?: number | UniversalMeasure;\n /** Direction angle in degrees (0–360). */\n direction?: number;\n /** Fade direction angle in degrees (0–360). */\n fadeDirection?: number;\n /** Horizontal scale as integer percent (100 = 100%) */\n scaleX?: number;\n /** Vertical scale as integer percent */\n scaleY?: number;\n /** Horizontal skew angle in degrees. */\n skewX?: number;\n /** Vertical skew angle in degrees. */\n skewY?: number;\n /** Reflection alignment (a:reflection `@algn`, ST_RectAlignment). */\n alignment?:\n | \"topLeft\"\n | \"top\"\n | \"topRight\"\n | \"left\"\n | \"center\"\n | \"right\"\n | \"bottomLeft\"\n | \"bottom\"\n | \"bottomRight\";\n /** Whether reflection rotates with shape */\n rotWithShape?: boolean;\n}\n\n/**\n * Creates a reflection effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_ReflectionEffect\">\n * <xsd:attribute name=\"blurRad\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"stA\" type=\"ST_PositiveFixedPercentage\" default=\"100%\"/>\n * <xsd:attribute name=\"stPos\" type=\"ST_PositiveFixedPercentage\" default=\"0%\"/>\n * <xsd:attribute name=\"endA\" type=\"ST_PositiveFixedPercentage\" default=\"0%\"/>\n * <xsd:attribute name=\"endPos\" type=\"ST_PositiveFixedPercentage\" default=\"100%\"/>\n * <xsd:attribute name=\"dist\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"dir\" type=\"ST_PositiveFixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"fadeDir\" type=\"ST_PositiveFixedAngle\" default=\"5400000\"/>\n * <xsd:attribute name=\"sx\" type=\"ST_Percentage\" default=\"100%\"/>\n * <xsd:attribute name=\"sy\" type=\"ST_Percentage\" default=\"100%\"/>\n * <xsd:attribute name=\"kx\" type=\"ST_FixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"ky\" type=\"ST_FixedAngle\" default=\"0\"/>\n * <xsd:attribute name=\"algn\" type=\"ST_RectAlignment\" default=\"b\"/>\n * <xsd:attribute name=\"rotWithShape\" type=\"xsd:boolean\" default=\"true\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createReflectionEffect = (options?: ReflectionEffectOptions): string => {\n if (!options) {\n return \"<a:reflection/>\";\n }\n\n const attrs: Record<string, string | number> = {};\n\n if (options.blurRadius !== undefined) attrs.blurRad = convertToEmu(options.blurRadius);\n if (options.startAlpha !== undefined) attrs.stA = Math.round(options.startAlpha * 1000);\n if (options.startPosition !== undefined) attrs.stPos = Math.round(options.startPosition * 1000);\n if (options.endAlpha !== undefined) attrs.endA = Math.round(options.endAlpha * 1000);\n if (options.endPosition !== undefined) attrs.endPos = Math.round(options.endPosition * 1000);\n if (options.distance !== undefined) attrs.dist = convertToEmu(options.distance);\n if (options.direction !== undefined) attrs.dir = Math.round(options.direction * 60000);\n if (options.fadeDirection !== undefined)\n attrs.fadeDir = Math.round(options.fadeDirection * 60000);\n if (options.scaleX !== undefined) attrs.sx = Math.round(options.scaleX * 1000);\n if (options.scaleY !== undefined) attrs.sy = Math.round(options.scaleY * 1000);\n if (options.skewX !== undefined) attrs.kx = Math.round(options.skewX * 60000);\n if (options.skewY !== undefined) attrs.ky = Math.round(options.skewY * 60000);\n if (options.alignment !== undefined) attrs.algn = xsdRectAlignment.to(options.alignment);\n if (options.rotWithShape === false) attrs.rotWithShape = 0;\n\n return element(\"a:reflection\", attrs);\n};\n","/**\n * Soft edge effect for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SoftEdgesEffect\n *\n * @module\n */\nimport { convertToEmu } from \"../../util/converters\";\nimport type { UniversalMeasure } from \"../../util/values\";\n\n/**\n * Creates a soft edge effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SoftEdgesEffect\">\n * <xsd:attribute name=\"rad\" type=\"ST_PositiveCoordinate\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @param rad - Soft edge radius in EMUs (number) or UniversalMeasure (required)\n */\nexport const createSoftEdgeEffect = (rad: number | UniversalMeasure): string =>\n `<a:softEdge rad=\"${convertToEmu(rad)}\"/>`;\n","/**\n * Effect list container for DrawingML shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectList, EG_EffectProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../../util/converters\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport type { FillOverlayEffectOptions } from \"./fill-overlay\";\nimport { createFillOverlayEffect } from \"./fill-overlay\";\nimport type { GlowEffectOptions } from \"./glow\";\nimport { createGlowEffect } from \"./glow\";\nimport type { InnerShadowEffectOptions } from \"./inner-shadow\";\nimport { createInnerShadowEffect } from \"./inner-shadow\";\nimport type { OuterShadowEffectOptions } from \"./outer-shadow\";\nimport { createOuterShadowEffect } from \"./outer-shadow\";\nimport type { PresetShadowEffectOptions } from \"./preset-shadow\";\nimport { createPresetShadowEffect } from \"./preset-shadow\";\nimport type { ReflectionEffectOptions } from \"./reflection\";\nimport { createReflectionEffect } from \"./reflection\";\nimport { createSoftEdgeEffect } from \"./soft-edge\";\n\n/**\n * Effect extent calculation result.\n * Represents the additional space needed on each edge (in EMUs).\n */\nexport interface EffectExtent {\n /** Left edge extension */\n l: number;\n /** Top edge extension */\n t: number;\n /** Right edge extension */\n r: number;\n /** Bottom edge extension */\n b: number;\n}\n\n/**\n * Calculates the effect extent for a given set of effects.\n *\n * The effectExtent specifies the additional extent which shall be added to each edge\n * of the image (top, bottom, left, right) in order to compensate for any drawing effects\n * applied to the DrawingML object.\n *\n * Reference: CT_EffectExtent in dml-wordprocessingDrawing.xsd\n *\n * @param options - Effect list options\n * @returns The calculated effect extent in EMUs\n */\nexport const calculateEffectExtent = (options?: EffectListOptions): EffectExtent => {\n if (!options) {\n return { l: 0, t: 0, r: 0, b: 0 };\n }\n\n let l = 0,\n t = 0,\n r = 0,\n b = 0;\n\n // Outer shadow: distance + blurRadius extends in the shadow direction\n if (options.outerShadow) {\n const dist = convertToEmu(options.outerShadow.distance ?? 0);\n const blur = convertToEmu(options.outerShadow.blurRadius ?? 0);\n const dir = options.outerShadow.direction ?? 0;\n\n // Direction is in degrees, convert to radians\n const radians = dir * (Math.PI / 180);\n const dx = Math.cos(radians) * dist;\n const dy = Math.sin(radians) * dist;\n\n // Shadow extends in direction + blur radius in all directions\n const extend = Math.abs(dx) + blur;\n const extendY = Math.abs(dy) + blur;\n\n if (dx > 0) r = Math.max(r, extend);\n else l = Math.max(l, extend);\n\n if (dy > 0) b = Math.max(b, extendY);\n else t = Math.max(t, extendY);\n }\n\n // Glow: radius extends equally in all directions\n if (options.glow) {\n const radius = convertToEmu(options.glow.radius ?? 0);\n l = Math.max(l, radius);\n t = Math.max(t, radius);\n r = Math.max(r, radius);\n b = Math.max(b, radius);\n }\n\n // Reflection: typically extends downward\n if (options.reflection && options.reflection !== true) {\n const dist = convertToEmu(options.reflection.distance ?? 0);\n const blur = convertToEmu(options.reflection.blurRadius ?? 0);\n // Reflection typically extends downward\n b = Math.max(b, dist + blur);\n }\n\n // Soft edge: radius extends equally in all directions\n if (options.softEdge !== undefined) {\n const softRad = convertToEmu(options.softEdge);\n l = Math.max(l, softRad);\n t = Math.max(t, softRad);\n r = Math.max(r, softRad);\n b = Math.max(b, softRad);\n }\n\n // EMU coordinates must be integers (ST_Coordinate); the cos/sin projections\n // above produce floats, so round before emitting.\n return { l: Math.round(l), t: Math.round(t), r: Math.round(r), b: Math.round(b) };\n};\n\n/**\n * Blur effect options.\n */\nexport interface BlurEffectOptions {\n /** Blur radius in EMUs */\n radius?: number;\n /** Whether to grow the shape boundary */\n grow?: boolean;\n}\n\n/**\n * Options for the effect list container.\n *\n * Each property corresponds to an optional child effect element.\n * Only specified effects will be included in the output.\n */\nexport interface EffectListOptions {\n /** Blur effect */\n blur?: BlurEffectOptions;\n /** Fill overlay effect */\n fillOverlay?: FillOverlayEffectOptions;\n /** Glow effect */\n glow?: GlowEffectOptions;\n /** Inner shadow effect */\n innerShadow?: InnerShadowEffectOptions;\n /** Outer shadow effect */\n outerShadow?: OuterShadowEffectOptions;\n /** Preset shadow effect */\n presetShadow?: PresetShadowEffectOptions;\n /** Reflection effect (pass object for attributes, or true for defaults) */\n reflection?: ReflectionEffectOptions | true;\n /** Soft edge radius in EMUs */\n softEdge?: number | UniversalMeasure;\n}\n\n/**\n * Creates a blur effect element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_BlurEffect\">\n * <xsd:attribute name=\"rad\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"grow\" type=\"xsd:boolean\" default=\"true\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createBlurEffect = (options: BlurEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options.radius !== undefined) attrs.rad = options.radius;\n if (options.grow === false) attrs.grow = 0;\n\n return Object.keys(attrs).length > 0 ? element(\"a:blur\", attrs) : element(\"a:blur\");\n};\n\n/**\n * Creates an effect list element (a:effectLst).\n *\n * This is the EG_EffectProperties choice for a flat list of effects.\n * Effects are emitted in XSD order: blur, glow, innerShdw, outerShdw, prstShdw, reflection, softEdge.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_EffectList\">\n * <xsd:sequence>\n * <xsd:element name=\"blur\" type=\"CT_BlurEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"fillOverlay\" type=\"CT_FillOverlayEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"glow\" type=\"CT_GlowEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"innerShdw\" type=\"CT_InnerShadowEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"outerShdw\" type=\"CT_OuterShadowEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"prstShdw\" type=\"CT_PresetShadowEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"reflection\" type=\"CT_ReflectionEffect\" minOccurs=\"0\"/>\n * <xsd:element name=\"softEdge\" type=\"CT_SoftEdgesEffect\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n */\n/**\n * Append the eight CT_EffectList effects (also valid in CT_EffectContainer),\n * in XSD sequence order. Shared by createEffectList and the DAG container.\n */\nexport const appendCommonEffects = (options: EffectListOptions, children: string[]): void => {\n if (options.blur) {\n children.push(createBlurEffect(options.blur));\n }\n if (options.fillOverlay) {\n children.push(createFillOverlayEffect(options.fillOverlay));\n }\n if (options.glow) {\n children.push(createGlowEffect(options.glow));\n }\n if (options.innerShadow) {\n children.push(createInnerShadowEffect(options.innerShadow));\n }\n if (options.outerShadow) {\n children.push(createOuterShadowEffect(options.outerShadow));\n }\n if (options.presetShadow) {\n children.push(createPresetShadowEffect(options.presetShadow));\n }\n if (options.reflection) {\n children.push(\n createReflectionEffect(options.reflection === true ? undefined : options.reflection),\n );\n }\n if (options.softEdge !== undefined) {\n children.push(createSoftEdgeEffect(options.softEdge));\n }\n};\n\nexport const createEffectList = (options: EffectListOptions): string => {\n const children: string[] = [];\n appendCommonEffects(options, children);\n return element(\"a:effectLst\", undefined, children);\n};\n","/**\n * Effect container (effectDag) for DrawingML shapes.\n *\n * Provides CT_EffectContainer — a directed acyclic graph (DAG) of effects\n * supporting 28 effect types including alpha/color operations, nested containers,\n * and all effects from CT_EffectList.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectContainer, EG_Effect\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdBlendMode, xsdEffectContainer } from \"../../util/mappings\";\nimport { createSolidFill } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport { createGradientFill } from \"../fill/gradient-fill\";\nimport type { GradientFillOptions } from \"../fill/gradient-fill\";\nimport { createGroupFill } from \"../fill/group-fill\";\nimport { createNoFill } from \"../fill/no-fill\";\nimport { createPatternFill } from \"../fill/pattern-fill\";\nimport type { PatternFillOptions } from \"../fill/pattern-fill\";\nimport type { BlurEffectOptions } from \"./effect-list\";\nimport { appendCommonEffects } from \"./effect-list\";\nimport type { FillOverlayEffectOptions } from \"./fill-overlay\";\nimport { BlendMode } from \"./fill-overlay\";\nimport type { GlowEffectOptions } from \"./glow\";\nimport type { InnerShadowEffectOptions } from \"./inner-shadow\";\nimport type { OuterShadowEffectOptions } from \"./outer-shadow\";\nimport type { PresetShadowEffectOptions } from \"./preset-shadow\";\nimport type { ReflectionEffectOptions } from \"./reflection\";\n\n// ─── Effect Container Type ──────────────────────────────────────────────────\n\n/**\n * Effect container type (ST_EffectContainerType).\n *\n * Controls how child effects are combined:\n * - `sib`: sibling effects are applied in parallel\n * - `tree`: effects are applied sequentially in tree order\n *\n * Note: the `sib` token maps to the `\"sibling\"` value accepted here.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_EffectContainerType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"sib\"/>\n * <xsd:enumeration value=\"tree\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport type EffectContainer = \"sibling\" | \"tree\";\n\n// ─── Effect Options ─────────────────────────────────────────────────────────\n// Shared CT_* effect option types live in blip-effects.ts (single home);\n// this module re-exports them for the effect-DAG path.\n\nimport type {\n AlphaBiLevelEffectOptions,\n AlphaModulateFixedEffectOptions,\n AlphaReplaceEffectOptions,\n ColorChangeEffectOptions,\n DuotoneEffectOptions,\n HSLEffectOptions,\n LuminanceEffectOptions,\n TintEffectOptions,\n} from \"../blip/blip-effects\";\n\nexport type {\n AlphaBiLevelEffectOptions,\n AlphaModulateFixedEffectOptions,\n AlphaReplaceEffectOptions,\n ColorChangeEffectOptions,\n DuotoneEffectOptions,\n HSLEffectOptions,\n LuminanceEffectOptions,\n TintEffectOptions,\n} from \"../blip/blip-effects\";\n\n/** Alpha inverse effect — inverts alpha, optionally with color (CT_AlphaInverseEffect). */\nexport interface AlphaInverseEffectOptions {\n /** Optional color to apply inverse to */\n color?: SolidFillOptions;\n}\n\n/** Alpha outset effect (CT_AlphaOutsetEffect). */\nexport interface AlphaOutsetEffectOptions {\n /** Outset radius */\n radius?: number;\n}\n\n/** Blend effect — blends with nested container (CT_BlendEffect). */\nexport interface BlendEffectOptions {\n /** Blend mode (required) */\n blend: (typeof BlendMode)[keyof typeof BlendMode];\n /** Nested effect container */\n container: EffectDagOptions;\n}\n\n/** Fill effect — applies a fill as an effect (CT_FillEffect). */\nexport interface FillEffectOptions {\n solidFill?: SolidFillOptions;\n gradientFill?: GradientFillOptions;\n patternFill?: PatternFillOptions;\n /** Group fill (inherit from parent) */\n groupFill?: boolean;\n noFill?: boolean;\n}\n\n/** Relative offset effect (CT_RelativeOffsetEffect). */\nexport interface RelativeOffsetEffectOptions {\n /** Horizontal offset percentage (default 0%) */\n translateX?: number;\n /** Vertical offset percentage (default 0%) */\n translateY?: number;\n}\n\n/** Transform effect — scale, skew, translate (CT_TransformEffect). */\nexport interface TransformEffectOptions {\n /** Horizontal scale percentage (default 100%) */\n scaleX?: number;\n /** Vertical scale percentage (default 100%) */\n scaleY?: number;\n /** Horizontal skew angle in degrees (default 0). */\n skewX?: number;\n /** Vertical skew angle in degrees (default 0). */\n skewY?: number;\n /** Horizontal translation */\n translateX?: number;\n /** Vertical translation */\n translateY?: number;\n}\n\n/** Effect reference — references an effect by ID (CT_EffectReference). */\nexport interface EffectReferenceOptions {\n /** Reference ID (required) */\n ref: string;\n}\n\n// ─── Effect Container Options ───────────────────────────────────────────────\n\n/**\n * Options for an effect container (CT_EffectContainer).\n *\n * Supports all 28 effect types from EG_Effect, including recursive nesting.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_EffectContainer\">\n * <xsd:group ref=\"EG_Effect\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * <xsd:attribute name=\"type\" type=\"ST_EffectContainerType\" default=\"sib\"/>\n * <xsd:attribute name=\"name\" type=\"xsd:token\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface EffectDagOptions {\n /** Container type: \"sib\" (parallel) or \"tree\" (sequential) */\n type?: EffectContainer;\n /** Container name */\n name?: string;\n\n // ── Existing effects (also in CT_EffectList) ──\n blur?: BlurEffectOptions;\n fillOverlay?: FillOverlayEffectOptions;\n glow?: GlowEffectOptions;\n innerShadow?: InnerShadowEffectOptions;\n outerShadow?: OuterShadowEffectOptions;\n presetShadow?: PresetShadowEffectOptions;\n reflection?: ReflectionEffectOptions | true;\n softEdge?: number;\n\n // ── New effects for CT_EffectContainer ──\n /** Nested effect containers */\n containers?: readonly EffectDagOptions[];\n /** Effect references */\n effectRefs?: readonly EffectReferenceOptions[];\n /** Alpha bi-level effect */\n alphaBiLevel?: AlphaBiLevelEffectOptions;\n /** Alpha ceiling effect (empty element) */\n alphaCeiling?: boolean;\n /** Alpha floor effect (empty element) */\n alphaFloor?: boolean;\n /** Alpha inverse effect */\n alphaInverse?: AlphaInverseEffectOptions;\n /** Alpha modulate effect (requires nested container) */\n alphaModulate?: EffectDagOptions;\n /** Alpha modulate fixed effect */\n alphaModulateFixed?: AlphaModulateFixedEffectOptions;\n /** Alpha outset effect */\n alphaOutset?: AlphaOutsetEffectOptions;\n /** Alpha replace effect */\n alphaReplace?: AlphaReplaceEffectOptions;\n /** Bi-level effect (threshold) */\n biLevel?: { threshold: number };\n /** Blend effect (requires nested container) */\n blend?: BlendEffectOptions;\n /** Color change effect */\n colorChange?: ColorChangeEffectOptions;\n /** Color replace effect */\n colorReplace?: SolidFillOptions;\n /** Duotone effect */\n duotone?: DuotoneEffectOptions;\n /** Fill effect */\n fill?: FillEffectOptions;\n /** Grayscale effect (empty element) */\n grayscale?: boolean;\n /** HSL effect */\n hsl?: HSLEffectOptions;\n /** Luminance effect */\n luminance?: LuminanceEffectOptions;\n /** Tint effect */\n tint?: TintEffectOptions;\n /** Relative offset effect */\n relativeOffset?: RelativeOffsetEffectOptions;\n /** Transform effect */\n transform?: TransformEffectOptions;\n}\n\n// ─── New Effect Factories ───────────────────────────────────────────────────\n\nconst createAlphaBiLevelEffect = (options: AlphaBiLevelEffectOptions): string =>\n `<a:alphaBiLevel thresh=\"${options.threshold}\"/>`;\n\nconst createAlphaCeilingEffect = (): string => \"<a:alphaCeiling/>\";\n\nconst createAlphaFloorEffect = (): string => \"<a:alphaFloor/>\";\n\nconst createAlphaInverseEffect = (options?: AlphaInverseEffectOptions): string =>\n element(\n \"a:alphaInv\",\n undefined,\n options?.color ? [createColorElement(options.color)] : undefined,\n );\n\nconst createAlphaModulateFixedEffect = (options?: AlphaModulateFixedEffectOptions): string =>\n options?.amount === undefined\n ? \"<a:alphaModFix/>\"\n : `<a:alphaModFix amt=\"${Math.round(options.amount * 1000)}\"/>`;\n\nconst createAlphaOutsetEffect = (options?: AlphaOutsetEffectOptions): string =>\n options?.radius === undefined ? \"<a:alphaOutset/>\" : `<a:alphaOutset rad=\"${options.radius}\"/>`;\n\nconst createAlphaReplaceEffect = (options: AlphaReplaceEffectOptions): string =>\n `<a:alphaRepl a=\"${Math.round(options.alpha * 1000)}\"/>`;\n\nconst createBiLevelEffect = (thresh: number): string =>\n `<a:biLevel thresh=\"${Math.round(thresh * 1000)}\"/>`;\n\nconst createBlendEffect = (options: BlendEffectOptions): string =>\n element(\"a:blend\", { blend: xsdBlendMode.to(options.blend) }, [\n createEffectContainer(options.container),\n ]);\n\nconst createColorChangeEffect = (options: ColorChangeEffectOptions): string => {\n const children: string[] = [\n element(\"a:clrFrom\", undefined, [createColorElement(options.from)]),\n element(\"a:clrTo\", undefined, [createColorElement(options.to)]),\n ];\n\n if (options.useAlpha === false) {\n return element(\"a:clrChange\", { useA: 0 }, children);\n }\n\n return element(\"a:clrChange\", undefined, children);\n};\n\nconst createColorReplaceEffect = (color: SolidFillOptions): string =>\n element(\"a:clrRepl\", undefined, [createColorElement(color)]);\n\nconst createDuotoneEffect = (options: DuotoneEffectOptions): string =>\n element(\"a:duotone\", undefined, [\n createColorElement(options.color1),\n createColorElement(options.color2),\n ]);\n\nconst createFillEffect = (options: FillEffectOptions): string => {\n let fillElement: string;\n\n if (options.noFill) {\n fillElement = createNoFill();\n } else if (options.solidFill) {\n fillElement = createSolidFill(options.solidFill);\n } else if (options.gradientFill) {\n fillElement = createGradientFill(options.gradientFill);\n } else if (options.patternFill) {\n fillElement = createPatternFill(options.patternFill);\n } else if (options.groupFill) {\n fillElement = createGroupFill();\n } else {\n fillElement = createNoFill();\n }\n\n return element(\"a:fill\", undefined, [fillElement]);\n};\n\nconst createGrayscaleEffect = (): string => \"<a:grayscl/>\";\n\nconst createHSLEffect = (options?: HSLEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options?.hue !== undefined) attrs.hue = Math.round(options.hue * 60000);\n if (options?.saturation !== undefined) attrs.sat = options.saturation;\n if (options?.luminance !== undefined) attrs.lum = options.luminance;\n return element(\"a:hsl\", Object.keys(attrs).length > 0 ? attrs : undefined);\n};\n\nconst createLuminanceEffect = (options?: LuminanceEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options?.bright !== undefined) attrs.bright = Math.round(options.bright * 1000);\n if (options?.contrast !== undefined) attrs.contrast = Math.round(options.contrast * 1000);\n return element(\"a:lum\", Object.keys(attrs).length > 0 ? attrs : undefined);\n};\n\nconst createTintEffect = (options?: TintEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options?.hue !== undefined) attrs.hue = Math.round(options.hue * 60000);\n if (options?.amount !== undefined) attrs.amt = Math.round(options.amount * 1000);\n return element(\"a:tint\", Object.keys(attrs).length > 0 ? attrs : undefined);\n};\n\nconst createRelativeOffsetEffect = (options?: RelativeOffsetEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options?.translateX !== undefined) attrs.tx = Math.round(options.translateX * 1000);\n if (options?.translateY !== undefined) attrs.ty = Math.round(options.translateY * 1000);\n return element(\"a:relOff\", Object.keys(attrs).length > 0 ? attrs : undefined);\n};\n\nconst createTransformEffect = (options?: TransformEffectOptions): string => {\n const attrs: Record<string, number> = {};\n if (options?.scaleX !== undefined) attrs.sx = Math.round(options.scaleX * 1000);\n if (options?.scaleY !== undefined) attrs.sy = Math.round(options.scaleY * 1000);\n if (options?.skewX !== undefined) attrs.kx = Math.round(options.skewX * 60000);\n if (options?.skewY !== undefined) attrs.ky = Math.round(options.skewY * 60000);\n if (options?.translateX !== undefined) attrs.tx = options.translateX;\n if (options?.translateY !== undefined) attrs.ty = options.translateY;\n return element(\"a:xfrm\", Object.keys(attrs).length > 0 ? attrs : undefined);\n};\n\nconst createEffectReference = (options: EffectReferenceOptions): string =>\n `<a:effect ref=\"${options.ref}\"/>`;\n\n// ─── Effect Container ───────────────────────────────────────────────────────\n\n/**\n * Creates an effect container element (a:effectDag or a:cont).\n *\n * This is the CT_EffectContainer type — a recursive DAG of effects.\n * All 28 EG_Effect types are supported.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_EffectContainer\">\n * <xsd:group ref=\"EG_Effect\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * <xsd:attribute name=\"type\" type=\"ST_EffectContainerType\" default=\"sib\"/>\n * <xsd:attribute name=\"name\" type=\"xsd:token\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Container options with effects\n * @param elementName - Element name, defaults to \"a:cont\" for top-level\n */\nconst createEffectContainer = (options: EffectDagOptions, elementName = \"a:cont\"): string => {\n const attrs: Record<string, string | number> = {};\n if (options.type) attrs.type = xsdEffectContainer.to(options.type);\n if (options.name) attrs.name = options.name;\n\n const children: string[] = [];\n\n // The eight CT_EffectList effects, then the DAG-only ones below.\n appendCommonEffects(options, children);\n\n // ── New effects for CT_EffectContainer ──\n if (options.containers) {\n for (const nested of options.containers) {\n children.push(createEffectContainer(nested));\n }\n }\n if (options.effectRefs) {\n for (const ref of options.effectRefs) {\n children.push(createEffectReference(ref));\n }\n }\n if (options.alphaBiLevel) {\n children.push(createAlphaBiLevelEffect(options.alphaBiLevel));\n }\n if (options.alphaCeiling) {\n children.push(createAlphaCeilingEffect());\n }\n if (options.alphaFloor) {\n children.push(createAlphaFloorEffect());\n }\n if (options.alphaInverse) {\n children.push(createAlphaInverseEffect(options.alphaInverse));\n }\n if (options.alphaModulate) {\n children.push(element(\"a:alphaMod\", undefined, [createEffectContainer(options.alphaModulate)]));\n }\n if (options.alphaModulateFixed) {\n children.push(createAlphaModulateFixedEffect(options.alphaModulateFixed));\n }\n if (options.alphaOutset) {\n children.push(createAlphaOutsetEffect(options.alphaOutset));\n }\n if (options.alphaReplace) {\n children.push(createAlphaReplaceEffect(options.alphaReplace));\n }\n if (options.biLevel) {\n children.push(createBiLevelEffect(options.biLevel.threshold));\n }\n if (options.blend) {\n children.push(createBlendEffect(options.blend));\n }\n if (options.colorChange) {\n children.push(createColorChangeEffect(options.colorChange));\n }\n if (options.colorReplace) {\n children.push(createColorReplaceEffect(options.colorReplace));\n }\n if (options.duotone) {\n children.push(createDuotoneEffect(options.duotone));\n }\n if (options.fill) {\n children.push(createFillEffect(options.fill));\n }\n if (options.grayscale) {\n children.push(createGrayscaleEffect());\n }\n if (options.hsl) {\n children.push(createHSLEffect(options.hsl));\n }\n if (options.luminance) {\n children.push(createLuminanceEffect(options.luminance));\n }\n if (options.tint) {\n children.push(createTintEffect(options.tint));\n }\n if (options.relativeOffset) {\n children.push(createRelativeOffsetEffect(options.relativeOffset));\n }\n if (options.transform) {\n children.push(createTransformEffect(options.transform));\n }\n\n return element(\n elementName,\n Object.keys(attrs).length > 0 ? attrs : undefined,\n children.length > 0 ? children : undefined,\n );\n};\n\n/**\n * Creates an effect DAG element (a:effectDag).\n *\n * This is the EG_EffectProperties choice alternative to effectLst,\n * supporting all 28 effect types with recursive nesting.\n *\n * @example\n * ```typescript\n * // Simple effect DAG with glow and outer shadow\n * createEffectDag({\n * glow: { radius: 50800, color: { value: \"FF0000\" } },\n * outerShadow: { color: { value: \"000000\" }, blurRadius: 76200 },\n * });\n *\n * // DAG with alpha effects and nested container\n * createEffectDag({\n * type: \"tree\",\n * alphaBiLevel: { threshold: 50 },\n * containers: [{\n * glow: { color: { value: \"FF0000\" } },\n * }],\n * });\n * ```\n */\nexport const createEffectDag = (options: EffectDagOptions): string =>\n createEffectContainer(options, \"a:effectDag\");\n","/**\n * 3D scene module for DrawingML shapes.\n *\n * Provides CT_Scene3D — the 3D scene properties including camera, light rig,\n * and optional backdrop that define how a 3D shape is rendered.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Scene3D\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdLightRigDirection } from \"../../util/mappings\";\nimport type { PositivePercentage } from \"../../util/values\";\n\n/** Preset camera type (ST_PresetCameraType). */\nexport type CameraPreset =\n | \"legacyObliqueTopLeft\"\n | \"legacyObliqueTop\"\n | \"legacyObliqueTopRight\"\n | \"legacyObliqueLeft\"\n | \"legacyObliqueFront\"\n | \"legacyObliqueRight\"\n | \"legacyObliqueBottomLeft\"\n | \"legacyObliqueBottom\"\n | \"legacyObliqueBottomRight\"\n | \"legacyPerspectiveTopLeft\"\n | \"legacyPerspectiveTop\"\n | \"legacyPerspectiveTopRight\"\n | \"legacyPerspectiveLeft\"\n | \"legacyPerspectiveFront\"\n | \"legacyPerspectiveRight\"\n | \"legacyPerspectiveBottomLeft\"\n | \"legacyPerspectiveBottom\"\n | \"legacyPerspectiveBottomRight\"\n | \"orthographicFront\"\n | \"isometricTopUp\"\n | \"isometricTopDown\"\n | \"isometricBottomUp\"\n | \"isometricBottomDown\"\n | \"isometricLeftUp\"\n | \"isometricLeftDown\"\n | \"isometricRightUp\"\n | \"isometricRightDown\"\n | \"isometricOffAxis1Left\"\n | \"isometricOffAxis1Right\"\n | \"isometricOffAxis1Top\"\n | \"isometricOffAxis2Left\"\n | \"isometricOffAxis2Right\"\n | \"isometricOffAxis2Top\"\n | \"isometricOffAxis3Left\"\n | \"isometricOffAxis3Right\"\n | \"isometricOffAxis3Bottom\"\n | \"isometricOffAxis4Left\"\n | \"isometricOffAxis4Right\"\n | \"isometricOffAxis4Bottom\"\n | \"obliqueTopLeft\"\n | \"obliqueTop\"\n | \"obliqueTopRight\"\n | \"obliqueLeft\"\n | \"obliqueRight\"\n | \"obliqueBottomLeft\"\n | \"obliqueBottom\"\n | \"obliqueBottomRight\"\n | \"perspectiveFront\"\n | \"perspectiveLeft\"\n | \"perspectiveRight\"\n | \"perspectiveAbove\"\n | \"perspectiveBelow\"\n | \"perspectiveAboveLeftFacing\"\n | \"perspectiveAboveRightFacing\"\n | \"perspectiveContrastingLeftFacing\"\n | \"perspectiveContrastingRightFacing\"\n | \"perspectiveHeroicLeftFacing\"\n | \"perspectiveHeroicRightFacing\"\n | \"perspectiveHeroicExtremeLeftFacing\"\n | \"perspectiveHeroicExtremeRightFacing\"\n | \"perspectiveRelaxed\"\n | \"perspectiveRelaxedModerately\";\n\n/** Light rig preset (ST_LightRigType). */\nexport type LightRigType =\n | \"legacyFlat1\"\n | \"legacyFlat2\"\n | \"legacyFlat3\"\n | \"legacyFlat4\"\n | \"legacyNormal1\"\n | \"legacyNormal2\"\n | \"legacyNormal3\"\n | \"legacyNormal4\"\n | \"legacyHarsh1\"\n | \"legacyHarsh2\"\n | \"legacyHarsh3\"\n | \"legacyHarsh4\"\n | \"threePt\"\n | \"balanced\"\n | \"soft\"\n | \"harsh\"\n | \"flood\"\n | \"contrasting\"\n | \"morning\"\n | \"sunrise\"\n | \"sunset\"\n | \"chilly\"\n | \"freezing\"\n | \"flat\"\n | \"twoPt\"\n | \"glow\"\n | \"brightRoom\";\n\n/** Light direction (ST_LightRigDirection) — full words; XSD tokens topLeft→tl etc. */\nexport type LightRigDirection =\n | \"topLeft\"\n | \"top\"\n | \"topRight\"\n | \"left\"\n | \"right\"\n | \"bottomLeft\"\n | \"bottom\"\n | \"bottomRight\";\n\n// ─── Sphere Coordinates ─────────────────────────────────────────────────────\n\n/**\n * Sphere coordinates (CT_SphereCoords).\n *\n * Used for camera and light rig rotation. All angles are in degrees.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SphereCoords\">\n * <xsd:attribute name=\"lat\" type=\"ST_PositiveFixedAngle\" use=\"required\"/>\n * <xsd:attribute name=\"lon\" type=\"ST_PositiveFixedAngle\" use=\"required\"/>\n * <xsd:attribute name=\"rev\" type=\"ST_PositiveFixedAngle\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface SphereCoords {\n /** Latitude angle in degrees (0–360). */\n lat: number;\n /** Longitude angle in degrees (0–360). */\n lon: number;\n /** Revolution angle in degrees (0–360). */\n rev: number;\n}\n\nconst createSphereCoords = (coords: SphereCoords): string => {\n const lat = Math.round(coords.lat * 60000);\n const lon = Math.round(coords.lon * 60000);\n const rev = Math.round(coords.rev * 60000);\n return `<a:rot lat=\"${lat}\" lon=\"${lon}\" rev=\"${rev}\"/>`;\n};\n\n// ─── Camera ─────────────────────────────────────────────────────────────────\n\n/**\n * Camera options (CT_Camera).\n *\n * Defines the camera type and optional rotation for the 3D scene.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Camera\">\n * <xsd:sequence>\n * <xsd:element name=\"rot\" type=\"CT_SphereCoords\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"prst\" type=\"ST_PresetCameraType\" use=\"required\"/>\n * <xsd:attribute name=\"fov\" type=\"ST_FOVAngle\" use=\"optional\"/>\n * <xsd:attribute name=\"zoom\" type=\"ST_PositivePercentage\" use=\"optional\" default=\"100%\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface CameraOptions {\n /** Preset camera type (ST_PresetCameraType) */\n preset: CameraPreset;\n /** Field of view angle in degrees (0–180). */\n fov?: number;\n /** Zoom percentage, e.g. \"100%\" (ST_PositivePercentage) */\n zoom?: PositivePercentage;\n /** Camera rotation */\n rotation?: SphereCoords;\n}\n\nconst createCamera = (options: CameraOptions): string => {\n const children: string[] = [];\n if (options.rotation) {\n children.push(createSphereCoords(options.rotation));\n }\n\n return element(\n \"a:camera\",\n {\n prst: options.preset,\n fov: options.fov !== undefined ? Math.round(options.fov * 60000) : undefined,\n zoom: options.zoom,\n },\n children,\n );\n};\n\n// ─── Light Rig ──────────────────────────────────────────────────────────────\n\n/**\n * Light rig options (CT_LightRig).\n *\n * Defines the lighting setup for the 3D scene.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_LightRig\">\n * <xsd:sequence>\n * <xsd:element name=\"rot\" type=\"CT_SphereCoords\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"rig\" type=\"ST_LightRigType\" use=\"required\"/>\n * <xsd:attribute name=\"dir\" type=\"ST_LightRigDirection\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface LightRigOptions {\n /** Light rig preset (ST_LightRigType) */\n rig: LightRigType;\n /** Light direction (ST_LightRigDirection, full words: \"tl\" → topLeft) */\n direction: LightRigDirection;\n /** Light rig rotation */\n rotation?: SphereCoords;\n}\n\nconst createLightRig = (options: LightRigOptions): string => {\n const children: string[] = [];\n if (options.rotation) {\n children.push(createSphereCoords(options.rotation));\n }\n\n return element(\n \"a:lightRig\",\n { rig: options.rig, dir: xsdLightRigDirection.to(options.direction) },\n children,\n );\n};\n\n// ─── Backdrop ───────────────────────────────────────────────────────────────\n\n/**\n * 3D point (CT_Point3D).\n */\nexport interface Point3D {\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * 3D vector (CT_Vector3D).\n */\nexport interface Vector3D {\n dx: number;\n dy: number;\n dz: number;\n}\n\n/**\n * Backdrop options (CT_Backdrop).\n *\n * Defines the backdrop plane for the 3D scene.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Backdrop\">\n * <xsd:sequence>\n * <xsd:element name=\"anchor\" type=\"CT_Point3D\" use=\"required\"/>\n * <xsd:element name=\"norm\" type=\"CT_Vector3D\" use=\"required\"/>\n * <xsd:element name=\"up\" type=\"CT_Vector3D\" use=\"required\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n */\nexport interface BackdropOptions {\n /** Anchor point */\n anchor: Point3D;\n /** Normal vector */\n normal: Vector3D;\n /** Up vector */\n up: Vector3D;\n /** Trailing a:extLst verbatim inner XML (unknown extensions). */\n ext?: string;\n}\n\nconst createPoint3D = (name: string, point: Point3D): string =>\n `<${name} x=\"${point.x}\" y=\"${point.y}\" z=\"${point.z}\"/>`;\n\nconst createVector3D = (name: string, vector: Vector3D): string =>\n `<${name} dx=\"${vector.dx}\" dy=\"${vector.dy}\" dz=\"${vector.dz}\"/>`;\n\nconst createBackdrop = (options: BackdropOptions): string =>\n element(\"a:backdrop\", undefined, [\n createPoint3D(\"a:anchor\", options.anchor),\n createVector3D(\"a:norm\", options.normal),\n createVector3D(\"a:up\", options.up),\n ...(options.ext !== undefined ? [`<a:extLst>${options.ext}</a:extLst>`] : []),\n ]);\n\n// ─── Scene 3D ───────────────────────────────────────────────────────────────\n\n/**\n * Options for a 3D scene (CT_Scene3D).\n *\n * Both `camera` and `lightRig` are required. `backdrop` is optional.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Scene3D\">\n * <xsd:sequence>\n * <xsd:element name=\"camera\" type=\"CT_Camera\" minOccurs=\"1\"/>\n * <xsd:element name=\"lightRig\" type=\"CT_LightRig\" minOccurs=\"1\"/>\n * <xsd:element name=\"backdrop\" type=\"CT_Backdrop\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * createScene3D({\n * camera: { preset: \"perspectiveFront\" },\n * lightRig: { rig: \"threePt\", direction: \"top\" },\n * });\n * ```\n */\nexport interface Scene3DOptions {\n /** Camera settings (required) */\n camera: CameraOptions;\n /** Light rig settings (required) */\n lightRig: LightRigOptions;\n /** Backdrop settings (optional) */\n backdrop?: BackdropOptions;\n}\n\n/**\n * Creates a 3D scene element (a:scene3d).\n *\n * @example\n * ```typescript\n * // Simple scene with default camera and lighting\n * createScene3D({\n * camera: { preset: \"perspectiveFront\" },\n * lightRig: { rig: \"threePt\", direction: \"top\" },\n * });\n *\n * // Scene with rotated camera and backdrop\n * createScene3D({\n * camera: {\n * preset: \"isometricTopUp\",\n * rotation: { lat: 0, lon: 0, rev: 90 },\n * },\n * lightRig: { rig: \"balanced\", direction: \"topLeft\" },\n * backdrop: {\n * anchor: { x: 0, y: 0, z: 0 },\n * normal: { dx: 0, dy: 0, dz: 1 },\n * up: { dx: 0, dy: 1, dz: 0 },\n * },\n * });\n * ```\n */\nexport const createScene3D = (options: Scene3DOptions): string => {\n const children: string[] = [createCamera(options.camera), createLightRig(options.lightRig)];\n\n if (options.backdrop) {\n children.push(createBackdrop(options.backdrop));\n }\n\n return element(\"a:scene3d\", undefined, children);\n};\n","/**\n * Bevel element for DrawingML 3D shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Bevel\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n/**\n * Bevel preset types (12 variations).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_BevelPresetType\n */\nexport type BevelPreset =\n | \"relaxedInset\"\n | \"circle\"\n | \"slope\"\n | \"cross\"\n | \"angle\"\n | \"softRound\"\n | \"convex\"\n | \"coolSlant\"\n | \"divot\"\n | \"riblet\"\n | \"hardEdge\"\n | \"artDeco\";\n\n/**\n * Options for a bevel element.\n */\nexport interface BevelOptions {\n /** Bevel width in EMUs (default 76200) */\n w?: number;\n /** Bevel height in EMUs (default 76200) */\n h?: number;\n /** Bevel preset type */\n prst?: BevelPreset;\n}\n\n/**\n * Creates a bevel element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Bevel\">\n * <xsd:attribute name=\"w\" type=\"ST_PositiveCoordinate\" default=\"76200\"/>\n * <xsd:attribute name=\"h\" type=\"ST_PositiveCoordinate\" default=\"76200\"/>\n * <xsd:attribute name=\"prst\" type=\"ST_BevelPresetType\" default=\"circle\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createBevel = (options?: BevelOptions): string => {\n if (!options) {\n return `<a:bevelT/>`;\n }\n\n const attrs: Record<string, string | number> = {};\n\n if (options.w !== undefined) {\n attrs.w = options.w;\n }\n if (options.h !== undefined) {\n attrs.h = options.h;\n }\n if (options.prst !== undefined) {\n attrs.prst = options.prst;\n }\n\n return element(\"a:bevelT\", attrs);\n};\n\n/**\n * Creates a bottom bevel element (a:bevelB).\n */\nexport const createBottomBevel = (options?: BevelOptions): string => {\n if (!options) {\n return `<a:bevelB/>`;\n }\n\n const attrs: Record<string, string | number> = {};\n\n if (options.w !== undefined) {\n attrs.w = options.w;\n }\n if (options.h !== undefined) {\n attrs.h = options.h;\n }\n if (options.prst !== undefined) {\n attrs.prst = options.prst;\n }\n\n return element(\"a:bevelB\", attrs);\n};\n","/**\n * 3D shape properties for DrawingML.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Shape3D\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdMaterialType } from \"../../util/mappings\";\nimport { createColorElement } from \"../color/solid-fill\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { createBevel, createBottomBevel } from \"./bevel\";\nimport type { BevelOptions } from \"./bevel\";\n\n/**\n * Preset material types for 3D shapes (15 variations).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetMaterialType\n */\nexport type PresetMaterial =\n | \"legacyMatte\"\n | \"legacyPlastic\"\n | \"legacyMetal\"\n | \"legacyWireframe\"\n | \"matte\"\n | \"plastic\"\n | \"metal\"\n | \"warmMatte\"\n | \"translucentPowder\"\n | \"powder\"\n | \"darkEdge\"\n | \"softEdge\"\n | \"clear\"\n | \"flat\"\n | \"softMetal\";\n\n/**\n * Options for 3D shape properties.\n */\nexport interface Shape3DOptions {\n /** Top bevel options */\n bevelT?: BevelOptions;\n /** Bottom bevel options */\n bevelB?: BevelOptions;\n /** Extrusion color (CT_Color / EG_ColorChoice) */\n extrusionColor?: SolidFillOptions;\n /** Contour color (CT_Color / EG_ColorChoice) */\n contourColor?: SolidFillOptions;\n /** Depth in EMUs (default 0) */\n z?: number;\n /** Extrusion height in EMUs (default 0) */\n extrusionH?: number;\n /** Contour width in EMUs (default 0) */\n contourW?: number;\n /** Material preset type */\n prstMaterial?: PresetMaterial;\n}\n\n/**\n * Creates a 3D shape properties element (a:sp3d).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Shape3D\">\n * <xsd:sequence>\n * <xsd:element name=\"bevelT\" type=\"CT_Bevel\" minOccurs=\"0\"/>\n * <xsd:element name=\"bevelB\" type=\"CT_Bevel\" minOccurs=\"0\"/>\n * <xsd:element name=\"extrusionClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * <xsd:element name=\"contourClr\" type=\"CT_Color\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"z\" type=\"ST_Coordinate\" default=\"0\"/>\n * <xsd:attribute name=\"extrusionH\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"contourW\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"prstMaterial\" type=\"ST_PresetMaterialType\" default=\"warmMatte\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createShape3D = (options: Shape3DOptions): string => {\n const children: string[] = [];\n\n if (options.bevelT) {\n children.push(createBevel(options.bevelT));\n }\n if (options.bevelB) {\n children.push(createBottomBevel(options.bevelB));\n }\n if (options.extrusionColor) {\n children.push(\n element(\"a:extrusionClr\", undefined, [createColorElement(options.extrusionColor)]),\n );\n }\n if (options.contourColor) {\n children.push(element(\"a:contourClr\", undefined, [createColorElement(options.contourColor)]));\n }\n\n const attrs: Record<string, string | number> = {};\n if (options.z !== undefined) attrs.z = options.z;\n if (options.extrusionH !== undefined) attrs.extrusionH = options.extrusionH;\n if (options.contourW !== undefined) attrs.contourW = options.contourW;\n if (options.prstMaterial !== undefined)\n attrs.prstMaterial = xsdMaterialType.to(options.prstMaterial);\n\n return element(\"a:sp3d\", attrs, children);\n};\n","/**\n * Adjustment values module for preset geometries.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\n\n/**\n * A single geometry guide that defines an adjustment value.\n */\nexport interface GeometryGuide {\n /** Guide name (identifier) */\n name: string;\n /** Guide formula (e.g., \"val 16667\") */\n formula: string;\n}\n\n/**\n * Build a:avLst XML string from geometry guides.\n */\nexport function stringifyAdjustmentValues(guides?: readonly GeometryGuide[]): string {\n if (!guides || guides.length === 0) return \"<a:avLst/>\";\n const inner = guides\n .map((g) => `<a:gd name=\"${escapeXml(g.name)}\" fmla=\"${escapeXml(g.formula)}\"/>`)\n .join(\"\");\n return `<a:avLst>${inner}</a:avLst>`;\n}\n","/**\n * Preset geometry stringifier for DrawingML shapes.\n *\n * @module\n */\n\nimport type { GeometryGuide } from \"./adjustment-values\";\nimport { stringifyAdjustmentValues } from \"./adjustment-values\";\n\n/**\n * Preset shape tokens (a:prstGeom `@prst`, ST_ShapeType — dml-main.xsd, 188\n * values verbatim). `textNoShape` is a text-body-only preset; the arrows,\n * flowChart*, and actionButton* families round out the set.\n */\nexport type ShapeType =\n | \"line\"\n | \"lineInv\"\n | \"triangle\"\n | \"rtTriangle\"\n | \"rect\"\n | \"diamond\"\n | \"parallelogram\"\n | \"trapezoid\"\n | \"nonIsoscelesTrapezoid\"\n | \"pentagon\"\n | \"hexagon\"\n | \"heptagon\"\n | \"octagon\"\n | \"decagon\"\n | \"dodecagon\"\n | \"star4\"\n | \"star5\"\n | \"star6\"\n | \"star7\"\n | \"star8\"\n | \"star10\"\n | \"star12\"\n | \"star16\"\n | \"star24\"\n | \"star32\"\n | \"roundRect\"\n | \"round1Rect\"\n | \"round2SameRect\"\n | \"round2DiagRect\"\n | \"snipRoundRect\"\n | \"snip1Rect\"\n | \"snip2SameRect\"\n | \"snip2DiagRect\"\n | \"plaque\"\n | \"ellipse\"\n | \"teardrop\"\n | \"homePlate\"\n | \"chevron\"\n | \"pieWedge\"\n | \"pie\"\n | \"blockArc\"\n | \"donut\"\n | \"noSmoking\"\n | \"rightArrow\"\n | \"leftArrow\"\n | \"upArrow\"\n | \"downArrow\"\n | \"stripedRightArrow\"\n | \"notchedRightArrow\"\n | \"bentUpArrow\"\n | \"leftRightArrow\"\n | \"upDownArrow\"\n | \"leftUpArrow\"\n | \"leftRightUpArrow\"\n | \"quadArrow\"\n | \"leftArrowCallout\"\n | \"rightArrowCallout\"\n | \"upArrowCallout\"\n | \"downArrowCallout\"\n | \"leftRightArrowCallout\"\n | \"upDownArrowCallout\"\n | \"quadArrowCallout\"\n | \"bentArrow\"\n | \"uturnArrow\"\n | \"circularArrow\"\n | \"leftCircularArrow\"\n | \"leftRightCircularArrow\"\n | \"curvedRightArrow\"\n | \"curvedLeftArrow\"\n | \"curvedUpArrow\"\n | \"curvedDownArrow\"\n | \"swooshArrow\"\n | \"cube\"\n | \"can\"\n | \"lightningBolt\"\n | \"heart\"\n | \"sun\"\n | \"moon\"\n | \"smileyFace\"\n | \"irregularSeal1\"\n | \"irregularSeal2\"\n | \"foldedCorner\"\n | \"bevel\"\n | \"frame\"\n | \"halfFrame\"\n | \"corner\"\n | \"diagStripe\"\n | \"chord\"\n | \"arc\"\n | \"leftBracket\"\n | \"rightBracket\"\n | \"leftBrace\"\n | \"rightBrace\"\n | \"bracketPair\"\n | \"bracePair\"\n | \"straightConnector1\"\n | \"bentConnector2\"\n | \"bentConnector3\"\n | \"bentConnector4\"\n | \"bentConnector5\"\n | \"curvedConnector2\"\n | \"curvedConnector3\"\n | \"curvedConnector4\"\n | \"curvedConnector5\"\n | \"callout1\"\n | \"callout2\"\n | \"callout3\"\n | \"accentCallout1\"\n | \"accentCallout2\"\n | \"accentCallout3\"\n | \"borderCallout1\"\n | \"borderCallout2\"\n | \"borderCallout3\"\n | \"accentBorderCallout1\"\n | \"accentBorderCallout2\"\n | \"accentBorderCallout3\"\n | \"wedgeRectCallout\"\n | \"wedgeRoundRectCallout\"\n | \"wedgeEllipseCallout\"\n | \"cloudCallout\"\n | \"cloud\"\n | \"ribbon\"\n | \"ribbon2\"\n | \"ellipseRibbon\"\n | \"ellipseRibbon2\"\n | \"leftRightRibbon\"\n | \"verticalScroll\"\n | \"horizontalScroll\"\n | \"wave\"\n | \"doubleWave\"\n | \"plus\"\n | \"flowChartProcess\"\n | \"flowChartDecision\"\n | \"flowChartInputOutput\"\n | \"flowChartPredefinedProcess\"\n | \"flowChartInternalStorage\"\n | \"flowChartDocument\"\n | \"flowChartMultidocument\"\n | \"flowChartTerminator\"\n | \"flowChartPreparation\"\n | \"flowChartManualInput\"\n | \"flowChartManualOperation\"\n | \"flowChartConnector\"\n | \"flowChartPunchedCard\"\n | \"flowChartPunchedTape\"\n | \"flowChartSummingJunction\"\n | \"flowChartOr\"\n | \"flowChartCollate\"\n | \"flowChartSort\"\n | \"flowChartExtract\"\n | \"flowChartMerge\"\n | \"flowChartOfflineStorage\"\n | \"flowChartOnlineStorage\"\n | \"flowChartMagneticTape\"\n | \"flowChartMagneticDisk\"\n | \"flowChartMagneticDrum\"\n | \"flowChartDisplay\"\n | \"flowChartDelay\"\n | \"flowChartAlternateProcess\"\n | \"flowChartOffpageConnector\"\n | \"actionButtonBlank\"\n | \"actionButtonHome\"\n | \"actionButtonHelp\"\n | \"actionButtonInformation\"\n | \"actionButtonForwardNext\"\n | \"actionButtonBackPrevious\"\n | \"actionButtonEnd\"\n | \"actionButtonBeginning\"\n | \"actionButtonReturn\"\n | \"actionButtonDocument\"\n | \"actionButtonSound\"\n | \"actionButtonMovie\"\n | \"gear6\"\n | \"gear9\"\n | \"funnel\"\n | \"mathPlus\"\n | \"mathMinus\"\n | \"mathMultiply\"\n | \"mathDivide\"\n | \"mathEqual\"\n | \"mathNotEqual\"\n | \"cornerTabs\"\n | \"squareTabs\"\n | \"plaqueTabs\"\n | \"chartX\"\n | \"chartStar\"\n | \"chartPlus\"\n | \"textNoShape\";\n\nexport interface PresetGeometryOptions {\n /** Preset token (a:prstGeom `@prst`, ST_ShapeType) */\n preset?: ShapeType;\n adjustmentValues?: readonly GeometryGuide[];\n}\n\n/**\n * Build a:prstGeom XML string.\n */\nexport function stringifyPresetGeometry(options?: PresetGeometryOptions): string {\n const prst = options?.preset ?? \"rect\";\n const avLst = stringifyAdjustmentValues(options?.adjustmentValues);\n return `<a:prstGeom prst=\"${prst}\">${avLst}</a:prstGeom>`;\n}\n","/**\n * Custom geometry module for DrawingML shapes.\n *\n * Provides CT_CustomGeometry2D — user-defined 2D geometry with paths,\n * guides, adjust handles, connection sites, and a text insertion rectangle.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_CustomGeometry2D\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdPathFillMode } from \"../../util/mappings\";\nimport type { GeometryGuide } from \"./adjustment-values\";\n\n/**\n * Creates a geometry guide list element (a:avLst or a:gdLst).\n *\n * Both CT_GeomGuideList types share the same structure — a list of `a:gd` children.\n * The only difference is the wrapper element name.\n */\nconst createGuideList = (name: string, guides: readonly GeometryGuide[]): string => {\n const children = guides.map((guide) => `<a:gd name=\"${guide.name}\" fmla=\"${guide.formula}\"/>`);\n return element(name, undefined, children);\n};\n\n// ─── Path Fill Mode ─────────────────────────────────────────────────────────\n\n/**\n * Path fill mode (ST_PathFillMode).\n *\n * Note: the `\"normal\"` value here maps to the XSD `norm` token.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PathFillMode\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"norm\"/>\n * <xsd:enumeration value=\"lighten\"/>\n * <xsd:enumeration value=\"lightenLess\"/>\n * <xsd:enumeration value=\"darken\"/>\n * <xsd:enumeration value=\"darkenLess\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport type PathFillMode = \"none\" | \"normal\" | \"lighten\" | \"lightenLess\" | \"darken\" | \"darkenLess\";\n\n// ─── Point ──────────────────────────────────────────────────────────────────\n\n/**\n * An adjustable point (CT_AdjPoint2D).\n *\n * Coordinates can be absolute values or references to geometry guide names.\n */\nexport interface AdjustPoint {\n /** X coordinate (absolute value or guide name) */\n x: string;\n /** Y coordinate (absolute value or guide name) */\n y: string;\n}\n\nconst createAdjustPoint = (name: string, point: AdjustPoint): string =>\n element(name, undefined, [`<a:pt x=\"${point.x}\" y=\"${point.y}\"/>`]);\n\n// ─── Path Commands ──────────────────────────────────────────────────────────\n\n/** Move-to path command (CT_Path2DMoveTo). */\nexport interface PathMoveTo {\n command: \"moveTo\";\n point: AdjustPoint;\n}\n\n/** Line-to path command (CT_Path2DLineTo). */\nexport interface PathLineTo {\n command: \"lineTo\";\n point: AdjustPoint;\n}\n\n/** Arc-to path command (CT_Path2DArcTo). */\nexport interface PathArcTo {\n command: \"arcTo\";\n widthRadius: string;\n heightRadius: string;\n startAngle: string;\n sweepAngle: string;\n}\n\n/** Quadratic Bezier-to path command (CT_Path2DQuadBezierTo). */\nexport interface PathQuadBezTo {\n command: \"quadBezTo\";\n points: readonly [AdjustPoint, AdjustPoint];\n}\n\n/** Cubic Bezier-to path command (CT_Path2DCubicBezierTo). */\nexport interface PathCubicBezTo {\n command: \"cubicBezTo\";\n points: readonly [AdjustPoint, AdjustPoint, AdjustPoint];\n}\n\n/** Close path command (CT_Path2DClose). */\nexport interface PathClose {\n command: \"close\";\n}\n\n/** A path command within a custom geometry path. */\nexport type PathCommand =\n | PathMoveTo\n | PathLineTo\n | PathArcTo\n | PathQuadBezTo\n | PathCubicBezTo\n | PathClose;\n\nconst createPathCommand = (cmd: PathCommand): string => {\n switch (cmd.command) {\n case \"moveTo\":\n return createAdjustPoint(\"a:moveTo\", cmd.point);\n case \"lineTo\":\n return createAdjustPoint(\"a:lnTo\", cmd.point);\n case \"arcTo\":\n return `<a:arcTo wR=\"${cmd.widthRadius}\" hR=\"${cmd.heightRadius}\" stAng=\"${cmd.startAngle}\" swAng=\"${cmd.sweepAngle}\"/>`;\n case \"quadBezTo\":\n return element(\n \"a:quadBezTo\",\n undefined,\n cmd.points.map((pt) => `<a:pt x=\"${pt.x}\" y=\"${pt.y}\"/>`),\n );\n case \"cubicBezTo\":\n return element(\n \"a:cubicBezTo\",\n undefined,\n cmd.points.map((pt) => `<a:pt x=\"${pt.x}\" y=\"${pt.y}\"/>`),\n );\n case \"close\":\n return \"<a:close/>\";\n }\n};\n\n// ─── Path ───────────────────────────────────────────────────────────────────\n\n/**\n * Options for a 2D path (CT_Path2D).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Path2D\">\n * <xsd:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n * <xsd:element name=\"close\" type=\"CT_Path2DClose\"/>\n * <xsd:element name=\"moveTo\" type=\"CT_Path2DMoveTo\"/>\n * <xsd:element name=\"lnTo\" type=\"CT_Path2DLineTo\"/>\n * <xsd:element name=\"arcTo\" type=\"CT_Path2DArcTo\"/>\n * <xsd:element name=\"quadBezTo\" type=\"CT_Path2DQuadBezierTo\"/>\n * <xsd:element name=\"cubicBezTo\" type=\"CT_Path2DCubicBezierTo\"/>\n * </xsd:choice>\n * <xsd:attribute name=\"w\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"h\" type=\"ST_PositiveCoordinate\" default=\"0\"/>\n * <xsd:attribute name=\"fill\" type=\"ST_PathFillMode\" default=\"norm\"/>\n * <xsd:attribute name=\"stroke\" type=\"xsd:boolean\" default=\"true\"/>\n * <xsd:attribute name=\"extrusionOk\" type=\"xsd:boolean\" default=\"true\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface PathOptions {\n /** Path width (coordinate value, default 0 = use shape width) */\n w?: number;\n /** Path height (coordinate value, default 0 = use shape height) */\n h?: number;\n /** Fill mode for this path */\n fill?: PathFillMode;\n /** Whether to stroke the path */\n stroke?: boolean;\n /** Whether extrusion is allowed */\n extrusionOk?: boolean;\n /** Path commands (moveTo, lineTo, arcTo, etc.) */\n commands: readonly PathCommand[];\n}\n\nconst createPath = (options: PathOptions): string => {\n const attrs: Record<string, string | number | boolean | undefined> = {};\n if (options.w !== undefined) attrs.w = options.w;\n if (options.h !== undefined) attrs.h = options.h;\n if (options.fill !== undefined) attrs.fill = xsdPathFillMode.to(options.fill);\n if (options.stroke !== undefined) attrs.stroke = options.stroke;\n if (options.extrusionOk !== undefined) attrs.extrusionOk = options.extrusionOk;\n\n return element(\"a:path\", attrs, options.commands.map(createPathCommand));\n};\n\n// ─── Adjust Handle ──────────────────────────────────────────────────────────\n\n/**\n * A position reference for adjust handles and connection sites.\n */\nexport interface AdjustHandlePosition {\n x: string;\n y: string;\n}\n\n/**\n * XY adjust handle (CT_XYAdjustHandle).\n *\n * Allows the user to drag a handle in X/Y directions.\n */\nexport interface XYAdjustHandle {\n type: \"xy\";\n guideRefX?: string;\n minX?: string;\n maxX?: string;\n guideRefY?: string;\n minY?: string;\n maxY?: string;\n position: AdjustHandlePosition;\n}\n\n/**\n * Polar adjust handle (CT_PolarAdjustHandle).\n *\n * Allows the user to drag a handle in radius/angle directions.\n */\nexport interface PolarAdjustHandle {\n type: \"polar\";\n guideRefRadius?: string;\n minRadius?: string;\n maxRadius?: string;\n guideRefAngle?: string;\n minAngle?: string;\n maxAngle?: string;\n position: AdjustHandlePosition;\n}\n\n/** An adjust handle (XY or Polar). */\nexport type AdjustHandle = XYAdjustHandle | PolarAdjustHandle;\n\nconst createAdjustHandlePos = (position: AdjustHandlePosition): string =>\n `<a:pos x=\"${position.x}\" y=\"${position.y}\"/>`;\n\nconst createXYAdjustHandle = (handle: XYAdjustHandle): string => {\n const attrs: Record<string, string | undefined> = {};\n if (handle.guideRefX !== undefined) attrs.gdRefX = handle.guideRefX;\n if (handle.minX !== undefined) attrs.minX = handle.minX;\n if (handle.maxX !== undefined) attrs.maxX = handle.maxX;\n if (handle.guideRefY !== undefined) attrs.gdRefY = handle.guideRefY;\n if (handle.minY !== undefined) attrs.minY = handle.minY;\n if (handle.maxY !== undefined) attrs.maxY = handle.maxY;\n\n return element(\"a:ahXY\", attrs, [createAdjustHandlePos(handle.position)]);\n};\n\nconst createPolarAdjustHandle = (handle: PolarAdjustHandle): string => {\n const attrs: Record<string, string | undefined> = {};\n if (handle.guideRefRadius !== undefined) attrs.gdRefR = handle.guideRefRadius;\n if (handle.minRadius !== undefined) attrs.minR = handle.minRadius;\n if (handle.maxRadius !== undefined) attrs.maxR = handle.maxRadius;\n if (handle.guideRefAngle !== undefined) attrs.gdRefAng = handle.guideRefAngle;\n if (handle.minAngle !== undefined) attrs.minAng = handle.minAngle;\n if (handle.maxAngle !== undefined) attrs.maxAng = handle.maxAngle;\n\n return element(\"a:ahPolar\", attrs, [createAdjustHandlePos(handle.position)]);\n};\n\n// ─── Connection Site ────────────────────────────────────────────────────────\n\n/**\n * Connection site (CT_ConnectionSite).\n *\n * Defines a point on the shape boundary where connectors can attach.\n */\nexport interface ConnectionSite {\n /** Angle (absolute value or guide name) */\n angle: string;\n position: AdjustHandlePosition;\n}\n\nconst createConnectionSite = (site: ConnectionSite): string =>\n element(\"a:cxn\", { ang: site.angle }, [createAdjustHandlePos(site.position)]);\n\n// ─── Geometry Rectangle ─────────────────────────────────────────────────────\n\n/**\n * Text insertion rectangle (CT_GeomRect).\n *\n * Defines the rectangle within the shape where text is placed.\n * Coordinates can be absolute values or references to geometry guide names.\n */\nexport interface GeomRect {\n left: string;\n top: string;\n right: string;\n bottom: string;\n}\n\nconst createGeomRect = (rect: GeomRect): string =>\n `<a:rect l=\"${rect.left}\" t=\"${rect.top}\" r=\"${rect.right}\" b=\"${rect.bottom}\"/>`;\n\n// ─── Custom Geometry ────────────────────────────────────────────────────────\n\n/**\n * Options for a custom 2D geometry (CT_CustomGeometry2D).\n *\n * Only `pathList` is required. All other sub-elements are optional.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_CustomGeometry2D\">\n * <xsd:sequence>\n * <xsd:element name=\"avLst\" type=\"CT_GeomGuideList\" minOccurs=\"0\"/>\n * <xsd:element name=\"gdLst\" type=\"CT_GeomGuideList\" minOccurs=\"0\"/>\n * <xsd:element name=\"ahLst\" type=\"CT_AdjustHandleList\" minOccurs=\"0\"/>\n * <xsd:element name=\"cxnLst\" type=\"CT_ConnectionSiteList\" minOccurs=\"0\"/>\n * <xsd:element name=\"rect\" type=\"CT_GeomRect\" minOccurs=\"0\"/>\n * <xsd:element name=\"pathLst\" type=\"CT_Path2DList\" minOccurs=\"1\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Simple triangle\n * createCustomGeometry({\n * pathList: [{\n * commands: [\n * { command: \"moveTo\", point: { x: \"0\", y: \"0\" } },\n * { command: \"lineTo\", point: { x: \"10000000\", y: \"0\" } },\n * { command: \"lineTo\", point: { x: \"5000000\", y: \"10000000\" } },\n * { command: \"close\" },\n * ],\n * }],\n * });\n * ```\n */\nexport interface CustomGeometryOptions {\n /** Adjustment value guides (a:avLst) */\n adjustmentValues?: readonly GeometryGuide[];\n /** Geometry guide formulas (a:gdLst) */\n guides?: readonly GeometryGuide[];\n /** Adjust handles (a:ahLst) */\n adjustHandles?: readonly AdjustHandle[];\n /** Connection sites (a:cxnLst) */\n connectionSites?: readonly ConnectionSite[];\n /** Text insertion rectangle (a:rect) */\n textRectangle?: GeomRect;\n /**\n * Path definitions (a:pathLst) — XSD-required (minOccurs=1): omitting it on\n * stringify still emits an empty `<a:pathLst/>` so the geometry stays\n * schema-valid. An empty array round-trips an explicit empty list.\n */\n pathList?: readonly PathOptions[];\n}\n\n/**\n * Creates a custom 2D geometry element as an XML string (a:custGeom).\n *\n * @example\n * ```typescript\n * // Diamond shape\n * const geom = createCustomGeometry({\n * pathList: [{\n * commands: [\n * { command: \"moveTo\", point: { x: \"5000000\", y: \"0\" } },\n * { command: \"lineTo\", point: { x: \"10000000\", y: \"5000000\" } },\n * { command: \"lineTo\", point: { x: \"5000000\", y: \"10000000\" } },\n * { command: \"lineTo\", point: { x: \"0\", y: \"5000000\" } },\n * { command: \"close\" },\n * ],\n * }],\n * textRectangle: { left: \"2000000\", top: \"2000000\", right: \"8000000\", bottom: \"8000000\" },\n * });\n * ```\n */\nexport const createCustomGeometry = (options: CustomGeometryOptions): string => {\n const children: string[] = [];\n\n // a:avLst\n if (options.adjustmentValues) {\n children.push(createGuideList(\"a:avLst\", options.adjustmentValues));\n }\n\n // a:gdLst\n if (options.guides) {\n children.push(createGuideList(\"a:gdLst\", options.guides));\n }\n\n // a:ahLst — an empty array keeps the bare element (sources often carry one).\n if (options.adjustHandles) {\n children.push(\n element(\n \"a:ahLst\",\n undefined,\n options.adjustHandles.map((h) =>\n h.type === \"xy\" ? createXYAdjustHandle(h) : createPolarAdjustHandle(h),\n ),\n ),\n );\n }\n\n // a:cxnLst\n if (options.connectionSites && options.connectionSites.length > 0) {\n children.push(\n element(\"a:cxnLst\", undefined, options.connectionSites.map(createConnectionSite)),\n );\n }\n\n // a:rect\n if (options.textRectangle) {\n children.push(createGeomRect(options.textRectangle));\n }\n\n // a:pathLst (required, minOccurs=1) — omitting it still emits the empty form\n children.push(element(\"a:pathLst\", undefined, (options.pathList ?? []).map(createPath)));\n\n return element(\"a:custGeom\", undefined, children);\n};\n","/**\n * Blip extensions module for SVG support.\n *\n * This module provides extension elements that enable SVG image support\n * within blip elements using Office-specific extensions.\n *\n * Reference: http://officeopenxml.com/drwPic.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n/**\n * Creates an SVG blip element for embedding SVG images.\n *\n * This element is a Microsoft Office extension that allows SVG images\n * to be referenced within a blip.\n *\n * @param svgReferenceId - The reference ID for the SVG image\n * @returns An XML string representing the SVG blip element\n * @internal\n */\nconst createSvgBlip = (svgReferenceId: string): string =>\n `<asvg:svgBlip xmlns:asvg=\"http://schemas.microsoft.com/office/drawing/2016/SVG/main\" r:embed=\"{${svgReferenceId}}\"/>`;\n\n/**\n * Creates an extension element for SVG support.\n *\n * This element wraps the SVG blip extension with the appropriate URI\n * to identify it as an SVG extension.\n *\n * @param svgReferenceId - The reference ID for the SVG image\n * @returns An XML string representing the extension element\n * @internal\n */\nconst createExtension = (svgReferenceId: string): string =>\n element(\"a:ext\", { uri: \"{96DAC541-7B7A-43D3-8B79-37D633B846F1}\" }, [\n createSvgBlip(svgReferenceId),\n ]);\n\n/**\n * Creates an extension list for SVG images.\n *\n * This element contains the extensions needed to embed SVG images\n * within a blip. It wraps the SVG-specific extension elements.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_OfficeArtExtensionList\">\n * <xsd:sequence>\n * <xsd:element name=\"ext\" type=\"CT_OfficeArtExtension\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @param svgReferenceId - The reference ID for the SVG image\n * @returns An XML string representing the extension list\n */\nexport const createExtensionList = (svgReferenceId: string): string =>\n element(\"a:extLst\", undefined, [createExtension(svgReferenceId)]);\n","/**\n * Blip (Binary Large Image or Picture) module for DrawingML.\n *\n * This module provides the blip element that references the actual\n * image data within a picture.\n *\n * Reference: http://officeopenxml.com/drwPic.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { createBlipEffects } from \"./blip-effects\";\nimport type { BlipEffectsOptions } from \"./blip-effects\";\nimport { createExtensionList } from \"./blip-extensions\";\n\n/** Blip compression states (ST_BlipCompression, the a:blip @cstate attribute). */\nexport type BlipCompression = \"email\" | \"screen\" | \"print\" | \"hqprint\" | \"none\";\n\n/**\n * Options for creating a blip element.\n */\nexport interface BlipOptions {\n /**\n * File name used as placeholder for the embedded image; the packer's\n * ImageReplacer replaces `{referenceId}` with `rId{N}`. Absent on a\n * linked-only picture (external URL, no bytes in the package).\n */\n referenceId?: string;\n /**\n * Placeholder key for the linked image source (a:blip @r:link) — an external\n * URL relationship. Present alone on linked-only pictures, alongside\n * referenceId when the package also caches a local copy.\n */\n linkReferenceId?: string;\n /** Compression state (a:blip @cstate); absent = attribute omitted (schema default \"none\"). */\n compression?: BlipCompression;\n /** Image type for SVG detection */\n type?: \"svg\" | string;\n /** For SVG images, the fallback image file name */\n fallbackFileName?: string;\n}\n\n/**\n * Creates a blip element for an image.\n *\n * A blip references the actual image data stored in the document package\n * through a relationship ID. For SVG images, it includes extensions that\n * reference the SVG data.\n *\n * Reference: http://officeopenxml.com/drwPic.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Blip\">\n * <xsd:sequence>\n * <xsd:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n * <xsd:element name=\"alphaBiLevel\" type=\"CT_AlphaBiLevelEffect\"/>\n * <xsd:element name=\"alphaCeiling\" type=\"CT_AlphaCeilingEffect\"/>\n * <xsd:element name=\"alphaFloor\" type=\"CT_AlphaFloorEffect\"/>\n * <xsd:element name=\"alphaInv\" type=\"CT_AlphaInverseEffect\"/>\n * <xsd:element name=\"alphaMod\" type=\"CT_AlphaModulateEffect\"/>\n * <xsd:element name=\"alphaModFix\" type=\"CT_AlphaModulateFixedEffect\"/>\n * <xsd:element name=\"alphaRepl\" type=\"CT_AlphaReplaceEffect\"/>\n * <xsd:element name=\"biLevel\" type=\"CT_BiLevelEffect\"/>\n * <xsd:element name=\"blur\" type=\"CT_BlurEffect\"/>\n * <xsd:element name=\"clrChange\" type=\"CT_ColorChangeEffect\"/>\n * <xsd:element name=\"clrRepl\" type=\"CT_ColorReplaceEffect\"/>\n * <xsd:element name=\"duotone\" type=\"CT_DuotoneEffect\"/>\n * <xsd:element name=\"fillOverlay\" type=\"CT_FillOverlayEffect\"/>\n * <xsd:element name=\"grayscl\" type=\"CT_GrayscaleEffect\"/>\n * <xsd:element name=\"hsl\" type=\"CT_HSLEffect\"/>\n * <xsd:element name=\"lum\" type=\"CT_LuminanceEffect\"/>\n * <xsd:element name=\"tint\" type=\"CT_TintEffect\"/>\n * </xsd:choice>\n * <xsd:element name=\"extLst\" type=\"CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute ref=\"r:embed\"/>\n * <xsd:attribute ref=\"r:link\"/>\n * <xsd:attribute name=\"cstate\" type=\"ST_BlipCompression\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Blip options including referenceId and type\n * @param blipEffects - Optional blip effects (brightness, contrast, etc.)\n * @returns An XML string representing the blip element\n */\nexport const createBlip = (options: BlipOptions, blipEffects?: BlipEffectsOptions): string => {\n const children: string[] = [];\n\n if (blipEffects) {\n children.push(...createBlipEffects(blipEffects));\n }\n\n if (options.type === \"svg\" && options.fallbackFileName && options.referenceId !== undefined) {\n children.push(createExtensionList(options.referenceId));\n }\n\n return element(\n \"a:blip\",\n {\n ...(options.referenceId !== undefined\n ? {\n \"r:embed\": `{${options.type === \"svg\" && options.fallbackFileName ? options.fallbackFileName : options.referenceId}}`,\n }\n : {}),\n ...(options.compression !== undefined ? { cstate: options.compression } : {}),\n ...(options.linkReferenceId !== undefined\n ? { \"r:link\": `{${options.linkReferenceId}}` }\n : {}),\n },\n children.length > 0 ? children : undefined,\n );\n};\n","/**\n * Blip fill module for DrawingML pictures.\n *\n * This module defines how an image (blip) fills a picture shape,\n * including stretching and cropping options.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { createBlip } from \"./blip\";\nimport type { BlipOptions } from \"./blip\";\nimport type { BlipEffectsOptions } from \"./blip-effects\";\nimport { createSourceRectangle } from \"./source-rectangle\";\nimport type { SourceRectangleOptions } from \"./source-rectangle\";\nimport { createTileInfo } from \"./tile\";\nimport type { TileOptions } from \"./tile\";\n\n/**\n * Options for blip fill properties.\n */\nexport interface BlipFillOptions {\n /** DPI of the image */\n dpi?: number;\n /** Whether the fill rotates with the shape */\n rotWithShape?: boolean;\n /** Image adjustment effects (brightness, contrast, grayscale, etc.) */\n blipEffects?: BlipEffectsOptions;\n /** Source rectangle for cropping */\n sourceRectangle?: SourceRectangleOptions;\n /** Tile fill mode (if omitted, defaults to stretch) */\n tile?: TileOptions;\n}\n\n/**\n * Creates a blip fill element.\n *\n * This element specifies the type of fill used for a picture. It contains the blip (image)\n * reference, an optional source rectangle for cropping, and the fill mode (typically stretch).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_BlipFillProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"blip\" type=\"CT_Blip\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"srcRect\" type=\"CT_RelativeRect\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:group ref=\"EG_FillModeProperties\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"dpi\" type=\"xsd:unsignedInt\" use=\"optional\"/>\n * <xsd:attribute name=\"rotWithShape\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @param blipOptions - Blip options including referenceId and type\n * @param fillOptions - Optional blip fill options\n * @returns An XML string representing the blip fill element\n */\nexport const createBlipFill = (blipOptions: BlipOptions, fillOptions?: BlipFillOptions): string => {\n const children: string[] = [];\n\n children.push(createBlip(blipOptions, fillOptions?.blipEffects));\n children.push(createSourceRectangle(fillOptions?.sourceRectangle));\n\n if (fillOptions?.tile) {\n children.push(createTileInfo(fillOptions.tile));\n } else {\n children.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n\n const attrs: Record<string, string | number | undefined> = {};\n if (fillOptions?.dpi !== undefined) {\n attrs.dpi = fillOptions.dpi;\n }\n if (fillOptions?.rotWithShape !== undefined) {\n attrs.rotWithShape = fillOptions.rotWithShape ? 1 : 0;\n }\n\n return element(\"pic:blipFill\", attrs, children);\n};\n","/**\n * Stretch fill stringifier for blip fills.\n *\n * @module\n */\n\n/**\n * Build a:stretch XML string with a:fillRect child.\n */\nexport function stringifyStretch(): string {\n return \"<a:stretch><a:fillRect/></a:stretch>\";\n}\n","import { element } from \"@office-open/xml\";\n\nimport { convertToEmu } from \"../util/converters\";\n/**\n * 2D transform for DrawingML shapes.\n *\n * This module provides factory functions for creating transform elements\n * (a:xfrm) used in shape properties, picture properties, and group shapes.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Transform2D / CT_GroupTransform2D\n *\n * @module\n */\nimport type { UniversalMeasure } from \"../util/values\";\n\n// <xsd:complexType name=\"CT_Transform2D\">\n// <xsd:sequence>\n// <xsd:element name=\"off\" type=\"CT_Point2D\" minOccurs=\"0\"/>\n// <xsd:element name=\"ext\" type=\"CT_PositiveSize2D\" minOccurs=\"0\"/>\n// </xsd:sequence>\n// <xsd:attribute name=\"rot\" type=\"ST_Angle\" use=\"optional\"/>\n// <xsd:attribute name=\"flipH\" type=\"xsd:boolean\" use=\"optional\"/>\n// <xsd:attribute name=\"flipV\" type=\"xsd:boolean\" use=\"optional\"/>\n// </xsd:complexType>\n\nexport interface Transform2DOptions {\n x?: number | UniversalMeasure;\n y?: number | UniversalMeasure;\n width?: number | UniversalMeasure;\n height?: number | UniversalMeasure;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n /** Rotation angle in degrees (e.g., 45 = 45°). */\n rotation?: number;\n}\n\n// <xsd:complexType name=\"CT_GroupTransform2D\">\n// <xsd:complexContent>\n// <xsd:extension base=\"CT_Transform2D\">\n// <xsd:sequence>\n// <xsd:element name=\"chOff\" type=\"CT_Point2D\" minOccurs=\"0\"/>\n// <xsd:element name=\"chExt\" type=\"CT_PositiveSize2D\" minOccurs=\"0\"/>\n// </xsd:sequence>\n// </xsd:extension>\n// </xsd:complexContent>\n// </xsd:complexType>\n\nexport interface GroupTransform2DOptions extends Transform2DOptions {\n childOffsetX?: number | UniversalMeasure;\n childOffsetY?: number | UniversalMeasure;\n childExtentWidth?: number | UniversalMeasure;\n childExtentHeight?: number | UniversalMeasure;\n}\n\nfunction buildXfrmAttrs(\n options: Transform2DOptions,\n): Record<string, string | number | boolean> | undefined {\n const attrs: Record<string, string | number | boolean> = {};\n if (options.flipHorizontal !== undefined) attrs.flipH = options.flipHorizontal;\n if (options.flipVertical !== undefined) attrs.flipV = options.flipVertical;\n if (options.rotation !== undefined) attrs.rot = Math.round(options.rotation * 60000);\n return Object.keys(attrs).length > 0 ? attrs : undefined;\n}\n\n/**\n * Creates a 2D transform element (a:xfrm).\n *\n * @param options - Transform options including position, size, rotation, and flip.\n * @param elementName - Element name, defaults to \"a:xfrm\".\n */\nexport const createTransform2D = (\n options: Transform2DOptions,\n elementName: string = \"a:xfrm\",\n): string => {\n const children: string[] = [];\n\n if (options.x !== undefined || options.y !== undefined) {\n const x = options.x !== undefined ? convertToEmu(options.x) : 0;\n const y = options.y !== undefined ? convertToEmu(options.y) : 0;\n children.push(`<a:off x=\"${x}\" y=\"${y}\"/>`);\n }\n\n if (options.width !== undefined || options.height !== undefined) {\n const cx = options.width !== undefined ? convertToEmu(options.width) : 0;\n const cy = options.height !== undefined ? convertToEmu(options.height) : 0;\n children.push(`<a:ext cx=\"${cx}\" cy=\"${cy}\"/>`);\n }\n\n return element(elementName, buildXfrmAttrs(options), children);\n};\n\n/**\n * Creates a group transform element (a:xfrm with chOff/chExt children).\n */\nexport const createGroupTransform2D = (\n options: GroupTransform2DOptions,\n elementName: string = \"a:xfrm\",\n): string => {\n const children: string[] = [];\n\n if (options.x !== undefined || options.y !== undefined) {\n const x = options.x !== undefined ? convertToEmu(options.x) : 0;\n const y = options.y !== undefined ? convertToEmu(options.y) : 0;\n children.push(`<a:off x=\"${x}\" y=\"${y}\"/>`);\n }\n\n if (options.width !== undefined || options.height !== undefined) {\n const cx = options.width !== undefined ? convertToEmu(options.width) : 0;\n const cy = options.height !== undefined ? convertToEmu(options.height) : 0;\n children.push(`<a:ext cx=\"${cx}\" cy=\"${cy}\"/>`);\n }\n\n const chOffX = options.childOffsetX !== undefined ? convertToEmu(options.childOffsetX) : 0;\n const chOffY = options.childOffsetY !== undefined ? convertToEmu(options.childOffsetY) : 0;\n children.push(`<a:chOff x=\"${chOffX}\" y=\"${chOffY}\"/>`);\n\n const chExtCx =\n options.childExtentWidth !== undefined ? convertToEmu(options.childExtentWidth) : 0;\n const chExtCy =\n options.childExtentHeight !== undefined ? convertToEmu(options.childExtentHeight) : 0;\n children.push(`<a:chExt cx=\"${chExtCx}\" cy=\"${chExtCy}\"/>`);\n\n return element(elementName, buildXfrmAttrs(options), children);\n};\n","/**\n * Table Style system for DrawingML.\n *\n * Generates CT_TableStyle and CT_TableStyleList XML for custom table styles\n * in presentations (PPTX) and documents.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TableStyle / CT_TableStyleList\n *\n * @module\n */\nimport { attr, attrNum, element, findChild, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { ReadContext, WriteContext } from \"../descriptor\";\nimport { parse as parseDesc, stringify as stringifyDesc } from \"../descriptor\";\nimport { xsdCompoundLine } from \"../util/mappings\";\nimport { parseColorChoice, stringifyColorChoice } from \"./color/color-descriptors\";\nimport type { SolidFillOptions } from \"./color/solid-fill\";\nimport type { StyleMatrixReferenceOptions } from \"./style-reference\";\nimport { cell3DDesc } from \"./three-d/three-d-descriptors\";\nimport type { Cell3DOptions } from \"./three-d/three-d-descriptors\";\n\nexport type { StyleMatrixReferenceOptions } from \"./style-reference\";\n\n// cell3DDesc's stringify/parse never touch the context (bevel/lightRig are\n// pure attribute emitters), so bare stubs satisfy the descriptor signature.\nconst EMPTY_WRITE_CTX = {} as WriteContext;\nconst EMPTY_READ_CTX = {} as ReadContext;\n\n// ── Options ──\n\nexport type TableStyleRegion =\n | \"tblBg\"\n | \"wholeTbl\"\n | \"band1H\"\n | \"band2H\"\n | \"band1V\"\n | \"band2V\"\n | \"lastCol\"\n | \"firstCol\"\n | \"lastRow\"\n | \"seCell\"\n | \"swCell\"\n | \"firstRow\"\n | \"neCell\"\n | \"nwCell\";\n\n/** Style-part on/off state (ST_OnOffStyleType). */\nexport type OnOffStyleType = \"on\" | \"off\" | \"default\";\n\n/** Compound line type (ST_CompoundLine, @cmpd on a:ln). */\nexport type CompoundLineType = \"single\" | \"double\" | \"thickThin\" | \"thinThick\" | \"triple\";\n\n/**\n * Font reference — a:fontRef (CT_FontReference). Unlike lnRef/fillRef/effectRef\n * (CT_StyleMatrixReference, integer idx), its @idx is a font-collection name\n * (ST_FontCollectionIndex: major/minor/none).\n */\nexport interface TableFontReferenceOptions {\n /** Theme font slot: \"major\" headings, \"minor\" body text, \"none\". */\n collection: \"major\" | \"minor\" | \"none\";\n color?: SolidFillOptions;\n}\n\nexport interface TablePartStyleOptions {\n /** Cell text style */\n text?: TableTextStyleOptions;\n /** Cell style (fill, borders, 3D) */\n cell?: TableCellStyleOptions;\n /** Table background (a:tblBg only) — themeable fill/effect references. */\n background?: TableBackgroundStyleOptions;\n}\n\n/** Table background style (CT_TableBackgroundStyle: fill → effect). */\nexport interface TableBackgroundStyleOptions {\n /** Theme fill reference (a:fillRef idx). */\n fillReference?: StyleMatrixReferenceOptions;\n /** Explicit fill choice as raw XML (e.g. a:solidFill). */\n fill?: string;\n /** Theme effect reference (a:effectRef idx). */\n effectReference?: StyleMatrixReferenceOptions;\n}\n\nexport interface TableTextStyleOptions {\n /** Bold style */\n bold?: OnOffStyleType;\n /** Italic style */\n italic?: OnOffStyleType;\n /** Font reference (themeable) */\n fontReference?: TableFontReferenceOptions;\n /** Color element */\n color?: string;\n}\n\nexport interface TableCellStyleOptions {\n /** Cell borders */\n borders?: TableCellBorderOptions;\n /** Fill reference (themeable) */\n fillReference?: StyleMatrixReferenceOptions;\n /** Direct fill */\n fill?: string;\n /** Cell bevel (CT_Cell3D) */\n cell3D?: Cell3DOptions;\n}\n\nexport interface TableCellBorderOptions {\n left?: ThemeableLineStyleOptions;\n right?: ThemeableLineStyleOptions;\n top?: ThemeableLineStyleOptions;\n bottom?: ThemeableLineStyleOptions;\n insideH?: ThemeableLineStyleOptions;\n insideV?: ThemeableLineStyleOptions;\n}\n\nexport interface ThemeableLineStyleOptions {\n /** Line width in EMUs */\n width?: number;\n /** Compound line type (@cmpd) */\n compound?: CompoundLineType;\n /** Fill color component */\n color?: string;\n /** Line reference (a:lnRef) into the theme style matrix */\n lineReference?: StyleMatrixReferenceOptions;\n}\n\nexport interface TableStyleOptions {\n /** Unique GUID for this style */\n styleId: string;\n /** Display name */\n styleName: string;\n /** Style regions */\n regions?: Partial<Record<TableStyleRegion, TablePartStyleOptions>>;\n}\n\n/** The table-style gallery (p:tblStyleLst / w:tblStyles — default GUID plus custom styles). */\nexport interface TableStyleListOptions {\n /** Default style GUID */\n defaultStyleId: string;\n /** Custom table styles */\n styles?: readonly TableStyleOptions[];\n /**\n * Unmodeled trailing child elements (markup-compatibility blocks above\n * all), serialized verbatim — re-emitted as written after the styles.\n */\n ext?: string;\n}\n\n// ── Helpers ──\n\n/** Pass through a string value (all color/fill factories now return string). */\nfunction toStr(el: string): string {\n return el;\n}\n\n/** Create a:styleMatrixReference (fillRef, lnRef, effectRef, fontRef) */\nfunction createStyleMatrixRef(elementName: string, opts: StyleMatrixReferenceOptions): string {\n const children: string[] = [];\n if (opts.color) children.push(stringifyColorChoice(opts.color, EMPTY_WRITE_CTX));\n return element(\n `a:${elementName}`,\n { idx: String(opts.index) },\n children.length > 0 ? children : undefined,\n );\n}\n\n/** Create border line element (a:ln with color) or a:lnRef */\nfunction createThemeableLine(opts: ThemeableLineStyleOptions): string {\n if (opts.lineReference !== undefined) {\n const children: string[] = [];\n if (opts.color) children.push(toStr(opts.color));\n return element(\n \"a:lnRef\",\n { idx: String(opts.lineReference.index) },\n children.length > 0 ? children : undefined,\n );\n }\n const children: string[] = [];\n if (opts.color) children.push(toStr(opts.color));\n const attrs: Record<string, string> = {};\n if (opts.width !== undefined) attrs.w = String(opts.width);\n if (opts.compound) attrs.cmpd = xsdCompoundLine.to(opts.compound);\n return element(\"a:ln\", attrs, children.length > 0 ? children : undefined);\n}\n\n// ── Part builders ──\n\n/** Each cell-border side: Options key → a:tcBdr child element name. */\nconst BORDER_SIDES: ReadonlyArray<[keyof TableCellBorderOptions, string]> = [\n [\"left\", \"a:left\"],\n [\"right\", \"a:right\"],\n [\"top\", \"a:top\"],\n [\"bottom\", \"a:bottom\"],\n [\"insideH\", \"a:insideH\"],\n [\"insideV\", \"a:insideV\"],\n];\n\n/** CT_TableCellBorderStyle: each side wraps an EG_ThemeableLineStyle choice. */\nfunction buildCellBorders(opts: TableCellBorderOptions): string {\n const children: string[] = [];\n for (const [key, name] of BORDER_SIDES) {\n const line = opts[key];\n if (line) children.push(element(name, undefined, [createThemeableLine(line)]));\n }\n return element(\"a:tcBdr\", undefined, children);\n}\n\nfunction buildTextStyle(opts: TableTextStyleOptions): string {\n const children: string[] = [];\n if (opts.fontReference) {\n const color = opts.fontReference.color\n ? stringifyColorChoice(opts.fontReference.color, EMPTY_WRITE_CTX)\n : \"\";\n children.push(`<a:fontRef idx=\"${opts.fontReference.collection}\">${color}</a:fontRef>`);\n }\n if (opts.color) children.push(toStr(opts.color));\n const attrs: Record<string, string> = {};\n if (opts.bold && opts.bold !== \"default\") attrs.b = opts.bold;\n if (opts.italic && opts.italic !== \"default\") attrs.i = opts.italic;\n return element(\"a:tcTxStyle\", attrs, children.length > 0 ? children : undefined);\n}\n\nfunction buildCellStyle(opts: TableCellStyleOptions): string {\n const children: string[] = [];\n if (opts.borders) children.push(buildCellBorders(opts.borders));\n if (opts.fillReference) children.push(createStyleMatrixRef(\"fillRef\", opts.fillReference));\n else if (opts.fill) children.push(toStr(opts.fill));\n if (opts.cell3D) children.push(stringifyDesc(cell3DDesc, opts.cell3D, EMPTY_WRITE_CTX) ?? \"\");\n return element(\"a:tcStyle\", undefined, children);\n}\n\n/**\n * Build one region element. a:tblBg is CT_TableBackgroundStyle (themeable\n * fill/effect only); every other region is CT_TablePartStyle (tcTxStyle +\n * tcStyle only) — the two child sets never mix per XSD.\n */\nfunction buildPartStyle(\n elementName: string,\n opts: TablePartStyleOptions,\n isBackground: boolean,\n): string {\n const children: string[] = [];\n if (isBackground) {\n const background = opts.background;\n if (background) {\n if (background.fillReference)\n children.push(createStyleMatrixRef(\"fillRef\", background.fillReference));\n else if (background.fill) children.push(toStr(background.fill));\n if (background.effectReference)\n children.push(createStyleMatrixRef(\"effectRef\", background.effectReference));\n }\n } else {\n if (opts.text) children.push(buildTextStyle(opts.text));\n if (opts.cell) children.push(buildCellStyle(opts.cell));\n }\n return element(elementName, undefined, children);\n}\n\n// ── Public API ──\n\n/** XSD ordering for CT_TableStyle children */\nconst REGION_ORDER: readonly TableStyleRegion[] = [\n \"tblBg\",\n \"wholeTbl\",\n \"band1H\",\n \"band2H\",\n \"band1V\",\n \"band2V\",\n \"lastCol\",\n \"firstCol\",\n \"lastRow\",\n \"seCell\",\n \"swCell\",\n \"firstRow\",\n \"neCell\",\n \"nwCell\",\n];\n\n/** XML element name for each region */\nconst REGION_ELEMENTS: Record<TableStyleRegion, string> = {\n tblBg: \"a:tblBg\",\n wholeTbl: \"a:wholeTbl\",\n band1H: \"a:band1H\",\n band2H: \"a:band2H\",\n band1V: \"a:band1V\",\n band2V: \"a:band2V\",\n lastCol: \"a:lastCol\",\n firstCol: \"a:firstCol\",\n lastRow: \"a:lastRow\",\n seCell: \"a:seCell\",\n swCell: \"a:swCell\",\n firstRow: \"a:firstRow\",\n neCell: \"a:neCell\",\n nwCell: \"a:nwCell\",\n};\n\n/** Create a single table style (CT_TableStyle). `elementName` covers the part-list form (a:tblStyle) and the inline a:tblPr form (a:tableStyle). */\nexport function createTableStyle(opts: TableStyleOptions, elementName = \"a:tblStyle\"): string {\n const children: string[] = [];\n if (opts.regions) {\n for (const region of REGION_ORDER) {\n const part = opts.regions[region];\n if (!part) continue;\n children.push(buildPartStyle(REGION_ELEMENTS[region], part, region === \"tblBg\"));\n }\n }\n return element(\n elementName,\n { styleId: opts.styleId, styleName: opts.styleName },\n children.length > 0 ? children : undefined,\n );\n}\n\n/** Create table style list (CT_TableStyleList) */\nexport function createTableStyleList(opts: TableStyleListOptions): string {\n const children: string[] = [];\n if (opts.styles) {\n for (const style of opts.styles) {\n children.push(createTableStyle(style));\n }\n }\n if (opts.ext) children.push(opts.ext);\n return element(\n \"a:tblStyleLst\",\n {\n \"xmlns:a\": \"http://schemas.openxmlformats.org/drawingml/2006/main\",\n def: opts.defaultStyleId,\n },\n children.length > 0 ? children : undefined,\n );\n}\n\n// ── Parse (Element → TableStyleListOptions) ──\n\n/**\n * Serialize a single parsed element. `stringify` treats its argument as a\n * document root and serializes the `elements` array, so wrap the child to\n * serialize the child itself (round-trips raw color/fill child elements).\n */\nfunction serializeChild(child: Element): string {\n return stringify({ elements: [child] });\n}\n\n/** Reverse of REGION_ELEMENTS: XML element name → region key. */\nconst ELEMENT_TO_REGION = Object.fromEntries(\n Object.entries(REGION_ELEMENTS).map(([region, name]) => [name, region]),\n) as Record<string, TableStyleRegion>;\n\n/** Parse a:tblStyleLst → TableStyleListOptions (reverse of createTableStyleList). */\nexport function parseTableStyleList(el: Element): TableStyleListOptions {\n const defaultStyleId = attr(el, \"def\") ?? \"\";\n const styles: TableStyleOptions[] = [];\n const extParts: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"a:tblStyle\") {\n // Markup-compatibility blocks and other unmodeled children stay\n // verbatim — re-serialized as written after the parsed styles.\n extParts.push(serializeChild(child));\n continue;\n }\n const style = parseTableStyle(child);\n if (style) styles.push(style);\n }\n return {\n defaultStyleId,\n ...(styles.length > 0 ? { styles } : {}),\n ...(extParts.length > 0 ? { ext: extParts.join(\"\") } : {}),\n };\n}\n\nexport function parseTableStyle(el: Element): TableStyleOptions | undefined {\n const styleId = attr(el, \"styleId\");\n const styleName = attr(el, \"styleName\");\n if (styleId === undefined || styleName === undefined) return undefined;\n const regions: Partial<Record<TableStyleRegion, TablePartStyleOptions>> = {};\n for (const child of el.elements ?? []) {\n if (!child.name) continue;\n const region = ELEMENT_TO_REGION[child.name];\n if (!region) continue;\n const part = region === \"tblBg\" ? parseTableBackgroundStyle(child) : parsePartStyle(child);\n if (part) regions[region] = part;\n }\n return { styleId, styleName, ...(Object.keys(regions).length > 0 ? { regions } : {}) };\n}\n\n/** Parse a:tblBg (CT_TableBackgroundStyle: fill → effect, no tc* wrappers). */\nfunction parseTableBackgroundStyle(el: Element): TablePartStyleOptions | undefined {\n const background: TableBackgroundStyleOptions = {};\n const fillRefEl = findChild(el, \"a:fillRef\");\n if (fillRefEl) {\n background.fillReference = parseStyleMatrixRef(fillRefEl);\n } else {\n const explicitFill = (el.elements ?? []).find((c) => c.name !== \"a:effectRef\");\n if (explicitFill) background.fill = serializeChild(explicitFill);\n }\n const effectRefEl = findChild(el, \"a:effectRef\");\n if (effectRefEl) background.effectReference = parseStyleMatrixRef(effectRefEl);\n return Object.keys(background).length > 0 ? { background } : undefined;\n}\n\nfunction parsePartStyle(el: Element): TablePartStyleOptions | undefined {\n const part: TablePartStyleOptions = {};\n const txStyle = findChild(el, \"a:tcTxStyle\");\n if (txStyle) {\n const text = parseTableTextStyle(txStyle);\n if (text) part.text = text;\n }\n const cellStyle = findChild(el, \"a:tcStyle\");\n if (cellStyle) {\n const cell = parseTableCellStyle(cellStyle);\n if (cell) part.cell = cell;\n }\n return Object.keys(part).length > 0 ? part : undefined;\n}\n\nfunction parseTableTextStyle(el: Element): TableTextStyleOptions | undefined {\n const opts: TableTextStyleOptions = {};\n const b = attr(el, \"b\");\n if (b === \"on\" || b === \"off\") opts.bold = b;\n const i = attr(el, \"i\");\n if (i === \"on\" || i === \"off\") opts.italic = i;\n const fontRefEl = findChild(el, \"a:fontRef\");\n if (fontRefEl) {\n const idx = attr(fontRefEl, \"idx\");\n if (idx === \"major\" || idx === \"minor\" || idx === \"none\") {\n const color = parseColorChoice(fontRefEl, EMPTY_READ_CTX);\n opts.fontReference =\n color && Object.keys(color).length > 0 ? { collection: idx, color } : { collection: idx };\n }\n }\n // color: first non-fontRef child element, serialized back to the raw string\n // buildTextStyle stores (it pushes opts.color verbatim).\n for (const child of el.elements ?? []) {\n if (child.name === \"a:fontRef\") continue;\n opts.color = serializeChild(child);\n break;\n }\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseTableCellStyle(el: Element): TableCellStyleOptions | undefined {\n const opts: TableCellStyleOptions = {};\n const tcBdr = findChild(el, \"a:tcBdr\");\n if (tcBdr) {\n const borders = parseCellBorders(tcBdr);\n if (borders) opts.borders = borders;\n }\n const fillRefEl = findChild(el, \"a:fillRef\");\n if (fillRefEl) {\n opts.fillReference = parseStyleMatrixRef(fillRefEl);\n } else {\n // fill: first non-tcBdr/non-cell3D child element, serialized\n // (buildCellStyle pushes opts.fill verbatim).\n for (const child of el.elements ?? []) {\n if (child.name === \"a:tcBdr\" || child.name === \"a:cell3D\") continue;\n opts.fill = serializeChild(child);\n break;\n }\n }\n const cell3DEl = findChild(el, \"a:cell3D\");\n if (cell3DEl) opts.cell3D = parseDesc(cell3DDesc, cell3DEl, EMPTY_READ_CTX);\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseCellBorders(el: Element): TableCellBorderOptions | undefined {\n const borders: TableCellBorderOptions = {};\n for (const [key, name] of BORDER_SIDES) {\n const borderEl = findChild(el, name);\n if (!borderEl) continue;\n // Each side wraps an EG_ThemeableLineStyle choice (a:ln or a:lnRef).\n const lineEl = borderEl.elements?.find((c) => c.type === \"element\");\n if (!lineEl) continue;\n const line = parseThemeableLine(lineEl);\n if (line) borders[key] = line;\n }\n // An empty a:tcBdr is meaningful — it overrides the outer-region borders\n // with none — so presence round-trips as an empty borders object.\n return borders;\n}\n\nfunction parseThemeableLine(el: Element): ThemeableLineStyleOptions | undefined {\n const opts: ThemeableLineStyleOptions = {};\n if (el.name === \"a:lnRef\") {\n const idx = attrNum(el, \"idx\");\n if (idx !== undefined) opts.lineReference = { index: idx };\n } else {\n const w = attrNum(el, \"w\");\n if (w !== undefined) opts.width = w;\n const cmpd = attr(el, \"cmpd\");\n if (cmpd) opts.compound = xsdCompoundLine.from(cmpd) as CompoundLineType;\n }\n for (const child of el.elements ?? []) {\n opts.color = serializeChild(child);\n break;\n }\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseStyleMatrixRef(el: Element): StyleMatrixReferenceOptions {\n const idx = attrNum(el, \"idx\") ?? 0;\n const color = parseColorChoice(el, EMPTY_READ_CTX);\n const opts: StyleMatrixReferenceOptions =\n color && Object.keys(color).length > 0 ? { index: idx, color } : { index: idx };\n return opts;\n}\n","/**\n * DrawingML shape locking properties.\n *\n * Controls which aspects of a shape can be modified by users.\n *\n * Reference: OOXML transitional, dml-main.xsd, AG_Locking / CT_ShapeLocking / CT_PictureLocking / CT_GroupLocking\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n// ── Common locking attributes (AG_Locking) ──\n\nexport interface BaseLockingOptions {\n /** Prevent grouping */\n noGrp?: boolean;\n /** Prevent selection */\n noSelect?: boolean;\n /** Prevent rotation */\n noRot?: boolean;\n /** Prevent aspect ratio change */\n noChangeAspect?: boolean;\n /** Prevent moving */\n noMove?: boolean;\n /** Prevent resizing */\n noResize?: boolean;\n /** Prevent edit points */\n noEditPoints?: boolean;\n /** Prevent adjust handles */\n noAdjustHandles?: boolean;\n /** Prevent changing arrowheads */\n noChangeArrowheads?: boolean;\n /** Prevent changing shape type */\n noChangeShapeType?: boolean;\n}\n\n// ── Shape locking (CT_ShapeLocking) ──\n\nexport interface ShapeLockingOptions extends BaseLockingOptions {\n /** Prevent text editing */\n noTextEdit?: boolean;\n}\n\n// ── Picture locking (CT_PictureLocking) ──\n\nexport interface PictureLockingOptions extends BaseLockingOptions {\n /** Prevent cropping */\n noCrop?: boolean;\n}\n\n// ── Group locking (CT_GroupLocking) ──\n\nexport interface GroupLockingOptions {\n noGrp?: boolean;\n noUngrp?: boolean;\n noSelect?: boolean;\n noRot?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\n// ── Graphic frame locking (CT_GraphicalObjectFrameLocking) ──\n\nexport interface GraphicFrameLockingOptions {\n noGrp?: boolean;\n noDrilldown?: boolean;\n noSelect?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\n// ── Connector locking (CT_ConnectorLocking = AG_Locking, no extras) ──\n\nexport type ConnectorLockingOptions = BaseLockingOptions;\n\n// ── Content part locking (CT_ContentPartLocking = AG_Locking, no extras) ──\n\nexport type ContentPartLockingOptions = BaseLockingOptions;\n\n// ── Factory functions ──\n\nfunction toFlatAttrs(opts: Readonly<Record<string, boolean | undefined>>): Record<string, boolean> {\n const result: Record<string, boolean> = {};\n for (const key of Object.keys(opts)) {\n if (opts[key] !== undefined) {\n result[key] = opts[key]!;\n }\n }\n return result;\n}\n\nexport function createShapeLocking(opts: ShapeLockingOptions): string {\n return element(\"a:spLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n\nexport function createPictureLocking(opts: PictureLockingOptions): string {\n return element(\"a:picLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n\nexport function createGroupLocking(opts: GroupLockingOptions): string {\n return element(\"a:grpSpLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n\nexport function createGraphicFrameLocking(opts: GraphicFrameLockingOptions): string {\n return element(\"a:graphicFrameLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n\nexport function createConnectorLocking(opts: ConnectorLockingOptions): string {\n return element(\"a:cxnSpLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n\nexport function createContentPartLocking(opts: ContentPartLockingOptions): string {\n return element(\"a:cpLocks\", toFlatAttrs(opts as Record<string, boolean | undefined>));\n}\n","/**\n * Connector endpoint connection (a:stCxn / a:endCxn / CT_Connection).\n *\n * Glues a connector endpoint to a specific connection site on a target shape,\n * so the endpoint follows the shape when it moves. Used inside cNvCxnSpPr.\n *\n * @module\n */\n\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\n/** a:stCxn / a:endCxn — a connector endpoint glued to a shape connection site. */\nexport interface EndpointConnectionOptions {\n /** Target shape cNvPr id (ST_DrawingElementId). */\n id: number;\n /** Connection site index on the target shape. */\n index: number;\n}\n\n/** Stringify an a:stCxn or a:endCxn element. */\nexport function stringifyEndpointConnection(\n tag: \"stCxn\" | \"endCxn\",\n conn: EndpointConnectionOptions,\n): string {\n return `<a:${tag} id=\"${conn.id}\" idx=\"${conn.index}\"/>`;\n}\n\n/** Parse an a:stCxn or a:endCxn element. */\nexport function parseEndpointConnection(el: XmlElement): EndpointConnectionOptions | undefined {\n const id = el.attributes?.[\"id\"];\n const idx = el.attributes?.[\"idx\"];\n if (id === undefined || idx === undefined) return undefined;\n return { id: Number(id), index: Number(idx) };\n}\n","/**\n * Non-visual drawing properties (a:CT_NonVisualDrawingProps).\n *\n * The shared XSD type behind every drawing object's cNvPr (pic:/p:/xdr:/a:) and\n * docx's wp:docPr — picture, shape, connector, group, graphicFrame, chart, ole,\n * smartart each carry one. This module is the single source of truth for its\n * four user-facing attributes (name/descr/title/hidden). The runtime id is\n * allocated by each descriptor's nextId counter, and hlinkClick/hlinkHover stay\n * package-side (relationship wiring differs per format).\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { attr, findChild, stringifyElement } from \"@office-open/xml\";\n\nimport { extUriMatches } from \"../../util/ext-uri\";\nimport { parseOnOff } from \"../../util/values\";\nimport type { Guid } from \"../../util/values\";\n\n/** The a16:creationId extension uri (CT_NonVisualDrawingProps extLst). */\nconst CREATION_ID_EXT_URI = \"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}\";\n\n/** Mirrors a:CT_NonVisualDrawingProps — name/descr/title/hidden. id is runtime; hyperlinks stay package-side. */\nexport interface NonVisualDrawingPropertiesOptions {\n /** XSD `@name` (required in XML); API-optional, the descriptor synthesizes a fallback. */\n name?: string;\n /** XSD `@descr` — alt text for accessibility; emitted only when present. */\n description?: string;\n /** XSD `@title`. */\n title?: string;\n /** XSD `@hidden` (default false); emitted as \"1\" only when true. */\n hidden?: boolean;\n /**\n * a16:creationId `@id` from the cNvPr/docPr extension list — Office's\n * per-object creation stamp, the sole known cNvPr ext content.\n */\n creationId?: Guid;\n /**\n * Verbatim `a:extLst` inner XML for extensions beyond creationId (a14\n * picture effects, useLocalDpi, …). Round-trip only: takes precedence over\n * `creationId`, which it subsumes when the source list carries both.\n */\n ext?: string;\n}\n\n/**\n * Stringify a cNvPr/docPr opening tag (a:CT_NonVisualDrawingProps attributes).\n *\n * `tag` is the fully-qualified element name (\"p:cNvPr\", \"pic:cNvPr\", \"wp:docPr\",\n * …) since the same XSD type is serialized under several element names across\n * the format packages. `innerXml` carries caller-built hlinkClick/hlinkHover.\n */\nexport function stringifyNonVisualDrawingProperties(\n tag: string,\n id: number | string,\n opts: NonVisualDrawingPropertiesOptions | undefined,\n fallbackName: string,\n innerXml?: string,\n): string {\n const name = opts?.name ?? fallbackName;\n let attrs = `id=\"${id}\" name=\"${escapeXml(name)}\"`;\n if (opts?.description) attrs += ` descr=\"${escapeXml(opts.description)}\"`;\n if (opts?.title) attrs += ` title=\"${escapeXml(opts.title)}\"`;\n if (opts?.hidden) attrs += ` hidden=\"1\"`;\n // CT_NonVisualDrawingProps tail: hlinkClick/hover (caller innerXml) → extLst.\n // xmlns:a is declared locally: parts that host docPr without a DrawingML\n // root (comments.xml, notes) never declare the a: prefix themselves.\n const A_NS = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\n const extLst = opts?.ext\n ? `<a:extLst ${A_NS}>${opts.ext}</a:extLst>`\n : opts?.creationId\n ? `<a:extLst ${A_NS}><a:ext uri=\"${CREATION_ID_EXT_URI}\"><a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"${escapeXml(opts.creationId)}\"/></a:ext></a:extLst>`\n : \"\";\n const content = (innerXml ?? \"\") + extLst;\n return content ? `<${tag} ${attrs}>${content}</${tag}>` : `<${tag} ${attrs}/>`;\n}\n\n/**\n * Parse cNvPr/docPr attributes into NonVisualDrawingPropertiesOptions.\n * Empty descr/title are dropped (Word never round-trips them empty).\n */\nexport function parseNonVisualDrawingProperties(\n el: XmlElement | undefined,\n): Partial<NonVisualDrawingPropertiesOptions> {\n if (!el) return {};\n const result: Partial<NonVisualDrawingPropertiesOptions> = {};\n if (el.attributes) {\n const a = el.attributes;\n if (a[\"name\"] !== undefined) result.name = String(a[\"name\"]);\n const descr = a[\"descr\"];\n if (descr !== undefined && descr !== \"\") result.description = String(descr);\n const title = a[\"title\"];\n if (title !== undefined && title !== \"\") result.title = String(title);\n const hidden = a[\"hidden\"];\n if (hidden !== undefined) result.hidden = parseOnOff(hidden) ?? false;\n }\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) {\n // Extensions beyond creationId (a14 picture effects, useLocalDpi, …) have\n // no structured model — keep the whole list verbatim and skip the\n // creationId extraction so the two channels never double-emit.\n const hasUnmodeled = (extLst.elements ?? []).some(\n (ext) => ext.name === \"a:ext\" && !extUriMatches(attr(ext, \"uri\"), CREATION_ID_EXT_URI),\n );\n if (hasUnmodeled) {\n const inner = (extLst.elements ?? []).map((e) => stringifyElement(e)).join(\"\");\n if (inner) result.ext = inner;\n } else {\n for (const ext of extLst.elements ?? []) {\n if (ext.name !== \"a:ext\" || !extUriMatches(attr(ext, \"uri\"), CREATION_ID_EXT_URI)) continue;\n const creationId = findChild(ext, \"a16:creationId\");\n // a16:creationId keys its GUID on @id (p14:creationId uses @val).\n const id = creationId ? attr(creationId, \"id\") : undefined;\n if (id) result.creationId = id;\n }\n }\n }\n return result;\n}\n\n/**\n * Pick the cNvPr attributes (name/description/title/hidden) actually set on\n * `opts`, dropping undefined. Used when bridging a package's options onto a\n * descriptor that carries the same fields — spreads only what was authored so\n * the descriptor's fallbacks (e.g. synthesized name) still apply for the rest.\n */\nexport function pickNonVisualDrawingProperties(\n opts: NonVisualDrawingPropertiesOptions | undefined,\n): Partial<NonVisualDrawingPropertiesOptions> {\n if (!opts) return {};\n const picked: Partial<NonVisualDrawingPropertiesOptions> = {};\n if (opts.name !== undefined) picked.name = opts.name;\n if (opts.description !== undefined) picked.description = opts.description;\n if (opts.title !== undefined) picked.title = opts.title;\n if (opts.hidden !== undefined) picked.hidden = opts.hidden;\n if (opts.creationId !== undefined) picked.creationId = opts.creationId;\n if (opts.ext !== undefined) picked.ext = opts.ext;\n return picked;\n}\n","/**\n * Non-visual content part properties (a:CT_NonVisualContentPartProperties).\n *\n * Carries the cpLocks locking set and the isComment flag for wp:contentPart\n * wrappers (CT_WordprocessingContentPart). The cNvContentPartPr element itself\n * is host-namespaced (wp:/wpg:/wpc:), so the tag is caller-supplied.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_NonVisualContentPartProperties\n *\n * @module\n */\n\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild } from \"@office-open/xml\";\n\nimport { parseOnOff } from \"../../util/values\";\nimport { createContentPartLocking } from \"../locking/locking\";\nimport type { ContentPartLockingOptions } from \"../locking/locking\";\n\nexport interface NonVisualContentPartPropertiesOptions {\n /** Locking flags (a:cpLocks — CT_ContentPartLocking) */\n locks?: ContentPartLockingOptions;\n /**\n * Whether the content part hosts a comment (`@isComment`, default true).\n * Only `false` deviates from the default and is emitted explicitly.\n */\n isComment?: boolean;\n}\n\n/** Locking attribute keys shared by stringify/parse. */\nconst LOCKING_KEYS: readonly (keyof ContentPartLockingOptions & string)[] = [\n \"noGrp\",\n \"noSelect\",\n \"noRot\",\n \"noChangeAspect\",\n \"noMove\",\n \"noResize\",\n \"noEditPoints\",\n \"noAdjustHandles\",\n \"noChangeArrowheads\",\n \"noChangeShapeType\",\n];\n\n/**\n * Stringify a cNvContentPartPr element (CT_NonVisualContentPartProperties).\n * The `isComment` default is true, so only `false` is written.\n */\nexport function stringifyNonVisualContentPartProperties(\n tag: string,\n opts: NonVisualContentPartPropertiesOptions | undefined,\n): string {\n if (!opts) return `<${tag}/>`;\n let inner = \"\";\n if (opts.locks) inner += createContentPartLocking(opts.locks);\n const attr = opts.isComment === false ? ' isComment=\"0\"' : \"\";\n return inner ? `<${tag}${attr}>${inner}</${tag}>` : `<${tag}${attr}/>`;\n}\n\n/** Parse a cNvContentPartPr element into its options form. */\nexport function parseNonVisualContentPartProperties(\n el: XmlElement | undefined,\n): NonVisualContentPartPropertiesOptions | undefined {\n if (!el) return undefined;\n const result: NonVisualContentPartPropertiesOptions = {};\n const locks = findChild(el, \"a:cpLocks\");\n if (locks) {\n const flags: Record<string, boolean> = {};\n for (const key of LOCKING_KEYS) {\n const raw = locks.attributes?.[key];\n if (raw !== undefined) flags[key] = parseOnOff(raw) ?? false;\n }\n if (Object.keys(flags).length > 0) result.locks = flags as ContentPartLockingOptions;\n }\n const isComment = el.attributes?.[\"isComment\"];\n if (isComment !== undefined) result.isComment = parseOnOff(isComment) ?? true;\n return Object.keys(result).length > 0 ? result : undefined;\n}\n","/**\n * Diagram layout variable property set elements.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd\n * CT_LayoutVariablePropertySet and its child elements.\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport { xsdAnimLevel, xsdHierBranch } from \"../../util/mappings\";\n\n// ---------------------------------------------------------------------------\n// dgm:adj — adjustment handle (CT_Adj)\n// ---------------------------------------------------------------------------\n\nexport interface AdjustOptions {\n /** 1-based index (required) */\n idx: number;\n /** Adjustment value (required) */\n val: number;\n}\n\n/** Creates a dgm:adj element. */\nexport const createAdjust = (options: AdjustOptions): string =>\n `<dgm:adj idx=\"${options.idx}\" val=\"${options.val}\"/>`;\n\n// ---------------------------------------------------------------------------\n// dgm:animLvl — animation level (CT_AnimLvl)\n// ---------------------------------------------------------------------------\n\n/** Diagram animation granularity (ST_AnimLvl). */\nexport type AnimationLevel = \"none\" | \"level\" | \"center\";\n\nexport interface AnimationLevelOptions {\n val?: AnimationLevel;\n}\n\n/** Creates a dgm:animLvl element. */\nexport const createAnimationLevel = (options?: AnimationLevelOptions): string =>\n options?.val !== undefined\n ? `<dgm:animLvl val=\"${xsdAnimLevel.to(options.val)}\"/>`\n : \"<dgm:animLvl/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:animOne — animation one-by-one (CT_AnimOne)\n// ---------------------------------------------------------------------------\n\n/** One-by-one animation scope (ST_AnimOne): \"one\" item by item, \"branch\" branch by branch, \"none\". */\nexport type AnimateOneByOne = \"none\" | \"one\" | \"branch\";\n\nexport interface AnimateOneByOneOptions {\n val?: AnimateOneByOne;\n}\n\n/** Creates a dgm:animOne element. */\nexport const createAnimateOneByOne = (options?: AnimateOneByOneOptions): string =>\n options?.val !== undefined ? `<dgm:animOne val=\"${options.val}\"/>` : \"<dgm:animOne/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:chMax — max children constraint (CT_ChildMax)\n// ---------------------------------------------------------------------------\n\nexport interface MaxChildrenOptions {\n val?: number;\n}\n\n/** Creates a dgm:chMax element. */\nexport const createMaxChildren = (options?: MaxChildrenOptions): string =>\n options?.val !== undefined ? `<dgm:chMax val=\"${options.val}\"/>` : \"<dgm:chMax/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:chPref — preferred children count (CT_ChildPref)\n// ---------------------------------------------------------------------------\n\nexport interface PreferredChildrenOptions {\n val?: number;\n}\n\n/** Creates a dgm:chPref element. */\nexport const createPreferredChildren = (options?: PreferredChildrenOptions): string =>\n options?.val !== undefined ? `<dgm:chPref val=\"${options.val}\"/>` : \"<dgm:chPref/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:orgChart — organization chart flag (CT_OrgChart)\n// ---------------------------------------------------------------------------\n\nexport interface OrgChartOptions {\n val?: boolean;\n}\n\n/** Creates a dgm:orgChart element. */\nexport const createOrgChart = (options?: OrgChartOptions): string =>\n options?.val !== undefined ? `<dgm:orgChart val=\"${options.val}\"/>` : \"<dgm:orgChart/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:hierBranch — hierarchy branch style (CT_HierBranchStyle)\n// ---------------------------------------------------------------------------\n\n/** Hierarchy branch style (ST_HierBranchStyle). */\nexport type HierBranch = \"left\" | \"right\" | \"hanging\" | \"standard\" | \"initial\";\n\nexport interface HierBranchOptions {\n val?: HierBranch;\n}\n\n/** Creates a dgm:hierBranch element. */\nexport const createHierBranch = (options?: HierBranchOptions): string =>\n options?.val !== undefined\n ? `<dgm:hierBranch val=\"${xsdHierBranch.to(options.val)}\"/>`\n : \"<dgm:hierBranch/>\";\n\n// ---------------------------------------------------------------------------\n// dgm:presLayoutVars — presentation layout variables (CT_LayoutVariablePropertySet)\n// ---------------------------------------------------------------------------\n\nexport interface PresentationLayoutVariablesOptions {\n orgChart?: OrgChartOptions;\n maxChildren?: MaxChildrenOptions;\n preferredChildren?: PreferredChildrenOptions;\n animateOneByOne?: AnimateOneByOneOptions;\n animationLevel?: AnimationLevelOptions;\n hierBranch?: HierBranchOptions;\n}\n\n/**\n * Creates a dgm:presLayoutVars element (CT_LayoutVariablePropertySet).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_LayoutVariablePropertySet\">\n * <xsd:sequence>\n * <xsd:element name=\"orgChart\" type=\"CT_OrgChart\" minOccurs=\"0\"/>\n * <xsd:element name=\"chMax\" type=\"CT_ChildMax\" minOccurs=\"0\"/>\n * <xsd:element name=\"chPref\" type=\"CT_ChildPref\" minOccurs=\"0\"/>\n * <xsd:element name=\"bulletEnabled\" type=\"CT_BulletEnabled\" minOccurs=\"0\"/>\n * <xsd:element name=\"dir\" type=\"CT_Direction\" minOccurs=\"0\"/>\n * <xsd:element name=\"hierBranch\" type=\"CT_HierBranchStyle\" minOccurs=\"0\"/>\n * <xsd:element name=\"animOne\" type=\"CT_AnimOne\" minOccurs=\"0\"/>\n * <xsd:element name=\"animLvl\" type=\"CT_AnimLvl\" minOccurs=\"0\"/>\n * <xsd:element name=\"resizeHandles\" type=\"CT_ResizeHandles\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n */\nexport const createPresentationLayoutVariables = (\n options?: PresentationLayoutVariablesOptions,\n): string => {\n const children: string[] = [];\n if (options?.orgChart) children.push(createOrgChart(options.orgChart));\n if (options?.maxChildren) children.push(createMaxChildren(options.maxChildren));\n if (options?.preferredChildren) children.push(createPreferredChildren(options.preferredChildren));\n if (options?.animateOneByOne) children.push(createAnimateOneByOne(options.animateOneByOne));\n if (options?.animationLevel) children.push(createAnimationLevel(options.animationLevel));\n if (options?.hierBranch) children.push(createHierBranch(options.hierBranch));\n\n return element(\"dgm:presLayoutVars\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:adjLst — adjustment list (CT_AdjLst)\n// ---------------------------------------------------------------------------\n\nexport interface AdjustListOptions {\n adjustments?: readonly AdjustOptions[];\n}\n\n/** Creates a dgm:adjLst element containing dgm:adj children. */\nexport const createAdjustList = (options?: AdjustListOptions): string => {\n const children: string[] = [];\n if (options?.adjustments) {\n for (const a of options.adjustments) {\n children.push(createAdjust(a));\n }\n }\n return element(\"dgm:adjLst\", undefined, children);\n};\n","/**\n * Diagram definition header elements.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd\n * CT_ColorTransformHeader, CT_DiagramDefinitionHeader, CT_StyleDefinitionHeader\n * and their list containers.\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\n// ---------------------------------------------------------------------------\n// Shared name/description/category types\n// ---------------------------------------------------------------------------\n\nexport interface DiagramNameOptions {\n lang?: string;\n val: string;\n}\n\nexport interface DiagramDescriptionOptions {\n lang?: string;\n val: string;\n}\n\nexport interface DiagramCategoryOptions {\n type: string;\n pri: number;\n}\n\nconst createNameEl = (tag: string, options: DiagramNameOptions): string => {\n const attrs: Record<string, string> = { val: options.val };\n if (options.lang) attrs.lang = options.lang;\n return element(tag, attrs);\n};\n\nconst createDescEl = (tag: string, options: DiagramDescriptionOptions): string => {\n const attrs: Record<string, string> = { val: options.val };\n if (options.lang) attrs.lang = options.lang;\n return element(tag, attrs);\n};\n\nconst createCatEl = (options: DiagramCategoryOptions): string =>\n `<dgm:cat type=\"${options.type}\" pri=\"${options.pri}\"/>`;\n\nconst createCatLst = (categories?: readonly DiagramCategoryOptions[]): string => {\n const children: string[] = [];\n if (categories) {\n for (const cat of categories) {\n children.push(createCatEl(cat));\n }\n }\n return element(\"dgm:catLst\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:colorsDefHdr — color definition header (CT_ColorTransformHeader)\n// ---------------------------------------------------------------------------\n\nexport interface ColorsDefinitionHeaderOptions {\n uniqueId: string;\n minVer?: string;\n resId?: number;\n title: readonly DiagramNameOptions[];\n desc: readonly DiagramDescriptionOptions[];\n categories?: readonly DiagramCategoryOptions[];\n}\n\n/**\n * Creates a dgm:colorsDefHdr element (CT_ColorTransformHeader).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_ColorTransformHeader\">\n * <xsd:sequence>\n * <xsd:element name=\"title\" type=\"CT_CTName\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"desc\" type=\"CT_CTDescription\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"catLst\" type=\"CT_CTCategories\" minOccurs=\"0\"/>\n * <xsd:element name=\"extLst\" type=\"a:CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"uniqueId\" type=\"xsd:string\" use=\"required\"/>\n * <xsd:attribute name=\"minVer\" type=\"xsd:string\" use=\"optional\"/>\n * <xsd:attribute name=\"resId\" type=\"xsd:int\" use=\"optional\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createColorsDefinitionHeader = (options: ColorsDefinitionHeaderOptions): string => {\n const children: string[] = [];\n for (const t of options.title) children.push(createNameEl(\"dgm:title\", t));\n for (const d of options.desc) children.push(createDescEl(\"dgm:desc\", d));\n if (options.categories?.length) children.push(createCatLst(options.categories));\n\n const attrs: Record<string, string | number> = { uniqueId: options.uniqueId };\n if (options.minVer !== undefined) attrs.minVer = options.minVer;\n if (options.resId !== undefined) attrs.resId = options.resId;\n\n return element(\"dgm:colorsDefHdr\", attrs, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:colorsDefHdrLst — list of color definition headers (CT_ColorTransformHeaderLst)\n// ---------------------------------------------------------------------------\n\nexport interface ColorsDefinitionHeaderListOptions {\n headers?: readonly ColorsDefinitionHeaderOptions[];\n}\n\n/** Creates a dgm:colorsDefHdrLst element. */\nexport const createColorsDefinitionHeaderList = (\n options?: ColorsDefinitionHeaderListOptions,\n): string => {\n const children: string[] = [];\n if (options?.headers) {\n for (const hdr of options.headers) {\n children.push(createColorsDefinitionHeader(hdr));\n }\n }\n return element(\"dgm:colorsDefHdrLst\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:layoutDefHdr — layout definition header (CT_DiagramDefinitionHeader)\n// ---------------------------------------------------------------------------\n\nexport interface LayoutDefinitionHeaderOptions {\n uniqueId: string;\n minVer?: string;\n defStyle?: string;\n resId?: number;\n title: readonly DiagramNameOptions[];\n desc: readonly DiagramDescriptionOptions[];\n categories?: readonly DiagramCategoryOptions[];\n}\n\n/**\n * Creates a dgm:layoutDefHdr element (CT_DiagramDefinitionHeader).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_DiagramDefinitionHeader\">\n * <xsd:sequence>\n * <xsd:element name=\"title\" type=\"CT_Name\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"desc\" type=\"CT_Description\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"catLst\" type=\"CT_Categories\" minOccurs=\"0\"/>\n * <xsd:element name=\"extLst\" type=\"a:CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"uniqueId\" type=\"xsd:string\" use=\"required\"/>\n * <xsd:attribute name=\"minVer\" type=\"xsd:string\" use=\"optional\"/>\n * <xsd:attribute name=\"defStyle\" type=\"xsd:string\" use=\"optional\" default=\"\"/>\n * <xsd:attribute name=\"resId\" type=\"xsd:int\" use=\"optional\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createLayoutDefinitionHeader = (options: LayoutDefinitionHeaderOptions): string => {\n const children: string[] = [];\n for (const t of options.title) children.push(createNameEl(\"dgm:title\", t));\n for (const d of options.desc) children.push(createDescEl(\"dgm:desc\", d));\n if (options.categories?.length) children.push(createCatLst(options.categories));\n\n const attrs: Record<string, string | number> = { uniqueId: options.uniqueId };\n if (options.minVer !== undefined) attrs.minVer = options.minVer;\n if (options.defStyle !== undefined) attrs.defStyle = options.defStyle;\n if (options.resId !== undefined) attrs.resId = options.resId;\n\n return element(\"dgm:layoutDefHdr\", attrs, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:layoutDefHdrLst — list of layout definition headers (CT_DiagramDefinitionHeaderLst)\n// ---------------------------------------------------------------------------\n\nexport interface LayoutDefinitionHeaderListOptions {\n headers?: readonly LayoutDefinitionHeaderOptions[];\n}\n\n/** Creates a dgm:layoutDefHdrLst element. */\nexport const createLayoutDefinitionHeaderList = (\n options?: LayoutDefinitionHeaderListOptions,\n): string => {\n const children: string[] = [];\n if (options?.headers) {\n for (const hdr of options.headers) {\n children.push(createLayoutDefinitionHeader(hdr));\n }\n }\n return element(\"dgm:layoutDefHdrLst\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:styleDefHdr — style definition header (CT_StyleDefinitionHeader)\n// ---------------------------------------------------------------------------\n\nexport interface StyleDefinitionHeaderOptions {\n uniqueId: string;\n minVer?: string;\n resId?: number;\n title: readonly DiagramNameOptions[];\n desc: readonly DiagramDescriptionOptions[];\n categories?: readonly DiagramCategoryOptions[];\n}\n\n/**\n * Creates a dgm:styleDefHdr element (CT_StyleDefinitionHeader).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_StyleDefinitionHeader\">\n * <xsd:sequence>\n * <xsd:element name=\"title\" type=\"CT_SDName\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"desc\" type=\"CT_SDDescription\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>\n * <xsd:element name=\"catLst\" type=\"CT_SDCategories\" minOccurs=\"0\"/>\n * <xsd:element name=\"extLst\" type=\"a:CT_OfficeArtExtensionList\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"uniqueId\" type=\"xsd:string\" use=\"required\"/>\n * <xsd:attribute name=\"minVer\" type=\"xsd:string\" use=\"optional\"/>\n * <xsd:attribute name=\"resId\" type=\"xsd:int\" use=\"optional\" default=\"0\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createStyleDefinitionHeader = (options: StyleDefinitionHeaderOptions): string => {\n const children: string[] = [];\n for (const t of options.title) children.push(createNameEl(\"dgm:title\", t));\n for (const d of options.desc) children.push(createDescEl(\"dgm:desc\", d));\n if (options.categories?.length) children.push(createCatLst(options.categories));\n\n const attrs: Record<string, string | number> = { uniqueId: options.uniqueId };\n if (options.minVer !== undefined) attrs.minVer = options.minVer;\n if (options.resId !== undefined) attrs.resId = options.resId;\n\n return element(\"dgm:styleDefHdr\", attrs, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:styleDefHdrLst — list of style definition headers (CT_StyleDefinitionHeaderLst)\n// ---------------------------------------------------------------------------\n\nexport interface StyleDefinitionHeaderListOptions {\n headers?: readonly StyleDefinitionHeaderOptions[];\n}\n\n/** Creates a dgm:styleDefHdrLst element. */\nexport const createStyleDefinitionHeaderList = (\n options?: StyleDefinitionHeaderListOptions,\n): string => {\n const children: string[] = [];\n if (options?.headers) {\n for (const hdr of options.headers) {\n children.push(createStyleDefinitionHeader(hdr));\n }\n }\n return element(\"dgm:styleDefHdrLst\", undefined, children);\n};\n","/**\n * Diagram relationship IDs element.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd, CT_RelIds\n *\n * @module\n */\n\n// ---------------------------------------------------------------------------\n// dgm:relIds — relationship IDs (CT_RelIds)\n// ---------------------------------------------------------------------------\n\nexport interface DiagramRelationshipIdsOptions {\n /** Relationship to data model part (`@r:dm`) */\n dataModel: string;\n /** Relationship to layout definition part (`@r:lo`) */\n layout: string;\n /** Relationship to quick style part (`@r:qs`) */\n quickStyle: string;\n /** Relationship to color transform part (`@r:cs`) */\n colorStyle: string;\n}\n\n/**\n * Creates a dgm:relIds element (CT_RelIds).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_RelIds\">\n * <xsd:attribute ref=\"r:dm\" use=\"required\"/>\n * <xsd:attribute ref=\"r:lo\" use=\"required\"/>\n * <xsd:attribute ref=\"r:qs\" use=\"required\"/>\n * <xsd:attribute ref=\"r:cs\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createDiagramRelationshipIds = (options: DiagramRelationshipIdsOptions): string =>\n `<dgm:relIds r:dm=\"${options.dataModel}\" r:lo=\"${options.layout}\" r:qs=\"${options.quickStyle}\" r:cs=\"${options.colorStyle}\"/>`;\n","/**\n * Diagram extension list, 3D shape, and text properties.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd, dml-main.xsd\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { Shape3DOptions } from \"../three-d/shape-3d\";\nimport { createShape3D } from \"../three-d/shape-3d\";\n\n// ---------------------------------------------------------------------------\n// dgm:extLst — extension list (a:CT_OfficeArtExtensionList)\n// ---------------------------------------------------------------------------\n\nexport interface DiagramExtensionListOptions {\n /** Extension URIs */\n extensions?: readonly DiagramExtensionOptions[];\n}\n\nexport interface DiagramExtensionOptions {\n uri: string;\n}\n\n/**\n * Creates a dgm:extLst element (a:CT_OfficeArtExtensionList).\n *\n * Generic extension list pattern used across OOXML.\n */\nexport const createDiagramExtensionList = (options?: DiagramExtensionListOptions): string => {\n const children: string[] = [];\n if (options?.extensions) {\n for (const ext of options.extensions) {\n children.push(`<a:ext uri=\"${ext.uri}\"/>`);\n }\n }\n return element(\"dgm:extLst\", undefined, children);\n};\n\n// ---------------------------------------------------------------------------\n// dgm:sp3d — 3D shape properties (a:CT_Shape3D)\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a dgm:sp3d element wrapping a:CT_Shape3D.\n *\n * Delegates to the shared createShape3D factory but wraps in dgm: namespace context.\n */\nexport const createDiagramShape3D = (options: Shape3DOptions): string => createShape3D(options);\n\n// ---------------------------------------------------------------------------\n// dgm:txPr — text properties (CT_TextProps)\n// ---------------------------------------------------------------------------\n\nexport interface DiagramTextPropertiesOptions {\n /** Flat text (a:flatTx, the no-3D member of EG_Text3D) — empty marker element */\n flat?: boolean;\n}\n\n/**\n * Creates a dgm:txPr element (CT_TextProps).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TextProps\">\n * <xsd:sequence>\n * <xsd:group ref=\"a:EG_Text3D\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n */\nexport const createDiagramTextProperties = (options?: DiagramTextPropertiesOptions): string =>\n options?.flat ? \"<dgm:txPr><a:flatTx/></dgm:txPr>\" : \"<dgm:txPr/>\";\n","/**\n * Effect list descriptor for DrawingML shapes.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport { parse } from \"../../descriptor\";\nimport {\n convertToEmu,\n emitAngle,\n emitPercent,\n mapOptional,\n parseAngle,\n parsePercentAttr,\n} from \"../../util/converters\";\nimport { xsdBlendMode, xsdPresetShadow, xsdRectAlignment } from \"../../util/mappings\";\nimport { parseOnOff } from \"../../util/values\";\nimport { parseColorChoice, solidFillDesc, stringifyColorChoice } from \"../color/color-descriptors\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { gradientFillDesc, patternFillDesc } from \"../fill/fill-descriptors\";\nimport type { BlurEffectOptions, EffectListOptions } from \"./effect-list\";\nimport { createFillOverlayEffect } from \"./fill-overlay\";\nimport type { FillOverlayEffectOptions } from \"./fill-overlay\";\nimport type { GlowEffectOptions } from \"./glow\";\nimport type { InnerShadowEffectOptions } from \"./inner-shadow\";\nimport type { OuterShadowEffectOptions } from \"./outer-shadow\";\nimport type { PresetShadowEffectOptions } from \"./preset-shadow\";\nimport type { ReflectionEffectOptions } from \"./reflection\";\n\n// ── Helper: stringify a color into an effect element ──\n\nfunction stringifyEffectColor(\n color: SolidFillOptions | undefined,\n ctx: WriteContext,\n): string | undefined {\n if (!color) return undefined;\n // Effect elements expect EG_ColorChoice (direct color), NOT wrapped in solidFill\n return stringifyColorChoice(color, ctx);\n}\n\nfunction stringifyColorEffect(\n tag: string,\n attrs: Record<string, string | number | undefined>,\n color: SolidFillOptions | undefined,\n ctx: WriteContext,\n): string | undefined {\n const attrParts: string[] = [];\n for (const [key, val] of Object.entries(attrs)) {\n if (val !== undefined) attrParts.push(`${key}=\"${escapeXml(String(val as number | string))}\"`);\n }\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const colorXml = stringifyEffectColor(color, ctx);\n if (!colorXml && !attrStr) return undefined;\n\n if (!colorXml) return `<${tag}${attrStr}/>`;\n return `<${tag}${attrStr}>${colorXml}</${tag}>`;\n}\n\nfunction readColorFromElement(el: XmlElement, ctx: ReadContext): SolidFillOptions | undefined {\n // Effect elements contain EG_ColorChoice directly (not wrapped in solidFill).\n // Reuse parseColorChoice for full coverage (srgb/scheme/hsl/sys/prst/scrgb + transforms).\n const color = parseColorChoice(el, ctx);\n if (!color || Object.keys(color).length === 0) return undefined;\n return color;\n}\n\n// ── EffectList descriptor ──\n\nexport const effectListDesc: CustomDescriptor<EffectListOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Blur\n if (opts.blur) {\n const attrParts: string[] = [];\n if (opts.blur.radius !== undefined) attrParts.push(`rad=\"${opts.blur.radius}\"`);\n if (opts.blur.grow === false) attrParts.push('grow=\"0\"');\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:blur${attrStr}/>`);\n }\n\n // Fill overlay — CT_FillOverlayEffect requires an EG_FillProperties child.\n if (opts.fillOverlay) {\n parts.push(createFillOverlayEffect(opts.fillOverlay));\n }\n\n // Glow\n if (opts.glow) {\n parts.push(\n stringifyColorEffect(\n \"a:glow\",\n { rad: mapOptional(opts.glow.radius, convertToEmu) },\n opts.glow.color,\n ctx,\n ) ?? \"\",\n );\n }\n\n // Inner shadow\n if (opts.innerShadow) {\n parts.push(\n stringifyColorEffect(\n \"a:innerShdw\",\n {\n blurRad: mapOptional(opts.innerShadow.blurRadius, convertToEmu),\n dist: mapOptional(opts.innerShadow.distance, convertToEmu),\n dir:\n opts.innerShadow.direction !== undefined\n ? emitAngle(opts.innerShadow.direction)\n : undefined,\n },\n opts.innerShadow.color,\n ctx,\n ) ?? \"\",\n );\n }\n\n // Outer shadow\n if (opts.outerShadow) {\n parts.push(\n stringifyColorEffect(\n \"a:outerShdw\",\n {\n blurRad: mapOptional(opts.outerShadow.blurRadius, convertToEmu),\n dist: mapOptional(opts.outerShadow.distance, convertToEmu),\n dir:\n opts.outerShadow.direction !== undefined\n ? emitAngle(opts.outerShadow.direction)\n : undefined,\n sx:\n opts.outerShadow.scaleX !== undefined\n ? emitPercent(opts.outerShadow.scaleX)\n : undefined,\n sy:\n opts.outerShadow.scaleY !== undefined\n ? emitPercent(opts.outerShadow.scaleY)\n : undefined,\n kx:\n opts.outerShadow.skewX !== undefined ? emitAngle(opts.outerShadow.skewX) : undefined,\n ky:\n opts.outerShadow.skewY !== undefined ? emitAngle(opts.outerShadow.skewY) : undefined,\n algn:\n opts.outerShadow.alignment !== undefined\n ? xsdRectAlignment.to(opts.outerShadow.alignment)\n : undefined,\n rotWithShape: opts.outerShadow.rotWithShape === false ? 0 : undefined,\n },\n opts.outerShadow.color,\n ctx,\n ) ?? \"\",\n );\n }\n\n // Preset shadow\n if (opts.presetShadow) {\n parts.push(\n stringifyColorEffect(\n \"a:prstShdw\",\n {\n prst: xsdPresetShadow.to(opts.presetShadow.preset),\n dist: mapOptional(opts.presetShadow.distance, convertToEmu),\n dir:\n opts.presetShadow.direction !== undefined\n ? emitAngle(opts.presetShadow.direction)\n : undefined,\n },\n opts.presetShadow.color,\n ctx,\n ) ?? \"\",\n );\n }\n\n // Reflection\n if (opts.reflection) {\n const refOpts = opts.reflection === true ? ({} as ReflectionEffectOptions) : opts.reflection;\n const attrParts: string[] = [];\n if (refOpts.blurRadius !== undefined)\n attrParts.push(`blurRad=\"${convertToEmu(refOpts.blurRadius)}\"`);\n if (refOpts.startAlpha !== undefined)\n attrParts.push(`stA=\"${emitPercent(refOpts.startAlpha)}\"`);\n if (refOpts.startPosition !== undefined)\n attrParts.push(`stPos=\"${emitPercent(refOpts.startPosition)}\"`);\n if (refOpts.endAlpha !== undefined) attrParts.push(`endA=\"${emitPercent(refOpts.endAlpha)}\"`);\n if (refOpts.endPosition !== undefined)\n attrParts.push(`endPos=\"${emitPercent(refOpts.endPosition)}\"`);\n if (refOpts.distance !== undefined)\n attrParts.push(`dist=\"${convertToEmu(refOpts.distance)}\"`);\n if (refOpts.direction !== undefined) attrParts.push(`dir=\"${emitAngle(refOpts.direction)}\"`);\n if (refOpts.fadeDirection !== undefined)\n attrParts.push(`fadeDir=\"${emitAngle(refOpts.fadeDirection)}\"`);\n if (refOpts.scaleX !== undefined) attrParts.push(`sx=\"${emitPercent(refOpts.scaleX)}\"`);\n if (refOpts.scaleY !== undefined) attrParts.push(`sy=\"${emitPercent(refOpts.scaleY)}\"`);\n if (refOpts.skewX !== undefined) attrParts.push(`kx=\"${emitAngle(refOpts.skewX)}\"`);\n if (refOpts.skewY !== undefined) attrParts.push(`ky=\"${emitAngle(refOpts.skewY)}\"`);\n if (refOpts.alignment !== undefined)\n attrParts.push(`algn=\"${escapeXml(xsdRectAlignment.to(refOpts.alignment))}\"`);\n if (refOpts.rotWithShape !== undefined)\n attrParts.push(`rotWithShape=\"${refOpts.rotWithShape ? 1 : 0}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n parts.push(`<a:reflection${attrStr}/>`);\n }\n\n // Soft edge\n if (opts.softEdge !== undefined) {\n parts.push(`<a:softEdge rad=\"${convertToEmu(opts.softEdge)}\"/>`);\n }\n\n // Filter empty strings. An explicitly empty options object round-trips as\n // the empty element Word writes (<a:effectLst/>); omitting `effects`\n // entirely is what omits the element.\n const content = parts.filter(Boolean).join(\"\");\n if (!content) return \"<a:effectLst/>\";\n return `<a:effectLst>${content}</a:effectLst>`;\n },\n parse(el, ctx) {\n const result: EffectListOptions = {};\n\n // Blur\n const blur = findChild(el, \"a:blur\");\n if (blur) {\n const blurOpts: BlurEffectOptions = {};\n if (blur.attributes?.[\"rad\"] !== undefined) blurOpts.radius = Number(blur.attributes[\"rad\"]);\n if (blur.attributes?.[\"grow\"] !== undefined)\n blurOpts.grow = parseOnOff(blur.attributes[\"grow\"]) ?? true;\n result.blur = blurOpts;\n }\n\n // Glow\n const glow = findChild(el, \"a:glow\");\n if (glow) {\n const glowOpts: Partial<GlowEffectOptions> = {};\n if (glow.attributes?.[\"rad\"] !== undefined) glowOpts.radius = Number(glow.attributes[\"rad\"]);\n const color = readColorFromElement(glow, ctx);\n if (color) glowOpts.color = color;\n result.glow = glowOpts as GlowEffectOptions;\n }\n\n // Inner shadow\n const innerShdw = findChild(el, \"a:innerShdw\");\n if (innerShdw) {\n const innerOpts: Partial<InnerShadowEffectOptions> = {};\n if (innerShdw.attributes?.[\"blurRad\"] !== undefined)\n innerOpts.blurRadius = Number(innerShdw.attributes[\"blurRad\"]);\n if (innerShdw.attributes?.[\"dist\"] !== undefined)\n innerOpts.distance = Number(innerShdw.attributes[\"dist\"]);\n if (innerShdw.attributes?.[\"dir\"] !== undefined)\n innerOpts.direction = parseAngle(Number(innerShdw.attributes[\"dir\"]));\n const color = readColorFromElement(innerShdw, ctx);\n if (color) innerOpts.color = color;\n result.innerShadow = innerOpts as InnerShadowEffectOptions;\n }\n\n // Outer shadow\n const outerShdw = findChild(el, \"a:outerShdw\");\n if (outerShdw) {\n const outerOpts: Partial<OuterShadowEffectOptions> = {};\n if (outerShdw.attributes?.[\"blurRad\"] !== undefined)\n outerOpts.blurRadius = Number(outerShdw.attributes[\"blurRad\"]);\n if (outerShdw.attributes?.[\"dist\"] !== undefined)\n outerOpts.distance = Number(outerShdw.attributes[\"dist\"]);\n if (outerShdw.attributes?.[\"dir\"] !== undefined)\n outerOpts.direction = parseAngle(Number(outerShdw.attributes[\"dir\"]));\n if (outerShdw.attributes?.[\"sx\"] !== undefined)\n outerOpts.scaleX = parsePercentAttr(outerShdw.attributes[\"sx\"]);\n if (outerShdw.attributes?.[\"sy\"] !== undefined)\n outerOpts.scaleY = parsePercentAttr(outerShdw.attributes[\"sy\"]);\n if (outerShdw.attributes?.[\"kx\"] !== undefined)\n outerOpts.skewX = parseAngle(Number(outerShdw.attributes[\"kx\"]));\n if (outerShdw.attributes?.[\"ky\"] !== undefined)\n outerOpts.skewY = parseAngle(Number(outerShdw.attributes[\"ky\"]));\n if (outerShdw.attributes?.[\"algn\"] !== undefined)\n outerOpts.alignment = xsdRectAlignment.from(\n String(outerShdw.attributes[\"algn\"]),\n ) as OuterShadowEffectOptions[\"alignment\"];\n if (outerShdw.attributes?.[\"rotWithShape\"] !== undefined)\n outerOpts.rotWithShape = parseOnOff(outerShdw.attributes[\"rotWithShape\"]) ?? true;\n const color = readColorFromElement(outerShdw, ctx);\n if (color) outerOpts.color = color;\n result.outerShadow = outerOpts as OuterShadowEffectOptions;\n }\n\n // Fill overlay\n const fillOverlay = findChild(el, \"a:fillOverlay\");\n if (fillOverlay) {\n const overlayOpts: Partial<FillOverlayEffectOptions> = {};\n if (fillOverlay.attributes?.[\"blend\"] !== undefined)\n overlayOpts.blend = xsdBlendMode.from(\n String(fillOverlay.attributes[\"blend\"]),\n ) as FillOverlayEffectOptions[\"blend\"];\n const foSolid = findChild(fillOverlay, \"a:solidFill\");\n if (foSolid) overlayOpts.solidFill = parse(solidFillDesc, foSolid, ctx) as SolidFillOptions;\n const foGrad = findChild(fillOverlay, \"a:gradFill\");\n if (foGrad) overlayOpts.gradientFill = parse(gradientFillDesc, foGrad, ctx);\n const foPatt = findChild(fillOverlay, \"a:pattFill\");\n if (foPatt) overlayOpts.patternFill = parse(patternFillDesc, foPatt, ctx);\n if (findChild(fillOverlay, \"a:noFill\")) overlayOpts.noFill = true;\n if (findChild(fillOverlay, \"a:grpFill\")) overlayOpts.groupFill = true;\n result.fillOverlay = overlayOpts as FillOverlayEffectOptions;\n }\n\n // Preset shadow\n const prstShdw = findChild(el, \"a:prstShdw\");\n if (prstShdw) {\n const prstOpts: Partial<PresetShadowEffectOptions> = {};\n if (prstShdw.attributes?.[\"prst\"] !== undefined)\n prstOpts.preset = xsdPresetShadow.from(\n String(prstShdw.attributes[\"prst\"]),\n ) as PresetShadowEffectOptions[\"preset\"];\n if (prstShdw.attributes?.[\"dist\"] !== undefined)\n prstOpts.distance = Number(prstShdw.attributes[\"dist\"]);\n if (prstShdw.attributes?.[\"dir\"] !== undefined)\n prstOpts.direction = parseAngle(Number(prstShdw.attributes[\"dir\"]));\n const color = readColorFromElement(prstShdw, ctx);\n if (color) prstOpts.color = color;\n result.presetShadow = prstOpts as PresetShadowEffectOptions;\n }\n\n // Reflection\n const reflection = findChild(el, \"a:reflection\");\n if (reflection) {\n const refOpts: ReflectionEffectOptions = {};\n if (reflection.attributes?.[\"blurRad\"] !== undefined)\n refOpts.blurRadius = Number(reflection.attributes[\"blurRad\"]);\n if (reflection.attributes?.[\"stA\"] !== undefined)\n refOpts.startAlpha = parsePercentAttr(reflection.attributes[\"stA\"]);\n if (reflection.attributes?.[\"stPos\"] !== undefined)\n refOpts.startPosition = parsePercentAttr(reflection.attributes[\"stPos\"]);\n if (reflection.attributes?.[\"endA\"] !== undefined)\n refOpts.endAlpha = parsePercentAttr(reflection.attributes[\"endA\"]);\n if (reflection.attributes?.[\"endPos\"] !== undefined)\n refOpts.endPosition = parsePercentAttr(reflection.attributes[\"endPos\"]);\n if (reflection.attributes?.[\"dist\"] !== undefined)\n refOpts.distance = Number(reflection.attributes[\"dist\"]);\n if (reflection.attributes?.[\"dir\"] !== undefined)\n refOpts.direction = parseAngle(Number(reflection.attributes[\"dir\"]));\n if (reflection.attributes?.[\"fadeDir\"] !== undefined)\n refOpts.fadeDirection = parseAngle(Number(reflection.attributes[\"fadeDir\"]));\n if (reflection.attributes?.[\"sx\"] !== undefined)\n refOpts.scaleX = parsePercentAttr(reflection.attributes[\"sx\"]);\n if (reflection.attributes?.[\"sy\"] !== undefined)\n refOpts.scaleY = parsePercentAttr(reflection.attributes[\"sy\"]);\n if (reflection.attributes?.[\"kx\"] !== undefined)\n refOpts.skewX = parseAngle(Number(reflection.attributes[\"kx\"]));\n if (reflection.attributes?.[\"ky\"] !== undefined)\n refOpts.skewY = parseAngle(Number(reflection.attributes[\"ky\"]));\n if (reflection.attributes?.[\"algn\"] !== undefined)\n refOpts.alignment = xsdRectAlignment.from(\n String(reflection.attributes[\"algn\"]),\n ) as ReflectionEffectOptions[\"alignment\"];\n if (reflection.attributes?.[\"rotWithShape\"] !== undefined)\n refOpts.rotWithShape = parseOnOff(reflection.attributes[\"rotWithShape\"]) ?? true;\n result.reflection = refOpts;\n }\n\n // Soft edge\n const softEdge = findChild(el, \"a:softEdge\");\n if (softEdge?.attributes?.[\"rad\"] !== undefined) {\n result.softEdge = Number(softEdge.attributes[\"rad\"]);\n }\n\n return result;\n },\n};\n","/**\n * Locking descriptor for DrawingML shapes.\n *\n * @module\n */\n\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { parseOnOff } from \"../../util/values\";\nimport type {\n BaseLockingOptions,\n ConnectorLockingOptions,\n GraphicFrameLockingOptions,\n GroupLockingOptions,\n PictureLockingOptions,\n ShapeLockingOptions,\n} from \"./locking\";\n\n// ── Common locking attribute keys ──\n\nconst BASE_LOCKING_KEYS: readonly (keyof BaseLockingOptions & string)[] = [\n \"noGrp\",\n \"noSelect\",\n \"noRot\",\n \"noChangeAspect\",\n \"noMove\",\n \"noResize\",\n \"noEditPoints\",\n \"noAdjustHandles\",\n \"noChangeArrowheads\",\n \"noChangeShapeType\",\n];\n\nconst SHAPE_EXTRA_KEYS: readonly (keyof ShapeLockingOptions & string)[] = [\"noTextEdit\"];\nconst PICTURE_EXTRA_KEYS: readonly (keyof PictureLockingOptions & string)[] = [\"noCrop\"];\nconst GROUP_EXTRA_KEYS: readonly (keyof GroupLockingOptions & string)[] = [\"noUngrp\"];\nconst FRAME_EXTRA_KEYS: readonly (keyof GraphicFrameLockingOptions & string)[] = [\"noDrilldown\"];\n\n// ── Helper: stringify boolean attributes ──\n\nfunction stringifyLockingAttrs(\n opts: Readonly<Record<string, boolean | undefined>>,\n keys: readonly string[],\n): string {\n const parts: string[] = [];\n for (const key of keys) {\n if (opts[key] !== undefined) {\n parts.push(`${key}=\"${opts[key] ? 1 : 0}\"`);\n }\n }\n return parts.length ? \" \" + parts.join(\" \") : \"\";\n}\n\nfunction readLockingAttrs(el: XmlElement, keys: readonly string[]): Record<string, boolean> {\n const result: Record<string, boolean> = {};\n if (!el.attributes) return result;\n for (const key of keys) {\n const val = el.attributes[key];\n if (val !== undefined) result[key] = parseOnOff(val) ?? false;\n }\n return result;\n}\n\n/** One locking descriptor: element tag plus the base keys and any extras. */\nfunction createLockingDesc<T extends BaseLockingOptions>(\n tag: string,\n extraKeys: readonly string[] = [],\n): CustomDescriptor<T> {\n const allKeys = [...BASE_LOCKING_KEYS, ...extraKeys];\n return {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const attrStr = stringifyLockingAttrs(\n opts as unknown as Record<string, boolean | undefined>,\n allKeys,\n );\n // An empty <a:*Locks/> container is meaningful (locks present, none set)\n // and round-trips as {} — only an absent container stays undefined.\n if (!attrStr) return `<${tag}/>`;\n return `<${tag}${attrStr}/>`;\n },\n parse(el, _ctx) {\n return readLockingAttrs(el, allKeys) as unknown as T;\n },\n };\n}\n\n// ── Locking descriptors ──\n\nexport const shapeLockingDesc: CustomDescriptor<ShapeLockingOptions> =\n createLockingDesc<ShapeLockingOptions>(\"a:spLocks\", SHAPE_EXTRA_KEYS);\n\nexport const pictureLockingDesc: CustomDescriptor<PictureLockingOptions> =\n createLockingDesc<PictureLockingOptions>(\"a:picLocks\", PICTURE_EXTRA_KEYS);\n\nexport const groupLockingDesc: CustomDescriptor<GroupLockingOptions> =\n createLockingDesc<GroupLockingOptions>(\"a:grpSpLocks\", GROUP_EXTRA_KEYS);\n\nexport const graphicFrameLockingDesc: CustomDescriptor<GraphicFrameLockingOptions> =\n createLockingDesc<GraphicFrameLockingOptions>(\"a:graphicFrameLocks\", FRAME_EXTRA_KEYS);\n\n// CT_ConnectorLocking = AG_Locking (base keys only)\nexport const connectorLockingDesc: CustomDescriptor<ConnectorLockingOptions> =\n createLockingDesc<ConnectorLockingOptions>(\"a:cxnSpLocks\");\n","/**\n * Geometry descriptors for DrawingML shapes.\n *\n * @module\n */\n\nimport { escapeXml, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { stringify, parse } from \"../../descriptor\";\nimport { parseOnOff } from \"../../util/values\";\nimport type { GeometryGuide } from \"./adjustment-values\";\nimport type {\n CustomGeometryOptions,\n PathOptions,\n PathCommand,\n AdjustPoint,\n AdjustHandle,\n XYAdjustHandle,\n PolarAdjustHandle,\n ConnectionSite,\n GeomRect,\n} from \"./custom-geometry\";\nimport type { PresetGeometryOptions, ShapeType } from \"./preset-geometry\";\n\n// ── Adjustment values helper ──\n\nconst adjustmentValuesDesc: CustomDescriptor<readonly GeometryGuide[]> = {\n kind: \"custom\",\n stringify(guides, _ctx) {\n return stringifyGuideList(\"a:avLst\", guides ?? []);\n },\n parse(el, _ctx) {\n return readGuideList(el) as readonly GeometryGuide[];\n },\n};\n\n// ── Preset geometry descriptor ──\n\nexport const presetGeometryDesc: CustomDescriptor<PresetGeometryOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const prst = opts.preset ?? \"rect\";\n let avXml = \"\";\n if (opts.adjustmentValues) {\n avXml = stringify(adjustmentValuesDesc, opts.adjustmentValues, ctx) ?? \"<a:avLst/>\";\n } else {\n avXml = \"<a:avLst/>\";\n }\n return `<a:prstGeom prst=\"${escapeXml(prst)}\">${avXml}</a:prstGeom>`;\n },\n parse(el, ctx) {\n const result: PresetGeometryOptions = {};\n if (el.attributes?.[\"prst\"] !== undefined) {\n result.preset = String(el.attributes[\"prst\"]) as ShapeType;\n }\n const avLst = findChild(el, \"a:avLst\");\n if (avLst) {\n const guides = parse(adjustmentValuesDesc, avLst, ctx);\n if (guides.length > 0) {\n result.adjustmentValues = guides;\n }\n }\n return result;\n },\n};\n\n// ── Path command helpers ──\n\nfunction stringifyAdjustPoint(pt: AdjustPoint): string {\n return `<a:pt x=\"${escapeXml(pt.x)}\" y=\"${escapeXml(pt.y)}\"/>`;\n}\n\nfunction stringifyPathCommand(cmd: PathCommand): string {\n switch (cmd.command) {\n case \"moveTo\":\n return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;\n case \"lineTo\":\n return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;\n case \"arcTo\":\n return (\n `<a:arcTo wR=\"${escapeXml(cmd.widthRadius)}\" hR=\"${escapeXml(cmd.heightRadius)}\"` +\n ` stAng=\"${escapeXml(cmd.startAngle)}\" swAng=\"${escapeXml(cmd.sweepAngle)}\"/>`\n );\n case \"quadBezTo\": {\n const pts = cmd.points.map(stringifyAdjustPoint).join(\"\");\n return `<a:quadBezTo>${pts}</a:quadBezTo>`;\n }\n case \"cubicBezTo\": {\n const pts = cmd.points.map(stringifyAdjustPoint).join(\"\");\n return `<a:cubicBezTo>${pts}</a:cubicBezTo>`;\n }\n case \"close\":\n return \"<a:close/>\";\n }\n}\n\nfunction stringifyPath(path: PathOptions): string {\n const attrs: string[] = [];\n if (path.w !== undefined) attrs.push(`w=\"${path.w}\"`);\n if (path.h !== undefined) attrs.push(`h=\"${path.h}\"`);\n if (path.fill !== undefined) attrs.push(`fill=\"${escapeXml(path.fill)}\"`);\n if (path.stroke !== undefined) attrs.push(`stroke=\"${path.stroke}\"`);\n if (path.extrusionOk !== undefined) attrs.push(`extrusionOk=\"${path.extrusionOk}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n const cmds = path.commands.map(stringifyPathCommand).join(\"\");\n if (!cmds && !attrStr) return \"<a:path/>\";\n return `<a:path${attrStr}>${cmds}</a:path>`;\n}\n\nfunction readAdjustPoint(el: XmlElement): AdjustPoint | undefined {\n if (!el.attributes) return undefined;\n const x = el.attributes[\"x\"];\n const y = el.attributes[\"y\"];\n if (x === undefined || y === undefined) return undefined;\n return { x: String(x), y: String(y) };\n}\n\nfunction readPathCommand(tag: string, el: XmlElement): PathCommand | undefined {\n switch (tag) {\n case \"a:moveTo\": {\n const pt = el.elements?.find((c) => c.name === \"a:pt\");\n if (!pt) return undefined;\n const point = readAdjustPoint(pt);\n if (!point) return undefined;\n return { command: \"moveTo\", point };\n }\n case \"a:lnTo\": {\n const pt = el.elements?.find((c) => c.name === \"a:pt\");\n if (!pt) return undefined;\n const point = readAdjustPoint(pt);\n if (!point) return undefined;\n return { command: \"lineTo\", point };\n }\n case \"a:arcTo\": {\n const a = el.attributes;\n if (!a) return undefined;\n return {\n command: \"arcTo\",\n widthRadius: String(a[\"wR\"] ?? \"\"),\n heightRadius: String(a[\"hR\"] ?? \"\"),\n startAngle: String(a[\"stAng\"] ?? \"\"),\n sweepAngle: String(a[\"swAng\"] ?? \"\"),\n };\n }\n case \"a:quadBezTo\": {\n const points = (el.elements ?? [])\n .filter((c) => c.name === \"a:pt\")\n .map(readAdjustPoint)\n .filter((p): p is AdjustPoint => p !== undefined);\n const [p0, p1] = points;\n if (!p0 || !p1) return undefined;\n return { command: \"quadBezTo\", points: [p0, p1] };\n }\n case \"a:cubicBezTo\": {\n const points = (el.elements ?? [])\n .filter((c) => c.name === \"a:pt\")\n .map(readAdjustPoint)\n .filter((p): p is AdjustPoint => p !== undefined);\n const [p0, p1, p2] = points;\n if (!p0 || !p1 || !p2) return undefined;\n return { command: \"cubicBezTo\", points: [p0, p1, p2] };\n }\n case \"a:close\":\n return { command: \"close\" };\n default:\n return undefined;\n }\n}\n\nfunction readPath(el: XmlElement): Partial<PathOptions> {\n const result: Partial<PathOptions> = {};\n if (el.attributes) {\n if (el.attributes[\"w\"] !== undefined) result.w = Number(el.attributes[\"w\"]);\n if (el.attributes[\"h\"] !== undefined) result.h = Number(el.attributes[\"h\"]);\n if (el.attributes[\"fill\"] !== undefined)\n result.fill = String(el.attributes[\"fill\"]) as PathOptions[\"fill\"];\n if (el.attributes[\"stroke\"] !== undefined)\n result.stroke = parseOnOff(el.attributes[\"stroke\"]) ?? true;\n if (el.attributes[\"extrusionOk\"] !== undefined)\n result.extrusionOk = parseOnOff(el.attributes[\"extrusionOk\"]) ?? true;\n }\n const commands: PathCommand[] = [];\n if (el.elements) {\n for (const child of el.elements) {\n if (child.name) {\n const cmd = readPathCommand(child.name, child);\n if (cmd) commands.push(cmd);\n }\n }\n }\n if (commands.length > 0) result.commands = commands;\n return result as PathOptions;\n}\n\n// ── Guide list helper (avLst / gdLst) ──\n\nfunction stringifyGuideList(tag: string, guides: readonly GeometryGuide[]): string {\n if (!guides || guides.length === 0) return `<${tag}/>`;\n const inner = guides\n .map((g) => `<a:gd name=\"${escapeXml(g.name)}\" fmla=\"${escapeXml(g.formula)}\"/>`)\n .join(\"\");\n return `<${tag}>${inner}</${tag}>`;\n}\n\nfunction readGuideList(el: XmlElement): GeometryGuide[] {\n const result: GeometryGuide[] = [];\n if (el.elements) {\n for (const child of el.elements) {\n if (child.name === \"a:gd\" && child.attributes) {\n const name = child.attributes[\"name\"];\n const fmla = child.attributes[\"fmla\"];\n if (name !== undefined && fmla !== undefined) {\n result.push({ name: String(name), formula: String(fmla) });\n }\n }\n }\n }\n return result;\n}\n\n// ── Adjust handle helpers ──\n\nfunction stringifyAdjustHandlePos(pos: { x: string; y: string }): string {\n return `<a:pos x=\"${escapeXml(pos.x)}\" y=\"${escapeXml(pos.y)}\"/>`;\n}\n\nfunction stringifyXYAdjustHandle(h: XYAdjustHandle): string {\n const attrs: string[] = [];\n if (h.guideRefX !== undefined) attrs.push(`gdRefX=\"${escapeXml(h.guideRefX)}\"`);\n if (h.minX !== undefined) attrs.push(`minX=\"${escapeXml(h.minX)}\"`);\n if (h.maxX !== undefined) attrs.push(`maxX=\"${escapeXml(h.maxX)}\"`);\n if (h.guideRefY !== undefined) attrs.push(`gdRefY=\"${escapeXml(h.guideRefY)}\"`);\n if (h.minY !== undefined) attrs.push(`minY=\"${escapeXml(h.minY)}\"`);\n if (h.maxY !== undefined) attrs.push(`maxY=\"${escapeXml(h.maxY)}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return `<a:ahXY${attrStr}>${stringifyAdjustHandlePos(h.position)}</a:ahXY>`;\n}\n\nfunction stringifyPolarAdjustHandle(h: PolarAdjustHandle): string {\n const attrs: string[] = [];\n if (h.guideRefRadius !== undefined) attrs.push(`gdRefR=\"${escapeXml(h.guideRefRadius)}\"`);\n if (h.minRadius !== undefined) attrs.push(`minR=\"${escapeXml(h.minRadius)}\"`);\n if (h.maxRadius !== undefined) attrs.push(`maxR=\"${escapeXml(h.maxRadius)}\"`);\n if (h.guideRefAngle !== undefined) attrs.push(`gdRefAng=\"${escapeXml(h.guideRefAngle)}\"`);\n if (h.minAngle !== undefined) attrs.push(`minAng=\"${escapeXml(h.minAngle)}\"`);\n if (h.maxAngle !== undefined) attrs.push(`maxAng=\"${escapeXml(h.maxAngle)}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return `<a:ahPolar${attrStr}>${stringifyAdjustHandlePos(h.position)}</a:ahPolar>`;\n}\n\nfunction stringifyAdjustHandle(h: AdjustHandle): string {\n return h.type === \"xy\" ? stringifyXYAdjustHandle(h) : stringifyPolarAdjustHandle(h);\n}\n\nfunction readAdjustHandlePos(el: XmlElement): { x: string; y: string } | undefined {\n const pos = el.elements?.find((c) => c.name === \"a:pos\");\n if (!pos?.attributes) return undefined;\n const x = pos.attributes[\"x\"];\n const y = pos.attributes[\"y\"];\n if (x === undefined || y === undefined) return undefined;\n return { x: String(x), y: String(y) };\n}\n\nfunction readXYAdjustHandle(el: XmlElement): XYAdjustHandle | undefined {\n const position = readAdjustHandlePos(el);\n if (!position) return undefined;\n const result: XYAdjustHandle = { type: \"xy\", position };\n if (el.attributes?.[\"gdRefX\"] !== undefined) result.guideRefX = String(el.attributes[\"gdRefX\"]);\n if (el.attributes?.[\"minX\"] !== undefined) result.minX = String(el.attributes[\"minX\"]);\n if (el.attributes?.[\"maxX\"] !== undefined) result.maxX = String(el.attributes[\"maxX\"]);\n if (el.attributes?.[\"gdRefY\"] !== undefined) result.guideRefY = String(el.attributes[\"gdRefY\"]);\n if (el.attributes?.[\"minY\"] !== undefined) result.minY = String(el.attributes[\"minY\"]);\n if (el.attributes?.[\"maxY\"] !== undefined) result.maxY = String(el.attributes[\"maxY\"]);\n return result;\n}\n\nfunction readPolarAdjustHandle(el: XmlElement): PolarAdjustHandle | undefined {\n const position = readAdjustHandlePos(el);\n if (!position) return undefined;\n const result: PolarAdjustHandle = { type: \"polar\", position };\n if (el.attributes?.[\"gdRefR\"] !== undefined)\n result.guideRefRadius = String(el.attributes[\"gdRefR\"]);\n if (el.attributes?.[\"minR\"] !== undefined) result.minRadius = String(el.attributes[\"minR\"]);\n if (el.attributes?.[\"maxR\"] !== undefined) result.maxRadius = String(el.attributes[\"maxR\"]);\n if (el.attributes?.[\"gdRefAng\"] !== undefined)\n result.guideRefAngle = String(el.attributes[\"gdRefAng\"]);\n if (el.attributes?.[\"minAng\"] !== undefined) result.minAngle = String(el.attributes[\"minAng\"]);\n if (el.attributes?.[\"maxAng\"] !== undefined) result.maxAngle = String(el.attributes[\"maxAng\"]);\n return result;\n}\n\n// ── Connection site helpers ──\n\nfunction stringifyConnectionSite(site: ConnectionSite): string {\n return `<a:cxn ang=\"${escapeXml(site.angle)}\">${stringifyAdjustHandlePos(site.position)}</a:cxn>`;\n}\n\nfunction readConnectionSite(el: XmlElement): ConnectionSite | undefined {\n const ang = el.attributes?.[\"ang\"];\n if (ang === undefined) return undefined;\n const position = readAdjustHandlePos(el);\n if (!position) return undefined;\n return { angle: String(ang), position };\n}\n\n// ── Geom rect helpers ──\n\nfunction stringifyGeomRect(rect: GeomRect): string {\n return (\n `<a:rect l=\"${escapeXml(rect.left)}\" t=\"${escapeXml(rect.top)}\"` +\n ` r=\"${escapeXml(rect.right)}\" b=\"${escapeXml(rect.bottom)}\"/>`\n );\n}\n\nfunction readGeomRect(el: XmlElement): GeomRect | undefined {\n const a = el.attributes;\n if (!a) return undefined;\n const l = a[\"l\"];\n const t = a[\"t\"];\n const r = a[\"r\"];\n const b = a[\"b\"];\n if (l === undefined || t === undefined || r === undefined || b === undefined) return undefined;\n return { left: String(l), top: String(t), right: String(r), bottom: String(b) };\n}\n\n// ── Custom geometry descriptor ──\n\nexport const customGeometryDesc: CustomDescriptor<CustomGeometryOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const parts: string[] = [];\n\n // a:avLst\n if (opts.adjustmentValues && opts.adjustmentValues.length > 0) {\n parts.push(stringifyGuideList(\"a:avLst\", opts.adjustmentValues));\n } else {\n parts.push(\"<a:avLst/>\");\n }\n\n // a:gdLst\n if (opts.guides && opts.guides.length > 0) {\n parts.push(stringifyGuideList(\"a:gdLst\", opts.guides));\n }\n\n // a:ahLst — an empty array keeps the bare element (sources often carry one).\n if (opts.adjustHandles) {\n const inner = opts.adjustHandles.map(stringifyAdjustHandle).join(\"\");\n parts.push(inner ? `<a:ahLst>${inner}</a:ahLst>` : \"<a:ahLst/>\");\n }\n\n // a:cxnLst\n if (opts.connectionSites && opts.connectionSites.length > 0) {\n const inner = opts.connectionSites.map(stringifyConnectionSite).join(\"\");\n parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);\n }\n\n // a:rect\n if (opts.textRectangle) {\n parts.push(stringifyGeomRect(opts.textRectangle));\n }\n\n // a:pathLst (XSD-required, minOccurs=1). Parse leaves it undefined only\n // for a malformed source custGeom without one — emit the empty form there\n // so the output stays schema-valid.\n const pathsXml = (opts.pathList ?? []).map(stringifyPath).join(\"\");\n parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);\n\n return `<a:custGeom>${parts.join(\"\")}</a:custGeom>`;\n },\n parse(el, _ctx) {\n const result: Partial<CustomGeometryOptions> = {};\n\n // a:avLst\n const avLst = findChild(el, \"a:avLst\");\n if (avLst) {\n const guides = readGuideList(avLst);\n if (guides.length > 0) result.adjustmentValues = guides;\n }\n\n // a:gdLst\n const gdLst = findChild(el, \"a:gdLst\");\n if (gdLst) {\n const guides = readGuideList(gdLst);\n if (guides.length > 0) result.guides = guides;\n }\n\n // a:ahLst — keep a bare element too (sources often carry <a:ahLst/>).\n const ahLst = findChild(el, \"a:ahLst\");\n if (ahLst) {\n const handles: AdjustHandle[] = [];\n for (const child of ahLst.elements ?? []) {\n if (child.name === \"a:ahXY\") {\n const h = readXYAdjustHandle(child);\n if (h) handles.push(h);\n } else if (child.name === \"a:ahPolar\") {\n const h = readPolarAdjustHandle(child);\n if (h) handles.push(h);\n }\n }\n // Keep an explicit empty element — sources often carry a bare <a:ahLst/>.\n result.adjustHandles = handles;\n }\n\n // a:cxnLst\n const cxnLst = findChild(el, \"a:cxnLst\");\n if (cxnLst?.elements) {\n const sites: ConnectionSite[] = [];\n for (const child of cxnLst.elements) {\n if (child.name === \"a:cxn\") {\n const site = readConnectionSite(child);\n if (site) sites.push(site);\n }\n }\n if (sites.length > 0) result.connectionSites = sites;\n }\n\n // a:rect\n const rect = findChild(el, \"a:rect\");\n if (rect) {\n const textRectangle = readGeomRect(rect);\n if (textRectangle) result.textRectangle = textRectangle;\n }\n\n // a:pathLst (required) — presence-based: an explicit empty <a:pathLst/>\n // round-trips as [] so the empty form survives verbatim.\n const pathLst = findChild(el, \"a:pathLst\");\n if (pathLst) {\n const paths: PathOptions[] = [];\n for (const child of pathLst.elements ?? []) {\n if (child.name === \"a:path\") {\n const p = readPath(child);\n if (p.commands && p.commands.length > 0) {\n paths.push(p as PathOptions);\n }\n }\n }\n result.pathList = paths;\n }\n\n return result as CustomGeometryOptions;\n },\n};\n","/**\n * Transform 2D descriptor for DrawingML shapes.\n *\n * @module\n */\n\nimport { attrMeasure, findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport { convertToEmu, emitAngle, parseAngle } from \"../util/converters\";\nimport { parseOnOff } from \"../util/values\";\nimport type { GroupTransform2DOptions, Transform2DOptions } from \"./transform\";\n\n// ── Transform2D descriptor ──\n// x, y, width, height: number (EMU) | string (UniversalMeasure)\n\nexport const transform2DDesc: CustomDescriptor<Transform2DOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const parts: string[] = [];\n\n // Attributes\n const attrParts: string[] = [];\n if (opts.flipHorizontal !== undefined) attrParts.push(`flipH=\"${opts.flipHorizontal ? 1 : 0}\"`);\n if (opts.flipVertical !== undefined) attrParts.push(`flipV=\"${opts.flipVertical ? 1 : 0}\"`);\n if (opts.rotation !== undefined) attrParts.push(`rot=\"${emitAngle(opts.rotation)}\"`);\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n // Child elements: off, ext\n if (opts.x !== undefined || opts.y !== undefined) {\n const x = opts.x !== undefined ? convertToEmu(opts.x) : 0;\n const y = opts.y !== undefined ? convertToEmu(opts.y) : 0;\n parts.push(`<a:off x=\"${x}\" y=\"${y}\"/>`);\n }\n if (opts.width !== undefined || opts.height !== undefined) {\n const cx = opts.width !== undefined ? convertToEmu(opts.width) : 0;\n const cy = opts.height !== undefined ? convertToEmu(opts.height) : 0;\n parts.push(`<a:ext cx=\"${cx}\" cy=\"${cy}\"/>`);\n }\n\n if (parts.length === 0 && !attrStr) return undefined;\n if (parts.length === 0) return `<a:xfrm${attrStr}/>`;\n return `<a:xfrm${attrStr}>${parts.join(\"\")}</a:xfrm>`;\n },\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // Attributes\n if (el.attributes) {\n if (el.attributes[\"flipH\"] !== undefined)\n result.flipHorizontal = parseOnOff(el.attributes[\"flipH\"]) ?? false;\n if (el.attributes[\"flipV\"] !== undefined)\n result.flipVertical = parseOnOff(el.attributes[\"flipV\"]) ?? false;\n if (el.attributes[\"rot\"] !== undefined)\n result.rotation = parseAngle(Number(el.attributes[\"rot\"]));\n }\n\n // Child: off — a:off x/y are ST_Coordinate (number EMU | UniversalMeasure)\n const off = findChild(el, \"a:off\");\n if (off?.attributes) {\n const xv = attrMeasure(off, \"x\");\n result.x = xv ?? 0;\n const yv = attrMeasure(off, \"y\");\n result.y = yv ?? 0;\n }\n\n // Child: ext\n const ext = findChild(el, \"a:ext\");\n if (ext?.attributes) {\n const cxv = attrMeasure(ext, \"cx\");\n result.width = cxv ?? 0;\n const cyv = attrMeasure(ext, \"cy\");\n result.height = cyv ?? 0;\n }\n\n return result as Transform2DOptions;\n },\n};\n\n// ── GroupTransform2D descriptor ──\n\nexport const groupTransform2DDesc: CustomDescriptor<GroupTransform2DOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const base = transform2DDesc.stringify(opts, ctx) ?? \"<a:xfrm/>\";\n\n // Append chOff and chExt children before closing tag (values are already in EMU)\n const chOff = `<a:chOff x=\"${opts.childOffsetX ?? 0}\" y=\"${opts.childOffsetY ?? 0}\"/>`;\n const chExt = `<a:chExt cx=\"${opts.childExtentWidth ?? 0}\" cy=\"${opts.childExtentHeight ?? 0}\"/>`;\n\n if (base.endsWith(\"/>\")) {\n return `<a:xfrm>${chOff}${chExt}</a:xfrm>`;\n }\n return base.replace(/<\\/a:xfrm>$/, `${chOff}${chExt}</a:xfrm>`);\n },\n parse(el, ctx) {\n const result = transform2DDesc.parse(el, ctx) as Record<string, unknown>;\n\n const chOff = findChild(el, \"a:chOff\");\n if (chOff?.attributes) {\n const cx = attrMeasure(chOff, \"x\");\n result.childOffsetX = cx ?? 0;\n const cy = attrMeasure(chOff, \"y\");\n result.childOffsetY = cy ?? 0;\n }\n\n const chExt = findChild(el, \"a:chExt\");\n if (chExt?.attributes) {\n const ccx = attrMeasure(chExt, \"cx\");\n result.childExtentWidth = ccx ?? 0;\n const ccy = attrMeasure(chExt, \"cy\");\n result.childExtentHeight = ccy ?? 0;\n }\n\n return result as GroupTransform2DOptions;\n },\n};\n","/**\n * Shape properties descriptor for DrawingML CT_ShapeProperties.\n *\n * Assembles the XSD-ordered children of a shape/picture/group properties\n * element (a:xfrm → geometry → fill → a:ln → effects → a:scene3d → a:sp3d).\n * Returns the inner content only; the caller wraps the container tag\n * (p:spPr / wps:spPr / pic:spPr / xdr:spPr) and any container-only attributes\n * such as bwMode.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ShapeProperties / EG_ShapeProperties\n *\n * @module\n */\n\nimport { escapeXml, findChild, stringifyElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport { parse } from \"../descriptor\";\nimport type { UniversalMeasure } from \"../util/values\";\nimport { createEffectDag } from \"./effects/effect-dag\";\nimport type { EffectDagOptions } from \"./effects/effect-dag\";\nimport { effectListDesc } from \"./effects/effect-descriptors\";\nimport type { EffectListOptions } from \"./effects/effect-list\";\nimport { fillDesc, findFillChild } from \"./fill/fill-descriptors\";\nimport type { FillOptions } from \"./fill/fill-options\";\nimport type { CustomGeometryOptions } from \"./geometry/custom-geometry\";\nimport { presetGeometryDesc, customGeometryDesc } from \"./geometry/geometry-descriptors\";\nimport type { PresetGeometryOptions, ShapeType } from \"./geometry/preset-geometry\";\nimport type { OutlineOptions } from \"./outline/outline\";\nimport { outlineDesc, stringifyLineProperties } from \"./outline/outline-descriptors\";\nimport type { Scene3DOptions } from \"./three-d/scene-3d\";\nimport type { Shape3DOptions } from \"./three-d/shape-3d\";\nimport { scene3DDesc, shape3DDesc } from \"./three-d/three-d-descriptors\";\nimport type { Transform2DOptions } from \"./transform\";\nimport { transform2DDesc } from \"./transform-descriptors\";\n\n// ── Types ──\n\n/** A shape-property extension (a:ext). Known Office extensions are structured;\n * unknown payloads remain verbatim in `content`. */\nexport interface ShapePropertiesExtensionOptions {\n uri: string;\n hiddenLine?: OutlineOptions;\n content?: string;\n}\n\n/**\n * Shape properties (CT_ShapeProperties children). Field order follows the XSD\n * content model; the serializer emits in that order. Container-only attributes\n * (bwMode, rotWithShape) and the wrapping tag are the caller's responsibility.\n */\nexport interface ShapePropertiesOptions {\n // CT_Transform2D (a:xfrm)\n x?: number | UniversalMeasure;\n y?: number | UniversalMeasure;\n width?: number | UniversalMeasure;\n height?: number | UniversalMeasure;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n /** Rotation angle in degrees (e.g., 45 = 45°). */\n rotation?: number;\n // EG_Geometry (choice: a:custGeom | a:prstGeom). customGeometry wins; a bare\n // string geometry is shorthand for { preset: \"<name>\" }.\n geometry?: ShapeType | PresetGeometryOptions;\n customGeometry?: CustomGeometryOptions;\n // EG_FillProperties\n fill?: FillOptions;\n // a:ln\n outline?: OutlineOptions;\n // EG_EffectProperties (choice: a:effectDag | a:effectLst)\n effects?: EffectListOptions;\n effectDag?: EffectDagOptions;\n // 3D\n scene3d?: Scene3DOptions;\n shape3d?: Shape3DOptions;\n /** Shape-property extensions (a:extLst/a:ext). */\n extensions?: ShapePropertiesExtensionOptions[];\n /**\n * Raw a:extLst inner XML. Prefer `extensions` for structured shape-property\n * extensions; retained for existing callers and unmodeled payloads.\n */\n ext?: string;\n}\n\n// ── Descriptor ──\n\nexport const shapePropertiesDesc: CustomDescriptor<ShapePropertiesOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // a:xfrm — CT_Transform2D; emit only when any transform field is set.\n // (chOff/chExt belong to CT_GroupTransform2D under grpSpPr — group shapes\n // go through groupShapePropertiesDesc, never here.)\n const hasTransform =\n opts.x !== undefined ||\n opts.y !== undefined ||\n opts.width !== undefined ||\n opts.height !== undefined ||\n opts.flipHorizontal !== undefined ||\n opts.flipVertical !== undefined ||\n opts.rotation !== undefined;\n if (hasTransform) {\n const transformOpts = {\n x: opts.x,\n y: opts.y,\n width: opts.width,\n height: opts.height,\n flipHorizontal: opts.flipHorizontal,\n flipVertical: opts.flipVertical,\n rotation: opts.rotation,\n };\n const xfrm = transform2DDesc.stringify(transformOpts as Transform2DOptions, ctx);\n if (xfrm) parts.push(xfrm);\n }\n\n // EG_Geometry: customGeometry takes precedence (matches pptx/docx).\n if (opts.customGeometry) {\n const g = customGeometryDesc.stringify(opts.customGeometry, ctx);\n if (g) parts.push(g);\n } else if (opts.geometry !== undefined) {\n const geom: PresetGeometryOptions =\n typeof opts.geometry === \"string\" ? { preset: opts.geometry } : opts.geometry;\n const g = presetGeometryDesc.stringify(geom, ctx);\n if (g) parts.push(g);\n }\n\n // EG_FillProperties\n if (opts.fill !== undefined) {\n const f = fillDesc.stringify(opts.fill, ctx);\n if (f) parts.push(f);\n }\n\n // a:ln\n if (opts.outline) {\n const ln = outlineDesc.stringify(opts.outline, ctx);\n if (ln) parts.push(ln);\n }\n\n // EG_EffectProperties: effectDag | effectLst (mutually exclusive).\n if (opts.effectDag) {\n parts.push(createEffectDag(opts.effectDag));\n } else if (opts.effects) {\n const e = effectListDesc.stringify(opts.effects, ctx);\n if (e) parts.push(e);\n }\n\n // a:scene3d\n if (opts.scene3d) {\n const s = scene3DDesc.stringify(opts.scene3d, ctx);\n if (s) parts.push(s);\n }\n\n // a:sp3d\n if (opts.shape3d) {\n const sp = shape3DDesc.stringify(opts.shape3d, ctx);\n if (sp) parts.push(sp);\n }\n\n // a:extLst — last child per CT_ShapeProperties sequence. Structured\n // extensions take precedence over the legacy raw inner XML field.\n if (opts.extensions !== undefined) {\n const extensions = opts.extensions\n .map((extension) => {\n let content = extension.content ?? \"\";\n if (extension.hiddenLine) {\n const hiddenLine =\n stringifyLineProperties(\"a14:hiddenLine\", extension.hiddenLine, ctx) ?? \"\";\n content += hiddenLine.replace(\n \"<a14:hiddenLine\",\n '<a14:hiddenLine xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\"',\n );\n }\n return `<a:ext uri=\"${escapeXml(extension.uri)}\">${content}</a:ext>`;\n })\n .join(\"\");\n parts.push(`<a:extLst>${extensions}</a:extLst>`);\n } else if (opts.ext !== undefined) {\n parts.push(`<a:extLst>${opts.ext}</a:extLst>`);\n }\n\n return parts.length > 0 ? parts.join(\"\") : undefined;\n },\n\n parse(el, ctx) {\n const result: Partial<ShapePropertiesOptions> = {};\n\n // a:xfrm — plain CT_Transform2D (a chOff/chExt-bearing source xfrm would\n // only appear under grpSpPr, which parses through groupShapePropertiesDesc)\n const xfrm = findChild(el, \"a:xfrm\");\n if (xfrm) {\n Object.assign(result, transform2DDesc.parse(xfrm, ctx));\n }\n\n // EG_Geometry\n const custGeom = findChild(el, \"a:custGeom\");\n if (custGeom) {\n result.customGeometry = customGeometryDesc.parse(custGeom, ctx);\n } else {\n const prstGeom = findChild(el, \"a:prstGeom\");\n if (prstGeom) result.geometry = presetGeometryDesc.parse(prstGeom, ctx);\n }\n\n // EG_FillProperties — fillDesc always returns a value (defaults to none),\n // so probe for a fill child first to avoid synthesizing a spurious fill.\n const fillChild = findFillChild(el);\n if (fillChild) {\n result.fill = parse(fillDesc, fillChild, ctx);\n }\n\n // a:ln\n const ln = findChild(el, \"a:ln\");\n if (ln) result.outline = outlineDesc.parse(ln, ctx);\n\n // EG_EffectProperties — effectLst. (effectDag parse is not modeled here;\n // matches current per-package behavior. effectDag still round-trips via\n // stringify when the caller supplies it.)\n const effectLst = findChild(el, \"a:effectLst\");\n if (effectLst) result.effects = effectListDesc.parse(effectLst, ctx);\n\n // a:scene3d\n const scene3d = findChild(el, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n\n // a:sp3d\n const sp3d = findChild(el, \"a:sp3d\");\n if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, ctx);\n\n // a:extLst — structure known Office extensions. Lists with no known\n // payload stay on the legacy raw field so existing public APIs keep their\n // established shape; mixed lists retain unknown payloads per extension.\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) {\n const extensions = (extLst.elements ?? [])\n .filter((child) => child.type === \"element\" && child.name === \"a:ext\")\n .map((extension) => {\n const parsed: ShapePropertiesExtensionOptions = {\n uri: String(extension.attributes?.[\"uri\"] ?? \"\"),\n };\n const unknown: string[] = [];\n for (const child of extension.elements ?? []) {\n if (child.type === \"element\" && child.name === \"a14:hiddenLine\") {\n parsed.hiddenLine = outlineDesc.parse(child, ctx);\n } else {\n unknown.push(stringifyElement(child));\n }\n }\n if (unknown.length > 0) parsed.content = unknown.join(\"\");\n return parsed;\n });\n if (extensions.some((extension) => extension.hiddenLine !== undefined)) {\n result.extensions = extensions;\n } else {\n result.ext = (extLst.elements ?? []).map(stringifyElement).join(\"\");\n }\n }\n\n return result as ShapePropertiesOptions;\n },\n};\n","/**\n * Group shape properties descriptor for DrawingML CT_GroupShapeProperties.\n *\n * Assembles the XSD-ordered children of a group's properties element\n * (a:xfrm → EG_FillProperties → EG_EffectProperties → a:scene3d). Returns the\n * inner content only; the caller wraps the container tag (p:grpSpPr /\n * wpg:grpSpPr / xdr:grpSpPr / a:grpSpPr) and any container-only attributes\n * such as bwMode.\n *\n * Unlike CT_ShapeProperties, a group carries no geometry (prstGeom/custGeom),\n * no outline (a:ln), and no shape 3D (a:sp3d) — only the transform, fill,\n * effects, and scene 3D that apply to the group as a whole. The transform is\n * always a group transform (CT_GroupTransform2D), so the fields flatten in\n * directly via `extends GroupTransform2DOptions` (mirroring the flat style of\n * ShapePropertiesOptions, without its geometry/outline/shape3d extras).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GroupShapeProperties\n *\n * @module\n */\n\nimport { findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport { parse } from \"../descriptor\";\nimport { createEffectDag } from \"./effects/effect-dag\";\nimport type { EffectDagOptions } from \"./effects/effect-dag\";\nimport { effectListDesc } from \"./effects/effect-descriptors\";\nimport type { EffectListOptions } from \"./effects/effect-list\";\nimport { fillDesc, findFillChild } from \"./fill/fill-descriptors\";\nimport type { FillOptions } from \"./fill/fill-options\";\nimport type { Scene3DOptions } from \"./three-d/scene-3d\";\nimport { scene3DDesc } from \"./three-d/three-d-descriptors\";\nimport type { GroupTransform2DOptions } from \"./transform\";\nimport { groupTransform2DDesc } from \"./transform-descriptors\";\n\n// ── Types ──\n\n/**\n * Group shape properties (CT_GroupShapeProperties). Field order follows the XSD\n * content model. The transform fields come from {@link GroupTransform2DOptions}\n * (flat x/y/width/height/flip/rotation/childOffset/childExtent); the serializer\n * emits them as a single a:xfrm group transform. The container-only `@bwMode`\n * attribute and the wrapping tag are the caller's responsibility (mirrors\n * shapePropertiesDesc).\n */\nexport interface GroupShapePropertiesOptions extends GroupTransform2DOptions {\n /** EG_FillProperties. */\n fill?: FillOptions;\n /** EG_EffectProperties (choice: a:effectDag | a:effectLst). */\n effects?: EffectListOptions;\n effectDag?: EffectDagOptions;\n /** a:scene3d. */\n scene3d?: Scene3DOptions;\n}\n\n// ── Descriptor ──\n\nexport const groupShapePropertiesDesc: CustomDescriptor<GroupShapePropertiesOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // a:xfrm — group transform (CT_GroupTransform2D). Emit when any transform\n // field is set. A group always uses a group transform (no plain/sp transform).\n const hasTransform =\n opts.x !== undefined ||\n opts.y !== undefined ||\n opts.width !== undefined ||\n opts.height !== undefined ||\n opts.flipHorizontal !== undefined ||\n opts.flipVertical !== undefined ||\n opts.rotation !== undefined ||\n opts.childOffsetX !== undefined ||\n opts.childOffsetY !== undefined ||\n opts.childExtentWidth !== undefined ||\n opts.childExtentHeight !== undefined;\n if (hasTransform) {\n const xfrm = groupTransform2DDesc.stringify(opts, ctx);\n if (xfrm) parts.push(xfrm);\n }\n\n // EG_FillProperties\n if (opts.fill !== undefined) {\n const f = fillDesc.stringify(opts.fill, ctx);\n if (f) parts.push(f);\n }\n\n // EG_EffectProperties: effectDag | effectLst (mutually exclusive).\n if (opts.effectDag) {\n parts.push(createEffectDag(opts.effectDag));\n } else if (opts.effects) {\n const e = effectListDesc.stringify(opts.effects, ctx);\n if (e) parts.push(e);\n }\n\n // a:scene3d\n if (opts.scene3d) {\n const s = scene3DDesc.stringify(opts.scene3d, ctx);\n if (s) parts.push(s);\n }\n\n return parts.length > 0 ? parts.join(\"\") : undefined;\n },\n\n parse(el, ctx) {\n const result: Partial<GroupShapePropertiesOptions> = {};\n\n // a:xfrm — group transform.\n const xfrm = findChild(el, \"a:xfrm\");\n if (xfrm) {\n Object.assign(result, groupTransform2DDesc.parse(xfrm, ctx));\n }\n\n // EG_FillProperties — fillDesc always returns a value (defaults to none),\n // so probe for a fill child first to avoid synthesizing a spurious fill.\n const fillChild = findFillChild(el);\n if (fillChild) {\n result.fill = parse(fillDesc, fillChild, ctx);\n }\n\n // EG_EffectProperties — effectLst. (effectDag parse is not modeled here;\n // matches shapePropertiesDesc behavior. effectDag still round-trips via\n // stringify when the caller supplies it.)\n const effectLst = findChild(el, \"a:effectLst\");\n if (effectLst) result.effects = effectListDesc.parse(effectLst, ctx);\n\n // a:scene3d\n const scene3d = findChild(el, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n\n return result as GroupShapePropertiesOptions;\n },\n};\n","/**\n * Shared DrawingML text option types, enums, and constants.\n *\n * Promoted from per-format implementations so DOCX/PPTX/XLSX share one text\n * model for runs, paragraphs, fields, and bullets. DOCX still uses\n * WordprocessingML (w:p) inside text boxes, but its DrawingML run/paragraph\n * options align with these types where they overlap.\n *\n * @module\n */\n\nimport type { Panose } from \"../../util/values\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport type { EffectListOptions } from \"../effects/effect-list\";\nimport type { FillOptions } from \"../fill/fill-options\";\nimport type { OutlineOptions } from \"../outline/outline\";\n\n// ── Run style enums ──\n\n/** Underline (ST_TextUnderlineType, simplified set). */\nexport type UnderlineStyle = \"single\" | \"double\" | \"none\";\n\n/** Strikethrough (ST_TextStrikeType). Friendly spellings; xsdStrikeStyle maps them to the XML tokens. */\nexport type StrikeStyle = \"singleStrike\" | \"doubleStrike\" | \"noStrike\";\n\n/** Case effect (ST_TextCaps): \"all\" ALL CAPS, \"small\" Small Caps, \"none\". */\nexport type TextCapitalization = \"none\" | \"all\" | \"small\";\n\n// ── Paragraph alignment ──\n\n/** Paragraph alignment (ST_TextAlignType); \"justify\" stretches lines to full width. */\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\n// ── Hyperlink (a:hlinkClick) ──\n\nexport interface TextHyperlinkOptions {\n /** External URL target (mutually exclusive with slide). */\n url?: string;\n /**\n * Internal slide target, 1-based slide number (mutually exclusive with url);\n * emitted as r:id → slideN.xml + action=\"ppaction://hlinksldjump\". PPTX\n * only — other formats reject the field at generate time.\n */\n slide?: number;\n /** Internal placeholder key (\"{hlink:N}\" → \"N\"); preserved across parse → stringify. */\n referenceId?: string;\n tooltip?: string;\n action?: string;\n highlightClick?: boolean;\n endSound?: boolean;\n invalidUrl?: boolean;\n}\n\n// ── Text fonts (CT_TextFont: a:latin / a:ea / a:cs / a:sym) ──\n\n/**\n * A script typeface (CT_TextFont). A bare string is the typeface only; the\n * full object carries panose/pitchFamily/charset for embedded font metrics.\n */\nexport type TextFont =\n | string\n | {\n typeface: string;\n /** ST_Panose — 10-byte hex panose classification. */\n panose?: Panose;\n pitchFamily?: number;\n charset?: number;\n };\n\n/**\n * Run font scripts. A bare string sets latin + ea to the same typeface (the\n * common case); the object form sets each script independently.\n */\nexport type RunFont =\n | string\n | {\n latin?: TextFont;\n eastAsia?: TextFont;\n complexScript?: TextFont;\n symbol?: TextFont;\n };\n\n// ── Run properties (CT_TextCharacterProperties) ──\n\nexport interface TextCharacterPropertiesOptions {\n /** Font size in points. Serialized as OOXML a:sz (hundredths of a point). */\n size?: number;\n bold?: boolean;\n italic?: boolean;\n underline?: UnderlineStyle;\n font?: RunFont;\n lang?: string;\n fill?: FillOptions;\n hyperlink?: TextHyperlinkOptions;\n /** a:hlinkMouseOver — hover hyperlink (CT_Hyperlink). */\n mouseoverHyperlink?: TextHyperlinkOptions;\n strike?: StrikeStyle;\n /** Baseline offset as integer percent (positive = superscript, negative = subscript). */\n baseline?: number;\n /** Character spacing in points (a:spc). */\n spacing?: number;\n capitalization?: TextCapitalization;\n /** a:highlight (CT_Color) — text highlight color. */\n highlight?: SolidFillOptions;\n /** EG_TextUnderlineLine — underline line. `true` = a:uLnTx (follow the text line); an OutlineOptions = a:uLn. */\n underlineLine?: true | OutlineOptions;\n /** EG_TextUnderlineFill — underline fill. `true` = a:uFillTx (follow the text fill); a FillOptions = a:uFill. */\n underlineFill?: true | FillOptions;\n /** `@kern` — kerning threshold in points (ST_TextNonNegativePoint). */\n kern?: number;\n /** a:ln (CT_LineProperties). `true` emits a sane default; a full OutlineOptions round-trips. */\n outline?: true | OutlineOptions;\n /** a:effectLst (EG_EffectProperties). `true` emits a default outer shadow; a full EffectListOptions round-trips. */\n shadow?: true | EffectListOptions;\n rightToLeft?: boolean;\n noProof?: boolean;\n dirty?: boolean;\n kumimoji?: boolean;\n alternateLanguage?: string;\n normalizeHeight?: boolean;\n bookmarkMark?: string;\n /** `@smtId` — smart tag id (ST_UnsignedInt). */\n smartTagId?: number;\n /** `@err` — spelling error flag. */\n err?: boolean;\n /** `@smtClean` — smart tag clean flag (XSD default true). */\n smtClean?: boolean;\n}\n\n// ── Run (a:r) ──\n\nexport interface TextRunOptions extends TextCharacterPropertiesOptions {\n text?: string;\n /**\n * The source carried a bare `<a:rPr/>` with no attributes or children.\n * Round-trip marker only — re-emits the empty element instead of dropping\n * it (element presence is part of the source's fidelity).\n */\n emptyProperties?: boolean;\n}\n\n// ── Bullets ──\n\n/** Shared bullet color/size/font styling (EG_TextBulletColorSizeFont). Each\n * dimension is a choice: an explicit value, a \"follows text\" toggle, or unset. */\nexport type BulletStyleOptions = {\n /** a:buClr — hex shorthand (srgbClr) or a full color choice (schemeClr with\n * transforms, sysClr, …). */\n color?: string | SolidFillOptions;\n /** a:buClrTx — bullet color follows the text run color. */\n colorFollowsText?: boolean;\n /** a:buSzPct — bullet size as a percentage of the text size (60 = 60%). */\n size?: number;\n /** a:buSzTx — bullet size follows the text run size. */\n sizeFollowsText?: boolean;\n /** a:buSzPts `@val` — bullet size in points. */\n sizePoints?: number;\n /** a:buFont `@typeface` — explicit bullet font. */\n font?: string;\n /** a:buFontTx — bullet font follows the text run font. */\n fontFollowsText?: boolean;\n};\n\nexport type BulletCharOptions = BulletStyleOptions & {\n type: \"char\";\n char?: string;\n};\n\n/**\n * Autonumbering scheme (ST_TextAutonumberScheme). Values are the XSD tokens\n * verbatim — a numbering-scheme shorthand (alphaLc = lowercase letters,\n * ParenR = right parenthesis, Db = double-byte) that has no fuller spelling\n * in the wild.\n */\nexport type AutoNumberFormat =\n | \"alphaLcParenBoth\"\n | \"alphaUcParenBoth\"\n | \"alphaLcParenR\"\n | \"alphaUcParenR\"\n | \"alphaLcPeriod\"\n | \"alphaUcPeriod\"\n | \"arabicParenBoth\"\n | \"arabicParenR\"\n | \"arabicPeriod\"\n | \"arabicPlain\"\n | \"romanLcParenBoth\"\n | \"romanUcParenBoth\"\n | \"romanLcParenR\"\n | \"romanUcParenR\"\n | \"romanLcPeriod\"\n | \"romanUcPeriod\"\n | \"circleNumDbPlain\"\n | \"circleNumWdBlackPlain\"\n | \"circleNumWdWhitePlain\"\n | \"arabicDbPeriod\"\n | \"arabicDbPlain\"\n | \"ea1ChsPeriod\"\n | \"ea1ChsPlain\"\n | \"ea1ChtPeriod\"\n | \"ea1ChtPlain\"\n | \"ea1JpnChsDbPeriod\"\n | \"ea1JpnKorPlain\"\n | \"ea1JpnKorPeriod\"\n | \"arabic1Minus\"\n | \"arabic2Minus\"\n | \"hebrew2Minus\"\n | \"thaiAlphaPeriod\"\n | \"thaiAlphaParenR\"\n | \"thaiAlphaParenBoth\"\n | \"thaiNumPeriod\"\n | \"thaiNumParenR\"\n | \"thaiNumParenBoth\"\n | \"hindiAlphaPeriod\"\n | \"hindiNumPeriod\"\n | \"hindiNumParenR\"\n | \"hindiAlpha1Period\";\n\nexport type BulletAutoNumOptions = BulletStyleOptions & {\n type: \"autoNum\";\n format?: AutoNumberFormat;\n startAt?: number;\n};\n\n/** Picture bullet (a:buBlip r:embed). `embed` is the image relationship id. */\nexport type BulletPictureOptions = BulletStyleOptions & {\n type: \"picture\";\n embed: string;\n};\n\n/** No bullet (a:buNone) — may still carry the shared color/size/font style\n * (EG_Bullet allows buClrTx/buSzTx/buFontTx before buNone). */\nexport type BulletNoneOption = BulletStyleOptions & { type: \"none\" };\n\nexport type BulletOptions =\n | BulletCharOptions\n | BulletAutoNumOptions\n | BulletPictureOptions\n | BulletNoneOption;\n\n// ── Tab stops (a:tabLst) ──\n\n/** Tab-stop alignment (ST_TextTabAlignType). */\nexport type TextTabAlignment = \"left\" | \"center\" | \"right\" | \"decimal\";\n\nexport interface TabStopOptions {\n /** a:tab `@pos` — tab stop position in EMU. */\n position?: number;\n /** a:tab `@algn` — tab alignment (l/ctr/r/dec). */\n alignment?: TextTabAlignment;\n}\n\n// ── Paragraph properties (a:pPr) ──\n\nexport interface TextParagraphPropertiesOptions {\n alignment?: TextAlignment;\n indentLevel?: number;\n /** Space after a paragraph in points (a:spcAft/a:spcPts). */\n spaceAfter?: number;\n /** Space after a paragraph as a percentage (a:spcAft/a:spcPct). */\n spaceAfterPercent?: number;\n /** Space before a paragraph in points (a:spcBef/a:spcPts). */\n spaceBefore?: number;\n /** Space before a paragraph as a percentage (a:spcBef/a:spcPct). */\n spaceBeforePercent?: number;\n bullet?: BulletOptions;\n /** Line spacing as a percentage (100 = single). */\n lineSpacingPercent?: number;\n /** Line spacing in exact points (a:lnSpc/a:spcPts). */\n lineSpacingPoints?: number;\n marginIndent?: number;\n marginRight?: number;\n defTabSize?: number;\n /** `@indent` — first-line indent (ST_TextIndent, EMU). */\n indent?: number;\n /** a:tabLst — explicit tab stops (emitted after bullets, before defRPr). */\n tabStops?: TabStopOptions[];\n /** a:defRPr — default run properties for the paragraph (CT_TextCharacterProperties). */\n defaultRunProperties?: TextCharacterPropertiesOptions;\n /** `@fontAlgn` — baseline reference (ST_TextFontAlign): \"t\" top, \"ctr\" center, \"b\" bottom, \"base\" baseline, \"auto\". */\n /** Character-to-baseline alignment (a:pPr @fontAlgn). */\n fontAlignment?: \"auto\" | \"top\" | \"center\" | \"bottom\" | \"base\";\n /** `@rtl` — paragraph right-to-left. */\n rightToLeft?: boolean;\n /** `@eaLnBrk` — East Asian line break. */\n eastAsianLineBreak?: boolean;\n /** `@latinLnBrk` — Latin line break. */\n latinLineBreak?: boolean;\n /** `@hangingPunct` — hanging punctuation. */\n hangingPunctuation?: boolean;\n /** Verbatim inner XML of a:extLst (last child per CT_TextParagraphProperties). */\n ext?: string;\n}\n\n// ── Text field (a:fld) ──\n\nexport interface TextFieldOptions {\n /** a:fld `@type` — field type token (e.g. \"datetimeFigureOut\", \"slidenum\"). */\n type: string;\n /** a:fld `@id` — GUID identifier. */\n id?: string;\n /** a:t — display text (often a placeholder such as \"‹#›\" or \"1/27/13\"). */\n text?: string;\n /** a:rPr — run properties. */\n properties?: TextCharacterPropertiesOptions;\n /** a:pPr — paragraph properties (CT_TextParagraphProperties). */\n paragraphProperties?: TextParagraphPropertiesOptions;\n}\n\n// ── Soft line break (a:br) ──\n\nexport interface TextBreakOptions {\n /** Marks a soft line break (a:br) within a paragraph's children. */\n break: true;\n properties?: TextCharacterPropertiesOptions;\n}\n\n// ── Defaults ──\n\n/** Default outline width: 1pt = 12700 EMU. */\nexport const DEFAULT_OUTLINE_WIDTH = 12700;\n/** Default shadow blur radius: ~4pt = 50800 EMU. */\nexport const DEFAULT_SHADOW_BLUR_RADIUS = 50800;\n/** Default shadow distance: ~3pt = 38100 EMU. */\nexport const DEFAULT_SHADOW_DISTANCE = 38100;\n/** Default shadow direction: 270° (degrees). */\nexport const DEFAULT_SHADOW_DIRECTION = 270;\n/** Default shadow alpha: 40% (integer percent). */\nexport const DEFAULT_SHADOW_ALPHA = 40;\n","/**\n * Text body properties for DrawingML shapes (CT_TextBodyProperties).\n *\n * Defines how text is laid out within a shape: margins, alignment, autofit,\n * vertical text, overflow, columns, and 3D. The factory + parser cover all 19\n * CT_TextBodyProperties attributes and child elements (prstTxWarp, EG_TextAutofit,\n * scene3d, EG_Text3D).\n *\n * The container tag is parameterized: PPTX/XLSX emit a:bodyPr, DOCX emits\n * wps:bodyPr. `createBodyProperties` takes an optional tagName (default a:bodyPr);\n * `bodyPropertiesDesc` is the a:bodyPr descriptor instance.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TextBodyProperties\n *\n * @module\n */\n\nimport { attr, attrBool, attrMeasure, attrNum, element, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { ReadContext, WriteContext, CustomDescriptor } from \"../../descriptor\";\nimport { convertToEmu } from \"../../util/converters\";\nimport { xsdTextAnchor, xsdTextVerticalType } from \"../../util/mappings\";\nimport type { UniversalMeasure } from \"../../util/values\";\nimport { createScene3D } from \"../three-d/scene-3d\";\nimport type { Scene3DOptions } from \"../three-d/scene-3d\";\nimport { createShape3D } from \"../three-d/shape-3d\";\nimport type { Shape3DOptions } from \"../three-d/shape-3d\";\nimport { scene3DDesc, shape3DDesc } from \"../three-d/three-d-descriptors\";\n\n// ── Enumerations ──\n\n/** Text anchoring type (ST_TextAnchoringType). */\nexport type VerticalAnchor = \"top\" | \"center\" | \"bottom\" | \"justify\" | \"distribute\";\n\n/** Text vertical overflow type (ST_TextVertOverflowType). */\nexport type TextVertOverflow = \"overflow\" | \"ellipsis\" | \"clip\";\n\n/** Text horizontal overflow type (ST_TextHorzOverflowType). */\nexport type TextHorzOverflow = \"overflow\" | \"clip\";\n\n/** Text vertical type (ST_TextVerticalType). */\nexport type TextVertical =\n | \"horizontal\"\n | \"vertical\"\n | \"vertical270\"\n | \"wordArtVertical\"\n | \"eastAsianVertical\"\n | \"mongolianVertical\"\n | \"wordArtVerticalRightToLeft\";\n\n/** Text body wrapping type (ST_TextWrappingType). */\nexport type TextBodyWrapping = \"none\" | \"square\";\n\n// ── Sub-element Options ──\n\n/** Normal autofit options (CT_TextNormalAutofit). */\nexport interface NormalAutofitOptions {\n /** Font scale percentage (e.g., 100000 = 100%). */\n fontScale?: number;\n /** Line spacing reduction percentage. */\n lnSpcReduction?: number;\n}\n\n/** Preset text warp options (CT_PresetTextShape). */\n/**\n * Preset text shape (ST_TextShapeType) — the warp geometry applied to a text\n * body (a:prstTxWarp `@prst`).\n */\nexport type TextShapePreset =\n | \"textNoShape\"\n | \"textPlain\"\n | \"textStop\"\n | \"textTriangle\"\n | \"textTriangleInverted\"\n | \"textChevron\"\n | \"textChevronInverted\"\n | \"textRingInside\"\n | \"textRingOutside\"\n | \"textArchUp\"\n | \"textArchDown\"\n | \"textCircle\"\n | \"textButton\"\n | \"textArchUpPour\"\n | \"textArchDownPour\"\n | \"textCirclePour\"\n | \"textButtonPour\"\n | \"textCurveUp\"\n | \"textCurveDown\"\n | \"textCanUp\"\n | \"textCanDown\"\n | \"textWave1\"\n | \"textWave2\"\n | \"textDoubleWave1\"\n | \"textWave4\"\n | \"textInflate\"\n | \"textDeflate\"\n | \"textInflateBottom\"\n | \"textDeflateBottom\"\n | \"textInflateTop\"\n | \"textDeflateTop\"\n | \"textDeflateInflate\"\n | \"textDeflateInflateDeflate\"\n | \"textFadeRight\"\n | \"textFadeLeft\"\n | \"textFadeUp\"\n | \"textFadeDown\"\n | \"textSlantUp\"\n | \"textSlantDown\"\n | \"textCascadeUp\"\n | \"textCascadeDown\";\n\nexport interface PresetTextShapeOptions {\n /** Preset shape type (ST_TextShapeType). */\n preset: TextShapePreset;\n /** Optional adjustment values. */\n adjustments?: { name: string; formula: string }[];\n}\n\n/** Flat text options (CT_FlatText). */\nexport interface FlatTextOptions {\n /** Z-offset in EMUs. */\n z?: number;\n}\n\n// ── Main Options ──\n\n/**\n * Options for text body properties (CT_TextBodyProperties).\n *\n * XSD content model:\n * prstTxWarp?, EG_TextAutofit?, scene3d?, EG_Text3D?\n * followed by 19 attributes.\n */\nexport interface BodyPropertiesOptions {\n rotation?: number;\n spcFirstLastPara?: boolean;\n vertOverflow?: TextVertOverflow;\n horzOverflow?: TextHorzOverflow;\n vertical?: TextVertical;\n wrap?: TextBodyWrapping;\n lIns?: number | UniversalMeasure;\n tIns?: number | UniversalMeasure;\n rIns?: number | UniversalMeasure;\n bIns?: number | UniversalMeasure;\n numCol?: number;\n spcCol?: number | UniversalMeasure;\n rtlCol?: boolean;\n fromWordArt?: boolean;\n anchor?: VerticalAnchor;\n anchorCtr?: boolean;\n forceAA?: boolean;\n upright?: boolean;\n compatLnSpc?: boolean;\n\n /** Margins shorthand. */\n margins?: {\n top?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n };\n\n prstTxWarp?: PresetTextShapeOptions;\n /** Disable autofit (EG_TextAutofit choice). */\n noAutoFit?: boolean;\n /** Normal autofit (EG_TextAutofit choice). */\n normAutofit?: NormalAutofitOptions;\n /** Shape autofit (EG_TextAutofit choice). */\n spAutoFit?: boolean;\n scene3d?: Scene3DOptions;\n sp3d?: Shape3DOptions;\n flatTx?: FlatTextOptions;\n}\n\n// ── Helpers ──\n\nconst filterAttrs = (\n options: Record<string, unknown>,\n): Record<string, string | number | boolean> | undefined => {\n const attrs: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(options)) {\n if (value !== undefined) {\n attrs[key] = value as string | number | boolean;\n }\n }\n return Object.keys(attrs).length > 0 ? attrs : undefined;\n};\n\nconst createPresetTextShape = (options: PresetTextShapeOptions): string => {\n const adjChildren: string[] = [];\n if (options.adjustments) {\n for (const adj of options.adjustments) {\n adjChildren.push(`<a:gd name=\"${adj.name}\" fmla=\"${adj.formula}\"/>`);\n }\n }\n // Word always writes the avLst child — empty when there are no overrides,\n // matching a:prstGeom's unconditional empty list.\n return element(\"a:prstTxWarp\", { prst: options.preset }, [\n element(\"a:avLst\", undefined, adjChildren),\n ]);\n};\n\n// ── Factory ──\n\n/**\n * Create a text body properties element. tagName defaults to a:bodyPr (PPTX/XLSX);\n * DOCX passes \"wps:bodyPr\".\n */\nexport const createBodyProperties = (\n options: BodyPropertiesOptions = {},\n tagName = \"a:bodyPr\",\n): string => {\n const anchor = options.anchor;\n const lIns = options.lIns ?? options.margins?.left;\n const tIns = options.tIns ?? options.margins?.top;\n const rIns = options.rIns ?? options.margins?.right;\n const bIns = options.bIns ?? options.margins?.bottom;\n\n const attrs = filterAttrs({\n rot: options.rotation,\n spcFirstLastPara: options.spcFirstLastPara,\n vertOverflow: options.vertOverflow,\n horzOverflow: options.horzOverflow,\n vert: options.vertical !== undefined ? xsdTextVerticalType.to(options.vertical) : undefined,\n wrap: options.wrap,\n lIns: lIns !== undefined ? convertToEmu(lIns) : undefined,\n tIns: tIns !== undefined ? convertToEmu(tIns) : undefined,\n rIns: rIns !== undefined ? convertToEmu(rIns) : undefined,\n bIns: bIns !== undefined ? convertToEmu(bIns) : undefined,\n numCol: options.numCol,\n spcCol: options.spcCol !== undefined ? convertToEmu(options.spcCol) : undefined,\n rtlCol: options.rtlCol,\n fromWordArt: options.fromWordArt,\n anchor: anchor !== undefined ? xsdTextAnchor.to(anchor) : undefined,\n anchorCtr: options.anchorCtr,\n forceAA: options.forceAA,\n upright: options.upright,\n compatLnSpc: options.compatLnSpc,\n });\n\n const children: string[] = [];\n if (options.prstTxWarp) children.push(createPresetTextShape(options.prstTxWarp));\n\n // EG_TextAutofit (mutually exclusive)\n if (options.noAutoFit) {\n children.push(`<a:noAutofit/>`);\n } else if (options.normAutofit) {\n const normAttrs = filterAttrs({\n fontScale: options.normAutofit.fontScale,\n lnSpcReduction: options.normAutofit.lnSpcReduction,\n });\n children.push(element(\"a:normAutofit\", normAttrs));\n } else if (options.spAutoFit) {\n children.push(`<a:spAutoFit/>`);\n }\n\n if (options.scene3d) children.push(createScene3D(options.scene3d));\n\n // EG_Text3D (mutually exclusive)\n if (options.sp3d) {\n children.push(createShape3D(options.sp3d));\n } else if (options.flatTx) {\n const flatAttrs = filterAttrs({ z: options.flatTx.z });\n children.push(element(\"a:flatTx\", flatAttrs));\n }\n\n return element(tagName, attrs, children.length > 0 ? children : undefined);\n};\n\n// ── Parse ──\n\n/** Parse a bodyPr element into BodyPropertiesOptions. */\nexport const parseBodyProperties = (el: Element, ctx: ReadContext): BodyPropertiesOptions => {\n const result: BodyPropertiesOptions = {};\n\n const rotation = attrNum(el, \"rot\");\n if (rotation !== undefined) result.rotation = rotation;\n const spcFirstLastPara = attrBool(el, \"spcFirstLastPara\");\n if (spcFirstLastPara !== undefined) result.spcFirstLastPara = spcFirstLastPara;\n const vertOverflow = attr(el, \"vertOverflow\");\n if (vertOverflow !== undefined)\n result.vertOverflow = vertOverflow as BodyPropertiesOptions[\"vertOverflow\"];\n const horzOverflow = attr(el, \"horzOverflow\");\n if (horzOverflow !== undefined)\n result.horzOverflow = horzOverflow as BodyPropertiesOptions[\"horzOverflow\"];\n const vert = attr(el, \"vert\");\n if (vert !== undefined)\n result.vertical = xsdTextVerticalType.from(vert) as BodyPropertiesOptions[\"vertical\"];\n const wrap = attr(el, \"wrap\");\n if (wrap !== undefined) result.wrap = wrap as BodyPropertiesOptions[\"wrap\"];\n const lIns = attrMeasure(el, \"lIns\");\n if (lIns !== undefined) result.lIns = lIns as number | UniversalMeasure;\n const tIns = attrMeasure(el, \"tIns\");\n if (tIns !== undefined) result.tIns = tIns as number | UniversalMeasure;\n const rIns = attrMeasure(el, \"rIns\");\n if (rIns !== undefined) result.rIns = rIns as number | UniversalMeasure;\n const bIns = attrMeasure(el, \"bIns\");\n if (bIns !== undefined) result.bIns = bIns as number | UniversalMeasure;\n const numCol = attrNum(el, \"numCol\");\n if (numCol !== undefined) result.numCol = numCol;\n const spcCol = attrNum(el, \"spcCol\");\n if (spcCol !== undefined) result.spcCol = spcCol;\n const rtlCol = attrBool(el, \"rtlCol\");\n if (rtlCol !== undefined) result.rtlCol = rtlCol;\n const fromWordArt = attrBool(el, \"fromWordArt\");\n if (fromWordArt !== undefined) result.fromWordArt = fromWordArt;\n const anchor = attr(el, \"anchor\");\n if (anchor !== undefined)\n result.anchor = xsdTextAnchor.from(anchor) as BodyPropertiesOptions[\"anchor\"];\n const anchorCtr = attrBool(el, \"anchorCtr\");\n if (anchorCtr !== undefined) result.anchorCtr = anchorCtr;\n const forceAA = attrBool(el, \"forceAA\");\n if (forceAA !== undefined) result.forceAA = forceAA;\n const upright = attrBool(el, \"upright\");\n if (upright !== undefined) result.upright = upright;\n const compatLnSpc = attrBool(el, \"compatLnSpc\");\n if (compatLnSpc !== undefined) result.compatLnSpc = compatLnSpc;\n\n // EG_TextAutofit (mutually exclusive)\n if (findChild(el, \"a:noAutofit\")) {\n result.noAutoFit = true;\n } else {\n const norm = findChild(el, \"a:normAutofit\");\n if (norm) {\n const normOpts: NormalAutofitOptions = {};\n const fontScale = attrNum(norm, \"fontScale\");\n if (fontScale !== undefined) normOpts.fontScale = fontScale;\n const lnSpcReduction = attrNum(norm, \"lnSpcReduction\");\n if (lnSpcReduction !== undefined) normOpts.lnSpcReduction = lnSpcReduction;\n result.normAutofit = normOpts;\n } else if (findChild(el, \"a:spAutoFit\")) {\n result.spAutoFit = true;\n }\n }\n\n // a:prstTxWarp (CT_PresetTextShape)\n const prstTxWarp = findChild(el, \"a:prstTxWarp\");\n if (prstTxWarp) {\n const preset = attr(prstTxWarp, \"prst\") ?? \"\";\n const avLst = findChild(prstTxWarp, \"a:avLst\");\n const adjustments: { name: string; formula: string }[] = [];\n for (const gd of avLst?.elements ?? []) {\n if (gd.type === \"element\" && gd.name === \"a:gd\") {\n adjustments.push({ name: attr(gd, \"name\") ?? \"\", formula: attr(gd, \"fmla\") ?? \"\" });\n }\n }\n result.prstTxWarp = {\n preset: preset as TextShapePreset,\n ...(adjustments.length > 0 ? { adjustments } : {}),\n };\n }\n\n // a:scene3d\n const scene3d = findChild(el, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n\n // EG_Text3D (mutually exclusive: sp3d | flatTx)\n const sp3d = findChild(el, \"a:sp3d\");\n if (sp3d) {\n result.sp3d = shape3DDesc.parse(sp3d, ctx);\n } else {\n const flatTx = findChild(el, \"a:flatTx\");\n if (flatTx) {\n const z = attrNum(flatTx, \"z\");\n result.flatTx = z !== undefined ? { z } : {};\n }\n }\n\n return result as BodyPropertiesOptions;\n};\n\n// ── Descriptor (a:bodyPr instance) ──\n\nexport const bodyPropertiesDesc: CustomDescriptor<\n BodyPropertiesOptions,\n WriteContext,\n BodyPropertiesOptions\n> = {\n kind: \"custom\",\n stringify(opts) {\n return createBodyProperties(opts);\n },\n parse(el, ctx) {\n return parseBodyProperties(el, ctx);\n },\n};\n","/**\n * RunProperties descriptor (a:rPr / CT_TextCharacterProperties).\n *\n * Promoted from PPTX so all formats share one run-properties model. The\n * hyperlink side-effect uses the core WriteContext.addHyperlink hook — no\n * format-specific cast.\n *\n * @module\n */\n\nimport { escapeXml, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport { parse, stringify } from \"../../descriptor\";\nimport { emitPercent, parsePercentAttr } from \"../../util/converters\";\nimport { xsdStrikeStyle, xsdTextCaps, xsdUnderlineStyle } from \"../../util/mappings\";\nimport { parseOnOff } from \"../../util/values\";\nimport { parseColorChoice, stringifyColorChoice } from \"../color/color-descriptors\";\nimport type { SolidFillOptions } from \"../color/solid-fill\";\nimport { effectListDesc } from \"../effects/effect-descriptors\";\nimport type { EffectListOptions } from \"../effects/effect-list\";\nimport { fillDesc, findFillChild } from \"../fill/fill-descriptors\";\nimport type { FillOptions } from \"../fill/fill-options\";\nimport type { OutlineOptions } from \"../outline/outline\";\nimport { outlineDesc, stringifyLineProperties } from \"../outline/outline-descriptors\";\nimport {\n DEFAULT_OUTLINE_WIDTH,\n DEFAULT_SHADOW_ALPHA,\n DEFAULT_SHADOW_BLUR_RADIUS,\n DEFAULT_SHADOW_DIRECTION,\n DEFAULT_SHADOW_DISTANCE,\n} from \"./types\";\nimport type { TextHyperlinkOptions, TextCharacterPropertiesOptions, TextFont } from \"./types\";\n\n/** Strip `readonly` from all properties. */\nexport type Mutable<T> = { -readonly [K in keyof T]?: T[K] };\n\n// ── Hyperlink ID counter (module-scoped) ──\n\nlet nextHyperlinkId = 1;\n\n/**\n * Register a hyperlink target on the write context and return its placeholder\n * key (\"{hlink:key}\" on the wire). Action-only hyperlinks (no url/slide) carry\n * no relationship — returns undefined. Shared by text runs and shape cNvPr\n * hyperlinks (both serialize CT_Hyperlink elements).\n */\nexport function registerHyperlink(hl: TextHyperlinkOptions, ctx: WriteContext): string | undefined {\n if (hl.url === undefined && hl.slide === undefined) return undefined;\n const key = hl.referenceId ?? `hlink_${nextHyperlinkId++}`;\n ctx.addHyperlink(key, { url: hl.url, slide: hl.slide, tooltip: hl.tooltip });\n return key;\n}\n\nexport function buildHyperlinkElement(\n tag: string,\n hl: TextHyperlinkOptions,\n key: string | undefined,\n): string {\n const attrs: string[] = [];\n // CT_Hyperlink r:id is optional — emit it only for relational targets\n // (external url or internal slide). Action-only tokens (nextslide/endshow/\n // macro/program/...) carry no r:id.\n if ((hl.url !== undefined || hl.slide !== undefined) && key !== undefined) {\n attrs.push(`r:id=\"{hlink:${key}}\"`);\n }\n // Internal slide jump takes precedence over an explicit action token.\n if (hl.slide !== undefined) {\n attrs.push('action=\"ppaction://hlinksldjump\"');\n } else if (hl.action) {\n attrs.push(`action=\"${escapeXml(hl.action)}\"`);\n }\n if (hl.tooltip) attrs.push(`tooltip=\"${escapeXml(hl.tooltip)}\"`);\n if (hl.highlightClick) attrs.push('highlightClick=\"1\"');\n if (hl.endSound) attrs.push('endSnd=\"1\"');\n if (hl.invalidUrl) attrs.push('invalidUrl=\"1\"');\n return attrs.length ? `<${tag} ${attrs.join(\" \")}/>` : `<${tag}/>`;\n}\n\nexport function readHyperlink(el: XmlElement, ctx: ReadContext): TextHyperlinkOptions {\n const hl: Mutable<TextHyperlinkOptions> = {};\n const rId = el.attributes?.[\"r:id\"];\n const action =\n el.attributes?.[\"action\"] !== undefined ? String(el.attributes[\"action\"]) : undefined;\n if (rId) {\n const ridStr = String(rId);\n const target = ctx.resolveRelationship(ridStr);\n if (target) {\n // Internal slide jump: r:id resolves to slides/slideN.xml.\n const slideMatch = target.match(/slide(\\d+)\\.xml$/);\n if (slideMatch && action === \"ppaction://hlinksldjump\") {\n hl.slide = Number(slideMatch[1]);\n } else {\n hl.url = target;\n }\n }\n const m = ridStr.match(/^\\{hlink:(.+)\\}$/);\n if (m) hl.referenceId = m[1];\n }\n if (el.attributes?.[\"tooltip\"]) hl.tooltip = String(el.attributes[\"tooltip\"]);\n // Preserve explicit action only when it isn't the synthesized slide-jump token\n // (slide already captures that intent).\n if (action && action !== \"ppaction://hlinksldjump\") hl.action = action;\n if (el.attributes?.[\"highlightClick\"]) hl.highlightClick = true;\n if (el.attributes?.[\"endSnd\"]) hl.endSound = true;\n if (el.attributes?.[\"invalidUrl\"]) hl.invalidUrl = true;\n return hl as TextHyperlinkOptions;\n}\n\n// ── CT_TextFont helpers (a:latin / a:ea / a:cs / a:sym) ──\n\nfunction stringifyFontElement(tag: string, font: TextFont): string {\n if (typeof font === \"string\") return `<${tag} typeface=\"${escapeXml(font)}\"/>`;\n const attrs = [`typeface=\"${escapeXml(font.typeface)}\"`];\n if (font.panose) attrs.push(`panose=\"${font.panose}\"`);\n if (font.pitchFamily !== undefined) attrs.push(`pitchFamily=\"${font.pitchFamily}\"`);\n if (font.charset !== undefined) attrs.push(`charset=\"${font.charset}\"`);\n return `<${tag} ${attrs.join(\" \")}/>`;\n}\n\nfunction parseFontElement(el: XmlElement | undefined): TextFont | undefined {\n if (!el) return undefined;\n const tf = el.attributes?.[\"typeface\"];\n if (tf === undefined) return undefined;\n const typeface = String(tf);\n const panose = el.attributes?.[\"panose\"];\n const pitchFamily = el.attributes?.[\"pitchFamily\"];\n const charset = el.attributes?.[\"charset\"];\n if (panose === undefined && pitchFamily === undefined && charset === undefined) {\n return typeface;\n }\n const font: { typeface: string; panose?: string; pitchFamily?: number; charset?: number } = {\n typeface,\n };\n if (panose !== undefined) font.panose = String(panose);\n if (pitchFamily !== undefined) font.pitchFamily = Number(pitchFamily);\n if (charset !== undefined) font.charset = Number(charset);\n return font;\n}\n\n/**\n * Serialize CT_TextCharacterProperties under a caller-chosen root tag\n * (a:rPr / a:defRPr / a:endParaRPr — same content model).\n */\nexport function stringifyRunProperties(\n tag: string,\n opts: TextCharacterPropertiesOptions,\n ctx: WriteContext,\n): string {\n // Side-effect: register hyperlinks (click + hover). Only relational targets\n // (url/slide) need a relationship; action-only hyperlinks carry no r:id.\n let hyperlinkKey: string | undefined;\n if (opts.hyperlink) {\n hyperlinkKey = registerHyperlink(opts.hyperlink, ctx);\n }\n let mouseoverKey: string | undefined;\n if (opts.mouseoverHyperlink) {\n mouseoverKey = registerHyperlink(opts.mouseoverHyperlink, ctx);\n }\n\n const attrParts: string[] = [];\n if (opts.size) attrParts.push(`sz=\"${Math.round(opts.size * 100)}\"`);\n if (opts.bold !== undefined) attrParts.push(`b=\"${opts.bold ? 1 : 0}\"`);\n if (opts.italic !== undefined) attrParts.push(`i=\"${opts.italic ? 1 : 0}\"`);\n if (opts.underline) attrParts.push(`u=\"${xsdUnderlineStyle.to(opts.underline)}\"`);\n if (opts.lang) attrParts.push(`lang=\"${opts.lang}\"`);\n if (opts.strike) attrParts.push(`strike=\"${xsdStrikeStyle.to(opts.strike)}\"`);\n if (opts.baseline !== undefined) attrParts.push(`baseline=\"${emitPercent(opts.baseline)}\"`);\n if (opts.capitalization) attrParts.push(`cap=\"${xsdTextCaps.to(opts.capitalization)}\"`);\n if (opts.spacing !== undefined) attrParts.push(`spc=\"${Math.round(opts.spacing * 100)}\"`);\n if (opts.kern !== undefined) attrParts.push(`kern=\"${Math.round(opts.kern * 100)}\"`);\n if (opts.noProof !== undefined) attrParts.push(`noProof=\"${opts.noProof ? 1 : 0}\"`);\n if (opts.dirty !== undefined) attrParts.push(`dirty=\"${opts.dirty ? 1 : 0}\"`);\n if (opts.kumimoji !== undefined) attrParts.push(`kumimoji=\"${opts.kumimoji ? 1 : 0}\"`);\n if (opts.alternateLanguage) attrParts.push(`altLang=\"${opts.alternateLanguage}\"`);\n if (opts.normalizeHeight !== undefined)\n attrParts.push(`normalizeH=\"${opts.normalizeHeight ? 1 : 0}\"`);\n if (opts.bookmarkMark) attrParts.push(`bmk=\"${opts.bookmarkMark}\"`);\n if (opts.smartTagId) attrParts.push(`smtId=\"${opts.smartTagId}\"`);\n if (opts.err !== undefined) attrParts.push(`err=\"${opts.err ? 1 : 0}\"`);\n if (opts.smtClean !== undefined) attrParts.push(`smtClean=\"${opts.smtClean ? 1 : 0}\"`);\n\n const attrStr = attrParts.length ? \" \" + attrParts.join(\" \") : \"\";\n\n const parts: string[] = [];\n\n // XSD order: ln -> fill -> effect -> latin/ea/cs/sym -> hlinkClick -> rtl\n if (opts.outline !== undefined) {\n const outlineOpts: OutlineOptions =\n opts.outline === true\n ? { width: DEFAULT_OUTLINE_WIDTH, type: \"solidFill\", color: { value: \"000000\" } }\n : opts.outline;\n const outlineXml = stringify(outlineDesc, outlineOpts, ctx);\n if (outlineXml) parts.push(outlineXml);\n }\n\n if (opts.fill !== undefined) {\n const fillXml = stringify(fillDesc, opts.fill, ctx);\n if (fillXml) parts.push(fillXml);\n }\n\n if (opts.shadow !== undefined) {\n const effectOpts: EffectListOptions =\n opts.shadow === true\n ? {\n outerShadow: {\n blurRadius: DEFAULT_SHADOW_BLUR_RADIUS,\n distance: DEFAULT_SHADOW_DISTANCE,\n direction: DEFAULT_SHADOW_DIRECTION,\n color: { value: \"000000\", transforms: { alpha: DEFAULT_SHADOW_ALPHA } },\n },\n }\n : opts.shadow;\n const effectXml = stringify(effectListDesc, effectOpts, ctx);\n if (effectXml) parts.push(effectXml);\n }\n\n // XSD order: highlight (CT_Color) comes after effects, before fonts.\n if (opts.highlight !== undefined) {\n const hlXml = stringifyColorChoice(opts.highlight, ctx);\n if (hlXml) parts.push(`<a:highlight>${hlXml}</a:highlight>`);\n }\n\n // EG_TextUnderlineLine / EG_TextUnderlineFill — after highlight, before fonts.\n if (opts.underlineLine !== undefined) {\n if (opts.underlineLine === true) {\n parts.push(\"<a:uLnTx/>\");\n } else {\n // a:uLn is itself a CT_LineProperties — same content, different root tag.\n const uLnXml = stringifyLineProperties(\"a:uLn\", opts.underlineLine, ctx);\n if (uLnXml) parts.push(uLnXml);\n }\n }\n if (opts.underlineFill !== undefined) {\n if (opts.underlineFill === true) {\n parts.push(\"<a:uFillTx/>\");\n } else {\n const uFillXml = stringify(fillDesc, opts.underlineFill, ctx);\n if (uFillXml) parts.push(`<a:uFill>${uFillXml}</a:uFill>`);\n }\n }\n\n if (opts.font !== undefined) {\n const scripts: {\n latin?: TextFont;\n eastAsia?: TextFont;\n complexScript?: TextFont;\n symbol?: TextFont;\n } = typeof opts.font === \"string\" ? { latin: opts.font, eastAsia: opts.font } : opts.font;\n if (scripts.latin) parts.push(stringifyFontElement(\"a:latin\", scripts.latin));\n if (scripts.eastAsia) parts.push(stringifyFontElement(\"a:ea\", scripts.eastAsia));\n if (scripts.complexScript) parts.push(stringifyFontElement(\"a:cs\", scripts.complexScript));\n if (scripts.symbol) parts.push(stringifyFontElement(\"a:sym\", scripts.symbol));\n }\n\n if (opts.hyperlink) {\n parts.push(buildHyperlinkElement(\"a:hlinkClick\", opts.hyperlink, hyperlinkKey));\n }\n if (opts.mouseoverHyperlink) {\n parts.push(buildHyperlinkElement(\"a:hlinkMouseOver\", opts.mouseoverHyperlink, mouseoverKey));\n }\n\n if (opts.rightToLeft !== undefined) {\n parts.push(`<a:rtl val=\"${opts.rightToLeft ? 1 : 0}\"/>`);\n }\n\n if (attrParts.length === 0 && parts.length === 0) return \"\";\n\n if (parts.length === 0) return `<${tag}${attrStr}/>`;\n return `<${tag}${attrStr}>${parts.join(\"\")}</${tag}>`;\n}\n\nexport const runPropertiesDesc: CustomDescriptor<TextCharacterPropertiesOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n return stringifyRunProperties(\"a:rPr\", opts, ctx);\n },\n\n parse(el, _ctx) {\n const result: Mutable<TextCharacterPropertiesOptions> = {};\n\n // nativeTypeAttributes (opc parser) coerces boolean attribute values between\n // string/number/boolean forms; parseOnOff accepts all of them.\n const isOn = (raw: string | number | boolean | undefined): boolean => parseOnOff(raw) ?? false;\n\n if (el.attributes) {\n if (el.attributes[\"sz\"] !== undefined) result.size = Number(el.attributes[\"sz\"]) / 100;\n if (el.attributes[\"b\"] !== undefined) result.bold = isOn(el.attributes[\"b\"]);\n if (el.attributes[\"i\"] !== undefined) result.italic = isOn(el.attributes[\"i\"]);\n if (el.attributes[\"u\"] !== undefined)\n result.underline = xsdUnderlineStyle.from(\n String(el.attributes[\"u\"]),\n ) as TextCharacterPropertiesOptions[\"underline\"];\n if (el.attributes[\"lang\"] !== undefined) result.lang = String(el.attributes[\"lang\"]);\n if (el.attributes[\"strike\"] !== undefined)\n result.strike = xsdStrikeStyle.from(\n String(el.attributes[\"strike\"]),\n ) as TextCharacterPropertiesOptions[\"strike\"];\n if (el.attributes[\"baseline\"] !== undefined) {\n result.baseline = parsePercentAttr(el.attributes[\"baseline\"])!;\n }\n if (el.attributes[\"cap\"] !== undefined)\n result.capitalization = xsdTextCaps.from(\n String(el.attributes[\"cap\"]),\n ) as TextCharacterPropertiesOptions[\"capitalization\"];\n if (el.attributes[\"spc\"] !== undefined) result.spacing = Number(el.attributes[\"spc\"]) / 100;\n if (el.attributes[\"noProof\"] !== undefined) result.noProof = isOn(el.attributes[\"noProof\"]);\n if (el.attributes[\"dirty\"] !== undefined) result.dirty = isOn(el.attributes[\"dirty\"]);\n if (el.attributes[\"kumimoji\"] !== undefined)\n result.kumimoji = isOn(el.attributes[\"kumimoji\"]);\n if (el.attributes[\"altLang\"] !== undefined)\n result.alternateLanguage = String(el.attributes[\"altLang\"]);\n if (el.attributes[\"normalizeH\"] !== undefined)\n result.normalizeHeight = isOn(el.attributes[\"normalizeH\"]);\n if (el.attributes[\"bmk\"] !== undefined) result.bookmarkMark = String(el.attributes[\"bmk\"]);\n if (el.attributes[\"smtId\"] !== undefined) result.smartTagId = Number(el.attributes[\"smtId\"]);\n if (el.attributes[\"kern\"] !== undefined) result.kern = Number(el.attributes[\"kern\"]) / 100;\n if (el.attributes[\"err\"] !== undefined) result.err = isOn(el.attributes[\"err\"]);\n if (el.attributes[\"smtClean\"] !== undefined)\n result.smtClean = isOn(el.attributes[\"smtClean\"]);\n }\n\n // Outline — full CT_LineProperties round-trip\n const ln = findChild(el, \"a:ln\");\n if (ln) result.outline = parse(outlineDesc, ln, _ctx) as OutlineOptions;\n\n // Fill — CT_TextCharacterProperties references the full EG_FillProperties\n // choice, so accept all six fill kinds (grpFill/blipFill included).\n const fillChild = findFillChild(el);\n if (fillChild) {\n result.fill = parse(fillDesc, fillChild, _ctx) as FillOptions;\n }\n\n // Shadow — full EG_EffectProperties round-trip\n const effectLst = findChild(el, \"a:effectLst\");\n if (effectLst) result.shadow = parse(effectListDesc, effectLst, _ctx) as EffectListOptions;\n\n // Highlight (CT_Color)\n const highlight = findChild(el, \"a:highlight\");\n if (highlight) result.highlight = parseColorChoice(highlight, _ctx) as SolidFillOptions;\n\n // Underline line/fill (EG_TextUnderlineLine / EG_TextUnderlineFill)\n const uLnTx = findChild(el, \"a:uLnTx\");\n if (uLnTx) result.underlineLine = true;\n else {\n const uLn = findChild(el, \"a:uLn\");\n if (uLn) result.underlineLine = parse(outlineDesc, uLn, _ctx) as OutlineOptions;\n }\n const uFillTx = findChild(el, \"a:uFillTx\");\n if (uFillTx) result.underlineFill = true;\n else {\n const uFill = findChild(el, \"a:uFill\");\n if (uFill) result.underlineFill = parse(fillDesc, uFill, _ctx) as FillOptions;\n }\n\n // Font — latin/ea/cs/sym (CT_TextFont). Collapse to a string when only latin\n // and ea share the same typeface (the common case); otherwise the full object.\n const latinFont = parseFontElement(findChild(el, \"a:latin\"));\n const eaFont = parseFontElement(findChild(el, \"a:ea\"));\n const csFont = parseFontElement(findChild(el, \"a:cs\"));\n const symFont = parseFontElement(findChild(el, \"a:sym\"));\n if (\n latinFont &&\n eaFont &&\n !csFont &&\n !symFont &&\n typeof latinFont === \"string\" &&\n typeof eaFont === \"string\" &&\n latinFont === eaFont\n ) {\n result.font = latinFont;\n } else if (latinFont || eaFont || csFont || symFont) {\n const font: {\n latin?: TextFont;\n eastAsia?: TextFont;\n complexScript?: TextFont;\n symbol?: TextFont;\n } = {};\n if (latinFont) font.latin = latinFont;\n if (eaFont) font.eastAsia = eaFont;\n if (csFont) font.complexScript = csFont;\n if (symFont) font.symbol = symFont;\n result.font = font;\n }\n\n // Hyperlinks (click + hover)\n const hlinkClick = findChild(el, \"a:hlinkClick\");\n if (hlinkClick) result.hyperlink = readHyperlink(hlinkClick, _ctx);\n const hlinkMouseOver = findChild(el, \"a:hlinkMouseOver\");\n if (hlinkMouseOver) result.mouseoverHyperlink = readHyperlink(hlinkMouseOver, _ctx);\n\n // RTL\n const rtl = findChild(el, \"a:rtl\");\n if (rtl) result.rightToLeft = isOn(rtl.attributes?.[\"val\"]);\n\n return result as TextCharacterPropertiesOptions;\n },\n};\n","/**\n * TextRun descriptor (a:r / CT_RegularTextRun).\n *\n * @module\n */\n\nimport { findChild, escapeXml } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { runPropertiesDesc } from \"./run-properties\";\nimport type { Mutable } from \"./run-properties\";\nimport type { TextRunOptions } from \"./types\";\n\n/**\n * Stringify a text-only run — `<a:r><a:t>…</a:t></a:r>` with no `a:rPr`.\n * Shared with the paragraph descriptor, whose string-children shorthand\n * expands to exactly this and would otherwise pay a full run-properties\n * scan plus a throwaway `{ text }` object per child.\n */\nexport function stringifyTextRun(text: string): string {\n return `<a:r><a:t>${escapeXml(text)}</a:t></a:r>`;\n}\n\nexport const textRunDesc: CustomDescriptor<TextRunOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n let body = runPropertiesDesc.stringify(opts, ctx) ?? \"\";\n // A bare <a:rPr/> is presence, not nothing — keep the empty element.\n if (!body && opts.emptyProperties) body = \"<a:rPr/>\";\n // Empty string keeps an explicit <a:t/> — sources carry empty text runs\n // (a:br neighbors) and round-trip must not drop the element.\n if (opts.text !== undefined) {\n return body\n ? `<a:r>${body}<a:t>${escapeXml(opts.text)}</a:t></a:r>`\n : stringifyTextRun(opts.text);\n }\n return body ? `<a:r>${body}</a:r>` : \"<a:r/>\";\n },\n\n parse(el, _ctx) {\n const result: Mutable<TextRunOptions> = {};\n\n const rPr = findChild(el, \"a:rPr\");\n if (rPr) {\n const props = runPropertiesDesc.parse(rPr, _ctx);\n Object.assign(result, props);\n if (Object.keys(props).length === 0) result.emptyProperties = true;\n }\n\n const t = findChild(el, \"a:t\");\n if (t) {\n result.text = (t.elements ?? [])\n .filter((e) => e.type === \"text\")\n .map((e) => e.text ?? \"\")\n .join(\"\");\n }\n\n return result as TextRunOptions;\n },\n};\n","/**\n * Paragraph descriptor (a:p / CT_TextParagraph) plus paragraph-properties,\n * text-field, and line-break helpers.\n *\n * Promoted verbatim from PPTX — the fresh-paragraph default lang marker,\n * a:lstStyle-always-emit, and single-run text shorthand behaviors are\n * load-bearing for round-trip fidelity and must carry over unchanged.\n *\n * @module\n */\n\nimport { findChild, escapeXml, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport { emitPercent, parsePercent } from \"../../util/converters\";\nimport { xsdFontAlignment, xsdTextAlign, xsdTextTabAlignment } from \"../../util/mappings\";\nimport { parseOnOff, stripColorHashPrefix } from \"../../util/values\";\nimport { emitColorChoice, isPlainRgbColor, parseColorChoice } from \"../color/color-descriptors\";\nimport { stringifyTextRun, textRunDesc } from \"./run\";\nimport { runPropertiesDesc, stringifyRunProperties } from \"./run-properties\";\nimport type { Mutable } from \"./run-properties\";\nimport type {\n BulletAutoNumOptions,\n BulletCharOptions,\n BulletOptions,\n BulletPictureOptions,\n BulletStyleOptions,\n TextParagraphPropertiesOptions,\n TextRunOptions,\n TextCharacterPropertiesOptions,\n TabStopOptions,\n TextAlignment,\n TextTabAlignment,\n TextFieldOptions,\n TextBreakOptions,\n} from \"./types\";\n\n/** Descriptor-layer paragraph accumulator (a:p). */\nexport interface ParagraphDescriptorOptions {\n text?: string;\n properties?: TextParagraphPropertiesOptions;\n children?: (TextRunOptions | TextFieldOptions | TextBreakOptions | string)[];\n /**\n * End-paragraph run properties (a:endParaRPr). Fresh paragraphs emit a\n * default lang marker; a parsed source preserves its value; false omits it.\n */\n endParagraphProperties?: TextCharacterPropertiesOptions | false;\n}\n\n// ── Paragraph properties helper (a:pPr / a:lvlNpPr / a:defPPr) ──\n\n/**\n * Serialize CT_TextParagraphProperties under a caller-chosen root tag. The\n * same content model backs a:pPr in paragraphs and a:lvlNpPr/a:defPPr in\n * list styles. Attribute order follows the XSD declaration order so MS\n * Office-authored bytes re-emit unchanged.\n */\nexport function stringifyParagraphPropertiesElement(\n tag: string,\n options: TextParagraphPropertiesOptions,\n ctx: WriteContext,\n): string {\n const children: string[] = [];\n\n // XSD attribute order: marL, marR, lvl, indent, algn, defTabSz, rtl,\n // eaLnBrk, fontAlgn, latinLnBrk, hangingPunct.\n const attrs: string[] = [];\n if (options.marginIndent !== undefined) attrs.push(`marL=\"${options.marginIndent}\"`);\n if (options.marginRight !== undefined) attrs.push(`marR=\"${options.marginRight}\"`);\n if (options.indentLevel !== undefined) attrs.push(`lvl=\"${options.indentLevel}\"`);\n if (options.indent !== undefined) attrs.push(`indent=\"${options.indent}\"`);\n if (options.alignment) attrs.push(`algn=\"${xsdTextAlign.to(options.alignment)}\"`);\n if (options.defTabSize !== undefined) attrs.push(`defTabSz=\"${options.defTabSize}\"`);\n if (options.rightToLeft !== undefined) attrs.push(`rtl=\"${options.rightToLeft ? 1 : 0}\"`);\n if (options.eastAsianLineBreak !== undefined)\n attrs.push(`eaLnBrk=\"${options.eastAsianLineBreak ? 1 : 0}\"`);\n if (options.fontAlignment) attrs.push(`fontAlgn=\"${xsdFontAlignment.to(options.fontAlignment)}\"`);\n if (options.latinLineBreak !== undefined)\n attrs.push(`latinLnBrk=\"${options.latinLineBreak ? 1 : 0}\"`);\n if (options.hangingPunctuation !== undefined)\n attrs.push(`hangingPunct=\"${options.hangingPunctuation ? 1 : 0}\"`);\n\n // Line spacing — a percentage and a points value are mutually exclusive\n // (a:lnSpc carries a single spcPct | spcPts child).\n if (options.lineSpacingPercent !== undefined) {\n children.push(\n `<a:lnSpc><a:spcPct val=\"${emitPercent(options.lineSpacingPercent)}\"/></a:lnSpc>`,\n );\n } else if (options.lineSpacingPoints !== undefined) {\n children.push(\n `<a:lnSpc><a:spcPts val=\"${Math.round(options.lineSpacingPoints * 100)}\"/></a:lnSpc>`,\n );\n }\n\n // Spacing before/after (XSD CT_TextParagraphProperties order: spcBef, spcAft).\n // A percentage and a points value are mutually exclusive per XSD (spcPct | spcPts).\n if (options.spaceBeforePercent !== undefined) {\n children.push(\n `<a:spcBef><a:spcPct val=\"${emitPercent(options.spaceBeforePercent)}\"/></a:spcBef>`,\n );\n } else if (options.spaceBefore !== undefined) {\n children.push(\n `<a:spcBef><a:spcPts val=\"${Math.round(options.spaceBefore * 100)}\"/></a:spcBef>`,\n );\n }\n if (options.spaceAfterPercent !== undefined) {\n children.push(\n `<a:spcAft><a:spcPct val=\"${emitPercent(options.spaceAfterPercent)}\"/></a:spcAft>`,\n );\n } else if (options.spaceAfter !== undefined) {\n children.push(`<a:spcAft><a:spcPts val=\"${Math.round(options.spaceAfter * 100)}\"/></a:spcAft>`);\n }\n\n // Bullets\n if (options.bullet) {\n children.push(...stringifyBullet(options.bullet));\n }\n\n // Tab stops (after bullets, before defRPr)\n if (options.tabStops) {\n children.push(stringifyTabStops(options.tabStops));\n }\n\n // Default run properties — after tabLst (CT_TextParagraphProperties).\n // Presence-based: an explicitly empty object still emits <a:defRPr/> (the\n // otherStyle defPPr default carries one).\n if (options.defaultRunProperties !== undefined) {\n const rPr = stringifyRunProperties(\"a:defRPr\", options.defaultRunProperties, ctx);\n children.push(rPr || \"<a:defRPr/>\");\n }\n\n // a:extLst — last child.\n if (options.ext) children.push(`<a:extLst>${options.ext}</a:extLst>`);\n\n if (attrs.length === 0 && children.length === 0) return \"\";\n\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n if (children.length === 0) return `<${tag}${attrStr}/>`;\n return `<${tag}${attrStr}>${children.join(\"\")}</${tag}>`;\n}\n\nfunction stringifyParagraphProperties(\n options: TextParagraphPropertiesOptions,\n ctx: WriteContext,\n): string {\n return stringifyParagraphPropertiesElement(\"a:pPr\", options, ctx);\n}\n\nfunction stringifyBullet(options: BulletOptions): string[] {\n const parts: string[] = [];\n\n // Color: buClrTx | buClr\n if (options.colorFollowsText) {\n parts.push(\"<a:buClrTx/>\");\n } else if (options.color) {\n const color =\n typeof options.color === \"string\"\n ? emitColorChoice({ value: stripColorHashPrefix(options.color) })\n : emitColorChoice(options.color);\n parts.push(`<a:buClr>${color}</a:buClr>`);\n }\n\n // Size: buSzTx | buSzPts | buSzPct\n if (options.sizeFollowsText) {\n parts.push(\"<a:buSzTx/>\");\n } else if (options.sizePoints !== undefined) {\n parts.push(`<a:buSzPts val=\"${Math.round(options.sizePoints * 100)}\"/>`);\n } else if (options.size !== undefined) {\n // ST_TextBulletSizePercent is an \"N%\" string per the XSD pattern (25-400);\n // the union's per-mille-integer branch is what Office writes but the XSD\n // loader here only enforces the pattern, so emit the string form.\n parts.push(`<a:buSzPct val=\"${Math.round(options.size)}%\"/>`);\n }\n\n // Font: buFontTx | buFont. No fresh default — Office files omit buFont when\n // the bullet follows the paragraph font, and a synthesized one would not\n // round-trip.\n if (options.fontFollowsText) {\n parts.push(\"<a:buFontTx/>\");\n } else if (options.font !== undefined) {\n parts.push(\n `<a:buFont typeface=\"${options.font}\" panose=\"020B0604020202020204\" pitchFamily=\"34\" charset=\"0\"/>`,\n );\n }\n\n // Bullet type: buNone | buChar | buAutoNum | buBlip\n if (options.type === \"none\") {\n parts.push(\"<a:buNone/>\");\n } else if (options.type === \"char\") {\n parts.push(`<a:buChar char=\"${escapeXml(options.char ?? \"•\")}\"/>`);\n } else if (options.type === \"autoNum\") {\n const buAttrs: string[] = [`type=\"${options.format ?? \"arabicPeriod\"}\"`];\n if (options.startAt !== undefined) buAttrs.push(`startAt=\"${options.startAt}\"`);\n parts.push(`<a:buAutoNum ${buAttrs.join(\" \")}/>`);\n } else if (options.type === \"picture\") {\n // a:blip @r:embed must name a relationship the host part owns — without\n // one there is no image to bullet with, so the element is skipped\n if (options.embed) {\n parts.push(`<a:buBlip><a:blip r:embed=\"${options.embed}\"/></a:buBlip>`);\n }\n }\n\n return parts;\n}\n\nfunction stringifyTabStops(stops: TabStopOptions[]): string {\n const tabs = stops.map((t) => {\n const attrs: string[] = [];\n if (t.position !== undefined) attrs.push(`pos=\"${t.position}\"`);\n if (t.alignment) attrs.push(`algn=\"${xsdTextTabAlignment.to(t.alignment)}\"`);\n return `<a:tab${attrs.length ? \" \" + attrs.join(\" \") : \"\"}/>`;\n });\n if (tabs.length === 0) return \"<a:tabLst/>\";\n return `<a:tabLst>${tabs.join(\"\")}</a:tabLst>`;\n}\n\nexport function readParagraphProperties(\n el: XmlElement,\n ctx: ReadContext,\n): Mutable<TextParagraphPropertiesOptions> {\n const result: Mutable<TextParagraphPropertiesOptions> = {};\n\n if (el.attributes) {\n if (el.attributes[\"algn\"] !== undefined)\n result.alignment = xsdTextAlign.from(String(el.attributes[\"algn\"])) as TextAlignment;\n if (el.attributes[\"lvl\"] !== undefined) result.indentLevel = Number(el.attributes[\"lvl\"]);\n if (el.attributes[\"marL\"] !== undefined) result.marginIndent = Number(el.attributes[\"marL\"]);\n if (el.attributes[\"marR\"] !== undefined) result.marginRight = Number(el.attributes[\"marR\"]);\n if (el.attributes[\"indent\"] !== undefined) result.indent = Number(el.attributes[\"indent\"]);\n if (el.attributes[\"defTabSz\"] !== undefined)\n result.defTabSize = Number(el.attributes[\"defTabSz\"]);\n if (el.attributes[\"fontAlgn\"] !== undefined)\n result.fontAlignment = xsdFontAlignment.from(\n String(el.attributes[\"fontAlgn\"]),\n ) as TextParagraphPropertiesOptions[\"fontAlignment\"];\n if (el.attributes[\"rtl\"] !== undefined)\n result.rightToLeft = parseOnOff(el.attributes[\"rtl\"]) ?? false;\n if (el.attributes[\"eaLnBrk\"] !== undefined)\n result.eastAsianLineBreak = parseOnOff(el.attributes[\"eaLnBrk\"]) ?? false;\n if (el.attributes[\"latinLnBrk\"] !== undefined)\n result.latinLineBreak = parseOnOff(el.attributes[\"latinLnBrk\"]) ?? false;\n if (el.attributes[\"hangingPunct\"] !== undefined)\n result.hangingPunctuation = parseOnOff(el.attributes[\"hangingPunct\"]) ?? false;\n }\n\n // Line spacing\n const lnSpc = findChild(el, \"a:lnSpc\");\n if (lnSpc) {\n const spcPct = findChild(lnSpc, \"a:spcPct\");\n if (spcPct?.attributes?.[\"val\"] !== undefined) {\n result.lineSpacingPercent = parsePercent(Number(spcPct.attributes[\"val\"]));\n }\n const spcPts = findChild(lnSpc, \"a:spcPts\");\n if (spcPts?.attributes?.[\"val\"] !== undefined) {\n result.lineSpacingPoints = Number(spcPts.attributes[\"val\"]) / 100;\n }\n }\n\n // Spacing after/before — each is a spcPct | spcPts choice\n const spcAft = findChild(el, \"a:spcAft\");\n if (spcAft) {\n const pct = findChild(spcAft, \"a:spcPct\");\n if (pct?.attributes?.[\"val\"] !== undefined) {\n result.spaceAfterPercent = parsePercent(Number(pct.attributes[\"val\"]));\n } else {\n const pts = findChild(spcAft, \"a:spcPts\");\n if (pts?.attributes?.[\"val\"] !== undefined)\n result.spaceAfter = Number(pts.attributes[\"val\"]) / 100;\n }\n }\n\n const spcBef = findChild(el, \"a:spcBef\");\n if (spcBef) {\n const pct = findChild(spcBef, \"a:spcPct\");\n if (pct?.attributes?.[\"val\"] !== undefined) {\n result.spaceBeforePercent = parsePercent(Number(pct.attributes[\"val\"]));\n } else {\n const pts = findChild(spcBef, \"a:spcPts\");\n if (pts?.attributes?.[\"val\"] !== undefined)\n result.spaceBefore = Number(pts.attributes[\"val\"]) / 100;\n }\n }\n\n // Bullets\n const buNone = findChild(el, \"a:buNone\");\n {\n const buChar = findChild(el, \"a:buChar\");\n const buAutoNum = findChild(el, \"a:buAutoNum\");\n const buBlip = findChild(el, \"a:buBlip\");\n if (buChar || buAutoNum || buBlip || buNone) {\n // Shared color/size/font style — each dimension is a choice.\n const style: Mutable<BulletStyleOptions> = {};\n if (findChild(el, \"a:buClrTx\")) {\n style.colorFollowsText = true;\n } else {\n const buClr = findChild(el, \"a:buClr\");\n if (buClr) {\n const parsed = parseColorChoice(buClr, ctx);\n if (parsed && Object.keys(parsed).length > 0) {\n style.color = isPlainRgbColor(parsed) ? (parsed as { value: string }).value : parsed;\n }\n }\n }\n if (findChild(el, \"a:buSzTx\")) {\n style.sizeFollowsText = true;\n } else {\n const buSzPts = findChild(el, \"a:buSzPts\");\n if (buSzPts?.attributes?.[\"val\"]) {\n style.sizePoints = Number(buSzPts.attributes[\"val\"]) / 100;\n } else {\n const buSzPct = findChild(el, \"a:buSzPct\");\n if (buSzPct?.attributes?.[\"val\"]) {\n // Per-mille integer (\"60000\" = 60%) is what Office writes; the\n // XSD's \"75%\"-string form carries the percentage directly.\n const raw = String(buSzPct.attributes[\"val\"]);\n const num = Number(raw.replace(\"%\", \"\"));\n style.size = raw.includes(\"%\") ? num : num / 1000;\n }\n }\n }\n if (findChild(el, \"a:buFontTx\")) {\n style.fontFollowsText = true;\n } else {\n const buFont = findChild(el, \"a:buFont\");\n if (buFont?.attributes?.[\"typeface\"]) style.font = String(buFont.attributes[\"typeface\"]);\n }\n\n if (buNone) {\n result.bullet = { type: \"none\", ...style };\n } else if (buBlip) {\n const blip = findChild(buBlip, \"a:blip\");\n result.bullet = {\n type: \"picture\",\n embed: String(blip?.attributes?.[\"r:embed\"] ?? \"\"),\n ...style,\n } as BulletPictureOptions;\n } else if (buChar) {\n const bullet: Mutable<BulletCharOptions> = { type: \"char\", ...style };\n if (buChar.attributes?.[\"char\"]) bullet.char = String(buChar.attributes[\"char\"]);\n result.bullet = bullet as BulletCharOptions;\n } else {\n const bullet: Mutable<BulletAutoNumOptions> = { type: \"autoNum\", ...style };\n if (buAutoNum!.attributes?.[\"type\"])\n bullet.format = String(buAutoNum!.attributes[\"type\"]) as BulletAutoNumOptions[\"format\"];\n if (buAutoNum!.attributes?.[\"startAt\"] !== undefined)\n bullet.startAt = Number(buAutoNum!.attributes[\"startAt\"]);\n result.bullet = bullet as BulletAutoNumOptions;\n }\n }\n }\n\n // Tab stops (after bullets, before defRPr)\n const tabLst = findChild(el, \"a:tabLst\");\n if (tabLst) {\n const tabs: TabStopOptions[] = [];\n for (const child of tabLst.elements ?? []) {\n if (child.name === \"a:tab\") {\n const tab: Mutable<TabStopOptions> = {};\n if (child.attributes?.[\"pos\"] !== undefined) tab.position = Number(child.attributes[\"pos\"]);\n if (child.attributes?.[\"algn\"] !== undefined)\n tab.alignment = xsdTextTabAlignment.from(\n String(child.attributes[\"algn\"]),\n ) as TextTabAlignment;\n tabs.push(tab);\n }\n }\n // Keep an explicit empty element — sources often carry a bare <a:tabLst/>.\n result.tabStops = tabs;\n }\n\n // Default run properties — after tabLst (CT_TextParagraphProperties).\n const defRPr = findChild(el, \"a:defRPr\");\n if (defRPr) {\n result.defaultRunProperties = runPropertiesDesc.parse(\n defRPr,\n ctx,\n ) as TextCharacterPropertiesOptions;\n }\n\n // a:extLst — last child; verbatim inner XML for unmodeled extensions.\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) {\n const inner = stringifyXml(extLst);\n if (inner) result.ext = inner;\n }\n\n return result as TextParagraphPropertiesOptions;\n}\n\n// ── Paragraph (a:p) ──\n\nexport const paragraphDesc: CustomDescriptor<ParagraphDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Paragraph properties\n if (opts.properties) {\n const pPrXml = stringifyParagraphProperties(opts.properties, ctx);\n if (pPrXml) parts.push(pPrXml);\n }\n\n // Simple text shorthand\n if (opts.text) {\n parts.push(stringifyTextRun(opts.text));\n }\n\n // Children (text runs + fields + line breaks; a bare string is shorthand\n // for a single text-only run).\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyTextRun(child));\n } else if (isTextField(child)) {\n parts.push(stringifyTextField(child, ctx));\n } else if (isBreak(child)) {\n parts.push(stringifyBreak(child, ctx));\n } else {\n parts.push(textRunDesc.stringify(child, ctx) ?? \"\");\n }\n }\n }\n\n // End-paragraph run properties — fresh emits a default lang marker; a\n // parsed source preserves its value; false omits the element.\n if (opts.endParagraphProperties === false) {\n // omit\n } else {\n const epr = opts.endParagraphProperties ?? { lang: \"en-US\" };\n parts.push(stringifyEndParaRPr(epr, ctx));\n }\n\n const body = parts.join(\"\");\n return body ? `<a:p>${body}</a:p>` : \"<a:p/>\";\n },\n\n parse(el, ctx) {\n const result: ParagraphDescriptorOptions = {};\n\n // Paragraph properties\n const pPr = findChild(el, \"a:pPr\");\n if (pPr) {\n result.properties = readParagraphProperties(pPr, ctx) as TextParagraphPropertiesOptions;\n }\n\n // Collect runs, fields, and breaks in document order.\n const children: (TextRunOptions | TextFieldOptions | TextBreakOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"a:r\") {\n children.push(textRunDesc.parse(child, ctx) as TextRunOptions);\n } else if (child.name === \"a:fld\") {\n children.push(readTextField(child, ctx));\n } else if (child.name === \"a:br\") {\n children.push(readBreak(child, ctx));\n }\n }\n\n const [onlyRun] = children;\n if (\n onlyRun !== undefined &&\n !isTextField(onlyRun) &&\n !isBreak(onlyRun) &&\n children.length === 1 &&\n !result.properties &&\n onlyRun.text !== undefined &&\n Object.keys(onlyRun).length === 1\n ) {\n // Single run with no paragraph properties and only text -> use text shorthand\n result.text = onlyRun.text;\n } else if (children.length > 0) {\n result.children = children;\n }\n\n // End-paragraph run properties — preserve source value, or mark false so\n // stringify omits it (fresh paragraphs re-emit the default lang marker).\n const endParaRPr = findChild(el, \"a:endParaRPr\");\n if (endParaRPr) {\n result.endParagraphProperties = runPropertiesDesc.parse(\n endParaRPr,\n ctx,\n ) as TextCharacterPropertiesOptions;\n } else {\n result.endParagraphProperties = false;\n }\n\n return result as ParagraphDescriptorOptions;\n },\n};\n\n// ── Text field (a:fld) + break (a:br) helpers ──\n\nfunction isTextField(\n child: TextRunOptions | TextFieldOptions | TextBreakOptions,\n): child is TextFieldOptions {\n return typeof (child as TextFieldOptions).type === \"string\";\n}\n\nfunction isBreak(\n child: TextRunOptions | TextFieldOptions | TextBreakOptions,\n): child is TextBreakOptions {\n return (child as TextBreakOptions).break === true;\n}\n\nfunction stringifyBreak(opts: TextBreakOptions, ctx: WriteContext): string {\n const rPr = opts.properties ? (runPropertiesDesc.stringify(opts.properties, ctx) ?? \"\") : \"\";\n return rPr ? `<a:br>${rPr}</a:br>` : \"<a:br/>\";\n}\n\nfunction readBreak(el: XmlElement, ctx: ReadContext): TextBreakOptions {\n const result = { break: true } as Mutable<TextBreakOptions>;\n const rPr = findChild(el, \"a:rPr\");\n if (rPr) result.properties = runPropertiesDesc.parse(rPr, ctx) as TextCharacterPropertiesOptions;\n return result as TextBreakOptions;\n}\n\n// a:endParaRPr has the same CT_TextCharacterProperties shape as a:rPr; reuse\n// the run-properties serializer under the endParaRPr tag.\nfunction stringifyEndParaRPr(opts: TextCharacterPropertiesOptions, ctx: WriteContext): string {\n return stringifyRunProperties(\"a:endParaRPr\", opts, ctx) || \"<a:endParaRPr/>\";\n}\n\n// PowerPoint refuses to open a file whose a:fld carries a nil GUID (reports\n// the whole package as corrupt even though the XSD allows any ST_Guid), so an\n// unspecified id falls back to a stable non-zero one derived from a call\n// counter — same options, same call order, same output.\nlet nextFieldId = 0;\n\nfunction fallbackFieldGuid(): string {\n nextFieldId += 1;\n return `{5BCAD085-E8A6-8845-BD4E-CB4CCA05${(nextFieldId % 0x10000).toString(16).padStart(4, \"0\")}}`;\n}\n\nfunction stringifyTextField(opts: TextFieldOptions, ctx: WriteContext): string {\n // id is a required GUID on CT_TextField; the fallback keeps user-authored\n // fields PowerPoint-openable (see fallbackFieldGuid).\n const id = opts.id ?? fallbackFieldGuid();\n const rPr = opts.properties ? (runPropertiesDesc.stringify(opts.properties, ctx) ?? \"\") : \"\";\n // CT_TextField sequence: rPr?, pPr?, t? — a bare <a:pPr/> placeholder (empty\n // options object) still round-trips, so fall back to the empty element.\n const pPrInner = opts.paragraphProperties\n ? (stringifyParagraphProperties(opts.paragraphProperties, ctx) ?? \"\")\n : \"\";\n const pPr = pPrInner || (opts.paragraphProperties ? \"<a:pPr/>\" : \"\");\n const t = opts.text !== undefined ? `<a:t>${escapeXml(opts.text)}</a:t>` : \"\";\n return `<a:fld id=\"${id}\" type=\"${opts.type}\">${rPr}${pPr}${t}</a:fld>`;\n}\n\nfunction readTextField(el: XmlElement, ctx: ReadContext): TextFieldOptions {\n const result: TextFieldOptions = { type: String(el.attributes?.[\"type\"] ?? \"\") };\n const id = el.attributes?.[\"id\"];\n if (id !== undefined) result.id = String(id);\n const rPr = findChild(el, \"a:rPr\");\n if (rPr) result.properties = runPropertiesDesc.parse(rPr, ctx) as TextCharacterPropertiesOptions;\n const pPr = findChild(el, \"a:pPr\");\n if (pPr) result.paragraphProperties = readParagraphProperties(pPr, ctx);\n const t = findChild(el, \"a:t\");\n if (t) {\n result.text = (t.elements ?? [])\n .filter((e) => e.type === \"text\")\n .map((e) => e.text ?? \"\")\n .join(\"\");\n }\n return result;\n}\n","/**\n * Text list style descriptors.\n *\n * CT_TextListStyle is the level list behind a:lstStyle (txBody), p:notesStyle\n * and p:defaultTextStyle: an optional defPPr plus up to 9 outline levels\n * (lvl1pPr..lvl9pPr), each a CT_TextParagraphProperties reusing the shared\n * paragraph model. CT_SlideMasterTextStyles groups three of those lists as\n * p:titleStyle/p:bodyStyle/p:otherStyle on the slide master.\n *\n * Stringify models MS Office's byte layout exactly (XSD declaration order)\n * so the structured defaults reproduce Office-authored bytes bit-for-bit.\n * Parse is the inverse via the shared paragraph reader.\n *\n * @module\n */\n\nimport type { Element } from \"@office-open/xml\";\nimport { findChild, stringify } from \"@office-open/xml\";\n\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"../../descriptor\";\nimport { readParagraphProperties, stringifyParagraphPropertiesElement } from \"./paragraph\";\nimport type { TextParagraphPropertiesOptions } from \"./types\";\n\n// ── Types ──\n\n/**\n * A bare CT_TextListStyle — a:defPPr plus up to 9 outline levels. The shape\n * of a:lstStyle inside a txBody, p:notesStyle, and p:defaultTextStyle.\n */\nexport interface TextListStyleOptions {\n /** a:defPPr — defaults applied before any level. */\n defaultParagraph?: TextParagraphPropertiesOptions;\n /** Levels 1-9; index 0 = lvl1pPr. `null` omits the level (JSON form of\n * an undefined array slot — the position still pins the level number). */\n levels?: (TextParagraphPropertiesOptions | null)[];\n /** Trailing a:extLst verbatim inner XML; `\"\"` preserves a bare <a:extLst/>. */\n ext?: string;\n}\n\n/** CT_SlideMasterTextStyles — the master's title/body/other style groups. */\nexport interface TextStylesOptions {\n title?: TextListStyleOptions;\n body?: TextListStyleOptions;\n other?: TextListStyleOptions;\n}\n\n// ── Stringify ──\n\nfunction stringifyGroup(\n tag: string,\n group: TextListStyleOptions | undefined,\n ctx: WriteContext,\n): string {\n if (!group) return \"\";\n const parts: string[] = [];\n if (group.defaultParagraph) {\n parts.push(stringifyParagraphPropertiesElement(\"a:defPPr\", group.defaultParagraph, ctx));\n }\n const levels = group.levels ?? [];\n for (let i = 0; i < Math.min(levels.length, 9); i++) {\n const lvl = levels[i];\n if (lvl) parts.push(stringifyParagraphPropertiesElement(`a:lvl${i + 1}pPr`, lvl, ctx));\n }\n if (group.ext !== undefined) parts.push(`<a:extLst>${group.ext}</a:extLst>`);\n // An empty group keeps the bare element — sources may carry <p:otherStyle/>.\n return parts.length ? `<${tag}>${parts.join(\"\")}</${tag}>` : `<${tag}/>`;\n}\n\n/**\n * Stringify the three master text-style groups (CT_SlideMasterTextStyles).\n * Group tags use the p: prefix (PML); level tags inside are a: (DrawingML).\n * Caller wraps with `<p:txStyles>…</p:txStyles>`.\n */\nexport function stringifyTextStyles(opts: TextStylesOptions, ctx: WriteContext): string {\n return (\n `${stringifyGroup(\"p:titleStyle\", opts.title, ctx)}` +\n `${stringifyGroup(\"p:bodyStyle\", opts.body, ctx)}` +\n `${stringifyGroup(\"p:otherStyle\", opts.other, ctx)}`\n );\n}\n\n/** Emit a bare CT_TextListStyle under a caller-chosen tag, e.g. p:notesStyle. */\nexport function stringifyTextListStyleTag(\n tag: string,\n group: TextListStyleOptions | undefined,\n ctx: WriteContext,\n): string {\n return stringifyGroup(tag, group, ctx);\n}\n\n// ── Parse ──\n\nfunction parseGroup(el: Element | undefined, ctx: ReadContext): TextListStyleOptions | undefined {\n if (!el) return undefined;\n const group: TextListStyleOptions = {};\n const defPPr = findChild(el, \"a:defPPr\");\n if (defPPr) group.defaultParagraph = readParagraphProperties(defPPr, ctx);\n const levels: (TextParagraphPropertiesOptions | null)[] = [];\n for (let i = 1; i <= 9; i++) {\n const lvlEl = findChild(el, `a:lvl${i}pPr`);\n levels.push(lvlEl ? readParagraphProperties(lvlEl, ctx) : null);\n }\n if (group.defaultParagraph || levels.some((l) => l !== null)) group.levels = levels;\n const extLst = findChild(el, \"a:extLst\");\n if (extLst) group.ext = stringify(extLst);\n return group;\n}\n\n/** Parse CT_SlideMasterTextStyles (the three p:titleStyle/p:bodyStyle/p:otherStyle groups). */\nexport function parseTextStyles(el: Element, ctx: ReadContext): TextStylesOptions {\n return {\n title: parseGroup(findChild(el, \"p:titleStyle\"), ctx),\n body: parseGroup(findChild(el, \"p:bodyStyle\"), ctx),\n other: parseGroup(findChild(el, \"p:otherStyle\"), ctx),\n };\n}\n\n// ── Descriptors ──\n\n/** A bare CT_TextListStyle (a:lstStyle in a txBody). */\nexport const textListStyleDesc: CustomDescriptor<TextListStyleOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n const parts: string[] = [];\n if (opts.defaultParagraph) {\n parts.push(stringifyParagraphPropertiesElement(\"a:defPPr\", opts.defaultParagraph, ctx));\n }\n const levels = opts.levels ?? [];\n for (let i = 0; i < Math.min(levels.length, 9); i++) {\n const lvl = levels[i];\n if (lvl) parts.push(stringifyParagraphPropertiesElement(`a:lvl${i + 1}pPr`, lvl, ctx));\n }\n if (opts.ext !== undefined) parts.push(`<a:extLst>${opts.ext}</a:extLst>`);\n return parts.join(\"\");\n },\n parse(el, ctx) {\n return parseGroup(el, ctx) ?? {};\n },\n};\n\n/** CT_SlideMasterTextStyles descriptor (p:titleStyle/p:bodyStyle/p:otherStyle). */\nexport const textStylesDesc: CustomDescriptor<TextStylesOptions> = {\n kind: \"custom\",\n stringify(opts, ctx) {\n return stringifyTextStyles(opts, ctx);\n },\n parse(el, ctx) {\n return parseTextStyles(el, ctx);\n },\n};\n\n// ── MS Office standard master text styles (structured form) ──\n\nconst MJ_RUN = {\n fill: { type: \"solid\", color: { value: \"tx1\" } },\n font: { latin: \"+mj-lt\", eastAsia: \"+mj-ea\", complexScript: \"+mj-cs\" },\n} as const;\nconst MN_RUN = {\n fill: { type: \"solid\", color: { value: \"tx1\" } },\n font: { latin: \"+mn-lt\", eastAsia: \"+mn-ea\", complexScript: \"+mn-cs\" },\n} as const;\nconst BASE_ATTRS = {\n alignment: \"left\",\n defTabSize: 914400,\n rightToLeft: false,\n eastAsianLineBreak: true,\n latinLineBreak: false,\n hangingPunctuation: true,\n} as const;\n\nconst BODY_MARL = [228600, 685800, 1143000, 1600200, 2057400, 2514600, 2971800, 3429000, 3886200];\nconst BODY_SZ = [28, 24, 20, 18, 18, 18, 18, 18, 18];\nconst OTHER_MARL = [0, 457200, 914400, 1371600, 1828800, 2286000, 2743200, 3200400, 3657600];\n\n/** MS Office's default p:txStyles — title/body/other, 9 outline levels. */\nexport const DEFAULT_TEXT_STYLES: TextStylesOptions = {\n title: {\n levels: [\n {\n ...BASE_ATTRS,\n lineSpacingPercent: 90,\n spaceBeforePercent: 0,\n bullet: { type: \"none\" },\n defaultRunProperties: { size: 44, kern: 12, ...MJ_RUN },\n },\n ],\n },\n body: {\n levels: BODY_MARL.map((marL, i) => ({\n ...BASE_ATTRS,\n marginIndent: marL,\n indent: -228600,\n lineSpacingPercent: 90,\n spaceBeforePercent: i === 0 ? 0 : undefined,\n spaceBefore: i === 0 ? undefined : 5,\n bullet: { type: \"char\", char: \"•\", font: \"Arial\" },\n defaultRunProperties: { size: BODY_SZ[i]!, kern: 12, ...MN_RUN },\n })),\n },\n other: {\n defaultParagraph: { defaultRunProperties: {} },\n levels: OTHER_MARL.map((marL, i) => ({\n ...BASE_ATTRS,\n marginIndent: marL,\n indent: i === 8 ? -228600 : undefined,\n defaultRunProperties: { size: 18, kern: 12, ...MN_RUN },\n })),\n },\n};\n","/**\n * Text body descriptor — assembles the inner content of a DrawingML text body\n * (a:bodyPr + a:lstStyle + a:p[]). The caller wraps the container tag\n * (p:txBody / xdr:txBody / a:txBody); DOCX text boxes use wps:txbx (not txBody).\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TextBody\n *\n * @module\n */\n\nimport { findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { createBodyProperties, parseBodyProperties } from \"./body-properties\";\nimport type { BodyPropertiesOptions } from \"./body-properties\";\nimport { textListStyleDesc } from \"./list-style\";\nimport type { TextListStyleOptions } from \"./list-style\";\nimport { paragraphDesc } from \"./paragraph\";\nimport type { ParagraphDescriptorOptions } from \"./paragraph\";\n\nexport interface TextBodyOptions {\n bodyProperties?: BodyPropertiesOptions;\n listStyle?: TextListStyleOptions;\n /** Single-paragraph shorthand; expands to one paragraph on stringify. */\n text?: string;\n /** Paragraph list; string entries expand to a one-run paragraph. */\n paragraphs?: (ParagraphDescriptorOptions | string)[];\n\n /**\n * Convenience sugar — merged into `bodyProperties` on stringify (explicit\n * `bodyProperties` fields take precedence). Input-only: parse always emits\n * the normalized `bodyProperties` form. Mirrors the `fill` descriptor's\n * string-sugar convention.\n */\n anchor?: BodyPropertiesOptions[\"anchor\"];\n /** Sugar → `bodyProperties.normAutofit` (`\"normal\"`) / `spAutoFit` (`\"shape\"`). */\n autoFit?: \"normal\" | \"shape\";\n /** Sugar → `bodyProperties.numCol`. */\n columns?: BodyPropertiesOptions[\"numCol\"];\n /** Sugar → `bodyProperties.spcCol`. */\n columnSpacing?: BodyPropertiesOptions[\"spcCol\"];\n /** Sugar → `bodyProperties.margins`. */\n margins?: BodyPropertiesOptions[\"margins\"];\n /** Sugar → `bodyProperties.wrap`. */\n wrap?: BodyPropertiesOptions[\"wrap\"];\n /** Sugar → `bodyProperties.vertical`. */\n vertical?: BodyPropertiesOptions[\"vertical\"];\n}\n\n/**\n * Collect top-level TextBodyOptions sugar into a partial BodyPropertiesOptions.\n * Returns undefined when no sugar field is set — textBodyDesc runs once per\n * shape and the common case has no sugar, so the guard avoids allocating the\n * collector object (and the caller's emptiness check) on that path.\n */\nfunction bodyPropertiesSugar(opts: TextBodyOptions): Partial<BodyPropertiesOptions> | undefined {\n if (\n opts.anchor === undefined &&\n opts.autoFit === undefined &&\n opts.columns === undefined &&\n opts.columnSpacing === undefined &&\n opts.margins === undefined &&\n opts.wrap === undefined &&\n opts.vertical === undefined\n ) {\n return undefined;\n }\n const sugar: Partial<BodyPropertiesOptions> = {};\n if (opts.anchor !== undefined) sugar.anchor = opts.anchor;\n if (opts.autoFit === \"normal\") sugar.normAutofit = {};\n else if (opts.autoFit === \"shape\") sugar.spAutoFit = true;\n if (opts.columns !== undefined) sugar.numCol = opts.columns;\n if (opts.columnSpacing !== undefined) sugar.spcCol = opts.columnSpacing;\n if (opts.margins !== undefined) sugar.margins = opts.margins;\n if (opts.wrap !== undefined) sugar.wrap = opts.wrap;\n if (opts.vertical !== undefined) sugar.vertical = opts.vertical;\n return sugar;\n}\n\nexport const textBodyDesc: CustomDescriptor<TextBodyOptions> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // a:bodyPr — always present in CT_TextBody. Top-level sugar (anchor/\n // autoFit/columns/...) merges into bodyProperties; explicit bodyProperties\n // fields win.\n const sugar = bodyPropertiesSugar(opts);\n if (opts.bodyProperties || sugar !== undefined) {\n parts.push(createBodyProperties({ ...sugar, ...opts.bodyProperties }));\n } else {\n parts.push(\"<a:bodyPr/>\");\n }\n\n // a:lstStyle — always emit (matches MS Office byte layout).\n parts.push(\n opts.listStyle\n ? `<a:lstStyle>${textListStyleDesc.stringify(opts.listStyle, ctx) ?? \"\"}</a:lstStyle>`\n : \"<a:lstStyle/>\",\n );\n\n // a:p[] — CT_TextBody requires at least one paragraph. `text` is a\n // single-paragraph shorthand; `paragraphs` accepts string entries that\n // each expand to a one-run paragraph.\n const paragraphs = opts.paragraphs ?? (opts.text !== undefined ? [{ text: opts.text }] : []);\n if (paragraphs.length > 0) {\n for (const p of paragraphs) {\n const para = typeof p === \"string\" ? { children: [p] } : p;\n parts.push(paragraphDesc.stringify(para, ctx) ?? \"<a:p/>\");\n }\n } else {\n parts.push(\"<a:p/>\");\n }\n\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const result: TextBodyOptions = {};\n\n const bodyPr = findChild(el, \"a:bodyPr\");\n if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr, ctx);\n\n const lstStyle = findChild(el, \"a:lstStyle\");\n if (lstStyle) {\n const parsed = textListStyleDesc.parse(lstStyle, ctx);\n // An empty <a:lstStyle/> parses to an empty list; skip it so stringify\n // re-emits the self-closing form (matches MS Office byte layout for\n // bare text bodies).\n if (parsed.defaultParagraph || parsed.ext !== undefined || (parsed.levels?.length ?? 0) > 0) {\n result.listStyle = parsed;\n }\n }\n\n const paragraphs: ParagraphDescriptorOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"a:p\") {\n paragraphs.push(paragraphDesc.parse(child, ctx) as ParagraphDescriptorOptions);\n }\n }\n if (paragraphs.length > 0) result.paragraphs = paragraphs;\n\n return result;\n },\n};\n","/**\n * Diagram descriptors for declarative XML read/write.\n *\n * @module\n */\n\nimport { escapeXml, findChild } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../../descriptor\";\nimport { xsdAnimLevel, xsdHierBranch } from \"../../util/mappings\";\nimport { parseOnOff } from \"../../util/values\";\nimport type { DiagramExtensionListOptions } from \"./diagram-props\";\nimport type { DiagramRelationshipIdsOptions } from \"./diagram-rel\";\nimport type { DiagramStyleOptions } from \"./diagram-style\";\nimport type { PresentationLayoutVariablesOptions } from \"./layout-vars\";\n\n// ── dgm:relIds descriptor ──\n\nexport const diagramRelationshipIdsDesc: CustomDescriptor<DiagramRelationshipIdsOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n return `<dgm:relIds r:dm=\"${escapeXml(opts.dataModel)}\" r:lo=\"${escapeXml(opts.layout)}\" r:qs=\"${escapeXml(opts.quickStyle)}\" r:cs=\"${escapeXml(opts.colorStyle)}\"/>`;\n },\n parse(el, _ctx) {\n const result: Partial<DiagramRelationshipIdsOptions> = {};\n if (el.attributes) {\n if (el.attributes[\"r:dm\"] !== undefined) result.dataModel = String(el.attributes[\"r:dm\"]);\n if (el.attributes[\"r:lo\"] !== undefined) result.layout = String(el.attributes[\"r:lo\"]);\n if (el.attributes[\"r:qs\"] !== undefined) result.quickStyle = String(el.attributes[\"r:qs\"]);\n if (el.attributes[\"r:cs\"] !== undefined) result.colorStyle = String(el.attributes[\"r:cs\"]);\n }\n return result as DiagramRelationshipIdsOptions;\n },\n};\n\n// ── dgm:style descriptor ──\n\nexport const diagramStyleDesc: CustomDescriptor<DiagramStyleOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const lineIdx = opts.lineReference?.idx ?? 1;\n const fillIdx = opts.fillReference?.idx ?? 1;\n const effectIdx = opts.effectReference?.idx ?? 0;\n const fontIdx = opts.fontReference?.idx ?? \"minor\";\n\n return (\n `<dgm:style>` +\n `<a:lnRef idx=\"${lineIdx}\"><a:schemeClr val=\"accent1\"/></a:lnRef>` +\n `<a:fillRef idx=\"${fillIdx}\"><a:schemeClr val=\"accent1\"/></a:fillRef>` +\n `<a:effectRef idx=\"${effectIdx}\"><a:schemeClr val=\"accent1\"/></a:effectRef>` +\n `<a:fontRef idx=\"${escapeXml(fontIdx)}\"><a:schemeClr val=\"tx1\"/></a:fontRef>` +\n `</dgm:style>`\n );\n },\n parse(el, _ctx) {\n const result: DiagramStyleOptions = {};\n\n const lnRef = findChild(el, \"a:lnRef\");\n if (lnRef?.attributes?.[\"idx\"] !== undefined)\n result.lineReference = { idx: Number(lnRef.attributes[\"idx\"]) };\n\n const fillRef = findChild(el, \"a:fillRef\");\n if (fillRef?.attributes?.[\"idx\"] !== undefined)\n result.fillReference = { idx: Number(fillRef.attributes[\"idx\"]) };\n\n const effectRef = findChild(el, \"a:effectRef\");\n if (effectRef?.attributes?.[\"idx\"] !== undefined)\n result.effectReference = { idx: Number(effectRef.attributes[\"idx\"]) };\n\n const fontRef = findChild(el, \"a:fontRef\");\n if (fontRef?.attributes?.[\"idx\"] !== undefined)\n result.fontReference = { idx: String(fontRef.attributes[\"idx\"]) };\n\n return result;\n },\n};\n\n// ── dgm:presLayoutVars descriptor ──\n\nexport const presentationLayoutVariablesDesc: CustomDescriptor<PresentationLayoutVariablesOptions> =\n {\n kind: \"custom\",\n stringify(opts, _ctx) {\n const parts: string[] = [];\n\n if (opts.orgChart?.val !== undefined)\n parts.push(`<dgm:orgChart val=\"${opts.orgChart.val ? 1 : 0}\"/>`);\n\n if (opts.maxChildren?.val !== undefined)\n parts.push(`<dgm:chMax val=\"${opts.maxChildren.val}\"/>`);\n\n if (opts.preferredChildren?.val !== undefined)\n parts.push(`<dgm:chPref val=\"${opts.preferredChildren.val}\"/>`);\n\n if (opts.animateOneByOne?.val !== undefined)\n parts.push(`<dgm:animOne val=\"${escapeXml(opts.animateOneByOne.val)}\"/>`);\n\n if (opts.animationLevel?.val !== undefined)\n parts.push(`<dgm:animLvl val=\"${xsdAnimLevel.to(opts.animationLevel.val)}\"/>`);\n\n if (opts.hierBranch?.val !== undefined)\n parts.push(`<dgm:hierBranch val=\"${xsdHierBranch.to(opts.hierBranch.val)}\"/>`);\n\n if (parts.length === 0) return `<dgm:presLayoutVars/>`;\n return `<dgm:presLayoutVars>${parts.join(\"\")}</dgm:presLayoutVars>`;\n },\n parse(el, _ctx) {\n const result: PresentationLayoutVariablesOptions = {};\n\n const orgChart = findChild(el, \"dgm:orgChart\");\n if (orgChart?.attributes?.[\"val\"] !== undefined)\n result.orgChart = {\n val: parseOnOff(orgChart.attributes[\"val\"]) ?? false,\n };\n\n const chMax = findChild(el, \"dgm:chMax\");\n if (chMax?.attributes?.[\"val\"] !== undefined)\n result.maxChildren = { val: Number(chMax.attributes[\"val\"]) };\n\n const chPref = findChild(el, \"dgm:chPref\");\n if (chPref?.attributes?.[\"val\"] !== undefined)\n result.preferredChildren = { val: Number(chPref.attributes[\"val\"]) };\n\n const animOne = findChild(el, \"dgm:animOne\");\n if (animOne?.attributes?.[\"val\"] !== undefined)\n result.animateOneByOne = {\n val: String(\n animOne.attributes[\"val\"],\n ) as PresentationLayoutVariablesOptions[\"animateOneByOne\"] extends\n | { val?: infer V }\n | undefined\n ? V\n : never,\n };\n\n const animLvl = findChild(el, \"dgm:animLvl\");\n if (animLvl?.attributes?.[\"val\"] !== undefined)\n result.animationLevel = {\n val: xsdAnimLevel.from(\n String(animLvl.attributes[\"val\"]),\n ) as PresentationLayoutVariablesOptions[\"animationLevel\"] extends\n | { val?: infer V }\n | undefined\n ? V\n : never,\n };\n\n const hierBranch = findChild(el, \"dgm:hierBranch\");\n if (hierBranch?.attributes?.[\"val\"] !== undefined)\n result.hierBranch = {\n val: xsdHierBranch.from(\n String(hierBranch.attributes[\"val\"]),\n ) as PresentationLayoutVariablesOptions[\"hierBranch\"] extends\n | { val?: infer V }\n | undefined\n ? V\n : never,\n };\n\n return result;\n },\n };\n\n// ── dgm:extLst descriptor ──\n\nexport const diagramExtensionListDesc: CustomDescriptor<DiagramExtensionListOptions> = {\n kind: \"custom\",\n stringify(opts, _ctx) {\n if (!opts.extensions?.length) return undefined;\n\n const inner = opts.extensions.map((ext) => `<a:ext uri=\"${escapeXml(ext.uri)}\"/>`).join(\"\");\n\n return `<dgm:extLst>${inner}</dgm:extLst>`;\n },\n parse(el, _ctx) {\n const result: DiagramExtensionListOptions = {};\n\n if (el.elements) {\n const extensions = el.elements\n .filter((c) => c.name === \"a:ext\")\n .map((c) => ({ uri: String(c.attributes?.[\"uri\"] ?? \"\") }));\n if (extensions.length) result.extensions = extensions;\n }\n\n return result;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqFA,MAAa,qCAAgD,IAAI,IAAkB;CACjF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,mCAA8C,IAAI,IAAkB,CAAC,OAAO,QAAQ,CAAC;;AAGlG,MAAa,qCAAgD,IAAI,IAAkB;CACjF;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,SAAgB,mBAAmB,KAAmB,OAAuB;CAC3E,IAAI,mBAAmB,IAAI,GAAG,GAAG,OAAO,YAAY,KAAK;CACzD,IAAI,iBAAiB,IAAI,GAAG,GAAG,OAAO,UAAU,KAAK;CACrD,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,MAAa,yBAAyB,YAAsD;CAC1F,MAAM,IAAc,CAAC;CAErB,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;EACnD,MAAM,MAAM;EACZ,IAAI,UAAU,KAAA,KAAa,UAAU,OAAO;EAC5C,IAAI,UAAU,MAAM;GAClB,EAAE,KAAK,MAAM,IAAI,GAAG;GACpB;EACF;EACA,EAAE,KAAK,MAAM,IAAI,QAAQ,mBAAmB,KAAK,KAAK,EAAE,IAAI;CAC9D;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;ACjIA,MAAa,cAAc;CACzB,YAAY;CACZ,eAAe;CACf,MAAM;CACN,YAA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