{"version":3,"file":"drawing.mjs","names":[],"sources":["../src/drawing/dml/shape-properties.ts","../src/drawing/dml/fill.ts","../src/drawing/dml/text.ts"],"sourcesContent":["// DrawingML shape properties.\n//\n// `<a:spPr>` is the universal \"how should this be drawn\" wrapper that every\n// chart element (chartSpace, chart container, plotArea, series, dataPoint,\n// axis, …) accepts. The model intentionally splits the wrapper (this file) from\n// the leaves (colors / fill / line / geometry / effect / text) so the slot\n// grows by attribute as new primitive modules land.\n\nimport type { Point2D, PositiveSize2D } from '../anchor';\nimport type { EffectsRef } from './effect';\nimport type { Fill } from './fill';\nimport type { Geometry } from './geometry';\nimport type { LineProperties } from './line';\n\nexport type { Point2D, PositiveSize2D };\n\nexport type BlackWhiteMode =\n  | 'clr'\n  | 'auto'\n  | 'gray'\n  | 'ltGray'\n  | 'invGray'\n  | 'grayWhite'\n  | 'blackGray'\n  | 'blackWhite'\n  | 'black'\n  | 'white'\n  | 'hidden';\n\n/** `<a:xfrm>`. Position / size / rotation transformation. */\nexport interface Transform2D {\n  off?: Point2D;\n  ext?: PositiveSize2D;\n  /** Rotation in 60_000-ths of a degree (0..21_600_000). */\n  rot?: number;\n  flipH?: boolean;\n  flipV?: boolean;\n  chOff?: Point2D;\n  chExt?: PositiveSize2D;\n}\n\n/**\n * `<a:spPr>` wrapper. 3-D / text-body slots will be added as their primitive\n * modules land — kept absent here so the type stays closed under the modules\n * currently shipped.\n */\nexport interface ShapeProperties {\n  bwMode?: BlackWhiteMode;\n  xfrm?: Transform2D;\n  geometry?: Geometry;\n  fill?: Fill;\n  ln?: LineProperties;\n  /** Either `<a:effectLst>` (kind: 'lst') or `<a:effectDag>` (kind: 'dag'). */\n  effects?: EffectsRef;\n}\n\nexport const makeShapeProperties = (opts: Partial<ShapeProperties> = {}): ShapeProperties => ({\n  ...(opts.bwMode !== undefined ? { bwMode: opts.bwMode } : {}),\n  ...(opts.xfrm ? { xfrm: opts.xfrm } : {}),\n  ...(opts.geometry ? { geometry: opts.geometry } : {}),\n  ...(opts.fill ? { fill: opts.fill } : {}),\n  ...(opts.ln ? { ln: opts.ln } : {}),\n  ...(opts.effects ? { effects: opts.effects } : {}),\n});\n","// DrawingML fills.\n\nimport type { DmlColor, DmlColorWithMods } from './colors';\n\n/** Relative rectangle (0..100000-thousandths). */\nexport interface RelativeRect {\n  l?: number;\n  t?: number;\n  r?: number;\n  b?: number;\n}\n\nexport interface GradientStop {\n  /** Position along the gradient (0..100000). */\n  pos: number;\n  color: DmlColorWithMods;\n}\n\nexport type GradientLineDir =\n  | { kind: 'lin'; ang: number; scaled?: boolean }\n  | { kind: 'path'; pathType: 'shape' | 'circle' | 'rect'; tileRect?: RelativeRect };\n\nexport type TileFlip = 'x' | 'y' | 'xy' | 'none';\n\nexport interface TileFill {\n  tx?: number;\n  ty?: number;\n  sx?: number;\n  sy?: number;\n  flip?: TileFlip;\n  algn?: 'tl' | 't' | 'tr' | 'l' | 'ctr' | 'r' | 'bl' | 'b' | 'br';\n}\n\n/** Blip-source effects. The full ECMA-376 list is preserved here; `kind` discriminates. */\nexport type BlipEffect =\n  | { kind: 'biLevel'; thresh: number }\n  | { kind: 'blur'; rad: number; grow?: boolean }\n  | { kind: 'clrChange'; useA?: boolean; clrFrom: DmlColor; clrTo: DmlColor }\n  | { kind: 'clrRepl'; color: DmlColor }\n  | { kind: 'duotone'; colors: [DmlColor, DmlColor] }\n  | { kind: 'grayscl' }\n  | { kind: 'lum'; bright?: number; contrast?: number }\n  | { kind: 'tint'; hue?: number; amt?: number }\n  | { kind: 'alphaModFix'; amt: number };\n\nexport interface Blip {\n  embedRId?: string;\n  linkRId?: string;\n  cstate?: 'email' | 'screen' | 'print' | 'hqprint';\n  effects?: BlipEffect[];\n}\n\n/** Discriminated union for any fill that can attach to a shape. */\nexport type Fill =\n  | { kind: 'noFill' }\n  | { kind: 'solidFill'; color: DmlColorWithMods }\n  | {\n      kind: 'gradFill';\n      flip?: TileFlip;\n      rotWithShape?: boolean;\n      stops: GradientStop[];\n      lineDir?: GradientLineDir;\n    }\n  | {\n      kind: 'blipFill';\n      blip: Blip;\n      tile?: TileFill;\n      stretch?: { fillRect?: RelativeRect };\n      srcRect?: RelativeRect;\n      dpi?: number;\n      rotWithShape?: boolean;\n    }\n  | {\n      kind: 'pattFill';\n      preset: string;\n      fgClr?: DmlColorWithMods;\n      bgClr?: DmlColorWithMods;\n    }\n  | { kind: 'grpFill' };\n\nexport const makeNoFill = (): Fill => ({ kind: 'noFill' });\nexport const makeSolidFill = (color: DmlColorWithMods): Fill => ({ kind: 'solidFill', color });\n\nexport const makeGradientFill = (opts: {\n  stops: GradientStop[];\n  flip?: TileFlip;\n  rotWithShape?: boolean;\n  lineDir?: GradientLineDir;\n}): Fill => ({\n  kind: 'gradFill',\n  stops: opts.stops,\n  ...(opts.flip !== undefined ? { flip: opts.flip } : {}),\n  ...(opts.rotWithShape !== undefined ? { rotWithShape: opts.rotWithShape } : {}),\n  ...(opts.lineDir ? { lineDir: opts.lineDir } : {}),\n});\n\nexport const makePatternFill = (opts: {\n  preset: string;\n  fgClr?: DmlColorWithMods;\n  bgClr?: DmlColorWithMods;\n}): Fill => ({\n  kind: 'pattFill',\n  preset: opts.preset,\n  ...(opts.fgClr ? { fgClr: opts.fgClr } : {}),\n  ...(opts.bgClr ? { bgClr: opts.bgClr } : {}),\n});\n\n/** Excel's preset pattern names (54 entries, ECMA-376 §20.1.10.50; matches openpyxl). */\nexport const PRESET_PATTERN_NAMES: ReadonlyArray<string> = [\n  'pct5',\n  'pct10',\n  'pct20',\n  'pct25',\n  'pct30',\n  'pct40',\n  'pct50',\n  'pct60',\n  'pct70',\n  'pct75',\n  'pct80',\n  'pct90',\n  'horz',\n  'vert',\n  'ltHorz',\n  'ltVert',\n  'dkHorz',\n  'dkVert',\n  'narHorz',\n  'narVert',\n  'dashHorz',\n  'dashVert',\n  'cross',\n  'dnDiag',\n  'upDiag',\n  'ltDnDiag',\n  'ltUpDiag',\n  'dkDnDiag',\n  'dkUpDiag',\n  'wdDnDiag',\n  'wdUpDiag',\n  'dashDnDiag',\n  'dashUpDiag',\n  'diagCross',\n  'smCheck',\n  'lgCheck',\n  'smGrid',\n  'lgGrid',\n  'dotGrid',\n  'smConfetti',\n  'lgConfetti',\n  'horzBrick',\n  'diagBrick',\n  'solidDmnd',\n  'openDmnd',\n  'dotDmnd',\n  'plaid',\n  'sphere',\n  'weave',\n  'divot',\n  'shingle',\n  'wave',\n  'trellis',\n  'zigZag',\n];\n","// DrawingML text.\n//\n// Text body (`<a:txBody>`) is the universal \"rich text\" container chart\n// elements use for titles, axis labels, legend entries, etc. The model covers\n// ECMA-376 §21.1.2 (Text Body), §21.1.2.2 (Text Body Properties), §21.1.2.3\n// (List Style), §21.1.2.4 (Text Paragraph), §21.1.2.5 (Run / Break / Field),\n// and the Run / Paragraph property element groups.\n\nimport type { DmlColorWithMods } from './colors';\nimport type { EffectsRef } from './effect';\nimport type { Fill } from './fill';\nimport type { LineProperties } from './line';\n\n// ---- Common building blocks ------------------------------------------------\n\nexport type FontAlign = 'auto' | 't' | 'ctr' | 'base' | 'b';\nexport type ParagraphAlign = 'l' | 'ctr' | 'r' | 'just' | 'justLow' | 'dist' | 'thaiDist';\nexport type TextUnderline =\n  | 'none'\n  | 'words'\n  | 'sng'\n  | 'dbl'\n  | 'heavy'\n  | 'dotted'\n  | 'dottedHeavy'\n  | 'dash'\n  | 'dashHeavy'\n  | 'dashLong'\n  | 'dashLongHeavy'\n  | 'dotDash'\n  | 'dotDashHeavy'\n  | 'dotDotDash'\n  | 'dotDotDashHeavy'\n  | 'wavy'\n  | 'wavyHeavy'\n  | 'wavyDbl';\nexport type TextStrike = 'noStrike' | 'sngStrike' | 'dblStrike';\nexport type TextCap = 'none' | 'small' | 'all';\n\nexport type TextOverflow = 'overflow' | 'ellipsis' | 'clip';\nexport type TextHorzOverflow = 'overflow' | 'clip';\nexport type TextVertical = 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';\nexport type TextWrap = 'none' | 'square';\nexport type TextAnchor = 't' | 'ctr' | 'b' | 'just' | 'dist';\n\n/** `<a:lnSpc>` / `<a:spcBef>` / `<a:spcAft>` — either percent (×1000) or points (×100). */\nexport type TextSpacing = { kind: 'pct'; val: number } | { kind: 'pts'; val: number };\n\n/** `<a:tab>`. */\nexport interface TabStop {\n  pos: number;\n  algn?: 'l' | 'ctr' | 'r' | 'dec';\n}\n\n/** `<a:latin>` / `<a:ea>` / `<a:cs>` / `<a:sym>`. */\nexport interface TextFont {\n  typeface: string;\n  panose?: string;\n  pitchFamily?: number;\n  charset?: number;\n}\n\n/** `<a:hlinkClick>` / `<a:hlinkMouseOver>`. */\nexport interface HyperlinkInfo {\n  rId?: string;\n  invalidUrl?: string;\n  action?: string;\n  tgtFrame?: string;\n  tooltip?: string;\n  history?: boolean;\n  highlightClick?: boolean;\n  endSnd?: boolean;\n}\n\n/** `<a:rPr>` / `<a:endParaRPr>` / `<a:defRPr>`. */\nexport interface RunProperties {\n  kumimoji?: boolean;\n  lang?: string;\n  altLang?: string;\n  /** Font size in 1/100ths of a point. */\n  sz?: number;\n  b?: boolean;\n  i?: boolean;\n  u?: TextUnderline;\n  strike?: TextStrike;\n  kern?: number;\n  cap?: TextCap;\n  spc?: number;\n  normalizeH?: boolean;\n  /** Baseline shift × 1000 (super/subscript). */\n  baseline?: number;\n  noProof?: boolean;\n  dirty?: boolean;\n  err?: boolean;\n  smtClean?: boolean;\n  smtId?: number;\n  bmk?: string;\n  /** Right-to-left flag. */\n  rtl?: boolean;\n  ln?: LineProperties;\n  fill?: Fill;\n  effects?: EffectsRef;\n  highlight?: DmlColorWithMods;\n  /** Underline-line: either `'follow'` (`<a:uLnTx/>`) or an explicit LineProperties (`<a:uLn>`). */\n  uLn?: 'follow' | LineProperties;\n  /** Underline-fill: either `'follow'` (`<a:uFillTx/>`) or an explicit Fill (`<a:uFill>`). */\n  uFill?: 'follow' | Fill;\n  latin?: TextFont;\n  ea?: TextFont;\n  cs?: TextFont;\n  sym?: TextFont;\n  hlinkClick?: HyperlinkInfo;\n  hlinkMouseOver?: HyperlinkInfo;\n}\n\n/** `<a:buChar>` / `<a:buAutoNum>` / `<a:buBlip>` / `<a:buNone>`. */\nexport type BulletProperties =\n  | { kind: 'none' }\n  | { kind: 'char'; char: string }\n  | {\n      kind: 'autoNum';\n      type: string;\n      startAt?: number;\n    }\n  | { kind: 'blip'; embedRId?: string; linkRId?: string };\n\n/** `<a:pPr>`. */\nexport interface ParagraphProperties {\n  marL?: number;\n  marR?: number;\n  /** Indent level (0..8). */\n  lvl?: number;\n  indent?: number;\n  algn?: ParagraphAlign;\n  defTabSz?: number;\n  rtl?: boolean;\n  eaLnBrk?: boolean;\n  fontAlgn?: FontAlign;\n  latinLnBrk?: boolean;\n  hangingPunct?: boolean;\n  lnSpc?: TextSpacing;\n  spcBef?: TextSpacing;\n  spcAft?: TextSpacing;\n  tabLst?: TabStop[];\n  defRPr?: RunProperties;\n  bullet?: BulletProperties;\n  /** Bullet font (`<a:buFont>` / `<a:buFontTx/>`). */\n  buFont?: 'follow' | TextFont;\n  /** Bullet color (`<a:buClr>` / `<a:buClrTx/>`). */\n  buClr?: 'follow' | DmlColorWithMods;\n  /** Bullet size: percent of run size, points, or \"follow run\". */\n  buSz?: 'follow' | { kind: 'pct'; val: number } | { kind: 'pts'; val: number };\n}\n\n/** `<a:r>` (regular run), `<a:br>` (line break), `<a:fld>` (field). */\nexport type TextRun =\n  | { kind: 'r'; rPr?: RunProperties; t: string }\n  | { kind: 'br'; rPr?: RunProperties }\n  | { kind: 'fld'; id: string; type?: string; rPr?: RunProperties; pPr?: ParagraphProperties; t?: string };\n\n/** `<a:p>`. */\nexport interface TextParagraph {\n  pPr?: ParagraphProperties;\n  runs: TextRun[];\n  endParaRPr?: RunProperties;\n}\n\n/** `<a:bodyPr>` autofit choice. */\nexport type AutoFit =\n  | { kind: 'noAutofit' }\n  | { kind: 'normAutofit'; fontScale?: number; lnSpcReduction?: number }\n  | { kind: 'spAutoFit' };\n\n/** `<a:bodyPr>`. */\nexport interface TextBodyProperties {\n  rot?: number;\n  spcFirstLastPara?: boolean;\n  vertOverflow?: TextOverflow;\n  horzOverflow?: TextHorzOverflow;\n  vert?: TextVertical;\n  wrap?: TextWrap;\n  lIns?: number;\n  tIns?: number;\n  rIns?: number;\n  bIns?: number;\n  numCol?: number;\n  spcCol?: number;\n  rtlCol?: boolean;\n  fromWordArt?: boolean;\n  anchor?: TextAnchor;\n  anchorCtr?: boolean;\n  forceAA?: boolean;\n  upright?: boolean;\n  compatLnSpc?: boolean;\n  autoFit?: AutoFit;\n  flatTxZ?: number;\n}\n\n/**\n * `<a:lstStyle>` (list / level styles). ECMA-376 §21.1.2.4.12. One\n * ParagraphProperties per indent level (0..8). `defPPr` is the default applied\n * when no level-specific override exists.\n */\nexport interface TextListStyle {\n  defPPr?: ParagraphProperties;\n  lvl1pPr?: ParagraphProperties;\n  lvl2pPr?: ParagraphProperties;\n  lvl3pPr?: ParagraphProperties;\n  lvl4pPr?: ParagraphProperties;\n  lvl5pPr?: ParagraphProperties;\n  lvl6pPr?: ParagraphProperties;\n  lvl7pPr?: ParagraphProperties;\n  lvl8pPr?: ParagraphProperties;\n  lvl9pPr?: ParagraphProperties;\n}\n\nexport interface TextBody {\n  bodyPr: TextBodyProperties;\n  lstStyle?: TextListStyle;\n  paragraphs: TextParagraph[];\n}\n\n// ---- Factories -------------------------------------------------------------\n\nexport const makeRunProperties = (opts: Partial<RunProperties> = {}): RunProperties => ({ ...opts });\n\nexport const makeRun = (text: string, rPr?: RunProperties): TextRun =>\n  rPr ? { kind: 'r', rPr, t: text } : { kind: 'r', t: text };\n\nexport const makeBreak = (rPr?: RunProperties): TextRun => (rPr ? { kind: 'br', rPr } : { kind: 'br' });\n\nexport const makeParagraph = (\n  runs: TextRun[],\n  pPr?: ParagraphProperties,\n  endParaRPr?: RunProperties,\n): TextParagraph => ({\n  runs,\n  ...(pPr ? { pPr } : {}),\n  ...(endParaRPr ? { endParaRPr } : {}),\n});\n\nexport const makeTextBody = (\n  paragraphs: TextParagraph[],\n  bodyPr: TextBodyProperties = {},\n  lstStyle?: TextListStyle,\n): TextBody => ({\n  bodyPr,\n  ...(lstStyle ? { lstStyle } : {}),\n  paragraphs,\n});\n\n/** Convenience: build a single-paragraph body with one run. */\nexport const makeSimpleTextBody = (text: string, rPr?: RunProperties): TextBody =>\n  makeTextBody([makeParagraph([makeRun(text, rPr)])]);\n"],"mappings":";;;AAwDA,MAAa,uBAAuB,OAAiC,CAAC,OAAwB;CAC5F,GAAI,KAAK,WAAW,KAAA,IAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;CAC3D,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACvC,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;CACnD,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACvC,GAAI,KAAK,KAAK,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC;CACjC,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAClD;;;ACiBA,MAAa,oBAA0B,EAAE,MAAM,SAAS;AACxD,MAAa,iBAAiB,WAAmC;CAAE,MAAM;CAAa;AAAM;AAE5F,MAAa,oBAAoB,UAKpB;CACX,MAAM;CACN,OAAO,KAAK;CACZ,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACrD,GAAI,KAAK,iBAAiB,KAAA,IAAY,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;CAC7E,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAClD;AAEA,MAAa,mBAAmB,UAInB;CACX,MAAM;CACN,QAAQ,KAAK;CACb,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;CAC1C,GAAI,KAAK,QAAQ,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;AAC5C;;AAGA,MAAa,uBAA8C;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AC6DA,MAAa,qBAAqB,OAA+B,CAAC,OAAsB,EAAE,GAAG,KAAK;AAElG,MAAa,WAAW,MAAc,QACpC,MAAM;CAAE,MAAM;CAAK;CAAK,GAAG;AAAK,IAAI;CAAE,MAAM;CAAK,GAAG;AAAK;AAE3D,MAAa,aAAa,QAAkC,MAAM;CAAE,MAAM;CAAM;AAAI,IAAI,EAAE,MAAM,KAAK;AAErG,MAAa,iBACX,MACA,KACA,gBACmB;CACnB;CACA,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CACrB,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;AACrC;AAEA,MAAa,gBACX,YACA,SAA6B,CAAC,GAC9B,cACc;CACd;CACA,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAC/B;AACF;;AAGA,MAAa,sBAAsB,MAAc,QAC/C,aAAa,CAAC,cAAc,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC"}