pptx-react-viewer 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{AiChatPanel-MHURGN6G.mjs → AiChatPanel-C3ACRWOY.mjs} +4 -4
  3. package/dist/AiChatPanel-C3ACRWOY.mjs.br +0 -0
  4. package/dist/AiChatPanel-C3ACRWOY.mjs.gz +0 -0
  5. package/dist/{AiChatPanel-WMVQFNDC.js → AiChatPanel-GQNSKMP6.js} +25 -25
  6. package/dist/AiChatPanel-GQNSKMP6.js.br +0 -0
  7. package/dist/AiChatPanel-GQNSKMP6.js.gz +0 -0
  8. package/dist/{Area3DChartScene-IMGZEZNU.js → Area3DChartScene-3I6KB2DN.js} +2 -2
  9. package/dist/Area3DChartScene-3I6KB2DN.js.br +0 -0
  10. package/dist/Area3DChartScene-3I6KB2DN.js.gz +0 -0
  11. package/dist/{Area3DChartScene-LKOWSMAU.mjs → Area3DChartScene-4TPNRYXS.mjs} +1 -1
  12. package/dist/{Area3DChartScene-LKOWSMAU.mjs.br → Area3DChartScene-4TPNRYXS.mjs.br} +0 -0
  13. package/dist/Area3DChartScene-4TPNRYXS.mjs.gz +0 -0
  14. package/dist/{Bar3DChartScene-NQNSIMUL.mjs → Bar3DChartScene-V45IUIT7.mjs} +1 -1
  15. package/dist/{Bar3DChartScene-NQNSIMUL.mjs.br → Bar3DChartScene-V45IUIT7.mjs.br} +0 -0
  16. package/dist/Bar3DChartScene-V45IUIT7.mjs.gz +0 -0
  17. package/dist/{Bar3DChartScene-VLSYVFRT.js → Bar3DChartScene-ZSCATOYF.js} +2 -2
  18. package/dist/Bar3DChartScene-ZSCATOYF.js.br +0 -0
  19. package/dist/Bar3DChartScene-ZSCATOYF.js.gz +0 -0
  20. package/dist/{Line3DChartScene-ANZBJYQI.mjs → Line3DChartScene-DCQJEZK6.mjs} +1 -1
  21. package/dist/{Line3DChartScene-ANZBJYQI.mjs.br → Line3DChartScene-DCQJEZK6.mjs.br} +0 -0
  22. package/dist/Line3DChartScene-DCQJEZK6.mjs.gz +0 -0
  23. package/dist/{Line3DChartScene-IWZHA563.js → Line3DChartScene-DK55LQ2D.js} +2 -2
  24. package/dist/Line3DChartScene-DK55LQ2D.js.br +0 -0
  25. package/dist/Line3DChartScene-DK55LQ2D.js.gz +0 -0
  26. package/dist/{Model3DScene-2L3YRAMR.js → Model3DScene-2WNP4XBP.js} +2 -2
  27. package/dist/Model3DScene-2WNP4XBP.js.br +0 -0
  28. package/dist/Model3DScene-2WNP4XBP.js.gz +0 -0
  29. package/dist/{Model3DScene-Y34HTZXK.mjs → Model3DScene-SA5XMR2D.mjs} +1 -1
  30. package/dist/Model3DScene-SA5XMR2D.mjs.br +0 -0
  31. package/dist/Model3DScene-SA5XMR2D.mjs.gz +0 -0
  32. package/dist/{PieChart3DScene-FBRPLHLG.mjs → PieChart3DScene-HC2ZWL42.mjs} +1 -1
  33. package/dist/{PieChart3DScene-FBRPLHLG.mjs.br → PieChart3DScene-HC2ZWL42.mjs.br} +0 -0
  34. package/dist/PieChart3DScene-HC2ZWL42.mjs.gz +0 -0
  35. package/dist/{PieChart3DScene-NE3GN5VG.js → PieChart3DScene-Q75D66HS.js} +2 -2
  36. package/dist/PieChart3DScene-Q75D66HS.js.br +0 -0
  37. package/dist/PieChart3DScene-Q75D66HS.js.gz +0 -0
  38. package/dist/{SmartArt3DScene-QZGIABOK.mjs → SmartArt3DScene-D4VNNPHS.mjs} +124 -19
  39. package/dist/SmartArt3DScene-D4VNNPHS.mjs.br +0 -0
  40. package/dist/SmartArt3DScene-D4VNNPHS.mjs.gz +0 -0
  41. package/dist/{SmartArt3DScene-T236GYUT.js → SmartArt3DScene-NHD7CZJ5.js} +123 -18
  42. package/dist/SmartArt3DScene-NHD7CZJ5.js.br +0 -0
  43. package/dist/SmartArt3DScene-NHD7CZJ5.js.gz +0 -0
  44. package/dist/{SurfaceChart3DScene-7HE5DA3X.mjs → SurfaceChart3DScene-JRMX4PN5.mjs} +1 -1
  45. package/dist/SurfaceChart3DScene-JRMX4PN5.mjs.br +0 -0
  46. package/dist/SurfaceChart3DScene-JRMX4PN5.mjs.gz +0 -0
  47. package/dist/{SurfaceChart3DScene-OSMAVZJC.js → SurfaceChart3DScene-ODS5E6ZG.js} +2 -2
  48. package/dist/SurfaceChart3DScene-ODS5E6ZG.js.br +0 -0
  49. package/dist/SurfaceChart3DScene-ODS5E6ZG.js.gz +0 -0
  50. package/dist/{chunk-H7J4EYXS.mjs → chunk-25CABWCR.mjs} +131 -329
  51. package/dist/chunk-25CABWCR.mjs.br +0 -0
  52. package/dist/chunk-25CABWCR.mjs.gz +0 -0
  53. package/dist/{chunk-IWHZ2DUD.mjs → chunk-3B6YIH4K.mjs} +626 -133
  54. package/dist/chunk-3B6YIH4K.mjs.br +0 -0
  55. package/dist/chunk-3B6YIH4K.mjs.gz +0 -0
  56. package/dist/{chunk-L6I73WMO.js → chunk-A6JKOHSV.js} +2143 -1644
  57. package/dist/chunk-A6JKOHSV.js.br +0 -0
  58. package/dist/chunk-A6JKOHSV.js.gz +0 -0
  59. package/dist/{chunk-5F426BCZ.mjs → chunk-GRAARMUW.mjs} +1 -1
  60. package/dist/chunk-GRAARMUW.mjs.br +0 -0
  61. package/dist/chunk-GRAARMUW.mjs.gz +0 -0
  62. package/dist/{chunk-ZOB6ITIM.js → chunk-MQHMMB6V.js} +5 -5
  63. package/dist/chunk-MQHMMB6V.js.br +0 -0
  64. package/dist/chunk-MQHMMB6V.js.gz +0 -0
  65. package/dist/{chunk-I5F3XLVR.js → chunk-NR4MQJM5.js} +1961 -2161
  66. package/dist/chunk-NR4MQJM5.js.br +0 -0
  67. package/dist/chunk-NR4MQJM5.js.gz +0 -0
  68. package/dist/{chunk-M24DEOP6.js → chunk-NXGUR2DO.js} +2 -0
  69. package/dist/chunk-NXGUR2DO.js.br +0 -0
  70. package/dist/chunk-NXGUR2DO.js.gz +0 -0
  71. package/dist/{chunk-R664EPDC.mjs → chunk-PC7H3C5W.mjs} +2 -0
  72. package/dist/chunk-PC7H3C5W.mjs.br +0 -0
  73. package/dist/chunk-PC7H3C5W.mjs.gz +0 -0
  74. package/dist/{chunk-NKACTGK5.js → chunk-PUALTXTU.js} +182 -182
  75. package/dist/chunk-PUALTXTU.js.br +0 -0
  76. package/dist/chunk-PUALTXTU.js.gz +0 -0
  77. package/dist/{chunk-33YE6E2O.mjs → chunk-Q6QJOD56.mjs} +2145 -470
  78. package/dist/chunk-Q6QJOD56.mjs.br +0 -0
  79. package/dist/chunk-Q6QJOD56.mjs.gz +0 -0
  80. package/dist/{chunk-LAAXFMRE.js → chunk-SK2CZQ6P.js} +2151 -469
  81. package/dist/chunk-SK2CZQ6P.js.br +0 -0
  82. package/dist/chunk-SK2CZQ6P.js.gz +0 -0
  83. package/dist/{chunk-GITM3RKP.mjs → chunk-WLWAYLL6.mjs} +2 -2
  84. package/dist/chunk-WLWAYLL6.mjs.br +0 -0
  85. package/dist/chunk-WLWAYLL6.mjs.gz +0 -0
  86. package/dist/i18n/de.cjs +2 -0
  87. package/dist/i18n/de.cjs.br +0 -0
  88. package/dist/i18n/de.cjs.gz +0 -0
  89. package/dist/i18n/de.mjs +2 -0
  90. package/dist/i18n/de.mjs.br +0 -0
  91. package/dist/i18n/de.mjs.gz +0 -0
  92. package/dist/i18n/es.cjs +2 -0
  93. package/dist/i18n/es.cjs.br +0 -0
  94. package/dist/i18n/es.cjs.gz +0 -0
  95. package/dist/i18n/es.mjs +2 -0
  96. package/dist/i18n/es.mjs.br +0 -0
  97. package/dist/i18n/es.mjs.gz +0 -0
  98. package/dist/i18n/fr.cjs +2 -0
  99. package/dist/i18n/fr.cjs.br +0 -0
  100. package/dist/i18n/fr.cjs.gz +0 -0
  101. package/dist/i18n/fr.mjs +2 -0
  102. package/dist/i18n/fr.mjs.br +0 -0
  103. package/dist/i18n/fr.mjs.gz +0 -0
  104. package/dist/i18n/zh-CN.cjs +2 -0
  105. package/dist/i18n/zh-CN.cjs.br +0 -0
  106. package/dist/i18n/zh-CN.cjs.gz +0 -0
  107. package/dist/i18n/zh-CN.mjs +2 -0
  108. package/dist/i18n/zh-CN.mjs.br +0 -0
  109. package/dist/i18n/zh-CN.mjs.gz +0 -0
  110. package/dist/i18n.js +4 -4
  111. package/dist/i18n.js.br +0 -0
  112. package/dist/i18n.js.gz +0 -0
  113. package/dist/i18n.mjs +1 -1
  114. package/dist/i18n.mjs.br +0 -0
  115. package/dist/i18n.mjs.gz +0 -0
  116. package/dist/index.d.ts +586 -7
  117. package/dist/index.js +52 -48
  118. package/dist/index.js.br +0 -0
  119. package/dist/index.js.gz +0 -0
  120. package/dist/index.mjs +6 -6
  121. package/dist/index.mjs.br +0 -0
  122. package/dist/index.mjs.gz +0 -0
  123. package/dist/internals.d.ts +447 -13
  124. package/dist/internals.js +105 -105
  125. package/dist/internals.js.br +0 -0
  126. package/dist/internals.js.gz +0 -0
  127. package/dist/internals.mjs +4 -4
  128. package/dist/internals.mjs.br +0 -0
  129. package/dist/internals.mjs.gz +0 -0
  130. package/dist/viewer/index.js +32 -32
  131. package/dist/viewer/index.js.br +0 -0
  132. package/dist/viewer/index.js.gz +0 -0
  133. package/dist/viewer/index.mjs +6 -6
  134. package/dist/viewer/index.mjs.br +0 -0
  135. package/dist/viewer/index.mjs.gz +0 -0
  136. package/package.json +2 -2
  137. package/dist/AiChatPanel-MHURGN6G.mjs.br +0 -0
  138. package/dist/AiChatPanel-MHURGN6G.mjs.gz +0 -0
  139. package/dist/AiChatPanel-WMVQFNDC.js.br +0 -0
  140. package/dist/AiChatPanel-WMVQFNDC.js.gz +0 -0
  141. package/dist/Area3DChartScene-IMGZEZNU.js.br +0 -0
  142. package/dist/Area3DChartScene-IMGZEZNU.js.gz +0 -0
  143. package/dist/Area3DChartScene-LKOWSMAU.mjs.gz +0 -0
  144. package/dist/Bar3DChartScene-NQNSIMUL.mjs.gz +0 -0
  145. package/dist/Bar3DChartScene-VLSYVFRT.js.br +0 -0
  146. package/dist/Bar3DChartScene-VLSYVFRT.js.gz +0 -0
  147. package/dist/Line3DChartScene-ANZBJYQI.mjs.gz +0 -0
  148. package/dist/Line3DChartScene-IWZHA563.js.br +0 -0
  149. package/dist/Line3DChartScene-IWZHA563.js.gz +0 -0
  150. package/dist/Model3DScene-2L3YRAMR.js.br +0 -0
  151. package/dist/Model3DScene-2L3YRAMR.js.gz +0 -0
  152. package/dist/Model3DScene-Y34HTZXK.mjs.br +0 -0
  153. package/dist/Model3DScene-Y34HTZXK.mjs.gz +0 -0
  154. package/dist/PieChart3DScene-FBRPLHLG.mjs.gz +0 -0
  155. package/dist/PieChart3DScene-NE3GN5VG.js.br +0 -0
  156. package/dist/PieChart3DScene-NE3GN5VG.js.gz +0 -0
  157. package/dist/SmartArt3DScene-QZGIABOK.mjs.br +0 -0
  158. package/dist/SmartArt3DScene-QZGIABOK.mjs.gz +0 -0
  159. package/dist/SmartArt3DScene-T236GYUT.js.br +0 -0
  160. package/dist/SmartArt3DScene-T236GYUT.js.gz +0 -0
  161. package/dist/SurfaceChart3DScene-7HE5DA3X.mjs.br +0 -0
  162. package/dist/SurfaceChart3DScene-7HE5DA3X.mjs.gz +0 -0
  163. package/dist/SurfaceChart3DScene-OSMAVZJC.js.br +0 -0
  164. package/dist/SurfaceChart3DScene-OSMAVZJC.js.gz +0 -0
  165. package/dist/chunk-33YE6E2O.mjs.br +0 -0
  166. package/dist/chunk-33YE6E2O.mjs.gz +0 -0
  167. package/dist/chunk-5F426BCZ.mjs.br +0 -0
  168. package/dist/chunk-5F426BCZ.mjs.gz +0 -0
  169. package/dist/chunk-GITM3RKP.mjs.br +0 -0
  170. package/dist/chunk-GITM3RKP.mjs.gz +0 -0
  171. package/dist/chunk-H7J4EYXS.mjs.br +0 -0
  172. package/dist/chunk-H7J4EYXS.mjs.gz +0 -0
  173. package/dist/chunk-I5F3XLVR.js.br +0 -0
  174. package/dist/chunk-I5F3XLVR.js.gz +0 -0
  175. package/dist/chunk-IWHZ2DUD.mjs.br +0 -0
  176. package/dist/chunk-IWHZ2DUD.mjs.gz +0 -0
  177. package/dist/chunk-L6I73WMO.js.br +0 -0
  178. package/dist/chunk-L6I73WMO.js.gz +0 -0
  179. package/dist/chunk-LAAXFMRE.js.br +0 -0
  180. package/dist/chunk-LAAXFMRE.js.gz +0 -0
  181. package/dist/chunk-M24DEOP6.js.br +0 -0
  182. package/dist/chunk-M24DEOP6.js.gz +0 -0
  183. package/dist/chunk-NKACTGK5.js.br +0 -0
  184. package/dist/chunk-NKACTGK5.js.gz +0 -0
  185. package/dist/chunk-R664EPDC.mjs.br +0 -0
  186. package/dist/chunk-R664EPDC.mjs.gz +0 -0
  187. package/dist/chunk-ZOB6ITIM.js.br +0 -0
  188. package/dist/chunk-ZOB6ITIM.js.gz +0 -0
@@ -31072,7 +31072,7 @@ function directChildOrder(xml) {
31072
31072
  function extractElementOrders(xml, elementName) {
31073
31073
  const orders = [];
31074
31074
  const pattern = new RegExp(
31075
- `<([A-Za-z_][\\w.-]*:)?${elementName}\\b[^>]*>([\\s\\S]*?)<\\/\\1${elementName}\\s*>`,
31075
+ `<([A-Za-z_][\\w.-]*:)?${elementName}(?=[\\s/>])[^>]*>([\\s\\S]*?)<\\/\\1${elementName}\\s*>`,
31076
31076
  "gu"
31077
31077
  );
31078
31078
  for (const match of xml.matchAll(pattern)) {
@@ -32036,11 +32036,11 @@ function parseRunSolidFillColor(rPr) {
32036
32036
  if (!rPr) {
32037
32037
  return void 0;
32038
32038
  }
32039
- const solidFill3 = rPr["a:solidFill"];
32040
- if (!solidFill3) {
32039
+ const solidFill32 = rPr["a:solidFill"];
32040
+ if (!solidFill32) {
32041
32041
  return void 0;
32042
32042
  }
32043
- const srgb = solidFill3["a:srgbClr"];
32043
+ const srgb = solidFill32["a:srgbClr"];
32044
32044
  if (srgb?.["@_val"]) {
32045
32045
  return String(srgb["@_val"]);
32046
32046
  }
@@ -32050,11 +32050,11 @@ function parseRunSolidFillColorXml(rPr) {
32050
32050
  if (!rPr) {
32051
32051
  return void 0;
32052
32052
  }
32053
- const solidFill3 = rPr["a:solidFill"];
32054
- if (!solidFill3) {
32053
+ const solidFill32 = rPr["a:solidFill"];
32054
+ if (!solidFill32) {
32055
32055
  return void 0;
32056
32056
  }
32057
- return extractColorChoiceXml(solidFill3);
32057
+ return extractColorChoiceXml(solidFill32);
32058
32058
  }
32059
32059
  var init_text_run_properties_parser = __esm({
32060
32060
  "src/core/utils/text-run-properties-parser.ts"() {
@@ -37453,6 +37453,20 @@ function itemAspect(plan, index, nodeCount, presLayoutVars) {
37453
37453
  }
37454
37454
  return void 0;
37455
37455
  }
37456
+ function itemCrossAxisFraction(plan, index) {
37457
+ const item = itemNode(plan.node);
37458
+ if (!item) {
37459
+ return void 0;
37460
+ }
37461
+ const role = roleOf(item);
37462
+ const arrangerRole = roleOf(plan.node);
37463
+ const rawHeight = firstConstraintDeclaredBy(index, role, "h", arrangerRole);
37464
+ if (!rawHeight || rawHeight.referenceType !== "w") {
37465
+ return void 0;
37466
+ }
37467
+ const width = resolveConstraintDeclaredBy(index, role, "w", arrangerRole);
37468
+ return typeof width === "number" && width > 0 ? width : void 0;
37469
+ }
37456
37470
  function ordered(nodes, flow) {
37457
37471
  return flow.reverse ? [...nodes].reverse() : nodes;
37458
37472
  }
@@ -37840,6 +37854,7 @@ function arrangeLinear(plan, flow, nodes, box, palette, style, elementId, index
37840
37854
  const horizontal = flow.orientation === "horizontal";
37841
37855
  const usableMain = (horizontal ? w : h2) - INSET * 2;
37842
37856
  const usableCross = (horizontal ? h2 : w) - INSET * 2;
37857
+ const crossAxisFraction = horizontal ? void 0 : itemCrossAxisFraction(plan, index);
37843
37858
  const { mainExtent, gap } = resolveMainAxisLayout(
37844
37859
  constraints,
37845
37860
  index,
@@ -37855,7 +37870,7 @@ function arrangeLinear(plan, flow, nodes, box, palette, style, elementId, index
37855
37870
  const itemTemplate = itemNode(plan.node);
37856
37871
  const itemShape = findCompositeItemShape(itemTemplate);
37857
37872
  const naturalAspect = resolveItemSelfAspect(itemTemplate);
37858
- const crossExtent = aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : typeof naturalAspect === "number" ? Math.min(
37873
+ const crossExtent = crossAxisFraction ? Math.min(usableCross, Math.max(12, usableCross * crossAxisFraction)) : aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : typeof naturalAspect === "number" ? Math.min(
37859
37874
  usableCross,
37860
37875
  Math.max(12, mainExtent * (horizontal ? naturalAspect : 1 / naturalAspect))
37861
37876
  ) : usableCross;
@@ -46407,8 +46422,8 @@ function parseLineStyle(container, elementName, xmlLookup, colorParser) {
46407
46422
  if (spPr) {
46408
46423
  const lnNode = xmlLookup.getChildByLocalName(spPr, "ln");
46409
46424
  if (lnNode) {
46410
- const solidFill3 = xmlLookup.getChildByLocalName(lnNode, "solidFill");
46411
- const lineColor = colorParser.parseColor(solidFill3);
46425
+ const solidFill32 = xmlLookup.getChildByLocalName(lnNode, "solidFill");
46426
+ const lineColor = colorParser.parseColor(solidFill32);
46412
46427
  if (lineColor) {
46413
46428
  result.color = lineColor;
46414
46429
  }
@@ -47111,8 +47126,8 @@ function parseShapeProps(spPrNode, xmlLookup, colorParser) {
47111
47126
  }
47112
47127
  const result = {};
47113
47128
  let hasProps = false;
47114
- const solidFill3 = xmlLookup.getChildByLocalName(spPrNode, "solidFill");
47115
- const fillColor = colorParser.parseColor(solidFill3);
47129
+ const solidFill32 = xmlLookup.getChildByLocalName(spPrNode, "solidFill");
47130
+ const fillColor = colorParser.parseColor(solidFill32);
47116
47131
  if (fillColor) {
47117
47132
  result.fillColor = fillColor;
47118
47133
  hasProps = true;
@@ -48594,8 +48609,8 @@ function parseTxPr(txPrNode, xmlLookup, colorParser, target, resolveTypeface) {
48594
48609
  const raw = String(latin["@_typeface"]);
48595
48610
  target.fontFamily = resolveTypeface ? resolveTypeface(raw) : raw;
48596
48611
  }
48597
- const solidFill3 = xmlLookup.getChildByLocalName(defRPr, "solidFill");
48598
- const fontColor = colorParser.parseColor(solidFill3);
48612
+ const solidFill32 = xmlLookup.getChildByLocalName(defRPr, "solidFill");
48613
+ const fontColor = colorParser.parseColor(solidFill32);
48599
48614
  if (fontColor) {
48600
48615
  target.fontColor = fontColor;
48601
48616
  }
@@ -49096,13 +49111,13 @@ function extractCxSeriesColor(ser, xmlLookup, colorParser) {
49096
49111
  if (!spPr) {
49097
49112
  return void 0;
49098
49113
  }
49099
- const solidFill3 = xmlLookup.getChildByLocalName(spPr, "solidFill");
49100
- if (solidFill3) {
49101
- const resolved = colorParser?.parseColor(solidFill3);
49114
+ const solidFill32 = xmlLookup.getChildByLocalName(spPr, "solidFill");
49115
+ if (solidFill32) {
49116
+ const resolved = colorParser?.parseColor(solidFill32);
49102
49117
  if (resolved) {
49103
49118
  return resolved;
49104
49119
  }
49105
- const srgb = xmlLookup.getChildByLocalName(solidFill3, "srgbClr");
49120
+ const srgb = xmlLookup.getChildByLocalName(solidFill32, "srgbClr");
49106
49121
  const val2 = String(srgb?.["@_val"] || "").trim();
49107
49122
  return val2.length === 6 ? `#${val2}` : void 0;
49108
49123
  }
@@ -65952,9 +65967,9 @@ var init_effect_dag_specific_helpers = __esm({
65952
65967
  }
65953
65968
  });
65954
65969
  function fillOverlayColorHost(fillOverlay, context) {
65955
- const solidFill3 = fillOverlay["a:solidFill"];
65956
- if (solidFill3) {
65957
- return solidFill3;
65970
+ const solidFill32 = fillOverlay["a:solidFill"];
65971
+ if (solidFill32) {
65972
+ return solidFill32;
65958
65973
  }
65959
65974
  const gradFill = fillOverlay["a:gradFill"];
65960
65975
  if (!gradFill) {
@@ -67484,20 +67499,20 @@ var init_PptxShapeStyleExtractor = __esm({
67484
67499
  extractShapeStyle(spPr, styleNode) {
67485
67500
  const style = {};
67486
67501
  const shapeProps = spPr || {};
67487
- const solidFill3 = drawingChild(shapeProps, "solidFill");
67502
+ const solidFill32 = drawingChild(shapeProps, "solidFill");
67488
67503
  const gradFill = drawingChild(shapeProps, "gradFill");
67489
67504
  const pattFill = drawingChild(shapeProps, "pattFill");
67490
67505
  const noFill = hasDrawingChild(shapeProps, "noFill");
67491
67506
  const blipFill = drawingChild(shapeProps, "blipFill");
67492
- if (solidFill3) {
67507
+ if (solidFill32) {
67493
67508
  style.fillMode = "solid";
67494
- style.fillColor = this.context.parseColor(solidFill3);
67495
- style.fillOpacity = this.context.extractColorOpacity(solidFill3);
67496
- const solidFillColorXml = extractColorChoiceXml(solidFill3);
67509
+ style.fillColor = this.context.parseColor(solidFill32);
67510
+ style.fillOpacity = this.context.extractColorOpacity(solidFill32);
67511
+ const solidFillColorXml = extractColorChoiceXml(solidFill32);
67497
67512
  if (solidFillColorXml) {
67498
67513
  style.fillColorXml = solidFillColorXml;
67499
67514
  }
67500
- const solidFillColorRef = themeColorRefFromColorChoice(solidFill3);
67515
+ const solidFillColorRef = themeColorRefFromColorChoice(solidFill32);
67501
67516
  if (solidFillColorRef) {
67502
67517
  style.fillColorRef = solidFillColorRef;
67503
67518
  }
@@ -67723,11 +67738,11 @@ function parseTintShadeVal(value) {
67723
67738
  const fraction = parseOoxmlPercent(value);
67724
67739
  return fraction === void 0 || fraction === 0 ? void 0 : Math.round(fraction * 1e5);
67725
67740
  }
67726
- function parseSolidFillStyle(solidFill3) {
67727
- if (!solidFill3) {
67741
+ function parseSolidFillStyle(solidFill32) {
67742
+ if (!solidFill32) {
67728
67743
  return void 0;
67729
67744
  }
67730
- const schemeClr = solidFill3["a:schemeClr"];
67745
+ const schemeClr = solidFill32["a:schemeClr"];
67731
67746
  if (!schemeClr) {
67732
67747
  return void 0;
67733
67748
  }
@@ -67770,13 +67785,13 @@ function parseBorderSide(side) {
67770
67785
  border.dash = dashVal;
67771
67786
  has = true;
67772
67787
  }
67773
- const solidFill3 = ln["a:solidFill"];
67774
- const fill = parseSolidFillStyle(solidFill3);
67788
+ const solidFill32 = ln["a:solidFill"];
67789
+ const fill = parseSolidFillStyle(solidFill32);
67775
67790
  if (fill) {
67776
67791
  border.fill = fill;
67777
67792
  has = true;
67778
67793
  } else {
67779
- const srgb = solidFill3?.["a:srgbClr"];
67794
+ const srgb = solidFill32?.["a:srgbClr"];
67780
67795
  const hex4 = srgb ? String(srgb["@_val"] || "").trim() : "";
67781
67796
  if (hex4) {
67782
67797
  border.color = hex4.startsWith("#") ? hex4 : `#${hex4}`;
@@ -71336,10 +71351,6 @@ var init_compatibility_child_sets = __esm({
71336
71351
  ]);
71337
71352
  GRAPHIC_FRAME_LIMITATIONS = {
71338
71353
  unknown: ["UNSUPPORTED_GRAPHIC_FRAME", "The graphic-frame payload is preserved but unsupported."],
71339
- smartArt: [
71340
- "PARTIAL_SMARTART_SUPPORT",
71341
- "SmartArt is parsed and preserved, but some DiagramML behavior is not editable."
71342
- ],
71343
71354
  ole: [
71344
71355
  "PARTIAL_OLE_SUPPORT",
71345
71356
  "The OLE payload renders as a preview image and can be downloaded or opened in a new tab, but cannot be edited in place."
@@ -80229,8 +80240,8 @@ function parseTypedTextStyle(txPrNode, localName28, colorParser) {
80229
80240
  if (typeface) {
80230
80241
  style.fontFamily = String(typeface);
80231
80242
  }
80232
- const solidFill3 = nodesOf(defRPr, "solidFill", localName28)[0];
80233
- const color2 = literalColor(solidFill3, localName28, colorParser);
80243
+ const solidFill32 = nodesOf(defRPr, "solidFill", localName28)[0];
80244
+ const color2 = literalColor(solidFill32, localName28, colorParser);
80234
80245
  if (color2) {
80235
80246
  style.color = color2;
80236
80247
  }
@@ -95055,8 +95066,8 @@ function parseTableBackground(tblBg) {
95055
95066
  return void 0;
95056
95067
  }
95057
95068
  const fillNode = tblBg["a:fill"];
95058
- const solidFill3 = fillNode?.["a:solidFill"] ?? tblBg["a:solidFill"];
95059
- const schemeClr = solidFill3?.["a:schemeClr"];
95069
+ const solidFill32 = fillNode?.["a:solidFill"] ?? tblBg["a:solidFill"];
95070
+ const schemeClr = solidFill32?.["a:schemeClr"];
95060
95071
  const schemeColor = schemeClr ? String(schemeClr["@_val"] || "").trim() || void 0 : void 0;
95061
95072
  const fill = schemeColor ? { schemeColor } : void 0;
95062
95073
  const hasEffectLst = Boolean(tblBg["a:effectLst"]);
@@ -95852,9 +95863,9 @@ var init_PptxHandlerRuntimeImageEffects = __esm({
95852
95863
  }
95853
95864
  rawCopy[key2] = fillOverlay[key2];
95854
95865
  }
95855
- const solidFill3 = fillOverlay["a:solidFill"];
95856
- const resolvedColor = solidFill3 ? this.parseColor(solidFill3) : void 0;
95857
- const resolvedOpacity = solidFill3 ? this.extractColorOpacity(solidFill3) ?? 1 : void 0;
95866
+ const solidFill32 = fillOverlay["a:solidFill"];
95867
+ const resolvedColor = solidFill32 ? this.parseColor(solidFill32) : void 0;
95868
+ const resolvedOpacity = solidFill32 ? this.extractColorOpacity(solidFill32) ?? 1 : void 0;
95858
95869
  const gradFill = fillOverlay["a:gradFill"];
95859
95870
  const resolvedGradient = gradFill ? this.resolveFillOverlayGradient(gradFill) : void 0;
95860
95871
  const pattFill = fillOverlay["a:pattFill"];
@@ -97223,8 +97234,8 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
97223
97234
  if (hasNoFill) {
97224
97235
  return "none";
97225
97236
  }
97226
- const solidFill3 = this.xmlLookupService.getChildByLocalName(shapeProperties, "solidFill");
97227
- return solidFill3 ? this.parseColor(solidFill3) : void 0;
97237
+ const solidFill32 = this.xmlLookupService.getChildByLocalName(shapeProperties, "solidFill");
97238
+ return solidFill32 ? this.parseColor(solidFill32) : void 0;
97228
97239
  }
97229
97240
  /**
97230
97241
  * Extract chart style metadata from chart XML.
@@ -100163,14 +100174,14 @@ var init_PptxHandlerRuntimeTextRunStyleExtraction = __esm({
100163
100174
  if (csTypeface) {
100164
100175
  style.complexScriptFont = csTypeface;
100165
100176
  }
100166
- const solidFill3 = xmlChild(runProperties2, "a:solidFill");
100167
- if (solidFill3) {
100168
- style.color = this.parseColor(solidFill3);
100169
- const colorXml2 = extractColorChoiceXml(solidFill3);
100177
+ const solidFill32 = xmlChild(runProperties2, "a:solidFill");
100178
+ if (solidFill32) {
100179
+ style.color = this.parseColor(solidFill32);
100180
+ const colorXml2 = extractColorChoiceXml(solidFill32);
100170
100181
  if (colorXml2) {
100171
100182
  style.colorXml = colorXml2;
100172
100183
  }
100173
- const colorRef = themeColorRefFromColorChoice(solidFill3);
100184
+ const colorRef = themeColorRefFromColorChoice(solidFill32);
100174
100185
  if (colorRef) {
100175
100186
  style.colorRef = colorRef;
100176
100187
  }
@@ -116497,11 +116508,11 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
116497
116508
  }
116498
116509
  const bgPr = xmlChild(bg, "p:bgPr");
116499
116510
  if (bgPr) {
116500
- const solidFill3 = xmlChild(bgPr, "a:solidFill");
116501
- if (solidFill3) {
116511
+ const solidFill32 = xmlChild(bgPr, "a:solidFill");
116512
+ if (solidFill32) {
116502
116513
  return this.blendBackgroundColorOntoWhite(
116503
- this.parseColor(solidFill3),
116504
- this.extractColorOpacity(solidFill3)
116514
+ this.parseColor(solidFill32),
116515
+ this.extractColorOpacity(solidFill32)
116505
116516
  );
116506
116517
  }
116507
116518
  const pattFill = xmlChild(bgPr, "a:pattFill");
@@ -116594,11 +116605,11 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
116594
116605
  if (idx === 0) {
116595
116606
  return void 0;
116596
116607
  }
116597
- const solidFill3 = xmlChild(bgRef, "a:solidFill");
116598
- if (solidFill3) {
116608
+ const solidFill32 = xmlChild(bgRef, "a:solidFill");
116609
+ if (solidFill32) {
116599
116610
  return this.blendBackgroundColorOntoWhite(
116600
- this.parseColor(solidFill3),
116601
- this.extractColorOpacity(solidFill3)
116611
+ this.parseColor(solidFill32),
116612
+ this.extractColorOpacity(solidFill32)
116602
116613
  );
116603
116614
  }
116604
116615
  const overrideColor = this.blendBackgroundColorOntoWhite(
@@ -117416,13 +117427,13 @@ var init_PptxHandlerRuntimePlaceholderStyles = __esm({
117416
117427
  if (defRPr["@_i"] !== void 0) {
117417
117428
  style.italic = defRPr["@_i"] === "1";
117418
117429
  }
117419
- const solidFill3 = defRPr["a:solidFill"];
117420
- const color2 = this.parseColor(solidFill3);
117430
+ const solidFill32 = defRPr["a:solidFill"];
117431
+ const color2 = this.parseColor(solidFill32);
117421
117432
  if (color2) {
117422
117433
  style.color = color2;
117423
117434
  }
117424
- if (solidFill3) {
117425
- style.colorChoiceXml = solidFill3;
117435
+ if (solidFill32) {
117436
+ style.colorChoiceXml = solidFill32;
117426
117437
  }
117427
117438
  const latin = defRPr["a:latin"];
117428
117439
  if (latin?.["@_typeface"]) {
@@ -120156,8 +120167,8 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
120156
120167
  }
120157
120168
  const chrome = {};
120158
120169
  if (bg) {
120159
- const solidFill3 = this.xmlLookupService.getChildByLocalName(bg, "solidFill");
120160
- const bgColor = this.parseColor(solidFill3);
120170
+ const solidFill32 = this.xmlLookupService.getChildByLocalName(bg, "solidFill");
120171
+ const bgColor = this.parseColor(solidFill32);
120161
120172
  if (bgColor) {
120162
120173
  chrome.backgroundColor = bgColor;
120163
120174
  } else {
@@ -120171,8 +120182,8 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
120171
120182
  if (whole) {
120172
120183
  const lnNode = this.xmlLookupService.getChildByLocalName(whole, "ln");
120173
120184
  if (lnNode) {
120174
- const solidFill3 = this.xmlLookupService.getChildByLocalName(lnNode, "solidFill");
120175
- const outlineColor = this.parseColor(solidFill3);
120185
+ const solidFill32 = this.xmlLookupService.getChildByLocalName(lnNode, "solidFill");
120186
+ const outlineColor = this.parseColor(solidFill32);
120176
120187
  if (outlineColor) {
120177
120188
  chrome.outlineColor = outlineColor;
120178
120189
  }
@@ -120284,11 +120295,11 @@ function extractDrawingShapeFill(spPr, deps) {
120284
120295
  }
120285
120296
  return result;
120286
120297
  }
120287
- const solidFill3 = deps.getChild(spPr, "solidFill");
120288
- if (solidFill3) {
120289
- result.fillColor = deps.parseColor(solidFill3) ?? void 0;
120298
+ const solidFill32 = deps.getChild(spPr, "solidFill");
120299
+ if (solidFill32) {
120300
+ result.fillColor = deps.parseColor(solidFill32) ?? void 0;
120290
120301
  }
120291
- const gradFill = !solidFill3 ? deps.getChild(spPr, "gradFill") : void 0;
120302
+ const gradFill = !solidFill32 ? deps.getChild(spPr, "gradFill") : void 0;
120292
120303
  if (gradFill) {
120293
120304
  const stops = deps.extractGradientStops(gradFill).map((stop) => ({
120294
120305
  color: stop.color,
@@ -120302,7 +120313,7 @@ function extractDrawingShapeFill(spPr, deps) {
120302
120313
  result.fillColor ??= stops[Math.floor(stops.length / 2)]?.color;
120303
120314
  }
120304
120315
  }
120305
- const pattFill = !solidFill3 && !gradFill ? deps.getChild(spPr, "pattFill") : void 0;
120316
+ const pattFill = !solidFill32 && !gradFill ? deps.getChild(spPr, "pattFill") : void 0;
120306
120317
  if (pattFill) {
120307
120318
  const preset = String(pattFill["@_prst"] || "").trim();
120308
120319
  if (preset) {
@@ -120318,7 +120329,7 @@ function extractDrawingShapeFill(spPr, deps) {
120318
120329
  }
120319
120330
  result.fillColor ??= fg ?? bg;
120320
120331
  }
120321
- const blipFill = !solidFill3 && !gradFill && !pattFill ? deps.getChild(spPr, "blipFill") : void 0;
120332
+ const blipFill = !solidFill32 && !gradFill && !pattFill ? deps.getChild(spPr, "blipFill") : void 0;
120322
120333
  if (blipFill) {
120323
120334
  const blip = deps.getChild(blipFill, "blip");
120324
120335
  const embed = String(
@@ -148720,8 +148731,8 @@ function getOmmlMathColor(node) {
148720
148731
  }
148721
148732
  const drawingRunProperties = node["a:rPr"];
148722
148733
  if (drawingRunProperties && typeof drawingRunProperties === "object") {
148723
- const solidFill3 = drawingRunProperties["a:solidFill"];
148724
- const srgbColor = solidFill3 && typeof solidFill3 === "object" ? solidFill3["a:srgbClr"] : void 0;
148734
+ const solidFill22 = drawingRunProperties["a:solidFill"];
148735
+ const srgbColor = solidFill22 && typeof solidFill22 === "object" ? solidFill22["a:srgbClr"] : void 0;
148725
148736
  const value = srgbColor?.["@_val"];
148726
148737
  if (typeof value === "string" && /^[0-9a-f]{6}$/iu.test(value)) {
148727
148738
  return `#${value.toUpperCase()}`;
@@ -154479,6 +154490,102 @@ function buildCartesianHorizontalAxis(chartData, categoryLabels, layout, kind, p
154479
154490
  displayChartData: datePlan || categoryPlan ? chartDataInCategoryOrder(chartData, sourceIndices2) : chartData
154480
154491
  };
154481
154492
  }
154493
+ function estimatedGlyphAdvanceRatio(glyph) {
154494
+ if (/\p{Mark}/u.test(glyph)) {
154495
+ return 0;
154496
+ }
154497
+ if (/\s/u.test(glyph)) {
154498
+ return 0.33;
154499
+ }
154500
+ if (/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Extended_Pictographic}]/u.test(
154501
+ glyph
154502
+ )) {
154503
+ return 1;
154504
+ }
154505
+ if (/[A-Z]/u.test(glyph)) {
154506
+ return 0.65;
154507
+ }
154508
+ if (/[a-z0-9]/u.test(glyph)) {
154509
+ return 0.55;
154510
+ }
154511
+ if (/[,.;:!?()\u005b\u005d{}'"`\-_/\\]/u.test(glyph)) {
154512
+ return 0.35;
154513
+ }
154514
+ return 0.6;
154515
+ }
154516
+ function estimatedTextWidth(glyphs, fontSize) {
154517
+ return glyphs.reduce((sum, glyph) => sum + estimatedGlyphAdvanceRatio(glyph) * fontSize, 0);
154518
+ }
154519
+ function estimateTextWidth(text22, fontSize) {
154520
+ return estimatedTextWidth(Array.from(text22), fontSize);
154521
+ }
154522
+ var HANGING_PUNCTUATION_RE = /^[\u3001\u3002\uff0c\uff0e\uff01\uff1f\uff1b\uff1a\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\uff09\uff3d\uff5d\u2019\u201d\u00bb\u203a]$/u;
154523
+ var BREAKABLE_GLYPH_RE = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Extended_Pictographic}]$/u;
154524
+ function estimatedWrapUnits(text22) {
154525
+ const units = [];
154526
+ let unbreakableRun = "";
154527
+ const flushRun = () => {
154528
+ if (unbreakableRun.length > 0) {
154529
+ units.push(unbreakableRun);
154530
+ unbreakableRun = "";
154531
+ }
154532
+ };
154533
+ for (const glyph of Array.from(text22)) {
154534
+ if (/\s/u.test(glyph) || BREAKABLE_GLYPH_RE.test(glyph)) {
154535
+ flushRun();
154536
+ units.push(glyph);
154537
+ } else {
154538
+ unbreakableRun += glyph;
154539
+ }
154540
+ }
154541
+ flushRun();
154542
+ return units;
154543
+ }
154544
+ function wrapTextByEstimatedWidth(text22, maxWidth, fontSize, options = {}) {
154545
+ if (!text22 || text22.trim().length === 0) {
154546
+ return [];
154547
+ }
154548
+ if (!(maxWidth > 0) || !(fontSize > 0)) {
154549
+ return [];
154550
+ }
154551
+ const lines = [];
154552
+ for (const paragraph of text22.split(/\r?\n/u)) {
154553
+ if (paragraph.trim().length === 0) {
154554
+ if (options.keepBlankLines) {
154555
+ lines.push("");
154556
+ }
154557
+ continue;
154558
+ }
154559
+ let current = "";
154560
+ let pendingWhitespace = false;
154561
+ for (const unit of estimatedWrapUnits(paragraph)) {
154562
+ if (/^\s+$/u.test(unit)) {
154563
+ pendingWhitespace = current.length > 0;
154564
+ continue;
154565
+ }
154566
+ const separator = pendingWhitespace && current.length > 0 ? " " : "";
154567
+ const candidate = `${current}${separator}${unit}`;
154568
+ if (current.length === 0 || estimatedTextWidth(Array.from(candidate), fontSize) <= maxWidth) {
154569
+ current = candidate;
154570
+ pendingWhitespace = false;
154571
+ continue;
154572
+ }
154573
+ if (HANGING_PUNCTUATION_RE.test(unit)) {
154574
+ current += unit;
154575
+ pendingWhitespace = false;
154576
+ continue;
154577
+ }
154578
+ lines.push(current);
154579
+ current = unit;
154580
+ pendingWhitespace = false;
154581
+ }
154582
+ const completed = current.trimEnd();
154583
+ if (completed.length > 0) {
154584
+ lines.push(completed);
154585
+ }
154586
+ }
154587
+ return lines;
154588
+ }
154482
154589
  function valueToX(val2, range, leftX, rightX) {
154483
154590
  const usable = rightX - leftX;
154484
154591
  let ratio;
@@ -154528,6 +154635,12 @@ function buildSideCategoryLabels(categoryLabels, layout) {
154528
154635
  dominantBaseline: "central"
154529
154636
  }));
154530
154637
  }
154638
+ function widestCategoryLabelWidth(categoryLabels, fontSize) {
154639
+ return categoryLabels.reduce(
154640
+ (max, label) => Math.max(max, estimateTextWidth(label, fontSize)),
154641
+ 0
154642
+ );
154643
+ }
154531
154644
  function categoryTotals2(series, catCount) {
154532
154645
  return Array.from(
154533
154646
  { length: catCount },
@@ -154542,7 +154655,9 @@ function barFill(chartData, series, seriesIndex, pointIndex) {
154542
154655
  return resolveDataPointFill(series, pointIndex, paletteColor2(seriesIndex, palette)) ?? seriesColor2(series, seriesIndex, palette);
154543
154656
  }
154544
154657
  function buildHorizontalBarViewModel(element, chartData, categoryLabels) {
154545
- const layout = computePlotLayout(element.width, element.height, chartData, true), catCount = Math.max(categoryLabels.length, 1), series = chartData.series, grouping = chartData.grouping ?? "clustered", isStacked = grouping === "stacked" || grouping === "percentStacked", isPercent = grouping === "percentStacked", range = isPercent ? { min: 0, max: 100, span: 100 } : isStacked ? computeStackedValueRange(series, catCount, layout.plotWidth) : computeValueRangeForChart(series, chartData.axes, layout.plotWidth), { gridlines, axisLabels } = buildTransposedValueAxis(range, layout), zeroX = valueToX(0, range, layout.plotLeft, layout.plotRight), zeroLine = range.min < 0 && range.max > 0 ? {
154658
+ const layout = computePlotLayout(element.width, element.height, chartData, true, {
154659
+ leftCategoryLabelWidth: widestCategoryLabelWidth(categoryLabels, DEFAULT_CHART_TEXT_PX)
154660
+ }), catCount = Math.max(categoryLabels.length, 1), series = chartData.series, grouping = chartData.grouping ?? "clustered", isStacked = grouping === "stacked" || grouping === "percentStacked", isPercent = grouping === "percentStacked", range = isPercent ? { min: 0, max: 100, span: 100 } : isStacked ? computeStackedValueRange(series, catCount, layout.plotWidth) : computeValueRangeForChart(series, chartData.axes, layout.plotWidth), { gridlines, axisLabels } = buildTransposedValueAxis(range, layout), zeroX = valueToX(0, range, layout.plotLeft, layout.plotRight), zeroLine = range.min < 0 && range.max > 0 ? {
154546
154661
  kind: "line",
154547
154662
  x1: zeroX,
154548
154663
  y1: layout.plotTop,
@@ -157739,9 +157854,12 @@ function categoryAxisBand(chartData) {
157739
157854
  ), fontPx = axis?.fontSize !== void 0 ? chartFontPx(axis.fontSize) : DEFAULT_CHART_TEXT_PX, offset = 4 + 8 * ((axis?.labelOffset ?? 100) / 100);
157740
157855
  return Math.max(24, offset + fontPx * 1.2);
157741
157856
  }
157857
+ function leftAxisBand(leftCategoryLabelWidth) {
157858
+ return Math.max(40, (leftCategoryLabelWidth ?? 0) + 4);
157859
+ }
157742
157860
  function computePlotLayout(elementWidth, elementHeight, chartData, hasAxes, options) {
157743
157861
  const svgWidth = Math.max(1, elementWidth), svgHeight = Math.max(1, elementHeight);
157744
- let plotLeft = hasAxes ? 48 : 8, plotTop = 8, plotRight = svgWidth - 8, plotBottom = svgHeight - (hasAxes ? categoryAxisBand(chartData) : 8);
157862
+ let plotLeft = hasAxes ? 8 + leftAxisBand(options?.leftCategoryLabelWidth) : 8, plotTop = 8, plotRight = svgWidth - 8, plotBottom = svgHeight - (hasAxes ? categoryAxisBand(chartData) : 8);
157745
157863
  if (hasAxes && options?.categoryAxisAtTop) {
157746
157864
  plotBottom = svgHeight - 8;
157747
157865
  plotTop += categoryAxisBand(chartData);
@@ -157780,7 +157898,7 @@ function computePlotLayout(elementWidth, elementHeight, chartData, hasAxes, opti
157780
157898
  plotRight = manual.x + manual.width;
157781
157899
  plotBottom = manual.y + manual.height;
157782
157900
  if (hasAxes && plotLayout.layoutTarget !== "inner") {
157783
- plotLeft += 40;
157901
+ plotLeft += leftAxisBand(options?.leftCategoryLabelWidth);
157784
157902
  plotBottom -= categoryAxisBand(chartData) - 8;
157785
157903
  }
157786
157904
  }
@@ -158363,7 +158481,7 @@ function regionViewBounds(viewedRegionType, regionValues) {
158363
158481
  };
158364
158482
  }
158365
158483
  function scalePathD(d, scale2, dx, dy) {
158366
- const tokens = d.trim().split(/[\s,]+/u);
158484
+ const tokens = d.match(/[A-Za-z]|-?\d+(?:\.\d+)?/gu) ?? [];
158367
158485
  const out = [];
158368
158486
  let i2 = 0;
158369
158487
  while (i2 < tokens.length) {
@@ -158378,7 +158496,7 @@ function scalePathD(d, scale2, dx, dy) {
158378
158496
  continue;
158379
158497
  }
158380
158498
  const xRaw = parseFloat(tok);
158381
- const yRaw = parseFloat(tokens[i2 + 1] ?? "0");
158499
+ const yRaw = parseFloat(tokens[i2 + 1] ?? "");
158382
158500
  if (!Number.isNaN(xRaw) && !Number.isNaN(yRaw)) {
158383
158501
  out.push(`${(xRaw * scale2 + dx).toFixed(2)},${(yRaw * scale2 + dy).toFixed(2)}`);
158384
158502
  i2 += 2;
@@ -173131,6 +173249,8 @@ var translationsEn = {
173131
173249
  "pptx.collaboration.userCount": "{{count}} user(s)",
173132
173250
  "pptx.collaboration.youLabel": "{{name}} (you)",
173133
173251
  "pptx.collaboration.usersConnected": "{{count}} user(s) connected",
173252
+ "pptx.collaboration.editable": "Editable",
173253
+ "pptx.collaboration.shellStatusLabel": "Collaboration status",
173134
173254
  "pptx.collaboration.moreUsers": "{{count}} more user(s)",
173135
173255
  "pptx.collaboration.onePersonHere": "1 person here",
173136
173256
  "pptx.collaboration.peopleHere": "{{count}} people here",
@@ -179011,11 +179131,16 @@ function buildParagraphs(element, fieldContext, segmentOverrides, options) {
179011
179131
  }
179012
179132
  var sessions = /* @__PURE__ */ new WeakMap();
179013
179133
  var nextSession = 0;
179014
- function createInlineListSeed(element) {
179015
- if (!hasTextProperties(element) || !element.textSegments?.some((segment) => resolveParagraphBullet(segment))) {
179134
+ function createInlineListSeed(element, options) {
179135
+ if (!hasTextProperties(element) || !options?.includePlain && !element.textSegments?.some((segment) => resolveParagraphBullet(segment))) {
179016
179136
  return void 0;
179017
179137
  }
179018
- const segments = structuredClone(element.textSegments);
179138
+ const textStyle = element.textStyle;
179139
+ const segments = element.textSegments?.length ? structuredClone(element.textSegments) : (element.text ?? "").split("\n").flatMap((text22, index) => [
179140
+ ...index > 0 ? [{ text: "\n", style: {}, isParagraphBreak: true }] : [],
179141
+ { text: text22, style: structuredClone(textStyle ?? {}) }
179142
+ ]);
179143
+ element = { ...element, textSegments: structuredClone(segments) };
179019
179144
  const paragraphs2 = [{ segments: [] }];
179020
179145
  const indices = [[]];
179021
179146
  for (const [index, segment] of segments.entries()) {
@@ -179243,6 +179368,54 @@ function clearSingleTextDecoration(node, blockRoot) {
179243
179368
  ancestor = ancestor.parentElement;
179244
179369
  }
179245
179370
  }
179371
+ var snapshots = /* @__PURE__ */ new WeakMap();
179372
+ function recordInlineListProvenance(seed, root, snapshot, blocks, origins, unchanged22) {
179373
+ const session = inlineListSession(seed);
179374
+ const paragraphs2 = /* @__PURE__ */ new Map();
179375
+ const hidden = [];
179376
+ const segments = snapshot.textSegments ?? [];
179377
+ let paragraphIndex = 0;
179378
+ let start = 0;
179379
+ const record2 = (end, terminator) => {
179380
+ const block = blocks[paragraphIndex++];
179381
+ if (!block) return;
179382
+ paragraphs2.set(block, start < end ? start : terminator ?? null);
179383
+ const body = segments.slice(start, end);
179384
+ const content = body.filter((segment, index) => index !== 0 || !isBulletMarkerSegment(segment));
179385
+ const onlyEmptyCarrier = content.length === 1 && content[0].text === "" && !content[0].isLineBreak;
179386
+ for (let index = start; index < end; index++) {
179387
+ const segment = segments[index];
179388
+ const marker = index === start && isBulletMarkerSegment(segment);
179389
+ if (!marker && (segment.text !== "" || segment.isLineBreak)) continue;
179390
+ const node = marker || onlyEmptyCarrier ? block : unchanged22 ? inlineListDescendants(block).find((child27) => session.runNodes.get(child27) === index) : origins[index];
179391
+ hidden.push({ node, kind: marker ? "marker" : "empty", index });
179392
+ }
179393
+ };
179394
+ for (const [index, segment] of segments.entries()) {
179395
+ if (!isParagraphSeparatorSegment(segment)) continue;
179396
+ record2(index, index);
179397
+ start = index + 1;
179398
+ }
179399
+ record2(segments.length);
179400
+ snapshots.set(snapshot, { seed, root, paragraphs: paragraphs2, hidden });
179401
+ }
179402
+ function readInlineListProvenance(snapshot, previous) {
179403
+ const current = snapshots.get(snapshot);
179404
+ const before = previous && snapshots.get(previous);
179405
+ if (!current || previous && (!before || before.seed !== current.seed || before.root !== current.root)) {
179406
+ return void 0;
179407
+ }
179408
+ const matches2 = (a, b) => a.node !== void 0 && a.node === b.node && a.kind === b.kind;
179409
+ return {
179410
+ paragraphSources: [...current.paragraphs.keys()].map(
179411
+ (node) => before?.paragraphs.get(node) ?? null
179412
+ ),
179413
+ hiddenSources: current.hidden.map((origin) => {
179414
+ const old = before?.hidden.filter((candidate) => matches2(origin, candidate));
179415
+ return old?.length === 1 && current.hidden.filter((candidate) => matches2(origin, candidate)).length === 1 ? old[0].index : null;
179416
+ })
179417
+ };
179418
+ }
179246
179419
  function inlineListStyleDelta(node, baseline = "", inheritedColor) {
179247
179420
  const style = {};
179248
179421
  const original = node.ownerDocument.createElement("span").style;
@@ -179301,6 +179474,11 @@ function bodyOnly(segment) {
179301
179474
  }
179302
179475
  function readInlineListRuns(session, block, bodyStyle) {
179303
179476
  const runs = [];
179477
+ const origins = [];
179478
+ const push2 = (segment, node) => {
179479
+ runs.push(segment);
179480
+ origins.push(node);
179481
+ };
179304
179482
  let unsupported = false;
179305
179483
  let unchanged22 = true;
179306
179484
  let placeholder = false;
@@ -179314,10 +179492,10 @@ function readInlineListRuns(session, block, bodyStyle) {
179314
179492
  const style2 = { ...inherited, ...parentDelta };
179315
179493
  for (const [index2, text22] of node.nodeValue.split("\n").entries()) {
179316
179494
  if (index2 > 0) {
179317
- runs.push({ text: "\n", style: { ...style2 }, isLineBreak: true });
179495
+ push2({ text: "\n", style: { ...style2 }, isLineBreak: true }, node);
179318
179496
  }
179319
179497
  if (text22) {
179320
- runs.push({ text: text22, style: { ...style2 } });
179498
+ push2({ text: text22, style: { ...style2 } }, node);
179321
179499
  }
179322
179500
  }
179323
179501
  }
@@ -179349,7 +179527,7 @@ function readInlineListRuns(session, block, bodyStyle) {
179349
179527
  const oldChildren = originalIndex === void 0 ? void 0 : session.runChildren.get(originalIndex);
179350
179528
  const intact = originalIndex !== void 0 && node.innerHTML === session.runHtml.get(originalIndex) && children13.length === oldChildren?.length && children13.every((child27, childIndex) => child27 === oldChildren[childIndex]);
179351
179529
  if (intact && original) {
179352
- runs.push({ ...bodyOnly(original), style });
179530
+ push2({ ...bodyOnly(original), style }, node);
179353
179531
  unchanged22 &&= index === originalIndex && Object.keys(delta).length === 0;
179354
179532
  return;
179355
179533
  }
@@ -179363,7 +179541,7 @@ function readInlineListRuns(session, block, bodyStyle) {
179363
179541
  return;
179364
179542
  }
179365
179543
  if (node.tagName === "BR") {
179366
- runs.push({ text: "\n", style, isLineBreak: true });
179544
+ push2({ text: "\n", style, isLineBreak: true }, node);
179367
179545
  placeholder = original?.isLineBreak !== true;
179368
179546
  return;
179369
179547
  }
@@ -179373,9 +179551,9 @@ function readInlineListRuns(session, block, bodyStyle) {
179373
179551
  };
179374
179552
  walk2(block, bodyStyle);
179375
179553
  if (runs.length === 1 && runs[0].isLineBreak && placeholder) {
179376
- return { runs: [{ text: "", style: runs[0].style }], unchanged: false };
179554
+ return { runs: [{ text: "", style: runs[0].style }], origins: [block], unchanged: false };
179377
179555
  }
179378
- return unsupported ? void 0 : { runs, unchanged: unchanged22 };
179556
+ return unsupported ? void 0 : { runs, origins, unchanged: unchanged22 };
179379
179557
  }
179380
179558
  function hasOnlyCaretPlaceholder(element) {
179381
179559
  const content = Array.from(element.childNodes).filter((child27) => {
@@ -179447,6 +179625,7 @@ function readInlineListSnapshot(seed, root) {
179447
179625
  return fallback("unsupported-paragraph-structure");
179448
179626
  }
179449
179627
  const segments = [];
179628
+ const origins = [];
179450
179629
  const text22 = [];
179451
179630
  const sequence = createAutoNumberSequence();
179452
179631
  let unchanged22 = blocks.length === seed.paragraphs.length;
@@ -179467,7 +179646,7 @@ function readInlineListSnapshot(seed, root) {
179467
179646
  return fallback("unsupported-run-structure");
179468
179647
  }
179469
179648
  const { runs } = body;
179470
- const bodyText = runs.map((run) => run.text).join("");
179649
+ const bodyText = runs.map((run) => run.isLineBreak ? "\n" : run.text).join("");
179471
179650
  text22.push(bodyText);
179472
179651
  unchanged22 &&= original === position2 && token2 === seed.paragraphs[position2].token && body.unchanged && bodyText === seed.paragraphs[position2].runs.map((run) => run.text).join("") && runs.every(
179473
179652
  (run, index) => JSON.stringify(run.style) === JSON.stringify(seed.paragraphs[position2].runs[index]?.style)
@@ -179477,6 +179656,7 @@ function readInlineListSnapshot(seed, root) {
179477
179656
  text: "",
179478
179657
  style: structuredClone(carrier?.paragraphInsertionStyle ?? carrier?.style ?? {})
179479
179658
  });
179659
+ body.origins.push(block);
179480
179660
  }
179481
179661
  if (carrier) {
179482
179662
  if (original !== void 0) {
@@ -179524,14 +179704,18 @@ function readInlineListSnapshot(seed, root) {
179524
179704
  delete first[key2];
179525
179705
  }
179526
179706
  runs.unshift(marker);
179707
+ body.origins.unshift(block);
179527
179708
  }
179528
179709
  if (position2 > 0) {
179529
179710
  segments.push({ text: "\n", style: {}, isParagraphBreak: true });
179711
+ origins.push(void 0);
179530
179712
  }
179531
179713
  segments.push(...runs);
179714
+ origins.push(...body.origins);
179532
179715
  }
179533
179716
  const textSegments = unchanged22 ? structuredClone(session.originalSegments) : segments;
179534
179717
  const snapshot = { elementId: seed.elementId, text: text22.join("\n"), textSegments };
179718
+ recordInlineListProvenance(seed, root, snapshot, blocks, origins, unchanged22);
179535
179719
  return {
179536
179720
  kind: "supported",
179537
179721
  snapshot,
@@ -179540,6 +179724,12 @@ function readInlineListSnapshot(seed, root) {
179540
179724
  })
179541
179725
  };
179542
179726
  }
179727
+ function readInlineListNativeSnapshot(seed, root, previous) {
179728
+ const read = readInlineListSnapshot(seed, root);
179729
+ if (read.kind !== "supported") return read;
179730
+ const provenance = readInlineListProvenance(read.snapshot, previous);
179731
+ return provenance ? { ...read, ...provenance } : { kind: "unsupported", reason: "unknown-native-baseline", text: read.snapshot.text };
179732
+ }
179543
179733
  function paragraphBodies(segments) {
179544
179734
  const paragraphs2 = [""];
179545
179735
  let first = true;
@@ -179549,7 +179739,7 @@ function paragraphBodies(segments) {
179549
179739
  first = true;
179550
179740
  } else {
179551
179741
  if (!first || !isBulletMarkerSegment(segment)) {
179552
- paragraphs2[paragraphs2.length - 1] += segment.text;
179742
+ paragraphs2[paragraphs2.length - 1] += segment.isLineBreak ? "\n" : segment.text;
179553
179743
  }
179554
179744
  first = false;
179555
179745
  }
@@ -179569,7 +179759,7 @@ function modelPoint(segments, offset, end) {
179569
179759
  }
179570
179760
  continue;
179571
179761
  }
179572
- const next = position2 + segment.text.length;
179762
+ const next = position2 + (first || segment.isLineBreak ? 1 : segment.text.length);
179573
179763
  if (!first && !segment.isLineBreak) {
179574
179764
  last = { index, offset: segment.text.length };
179575
179765
  if (end ? offset <= next : offset < next || offset === position2 && next === position2) {
@@ -179581,18 +179771,30 @@ function modelPoint(segments, offset, end) {
179581
179771
  return last;
179582
179772
  }
179583
179773
  function readInlineListSelection(seed, root, selection = root.ownerDocument.defaultView?.getSelection() ?? null) {
179774
+ return readInlineListRange(seed, root, selection?.rangeCount ? selection.getRangeAt(0) : null);
179775
+ }
179776
+ function readInlineListRange(seed, root, range) {
179584
179777
  const read = readInlineListSnapshot(seed, root);
179585
179778
  if (read.kind !== "supported") {
179586
179779
  return { kind: "unsupported", reason: read.reason };
179587
179780
  }
179588
179781
  const { snapshot } = read;
179589
- if (!selection?.rangeCount) {
179782
+ if (!range) {
179590
179783
  return { kind: "supported", snapshot, selection: null };
179591
179784
  }
179592
- const range = selection.getRangeAt(0);
179593
179785
  if (!root.contains(range.startContainer) || !root.contains(range.endContainer)) {
179594
179786
  return { kind: "unsupported", reason: "selection-outside-session" };
179595
179787
  }
179788
+ try {
179789
+ const checked = root.ownerDocument.createRange();
179790
+ checked.setStart(range.startContainer, range.startOffset);
179791
+ checked.setEnd(range.endContainer, range.endOffset);
179792
+ if (checked.startContainer !== range.startContainer || checked.startOffset !== range.startOffset || checked.endContainer !== range.endContainer || checked.endOffset !== range.endOffset) {
179793
+ return { kind: "unsupported", reason: "invalid-selection-boundary" };
179794
+ }
179795
+ } catch {
179796
+ return { kind: "unsupported", reason: "invalid-selection-boundary" };
179797
+ }
179596
179798
  const blocks = Array.from(root.children);
179597
179799
  const bodies = paragraphBodies(snapshot.textSegments);
179598
179800
  if (blocks.some(
@@ -185815,6 +186017,26 @@ function presenceToCursors(presence, activeSlideIndex) {
185815
186017
  }
185816
186018
  return cursors;
185817
186019
  }
186020
+ function resolveCollaborationShellEditability(input) {
186021
+ return input.authorizedCanEdit && (!input.configured || !input.readOnly && !input.sourcePending && !input.sourceError);
186022
+ }
186023
+ function resolveCollaborationShellState(input) {
186024
+ const status = input.configured ? input.status : "disconnected";
186025
+ const remoteUsers = input.configured ? input.remoteUsers : [];
186026
+ return {
186027
+ canEdit: resolveCollaborationShellEditability(input),
186028
+ status,
186029
+ remoteUsers,
186030
+ connectedCount: remoteUsers.length + (status === "connected" ? 1 : 0)
186031
+ };
186032
+ }
186033
+ function describeCollaborationShellState(state, translate) {
186034
+ return [
186035
+ translate(`pptx.collaboration.status.${state.status}`),
186036
+ translate("pptx.collaboration.usersConnected", { count: state.connectedCount }),
186037
+ translate(state.canEdit ? "pptx.collaboration.editable" : "pptx.toolbar.readOnly")
186038
+ ].join(" \xB7 ");
186039
+ }
185818
186040
  function observeExternalCollaborationSession(session, onSnapshot) {
185819
186041
  let active2 = true;
185820
186042
  let subscribing = true;
@@ -186010,6 +186232,9 @@ function buildSegmentAttrs(seg) {
186010
186232
  if (seg.paragraphInsertionStyle) {
186011
186233
  a.pi = JSON.stringify(seg.paragraphInsertionStyle);
186012
186234
  }
186235
+ if (seg.paragraphProperties) {
186236
+ a.pp = JSON.stringify(seg.paragraphProperties);
186237
+ }
186013
186238
  if (typeof seg.fieldType === "string") {
186014
186239
  a.ft = seg.fieldType;
186015
186240
  }
@@ -186122,6 +186347,12 @@ function decodeDelta(delta) {
186122
186347
  } catch {
186123
186348
  }
186124
186349
  }
186350
+ if (a.pp) {
186351
+ try {
186352
+ seg.paragraphProperties = JSON.parse(a.pp);
186353
+ } catch {
186354
+ }
186355
+ }
186125
186356
  if (a.ft) {
186126
186357
  seg.fieldType = a.ft;
186127
186358
  }
@@ -186184,6 +186415,22 @@ function decodeDelta(delta) {
186184
186415
  function decodeTextBody(ytext) {
186185
186416
  return decodeDelta(ytext.toDelta());
186186
186417
  }
186418
+ function inlineListBodyText(segments) {
186419
+ let first = true;
186420
+ let text22 = "";
186421
+ for (const segment of segments ?? []) {
186422
+ if (isParagraphSeparatorSegment(segment)) {
186423
+ text22 += "\n";
186424
+ first = true;
186425
+ } else {
186426
+ if (!first || !isBulletMarkerSegment(segment)) {
186427
+ text22 += segment.isLineBreak ? "\n" : segment.text;
186428
+ }
186429
+ first = false;
186430
+ }
186431
+ }
186432
+ return text22;
186433
+ }
186187
186434
  var YDOC_SLIDES_KEY = "pptx:slides";
186188
186435
  var SCALAR_ELEMENT_KEYS = /* @__PURE__ */ new Set([
186189
186436
  "id",
@@ -186437,6 +186684,9 @@ function readElementFromYMap(ymap, assets) {
186437
186684
  }
186438
186685
  });
186439
186686
  readAssetFields(ymap, assets, element);
186687
+ if (Array.isArray(element.textSegments) && element.textSegments.length > 0) {
186688
+ element.text = inlineListBodyText(element.textSegments);
186689
+ }
186440
186690
  return element;
186441
186691
  }
186442
186692
  function writeSlideToYMap(slide, ymap, factories, assets) {
@@ -186500,6 +186750,32 @@ function observeYDocSlides(ydoc, onChange) {
186500
186750
  arr.observeDeep(onChange);
186501
186751
  return () => arr.unobserveDeep(onChange);
186502
186752
  }
186753
+ var leases = /* @__PURE__ */ new WeakMap();
186754
+ function registerCollaborationTextLease(target, ownsModel) {
186755
+ const lease = { ownsModel };
186756
+ leases.set(target, lease);
186757
+ return () => {
186758
+ if (leases.get(target) === lease) {
186759
+ leases.delete(target);
186760
+ }
186761
+ };
186762
+ }
186763
+ function hasCollaborationTextLease(target, candidate) {
186764
+ const lease = leases.get(target);
186765
+ if (!lease) {
186766
+ return false;
186767
+ }
186768
+ try {
186769
+ if (lease.ownsModel(candidate) && leases.get(target) === lease) {
186770
+ return true;
186771
+ }
186772
+ } catch {
186773
+ }
186774
+ if (leases.get(target) === lease) {
186775
+ leases.delete(target);
186776
+ }
186777
+ return false;
186778
+ }
186503
186779
  function isYTextEditable(value) {
186504
186780
  return isYTextLike(value) && typeof value.delete === "function" && typeof value.format === "function";
186505
186781
  }
@@ -186622,8 +186898,11 @@ var LOCAL_SYNC_ORIGIN = "pptx-viewer:local-sync";
186622
186898
  function jsonEqual(a, b) {
186623
186899
  return a === b || JSON.stringify(a) === JSON.stringify(b);
186624
186900
  }
186625
- function reconcileScalars(ymap, rec, keys) {
186901
+ function reconcileScalars(ymap, rec, keys, skipKey) {
186626
186902
  for (const key2 of keys) {
186903
+ if (key2 === skipKey) {
186904
+ continue;
186905
+ }
186627
186906
  const next = rec[key2];
186628
186907
  const current = ymap.get(key2);
186629
186908
  if (next === void 0) {
@@ -186672,9 +186951,12 @@ function reconcileElementTextBody(ymap, rec, factories) {
186672
186951
  }
186673
186952
  function reconcileElementYMap(ymap, element, factories, assets) {
186674
186953
  const rec = element;
186675
- reconcileScalars(ymap, rec, SCALAR_ELEMENT_KEYS);
186954
+ const ownsText = hasCollaborationTextLease(ymap, element);
186955
+ reconcileScalars(ymap, rec, SCALAR_ELEMENT_KEYS, ownsText ? "text" : void 0);
186676
186956
  reconcileComplexFields(ymap, rec, COMPLEX_ELEMENT_FIELDS);
186677
- reconcileElementTextBody(ymap, rec, factories);
186957
+ if (!ownsText) {
186958
+ reconcileElementTextBody(ymap, rec, factories);
186959
+ }
186678
186960
  reconcileAssetFields(rec.id, rec, ymap, assets);
186679
186961
  }
186680
186962
  function mapIdAt(arr, index) {
@@ -186788,8 +187070,13 @@ function observeExternalCollaborationReadiness(session, options) {
186788
187070
  }
186789
187071
  };
186790
187072
  const suspend = () => {
187073
+ const preserveAcceptedEdits = active2 && established && options.gate.isOpen();
186791
187074
  options.gate.reset();
186792
187075
  options.livePatcher?.configure(null, null);
187076
+ if (preserveAcceptedEdits) {
187077
+ lastAdopted = void 0;
187078
+ adopt(readSlidesFromYDoc(session.doc));
187079
+ }
186793
187080
  options.onSuspend?.();
186794
187081
  notifyReadOnly();
186795
187082
  };
@@ -187046,6 +187333,576 @@ function applyLivePatch(doc, factories, patch, textPatchLimit) {
187046
187333
  reconcileElementTextBody(ymap, { textSegments: segments }, factories);
187047
187334
  }
187048
187335
  }
187336
+ function initializeCollaborationText(doc, element, factories, isCurrent) {
187337
+ const needsSeed = () => {
187338
+ const body = element.get("textBody");
187339
+ return (body === void 0 || isYTextEditable(body) && body.toDelta().length === 0) && typeof element.get("text") === "string";
187340
+ };
187341
+ if (!isCurrent() || !needsSeed()) {
187342
+ return;
187343
+ }
187344
+ doc.transact(() => {
187345
+ if (!isCurrent() || !needsSeed()) {
187346
+ return;
187347
+ }
187348
+ let textStyle;
187349
+ try {
187350
+ const raw = element.get(COMPLEX_ELEMENT_FIELDS.textStyle);
187351
+ if (typeof raw === "string") {
187352
+ textStyle = JSON.parse(raw);
187353
+ }
187354
+ } catch {
187355
+ }
187356
+ const seed = createInlineListSeed(
187357
+ {
187358
+ id: element.get("id"),
187359
+ type: element.get("type"),
187360
+ text: element.get("text"),
187361
+ textStyle
187362
+ },
187363
+ { includePlain: true }
187364
+ );
187365
+ const segments = seed && inlineListSession(seed)?.originalSegments;
187366
+ if (!segments) {
187367
+ return;
187368
+ }
187369
+ const previous = element.get("textBody");
187370
+ const text22 = isYTextEditable(previous) ? previous : factories.createText();
187371
+ encodeTextBody(segments, text22);
187372
+ if (text22 !== previous) {
187373
+ element.set("textBody", text22);
187374
+ }
187375
+ }, LOCAL_SYNC_ORIGIN);
187376
+ }
187377
+ var textBoundary = (text22, index) => !(text22.charCodeAt(index - 1) >= 55296 && text22.charCodeAt(index - 1) <= 56319 && text22.charCodeAt(index) >= 56320 && text22.charCodeAt(index) <= 57343);
187378
+ function textSessionReplacementSpan(before, after, { from, to }) {
187379
+ const suffix = before.length - to;
187380
+ const afterEnd = after.length - suffix;
187381
+ return Number.isInteger(from) && Number.isInteger(to) && from >= 0 && to >= from && to <= before.length && afterEnd >= from && before.slice(0, from) === after.slice(0, from) && before.slice(to) === after.slice(afterEnd) && textBoundary(before, from) && textBoundary(before, to) && textBoundary(after, from) && textBoundary(after, afterEnd) ? { prefix: from, suffix } : void 0;
187382
+ }
187383
+ function textSessionRetainedIndices(before, after, edit) {
187384
+ let indices;
187385
+ if (edit && "retainedIndices" in edit) {
187386
+ indices = Array.from(edit.retainedIndices);
187387
+ } else {
187388
+ const explicit = edit && textSessionReplacementSpan(before, after, edit);
187389
+ if (edit && !explicit) {
187390
+ return void 0;
187391
+ }
187392
+ const prefix = explicit?.prefix ?? commonPrefixLength3(before, after);
187393
+ const suffix = explicit?.suffix ?? commonSuffixLength3(before, after, prefix);
187394
+ indices = Array.from(
187395
+ { length: after.length },
187396
+ (_, index) => index < prefix ? index : index >= after.length - suffix ? before.length - (after.length - index) : null
187397
+ );
187398
+ }
187399
+ if (indices.length !== after.length) {
187400
+ return void 0;
187401
+ }
187402
+ let last = -1;
187403
+ for (const [index, retained] of indices.entries()) {
187404
+ if (retained === null) {
187405
+ continue;
187406
+ }
187407
+ if (!Number.isInteger(retained) || retained <= last || retained >= before.length || before[retained] !== after[index] || (!textBoundary(before, retained) || !textBoundary(after, index)) && indices[index - 1] !== retained - 1 || (!textBoundary(before, retained + 1) || !textBoundary(after, index + 1)) && indices[index + 1] !== retained + 1) {
187408
+ return void 0;
187409
+ }
187410
+ last = retained;
187411
+ }
187412
+ return indices;
187413
+ }
187414
+ function textSessionPlan(before, after, edit) {
187415
+ const retainedIndices = textSessionRetainedIndices(before, after, edit);
187416
+ if (!retainedIndices) {
187417
+ return void 0;
187418
+ }
187419
+ const sources = edit && "retainedIndices" in edit ? edit.paragraphSources : void 0;
187420
+ if (sources === void 0) {
187421
+ return { retainedIndices };
187422
+ }
187423
+ const paragraphSources = Array.from(sources);
187424
+ if (paragraphSources.length !== after.length || paragraphSources.some(
187425
+ (source) => source !== null && (!Number.isInteger(source) || source < 0 || source >= before.length)
187426
+ )) {
187427
+ return void 0;
187428
+ }
187429
+ return { retainedIndices, paragraphSources };
187430
+ }
187431
+ function textSessionAttributesEqual(a, b) {
187432
+ return Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key2) => a[key2] === b[key2]);
187433
+ }
187434
+ function textSessionDeltaSupported(delta) {
187435
+ return delta.every(
187436
+ (op2) => typeof op2.insert === "string" && Object.values(op2.attributes ?? {}).every((value) => typeof value === "string")
187437
+ );
187438
+ }
187439
+ function textSessionUnits(delta) {
187440
+ const units = [];
187441
+ for (const op2 of delta) {
187442
+ if (typeof op2.insert !== "string") {
187443
+ return void 0;
187444
+ }
187445
+ const attributes = {};
187446
+ for (const [key2, value] of Object.entries(op2.attributes ?? {})) {
187447
+ if (typeof value !== "string") {
187448
+ return void 0;
187449
+ }
187450
+ attributes[key2] = value;
187451
+ }
187452
+ for (let index = 0; index < op2.insert.length; index++) {
187453
+ units.push({ text: op2.insert[index], attributes });
187454
+ }
187455
+ }
187456
+ return units;
187457
+ }
187458
+ function textSessionAttributePatch(before, after, current) {
187459
+ const patch = {};
187460
+ for (const key2 of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
187461
+ if (before[key2] !== after[key2]) {
187462
+ patch[key2] = key2 === "s" ? mergeTextSessionObjectAttribute(before[key2], after[key2], current[key2]) : after[key2] ?? null;
187463
+ }
187464
+ }
187465
+ return patch;
187466
+ }
187467
+ function isObject(value) {
187468
+ return typeof value === "object" && value !== null && !Array.isArray(value);
187469
+ }
187470
+ function mergeObjectChanges(before, after, current) {
187471
+ const merged = new Map(Object.entries(current));
187472
+ for (const key2 of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
187473
+ const oldValue = Object.hasOwn(before, key2) ? before[key2] : void 0;
187474
+ const nextValue = Object.hasOwn(after, key2) ? after[key2] : void 0;
187475
+ if (JSON.stringify(oldValue) === JSON.stringify(nextValue)) {
187476
+ continue;
187477
+ }
187478
+ const liveValue = merged.get(key2);
187479
+ if ((oldValue === void 0 || isObject(oldValue)) && (nextValue === void 0 || isObject(nextValue)) && isObject(liveValue)) {
187480
+ const nested = mergeObjectChanges(oldValue ?? {}, nextValue ?? {}, liveValue);
187481
+ if (Object.keys(nested).length > 0) {
187482
+ merged.set(key2, nested);
187483
+ } else {
187484
+ merged.delete(key2);
187485
+ }
187486
+ } else if (nextValue === void 0) {
187487
+ merged.delete(key2);
187488
+ } else {
187489
+ merged.set(key2, nextValue);
187490
+ }
187491
+ }
187492
+ return Object.fromEntries(merged);
187493
+ }
187494
+ function mergeTextSessionObjectAttribute(before, after, current) {
187495
+ try {
187496
+ const oldValue = before ? JSON.parse(before) : {};
187497
+ const nextValue = after ? JSON.parse(after) : {};
187498
+ const liveValue = current ? JSON.parse(current) : {};
187499
+ if (isObject(oldValue) && isObject(nextValue) && isObject(liveValue)) {
187500
+ const merged = mergeObjectChanges(oldValue, nextValue, liveValue);
187501
+ return Object.keys(merged).length ? JSON.stringify(merged) : null;
187502
+ }
187503
+ } catch {
187504
+ }
187505
+ return after ?? null;
187506
+ }
187507
+ var paragraphKeys = ["bi", "pl", "pr", "pi", "pp"];
187508
+ function readParagraphAttributes(previous, source, readCurrent) {
187509
+ const carrier = readCurrent(source);
187510
+ if (carrier) return carrier;
187511
+ if (previous[source].attributes.pb === "1") return {};
187512
+ let start = source;
187513
+ while (start > 0 && previous[start - 1].attributes.pb !== "1") start--;
187514
+ for (let index = start; index < previous.length && previous[index].attributes.pb !== "1"; index++) {
187515
+ const current = readCurrent(index);
187516
+ if (current) return current;
187517
+ }
187518
+ return {};
187519
+ }
187520
+ function textSessionParagraphPatches(previous, desired, sources, readCurrent) {
187521
+ const patches = /* @__PURE__ */ new Map();
187522
+ const cache = /* @__PURE__ */ new Map();
187523
+ for (const [index, source] of (sources ?? []).entries()) {
187524
+ if (source === null) {
187525
+ continue;
187526
+ }
187527
+ const after = desired[index].attributes;
187528
+ let byAttributes = cache.get(source);
187529
+ if (!byAttributes) {
187530
+ byAttributes = /* @__PURE__ */ new Map();
187531
+ cache.set(source, byAttributes);
187532
+ }
187533
+ let patch = byAttributes.get(after);
187534
+ if (!patch) {
187535
+ const before = previous[source].attributes;
187536
+ const current = readParagraphAttributes(previous, source, readCurrent);
187537
+ patch = {};
187538
+ for (const key2 of paragraphKeys) {
187539
+ patch[key2] = before[key2] === after[key2] ? current[key2] ?? null : key2 === "pl" ? after[key2] ?? null : mergeTextSessionObjectAttribute(before[key2], after[key2], current[key2]);
187540
+ }
187541
+ byAttributes.set(after, patch);
187542
+ }
187543
+ patches.set(index, patch);
187544
+ }
187545
+ return patches;
187546
+ }
187547
+ function textSessionInsertionAttributes(attributes, paragraph) {
187548
+ const result = { ...attributes };
187549
+ for (const [key2, value] of Object.entries(paragraph ?? {})) {
187550
+ if (value === null) {
187551
+ delete result[key2];
187552
+ } else {
187553
+ result[key2] = value;
187554
+ }
187555
+ }
187556
+ return result;
187557
+ }
187558
+ function applyTextSessionPlan(text22, positions2, previous, desired, indices, emptyBoundary, paragraphSources) {
187559
+ const range = (unit) => {
187560
+ const start = positions2.resolve(unit.start);
187561
+ const end = positions2.resolve(unit.end);
187562
+ return start !== null && end !== null && end > start ? { start, end } : void 0;
187563
+ };
187564
+ const sourceUnits = paragraphSources && textSessionUnits(text22.toDelta());
187565
+ if (paragraphSources && !sourceUnits) {
187566
+ return void 0;
187567
+ }
187568
+ const paragraphPatches = textSessionParagraphPatches(
187569
+ previous,
187570
+ desired,
187571
+ paragraphSources,
187572
+ (source) => {
187573
+ const current = range(previous[source]);
187574
+ return current ? sourceUnits?.[current.start]?.attributes : void 0;
187575
+ }
187576
+ );
187577
+ const batches = [];
187578
+ for (let index = 0; index < indices.length; ) {
187579
+ if (indices[index] !== null) {
187580
+ index++;
187581
+ continue;
187582
+ }
187583
+ const from = index;
187584
+ while (index < indices.length && indices[index] === null) {
187585
+ index++;
187586
+ }
187587
+ const oldStart = from === 0 ? 0 : indices[from - 1] + 1;
187588
+ const boundary = previous[oldStart]?.start ?? previous.at(-1)?.end ?? emptyBoundary;
187589
+ if (positions2.resolve(boundary) === null) {
187590
+ return void 0;
187591
+ }
187592
+ batches.push({ from, to: index, boundary });
187593
+ }
187594
+ const retained = new Set(indices);
187595
+ const deletedRanges = previous.filter((_, index) => !retained.has(index)).map(range).filter((value) => value !== void 0).sort((a, b) => a.start - b.start);
187596
+ const deletions = [];
187597
+ for (const next of deletedRanges) {
187598
+ const last = deletions.at(-1);
187599
+ if (last && last.end === next.start) {
187600
+ last.end = next.end;
187601
+ } else {
187602
+ deletions.push(next);
187603
+ }
187604
+ }
187605
+ for (const deletion of deletions.reverse()) {
187606
+ text22.delete(deletion.start, deletion.end - deletion.start);
187607
+ }
187608
+ if (positions2.refresh?.() === false) {
187609
+ return void 0;
187610
+ }
187611
+ const inserted = /* @__PURE__ */ new Map();
187612
+ let precedingInsert;
187613
+ for (const batch of batches) {
187614
+ const boundary = positions2.resolve(batch.boundary);
187615
+ const minimum = precedingInsert ? positions2.resolve(precedingInsert.end) : 0;
187616
+ if (boundary === null || minimum === null) {
187617
+ return void 0;
187618
+ }
187619
+ const start = Math.max(boundary, minimum);
187620
+ let offset = start;
187621
+ for (let index = batch.from; index < batch.to; ) {
187622
+ let end = index + 1;
187623
+ while (end < batch.to && desired[end].attributes === desired[index].attributes && paragraphPatches.get(end) === paragraphPatches.get(index)) {
187624
+ end++;
187625
+ }
187626
+ text22.insert(
187627
+ offset,
187628
+ desired.slice(index, end).map((unit) => unit.text).join(""),
187629
+ textSessionInsertionAttributes(desired[index].attributes, paragraphPatches.get(index))
187630
+ );
187631
+ offset += end - index;
187632
+ index = end;
187633
+ }
187634
+ if (positions2.refresh?.() === false) {
187635
+ return void 0;
187636
+ }
187637
+ for (let index = batch.from; index < batch.to; index++) {
187638
+ const position2 = start + index - batch.from;
187639
+ inserted.set(index, {
187640
+ ...desired[index],
187641
+ start: positions2.capture(position2, 0),
187642
+ end: positions2.capture(position2 + 1, -1)
187643
+ });
187644
+ }
187645
+ precedingInsert = inserted.get(batch.to - 1);
187646
+ }
187647
+ const liveUnits = textSessionUnits(text22.toDelta());
187648
+ const formats = [];
187649
+ for (const [index, oldIndex] of indices.entries()) {
187650
+ if (oldIndex === null) {
187651
+ continue;
187652
+ }
187653
+ const unit = previous[oldIndex];
187654
+ const paragraph = paragraphPatches.get(index);
187655
+ if (!paragraph && textSessionAttributesEqual(unit.attributes, desired[index].attributes)) {
187656
+ continue;
187657
+ }
187658
+ const current = range(unit);
187659
+ if (!current) {
187660
+ continue;
187661
+ }
187662
+ const patch = {
187663
+ ...textSessionAttributePatch(
187664
+ unit.attributes,
187665
+ desired[index].attributes,
187666
+ liveUnits?.[current.start]?.attributes ?? {}
187667
+ ),
187668
+ ...paragraph
187669
+ };
187670
+ for (const key2 of Object.keys(patch)) {
187671
+ if (patch[key2] === (liveUnits?.[current.start]?.attributes[key2] ?? null)) {
187672
+ delete patch[key2];
187673
+ }
187674
+ }
187675
+ if (Object.keys(patch).length > 0) {
187676
+ const last = formats.at(-1);
187677
+ if (last && last.end === current.start && JSON.stringify(last.patch) === JSON.stringify(patch)) {
187678
+ last.end = current.end;
187679
+ } else {
187680
+ formats.push({ ...current, patch });
187681
+ }
187682
+ }
187683
+ }
187684
+ for (const format of formats) {
187685
+ text22.format(format.start, format.end - format.start, format.patch);
187686
+ }
187687
+ return indices.map((oldIndex, index) => ({
187688
+ ...oldIndex === null ? inserted.get(index) : previous[oldIndex],
187689
+ attributes: desired[index].attributes
187690
+ }));
187691
+ }
187692
+ function createCollaborationTextSession({
187693
+ text: text22,
187694
+ positions: positions2,
187695
+ transact,
187696
+ isCurrent
187697
+ }) {
187698
+ if (!isCurrent() || positions2.refresh?.() === false) {
187699
+ positions2.dispose?.();
187700
+ return void 0;
187701
+ }
187702
+ const observe = (delta) => textSessionUnits(delta)?.map((unit, index) => ({
187703
+ ...unit,
187704
+ start: positions2.capture(index, 0),
187705
+ end: positions2.capture(index + 1, -1)
187706
+ }));
187707
+ let baseline = observe(text22.toDelta());
187708
+ if (!baseline) {
187709
+ positions2.dispose?.();
187710
+ return void 0;
187711
+ }
187712
+ let emptyBoundary = positions2.capture(0, 0);
187713
+ let version = 0;
187714
+ let disposed = false;
187715
+ let snapshots2 = /* @__PURE__ */ new WeakMap();
187716
+ const dispose = () => {
187717
+ if (disposed) {
187718
+ return;
187719
+ }
187720
+ disposed = true;
187721
+ baseline = [];
187722
+ snapshots2 = /* @__PURE__ */ new WeakMap();
187723
+ positions2.dispose?.();
187724
+ };
187725
+ const active2 = () => {
187726
+ if (!disposed && (!isCurrent() || positions2.refresh?.() === false || !textSessionDeltaSupported(text22.toDelta()))) {
187727
+ dispose();
187728
+ }
187729
+ return !disposed;
187730
+ };
187731
+ return {
187732
+ bookmark(index, association) {
187733
+ if (!active2() || !Number.isInteger(index) || index < 0 || index > baseline.length) {
187734
+ return () => null;
187735
+ }
187736
+ const units = baseline;
187737
+ const position2 = association < 0 && index > 0 ? units[index - 1].end : units[index]?.start ?? units[index - 1]?.end ?? emptyBoundary;
187738
+ return () => active2() ? positions2.resolve(position2) : null;
187739
+ },
187740
+ applyLocalDelta(delta, edit) {
187741
+ if (!active2()) {
187742
+ return false;
187743
+ }
187744
+ const desired = textSessionUnits(delta);
187745
+ if (!desired) {
187746
+ return false;
187747
+ }
187748
+ const previous = baseline;
187749
+ const before = previous.map((unit) => unit.text).join("");
187750
+ const after = desired.map((unit) => unit.text).join("");
187751
+ const plan = textSessionPlan(before, after, edit);
187752
+ if (!plan) {
187753
+ return false;
187754
+ }
187755
+ const { retainedIndices: indices, paragraphSources } = plan;
187756
+ if (previous.length === desired.length && indices.every((retained, index) => retained === index) && (!paragraphSources || paragraphSources.every((source, index) => source === null || source === index)) && desired.every(
187757
+ (unit, index) => textSessionAttributesEqual(previous[index].attributes, unit.attributes)
187758
+ )) {
187759
+ return true;
187760
+ }
187761
+ let next;
187762
+ transact(() => {
187763
+ if (!active2()) {
187764
+ return;
187765
+ }
187766
+ next = applyTextSessionPlan(
187767
+ text22,
187768
+ positions2,
187769
+ previous,
187770
+ desired,
187771
+ indices,
187772
+ emptyBoundary,
187773
+ paragraphSources
187774
+ );
187775
+ });
187776
+ if (!next || !active2()) {
187777
+ return false;
187778
+ }
187779
+ baseline = next;
187780
+ version++;
187781
+ return true;
187782
+ },
187783
+ readMerged() {
187784
+ if (!active2()) {
187785
+ return void 0;
187786
+ }
187787
+ const delta = text22.toDelta();
187788
+ const units = observe(delta);
187789
+ if (!units) {
187790
+ dispose();
187791
+ return void 0;
187792
+ }
187793
+ const snapshot = { delta };
187794
+ snapshots2.set(snapshot, { units, boundary: positions2.capture(0, 0), version });
187795
+ return snapshot;
187796
+ },
187797
+ adoptMerged(snapshot) {
187798
+ const observed = snapshots2.get(snapshot);
187799
+ if (!active2() || !observed || observed.version !== version) {
187800
+ return false;
187801
+ }
187802
+ baseline = observed.units;
187803
+ emptyBoundary = observed.boundary;
187804
+ version++;
187805
+ return true;
187806
+ },
187807
+ dispose
187808
+ };
187809
+ }
187810
+ function createCollaborationTextTarget({
187811
+ doc,
187812
+ factories,
187813
+ slideId,
187814
+ elementId,
187815
+ isWritable,
187816
+ onChange,
187817
+ ownsModel
187818
+ }) {
187819
+ const element = findElementYMap(doc, slideId, elementId);
187820
+ if (element && factories.createTextPositions) {
187821
+ initializeCollaborationText(
187822
+ doc,
187823
+ element,
187824
+ factories,
187825
+ () => isWritable() && findElementYMap(doc, slideId, elementId) === element
187826
+ );
187827
+ }
187828
+ const text22 = element?.get("textBody");
187829
+ if (!element || !isYTextEditable(text22) || !factories.createTextPositions || !isWritable()) {
187830
+ return void 0;
187831
+ }
187832
+ const positions2 = factories.createTextPositions(text22);
187833
+ let disposed = false;
187834
+ let applying = false;
187835
+ const isCurrent = () => !disposed && isWritable() && findElementYMap(doc, slideId, elementId) === element && element.get("textBody") === text22;
187836
+ const session = createCollaborationTextSession({
187837
+ text: text22,
187838
+ positions: positions2,
187839
+ isCurrent,
187840
+ transact: (callback) => doc.transact(() => {
187841
+ callback();
187842
+ if (isCurrent()) {
187843
+ const segments = decodeDelta(text22.toDelta());
187844
+ const value = inlineListBodyText(segments);
187845
+ if (element.get("text") !== value) {
187846
+ element.set("text", value);
187847
+ }
187848
+ }
187849
+ }, LOCAL_SYNC_ORIGIN)
187850
+ });
187851
+ if (!session) {
187852
+ return void 0;
187853
+ }
187854
+ const slides = doc.getArray(YDOC_SLIDES_KEY);
187855
+ let previous = JSON.stringify(text22.toDelta());
187856
+ const changed = () => {
187857
+ if (disposed || applying) {
187858
+ return;
187859
+ }
187860
+ const next = isCurrent() ? JSON.stringify(text22.toDelta()) : void 0;
187861
+ if (next !== previous) {
187862
+ previous = next ?? "";
187863
+ onChange?.();
187864
+ }
187865
+ };
187866
+ slides.observeDeep(changed);
187867
+ const releaseLease = ownsModel ? registerCollaborationTextLease(element, ownsModel) : () => {
187868
+ };
187869
+ const readMerged = () => {
187870
+ const snapshot = session.readMerged();
187871
+ if (!snapshot) {
187872
+ return void 0;
187873
+ }
187874
+ const segments = decodeDelta([...snapshot.delta]);
187875
+ return Object.assign(snapshot, {
187876
+ inline: { elementId, text: inlineListBodyText(segments), textSegments: segments }
187877
+ });
187878
+ };
187879
+ return {
187880
+ readMerged,
187881
+ adoptMerged: session.adoptMerged,
187882
+ applyLocalDelta(delta, edit) {
187883
+ if (!isCurrent()) {
187884
+ return false;
187885
+ }
187886
+ applying = true;
187887
+ try {
187888
+ return session.applyLocalDelta(delta, edit);
187889
+ } finally {
187890
+ applying = false;
187891
+ changed();
187892
+ }
187893
+ },
187894
+ bookmark: session.bookmark,
187895
+ dispose() {
187896
+ if (!disposed) {
187897
+ disposed = true;
187898
+ releaseLease();
187899
+ slides.unobserveDeep(changed);
187900
+ session.dispose();
187901
+ onChange?.();
187902
+ }
187903
+ }
187904
+ };
187905
+ }
187049
187906
  var LIVE_PATCH_THROTTLE_MS = 50;
187050
187907
  function createCollaborationLivePatcher(options = {}) {
187051
187908
  const throttleMs = options.throttleMs ?? LIVE_PATCH_THROTTLE_MS;
@@ -187055,6 +187912,17 @@ function createCollaborationLivePatcher(options = {}) {
187055
187912
  let timer = null;
187056
187913
  let lastWriteAt = Number.NEGATIVE_INFINITY;
187057
187914
  let immediate = false;
187915
+ const textSessions = /* @__PURE__ */ new Map();
187916
+ const textOwners = /* @__PURE__ */ new Map();
187917
+ const keyFor3 = (slideId, elementId) => `${slideId ?? ""}\0${elementId}`;
187918
+ const retireTextSessions = () => {
187919
+ const retiring = [...textSessions.values()];
187920
+ textSessions.clear();
187921
+ textOwners.clear();
187922
+ for (const session of retiring) {
187923
+ session.dispose();
187924
+ }
187925
+ };
187058
187926
  const cancelTimer = () => {
187059
187927
  if (timer !== null) {
187060
187928
  clearTimeout(timer);
@@ -187102,7 +187970,7 @@ function createCollaborationLivePatcher(options = {}) {
187102
187970
  if (!doc || !factories || !elementId) {
187103
187971
  return null;
187104
187972
  }
187105
- const key2 = `${slideId ?? ""}\0${elementId}`;
187973
+ const key2 = keyFor3(slideId, elementId);
187106
187974
  let entry2 = pending.get(key2);
187107
187975
  if (!entry2) {
187108
187976
  entry2 = { slideId, elementId };
@@ -187111,6 +187979,53 @@ function createCollaborationLivePatcher(options = {}) {
187111
187979
  return entry2;
187112
187980
  };
187113
187981
  return {
187982
+ beginTextEdit(slideId, elementId, onChange, ownsModel) {
187983
+ if (!doc || !factories) {
187984
+ return void 0;
187985
+ }
187986
+ const activeDoc = doc;
187987
+ const activeFactories = factories;
187988
+ const key2 = keyFor3(slideId, elementId);
187989
+ const owner = {};
187990
+ textOwners.set(key2, owner);
187991
+ const isWritable = () => doc === activeDoc && factories === activeFactories && textOwners.get(key2) === owner;
187992
+ textSessions.get(key2)?.dispose();
187993
+ if (!isWritable()) {
187994
+ return void 0;
187995
+ }
187996
+ const queued = pending.get(key2);
187997
+ if (queued) {
187998
+ delete queued.text;
187999
+ }
188000
+ const target = createCollaborationTextTarget({
188001
+ doc,
188002
+ factories,
188003
+ slideId,
188004
+ elementId,
188005
+ onChange,
188006
+ ownsModel,
188007
+ isWritable
188008
+ });
188009
+ if (!target || textOwners.get(key2) !== owner) {
188010
+ target?.dispose();
188011
+ if (textOwners.get(key2) === owner) {
188012
+ textOwners.delete(key2);
188013
+ }
188014
+ return void 0;
188015
+ }
188016
+ const dispose = target.dispose;
188017
+ target.dispose = () => {
188018
+ dispose();
188019
+ if (textSessions.get(key2) === target) {
188020
+ textSessions.delete(key2);
188021
+ }
188022
+ if (textOwners.get(key2) === owner) {
188023
+ textOwners.delete(key2);
188024
+ }
188025
+ };
188026
+ textSessions.set(key2, target);
188027
+ return target;
188028
+ },
187114
188029
  configure(nextDoc, nextFactories, nextImmediate = false) {
187115
188030
  if (nextDoc === doc && nextFactories === factories && nextImmediate === immediate) {
187116
188031
  return;
@@ -187121,6 +188036,7 @@ function createCollaborationLivePatcher(options = {}) {
187121
188036
  factories = nextFactories;
187122
188037
  immediate = nextImmediate;
187123
188038
  lastWriteAt = Number.NEGATIVE_INFINITY;
188039
+ retireTextSessions();
187124
188040
  },
187125
188041
  isActive() {
187126
188042
  return doc !== null && factories !== null;
@@ -187134,6 +188050,9 @@ function createCollaborationLivePatcher(options = {}) {
187134
188050
  schedule();
187135
188051
  },
187136
188052
  patchText(slideId, elementId, text22, source) {
188053
+ if (textOwners.has(keyFor3(slideId, elementId))) {
188054
+ return;
188055
+ }
187137
188056
  const entry2 = enqueue(slideId, elementId);
187138
188057
  if (!entry2) {
187139
188058
  return;
@@ -187150,6 +188069,7 @@ function createCollaborationLivePatcher(options = {}) {
187150
188069
  pending.clear();
187151
188070
  doc = null;
187152
188071
  factories = null;
188072
+ retireTextSessions();
187153
188073
  }
187154
188074
  };
187155
188075
  }
@@ -187172,6 +188092,731 @@ function publishLiveGeometry(patcher, slideId, elementId, geometry) {
187172
188092
  }
187173
188093
  patcher.patchGeometry(slideId, elementId, geometry);
187174
188094
  }
188095
+ function normalizedRuns(delta) {
188096
+ const runs = [];
188097
+ for (const op2 of delta) {
188098
+ if (typeof op2.insert !== "string") {
188099
+ return void 0;
188100
+ }
188101
+ const entries = Object.entries(op2.attributes ?? {});
188102
+ if (entries.some(([, value]) => typeof value !== "string")) {
188103
+ return void 0;
188104
+ }
188105
+ if (!op2.insert) {
188106
+ continue;
188107
+ }
188108
+ const attributes = JSON.stringify(entries.sort(([a], [b]) => a.localeCompare(b)));
188109
+ const previous = runs[runs.length - 1];
188110
+ if (previous?.attributes === attributes) {
188111
+ previous.text += op2.insert;
188112
+ } else {
188113
+ runs.push({ text: op2.insert, attributes });
188114
+ }
188115
+ }
188116
+ return runs;
188117
+ }
188118
+ function validBoundary(text22, offset) {
188119
+ return Number.isInteger(offset) && offset >= 0 && offset <= text22.length && !(text22.charCodeAt(offset - 1) >= 55296 && text22.charCodeAt(offset - 1) <= 56319 && text22.charCodeAt(offset) >= 56320 && text22.charCodeAt(offset) <= 57343);
188120
+ }
188121
+ function createCollaborationTextProjection(segments, delta, body) {
188122
+ if (inlineListBodyText(segments) !== body) {
188123
+ return void 0;
188124
+ }
188125
+ const expected = normalizedRuns(encodeSegmentsToDelta([...segments]));
188126
+ const actual = normalizedRuns(delta);
188127
+ if (!expected || !actual || expected.length !== actual.length || expected.some(
188128
+ (run, index) => run.text !== actual[index].text || run.attributes !== actual[index].attributes
188129
+ )) {
188130
+ return void 0;
188131
+ }
188132
+ const encoded = actual.map((run) => run.text).join("");
188133
+ const spans = [];
188134
+ let bodyStart = 0;
188135
+ let encodedStart = 0;
188136
+ let first = true;
188137
+ for (const [segmentIndex, segment] of segments.entries()) {
188138
+ const paragraphBreak = isParagraphSeparatorSegment(segment);
188139
+ const marker = !paragraphBreak && first && isBulletMarkerSegment(segment);
188140
+ const kind = paragraphBreak ? "paragraph-break" : segment.isLineBreak ? "line-break" : marker ? "bullet-marker" : segment.text.length === 0 ? "empty-carrier" : "text";
188141
+ const bodyLength = paragraphBreak || segment.isLineBreak ? 1 : marker ? 0 : segment.text.length;
188142
+ const encodedLength = segment.isParagraphBreak || segment.isLineBreak ? 1 : Math.max(1, segment.text.length);
188143
+ spans.push({
188144
+ segmentIndex,
188145
+ bodyStart,
188146
+ bodyEnd: bodyStart + bodyLength,
188147
+ encodedStart,
188148
+ encodedEnd: encodedStart + encodedLength,
188149
+ kind
188150
+ });
188151
+ bodyStart += bodyLength;
188152
+ encodedStart += encodedLength;
188153
+ first = paragraphBreak;
188154
+ }
188155
+ return {
188156
+ spans,
188157
+ bodyOffsetToEncoded(offset) {
188158
+ if (!validBoundary(body, offset)) {
188159
+ return void 0;
188160
+ }
188161
+ let start = encoded.length;
188162
+ let end = 0;
188163
+ for (const span of spans) {
188164
+ if (offset < span.bodyStart || offset > span.bodyEnd) {
188165
+ continue;
188166
+ }
188167
+ const point = span.encodedStart + offset - span.bodyStart;
188168
+ start = Math.min(start, point);
188169
+ end = Math.max(end, span.bodyStart === span.bodyEnd ? span.encodedEnd : point);
188170
+ }
188171
+ return { start, end };
188172
+ },
188173
+ encodedOffsetToBody(offset) {
188174
+ if (!validBoundary(encoded, offset)) {
188175
+ return void 0;
188176
+ }
188177
+ for (const span of spans) {
188178
+ if (offset >= span.encodedStart && offset <= span.encodedEnd) {
188179
+ const point = span.bodyStart === span.bodyEnd ? span.bodyStart : span.bodyStart + offset - span.encodedStart;
188180
+ return validBoundary(body, point) ? point : void 0;
188181
+ }
188182
+ }
188183
+ return 0;
188184
+ }
188185
+ };
188186
+ }
188187
+ var initialized = /* @__PURE__ */ new WeakSet();
188188
+ function initializeInlineListDom(root, seed) {
188189
+ const session = inlineListSession(seed);
188190
+ if (!session || initialized.has(root) || root.childNodes.length > 0 || session.boundParagraphs.size > 0) {
188191
+ return false;
188192
+ }
188193
+ const textStyle = "textStyle" in session.element ? session.element.textStyle : void 0;
188194
+ const fontScale = resolveAutoFitFontScale(textStyle);
188195
+ for (const paragraph of seed.paragraphs) {
188196
+ const block = root.ownerDocument.createElement("div");
188197
+ block.dataset.pptxListParagraph = paragraph.token;
188198
+ for (const run of paragraph.runs) {
188199
+ const span = root.ownerDocument.createElement("span");
188200
+ span.dataset.pptxListRun = run.token;
188201
+ const source = session.segments[run.segmentIndex];
188202
+ const projected = {
188203
+ ...source,
188204
+ style: withInlineListDecorationDefaults(source.style, textStyle)
188205
+ };
188206
+ const style = segmentStyleToCss(projected, fontScale);
188207
+ applyUnderlineVariant(style, projected);
188208
+ for (const [key2, value] of Object.entries(style)) {
188209
+ span.style.setProperty(
188210
+ key2.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`),
188211
+ String(value)
188212
+ );
188213
+ }
188214
+ if (run.text === "" || run.isLineBreak) {
188215
+ span.append(root.ownerDocument.createElement("br"));
188216
+ } else {
188217
+ for (const [index, line4] of run.text.split("\n").entries()) {
188218
+ if (index > 0) {
188219
+ span.append(root.ownerDocument.createElement("br"));
188220
+ }
188221
+ span.append(root.ownerDocument.createTextNode(line4));
188222
+ }
188223
+ }
188224
+ block.append(span);
188225
+ bindInlineListRun(seed, span, run.segmentIndex);
188226
+ }
188227
+ root.append(block);
188228
+ bindInlineListParagraph(seed, block, paragraph.sourceIndex);
188229
+ }
188230
+ initialized.add(root);
188231
+ return true;
188232
+ }
188233
+ function collaborationInlineModelKey(element) {
188234
+ return JSON.stringify(
188235
+ element && {
188236
+ id: element.id,
188237
+ type: element.type,
188238
+ ..."text" in element ? { text: element.text } : {},
188239
+ ..."textSegments" in element ? { textSegments: element.textSegments } : {},
188240
+ ..."textStyle" in element ? { textStyle: element.textStyle } : {}
188241
+ }
188242
+ );
188243
+ }
188244
+ function prepareCollaborationInlineDom(root, element, snapshot) {
188245
+ const seed = createInlineListSeed({ ...element, ...snapshot }, {
188246
+ includePlain: true
188247
+ });
188248
+ if (!seed) {
188249
+ return void 0;
188250
+ }
188251
+ const detached = root.ownerDocument.createElement("div");
188252
+ return initializeInlineListDom(detached, seed) ? { seed, children: Array.from(detached.childNodes) } : void 0;
188253
+ }
188254
+ function bookmarkCollaborationInlineSelection(root, seed, snapshot, target) {
188255
+ const selected = readInlineListSelection(seed, root);
188256
+ const selection = root.ownerDocument.getSelection();
188257
+ const range = selection?.rangeCount ? selection.getRangeAt(0) : void 0;
188258
+ const backward = Boolean(
188259
+ range && !range.collapsed && selection?.anchorNode === range.endContainer && selection.anchorOffset === range.endOffset
188260
+ );
188261
+ const segments = snapshot.textSegments ?? [];
188262
+ const projection = createCollaborationTextProjection(
188263
+ segments,
188264
+ encodeSegmentsToDelta(segments),
188265
+ snapshot.text
188266
+ );
188267
+ if (selected.kind !== "supported" || !selected.bodyRange || !projection) {
188268
+ return void 0;
188269
+ }
188270
+ const { start, end } = selected.bodyRange;
188271
+ const first = projection.bodyOffsetToEncoded(start);
188272
+ const last = projection.bodyOffsetToEncoded(end);
188273
+ if (!first || !last) {
188274
+ return void 0;
188275
+ }
188276
+ const from = target.bookmark(first.end, 0);
188277
+ const to = start === end ? from : target.bookmark(last.start, -1);
188278
+ return (nextSeed, next) => {
188279
+ const nextSegments = next.textSegments ?? [];
188280
+ const nextProjection = createCollaborationTextProjection(
188281
+ nextSegments,
188282
+ encodeSegmentsToDelta(nextSegments),
188283
+ next.text
188284
+ );
188285
+ const encodedStart = from();
188286
+ const encodedEnd = to();
188287
+ const bodyStart = encodedStart === null ? void 0 : nextProjection?.encodedOffsetToBody(encodedStart);
188288
+ const bodyEnd = encodedEnd === null ? void 0 : nextProjection?.encodedOffsetToBody(encodedEnd);
188289
+ if (bodyStart !== void 0 && bodyEnd !== void 0) {
188290
+ restoreInlineListBodySelection(nextSeed, root, {
188291
+ start: Math.min(bodyStart, bodyEnd),
188292
+ end: Math.max(bodyStart, bodyEnd)
188293
+ });
188294
+ if (backward && selection?.rangeCount) {
188295
+ const restored = selection.getRangeAt(0);
188296
+ selection.setBaseAndExtent(
188297
+ restored.endContainer,
188298
+ restored.endOffset,
188299
+ restored.startContainer,
188300
+ restored.startOffset
188301
+ );
188302
+ }
188303
+ }
188304
+ };
188305
+ }
188306
+ function resolveCollaborationNativeRange(range, previous, current) {
188307
+ if (!range?.deleteDirection) {
188308
+ return range;
188309
+ }
188310
+ const removed = previous.length - current.length;
188311
+ if (removed <= 0) {
188312
+ return void 0;
188313
+ }
188314
+ const from = range.deleteDirection === "backward" ? range.from - removed : range.from;
188315
+ const to = range.deleteDirection === "forward" ? range.to + removed : range.to;
188316
+ return from >= 0 && to <= previous.length ? { from, to } : void 0;
188317
+ }
188318
+ function observeCollaborationInlineInput(root, getSeed, apply, settled) {
188319
+ let disposed = false;
188320
+ let composing = false;
188321
+ let pending = false;
188322
+ let range;
188323
+ const capture = (event) => {
188324
+ const target = event?.getTargetRanges?.()[0];
188325
+ const read = target ? readInlineListRange(getSeed(), root, target) : readInlineListSelection(getSeed(), root);
188326
+ range = read.kind === "supported" && read.bodyRange ? { from: read.bodyRange.start, to: read.bodyRange.end } : void 0;
188327
+ if (!target && range && range.from === range.to && event?.inputType?.startsWith("delete")) {
188328
+ if (event.inputType.endsWith("Backward")) {
188329
+ range.deleteDirection = "backward";
188330
+ } else if (event.inputType.endsWith("Forward")) {
188331
+ range.deleteDirection = "forward";
188332
+ }
188333
+ }
188334
+ };
188335
+ const before = (event) => {
188336
+ if (!composing) {
188337
+ capture(event);
188338
+ }
188339
+ pending = true;
188340
+ queueMicrotask(() => {
188341
+ if (!disposed && !composing && pending) {
188342
+ pending = false;
188343
+ settled();
188344
+ }
188345
+ });
188346
+ };
188347
+ const input = () => {
188348
+ if (composing || disposed) {
188349
+ return;
188350
+ }
188351
+ pending = false;
188352
+ const replacement = range;
188353
+ range = void 0;
188354
+ apply(replacement);
188355
+ };
188356
+ const start = () => {
188357
+ if (!composing) {
188358
+ capture();
188359
+ }
188360
+ composing = true;
188361
+ };
188362
+ const end = () => {
188363
+ queueMicrotask(() => {
188364
+ if (disposed) {
188365
+ return;
188366
+ }
188367
+ composing = false;
188368
+ input();
188369
+ });
188370
+ };
188371
+ root.addEventListener("beforeinput", before, true);
188372
+ root.addEventListener("paste", before, true);
188373
+ root.addEventListener("input", input, true);
188374
+ root.addEventListener("compositionstart", start, true);
188375
+ root.addEventListener("compositionend", end, true);
188376
+ return {
188377
+ blocked: () => composing || pending,
188378
+ reason: () => composing ? "composition-active" : pending ? "input-active" : void 0,
188379
+ dispose() {
188380
+ disposed = true;
188381
+ root.removeEventListener("beforeinput", before, true);
188382
+ root.removeEventListener("paste", before, true);
188383
+ root.removeEventListener("input", input, true);
188384
+ root.removeEventListener("compositionstart", start, true);
188385
+ root.removeEventListener("compositionend", end, true);
188386
+ }
188387
+ };
188388
+ }
188389
+ function paragraphCarriers(projection) {
188390
+ const carriers = [void 0];
188391
+ for (const span of projection.spans) {
188392
+ carriers[carriers.length - 1] ??= span;
188393
+ if (span.kind === "paragraph-break") {
188394
+ carriers.push(void 0);
188395
+ }
188396
+ }
188397
+ return carriers;
188398
+ }
188399
+ function bodyUnits(projection) {
188400
+ const indices = [];
188401
+ for (const span of projection.spans) {
188402
+ for (let body = span.bodyStart; body < span.bodyEnd; body++) {
188403
+ indices[body] = span.encodedStart + body - span.bodyStart;
188404
+ }
188405
+ }
188406
+ return indices;
188407
+ }
188408
+ function createNativeCollaborationTextEdit(before, after, replacement) {
188409
+ const range = textSessionReplacementSpan(before.body, after.body, replacement);
188410
+ const delta = encodeSegmentsToDelta([...after.segments]);
188411
+ const oldProjection = createCollaborationTextProjection(
188412
+ before.segments,
188413
+ before.delta,
188414
+ before.body
188415
+ );
188416
+ const nextProjection = createCollaborationTextProjection(after.segments, delta, after.body);
188417
+ if (!range || !oldProjection || !nextProjection) {
188418
+ return void 0;
188419
+ }
188420
+ const oldCarriers = new Map(
188421
+ paragraphCarriers(oldProjection).flatMap(
188422
+ (span) => span ? [[span.segmentIndex, span]] : []
188423
+ )
188424
+ );
188425
+ const nextCarriers = paragraphCarriers(nextProjection);
188426
+ if (after.paragraphSources.length !== nextCarriers.length || Array.from(after.paragraphSources).some(
188427
+ (source) => source !== null && (!Number.isInteger(source) || !oldCarriers.has(source))
188428
+ )) {
188429
+ return void 0;
188430
+ }
188431
+ const oldText = before.delta.map((op2) => op2.insert).join("");
188432
+ const nextText = delta.map((op2) => op2.insert).join("");
188433
+ const oldBody = bodyUnits(oldProjection);
188434
+ const nextBody = bodyUnits(nextProjection);
188435
+ const retainedIndices = Array(nextText.length).fill(null);
188436
+ const paragraphSources = Array(nextText.length).fill(null);
188437
+ const afterEnd = after.body.length - range.suffix;
188438
+ for (const [bodyIndex, encodedIndex] of nextBody.entries()) {
188439
+ const previous = bodyIndex < range.prefix ? bodyIndex : bodyIndex >= afterEnd ? before.body.length - (after.body.length - bodyIndex) : void 0;
188440
+ if (previous !== void 0) {
188441
+ retainedIndices[encodedIndex] = oldBody[previous];
188442
+ }
188443
+ }
188444
+ for (const [paragraph, carrier] of nextCarriers.entries()) {
188445
+ const source = after.paragraphSources[paragraph];
188446
+ const oldCarrier = source === null ? void 0 : oldCarriers.get(source);
188447
+ if (!carrier || !oldCarrier) {
188448
+ continue;
188449
+ }
188450
+ paragraphSources.fill(oldCarrier.encodedStart, carrier.encodedStart, carrier.encodedEnd);
188451
+ }
188452
+ const hidden = nextProjection.spans.filter((span) => span.bodyStart === span.bodyEnd);
188453
+ if (after.hiddenSources.length !== hidden.length) {
188454
+ return void 0;
188455
+ }
188456
+ for (const [index, carrier] of hidden.entries()) {
188457
+ const source = after.hiddenSources[index];
188458
+ if (source === null) {
188459
+ continue;
188460
+ }
188461
+ const oldCarrier = oldProjection.spans[source];
188462
+ if (!Number.isInteger(source) || !oldCarrier || oldCarrier.bodyStart !== oldCarrier.bodyEnd || oldCarrier.kind !== carrier.kind || oldText.slice(oldCarrier.encodedStart, oldCarrier.encodedEnd) !== nextText.slice(carrier.encodedStart, carrier.encodedEnd)) {
188463
+ return void 0;
188464
+ }
188465
+ for (let unit = carrier.encodedStart; unit < carrier.encodedEnd; unit++) {
188466
+ retainedIndices[unit] = oldCarrier.encodedStart + unit - carrier.encodedStart;
188467
+ }
188468
+ }
188469
+ const correspondence = { retainedIndices, paragraphSources };
188470
+ return textSessionRetainedIndices(oldText, nextText, correspondence) ? { delta, correspondence } : void 0;
188471
+ }
188472
+ function attachCollaborationInlineEditor(root, element, options) {
188473
+ let disposed = false;
188474
+ let busy = false;
188475
+ let model = element;
188476
+ let modelKey = collaborationInlineModelKey(element);
188477
+ let previous;
188478
+ let painted;
188479
+ let controller;
188480
+ let events = void 0;
188481
+ let target = void 0;
188482
+ target = options.patcher.beginTextEdit?.(options.slideId, element.id, synchronize, checkModel);
188483
+ if (!target) {
188484
+ return void 0;
188485
+ }
188486
+ const initial = target.readMerged();
188487
+ if (!initial || !paint(initial)) {
188488
+ controller?.dispose();
188489
+ target.dispose();
188490
+ return void 0;
188491
+ }
188492
+ events = observeCollaborationInlineInput(root, () => painted.seed, applyInput, synchronize);
188493
+ return {
188494
+ read,
188495
+ readAccepted: () => !disposed ? target?.readMerged()?.inline : void 0,
188496
+ checkModel,
188497
+ mutate(range, apply) {
188498
+ if (disposed || busy || events?.blocked() || !painted) {
188499
+ return false;
188500
+ }
188501
+ const selected = readInlineListRange(painted.seed, root, range);
188502
+ if (selected.kind !== "supported" || !selected.bodyRange) {
188503
+ return false;
188504
+ }
188505
+ try {
188506
+ apply();
188507
+ } catch {
188508
+ cancel();
188509
+ return false;
188510
+ }
188511
+ applyInput({ from: selected.bodyRange.start, to: selected.bodyRange.end });
188512
+ return !disposed;
188513
+ },
188514
+ format(snapshot) {
188515
+ if (disposed || events?.blocked()) {
188516
+ return read();
188517
+ }
188518
+ const result = controller?.format(snapshot);
188519
+ return result?.kind === "unsupported" ? result : read();
188520
+ },
188521
+ readSelection: (selection) => controller?.readSelection(selection) ?? { kind: "unsupported", reason: "inactive-session" },
188522
+ refresh() {
188523
+ synchronize();
188524
+ return read();
188525
+ },
188526
+ dispose
188527
+ };
188528
+ function dispose() {
188529
+ if (disposed) {
188530
+ return;
188531
+ }
188532
+ disposed = true;
188533
+ events?.dispose();
188534
+ controller?.dispose();
188535
+ target.dispose();
188536
+ }
188537
+ function cancel() {
188538
+ if (!disposed) {
188539
+ dispose();
188540
+ options.onCancel?.();
188541
+ }
188542
+ }
188543
+ function read() {
188544
+ const reason = events?.reason();
188545
+ if (reason && !disposed) {
188546
+ return { kind: "unsupported", reason, text: previous?.text ?? "" };
188547
+ }
188548
+ const merged = !disposed && target.readMerged();
188549
+ return merged ? {
188550
+ kind: "supported",
188551
+ snapshot: merged.inline,
188552
+ paragraphs: buildParagraphs(model, void 0, merged.inline.textSegments, {
188553
+ preserveTrailingEmpty: true
188554
+ })
188555
+ } : { kind: "unsupported", reason: "inactive-session", text: "" };
188556
+ }
188557
+ function checkModel(candidate) {
188558
+ if (disposed || !candidate || candidate.id !== element.id) {
188559
+ cancel();
188560
+ return false;
188561
+ }
188562
+ const key2 = collaborationInlineModelKey(candidate);
188563
+ if (key2 === modelKey) {
188564
+ return true;
188565
+ }
188566
+ const merged = target.readMerged();
188567
+ if (merged && collaborationInlineModelKey({ ...model, ...merged.inline }) === key2) {
188568
+ model = candidate;
188569
+ modelKey = key2;
188570
+ return true;
188571
+ }
188572
+ cancel();
188573
+ return false;
188574
+ }
188575
+ function paint(merged) {
188576
+ if (!createCollaborationTextProjection(
188577
+ merged.inline.textSegments ?? [],
188578
+ merged.delta,
188579
+ merged.inline.text
188580
+ )) {
188581
+ return false;
188582
+ }
188583
+ const prepared = prepareCollaborationInlineDom(root, model, merged.inline);
188584
+ if (!prepared) {
188585
+ return false;
188586
+ }
188587
+ const restore = painted && previous ? bookmarkCollaborationInlineSelection(root, painted.seed, previous, target) : void 0;
188588
+ controller?.dispose();
188589
+ root.replaceChildren(...prepared.children);
188590
+ painted = prepared;
188591
+ controller = attachInlineListController(root, prepared.seed, {
188592
+ isCurrent: () => !disposed,
188593
+ onFormat: () => applyInput({ from: 0, to: 0 })
188594
+ });
188595
+ const captured = readInlineListNativeSnapshot(prepared.seed, root);
188596
+ if (captured.kind !== "supported" || !createCollaborationTextProjection(
188597
+ captured.snapshot.textSegments ?? [],
188598
+ merged.delta,
188599
+ captured.snapshot.text
188600
+ ) || !target.adoptMerged(merged)) {
188601
+ return false;
188602
+ }
188603
+ previous = captured.snapshot;
188604
+ restore?.(prepared.seed, previous);
188605
+ return true;
188606
+ }
188607
+ function synchronize() {
188608
+ if (!target || disposed || busy) {
188609
+ return;
188610
+ }
188611
+ const merged = target.readMerged();
188612
+ if (!merged || !previous || !painted) {
188613
+ cancel();
188614
+ return;
188615
+ }
188616
+ if (events?.blocked()) {
188617
+ return;
188618
+ }
188619
+ const matching = createCollaborationTextProjection(
188620
+ previous.textSegments ?? [],
188621
+ merged.delta,
188622
+ previous.text
188623
+ );
188624
+ if (matching ? !target.adoptMerged(merged) : !paint(merged)) {
188625
+ cancel();
188626
+ return;
188627
+ }
188628
+ options.onSnapshot?.(merged.inline);
188629
+ }
188630
+ function applyInput(range) {
188631
+ if (disposed || busy || !previous || !painted) {
188632
+ return;
188633
+ }
188634
+ const next = readInlineListNativeSnapshot(painted.seed, root, previous);
188635
+ if (next.kind !== "supported") {
188636
+ cancel();
188637
+ return;
188638
+ }
188639
+ const beforeDelta = encodeSegmentsToDelta(previous.textSegments ?? []);
188640
+ if (JSON.stringify(beforeDelta) === JSON.stringify(encodeSegmentsToDelta(next.snapshot.textSegments ?? []))) {
188641
+ synchronize();
188642
+ return;
188643
+ }
188644
+ const replacement = resolveCollaborationNativeRange(range, previous.text, next.snapshot.text);
188645
+ const edit = replacement && createNativeCollaborationTextEdit(
188646
+ { segments: previous.textSegments ?? [], body: previous.text, delta: beforeDelta },
188647
+ {
188648
+ segments: next.snapshot.textSegments ?? [],
188649
+ body: next.snapshot.text,
188650
+ paragraphSources: next.paragraphSources,
188651
+ hiddenSources: next.hiddenSources
188652
+ },
188653
+ replacement
188654
+ );
188655
+ if (!edit) {
188656
+ cancel();
188657
+ return;
188658
+ }
188659
+ busy = true;
188660
+ let applied = false;
188661
+ try {
188662
+ applied = target.applyLocalDelta(edit.delta, edit.correspondence);
188663
+ } finally {
188664
+ busy = false;
188665
+ }
188666
+ if (!applied) {
188667
+ cancel();
188668
+ return;
188669
+ }
188670
+ previous = next.snapshot;
188671
+ synchronize();
188672
+ }
188673
+ }
188674
+ function createTextPositionTracker(length) {
188675
+ const start = { index: 0 };
188676
+ const end = { index: length };
188677
+ let cells2 = Array.from({ length }, (_, index) => ({ index }));
188678
+ let disposed = false;
188679
+ const dispose = () => {
188680
+ disposed = true;
188681
+ cells2 = [];
188682
+ };
188683
+ const neighbour = (cell, direction) => {
188684
+ const path = [];
188685
+ while (cell.index < 0) {
188686
+ path.push(cell);
188687
+ cell = cell[direction];
188688
+ }
188689
+ for (const removed of path) {
188690
+ removed[direction] = cell;
188691
+ }
188692
+ return cell;
188693
+ };
188694
+ return {
188695
+ capture(index, association) {
188696
+ if (disposed || !Number.isInteger(index) || index < 0 || index > cells2.length) {
188697
+ throw new RangeError("Cannot capture a position outside the current text");
188698
+ }
188699
+ return {
188700
+ cell: association < 0 ? cells2[index - 1] ?? start : cells2[index] ?? end,
188701
+ association
188702
+ };
188703
+ },
188704
+ resolve(position2) {
188705
+ if (disposed) {
188706
+ return null;
188707
+ }
188708
+ const cell = neighbour(position2.cell, position2.association < 0 ? "left" : "right");
188709
+ return cell === start || cell === end ? cell.index : cell.index + (position2.association < 0 ? 1 : 0);
188710
+ },
188711
+ apply(changes) {
188712
+ if (disposed) {
188713
+ return false;
188714
+ }
188715
+ let oldIndex = 0;
188716
+ const next = [];
188717
+ const removed = [];
188718
+ for (const change of changes) {
188719
+ if ([change.retain, change.delete, change.insert].filter((value) => value !== void 0).length !== 1) {
188720
+ dispose();
188721
+ return false;
188722
+ }
188723
+ if (change.insert !== void 0) {
188724
+ for (let index = 0; index < change.insert.length; index++) {
188725
+ next.push({ index: next.length });
188726
+ }
188727
+ continue;
188728
+ }
188729
+ const count = change.retain ?? change.delete;
188730
+ if (!Number.isInteger(count) || count < 0 || oldIndex + count > cells2.length) {
188731
+ dispose();
188732
+ return false;
188733
+ }
188734
+ for (let index = 0; index < count; index++) {
188735
+ const cell = cells2[oldIndex++];
188736
+ if (change.retain !== void 0) {
188737
+ next.push(cell);
188738
+ } else {
188739
+ removed.push({ cell, left: next.at(-1) ?? start, rightIndex: next.length });
188740
+ }
188741
+ }
188742
+ }
188743
+ while (oldIndex < cells2.length) {
188744
+ next.push(cells2[oldIndex++]);
188745
+ }
188746
+ for (const { cell, left, rightIndex } of removed) {
188747
+ cell.index = -1;
188748
+ cell.left = left;
188749
+ cell.right = next[rightIndex] ?? end;
188750
+ }
188751
+ next.forEach((cell, index) => {
188752
+ cell.index = index;
188753
+ });
188754
+ cells2 = next;
188755
+ end.index = cells2.length;
188756
+ return true;
188757
+ },
188758
+ dispose
188759
+ };
188760
+ }
188761
+ function createSnapshotTextPositions(text22, snapshots2) {
188762
+ const tracker = createTextPositionTracker(text22.toString().length);
188763
+ let previous = snapshots2.read();
188764
+ let busy = false;
188765
+ let disposed = false;
188766
+ let unsubscribe = () => {
188767
+ };
188768
+ const marker = /* @__PURE__ */ Symbol("text-identity-change");
188769
+ const dispose = () => {
188770
+ if (!disposed) {
188771
+ disposed = true;
188772
+ unsubscribe();
188773
+ tracker.dispose();
188774
+ }
188775
+ };
188776
+ const refresh = () => {
188777
+ if (disposed || busy) {
188778
+ return false;
188779
+ }
188780
+ busy = true;
188781
+ try {
188782
+ const current = snapshots2.read();
188783
+ if (snapshots2.equal(current, previous)) {
188784
+ return true;
188785
+ }
188786
+ const delta = text22.toDelta(current, previous, (type) => ({ type, marker }));
188787
+ const changes = [];
188788
+ for (const op2 of delta) {
188789
+ if (typeof op2.insert !== "string") {
188790
+ dispose();
188791
+ return false;
188792
+ }
188793
+ const change = op2.attributes?.ychange;
188794
+ const marked = typeof change === "object" && change !== null && "marker" in change && change.marker === marker && "type" in change;
188795
+ changes.push(
188796
+ !marked ? { retain: op2.insert.length } : change.type === "added" ? { insert: op2.insert } : { delete: op2.insert.length }
188797
+ );
188798
+ }
188799
+ previous = current;
188800
+ if (changes.some((change) => change.insert !== void 0 || change.delete !== void 0) && !tracker.apply(changes)) {
188801
+ dispose();
188802
+ return false;
188803
+ }
188804
+ return true;
188805
+ } catch {
188806
+ dispose();
188807
+ return false;
188808
+ } finally {
188809
+ busy = false;
188810
+ }
188811
+ };
188812
+ const stop = snapshots2.subscribeBeforeObservers(refresh);
188813
+ if (disposed) {
188814
+ stop();
188815
+ } else {
188816
+ unsubscribe = stop;
188817
+ }
188818
+ return { capture: tracker.capture, resolve: tracker.resolve, refresh, dispose };
188819
+ }
187175
188820
  function createSyncGate(onOpen, graceMs = INITIAL_SYNC_GRACE_MS) {
187176
188821
  let opened = false;
187177
188822
  let timer = null;
@@ -191235,6 +192880,362 @@ function collectCoherent3DOffNodeIds(nodes) {
191235
192880
  }
191236
192881
  return ids;
191237
192882
  }
192883
+ var LINE_HEIGHT_RATIO = 1.2;
192884
+ function centeredSvgTextLines(text22, fontSize, options = {}) {
192885
+ const lines = options.maxWidth !== void 0 ? wrapTextByEstimatedWidth(text22, options.maxWidth, fontSize) : text22.split("\n").filter((line4) => line4.length > 0);
192886
+ const centerY = options.centerY ?? 0;
192887
+ if (lines.length === 0) {
192888
+ return [{ text: "", y: centerY }];
192889
+ }
192890
+ const lineHeight = options.lineHeight ?? fontSize * (options.lineHeightRatio ?? LINE_HEIGHT_RATIO);
192891
+ const blockTop = centerY - lines.length * lineHeight / 2;
192892
+ return lines.map((line4, index) => ({
192893
+ text: line4,
192894
+ y: blockTop + lineHeight / 2 + index * lineHeight
192895
+ }));
192896
+ }
192897
+ var PALETTES = {
192898
+ colorful1: ["#3b82f6", "#22c55e", "#f97316", "#eab308", "#a855f7", "#ec4899"],
192899
+ colorful2: ["#6366f1", "#14b8a6", "#f59e0b", "#ef4444", "#8b5cf6", "#06b6d4"],
192900
+ colorful3: ["#0ea5e9", "#84cc16", "#f43e5e", "#a855f7", "#f97316", "#10b981"],
192901
+ monochromatic1: ["#3b82f6", "#60a5fa", "#93c5fd", "#bfdbfe", "#2563eb", "#1d4ed8"],
192902
+ monochromatic2: ["#6366f1", "#818cf8", "#a5b4fc", "#c7d2fe", "#4f46e5", "#4338ca"]
192903
+ };
192904
+ var DEFAULT_PALETTE2 = PALETTES.colorful1;
192905
+ function paletteColour(index, palette) {
192906
+ return palette[index % palette.length];
192907
+ }
192908
+ function resolvePalette(data) {
192909
+ if (!data) {
192910
+ return DEFAULT_PALETTE2;
192911
+ }
192912
+ const ctFills = data.colorTransform?.fillColors;
192913
+ if (ctFills && ctFills.length > 0) {
192914
+ return ctFills;
192915
+ }
192916
+ return PALETTES[data.colorScheme ?? "colorful1"] ?? DEFAULT_PALETTE2;
192917
+ }
192918
+ function buildChromeStyle(chrome) {
192919
+ const s = {
192920
+ width: "100%",
192921
+ height: "100%",
192922
+ "box-sizing": "border-box",
192923
+ overflow: "hidden"
192924
+ };
192925
+ if (!chrome) {
192926
+ return s;
192927
+ }
192928
+ if (chrome.backgroundColor) {
192929
+ s["background-color"] = chrome.backgroundColor;
192930
+ }
192931
+ if (chrome.outlineColor) {
192932
+ s["border"] = `${chrome.outlineWidth ?? 1}px solid ${chrome.outlineColor}`;
192933
+ }
192934
+ return s;
192935
+ }
192936
+ var TEXT_WIDTH_FRACTION = 0.82;
192937
+ var CJK_SMARTART_TEXT_RE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
192938
+ var CJK_SMARTART_LINE_HEIGHT_RATIO = 1.33;
192939
+ var DEFAULT_SMARTART_LINE_HEIGHT_RATIO = 1.2;
192940
+ function drawingTextBaseLineHeightRatio(text22) {
192941
+ return CJK_SMARTART_TEXT_RE.test(text22 ?? "") ? CJK_SMARTART_LINE_HEIGHT_RATIO : DEFAULT_SMARTART_LINE_HEIGHT_RATIO;
192942
+ }
192943
+ function underlyingFill(shape, shapes, index) {
192944
+ const centerX = shape.x + shape.width / 2;
192945
+ const centerY = shape.y + shape.height / 2;
192946
+ for (let below = index - 1; below >= 0; below--) {
192947
+ const candidate = shapes[below];
192948
+ if (!candidate || candidate.fillNone || !candidate.fillColor) {
192949
+ continue;
192950
+ }
192951
+ if (centerX >= candidate.x && centerX <= candidate.x + candidate.width && centerY >= candidate.y && centerY <= candidate.y + candidate.height) {
192952
+ return candidate.fillColor;
192953
+ }
192954
+ }
192955
+ return void 0;
192956
+ }
192957
+ function drawingShapeLabelColor(shape, shapes, index, resolvedFill) {
192958
+ const basis = resolvedFill === "none" || resolvedFill.startsWith("url(") ? underlyingFill(shape, shapes, index) : resolvedFill;
192959
+ return basis ? contrastTextColor(basis) : "#1a1a1a";
192960
+ }
192961
+ function computeDrawingViewBox(shapes) {
192962
+ let minX = Infinity;
192963
+ let minY = Infinity;
192964
+ let maxX = -Infinity;
192965
+ let maxY = -Infinity;
192966
+ for (const s of shapes) {
192967
+ const shapeMinX = Math.min(s.x, s.textFrameX ?? s.x);
192968
+ const shapeMinY = Math.min(s.y, s.textFrameY ?? s.y);
192969
+ const shapeMaxX = Math.max(
192970
+ s.x + s.width,
192971
+ (s.textFrameX ?? s.x) + (s.textFrameWidth ?? s.width)
192972
+ );
192973
+ const shapeMaxY = Math.max(
192974
+ s.y + s.height,
192975
+ (s.textFrameY ?? s.y) + (s.textFrameHeight ?? s.height)
192976
+ );
192977
+ if (shapeMinX < minX) {
192978
+ minX = shapeMinX;
192979
+ }
192980
+ if (shapeMinY < minY) {
192981
+ minY = shapeMinY;
192982
+ }
192983
+ if (shapeMaxX > maxX) {
192984
+ maxX = shapeMaxX;
192985
+ }
192986
+ if (shapeMaxY > maxY) {
192987
+ maxY = shapeMaxY;
192988
+ }
192989
+ }
192990
+ if (!Number.isFinite(minX)) {
192991
+ return { minX: 0, minY: 0, width: 1, height: 1 };
192992
+ }
192993
+ return {
192994
+ minX,
192995
+ minY,
192996
+ width: maxX - minX || 1,
192997
+ height: maxY - minY || 1
192998
+ };
192999
+ }
193000
+ function resolveGradient(shape, id) {
193001
+ const stops = shape.fillGradientStops;
193002
+ if (!stops || stops.length === 0) {
193003
+ return void 0;
193004
+ }
193005
+ const mapped = stops.map((stop) => ({
193006
+ offset: `${Math.max(0, Math.min(100, stop.position))}%`,
193007
+ color: stop.color,
193008
+ ...stop.opacity !== void 0 ? { opacity: stop.opacity } : {}
193009
+ }));
193010
+ if (shape.fillGradientType === "radial") {
193011
+ return { id, kind: "radial", cx: "50%", cy: "50%", r: "50%", stops: mapped };
193012
+ }
193013
+ const radians = (shape.fillGradientAngle ?? 0) * Math.PI / 180;
193014
+ const dx = Math.cos(radians) / 2;
193015
+ const dy = Math.sin(radians) / 2;
193016
+ return {
193017
+ id,
193018
+ kind: "linear",
193019
+ x1: `${(0.5 - dx) * 100}%`,
193020
+ y1: `${(0.5 - dy) * 100}%`,
193021
+ x2: `${(0.5 + dx) * 100}%`,
193022
+ y2: `${(0.5 + dy) * 100}%`,
193023
+ stops: mapped
193024
+ };
193025
+ }
193026
+ function resolveShapeKind(shape, hasImage) {
193027
+ if (hasImage) {
193028
+ return "image";
193029
+ }
193030
+ const normalized = (shape.shapeType ?? "").trim().toLowerCase();
193031
+ if (normalized === "ellipse" || normalized === "oval") {
193032
+ return "ellipse";
193033
+ }
193034
+ const identityPresets = /* @__PURE__ */ new Set(["rect", "flowchartprocess", "roundrect"]);
193035
+ return identityPresets.has(normalized) || normalized.length === 0 ? "rect" : "path";
193036
+ }
193037
+ function drawingShapeTransform(shape, cx, cy) {
193038
+ const transforms = [];
193039
+ if (shape.rotation) {
193040
+ transforms.push(`rotate(${shape.rotation} ${cx} ${cy})`);
193041
+ }
193042
+ if (shape.flipHorizontal || shape.flipVertical) {
193043
+ transforms.push(
193044
+ `translate(${cx} ${cy}) scale(${shape.flipHorizontal ? -1 : 1} ${shape.flipVertical ? -1 : 1}) translate(${-cx} ${-cy})`
193045
+ );
193046
+ }
193047
+ return transforms.length > 0 ? transforms.join(" ") : void 0;
193048
+ }
193049
+ function projectDrawingShapes(elementId, shapes, viewBox, palette, style) {
193050
+ const { minX, minY } = viewBox;
193051
+ const sw = styleStroke(style);
193052
+ return shapes.map((shape, i2) => {
193053
+ const gradient = shape.fillNone ? void 0 : resolveGradient(shape, `${elementId}-dspgrad-${shape.id}-${i2}`);
193054
+ const fill = shape.fillNone ? "none" : gradient ? `url(#${gradient.id})` : shape.fillPatternForegroundColor ?? shape.fillColor ?? paletteColour(i2, palette);
193055
+ const relX = shape.x - minX;
193056
+ const relY = shape.y - minY;
193057
+ const kind = resolveShapeKind(shape, Boolean(shape.fillImageUrl));
193058
+ const rx = getShapeType(shape.shapeType) === "roundRect" ? Math.min(shape.width, shape.height) * 0.1 : 0;
193059
+ const cx = relX + shape.width / 2;
193060
+ const cy = relY + shape.height / 2;
193061
+ const stroke = shape.strokeColor ?? (sw > 0 ? "rgba(255,255,255,0.3)" : "none");
193062
+ const transform6 = drawingShapeTransform(shape, cx, cy);
193063
+ const presetGeometry = kind === "path" ? getPresetShapeVectorGeometry(
193064
+ shape.shapeType,
193065
+ shape.width,
193066
+ shape.height,
193067
+ shape.shapeAdjustments
193068
+ ) : void 0;
193069
+ const fontSize = shape.fontSize ?? Math.max(8, Math.min(14, shape.height * 0.2));
193070
+ const hasTextFrame = Number.isFinite(shape.textFrameX) && Number.isFinite(shape.textFrameY) && Number.isFinite(shape.textFrameWidth) && Number.isFinite(shape.textFrameHeight) && (shape.textFrameWidth ?? 0) > 0 && (shape.textFrameHeight ?? 0) > 0;
193071
+ const textFrameX = (hasTextFrame ? shape.textFrameX : shape.x) - minX;
193072
+ const textFrameY = (hasTextFrame ? shape.textFrameY : shape.y) - minY;
193073
+ const textFrameWidth = hasTextFrame ? shape.textFrameWidth : shape.width;
193074
+ const textFrameHeight = hasTextFrame ? shape.textFrameHeight : shape.height;
193075
+ const textInsetLeft = shape.textInsetLeft ?? 0;
193076
+ const textInsetRight = shape.textInsetRight ?? 0;
193077
+ const textInsetTop = shape.textInsetTop ?? 0;
193078
+ const textInsetBottom = shape.textInsetBottom ?? 0;
193079
+ const textContentWidth = Math.max(1, textFrameWidth - textInsetLeft - textInsetRight);
193080
+ const textContentHeight = Math.max(1, textFrameHeight - textInsetTop - textInsetBottom);
193081
+ const textCenterX = textFrameX + textInsetLeft + textContentWidth / 2;
193082
+ const textCenterY = textFrameY + textInsetTop + textContentHeight / 2;
193083
+ const textWrapWidth = hasTextFrame ? textContentWidth : shape.width * TEXT_WIDTH_FRACTION;
193084
+ const authoredLineHeightRatio = shape.lineHeightRatio ?? 1;
193085
+ const lineHeightRatio = drawingTextBaseLineHeightRatio(shape.text) * authoredLineHeightRatio + (shape.lineSpacingAfterRatio ?? 0);
193086
+ const lineHeight = shape.lineHeight !== void 0 || shape.lineSpacingAfter !== void 0 ? (shape.lineHeight ?? fontSize * drawingTextBaseLineHeightRatio(shape.text) * authoredLineHeightRatio) + (shape.lineSpacingAfter ?? 0) : void 0;
193087
+ return {
193088
+ key: `${elementId}-dsp-${shape.id}-${i2}`,
193089
+ kind,
193090
+ ...presetGeometry ? {
193091
+ pathData: presetGeometry.d,
193092
+ pathTransform: [transform6, `translate(${relX} ${relY})`].filter(Boolean).join(" ")
193093
+ } : {},
193094
+ ...gradient ? { gradient } : {},
193095
+ x: relX,
193096
+ y: relY,
193097
+ width: shape.width,
193098
+ height: shape.height,
193099
+ rx,
193100
+ cx,
193101
+ cy,
193102
+ fill,
193103
+ stroke,
193104
+ strokeWidth: shape.strokeWidth ?? sw,
193105
+ transform: transform6,
193106
+ imageUrl: shape.fillImageUrl,
193107
+ textLines: shape.text ? centeredSvgTextLines(shape.text, fontSize, {
193108
+ maxWidth: textWrapWidth,
193109
+ centerY: textCenterY,
193110
+ lineHeight,
193111
+ lineHeightRatio
193112
+ }) : [],
193113
+ textX: textCenterX,
193114
+ textY: textCenterY,
193115
+ textWidth: textContentWidth,
193116
+ textHeight: textContentHeight,
193117
+ fontColor: shape.fontColor ?? drawingShapeLabelColor(shape, shapes, i2, fill),
193118
+ fontSize,
193119
+ fontFamily: shape.fontFamily ? getSubstituteFontFamily(shape.fontFamily) : void 0,
193120
+ fontWeight: shape.fontWeight,
193121
+ fontStyle: shape.fontStyle
193122
+ };
193123
+ });
193124
+ }
193125
+ function styleShadowFilter(style) {
193126
+ return styleShadow(style);
193127
+ }
193128
+ function fitDrawingToBox(drawing, box) {
193129
+ const scale2 = Math.min(box.width / drawing.width, box.height / drawing.height) || 1;
193130
+ return {
193131
+ scale: scale2,
193132
+ offsetX: (box.width - drawing.width * scale2) / 2,
193133
+ offsetY: (box.height - drawing.height * scale2) / 2
193134
+ };
193135
+ }
193136
+ function solidFill3(shape, rendered) {
193137
+ if (shape.fillNone || rendered.fill === "none") {
193138
+ return null;
193139
+ }
193140
+ if (rendered.gradient) {
193141
+ return rendered.gradient.stops[0]?.color ?? shape.fillColor ?? null;
193142
+ }
193143
+ return rendered.fill;
193144
+ }
193145
+ function drawingShapeNode(shape, rendered, fit) {
193146
+ const fill = solidFill3(shape, rendered);
193147
+ if (!fill) {
193148
+ return null;
193149
+ }
193150
+ const { scale: scale2, offsetX, offsetY } = fit;
193151
+ const sx = (x) => offsetX + x * scale2;
193152
+ const sy = (y) => offsetY + y * scale2;
193153
+ const base = {
193154
+ key: rendered.key,
193155
+ fill,
193156
+ stroke: rendered.stroke,
193157
+ strokeWidth: rendered.strokeWidth * scale2,
193158
+ opacity: 1,
193159
+ text: shape.text ?? "",
193160
+ fontSize: rendered.fontSize * scale2,
193161
+ textX: sx(rendered.textX),
193162
+ textY: sy(rendered.textY)
193163
+ };
193164
+ if (rendered.kind === "ellipse") {
193165
+ return {
193166
+ ...base,
193167
+ kind: "circle",
193168
+ cx: sx(rendered.cx),
193169
+ cy: sy(rendered.cy),
193170
+ r: Math.min(rendered.width, rendered.height) / 2 * scale2,
193171
+ rx: rendered.width / 2 * scale2,
193172
+ ry: rendered.height / 2 * scale2
193173
+ };
193174
+ }
193175
+ if (rendered.kind === "path" && rendered.pathData) {
193176
+ const pts = parsePathPoints(rendered.pathData);
193177
+ if (pts.length >= 3) {
193178
+ return {
193179
+ ...base,
193180
+ kind: "polygon",
193181
+ points: pts.map((p) => `${sx(rendered.x + p.x)},${sy(rendered.y + p.y)}`).join(" ")
193182
+ };
193183
+ }
193184
+ }
193185
+ return {
193186
+ ...base,
193187
+ kind: "rect",
193188
+ x: sx(rendered.x),
193189
+ y: sy(rendered.y),
193190
+ width: rendered.width * scale2,
193191
+ height: rendered.height * scale2,
193192
+ rx: rendered.rx * scale2
193193
+ };
193194
+ }
193195
+ function drawingShapesLayoutResult(elementId, shapes, box, palette, style, family) {
193196
+ if (!shapes || shapes.length === 0) {
193197
+ return null;
193198
+ }
193199
+ const viewBox = computeDrawingViewBox(shapes);
193200
+ const fit = fitDrawingToBox(viewBox, box);
193201
+ const rendered = projectDrawingShapes(elementId, shapes, viewBox, palette, style);
193202
+ const nodes = [];
193203
+ rendered.forEach((r, i2) => {
193204
+ const node = drawingShapeNode(shapes[i2], r, fit);
193205
+ if (node) {
193206
+ nodes.push(node);
193207
+ }
193208
+ });
193209
+ if (nodes.length === 0) {
193210
+ return null;
193211
+ }
193212
+ return {
193213
+ nodes,
193214
+ connectors: [],
193215
+ shadowFilter: void 0,
193216
+ viewBox: `0 0 ${box.width} ${box.height}`,
193217
+ family
193218
+ };
193219
+ }
193220
+ function resolveSmartArt3DLayout(smartArtData, nodes, box, palette, style, elementId) {
193221
+ const family = resolveLayoutFamily(nodes, smartArtData.resolvedLayoutType, smartArtData.layout);
193222
+ return drawingShapesLayoutResult(elementId, smartArtData.drawingShapes, box, palette, style, family) ?? computeSmartArtElementLayout(smartArtData, nodes, box, palette, style, elementId);
193223
+ }
193224
+ function observeElementHeight(el, onHeight) {
193225
+ onHeight(el.getBoundingClientRect().height);
193226
+ if (typeof ResizeObserver === "undefined") {
193227
+ return () => void 0;
193228
+ }
193229
+ const observer = new ResizeObserver((entries) => {
193230
+ const entry2 = entries[entries.length - 1];
193231
+ if (entry2) {
193232
+ const box = entry2.borderBoxSize?.[0]?.blockSize;
193233
+ onHeight(box ?? el.getBoundingClientRect().height);
193234
+ }
193235
+ });
193236
+ observer.observe(el);
193237
+ return () => observer.disconnect();
193238
+ }
191238
193239
  var MAX_LISTED_NODES = 8;
191239
193240
  var LAYOUT_LABELS = {
191240
193241
  list: "List",
@@ -192424,10 +194425,18 @@ function computeSphericalCameraPlacement(maxExtent, targetY, view3D) {
192424
194425
  fov
192425
194426
  };
192426
194427
  }
192427
- function computeCartesianCameraPlacement(cols, rows, view3D) {
194428
+ function computeCartesianCameraPlacement(cols, rows, view3D, horizontal = false) {
192428
194429
  const { gridWidth, gridDepth } = computeCartesianGridExtent(cols, rows, view3D?.depthPercent);
192429
194430
  const maxExtent = Math.max(gridWidth, gridDepth, MAX_VALUE_HEIGHT);
192430
- return computeSphericalCameraPlacement(maxExtent, MAX_VALUE_HEIGHT * 0.2, view3D);
194431
+ const placement = computeSphericalCameraPlacement(maxExtent, MAX_VALUE_HEIGHT * 0.2, view3D);
194432
+ if (!horizontal) {
194433
+ return placement;
194434
+ }
194435
+ return {
194436
+ ...placement,
194437
+ position: transposeForHorizontalBar3D(placement.position),
194438
+ target: transposeForHorizontalBar3D(placement.target)
194439
+ };
192431
194440
  }
192432
194441
  function buildCartesianChart3DLabels(cols, rows, categoryLabels, seriesNames, depthPercent, maxCat = 8, maxSer = 6, horizontal = false) {
192433
194442
  const { gridWidth, gridDepth } = computeCartesianGridExtent(cols, rows, depthPercent);
@@ -192876,7 +194885,12 @@ async function mountBarChart3D(container, options, interaction) {
192876
194885
  const fill = new three.DirectionalLight(16777215, 0.3);
192877
194886
  fill.position.set(-3, 4, -2);
192878
194887
  scene.add(fill);
192879
- const placement = computeCartesianCameraPlacement(options.cols, options.rows, options.view3D);
194888
+ const placement = computeCartesianCameraPlacement(
194889
+ options.cols,
194890
+ options.rows,
194891
+ options.view3D,
194892
+ options.horizontal
194893
+ );
192880
194894
  const camera = new three.PerspectiveCamera(placement.fov, width / height, 0.1, 1e3);
192881
194895
  camera.position.set(...placement.position);
192882
194896
  const target = new three.Vector3(...placement.target);
@@ -194291,344 +196305,6 @@ function buildPieChart3DDataForElement(element, options) {
194291
196305
  const categoryLabels = chartData.categories.length > 0 ? chartData.categories : Array.from({ length: pieSeries.values.length }, (_, i2) => String(i2 + 1));
194292
196306
  return buildPieChart3DData(chartData, categoryLabels, options);
194293
196307
  }
194294
- function estimatedGlyphAdvanceRatio(glyph) {
194295
- if (/\p{Mark}/u.test(glyph)) {
194296
- return 0;
194297
- }
194298
- if (/\s/u.test(glyph)) {
194299
- return 0.33;
194300
- }
194301
- if (/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Extended_Pictographic}]/u.test(
194302
- glyph
194303
- )) {
194304
- return 1;
194305
- }
194306
- if (/[A-Z]/u.test(glyph)) {
194307
- return 0.65;
194308
- }
194309
- if (/[a-z0-9]/u.test(glyph)) {
194310
- return 0.55;
194311
- }
194312
- if (/[,.;:!?()\u005b\u005d{}'"`\-_/\\]/u.test(glyph)) {
194313
- return 0.35;
194314
- }
194315
- return 0.6;
194316
- }
194317
- function estimatedTextWidth(glyphs, fontSize) {
194318
- return glyphs.reduce((sum, glyph) => sum + estimatedGlyphAdvanceRatio(glyph) * fontSize, 0);
194319
- }
194320
- var HANGING_PUNCTUATION_RE = /^[\u3001\u3002\uff0c\uff0e\uff01\uff1f\uff1b\uff1a\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\uff09\uff3d\uff5d\u2019\u201d\u00bb\u203a]$/u;
194321
- var BREAKABLE_GLYPH_RE = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Extended_Pictographic}]$/u;
194322
- function estimatedWrapUnits(text22) {
194323
- const units = [];
194324
- let unbreakableRun = "";
194325
- const flushRun = () => {
194326
- if (unbreakableRun.length > 0) {
194327
- units.push(unbreakableRun);
194328
- unbreakableRun = "";
194329
- }
194330
- };
194331
- for (const glyph of Array.from(text22)) {
194332
- if (/\s/u.test(glyph) || BREAKABLE_GLYPH_RE.test(glyph)) {
194333
- flushRun();
194334
- units.push(glyph);
194335
- } else {
194336
- unbreakableRun += glyph;
194337
- }
194338
- }
194339
- flushRun();
194340
- return units;
194341
- }
194342
- function wrapTextByEstimatedWidth(text22, maxWidth, fontSize, options = {}) {
194343
- if (!text22 || text22.trim().length === 0) {
194344
- return [];
194345
- }
194346
- if (!(maxWidth > 0) || !(fontSize > 0)) {
194347
- return [];
194348
- }
194349
- const lines = [];
194350
- for (const paragraph of text22.split(/\r?\n/u)) {
194351
- if (paragraph.trim().length === 0) {
194352
- if (options.keepBlankLines) {
194353
- lines.push("");
194354
- }
194355
- continue;
194356
- }
194357
- let current = "";
194358
- let pendingWhitespace = false;
194359
- for (const unit of estimatedWrapUnits(paragraph)) {
194360
- if (/^\s+$/u.test(unit)) {
194361
- pendingWhitespace = current.length > 0;
194362
- continue;
194363
- }
194364
- const separator = pendingWhitespace && current.length > 0 ? " " : "";
194365
- const candidate = `${current}${separator}${unit}`;
194366
- if (current.length === 0 || estimatedTextWidth(Array.from(candidate), fontSize) <= maxWidth) {
194367
- current = candidate;
194368
- pendingWhitespace = false;
194369
- continue;
194370
- }
194371
- if (HANGING_PUNCTUATION_RE.test(unit)) {
194372
- current += unit;
194373
- pendingWhitespace = false;
194374
- continue;
194375
- }
194376
- lines.push(current);
194377
- current = unit;
194378
- pendingWhitespace = false;
194379
- }
194380
- const completed = current.trimEnd();
194381
- if (completed.length > 0) {
194382
- lines.push(completed);
194383
- }
194384
- }
194385
- return lines;
194386
- }
194387
- var LINE_HEIGHT_RATIO = 1.2;
194388
- function centeredSvgTextLines(text22, fontSize, options = {}) {
194389
- const lines = options.maxWidth !== void 0 ? wrapTextByEstimatedWidth(text22, options.maxWidth, fontSize) : text22.split("\n").filter((line4) => line4.length > 0);
194390
- const centerY = options.centerY ?? 0;
194391
- if (lines.length === 0) {
194392
- return [{ text: "", y: centerY }];
194393
- }
194394
- const lineHeight = options.lineHeight ?? fontSize * (options.lineHeightRatio ?? LINE_HEIGHT_RATIO);
194395
- const blockTop = centerY - lines.length * lineHeight / 2;
194396
- return lines.map((line4, index) => ({
194397
- text: line4,
194398
- y: blockTop + lineHeight / 2 + index * lineHeight
194399
- }));
194400
- }
194401
- var PALETTES = {
194402
- colorful1: ["#3b82f6", "#22c55e", "#f97316", "#eab308", "#a855f7", "#ec4899"],
194403
- colorful2: ["#6366f1", "#14b8a6", "#f59e0b", "#ef4444", "#8b5cf6", "#06b6d4"],
194404
- colorful3: ["#0ea5e9", "#84cc16", "#f43e5e", "#a855f7", "#f97316", "#10b981"],
194405
- monochromatic1: ["#3b82f6", "#60a5fa", "#93c5fd", "#bfdbfe", "#2563eb", "#1d4ed8"],
194406
- monochromatic2: ["#6366f1", "#818cf8", "#a5b4fc", "#c7d2fe", "#4f46e5", "#4338ca"]
194407
- };
194408
- var DEFAULT_PALETTE2 = PALETTES.colorful1;
194409
- function paletteColour(index, palette) {
194410
- return palette[index % palette.length];
194411
- }
194412
- function resolvePalette(data) {
194413
- if (!data) {
194414
- return DEFAULT_PALETTE2;
194415
- }
194416
- const ctFills = data.colorTransform?.fillColors;
194417
- if (ctFills && ctFills.length > 0) {
194418
- return ctFills;
194419
- }
194420
- return PALETTES[data.colorScheme ?? "colorful1"] ?? DEFAULT_PALETTE2;
194421
- }
194422
- function buildChromeStyle(chrome) {
194423
- const s = {
194424
- width: "100%",
194425
- height: "100%",
194426
- "box-sizing": "border-box",
194427
- overflow: "hidden"
194428
- };
194429
- if (!chrome) {
194430
- return s;
194431
- }
194432
- if (chrome.backgroundColor) {
194433
- s["background-color"] = chrome.backgroundColor;
194434
- }
194435
- if (chrome.outlineColor) {
194436
- s["border"] = `${chrome.outlineWidth ?? 1}px solid ${chrome.outlineColor}`;
194437
- }
194438
- return s;
194439
- }
194440
- var TEXT_WIDTH_FRACTION = 0.82;
194441
- var CJK_SMARTART_TEXT_RE = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
194442
- var CJK_SMARTART_LINE_HEIGHT_RATIO = 1.33;
194443
- var DEFAULT_SMARTART_LINE_HEIGHT_RATIO = 1.2;
194444
- function drawingTextBaseLineHeightRatio(text22) {
194445
- return CJK_SMARTART_TEXT_RE.test(text22 ?? "") ? CJK_SMARTART_LINE_HEIGHT_RATIO : DEFAULT_SMARTART_LINE_HEIGHT_RATIO;
194446
- }
194447
- function underlyingFill(shape, shapes, index) {
194448
- const centerX = shape.x + shape.width / 2;
194449
- const centerY = shape.y + shape.height / 2;
194450
- for (let below = index - 1; below >= 0; below--) {
194451
- const candidate = shapes[below];
194452
- if (!candidate || candidate.fillNone || !candidate.fillColor) {
194453
- continue;
194454
- }
194455
- if (centerX >= candidate.x && centerX <= candidate.x + candidate.width && centerY >= candidate.y && centerY <= candidate.y + candidate.height) {
194456
- return candidate.fillColor;
194457
- }
194458
- }
194459
- return void 0;
194460
- }
194461
- function drawingShapeLabelColor(shape, shapes, index, resolvedFill) {
194462
- const basis = resolvedFill === "none" || resolvedFill.startsWith("url(") ? underlyingFill(shape, shapes, index) : resolvedFill;
194463
- return basis ? contrastTextColor(basis) : "#1a1a1a";
194464
- }
194465
- function computeDrawingViewBox(shapes) {
194466
- let minX = Infinity;
194467
- let minY = Infinity;
194468
- let maxX = -Infinity;
194469
- let maxY = -Infinity;
194470
- for (const s of shapes) {
194471
- const shapeMinX = Math.min(s.x, s.textFrameX ?? s.x);
194472
- const shapeMinY = Math.min(s.y, s.textFrameY ?? s.y);
194473
- const shapeMaxX = Math.max(
194474
- s.x + s.width,
194475
- (s.textFrameX ?? s.x) + (s.textFrameWidth ?? s.width)
194476
- );
194477
- const shapeMaxY = Math.max(
194478
- s.y + s.height,
194479
- (s.textFrameY ?? s.y) + (s.textFrameHeight ?? s.height)
194480
- );
194481
- if (shapeMinX < minX) {
194482
- minX = shapeMinX;
194483
- }
194484
- if (shapeMinY < minY) {
194485
- minY = shapeMinY;
194486
- }
194487
- if (shapeMaxX > maxX) {
194488
- maxX = shapeMaxX;
194489
- }
194490
- if (shapeMaxY > maxY) {
194491
- maxY = shapeMaxY;
194492
- }
194493
- }
194494
- if (!Number.isFinite(minX)) {
194495
- return { minX: 0, minY: 0, width: 1, height: 1 };
194496
- }
194497
- return {
194498
- minX,
194499
- minY,
194500
- width: maxX - minX || 1,
194501
- height: maxY - minY || 1
194502
- };
194503
- }
194504
- function resolveGradient(shape, id) {
194505
- const stops = shape.fillGradientStops;
194506
- if (!stops || stops.length === 0) {
194507
- return void 0;
194508
- }
194509
- const mapped = stops.map((stop) => ({
194510
- offset: `${Math.max(0, Math.min(100, stop.position))}%`,
194511
- color: stop.color,
194512
- ...stop.opacity !== void 0 ? { opacity: stop.opacity } : {}
194513
- }));
194514
- if (shape.fillGradientType === "radial") {
194515
- return { id, kind: "radial", cx: "50%", cy: "50%", r: "50%", stops: mapped };
194516
- }
194517
- const radians = (shape.fillGradientAngle ?? 0) * Math.PI / 180;
194518
- const dx = Math.cos(radians) / 2;
194519
- const dy = Math.sin(radians) / 2;
194520
- return {
194521
- id,
194522
- kind: "linear",
194523
- x1: `${(0.5 - dx) * 100}%`,
194524
- y1: `${(0.5 - dy) * 100}%`,
194525
- x2: `${(0.5 + dx) * 100}%`,
194526
- y2: `${(0.5 + dy) * 100}%`,
194527
- stops: mapped
194528
- };
194529
- }
194530
- function resolveShapeKind(shape, hasImage) {
194531
- if (hasImage) {
194532
- return "image";
194533
- }
194534
- const normalized = (shape.shapeType ?? "").trim().toLowerCase();
194535
- if (normalized === "ellipse" || normalized === "oval") {
194536
- return "ellipse";
194537
- }
194538
- const identityPresets = /* @__PURE__ */ new Set(["rect", "flowchartprocess", "roundrect"]);
194539
- return identityPresets.has(normalized) || normalized.length === 0 ? "rect" : "path";
194540
- }
194541
- function drawingShapeTransform(shape, cx, cy) {
194542
- const transforms = [];
194543
- if (shape.rotation) {
194544
- transforms.push(`rotate(${shape.rotation} ${cx} ${cy})`);
194545
- }
194546
- if (shape.flipHorizontal || shape.flipVertical) {
194547
- transforms.push(
194548
- `translate(${cx} ${cy}) scale(${shape.flipHorizontal ? -1 : 1} ${shape.flipVertical ? -1 : 1}) translate(${-cx} ${-cy})`
194549
- );
194550
- }
194551
- return transforms.length > 0 ? transforms.join(" ") : void 0;
194552
- }
194553
- function projectDrawingShapes(elementId, shapes, viewBox, palette, style) {
194554
- const { minX, minY } = viewBox;
194555
- const sw = styleStroke(style);
194556
- return shapes.map((shape, i2) => {
194557
- const gradient = shape.fillNone ? void 0 : resolveGradient(shape, `${elementId}-dspgrad-${shape.id}-${i2}`);
194558
- const fill = shape.fillNone ? "none" : gradient ? `url(#${gradient.id})` : shape.fillPatternForegroundColor ?? shape.fillColor ?? paletteColour(i2, palette);
194559
- const relX = shape.x - minX;
194560
- const relY = shape.y - minY;
194561
- const kind = resolveShapeKind(shape, Boolean(shape.fillImageUrl));
194562
- const rx = getShapeType(shape.shapeType) === "roundRect" ? Math.min(shape.width, shape.height) * 0.1 : 0;
194563
- const cx = relX + shape.width / 2;
194564
- const cy = relY + shape.height / 2;
194565
- const stroke = shape.strokeColor ?? (sw > 0 ? "rgba(255,255,255,0.3)" : "none");
194566
- const transform6 = drawingShapeTransform(shape, cx, cy);
194567
- const presetGeometry = kind === "path" ? getPresetShapeVectorGeometry(
194568
- shape.shapeType,
194569
- shape.width,
194570
- shape.height,
194571
- shape.shapeAdjustments
194572
- ) : void 0;
194573
- const fontSize = shape.fontSize ?? Math.max(8, Math.min(14, shape.height * 0.2));
194574
- const hasTextFrame = Number.isFinite(shape.textFrameX) && Number.isFinite(shape.textFrameY) && Number.isFinite(shape.textFrameWidth) && Number.isFinite(shape.textFrameHeight) && (shape.textFrameWidth ?? 0) > 0 && (shape.textFrameHeight ?? 0) > 0;
194575
- const textFrameX = (hasTextFrame ? shape.textFrameX : shape.x) - minX;
194576
- const textFrameY = (hasTextFrame ? shape.textFrameY : shape.y) - minY;
194577
- const textFrameWidth = hasTextFrame ? shape.textFrameWidth : shape.width;
194578
- const textFrameHeight = hasTextFrame ? shape.textFrameHeight : shape.height;
194579
- const textInsetLeft = shape.textInsetLeft ?? 0;
194580
- const textInsetRight = shape.textInsetRight ?? 0;
194581
- const textInsetTop = shape.textInsetTop ?? 0;
194582
- const textInsetBottom = shape.textInsetBottom ?? 0;
194583
- const textContentWidth = Math.max(1, textFrameWidth - textInsetLeft - textInsetRight);
194584
- const textContentHeight = Math.max(1, textFrameHeight - textInsetTop - textInsetBottom);
194585
- const textCenterX = textFrameX + textInsetLeft + textContentWidth / 2;
194586
- const textCenterY = textFrameY + textInsetTop + textContentHeight / 2;
194587
- const textWrapWidth = hasTextFrame ? textContentWidth : shape.width * TEXT_WIDTH_FRACTION;
194588
- const authoredLineHeightRatio = shape.lineHeightRatio ?? 1;
194589
- const lineHeightRatio = drawingTextBaseLineHeightRatio(shape.text) * authoredLineHeightRatio + (shape.lineSpacingAfterRatio ?? 0);
194590
- const lineHeight = shape.lineHeight !== void 0 || shape.lineSpacingAfter !== void 0 ? (shape.lineHeight ?? fontSize * drawingTextBaseLineHeightRatio(shape.text) * authoredLineHeightRatio) + (shape.lineSpacingAfter ?? 0) : void 0;
194591
- return {
194592
- key: `${elementId}-dsp-${shape.id}-${i2}`,
194593
- kind,
194594
- ...presetGeometry ? {
194595
- pathData: presetGeometry.d,
194596
- pathTransform: [transform6, `translate(${relX} ${relY})`].filter(Boolean).join(" ")
194597
- } : {},
194598
- ...gradient ? { gradient } : {},
194599
- x: relX,
194600
- y: relY,
194601
- width: shape.width,
194602
- height: shape.height,
194603
- rx,
194604
- cx,
194605
- cy,
194606
- fill,
194607
- stroke,
194608
- strokeWidth: shape.strokeWidth ?? sw,
194609
- transform: transform6,
194610
- imageUrl: shape.fillImageUrl,
194611
- textLines: shape.text ? centeredSvgTextLines(shape.text, fontSize, {
194612
- maxWidth: textWrapWidth,
194613
- centerY: textCenterY,
194614
- lineHeight,
194615
- lineHeightRatio
194616
- }) : [],
194617
- textX: textCenterX,
194618
- textY: textCenterY,
194619
- textWidth: textContentWidth,
194620
- textHeight: textContentHeight,
194621
- fontColor: shape.fontColor ?? drawingShapeLabelColor(shape, shapes, i2, fill),
194622
- fontSize,
194623
- fontFamily: shape.fontFamily ? getSubstituteFontFamily(shape.fontFamily) : void 0,
194624
- fontWeight: shape.fontWeight,
194625
- fontStyle: shape.fontStyle
194626
- };
194627
- });
194628
- }
194629
- function styleShadowFilter(style) {
194630
- return styleShadow(style);
194631
- }
194632
196308
  function collectFontsFromElement(element, fonts) {
194633
196309
  if (hasTextProperties(element)) {
194634
196310
  if (element.textStyle?.fontFamily) {
@@ -201574,13 +203250,14 @@ var COMPAT_TOAST_METRICS = {
201574
203250
  /** Stacking order: above the canvas and inspector, below dialogs. */
201575
203251
  zIndex: 40
201576
203252
  };
201577
- function compatToastStackStyle() {
203253
+ function compatToastStackStyle(extraRightInset = 0, extraBottomInset = 0) {
201578
203254
  const m = COMPAT_TOAST_METRICS;
201579
203255
  return {
201580
203256
  position: "absolute",
201581
- right: `${String(m.insetRight)}px`,
201582
- bottom: `${String(STATUS_BAR_METRICS.height + m.marginAboveStatusBar)}px`,
203257
+ right: `${String(m.insetRight + extraRightInset)}px`,
203258
+ bottom: `${String(STATUS_BAR_METRICS.height + m.marginAboveStatusBar + extraBottomInset)}px`,
201583
203259
  width: `${String(m.width)}px`,
203260
+ maxWidth: `calc(100% - ${String(m.insetRight + extraRightInset)}px)`,
201584
203261
  zIndex: String(m.zIndex),
201585
203262
  display: "flex",
201586
203263
  flexDirection: "column",
@@ -201791,8 +203468,20 @@ function filterCommands(query, resolveLabel) {
201791
203468
  (entry2) => resolveLabel(entry2.labelKey).toLowerCase().includes(lowerQuery)
201792
203469
  );
201793
203470
  }
203471
+ var sourceIdentities = /* @__PURE__ */ new WeakMap();
203472
+ function sourceIdentity(source) {
203473
+ if ((typeof source !== "object" || source === null) && typeof source !== "function") {
203474
+ return source;
203475
+ }
203476
+ let identity = sourceIdentities.get(source);
203477
+ if (!identity) {
203478
+ identity = {};
203479
+ sourceIdentities.set(source, identity);
203480
+ }
203481
+ return identity;
203482
+ }
201794
203483
  function autosaveSnapshotMark(filePath, sources) {
201795
- return { filePath, sources: [...sources] };
203484
+ return { filePath, sources: sources.map(sourceIdentity) };
201796
203485
  }
201797
203486
  function shouldWriteAutosaveSnapshot(input) {
201798
203487
  if (!input.filePath || !input.isDirty || input.saving) {
@@ -201805,7 +203494,9 @@ function shouldWriteAutosaveSnapshot(input) {
201805
203494
  if (input.sources.length === 0 || previous.sources.length !== input.sources.length) {
201806
203495
  return true;
201807
203496
  }
201808
- return input.sources.some((source, index) => !Object.is(source, previous.sources[index]));
203497
+ return input.sources.some(
203498
+ (source, index) => !Object.is(sourceIdentity(source), previous.sources[index])
203499
+ );
201809
203500
  }
201810
203501
  function resolveAutosaveActivation(input) {
201811
203502
  if (input.hostAutosave === false) {
@@ -201940,8 +203631,8 @@ async function listBackstageRecentFiles(translate, limit) {
201940
203631
  return [];
201941
203632
  }
201942
203633
  try {
201943
- const snapshots = await listAutosaveSnapshots();
201944
- const sorted = snapshots.map((snapshot) => ({ ...snapshot, ...splitFilePath(snapshot.key, translate) })).sort((a, b) => b.timestamp - a.timestamp);
203634
+ const snapshots2 = await listAutosaveSnapshots();
203635
+ const sorted = snapshots2.map((snapshot) => ({ ...snapshot, ...splitFilePath(snapshot.key, translate) })).sort((a, b) => b.timestamp - a.timestamp);
201945
203636
  return limit === void 0 ? sorted : sorted.slice(0, Math.max(0, limit));
201946
203637
  } catch {
201947
203638
  return [];
@@ -202814,15 +204505,15 @@ function resolveProfileInitial(profile) {
202814
204505
  return trimmed ? trimmed.slice(0, 1).toUpperCase() : "?";
202815
204506
  }
202816
204507
  async function getLocalStorageUsageSummary() {
202817
- const snapshots = await listAutosaveSnapshots();
204508
+ const snapshots2 = await listAutosaveSnapshots();
202818
204509
  return {
202819
- presentationCount: snapshots.length,
202820
- totalBytes: snapshots.reduce((sum, snapshot) => sum + snapshot.size, 0)
204510
+ presentationCount: snapshots2.length,
204511
+ totalBytes: snapshots2.reduce((sum, snapshot) => sum + snapshot.size, 0)
202821
204512
  };
202822
204513
  }
202823
204514
  async function clearAllLocalViewerData() {
202824
- const snapshots = await listAutosaveSnapshots();
202825
- await Promise.all(snapshots.map((snapshot) => deleteAutosaveSnapshot(snapshot.key)));
204515
+ const snapshots2 = await listAutosaveSnapshots();
204516
+ await Promise.all(snapshots2.map((snapshot) => deleteAutosaveSnapshot(snapshot.key)));
202826
204517
  clearStoredViewerPrefs();
202827
204518
  }
202828
204519
  function saveViewerProfile(profile) {
@@ -203341,13 +205032,13 @@ function shouldDiscardAutosaveOnSuccessfulSave(options) {
203341
205032
  function shouldClearAutosaveCacheOnClose(options) {
203342
205033
  return options.save.clearCacheOnClose;
203343
205034
  }
203344
- function resolveExpiredAutosaveSnapshots(snapshots, options, now = Date.now()) {
205035
+ function resolveExpiredAutosaveSnapshots(snapshots2, options, now = Date.now()) {
203345
205036
  const days = options.save.cacheRetentionDays;
203346
205037
  if (!Number.isFinite(days) || days <= 0) {
203347
205038
  return [];
203348
205039
  }
203349
205040
  const maxAgeMs = days * 24 * 60 * 60 * 1e3;
203350
- return snapshots.filter((snapshot) => now - snapshot.timestamp > maxAgeMs).map((s) => s.key);
205041
+ return snapshots2.filter((snapshot) => now - snapshot.timestamp > maxAgeMs).map((s) => s.key);
203351
205042
  }
203352
205043
  function playFeedbackSound(options) {
203353
205044
  if (!options.accessibility.feedbackWithSound || typeof window === "undefined") {
@@ -205461,22 +207152,6 @@ function calculateViewportFit(input, defaults = DEFAULTS2) {
205461
207152
  availableHeight
205462
207153
  };
205463
207154
  }
205464
- function inlineListBodyText(segments) {
205465
- let first = true;
205466
- let text22 = "";
205467
- for (const segment of segments ?? []) {
205468
- if (isParagraphSeparatorSegment(segment)) {
205469
- text22 += "\n";
205470
- first = true;
205471
- } else {
205472
- if (!first || !isBulletMarkerSegment(segment)) {
205473
- text22 += segment.isLineBreak ? "\n" : segment.text;
205474
- }
205475
- first = false;
205476
- }
205477
- }
205478
- return text22;
205479
- }
205480
207155
  function readListActivationSelection(root, body) {
205481
207156
  if (readEditableText(root) !== body) {
205482
207157
  return void 0;
@@ -208368,6 +210043,7 @@ exports.applyTransitionSoundFile = applyTransitionSoundFile;
208368
210043
  exports.applyTransitionStockSound = applyTransitionStockSound;
208369
210044
  exports.applyUnderlineVariant = applyUnderlineVariant;
208370
210045
  exports.assertElementUpdateTarget = assertElementUpdateTarget;
210046
+ exports.attachCollaborationInlineEditor = attachCollaborationInlineEditor;
208371
210047
  exports.attachEditorImagePaste = attachEditorImagePaste;
208372
210048
  exports.attachInlineListController = attachInlineListController;
208373
210049
  exports.attachPresentationVisibilityPause = attachPresentationVisibilityPause;
@@ -208579,6 +210255,7 @@ exports.createPresentationSessionId = createPresentationSessionId;
208579
210255
  exports.createPresenterShowGuard = createPresenterShowGuard;
208580
210256
  exports.createPresenterTimer = createPresenterTimer;
208581
210257
  exports.createRotationDrag = createRotationDrag;
210258
+ exports.createSnapshotTextPositions = createSnapshotTextPositions;
208582
210259
  exports.createSyncGate = createSyncGate;
208583
210260
  exports.createTableStyleEntry = createTableStyleEntry;
208584
210261
  exports.createTouchGestureRecognizer = createTouchGestureRecognizer;
@@ -208598,6 +210275,7 @@ exports.deleteTagFromCollections = deleteTagFromCollections;
208598
210275
  exports.demote = demote;
208599
210276
  exports.deriveSlideFieldContext = deriveSlideFieldContext;
208600
210277
  exports.deriveViewportBreakpoints = deriveViewportBreakpoints;
210278
+ exports.describeCollaborationShellState = describeCollaborationShellState;
208601
210279
  exports.describeFontEmbedding = describeFontEmbedding;
208602
210280
  exports.describeSmartArtBounds = describeSmartArtBounds;
208603
210281
  exports.describeTableStyleEditor = describeTableStyleEditor;
@@ -208864,6 +210542,7 @@ exports.normalizeHexColor = normalizeHexColor2;
208864
210542
  exports.normalizeStrokeDashType = normalizeStrokeDashType;
208865
210543
  exports.normalizeTableStyleGuid = normalizeTableStyleGuid;
208866
210544
  exports.notesSegmentsToSpans = notesSegmentsToSpans;
210545
+ exports.observeElementHeight = observeElementHeight;
208867
210546
  exports.observeExternalCollaborationReadiness = observeExternalCollaborationReadiness;
208868
210547
  exports.observeExternalCollaborationSession = observeExternalCollaborationSession;
208869
210548
  exports.observeYDocSlides = observeYDocSlides;
@@ -208976,6 +210655,8 @@ exports.resolveAutosaveActivation = resolveAutosaveActivation;
208976
210655
  exports.resolveAutosaveIntervalMs = resolveAutosaveIntervalMs;
208977
210656
  exports.resolveAutosaveIntervalSeconds = resolveAutosaveIntervalSeconds;
208978
210657
  exports.resolveChartKind = resolveChartKind;
210658
+ exports.resolveCollaborationShellEditability = resolveCollaborationShellEditability;
210659
+ exports.resolveCollaborationShellState = resolveCollaborationShellState;
208979
210660
  exports.resolveConnectorEndpointUpdate = resolveConnectorEndpointUpdate;
208980
210661
  exports.resolveDefaultFontFamily = resolveDefaultFontFamily;
208981
210662
  exports.resolveDefaultPrintSettings = resolveDefaultPrintSettings;
@@ -209018,6 +210699,7 @@ exports.resolveShapeGeometry = resolveShapeGeometry;
209018
210699
  exports.resolveShowSlideIndexes = resolveShowSlideIndexes;
209019
210700
  exports.resolveSlideSizeSelection = resolveSlideSizeSelection;
209020
210701
  exports.resolveSlideTransition = resolveSlideTransition;
210702
+ exports.resolveSmartArt3DLayout = resolveSmartArt3DLayout;
209021
210703
  exports.resolveTableCellImageUrls = resolveTableCellImageUrls;
209022
210704
  exports.resolveTableStyleImageUrls = resolveTableStyleImageUrls;
209023
210705
  exports.resolveTemplateBackgroundRows = resolveTemplateBackgroundRows;