@datalking/begonia-browser-sdk 0.2.0 → 0.3.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 (55) hide show
  1. package/dist/browser-command-table-state.d.ts +5 -0
  2. package/dist/browser-command-types.d.ts +3 -1
  3. package/dist/browser-comment-range-point.d.ts +56 -0
  4. package/dist/browser-editor-comments-controller.d.ts +2 -1
  5. package/dist/browser-editor-context-menu-open-at.d.ts +15 -0
  6. package/dist/browser-editor-contracts.d.ts +6 -0
  7. package/dist/browser-editor-domain-types.d.ts +48 -1
  8. package/dist/browser-editor-host.d.ts +0 -2
  9. package/dist/browser-editor-selection-geometry.d.ts +135 -1
  10. package/dist/browser-editor-types-controller.d.ts +46 -1
  11. package/dist/browser-editor-types-shared.d.ts +17 -0
  12. package/dist/browser-editor-viewport/browser-editor-viewport-bounds.d.ts +1 -1
  13. package/dist/browser-editor-viewport-session-state-types.d.ts +15 -0
  14. package/dist/browser-history-shortcut.d.ts +31 -0
  15. package/dist/browser-image-command-types.d.ts +28 -0
  16. package/dist/browser-insert-command-types.d.ts +5 -0
  17. package/dist/browser-page-review-target.d.ts +44 -0
  18. package/dist/browser-paginated-preview-editor-binding.d.ts +76 -1
  19. package/dist/browser-paginated-preview-key-selection.d.ts +48 -0
  20. package/dist/browser-paginated-preview-position-hit.d.ts +28 -0
  21. package/dist/browser-table-target-resolution.d.ts +59 -0
  22. package/dist/command.js +5 -5
  23. package/dist/editor.d.ts +8 -0
  24. package/dist/editor.js +5 -4
  25. package/dist/header-footer/header-footer-band-geometry.d.ts +70 -0
  26. package/dist/header-footer/header-footer-band-press.d.ts +51 -0
  27. package/dist/header-footer/header-footer-edit-state.d.ts +44 -0
  28. package/dist/header-footer/header-footer-edit-target.d.ts +54 -0
  29. package/dist/header-footer/header-footer-editing-controller.d.ts +133 -0
  30. package/dist/header-footer/header-footer-exit-press.d.ts +54 -0
  31. package/dist/header-footer/header-footer-slot.d.ts +38 -0
  32. package/dist/header-footer/header-footer-story-blocks.d.ts +71 -0
  33. package/dist/header-footer/section-header-footer-links.d.ts +60 -0
  34. package/dist/header-footer/section-header-footer-variants.d.ts +55 -0
  35. package/dist/index.d.ts +31 -0
  36. package/dist/index.js +60 -5
  37. package/dist/ooxml.js +4 -4
  38. package/dist/paginated-editing/index.d.ts +7 -0
  39. package/dist/paginated-editing/paginated-caret-reveal.d.ts +51 -0
  40. package/dist/paginated-editing/paginated-column-keyboard.d.ts +50 -0
  41. package/dist/paginated-editing/paginated-editing-session.d.ts +8 -0
  42. package/dist/paginated-editing/paginated-editing-types.d.ts +169 -0
  43. package/dist/paginated-editing/paginated-ime-caret-measure.d.ts +26 -0
  44. package/dist/paginated-editing/paginated-input-anchor.d.ts +116 -0
  45. package/dist/paginated-editing/paginated-input-bridge.d.ts +169 -0
  46. package/dist/paginated-editing/paginated-table-boundary-keyboard.d.ts +24 -0
  47. package/dist/paginated-editing/paginated-table-boundary-keys.d.ts +33 -0
  48. package/dist/paginated-preview-selection-table/preview-selection-table-exit.d.ts +61 -0
  49. package/dist/paginated-preview-selection-table/preview-selection-table-resolve.d.ts +7 -2
  50. package/dist/preview.js +1 -1
  51. package/dist/theme/theme-tokens.d.ts +35 -1
  52. package/dist/theme.js +1 -1
  53. package/dist/v1.d.ts +6 -0
  54. package/dist/v1.js +9 -9
  55. package/package.json +14 -14
package/dist/ooxml.js CHANGED
@@ -1,4 +1,4 @@
1
- import{isDocumentNodePathIndex as ir}from"@datalking/begonia-document-model";import{DELETION_MARK_NAME as lr}from"@datalking/begonia-engine";import{NodeSelection as ar}from"prosemirror-state";function at(e){return e instanceof ar||typeof e=="object"&&e!=null&&"node"in e&&e.node!=null&&"from"in e&&typeof e.from=="number"&&"to"in e&&typeof e.to=="number"&&"$from"in e&&e.$from!=null}function it(e){return e?e.surface??null:null}function st(e){return e==="ooxml_math"||e==="ooxml_chart"||e==="ooxml_shape"||e==="inline_ooxml_drawing"}function dt(e,t){let r=[];for(let o=0;o<t;o+=1)r.push(e.$from.index(o));return r}function cr(e){if(!at(e)||!st(e.node.type.name))return null;let t=dt(e,e.$from.depth);return t.push(e.$from.index(e.$from.depth)),t}function sr(e,t){let r=e;for(let o of t){if(!ir(o)||o>=r.childCount)return null;r=r.child(o)}return r}function lt(e,t){let r=sr(e.doc,t);return!!(r&&st(r.type.name)&&r.marks.some(o=>o.type.name===lr))}function Oe(e){let{selection:t}=e.state;for(let r=t.$from.depth;r>0;r-=1)if(t.$from.node(r).isTextblock)return dt(t,r);return null}function ae(e,t){let r=t.blocks.topLevel(),o=e.state.selection.from,n=r.find(c=>o>=c.from&&o<=c.from+c.nodeSize);return n?n.index+1:r.length}function x(){return{source:"browser-ooxml"}}function ct(e,t){let r=cr(e.selection);if(!r)return null;let o=t.ooxml.get(r);if(!o)return null;let n=lt(e,o.path),c=t.ooxml.getById(o.objectId);if(!c)return n?null:o;let d=lt(e,c.path);return n?d?null:c:d?o:c}function he(e,t){if(t)return ct(e.state,t);let r=e,o=it(r);return o?ct(o.state,r.documentApi):null}function S(e,t,r){let o=he(e,t);return o?.family===r?o:null}function b(e){return{changed:!1,reason:`No advanced OOXML ${e} node is selected.`}}function dr(e,t,r){let o=he(e,t);return o?e.trackingEnabled?t.ooxml.updateTracked(o.path,r,e.participant,x()):t.ooxml.update(o.path,r):{changed:!1,reason:"No advanced OOXML node is selected."}}function pr(e,t){let r=he(e,t);return r?e.trackingEnabled?t.ooxml.removeTracked(r.path,e.participant,x()):t.ooxml.remove(r.path):{changed:!1,reason:"No advanced OOXML node is selected."}}function ur(e,t,r,o={}){let n=Oe(e);return n?t.ooxml.math.appendInline(n,r,o):{changed:!1,reason:"Advanced OOXML math insertion requires an active text block selection."}}function mr(e,t,r,o={},n={}){let c=Oe(e);return c?t.ooxml.math.appendInlineTracked(c,r,e.participant,o,n):{changed:!1,reason:"Tracked math insertion requires an active text block selection."}}function hr(e,t,r){let o=S(e,t,"math");return o?e.trackingEnabled?t.ooxml.math.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.math.replaceModelById(o.objectId,r):b("math")}function fr(e,t,r,o){let n=S(e,t,"math");return n?e.trackingEnabled?t.ooxml.math.setPlainTextByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.math.setPlainTextById(n.objectId,r,o):b("math")}function xr(e,t,r){let o=S(e,t,"math");return o?e.trackingEnabled?t.ooxml.math.setDisplayModeByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.math.setDisplayModeById(o.objectId,r):b("math")}function yr(e,t,r,o={}){return t.ooxml.charts.insertBlock(ae(e,t),r,o)}function Sr(e,t,r,o={},n={}){return t.ooxml.charts.insertBlockTracked(ae(e,t),r,e.participant,o,n)}function br(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.replaceModelById(o.objectId,r):b("chart")}function gr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setMetadataByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setMetadataById(o.objectId,r):b("chart")}function Ar(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setTitleByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setTitleById(o.objectId,r):b("chart")}function wr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setTextBodyByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setTextBodyById(o.objectId,r):b("chart")}function vr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.appendSeriesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.appendSeriesById(o.objectId,r):b("chart")}function Er(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setSeriesListByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setSeriesListById(o.objectId,r):b("chart")}function Br(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.setSeriesByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.charts.setSeriesById(n.objectId,r,o):b("chart")}function Cr(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.upsertSeriesByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.charts.upsertSeriesById(n.objectId,r,o):b("chart")}function Or(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.removeSeriesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.removeSeriesById(o.objectId,r):b("chart")}function Ir(e,t,r){return pt(e,t,r)}function Mr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setAxesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setAxesById(o.objectId,r):b("chart")}function pt(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.upsertAxisByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.charts.upsertAxisById(n.objectId,r,o):b("chart")}function kr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.removeAxisByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.removeAxisById(o.objectId,r):b("chart")}function Dr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setLegendByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setLegendById(o.objectId,r):b("chart")}function Tr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setPlotAreaByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setPlotAreaById(o.objectId,r):b("chart")}function Nr(e,t,r,o={}){return t.ooxml.shapes.insertBlock(ae(e,t),r,o)}function jr(e,t,r,o={},n={}){return t.ooxml.shapes.insertBlockTracked(ae(e,t),r,e.participant,o,n)}function Pr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.replaceModelById(o.objectId,r):b("shape")}function Rr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setMetadataByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setMetadataById(o.objectId,r):b("shape")}function Vr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setWatermarkByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setWatermarkById(o.objectId,r):b("shape")}function Lr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setTextBodyByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setTextBodyById(o.objectId,r):b("shape")}function Fr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setGeometryByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setGeometryById(o.objectId,r):b("shape")}function Hr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setTransformByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setTransformById(o.objectId,r):b("shape")}function Ur(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setFillByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setFillById(o.objectId,r):b("shape")}function zr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setStrokeByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setStrokeById(o.objectId,r):b("shape")}function Wr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setAnchorByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setAnchorById(o.objectId,r):b("shape")}function Kr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setConnectorByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setConnectorById(o.objectId,r):b("shape")}function Gr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setPictureByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setPictureById(o.objectId,r):b("shape")}function qr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setWordArtByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setWordArtById(o.objectId,r):b("shape")}function Jr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setChildrenByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setChildrenById(o.objectId,r):b("shape")}function $r(e,t,r,o){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.setChildByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.shapes.setChildById(n.objectId,r,o):b("shape")}function Xr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.appendChildByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.appendChildById(o.objectId,r):b("shape")}function Yr(e,t,r,o){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.appendChildToParentByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.shapes.appendChildToParentById(n.objectId,r,o):b("shape")}function _r(e,t,r,o={}){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.moveChildByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.shapes.moveChildById(n.objectId,r,o):b("shape")}function Zr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.removeChildByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.removeChildById(o.objectId,r):b("shape")}var xe="ald:advanced-ooxml-nodeview-action";function re(e){return typeof e=="object"&&e!==null}function ut(e){if(!re(e)||typeof e.family!="string"||typeof e.action!="string"||typeof e.objectId!="string")return!1;switch(e.action){case"replace-math-model":return e.family==="math"&&re(e.model);case"set-math-plain-text":return e.family==="math"&&typeof e.text=="string"&&(e.displayMode==="inline"||e.displayMode==="block");case"replace-chart-model":return e.family==="chart"&&re(e.model);case"replace-shape-model":return e.family==="shape"&&re(e.model);case"apply-math-edits":return e.family==="math"&&re(e.model)&&Array.isArray(e.edits);case"apply-chart-edits":return e.family==="chart"&&re(e.model)&&Array.isArray(e.edits);case"apply-shape-edits":return e.family==="shape"&&re(e.model)&&Array.isArray(e.edits);case"remove-advanced-ooxml":return e.family==="math"||e.family==="chart"||e.family==="shape";default:return!1}}function $(e,t){e.dispatchEvent(new CustomEvent(xe,{bubbles:!0,cancelable:!0,detail:t}))}import{readSyntheticSideStoryDocOriginPath as Qr}from"@datalking/begonia-doc-service/v1";var eo="Detached side-story surfaces are read-only. Route mutations through the host document controller.";function to(e){return Qr(e?.document??null)!=null}function ro(e){return e?to(e)?eo:e.editable?null:"Document is read-only in the current document mode.":"Editor is not ready."}function mt(e){return ro(e)==null}function ht(e,t){return{surface:e,documentApi:t,context:{source:"browser-ooxml-nodeview"},runMutation(o,n){if(mt(e)){if(e.trackingEnabled){o();return}n()}}}}function ie(e,t){e.runMutation(()=>{e.documentApi.ooxml.removeByIdTracked(t,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.removeById(t)})}function Ie(e,t){switch(t.action){case"replace-chart-model":e.runMutation(()=>{e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.replaceModelById(t.objectId,t.model)});return;case"apply-chart-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-metadata":e.runMutation(()=>{e.documentApi.ooxml.charts.setMetadataByIdTracked(t.objectId,r,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setMetadataById(t.objectId,r)});return;case"set-text-body":e.runMutation(()=>{e.documentApi.ooxml.charts.setTextBodyByIdTracked(t.objectId,r.textBody,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setTextBodyById(t.objectId,r.textBody)});return;case"set-plot-area":e.runMutation(()=>{e.documentApi.ooxml.charts.setPlotAreaByIdTracked(t.objectId,r.plotArea,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setPlotAreaById(t.objectId,r.plotArea)});return;case"set-legend":e.runMutation(()=>{e.documentApi.ooxml.charts.setLegendByIdTracked(t.objectId,r.legend,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setLegendById(t.objectId,r.legend)});return;case"set-series":e.runMutation(()=>{e.documentApi.ooxml.charts.setSeriesByIdTracked(t.objectId,r.target,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setSeriesById(t.objectId,r.target,r.series)});return;case"set-series-list":e.runMutation(()=>{e.documentApi.ooxml.charts.setSeriesListByIdTracked(t.objectId,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setSeriesListById(t.objectId,r.series)});return;case"upsert-series":e.runMutation(()=>{e.documentApi.ooxml.charts.upsertSeriesByIdTracked(t.objectId,r.series,e.surface.participant,e.context,r.seriesId)},()=>{e.documentApi.ooxml.charts.upsertSeriesById(t.objectId,r.series,r.seriesId)});return;case"append-series":e.runMutation(()=>{e.documentApi.ooxml.charts.appendSeriesByIdTracked(t.objectId,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.appendSeriesById(t.objectId,r.series)});return;case"remove-series":e.runMutation(()=>{e.documentApi.ooxml.charts.removeSeriesByIdTracked(t.objectId,r.target,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.removeSeriesById(t.objectId,r.target)});return;case"set-axes":e.runMutation(()=>{e.documentApi.ooxml.charts.setAxesByIdTracked(t.objectId,r.axes,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setAxesById(t.objectId,r.axes)});return;case"upsert-axis":e.runMutation(()=>{e.documentApi.ooxml.charts.upsertAxisByIdTracked(t.objectId,r.axis,e.surface.participant,e.context,r.axisId)},()=>{e.documentApi.ooxml.charts.upsertAxisById(t.objectId,r.axis,r.axisId)});return;case"remove-axis":e.runMutation(()=>{e.documentApi.ooxml.charts.removeAxisByIdTracked(t.objectId,r.axisId,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.removeAxisById(t.objectId,r.axisId)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":ie(e,t.objectId);return}}function Me(e,t){switch(t.action){case"replace-math-model":e.runMutation(()=>{e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.replaceModelById(t.objectId,t.model)});return;case"set-math-plain-text":e.runMutation(()=>{e.documentApi.ooxml.math.setPlainTextByIdTracked(t.objectId,t.text,e.surface.participant,e.context,t.displayMode)},()=>{e.documentApi.ooxml.math.setPlainTextById(t.objectId,t.text,t.displayMode)});return;case"apply-math-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-display-mode":e.runMutation(()=>{e.documentApi.ooxml.math.setDisplayModeByIdTracked(t.objectId,r.displayMode,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.setDisplayModeById(t.objectId,r.displayMode)});return;case"set-plain-text":e.runMutation(()=>{e.documentApi.ooxml.math.setPlainTextByIdTracked(t.objectId,r.text,e.surface.participant,e.context,r.displayMode)},()=>{e.documentApi.ooxml.math.setPlainTextById(t.objectId,r.text,r.displayMode)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":ie(e,t.objectId);return}}function ke(e,t){switch(t.action){case"replace-shape-model":e.runMutation(()=>{e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.replaceModelById(t.objectId,t.model)});return;case"apply-shape-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-metadata":e.runMutation(()=>{e.documentApi.ooxml.shapes.setMetadataByIdTracked(t.objectId,r,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setMetadataById(t.objectId,r)});return;case"set-watermark":e.runMutation(()=>{e.documentApi.ooxml.shapes.setWatermarkByIdTracked(t.objectId,r.isWatermark,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setWatermarkById(t.objectId,r.isWatermark)});return;case"set-text-body":e.runMutation(()=>{e.documentApi.ooxml.shapes.setTextBodyByIdTracked(t.objectId,r.paragraphs,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setTextBodyById(t.objectId,r.paragraphs)});return;case"set-geometry":e.runMutation(()=>{e.documentApi.ooxml.shapes.setGeometryByIdTracked(t.objectId,r.geometry,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setGeometryById(t.objectId,r.geometry)});return;case"set-transform":e.runMutation(()=>{e.documentApi.ooxml.shapes.setTransformByIdTracked(t.objectId,r.transform,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setTransformById(t.objectId,r.transform)});return;case"set-fill":e.runMutation(()=>{e.documentApi.ooxml.shapes.setFillByIdTracked(t.objectId,r.fill,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setFillById(t.objectId,r.fill)});return;case"set-stroke":e.runMutation(()=>{e.documentApi.ooxml.shapes.setStrokeByIdTracked(t.objectId,r.stroke,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setStrokeById(t.objectId,r.stroke)});return;case"set-effects":e.runMutation(()=>{e.documentApi.ooxml.shapes.setEffectsByIdTracked(t.objectId,r.effects,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setEffectsById(t.objectId,r.effects)});return;case"set-anchor":e.runMutation(()=>{e.documentApi.ooxml.shapes.setAnchorByIdTracked(t.objectId,r.anchor,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setAnchorById(t.objectId,r.anchor)});return;case"set-children":e.runMutation(()=>{e.documentApi.ooxml.shapes.setChildrenByIdTracked(t.objectId,r.children,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setChildrenById(t.objectId,r.children)});return;case"set-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.setChildByIdTracked(t.objectId,r.target,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setChildById(t.objectId,r.target,r.child)});return;case"append-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.appendChildByIdTracked(t.objectId,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.appendChildById(t.objectId,r.child)});return;case"append-child-to-parent":e.runMutation(()=>{e.documentApi.ooxml.shapes.appendChildToParentByIdTracked(t.objectId,r.parentTarget,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.appendChildToParentById(t.objectId,r.parentTarget,r.child)});return;case"move-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.moveChildByIdTracked(t.objectId,r.target,e.surface.participant,e.context,{parentId:r.parentTarget,beforeId:r.beforeTarget})},()=>{e.documentApi.ooxml.shapes.moveChildById(t.objectId,r.target,{parentId:r.parentTarget,beforeId:r.beforeTarget})});return;case"remove-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.removeChildByIdTracked(t.objectId,r.target,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.removeChildById(t.objectId,r.target)});return;case"set-connector":e.runMutation(()=>{e.documentApi.ooxml.shapes.setConnectorByIdTracked(t.objectId,r.connector,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setConnectorById(t.objectId,r.connector)});return;case"set-picture":e.runMutation(()=>{e.documentApi.ooxml.shapes.setPictureByIdTracked(t.objectId,r.picture,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setPictureById(t.objectId,r.picture)});return;case"set-word-art":e.runMutation(()=>{e.documentApi.ooxml.shapes.setWordArtByIdTracked(t.objectId,r.wordArt,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setWordArtById(t.objectId,r.wordArt)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":ie(e,t.objectId);return}}function oo(e,t){let r=ht(e,t),o=e.view?.dom??null;if(!o)return()=>{};let n=c=>{let d=c instanceof CustomEvent?c.detail:null;if(ut(d))switch(c.preventDefault(),c.stopPropagation(),d.family){case"math":if(d.action==="remove-advanced-ooxml"){Me(r,{family:"math",action:d.action,objectId:d.objectId});return}Me(r,d);return;case"chart":if(d.action==="remove-advanced-ooxml"){Ie(r,{family:"chart",action:d.action,objectId:d.objectId});return}Ie(r,d);return;case"shape":if(d.action==="remove-advanced-ooxml"){ke(r,{family:"shape",action:d.action,objectId:d.objectId});return}ke(r,d);return}};return o.addEventListener(xe,n),()=>{o.removeEventListener(xe,n)}}import{normalizeOoxmlChartModel as wo}from"@datalking/begonia-engine";import{Schema as no}from"prosemirror-model";import{EditorState as ao}from"prosemirror-state";import{EditorView as io}from"prosemirror-view";var lo=["display:grid","gap:8px","padding:10px","border:1px solid #dbe3ea","border-radius:12px","background:#f8fafc"].join(";"),co=["font-size:11px","font-weight:700","letter-spacing:0.08em","text-transform:uppercase","color:#334155"].join(";"),so=["display:grid","gap:8px","padding-left:8px"].join(";"),po=["display:grid","gap:4px"].join(";"),uo=["font-size:11px","font-weight:600","letter-spacing:0.06em","text-transform:uppercase","color:#64748b"].join(";"),mo=["min-height:36px","padding:8px 10px","border:1px solid #cbd5e1","border-radius:10px","background:#ffffff","font-size:12px","color:#0f172a","white-space:pre-wrap"].join(";"),ho=["display:grid","gap:10px","outline:none"].join(";"),W=new no({nodes:{doc:{content:"entry*"},section:{group:"entry",content:"entry*",attrs:{key:{default:""},label:{default:"Section"}},parseDOM:[{tag:"section[data-ald-structured-section]",getAttrs:e=>{let t=e;return{key:t.dataset.key??"",label:t.dataset.label??"Section"}}}],toDOM(e){return["section",{"data-ald-structured-section":"true","data-key":e.attrs.key,"data-label":e.attrs.label,style:lo},["div",{style:co},e.attrs.label],["div",{style:so},0]]}},field:{group:"entry",content:"text*",marks:"",parseDOM:[{tag:"div[data-ald-structured-field]",getAttrs:e=>{let t=e;return{key:t.dataset.key??"",label:t.dataset.label??"Field"}}}],toDOM(e){return["div",{"data-ald-structured-field":"true","data-key":e.attrs.key,"data-label":e.attrs.label,style:po},["div",{style:uo},e.attrs.label],["div",{style:mo},0]]}},text:{}}});function fo(e){return W.nodes.field.create({key:e.key,label:e.label},e.value?W.text(e.value):void 0)}function xo(e){let t=e.children.map(De);return W.nodes.section.create({key:e.key,label:e.label},t)}function De(e){return e.type==="field"?fo(e):xo(e)}function yo(e){return W.nodes.doc.create(null,e.map(De))}function ft(e){return e.content.content.map(t=>St(t)).filter(t=>t!==null)}function St(e){return e.type===W.nodes.field?{type:"field",key:String(e.attrs.key??""),label:String(e.attrs.label??"Field"),value:e.textContent}:e.type===W.nodes.section?{type:"section",key:String(e.attrs.key??""),label:String(e.attrs.label??"Section"),children:e.content.content.map(t=>St(t)).filter(t=>t!==null)}:null}function xt(e){return ao.create({schema:W,doc:yo(e)})}function So(e){let{$from:t}=e.selection;for(let r=t.depth;r>0;r-=1)if(t.node(r).type===W.nodes.section)return t.end(r)-1;return e.doc.content.size}function bo(e){let{$from:t}=e.selection;for(let r=t.depth;r>0;r-=1){let o=t.node(r);if(o.type===W.nodes.field||o.type===W.nodes.section)return{from:t.before(r),to:t.before(r)+o.nodeSize}}return null}function yt(e){let{$from:t}=e.selection,r=[],o=e.doc;for(let n=1;n<=t.depth;n+=1){if(t.node(n).type!==W.nodes.section)continue;let c=String(t.node(n).attrs.key??"").trim();c.length>0&&r.push(c),o=t.node(n)}return{sectionKeys:r,containerKey:r[r.length-1]??null,childKeys:o.content.content.map(n=>String(n.attrs.key??"").trim()).filter(n=>n.length>0)}}function go(e){Object.assign(e.style,{display:"grid",gap:"10px",padding:"10px",borderRadius:"12px",border:"1px solid #dbe3ea",background:"#ffffff",minHeight:"160px",boxSizing:"border-box",overflow:"auto"})}function a(e,t,r=""){return{type:"field",key:e,label:t,value:r}}function l(e,t,r=[]){return{type:"section",key:e,label:t,children:[...r]}}function le(e,t,r={}){go(e);let o,n=()=>{r.onSelectionChange?.(yt(o.state))};return o=new io(e,{dispatchTransaction(c){let d=o.state.apply(c);o.updateState(d),c.docChanged&&r.onChange?.({entries:ft(d.doc)}),(c.docChanged||c.selectionSet)&&n()},state:xt(t),attributes:{style:ho,class:"ald-advanced-ooxml-subtree-editor"}}),n(),{dom:e,appendEntry(c){let d=De(c),p=So(o.state);o.dispatch(o.state.tr.insert(p,d)),o.focus()},destroy(){o.destroy()},focus(){o.focus()},readEntries(){return ft(o.state.doc)},readSelection(){return yt(o.state)},removeSelectedEntry(){let c=bo(o.state);return c?(o.dispatch(o.state.tr.delete(c.from,c.to)),o.focus(),!0):!1},setEntries(c){o.updateState(xt(c)),n()}}}function h(e){let t=e.trim();return t.length>0?t:null}function v(e){let t=e.trim();if(!t)return null;let r=Number(t);return Number.isFinite(r)?r:null}function O(e){let t=e.trim().toLowerCase();return t==="true"?!0:t==="false"?!1:null}function T(e){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function N(e){return e==null?"":JSON.stringify(e,null,2)}function i(e,t){let r=e.find(o=>o.type==="field"&&o.key===t);return r?.type==="field"?r.value:""}function z(e,t){return e.filter(r=>r.type==="section"&&r.key===t)}function Te(e,t){return z(e,t)[0]??null}function bt(e){return e.type==="field"?e.value.trim().length>0:e.children.some(t=>bt(t))}function Ao(e){return e.some(t=>bt(t))}function j(e,t){let r=Te(e,t);return r&&Ao(r.children)?r:null}function ce(e,t,r){let o=r?.paragraphs?.length?r.paragraphs:r?.plainText?[r.plainText]:[];return l(e,t,(o.length>0?o:[""]).map(n=>a("paragraph","Paragraph",n)))}function ye(e){if(!e)return null;let t=e.children.filter(r=>r.type==="field"&&r.key==="paragraph").map(r=>r.value);return t.length===0?null:{paragraphs:t,plainText:t.join(`
2
- `)}}function Se(e,t){return l(e,t,[a("paragraph","Paragraph","")])}function vo(e){return l("marker","Marker",[a("symbol","Symbol",e.marker?.symbol??""),a("size","Size",e.marker?.size==null?"":String(e.marker.size))])}function Eo(e){return l("data-labels","Data Labels",[a("show-value","Show Value",e.dataLabels?.showValue==null?"":String(e.dataLabels.showValue)),a("show-category","Show Category",e.dataLabels?.showCategory==null?"":String(e.dataLabels.showCategory)),a("show-series-name","Show Series Name",e.dataLabels?.showSeriesName==null?"":String(e.dataLabels.showSeriesName)),a("show-percentage","Show Percentage",e.dataLabels?.showPercentage==null?"":String(e.dataLabels.showPercentage)),a("position","Position",e.dataLabels?.position??""),a("separator","Separator",e.dataLabels?.separator??"")])}function Bo(e){return l("series","Series",[a("id","Series Id",e.id??""),a("order","Order",e.order==null?"":String(e.order)),a("name","Name",e.name??""),a("categories","Categories",e.categories.join(", ")),a("values","Values",e.values.map(t=>t==null?"":String(t)).join(", ")),a("color","Color",e.color??""),a("smooth","Smooth",e.smooth==null?"":String(e.smooth)),a("explosion","Explosion",e.explosion==null?"":String(e.explosion)),vo(e),Eo(e)])}function Co(e){return l("axis","Axis",[a("id","Axis Id",e.id??""),a("kind","Kind",e.kind??""),a("title","Title",e.title??""),a("format-code","Format Code",e.formatCode??""),a("orientation","Orientation",e.orientation??""),a("visible","Visible",e.visible==null?"":String(e.visible)),a("minimum","Minimum",e.minimum==null?"":String(e.minimum)),a("maximum","Maximum",e.maximum==null?"":String(e.maximum)),a("major-unit","Major Unit",e.majorUnit==null?"":String(e.majorUnit)),a("minor-unit","Minor Unit",e.minorUnit==null?"":String(e.minorUnit)),a("crosses-at","Crosses At",e.crossesAt==null?"":String(e.crossesAt)),a("major-gridlines","Major Gridlines",e.majorGridlines==null?"":String(e.majorGridlines)),a("minor-gridlines","Minor Gridlines",e.minorGridlines==null?"":String(e.minorGridlines))])}function Oo(e){return l("legend","Legend",[a("visible","Visible",e.legend==null?"":String(e.legend.visible)),a("position","Position",e.legend?.position??""),a("overlay","Overlay",e.legend?.overlay==null?"":String(e.legend.overlay))])}function Io(e){return l("plot-area","Plot Area",[a("stacked","Stacked",e.plotArea?.stacked==null?"":String(e.plotArea.stacked)),a("percent-stacked","Percent Stacked",e.plotArea?.percentStacked==null?"":String(e.plotArea.percentStacked)),a("vary-colors","Vary Colors",e.plotArea?.varyColors==null?"":String(e.plotArea.varyColors)),a("hole-size","Hole Size",e.plotArea?.holeSize==null?"":String(e.plotArea.holeSize))])}function Mo(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function ko(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{let r=Number(t);return Number.isFinite(r)?r:null})}function Do(e){return e.length>0?e:null}function To(e){let t=j(e,"marker"),r=j(e,"data-labels");return{id:h(i(e,"id")),order:v(i(e,"order")),name:h(i(e,"name")),categories:Mo(i(e,"categories")),values:ko(i(e,"values")),color:h(i(e,"color")),marker:t?{symbol:h(i(t.children,"symbol"))??"unknown",size:v(i(t.children,"size"))}:null,dataLabels:r?{showValue:O(i(r.children,"show-value")),showCategory:O(i(r.children,"show-category")),showSeriesName:O(i(r.children,"show-series-name")),showPercentage:O(i(r.children,"show-percentage")),position:h(i(r.children,"position")),separator:Do(i(r.children,"separator"))}:null,smooth:O(i(e,"smooth")),explosion:v(i(e,"explosion"))}}function No(e){let t=i(e,"kind"),r=i(e,"orientation");return{id:h(i(e,"id")),kind:t==="category"||t==="value"||t==="series"||t==="date"?t:"unknown",title:h(i(e,"title")),formatCode:h(i(e,"format-code")),orientation:r==="minMax"||r==="maxMin"?r:null,visible:O(i(e,"visible")),minimum:v(i(e,"minimum")),maximum:v(i(e,"maximum")),majorUnit:v(i(e,"major-unit")),minorUnit:v(i(e,"minor-unit")),crossesAt:v(i(e,"crosses-at")),majorGridlines:O(i(e,"major-gridlines")),minorGridlines:O(i(e,"minor-gridlines"))}}function Ne(e){return[a("title","Title",e.title??""),a("chart-type","Chart Type",e.chartType??""),a("subtitle","Subtitle",e.subtitle??""),ce("text-body","Text Body",e.textBody),Io(e),...e.series.map(t=>Bo(t)),...e.axes.map(t=>Co(t)),Oo(e)]}function je(e,t){let r=j(e,"text-body"),o=j(e,"plot-area"),n=j(e,"legend");return wo({...t,title:h(i(e,"title")),chartType:h(i(e,"chart-type")),subtitle:h(i(e,"subtitle")),textBody:ye(r),plotArea:o?{stacked:O(i(o.children,"stacked")),percentStacked:O(i(o.children,"percent-stacked")),varyColors:O(i(o.children,"vary-colors")),holeSize:v(i(o.children,"hole-size"))}:null,series:z(e,"series").map(c=>To(c.children)),axes:z(e,"axis").map(c=>No(c.children)),legend:n?{visible:O(i(n.children,"visible"))!==!1,position:h(i(n.children,"position"))??"unknown",overlay:O(i(n.children,"overlay"))}:null},t.title??"Chart")}function jo(){return l("series","Series",[a("id","Series Id",""),a("order","Order",""),a("name","Name",""),a("categories","Categories",""),a("values","Values",""),a("color","Color",""),a("smooth","Smooth",""),a("explosion","Explosion",""),l("marker","Marker",[a("symbol","Symbol",""),a("size","Size","")]),l("data-labels","Data Labels",[a("show-value","Show Value",""),a("show-category","Show Category",""),a("show-series-name","Show Series Name",""),a("show-percentage","Show Percentage",""),a("position","Position",""),a("separator","Separator","")])])}function Po(){return l("axis","Axis",[a("id","Axis Id",""),a("kind","Kind","category"),a("title","Title",""),a("format-code","Format Code",""),a("orientation","Orientation",""),a("visible","Visible",""),a("minimum","Minimum",""),a("maximum","Maximum",""),a("major-unit","Major Unit",""),a("minor-unit","Minor Unit",""),a("crosses-at","Crosses At",""),a("major-gridlines","Major Gridlines",""),a("minor-gridlines","Minor Gridlines","")])}function Ro(){return l("legend","Legend",[a("visible","Visible","true"),a("position","Position","right"),a("overlay","Overlay","")])}function Vo(){return l("plot-area","Plot Area",[a("stacked","Stacked",""),a("percent-stacked","Percent Stacked",""),a("vary-colors","Vary Colors",""),a("hole-size","Hole Size","")])}function Lo(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function Fo(e){return new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))}function Ho(e){return e==null}function gt(e={}){let t=Lo(e.containerKey),r=Fo(e.childKeys),o=n=>r.has(n);return t==="text-body"?[{label:"Paragraph",createEntry:()=>a("paragraph","Paragraph","")}]:Ho(t)?[{label:"Series",createEntry:jo},{label:"Axis",createEntry:Po},...o("legend")?[]:[{label:"Legend",createEntry:Ro}],...o("plot-area")?[]:[{label:"Plot Area",createEntry:Vo}],...o("text-body")?[]:[{label:"Text Body",createEntry:()=>Se("text-body","Text Body")}]]:[]}import{normalizeOoxmlMathModel as yn}from"@datalking/begonia-engine";import{createOoxmlMathTextNode as Uo}from"@datalking/begonia-engine";var zo=new Set(["numerator","denominator","body","degree","base","superscript-slot","subscript-slot","lower","upper","name","argument","matrix-cell","equation-row"]);function Pe(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function At(e){let t=Pe(e);return t==null||zo.has(t)}function Re(e){return Uo(e)}function Ve(){return Re("")}function Wo(e=""){return a("text","Text",e)}function C(e,t){return l(e,t,[Wo()])}function wt(e){throw new Error(`Unsupported math node type: ${JSON.stringify(e)}.`)}function P(e){return At(e)}function Ko(){return l("fraction","Fraction",[C("numerator","Numerator"),C("denominator","Denominator")])}function Go(){return l("radical","Radical",[C("body","Body"),l("degree","Degree",[])])}function qo(){return l("superscript","Superscript",[C("base","Base"),C("superscript-slot","Superscript")])}function Jo(){return l("subscript","Subscript",[C("base","Base"),C("subscript-slot","Subscript")])}function $o(){return l("subsup","Subscript and Superscript",[C("base","Base"),C("subscript-slot","Subscript"),C("superscript-slot","Superscript")])}function Xo(){return l("preSubSup","Pre-Sub/Superscript",[C("base","Base"),C("subscript-slot","Subscript"),C("superscript-slot","Superscript")])}function Yo(){return l("matrix","Matrix",[l("matrix-row","Row",[l("matrix-cell","Cell",[a("text","Text","")])])])}function _o(){return l("equationArray","Equation Array",[l("equation-row","Row",[a("text","Text","")])])}function Zo(){return l("delimiter","Delimiter",[a("begin","Begin Delimiter","("),a("end","End Delimiter",")"),C("body","Body")])}function Qo(){return l("operator","Operator",[a("operator-symbol","Operator","sum"),C("body","Body"),l("lower","Lower",[]),l("upper","Upper",[])])}function en(){return l("nary","N-ary Operator",[a("operator-symbol","Operator","prod"),C("body","Body"),l("subscript-slot","Subscript",[]),l("superscript-slot","Superscript",[])])}function tn(){return l("limitLower","Lower Limit",[C("base","Base"),C("lower","Lower")])}function rn(){return l("limitUpper","Upper Limit",[C("base","Base"),C("upper","Upper")])}function on(){return l("function","Function",[C("name","Name"),C("argument","Argument")])}function nn(){return l("accent","Accent",[a("accent-symbol","Accent","hat"),C("body","Body")])}function an(){return l("bar","Bar",[a("bar-position","Position","top"),C("body","Body")])}function ln(){return l("box","Box",[a("border-box","Border Box","true"),C("body","Body")])}function cn(){return l("groupCharacter","Group Character",[a("group-character","Character","_"),a("group-position","Position","bottom"),C("body","Body")])}function sn(){return l("phantom","Phantom",[a("zero-width","Zero Width","false"),a("zero-ascent","Zero Ascent","false"),a("zero-descent","Zero Descent","false"),a("transparent","Transparent","true"),C("body","Body")])}function dn(){return l("matrix-row","Row",[l("matrix-cell","Cell",[a("text","Text","")])])}function pn(){return l("matrix-cell","Cell",[a("text","Text","")])}function un(){return l("equation-row","Row",[a("text","Text","")])}var mn=[{label:"Text",createEntry:()=>a("text","Text",""),supportsContainer:P},{label:"Fraction",createEntry:Ko,supportsContainer:P},{label:"Radical",createEntry:Go,supportsContainer:P},{label:"Superscript",createEntry:qo,supportsContainer:P},{label:"Subscript",createEntry:Jo,supportsContainer:P},{label:"Sub+Sup",createEntry:$o,supportsContainer:P},{label:"Pre-Sub/Sup",createEntry:Xo,supportsContainer:P},{label:"Matrix",createEntry:Yo,supportsContainer:P},{label:"Matrix Row",createEntry:dn,supportsContainer:e=>e==="matrix"},{label:"Matrix Cell",createEntry:pn,supportsContainer:e=>e==="matrix-row"},{label:"Equation Array",createEntry:_o,supportsContainer:P},{label:"Equation Row",createEntry:un,supportsContainer:e=>e==="equationArray"},{label:"Delimiter",createEntry:Zo,supportsContainer:P},{label:"Operator",createEntry:Qo,supportsContainer:P},{label:"N-ary",createEntry:en,supportsContainer:P},{label:"Lower Limit",createEntry:tn,supportsContainer:P},{label:"Upper Limit",createEntry:rn,supportsContainer:P},{label:"Function",createEntry:on,supportsContainer:P},{label:"Accent",createEntry:nn,supportsContainer:P},{label:"Bar",createEntry:an,supportsContainer:P},{label:"Box",createEntry:ln,supportsContainer:P},{label:"Group Char",createEntry:cn,supportsContainer:P},{label:"Phantom",createEntry:sn,supportsContainer:P}];function Le(e={}){let t=Pe(e.containerKey);return mn.filter(r=>r.supportsContainer(t)).map(({label:r,createEntry:o})=>({label:r,createEntry:o}))}function B(e,t){return Te(e,t)?.children??[]}function hn(e){let t=e.map(r=>xn(r)).filter(r=>r!==null);return t.length===0?Ve():t.length===1?t[0]:{type:"sequence",items:t}}function be(e){return e.length>0?E(e):null}function fn(e){let t=z(e,"matrix-cell").map(r=>E(r.children));return t.length>0?t:[Ve()]}function xn(e){if(e.type==="field")return e.key==="text"?Re(e.value):null;switch(e.key){case"fraction":return{type:"fraction",numerator:E(B(e.children,"numerator")),denominator:E(B(e.children,"denominator"))};case"radical":{let t=B(e.children,"degree");return{type:"radical",body:E(B(e.children,"body")),degree:t.length>0?E(t):null}}case"superscript":return{type:"superscript",base:E(B(e.children,"base")),superscript:E(B(e.children,"superscript-slot"))};case"subscript":return{type:"subscript",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot"))};case"subsup":return{type:"subsup",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot")),superscript:E(B(e.children,"superscript-slot"))};case"preSubSup":return{type:"preSubSup",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot")),superscript:E(B(e.children,"superscript-slot"))};case"matrix":return{type:"matrix",rows:z(e.children,"matrix-row").map(t=>fn(t.children))};case"equationArray":return{type:"equationArray",rows:z(e.children,"equation-row").map(t=>E(t.children))};case"delimiter":return{type:"delimiter",begin:h(i(e.children,"begin")),end:h(i(e.children,"end")),body:E(B(e.children,"body"))};case"operator":return{type:"operator",operator:h(i(e.children,"operator-symbol")),body:E(B(e.children,"body")),lower:be(B(e.children,"lower")),upper:be(B(e.children,"upper"))};case"nary":return{type:"nary",operator:h(i(e.children,"operator-symbol")),body:E(B(e.children,"body")),subscript:be(B(e.children,"subscript-slot")),superscript:be(B(e.children,"superscript-slot"))};case"limitLower":return{type:"limitLower",base:E(B(e.children,"base")),lower:E(B(e.children,"lower"))};case"limitUpper":return{type:"limitUpper",base:E(B(e.children,"base")),upper:E(B(e.children,"upper"))};case"function":return{type:"function",name:E(B(e.children,"name")),argument:E(B(e.children,"argument"))};case"accent":return{type:"accent",accent:h(i(e.children,"accent-symbol")),body:E(B(e.children,"body"))};case"bar":{let t=i(e.children,"bar-position").trim().toLowerCase();return{type:"bar",position:t==="top"||t==="bottom"?t:"unknown",body:E(B(e.children,"body"))}}case"box":return{type:"box",body:E(B(e.children,"body")),borderBox:O(i(e.children,"border-box"))};case"groupCharacter":{let t=i(e.children,"group-position").trim().toLowerCase();return{type:"groupCharacter",character:h(i(e.children,"group-character")),position:t==="top"||t==="bottom"?t:"unknown",body:E(B(e.children,"body"))}}case"phantom":return{type:"phantom",body:E(B(e.children,"body")),zeroWidth:O(i(e.children,"zero-width")),zeroAscent:O(i(e.children,"zero-ascent")),zeroDescent:O(i(e.children,"zero-descent")),transparent:O(i(e.children,"transparent"))};default:return e.children.length>0?E(e.children):null}}function E(e){return hn(e)}function w(e){switch(e.type){case"sequence":return e.items.flatMap(t=>w(t));case"text":return[a("text","Text",e.value)];case"fraction":return[l("fraction","Fraction",[l("numerator","Numerator",w(e.numerator)),l("denominator","Denominator",w(e.denominator))])];case"radical":return[l("radical","Radical",[l("body","Body",w(e.body)),l("degree","Degree",e.degree?w(e.degree):[])])];case"superscript":return[l("superscript","Superscript",[l("base","Base",w(e.base)),l("superscript-slot","Superscript",w(e.superscript))])];case"subscript":return[l("subscript","Subscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript))])];case"subsup":return[l("subsup","Subscript and Superscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript)),l("superscript-slot","Superscript",w(e.superscript))])];case"preSubSup":return[l("preSubSup","Pre-Sub/Superscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript)),l("superscript-slot","Superscript",w(e.superscript))])];case"matrix":return[l("matrix","Matrix",e.rows.map(t=>l("matrix-row","Row",t.map(r=>l("matrix-cell","Cell",w(r))))))];case"equationArray":return[l("equationArray","Equation Array",e.rows.map(t=>l("equation-row","Row",w(t))))];case"delimiter":return[l("delimiter","Delimiter",[a("begin","Begin Delimiter",e.begin??""),a("end","End Delimiter",e.end??""),l("body","Body",w(e.body))])];case"operator":return[l("operator","Operator",[a("operator-symbol","Operator",e.operator??""),l("body","Body",w(e.body)),l("lower","Lower",e.lower?w(e.lower):[]),l("upper","Upper",e.upper?w(e.upper):[])])];case"nary":return[l("nary","N-ary Operator",[a("operator-symbol","Operator",e.operator??""),l("body","Body",w(e.body)),l("subscript-slot","Subscript",e.subscript?w(e.subscript):[]),l("superscript-slot","Superscript",e.superscript?w(e.superscript):[])])];case"limitLower":return[l("limitLower","Lower Limit",[l("base","Base",w(e.base)),l("lower","Lower",w(e.lower))])];case"limitUpper":return[l("limitUpper","Upper Limit",[l("base","Base",w(e.base)),l("upper","Upper",w(e.upper))])];case"function":return[l("function","Function",[l("name","Name",w(e.name)),l("argument","Argument",w(e.argument))])];case"accent":return[l("accent","Accent",[a("accent-symbol","Accent",e.accent??""),l("body","Body",w(e.body))])];case"bar":return[l("bar","Bar",[a("bar-position","Position",e.position),l("body","Body",w(e.body))])];case"box":return[l("box","Box",[a("border-box","Border Box",e.borderBox==null?"":String(e.borderBox)),l("body","Body",w(e.body))])];case"groupCharacter":return[l("groupCharacter","Group Character",[a("group-character","Character",e.character??""),a("group-position","Position",e.position),l("body","Body",w(e.body))])];case"phantom":return[l("phantom","Phantom",[a("zero-width","Zero Width",e.zeroWidth==null?"":String(e.zeroWidth)),a("zero-ascent","Zero Ascent",e.zeroAscent==null?"":String(e.zeroAscent)),a("zero-descent","Zero Descent",e.zeroDescent==null?"":String(e.zeroDescent)),a("transparent","Transparent",e.transparent==null?"":String(e.transparent)),l("body","Body",w(e.body))])]}return wt(e)}function Fe(e){return[a("display-mode","Display Mode",e.displayMode),...w(e.root)]}function vt(e){let r=i(e,"display-mode").trim().toLowerCase()==="block"?"block":"inline",o=e.filter(n=>!(n.type==="field"&&n.key==="display-mode"));return yn({displayMode:r,root:E(o)},"",r)}function Et(e){return l("shape-child","Child Object",[a("kind","Kind",e.kind??""),a("id","Id",e.id??""),a("label","Label",e.label??""),ce("text-body","Text Body",e.textBody),He(e.geometry),Ue(e.transform),ze(e.groupTransform??null),We(e.fill??null),Ke(e.stroke??null),Ge(e.effects??null),qe(e.connector),Je(e.picture),$e(e.wordArt),...e.children.map(t=>Et(t))])}function He(e){return l("geometry","Geometry",[a("preset","Preset",e?.preset??""),a("custom-path-count","Custom Path Count",e?.customPathCount==null?"":String(e.customPathCount)),a("adjustments","Adjustments",e?.adjustments.join(", ")??""),a("custom-geometry-json","Custom Geometry JSON",N(e?.customGeometry??null))])}function Ue(e){return l("transform","Transform",[a("width-emu","Width (EMU)",e?.widthEmu==null?"":String(e.widthEmu)),a("height-emu","Height (EMU)",e?.heightEmu==null?"":String(e.heightEmu)),a("offset-x-emu","Offset X (EMU)",e?.offsetXEmu==null?"":String(e.offsetXEmu)),a("offset-y-emu","Offset Y (EMU)",e?.offsetYEmu==null?"":String(e.offsetYEmu)),a("rotation","Rotation",e?.rotation==null?"":String(e.rotation)),a("flip-h","Flip H",e?.flipH==null?"":String(e.flipH)),a("flip-v","Flip V",e?.flipV==null?"":String(e.flipV))])}function ze(e){return l("group-transform","Group Transform",[a("child-offset-x-emu","Child Offset X (EMU)",e?.childOffsetXEmu==null?"":String(e.childOffsetXEmu)),a("child-offset-y-emu","Child Offset Y (EMU)",e?.childOffsetYEmu==null?"":String(e.childOffsetYEmu)),a("child-width-emu","Child Width (EMU)",e?.childWidthEmu==null?"":String(e.childWidthEmu)),a("child-height-emu","Child Height (EMU)",e?.childHeightEmu==null?"":String(e.childHeightEmu))])}function We(e){return l("fill","Fill",[a("kind","Kind",e?.kind??""),a("color","Color",e?.color??""),a("secondary-color","Secondary Color",e?.secondaryColor??""),a("opacity","Opacity",e?.opacity==null?"":String(e.opacity)),a("gradient-angle","Gradient Angle",e?.gradientAngle==null?"":String(e.gradientAngle)),a("gradient-path","Gradient Path",e?.gradientPath??""),a("pattern-preset","Pattern Preset",e?.patternPreset??""),a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("color-source-json","Color Source JSON",N(e?.colorSource??null)),a("secondary-color-source-json","Secondary Color Source JSON",N(e?.secondaryColorSource??null)),a("gradient-stops-json","Gradient Stops JSON",e?N(e.gradientStops??[]):""),a("picture-fill-json","Picture Fill JSON",N(e?.pictureFill??null))])}function Ke(e){return l("stroke","Stroke",[a("kind","Kind",e?.kind??""),a("color","Color",e?.color??""),a("width-emu","Width (EMU)",e?.widthEmu==null?"":String(e.widthEmu)),a("dash","Dash",e?.dash??""),a("cap","Cap",e?.cap??""),a("join","Join",e?.join??""),a("opacity","Opacity",e?.opacity==null?"":String(e.opacity)),a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("compound","Compound",e?.compound??""),a("color-source-json","Color Source JSON",N(e?.colorSource??null)),a("head-end-json","Head End JSON",N(e?.headEnd??null)),a("tail-end-json","Tail End JSON",N(e?.tailEnd??null))])}function Ge(e){return l("effects","Effects",[a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("style-ref-color-source-json","Style Ref Color Source JSON",N(e?.styleRefColorSource??null)),a("effect-nodes-json","Effect Nodes JSON",e?N(e.effectNodes??[]):""),a("glow-json","Glow JSON",N(e?.glow??null)),a("outer-shadow-json","Outer Shadow JSON",N(e?.outerShadow??null)),a("inner-shadow-json","Inner Shadow JSON",N(e?.innerShadow??null)),a("soft-edge-json","Soft Edge JSON",N(e?.softEdge??null)),a("blur-json","Blur JSON",N(e?.blur??null)),a("reflection-json","Reflection JSON",N(e?.reflection??null)),a("preset-shadow-json","Preset Shadow JSON",N(e?.presetShadow??null)),a("effect-dag-json","Effect DAG JSON",N(e?.effectDag??null))])}function Sn(e){return l("anchor","Anchor",[a("kind","Kind",e?.kind??""),a("wrap","Wrap",e?.wrap??""),a("behind-doc","Behind Doc",e?.behindDoc==null?"":String(e.behindDoc)),a("allow-overlap","Allow Overlap",e?.allowOverlap==null?"":String(e.allowOverlap)),a("layout-in-cell","Layout In Cell",e?.layoutInCell==null?"":String(e.layoutInCell)),a("relative-height","Relative Height",e?.relativeHeight==null?"":String(e.relativeHeight)),a("dist-top-emu","Dist Top (EMU)",e?.distTopEmu==null?"":String(e.distTopEmu)),a("dist-bottom-emu","Dist Bottom (EMU)",e?.distBottomEmu==null?"":String(e.distBottomEmu)),a("dist-left-emu","Dist Left (EMU)",e?.distLeftEmu==null?"":String(e.distLeftEmu)),a("dist-right-emu","Dist Right (EMU)",e?.distRightEmu==null?"":String(e.distRightEmu)),a("position-h","Position H",e?.positionH??""),a("position-v","Position V",e?.positionV??""),a("offset-x-emu","Anchor Offset X (EMU)",e?.offsetXEmu==null?"":String(e.offsetXEmu)),a("offset-y-emu","Anchor Offset Y (EMU)",e?.offsetYEmu==null?"":String(e.offsetYEmu)),a("align-h","Align H",e?.alignH??""),a("align-v","Align V",e?.alignV??"")])}function qe(e){return l("connector","Connector",[a("connector-type","Connector Type",e?.connectorType??""),a("begin-shape-id","Begin Shape Id",e?.beginShapeId??""),a("end-shape-id","End Shape Id",e?.endShapeId??"")])}function Je(e){return l("picture","Picture",[a("src","Source",e?.src??""),a("alt","Alt",e?.alt??""),a("title","Title",e?.title??""),a("relationship-id","Relationship Id",e?.relationshipId??""),a("blip-fill-json","Blip Fill JSON",N(e?.blipFill??null)),a("hyperlink-url","Hyperlink URL",e?.hyperlink?.url??""),a("hyperlink-tooltip","Hyperlink Tooltip",e?.hyperlink?.tooltip??"")])}function $e(e){return l("word-art","WordArt",[a("text","Text",e?.text??""),a("preset","Preset",e?.preset??"")])}function ge(e){return[a("label","Label",e.label??""),a("shape-type","Shape Type",e.shapeType??""),a("group-kind","Group Kind",e.groupKind??""),a("is-watermark","Is Watermark",e.isWatermark==null?"":String(e.isWatermark)),ce("text-body","Text Body",e.textBody),He(e.geometry),Ue(e.transform),ze(e.groupTransform??null),We(e.fill),Ke(e.stroke),Ge(e.effects??null),Sn(e.anchor),qe(e.connector),Je(e.picture),$e(e.wordArt),...e.children.map(t=>Et(t))]}function oe(e){return l("shape-child","Child Object",[a("kind","Kind",e),a("id","Id",""),a("label","Label",""),ce("text-body","Text Body",null),He(null),Ue(null),ze(null),We(null),Ke(null),Ge(null),qe(null),Je(null),$e(null)])}function bn(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function gn(e){return new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))}function An(){return[{label:"Child Shape",createEntry:()=>oe("shape")},{label:"Child Group",createEntry:()=>oe("group")},{label:"Text Box",createEntry:()=>oe("textBox")},{label:"Connector",createEntry:()=>oe("connector")},{label:"Picture",createEntry:()=>oe("picture")},{label:"WordArt",createEntry:()=>oe("wordArt")}]}function Xe(e={}){let t=bn(e.containerKey),r=gn(e.childKeys),o=(t==null||t==="shape-child")&&!r.has("text-body");return t==="text-body"?[{label:"Paragraph",createEntry:()=>a("paragraph","Paragraph","")}]:t!=null&&t!=="shape-child"?[]:[...o?[{label:"Text Body",createEntry:()=>Se("text-body","Text Body")}]:[],...An()]}import{normalizeOoxmlShapeModel as wn}from"@datalking/begonia-engine";function vn(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Bt(e){return{kind:h(i(e,"kind"))??"unknown",color:h(i(e,"color")),secondaryColor:h(i(e,"secondary-color")),opacity:v(i(e,"opacity")),gradientAngle:v(i(e,"gradient-angle")),gradientPath:h(i(e,"gradient-path")),patternPreset:h(i(e,"pattern-preset")),styleRefIndex:v(i(e,"style-ref-index")),colorSource:T(i(e,"color-source-json")),secondaryColorSource:T(i(e,"secondary-color-source-json")),gradientStops:T(i(e,"gradient-stops-json"))??[],pictureFill:T(i(e,"picture-fill-json"))}}function Ct(e){return{kind:h(i(e,"kind"))??"unknown",color:h(i(e,"color")),widthEmu:v(i(e,"width-emu")),dash:h(i(e,"dash")),cap:h(i(e,"cap")),join:h(i(e,"join")),opacity:v(i(e,"opacity")),styleRefIndex:v(i(e,"style-ref-index")),compound:h(i(e,"compound")),colorSource:T(i(e,"color-source-json")),headEnd:T(i(e,"head-end-json")),tailEnd:T(i(e,"tail-end-json"))}}function Ot(e){return{styleRefIndex:v(i(e,"style-ref-index")),styleRefColorSource:T(i(e,"style-ref-color-source-json")),effectNodes:T(i(e,"effect-nodes-json"))??[],glow:T(i(e,"glow-json")),outerShadow:T(i(e,"outer-shadow-json")),innerShadow:T(i(e,"inner-shadow-json")),softEdge:T(i(e,"soft-edge-json")),blur:T(i(e,"blur-json")),reflection:T(i(e,"reflection-json")),presetShadow:T(i(e,"preset-shadow-json")),effectDag:T(i(e,"effect-dag-json"))}}function It(e){let t=j(e,"geometry");return t?{preset:h(i(t.children,"preset")),customPathCount:v(i(t.children,"custom-path-count")),adjustments:vn(i(t.children,"adjustments")),customGeometry:T(i(t.children,"custom-geometry-json"))}:null}function Mt(e){let t=j(e,"transform");return t?{widthEmu:v(i(t.children,"width-emu")),heightEmu:v(i(t.children,"height-emu")),offsetXEmu:v(i(t.children,"offset-x-emu")),offsetYEmu:v(i(t.children,"offset-y-emu")),rotation:v(i(t.children,"rotation")),flipH:O(i(t.children,"flip-h")),flipV:O(i(t.children,"flip-v"))}:null}function kt(e){let t=j(e,"group-transform");return t?{childOffsetXEmu:v(i(t.children,"child-offset-x-emu")),childOffsetYEmu:v(i(t.children,"child-offset-y-emu")),childWidthEmu:v(i(t.children,"child-width-emu")),childHeightEmu:v(i(t.children,"child-height-emu"))}:null}function Dt(e){let t=j(e,"connector");return t?{connectorType:h(i(t.children,"connector-type")),beginShapeId:h(i(t.children,"begin-shape-id")),endShapeId:h(i(t.children,"end-shape-id"))}:null}function Tt(e){let t=j(e,"picture");if(!t)return null;let r=h(i(t.children,"hyperlink-url"));return{src:h(i(t.children,"src")),alt:h(i(t.children,"alt")),title:h(i(t.children,"title")),relationshipId:h(i(t.children,"relationship-id")),blipFill:T(i(t.children,"blip-fill-json")),hyperlink:r?{url:r,tooltip:h(i(t.children,"hyperlink-tooltip"))}:null}}function Nt(e){let t=j(e,"word-art");return t?{text:h(i(t.children,"text")),preset:h(i(t.children,"preset"))}:null}function jt(e){return ye(z(e,"text-body")[0]??null)}function En(e){let t=j(e,"anchor");return t?{kind:h(i(t.children,"kind"))??"unknown",wrap:h(i(t.children,"wrap"))??"unknown",behindDoc:O(i(t.children,"behind-doc")),allowOverlap:O(i(t.children,"allow-overlap")),layoutInCell:O(i(t.children,"layout-in-cell")),relativeHeight:v(i(t.children,"relative-height")),distTopEmu:v(i(t.children,"dist-top-emu")),distBottomEmu:v(i(t.children,"dist-bottom-emu")),distLeftEmu:v(i(t.children,"dist-left-emu")),distRightEmu:v(i(t.children,"dist-right-emu")),positionH:h(i(t.children,"position-h")),positionV:h(i(t.children,"position-v")),offsetXEmu:v(i(t.children,"offset-x-emu")),offsetYEmu:v(i(t.children,"offset-y-emu")),alignH:h(i(t.children,"align-h")),alignV:h(i(t.children,"align-v"))}:null}function Bn(e){return e==="shape"||e==="group"||e==="textBox"||e==="connector"||e==="picture"||e==="wordArt"}function Pt(e){let t=j(e,"fill"),r=j(e,"stroke"),o=j(e,"effects"),n=i(e,"kind");return{kind:Bn(n)?n:"unknown",id:h(i(e,"id")),label:h(i(e,"label")),textBody:jt(e),geometry:It(e),transform:Mt(e),groupTransform:kt(e),fill:t?Bt(t.children):null,stroke:r?Ct(r.children):null,effects:o?Ot(o.children):null,connector:Dt(e),picture:Tt(e),wordArt:Nt(e),children:z(e,"shape-child").map(c=>Pt(c.children))}}function Ae(e,t){let r=j(e,"fill"),o=j(e,"stroke"),n=j(e,"effects");return wn({...t,label:h(i(e,"label")),shapeType:h(i(e,"shape-type")),groupKind:h(i(e,"group-kind")),isWatermark:O(i(e,"is-watermark")),textBody:jt(e),geometry:It(e),transform:Mt(e),groupTransform:kt(e),fill:r?Bt(r.children):null,stroke:o?Ct(o.children):null,effects:n?Ot(n.children):null,anchor:En(e),connector:Dt(e),picture:Tt(e),wordArt:Nt(e),children:z(e,"shape-child").map(c=>Pt(c.children))},t.label??"Shape")}function I(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Cn(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function Z(e){return new Set(e).size===e.length}function fe(e,t){let r=new Set(t),o=e.filter(p=>r.has(p)),n=new Set(e),c=t.filter(p=>n.has(p));if(!Cn(o,c))return!1;let d=t.findIndex(p=>!n.has(p));return d===-1||t.slice(d).every(p=>!n.has(p))}function Rt(e){return e.map((t,r)=>t.id??`shape-child-${r+1}`)}function Vt(e,t){return I({...e,children:[]},{...t,children:[]})}function Ye(e,t,r){for(let o=0;o<e.length;o+=1){let n=e[o],c=n.id?.trim(),d=e[o+1]?.id?.trim()??null;if(!c||r.has(c)||e[o+1]&&!d||(r.set(c,{child:n,parentId:t,beforeId:d}),!Ye(n.children,c,r)))return!1}return!0}function On(e,t){return e.size===t.size&&[...t.keys()].every(r=>e.has(r))}function In(e,t){return{...t,children:[...e.children]}}function Lt(e,t,r){t.forEach(o=>{let n=o.id?.trim();if(!n)return;let c=e.get(n);c&&!Vt(c.child,o)&&r.push({type:"set-child",target:n,child:In(c.child,o)}),Lt(e,o.children,r)})}function Ft(e,t,r,o){let n=null;for(let c=t.length-1;c>=0;c-=1){let d=t[c],p=d.id?.trim();if(!p)continue;let u=e.get(p);u&&(u.parentId!==r||u.beforeId!==n)&&o.push({type:"move-child",target:p,parentTarget:r,beforeTarget:n}),Ft(e,d.children,p,o),n=p}}function Mn(e,t){let r=new Map,o=new Map;if(!Ye(e,null,r)||!Ye(t,null,o)||!On(r,o))return null;let n=[];return Lt(r,t,n),Ft(r,t,null,n),n}function kn(e,t,r){return t==null||r==null?[{type:"set-children",children:[...e]}]:[{type:"set-child",target:t,child:r}]}function Ht(e,t,r,o){if(I(e,t))return[];let n=Rt(e),c=Rt(t);if(!Z(n)||!Z(c)||!fe(n,c))return kn(t,r,o);let d=new Map(e.map((y,g)=>[n[g],y])),p=new Map(t.map((y,g)=>[c[g],y])),u=[];for(let y=n.length-1;y>=0;y-=1){let g=n[y];p.has(g)||u.push({type:"remove-child",target:g})}return c.forEach(y=>{let g=p.get(y),m=d.get(y);if(!m){u.push(r==null?{type:"append-child",child:g}:{type:"append-child-to-parent",parentTarget:r,child:g});return}if(!Vt(m,g)){u.push({type:"set-child",target:y,child:g});return}u.push(...Ht(m.children,g.children,y,g))}),u}function Ut(e,t){if(I(e,t))return[];if(!I(e.groupTransform,t.groupTransform))return[{type:"replace-model",model:t}];let r=[];(e.label!==t.label||e.shapeType!==t.shapeType||e.groupKind!==t.groupKind)&&r.push({type:"set-metadata",label:t.label,shapeType:t.shapeType,groupKind:t.groupKind}),(e.isWatermark??!1)!==(t.isWatermark??!1)&&r.push({type:"set-watermark",isWatermark:t.isWatermark??!1}),I(e.textBody,t.textBody)||r.push({type:"set-text-body",paragraphs:t.textBody?.paragraphs?[...t.textBody.paragraphs]:[]}),I(e.geometry,t.geometry)||r.push({type:"set-geometry",geometry:t.geometry}),I(e.transform,t.transform)||r.push({type:"set-transform",transform:t.transform}),I(e.fill,t.fill)||r.push({type:"set-fill",fill:t.fill}),I(e.stroke,t.stroke)||r.push({type:"set-stroke",stroke:t.stroke}),I(e.effects,t.effects)||r.push({type:"set-effects",effects:t.effects??null}),I(e.anchor,t.anchor)||r.push({type:"set-anchor",anchor:t.anchor}),I(e.connector,t.connector)||r.push({type:"set-connector",connector:t.connector}),I(e.picture,t.picture)||r.push({type:"set-picture",picture:t.picture}),I(e.wordArt,t.wordArt)||r.push({type:"set-word-art",wordArt:t.wordArt});let o=Mn(e.children,t.children);return o?(r.push(...o),r):(r.push(...Ht(e.children,t.children,null,null)),r)}import{createOoxmlFamilyEnvelope as Gt}from"@datalking/begonia-engine";function Dn(e,t){e.disabled=!t,e.style.opacity=t?"1":"0.65",e.style.cursor=t?"pointer":"default"}function Tn(e,t){e.textContent=t?"Local subtree edits pending. Leave this card or press Cmd/Ctrl+Enter to apply.":"Auto-applies when you leave this card. Apply is still available for an immediate commit.",e.style.color=t?"#0f766e":"#64748b",e.style.fontWeight=t?"600":"400"}function se(e){let t=!1,r=!1,o=null,n=()=>{o!==null&&(window.clearTimeout(o),o=null)},c=()=>{Dn(e.applyButton,r),Tn(e.status,r)},d=()=>{if(n(),t||!r)return!1;try{let g=e.onCommit();return r=!1,c(),g}catch(g){throw c(),g}},p=()=>{t||!r||(n(),o=window.setTimeout(()=>{o=null,e.root.contains(document.activeElement)||d()},0))},u=()=>{p()},y=g=>{r&&(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),d())};return e.root.addEventListener("focusout",u),e.root.addEventListener("keydown",y),c(),{destroy(){t=!0,n(),e.root.removeEventListener("focusout",u),e.root.removeEventListener("keydown",y)},flush:d,markDirty(){t||r||(r=!0,c())},reset(){n(),r=!1,c()}}}function q(e,t){return Object.assign(e.style,t),e}function de(e,t=!1){let r=document.createElement(e);return r.contentEditable="false",q(r,{display:t?"inline-flex":"grid",gap:"8px",padding:"10px",border:"1px solid #cbd5e1",borderRadius:"14px",background:"#f8fafc",margin:t?"0 4px":"8px 0",minWidth:t?"280px":"100%",boxSizing:"border-box",verticalAlign:"middle"}),r}function pe(e,t){let r=document.createElement("div");q(r,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let o=document.createElement("strong");o.textContent=e,q(o,{fontSize:"12px",color:"#0f172a"});let n=document.createElement("span");return n.textContent=t,q(n,{fontSize:"11px",fontWeight:"600",color:"#475569",background:"#e2e8f0",borderRadius:"999px",padding:"2px 8px"}),r.append(o,n),{header:r,heading:o}}function ue(){let e=document.createElement("div");return q(e,{fontSize:"11px",color:"#64748b"}),e}function ne(e){let t=document.createElement("section");q(t,{display:"grid",gap:"8px",padding:"10px",borderRadius:"12px",background:"#ffffff",border:"1px solid #e2e8f0"});let r=document.createElement("div");return r.textContent=e,q(r,{fontSize:"11px",fontWeight:"700",letterSpacing:"0.08em",textTransform:"uppercase",color:"#475569"}),t.append(r),{section:t,title:r}}function J(e){let t=document.createElement("div");return t.textContent=e,q(t,{fontSize:"11px",color:"#64748b"}),t}function X(){let e=document.createElement("div");return q(e,{display:"flex",gap:"8px",justifyContent:"flex-end",flexWrap:"wrap"}),e}function L(e,t="default"){let r=document.createElement("button");return r.type="button",r.textContent=e,q(r,{padding:"6px 12px",borderRadius:"999px",border:t==="danger"?"1px solid #fecaca":"1px solid #99f6e4",background:t==="danger"?"#fff1f2":"#f0fdfa",color:t==="danger"?"#be123c":"#0f766e",fontSize:"12px",fontWeight:"600",cursor:"pointer"}),r}function me(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLButtonElement}import{listOoxmlChartAxisIds as zt,listOoxmlChartSeriesIds as Wt}from"@datalking/begonia-engine";function Nn(e,t){if(I(e.series,t.series))return[];let r=Wt(e),o=Wt(t);if(!Z(r)||!Z(o)||!fe(r,o))return[{type:"set-series-list",series:[...t.series]}];let n=new Map(e.series.map((p,u)=>[r[u],p])),c=new Map(t.series.map((p,u)=>[o[u],p])),d=[];for(let p=r.length-1;p>=0;p-=1){let u=r[p];c.has(u)||d.push({type:"remove-series",target:u})}return o.forEach(p=>{let u=c.get(p),y=n.get(p);if(!y){d.push({type:"append-series",series:u});return}I(y,u)||d.push({type:"set-series",target:p,series:u})}),d}function jn(e,t){if(I(e.axes,t.axes))return[];let r=zt(e),o=zt(t);if(!Z(r)||!Z(o)||!fe(r,o))return[{type:"set-axes",axes:[...t.axes]}];let n=new Map(e.axes.map((p,u)=>[r[u],p])),c=new Map(t.axes.map((p,u)=>[o[u],p])),d=[];for(let p=r.length-1;p>=0;p-=1){let u=r[p];c.has(u)||d.push({type:"remove-axis",axisId:u})}return o.forEach(p=>{let u=c.get(p),y=n.get(p);(!y||!I(y,u))&&d.push({type:"upsert-axis",axisId:p,axis:u})}),d}function Kt(e,t){if(I(e,t))return[];let r=[];return(e.title!==t.title||e.chartType!==t.chartType||e.subtitle!==t.subtitle)&&r.push({type:"set-metadata",title:t.title,chartType:t.chartType,subtitle:t.subtitle}),I(e.textBody,t.textBody)||r.push({type:"set-text-body",textBody:t.textBody}),I(e.plotArea,t.plotArea)||r.push({type:"set-plot-area",plotArea:t.plotArea}),I(e.legend,t.legend)||r.push({type:"set-legend",legend:t.legend}),r.push(...jn(e,t)),r.push(...Nn(e,t)),r}function _e(e){let t=String(e.attrs.label??"Chart"),r=String(e.attrs.text??""),o=Gt("chart",{title:t,textBody:r?{plainText:r,paragraphs:[r]}:null},{label:t,text:r}),n=Gt("chart",e.attrs.familyData,{label:t,text:r})??o;return{objectId:String(e.attrs.objectId??""),label:t,model:n.data.model??o.data.model,evidence:n.evidence}}function Pn(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%"}),e}function qt(){return e=>{let t=e,r=de("div"),{header:o,heading:n}=pe("Chart","chart"),c=ue(),{section:d}=ne("Native Subtree"),p=J("Edit chart metadata, series, axes, legend, and plot area as a structured nested tree. Use insert buttons at the current subtree selection. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),u=X();u.style.justifyContent="flex-start";let y=L("Remove Selected","danger"),g=Pn(),m=X();m.style.justifyContent="space-between",m.style.alignItems="center";let s=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),M=L("Apply"),G=L("Remove Chart","danger");s.style.marginRight="auto",m.append(s,M,G),d.append(p,u,g,y),r.append(o,c,d,m);let R=null,ee=(f,k)=>{u.replaceChildren(),gt({containerKey:f,childKeys:k}).forEach(H=>{let D=L(H.label);D.addEventListener("click",()=>{F.appendEntry(H.createEntry())}),u.append(D)})},F=le(g,[],{onChange(){R?.markDirty()},onSelectionChange(f){ee(f.containerKey,f.childKeys)}});y.addEventListener("click",()=>{F.removeSelectedEntry()}),R=se({applyButton:M,onCommit:()=>{let f=_e(t),k=je(F.readEntries(),f.model),H=Kt(f.model,k);return H.length===0?!1:($(r,{family:"chart",action:"apply-chart-edits",objectId:f.objectId,model:k,edits:H}),!0)},root:r,status:s});let te=f=>{t=f;let k=_e(f);n.textContent=k.label,c.textContent=`${k.evidence.chartType??"chart"} | ${k.evidence.seriesCount} series | ${k.evidence.axisCount} axes`,R?.reset(),F.setEntries(Ne(k.model))};return M.addEventListener("click",()=>{R?.flush()}),G.addEventListener("click",()=>{R?.reset();let f=_e(t);$(r,{family:"chart",action:"remove-advanced-ooxml",objectId:f.objectId})}),te(e),{dom:r,destroy(){R?.destroy(),F.destroy()},update(f){return f.type!==t.type?!1:(te(f),!0)},stopEvent(f){return me(f.target)||f.target instanceof Node&&g.contains(f.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{createOoxmlFamilyEnvelope as $t,normalizeOoxmlMathModel as Rn}from"@datalking/begonia-engine";function Jt(e,t){if(I(e,t))return[];if(e.root.type==="text"&&t.root.type==="text"){let r=e.root.value,o=t.root.value;return r!==o?[{type:"set-plain-text",text:o,displayMode:t.displayMode}]:e.displayMode!==t.displayMode?[{type:"set-display-mode",displayMode:t.displayMode}]:[]}return t.root.type==="text"?[{type:"set-plain-text",text:t.root.value,displayMode:t.displayMode}]:I(e.root,t.root)&&e.displayMode!==t.displayMode?[{type:"set-display-mode",displayMode:t.displayMode}]:[{type:"replace-model",model:t}]}function Ze(e){let t=String(e.attrs.text??""),r=String(e.attrs.label??"Equation"),o=$t("math",{plainText:t,displayMode:"inline"},{label:r,text:t}),n=$t("math",e.attrs.familyData,{label:r,text:t})??o,c=Rn(n.data,n.data.plainText??t,n.data.displayMode??"inline");return{objectId:String(e.attrs.objectId??""),label:r,model:c,evidence:n.evidence}}function Vn(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%",maxWidth:"720px"}),e}function Xt(){return e=>{let t=e,r=de("span",!0);Object.assign(r.style,{display:"inline-grid",width:"min(720px, 100%)",verticalAlign:"top"});let{header:o,heading:n}=pe("Equation","math"),c=ue(),{section:d}=ne("Native Subtree"),p=J("Edit the equation as a nested ProseMirror tree. Insert structures into the selected slot. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),u=X();u.style.justifyContent="flex-start";let y=L("Remove Selected","danger"),g=Vn(),m=X();m.style.justifyContent="space-between",m.style.alignItems="center";let s=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),M=L("Apply"),G=L("Remove Equation","danger");s.style.marginRight="auto",m.append(s,M,G),d.append(p,u,g,y),r.append(o,c,d,m);let R=null,ee=f=>{u.replaceChildren(),Le({containerKey:f}).forEach(k=>{let H=L(k.label);H.addEventListener("click",()=>{F.appendEntry(k.createEntry())}),u.append(H)})},F=le(g,[],{onChange(){R?.markDirty()},onSelectionChange(f){ee(f.containerKey)}});y.addEventListener("click",()=>{F.removeSelectedEntry()}),R=se({applyButton:M,onCommit:()=>{let f=Ze(t),k=vt(F.readEntries()),H=Jt(f.model,k);return H.length===0?!1:($(r,{family:"math",action:"apply-math-edits",objectId:f.objectId,model:k,edits:H}),!0)},root:r,status:s});let te=f=>{t=f;let k=Ze(f);n.textContent=k.label,c.textContent=`${k.evidence.displayMode} | root ${k.evidence.rootType} | ${k.evidence.structureCount} structures`,R?.reset(),F.setEntries(Fe(k.model))};return M.addEventListener("click",()=>{R?.flush()}),G.addEventListener("click",()=>{R?.reset();let f=Ze(t);$(r,{family:"math",action:"remove-advanced-ooxml",objectId:f.objectId})}),te(e),{dom:r,destroy(){R?.destroy(),F.destroy()},update(f){return f.type!==t.type?!1:(te(f),!0)},stopEvent(f){return me(f.target)||f.target instanceof Node&&g.contains(f.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{createOoxmlFamilyEnvelope as Yt,createOoxmlShapePreview as Ln}from"@datalking/begonia-engine";function Qe(e){let t=String(e.attrs.label??"Shape"),r=String(e.attrs.text??""),o=Yt("shape",{label:t,textBody:r?{plainText:r,paragraphs:[r]}:null},{label:t,text:r}),n=Yt("shape",e.attrs.familyData,{label:t,text:r})??o;return{objectId:String(e.attrs.objectId??""),label:t,model:n.data.model??o.data.model,evidence:n.evidence}}function Fn(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%"}),e}function Hn(){let e=document.createElement("div");return Object.assign(e.style,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"84px",padding:"12px",borderRadius:"12px",background:"linear-gradient(180deg, #ffffff, #f8fafc)",border:"1px solid #e2e8f0"}),e}function Un(e,t,r,o){let n=Ln(o,{idPrefix:t||r,maxWidth:280,maxHeight:180});return e.dataset.previewKind=n.kind,e.dataset.previewSupported=String(n.supported),e.innerHTML=n.svg,n}function _t(){return e=>{let t=e,r=de("div"),{header:o,heading:n}=pe("Shape","shape"),c=ue(),{section:d}=ne("Visual Preview"),p=J("Preview uses begonia\u2019s clean-room SVG geometry renderer for preset, connector, group, and custom-path shape families."),u=Hn(),{section:y}=ne("Native Subtree"),g=J("Edit the shape object graph, text boxes, connector data, pictures, and child objects in a nested ProseMirror subtree. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),m=X();m.style.justifyContent="flex-start";let s=L("Remove Selected","danger"),M=Fn(),G=X();G.style.justifyContent="space-between",G.style.alignItems="center";let R=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),ee=L("Apply"),F=L("Remove Shape","danger");R.style.marginRight="auto",G.append(R,ee,F),d.append(p,u),y.append(g,m,M,s),r.append(o,c,d,y,G);let Y=null,te=(D,U)=>{m.replaceChildren(),Xe({containerKey:D,childKeys:U}).forEach(_=>{let nt=L(_.label);nt.addEventListener("click",()=>{f.appendEntry(_.createEntry())}),m.append(nt)})},f=le(M,[],{onChange(){Y?.markDirty()},onSelectionChange(D){te(D.containerKey,D.childKeys)}});s.addEventListener("click",()=>{f.removeSelectedEntry()}),Y=se({applyButton:ee,onCommit:()=>{let D=Qe(t),U=Ae(f.readEntries(),D.model),_=Ut(D.model,U);return _.length===0?!1:($(r,{family:"shape",action:"apply-shape-edits",objectId:D.objectId,model:U,edits:_}),!0)},root:r,status:R});let H=D=>{t=D;let U=Qe(D);n.textContent=U.label;let _=Un(u,U.objectId,U.label,U.model);c.textContent=`${U.evidence.shapeType??"shape"} | ${U.evidence.childCount} child objects | ${U.evidence.anchorKind} | preview ${_.kind}${_.supported?"":" fallback"}`,Y?.reset(),f.setEntries(ge(U.model))};return ee.addEventListener("click",()=>{Y?.flush()}),F.addEventListener("click",()=>{Y?.reset();let D=Qe(t);$(r,{family:"shape",action:"remove-advanced-ooxml",objectId:D.objectId})}),H(e),{dom:r,destroy(){Y?.destroy(),f.destroy()},update(D){return D.type!==t.type?!1:(H(D),!0)},stopEvent(D){return me(D.target)||D.target instanceof Node&&M.contains(D.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{inlineOoxmlDrawingMetadata as zn}from"@datalking/begonia-editor-adapters";function Zt(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function Wn(){let e=document.createElement("span");return e.contentEditable="false",e.className="ald-editor-inline-drawing",Object.assign(e.style,{display:"inline-block",boxSizing:"border-box",margin:"0 2px",lineHeight:"0",maxWidth:"100%",verticalAlign:"baseline"}),e}function Qt(e,t){let r=zn(t),o=r?.label||String(t.attrs.label??"Drawing"),n=r?.family??(t.attrs.family==="chart"?"chart":"shape"),c=r?.drawing,d=Zt(r?.width??c?.width,80),p=Zt(r?.height??c?.height,40);if(e.dataset.family=n,e.dataset.objectId=r?.objectId??String(t.attrs.objectId??""),e.setAttribute("aria-label",o),e.title=o,e.style.width=`${d}px`,e.style.height=`${p}px`,e.style.border=c?"0":"1px solid #94a3b8",e.style.background=c?"transparent":"#f8fafc",!c?.svg){e.replaceChildren();let y=document.createElement("span");y.textContent=o,Object.assign(y.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",color:"#334155",fontSize:"12px",lineHeight:"1.2",overflow:"hidden"}),e.append(y);return}e.innerHTML=c.svg;let u=e.querySelector("svg");u&&(u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("aria-hidden","true"),Object.assign(u.style,{display:"block"}))}function er(){return e=>{let t=e,r=Wn();return Qt(r,e),{dom:r,update(o){return o.type!==t.type?!1:(t=o,Qt(r,o),!0)},ignoreMutation(){return!0},selectNode(){r.style.outline="2px solid #0f766e",r.style.outlineOffset="2px"},deselectNode(){r.style.outline="",r.style.outlineOffset=""}}}}var et="browser-advanced-ooxml-nodeviews";function tr(){return{id:et,createPlugins(){return[]},createNodeViews(){return{ooxml_math:Xt(),ooxml_chart:qt(),ooxml_shape:_t(),inline_ooxml_drawing:er()}}}}function Kn(e=[]){return e.some(t=>t.id===et)?[...e]:[...e,tr()]}import{collectOoxmlMathStructures as Gn,countOoxmlChartCategories as qn,normalizeOoxmlChartModel as Jn,normalizeOoxmlMathModel as $n,normalizeOoxmlShapeModel as Xn}from"@datalking/begonia-engine";function we(e){return e.trackingEnabled??e.toolbar?.trackingEnabled??!1}function ve(e){return e.documentMode==="editing"||e.documentMode==="suggesting"||e.documentMode==="viewing"?e.documentMode:"editing"}function Yn(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="math")return null;let r=$n(t.familyData??{plainText:t.text,displayMode:"inline"},t.text,"inline");return{family:"math",record:t,model:r,plainText:t.familyData?.plainText??t.text,displayMode:r.displayMode,structures:t.familyData?.structures?.length?t.familyData.structures:Gn(r),trackingEnabled:we(e),documentMode:ve(e)}}function _n(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="chart")return null;let r=Jn(t.familyData?.model??t.familyData??{title:t.label,textBody:{plainText:t.text}},t.label);return{family:"chart",record:t,model:r,series:r.series,seriesCount:r.series.length,categoryCount:qn(r),trackingEnabled:we(e),documentMode:ve(e)}}function Zn(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="shape")return null;let r=Xn(t.familyData?.model??t.familyData??{label:t.label,textBody:t.text?{plainText:t.text,paragraphs:[t.text]}:null},t.label);return{family:"shape",record:t,model:r,trackingEnabled:we(e),documentMode:ve(e)}}function Ee(e="editing",t=!1){return{selected:null,documentMode:e,trackingEnabled:t}}function tt(e){return{selected:Yn(e)??_n(e)??Zn(e),trackingEnabled:we(e),documentMode:ve(e)}}function Be(e){return structuredClone(e)}function Qn(e){return"host"in e}function Ce(e){return e?Qn(e)?e.host:e:null}var ea=Symbol.for("@datalking/begonia-browser-sdk/browser-editor-v1-runtime"),rr=new WeakMap,ta=new WeakMap;function rt(e){return!e||typeof e!="object"?null:e[ea]??null}function ra(e){return"host"in e}function ot(e){if(!e)return null;if(ra(e))return ta.get(e)??rt(e)??rr.get(e.host)??rt(e.host)??null;let t=Ce(e);return t?rr.get(t)??rt(t)??null:null}function or(e){return ot(e)?.advancedOoxmlActions??null}function A(e){return{changed:!1,reason:e}}function oa(e){let t=e,r=Ce(t),o=ot(t),n=or(t),c=o?.controller.documentApi??{},d=()=>{let s=o?.controller.getState();return s?tt(s):Ee()},p=d(),u=new Set,y=()=>{p=d();for(let s of[...u])s(Be(p))},g=r?.session.subscribe(()=>y())??(()=>{}),m="Advanced OOXML editing requires a mounted browser editor backend.";return{actor:o?.controller.actor??null,documentApi:c,getSnapshot(){return p=d(),Be(p)},subscribe(s){return u.add(s),s(Be(p)),()=>{u.delete(s)}},replaceSelectedMathModel(s){return n?n.replaceSelectedMathModel(s):A(m)},setSelectedMathPlainText(s,M){return n?n.setSelectedMathPlainText(s,M):A(m)},setSelectedMathDisplayMode(s){return n?n.setSelectedMathDisplayMode(s):A(m)},replaceSelectedChartModel(s){return n?n.replaceSelectedChartModel(s):A(m)},setSelectedChartMetadata(s){return n?n.setSelectedChartMetadata(s):A(m)},appendSelectedChartSeries(s){return n?n.appendSelectedChartSeries(s):A(m)},setSelectedChartSeriesList(s){return n?n.setSelectedChartSeriesList(s):A(m)},setSelectedChartTitle(s){return n?n.setSelectedChartTitle(s):A(m)},setSelectedChartTextBody(s){return n?n.setSelectedChartTextBody(s):A(m)},setSelectedChartSeries(s,M){return n?n.setSelectedChartSeries(s,M):A(m)},upsertSelectedChartSeries(s,M){return n?n.upsertSelectedChartSeries(s,M):A(m)},removeSelectedChartSeries(s){return n?n.removeSelectedChartSeries(s):A(m)},appendSelectedChartAxis(s){return n?n.appendSelectedChartAxis(s):A(m)},setSelectedChartAxes(s){return n?n.setSelectedChartAxes(s):A(m)},upsertSelectedChartAxis(s,M){return n?n.upsertSelectedChartAxis(s,M):A(m)},removeSelectedChartAxis(s){return n?n.removeSelectedChartAxis(s):A(m)},setSelectedChartLegend(s){return n?n.setSelectedChartLegend(s):A(m)},setSelectedChartPlotArea(s){return n?n.setSelectedChartPlotArea(s):A(m)},replaceSelectedShapeModel(s){return n?n.replaceSelectedShapeModel(s):A(m)},setSelectedShapeMetadata(s){return n?n.setSelectedShapeMetadata(s):A(m)},setSelectedShapeWatermark(s){return n?n.setSelectedShapeWatermark(s):A(m)},setSelectedShapeTextBody(s){return n?n.setSelectedShapeTextBody(s):A(m)},setSelectedShapeGeometry(s){return n?n.setSelectedShapeGeometry(s):A(m)},setSelectedShapeTransform(s){return n?n.setSelectedShapeTransform(s):A(m)},setSelectedShapeFill(s){return n?n.setSelectedShapeFill(s):A(m)},setSelectedShapeStroke(s){return n?n.setSelectedShapeStroke(s):A(m)},setSelectedShapeAnchor(s){return n?n.setSelectedShapeAnchor(s):A(m)},setSelectedShapeConnector(s){return n?n.setSelectedShapeConnector(s):A(m)},setSelectedShapePicture(s){return n?n.setSelectedShapePicture(s):A(m)},setSelectedShapeWordArt(s){return n?n.setSelectedShapeWordArt(s):A(m)},setSelectedShapeChildren(s){return n?n.setSelectedShapeChildren(s):A(m)},setSelectedShapeChild(s,M){return n?n.setSelectedShapeChild(s,M):A(m)},appendSelectedShapeChild(s){return n?n.appendSelectedShapeChild(s):A(m)},appendSelectedShapeChildToParent(s,M){return n?n.appendSelectedShapeChildToParent(s,M):A(m)},moveSelectedShapeChild(s,M){return n?n.moveSelectedShapeChild(s,M):A(m)},removeSelectedShapeChild(s){return n?n.removeSelectedShapeChild(s):A(m)},removeSelected(){return n?n.removeSelectedAdvancedOoxml():A(m)},destroy(){g(),u.clear(),p=Ee()}}}function V(e){let t=e.trim();return t.length>0?t:null}function na(e){return e===!0?"true":e===!1?"false":"unknown"}function K(e){return e==="true"?!0:e==="false"?!1:null}function nr(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}function aa(e){let t=nr(e);return t.length===0?null:{paragraphs:t,plainText:t.join(`
3
- `)}}function ia(e){let t=nr(e);return t.length===0?null:{paragraphs:t,plainText:t.join(`
4
- `)}}function la(e){return e.series.map(t=>({id:t.id??"",order:t.order==null?"":String(t.order),name:t.name??"",categories:t.categories.join(", "),values:t.values.map(r=>r==null?"":String(r)).join(", ")}))}function ca(e){return e.axes.map(t=>({id:t.id??"",kind:t.kind??"unknown",title:t.title??"",formatCode:t.formatCode??"",orientation:t.orientation??"unknown"}))}function sa(e){return{enabled:e.legend?"true":"false",visible:e.legend?.visible===!1?"false":"true",position:e.legend?.position??"unknown",overlay:na(e.legend?.overlay)}}function da(e){return[...e,{id:"",order:e.length===0?"0":String(e.length),name:"",categories:"",values:""}]}function pa(e){return[...e,{id:"",kind:"category",title:"",formatCode:"",orientation:"unknown"}]}function ua(e){return{id:V(e.id),order:e.order.trim()?Number(e.order):null,name:V(e.name),categories:e.categories.split(",").map(t=>t.trim()).filter(t=>t.length>0),values:e.values.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{let r=Number(t);return Number.isFinite(r)?r:null}),color:null,marker:null,dataLabels:null,smooth:null,explosion:null}}function ma(e){return{id:V(e.id),kind:e.kind==="category"||e.kind==="value"||e.kind==="series"||e.kind==="date"?e.kind:"unknown",title:V(e.title),formatCode:V(e.formatCode),orientation:e.orientation==="minMax"||e.orientation==="maxMin"?e.orientation:null,visible:null,minimum:null,maximum:null,majorUnit:null,minorUnit:null,crossesAt:null,majorGridlines:null,minorGridlines:null}}function ha(e){return e.enabled==="false"?null:{visible:e.visible!=="false",position:e.position,overlay:K(e.overlay)}}function fa(e,t,r,o,n,c={}){return{...e,title:V(t),chartType:V(r),textBody:aa(o),series:n.map(ua),axes:c.axes?c.axes.map(ma):e.axes,legend:c.legend?ha(c.legend):e.legend}}function Q(e){let t=e.trim();if(!t)return null;let r=Number(t);return Number.isFinite(r)?r:null}function xa(e,t){let r=V(t.geometryPreset),o=Q(t.geometryCustomPathCount??""),n=Q(t.strokeWidthEmu),c=Q(t.widthEmu),d=Q(t.heightEmu),p=Q(t.offsetXEmu??""),u=Q(t.offsetYEmu??""),y=Q(t.rotation),g=Q(t.anchorRelativeHeight??"");return{...e,label:V(t.label),shapeType:V(t.shapeType),textBody:ia(t.textBody),geometry:r||o!=null?{preset:r,customPathCount:o,adjustments:[]}:null,fill:V(t.fillColor)||t.fillKind!=="unknown"?{kind:t.fillKind,color:V(t.fillColor),secondaryColor:null,opacity:null}:null,stroke:V(t.strokeColor)||V(t.strokeDash)||n!=null?{color:V(t.strokeColor),widthEmu:n,dash:V(t.strokeDash),cap:null,join:null}:null,transform:c!=null||d!=null||p!=null||u!=null||y!=null||K(t.flipH??"unknown")!=null||K(t.flipV??"unknown")!=null?{widthEmu:c,heightEmu:d,offsetXEmu:p,offsetYEmu:u,rotation:y,flipH:K(t.flipH??"unknown"),flipV:K(t.flipV??"unknown")}:null,anchor:t.anchorKind!=="unknown"||t.anchorWrap!=="unknown"||K(t.anchorBehindDoc??"unknown")!=null||K(t.anchorAllowOverlap??"unknown")!=null||K(t.anchorLayoutInCell??"unknown")!=null||g!=null?{...e.anchor,kind:t.anchorKind,wrap:t.anchorWrap,behindDoc:K(t.anchorBehindDoc??"unknown"),allowOverlap:K(t.anchorAllowOverlap??"unknown"),layoutInCell:K(t.anchorLayoutInCell??"unknown"),relativeHeight:g,distTopEmu:e.anchor?.distTopEmu??null,distBottomEmu:e.anchor?.distBottomEmu??null,distLeftEmu:e.anchor?.distLeftEmu??null,distRightEmu:e.anchor?.distRightEmu??null,positionH:e.anchor?.positionH??null,positionV:e.anchor?.positionV??null,offsetXEmu:e.anchor?.offsetXEmu??null,offsetYEmu:e.anchor?.offsetYEmu??null,alignH:e.anchor?.alignH??null,alignV:e.anchor?.alignV??null}:null}}export{pa as appendEmptyAxisDraft,da as appendEmptySeriesDraft,ur as appendMathToCurrentTextblock,mr as appendMathToCurrentTextblockTracked,Ir as appendSelectedChartAxis,vr as appendSelectedChartSeries,Xr as appendSelectedShapeChild,Yr as appendSelectedShapeChildToParent,ca as axisDraftsFromModel,xe as browserAdvancedOoxmlNodeViewActionEvent,et as browserAdvancedOoxmlSurfaceFeatureId,je as chartModelFromStructuredEntries,Ne as chartStructuredEntriesFromModel,oa as createBrowserAdvancedOoxmlInspectorController,tr as createBrowserAdvancedOoxmlSurfaceFeature,gt as createChartSubtreeInsertions,Le as createMathSubtreeInsertions,Xe as createShapeSubtreeInsertions,$ as dispatchBrowserAdvancedOoxmlNodeViewAction,Ee as emptyBrowserAdvancedOoxmlInspectorSnapshot,yr as insertChartAfterCurrentBlock,Sr as insertChartAfterCurrentBlockTracked,Nr as insertShapeAfterCurrentBlock,jr as insertShapeAfterCurrentBlockTracked,oo as installBrowserAdvancedOoxmlNodeViewBridge,ut as isBrowserAdvancedOoxmlNodeViewActionDetail,sa as legendDraftFromModel,vt as mathModelFromStructuredEntries,Fe as mathStructuredEntriesFromModel,fa as mergeChartModelWithDrafts,xa as mergeShapeModelWithDrafts,_r as moveSelectedShapeChild,Ut as planShapeNodeViewEdits,tt as readBrowserAdvancedOoxmlInspectorSnapshot,he as readSelectedAdvancedOoxmlRecord,pr as removeSelectedAdvancedOoxml,kr as removeSelectedChartAxis,Or as removeSelectedChartSeries,Zr as removeSelectedShapeChild,br as replaceSelectedChartModel,hr as replaceSelectedMathModel,Pr as replaceSelectedShapeModel,la as seriesDraftsFromModel,Mr as setSelectedChartAxes,Dr as setSelectedChartLegend,gr as setSelectedChartMetadata,Tr as setSelectedChartPlotArea,Br as setSelectedChartSeries,Er as setSelectedChartSeriesList,wr as setSelectedChartTextBody,Ar as setSelectedChartTitle,xr as setSelectedMathDisplayMode,fr as setSelectedMathPlainText,Wr as setSelectedShapeAnchor,$r as setSelectedShapeChild,Jr as setSelectedShapeChildren,Kr as setSelectedShapeConnector,Ur as setSelectedShapeFill,Fr as setSelectedShapeGeometry,Rr as setSelectedShapeMetadata,Gr as setSelectedShapePicture,zr as setSelectedShapeStroke,Lr as setSelectedShapeTextBody,Hr as setSelectedShapeTransform,Vr as setSelectedShapeWatermark,qr as setSelectedShapeWordArt,Ae as shapeModelFromStructuredEntries,ge as shapeStructuredEntriesFromModel,dr as updateSelectedAdvancedOoxml,pt as upsertSelectedChartAxis,Cr as upsertSelectedChartSeries,Kn as withBrowserAdvancedOoxmlSurfaceFeature};
1
+ import{isDocumentNodePathIndex as pr}from"@datalking/begonia-document-model";import{DELETION_MARK_NAME as mr}from"@datalking/begonia-engine";import{NodeSelection as ur}from"prosemirror-state";function st(e){return e instanceof ur||typeof e=="object"&&e!=null&&"node"in e&&e.node!=null&&"from"in e&&typeof e.from=="number"&&"to"in e&&typeof e.to=="number"&&"$from"in e&&e.$from!=null}function dt(e){return e?e.surface??null:null}function mt(e){return e==="ooxml_math"||e==="ooxml_chart"||e==="ooxml_shape"||e==="inline_ooxml_drawing"}function ht(e,t){let r=[];for(let o=0;o<t;o+=1)r.push(e.$from.index(o));return r}function hr(e){if(!st(e)||!mt(e.node.type.name))return null;let t=ht(e,e.$from.depth);return t.push(e.$from.index(e.$from.depth)),t}function fr(e,t){let r=e;for(let o of t){if(!pr(o)||o>=r.childCount)return null;r=r.child(o)}return r}function ut(e,t){let r=fr(e.doc,t);return!!(r&&mt(r.type.name)&&r.marks.some(o=>o.type.name===mr))}function ke(e){let{selection:t}=e.state;for(let r=t.$from.depth;r>0;r-=1)if(t.$from.node(r).isTextblock)return ht(t,r);return null}function ie(e,t){let r=t.blocks.topLevel(),o=e.state.selection.from,n=r.find(c=>o>=c.from&&o<=c.from+c.nodeSize);return n?n.index+1:r.length}function x(){return{source:"browser-ooxml"}}function pt(e,t){let r=hr(e.selection);if(!r)return null;let o=t.ooxml.get(r);if(!o)return null;let n=ut(e,o.path),c=t.ooxml.getById(o.objectId);if(!c)return n?null:o;let d=ut(e,c.path);return n?d?null:c:d?o:c}function xe(e,t){if(t)return pt(e.state,t);let r=e,o=dt(r);return o?pt(o.state,r.documentApi):null}function S(e,t,r){let o=xe(e,t);return o?.family===r?o:null}function b(e){return{changed:!1,reason:`No advanced OOXML ${e} node is selected.`}}function xr(e,t,r){let o=xe(e,t);return o?e.trackingEnabled?t.ooxml.updateTracked(o.path,r,e.participant,x()):t.ooxml.update(o.path,r):{changed:!1,reason:"No advanced OOXML node is selected."}}function yr(e,t){let r=xe(e,t);return r?e.trackingEnabled?t.ooxml.removeTracked(r.path,e.participant,x()):t.ooxml.remove(r.path):{changed:!1,reason:"No advanced OOXML node is selected."}}function Sr(e,t,r,o={}){let n=ke(e);return n?t.ooxml.math.appendInline(n,r,o):{changed:!1,reason:"Advanced OOXML math insertion requires an active text block selection."}}function br(e,t,r,o={},n={}){let c=ke(e);return c?t.ooxml.math.appendInlineTracked(c,r,e.participant,o,n):{changed:!1,reason:"Tracked math insertion requires an active text block selection."}}function gr(e,t,r){let o=S(e,t,"math");return o?e.trackingEnabled?t.ooxml.math.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.math.replaceModelById(o.objectId,r):b("math")}function Ar(e,t,r,o){let n=S(e,t,"math");return n?e.trackingEnabled?t.ooxml.math.setPlainTextByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.math.setPlainTextById(n.objectId,r,o):b("math")}function wr(e,t,r){let o=S(e,t,"math");return o?e.trackingEnabled?t.ooxml.math.setDisplayModeByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.math.setDisplayModeById(o.objectId,r):b("math")}function vr(e,t,r,o={}){return t.ooxml.charts.insertBlock(ie(e,t),r,o)}function Er(e,t,r,o={},n={}){return t.ooxml.charts.insertBlockTracked(ie(e,t),r,e.participant,o,n)}function Br(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.replaceModelById(o.objectId,r):b("chart")}function Cr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setMetadataByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setMetadataById(o.objectId,r):b("chart")}function Mr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setTitleByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setTitleById(o.objectId,r):b("chart")}function Ir(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setTextBodyByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setTextBodyById(o.objectId,r):b("chart")}function Or(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.appendSeriesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.appendSeriesById(o.objectId,r):b("chart")}function kr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setSeriesListByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setSeriesListById(o.objectId,r):b("chart")}function Tr(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.setSeriesByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.charts.setSeriesById(n.objectId,r,o):b("chart")}function Dr(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.upsertSeriesByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.charts.upsertSeriesById(n.objectId,r,o):b("chart")}function Nr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.removeSeriesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.removeSeriesById(o.objectId,r):b("chart")}function jr(e,t,r){return ft(e,t,r)}function Pr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setAxesByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setAxesById(o.objectId,r):b("chart")}function ft(e,t,r,o){let n=S(e,t,"chart");return n?e.trackingEnabled?t.ooxml.charts.upsertAxisByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.charts.upsertAxisById(n.objectId,r,o):b("chart")}function Rr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.removeAxisByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.removeAxisById(o.objectId,r):b("chart")}function Vr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setLegendByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setLegendById(o.objectId,r):b("chart")}function Lr(e,t,r){let o=S(e,t,"chart");return o?e.trackingEnabled?t.ooxml.charts.setPlotAreaByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.charts.setPlotAreaById(o.objectId,r):b("chart")}function Hr(e,t,r,o={}){return t.ooxml.shapes.insertBlock(ie(e,t),r,o)}function Fr(e,t,r,o={},n={}){return t.ooxml.shapes.insertBlockTracked(ie(e,t),r,e.participant,o,n)}function Ur(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.replaceModelByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.replaceModelById(o.objectId,r):b("shape")}function zr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setMetadataByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setMetadataById(o.objectId,r):b("shape")}function Wr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setWatermarkByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setWatermarkById(o.objectId,r):b("shape")}function Kr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setTextBodyByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setTextBodyById(o.objectId,r):b("shape")}function Gr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setGeometryByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setGeometryById(o.objectId,r):b("shape")}function qr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setTransformByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setTransformById(o.objectId,r):b("shape")}function Jr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setFillByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setFillById(o.objectId,r):b("shape")}function $r(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setStrokeByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setStrokeById(o.objectId,r):b("shape")}function Xr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setAnchorByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setAnchorById(o.objectId,r):b("shape")}function Yr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setConnectorByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setConnectorById(o.objectId,r):b("shape")}function _r(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setPictureByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setPictureById(o.objectId,r):b("shape")}function Zr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setWordArtByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setWordArtById(o.objectId,r):b("shape")}function Qr(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.setChildrenByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.setChildrenById(o.objectId,r):b("shape")}function eo(e,t,r,o){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.setChildByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.shapes.setChildById(n.objectId,r,o):b("shape")}function to(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.appendChildByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.appendChildById(o.objectId,r):b("shape")}function ro(e,t,r,o){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.appendChildToParentByIdTracked(n.objectId,r,o,e.participant,x()):t.ooxml.shapes.appendChildToParentById(n.objectId,r,o):b("shape")}function oo(e,t,r,o={}){let n=S(e,t,"shape");return n?e.trackingEnabled?t.ooxml.shapes.moveChildByIdTracked(n.objectId,r,e.participant,x(),o):t.ooxml.shapes.moveChildById(n.objectId,r,o):b("shape")}function no(e,t,r){let o=S(e,t,"shape");return o?e.trackingEnabled?t.ooxml.shapes.removeChildByIdTracked(o.objectId,r,e.participant,x()):t.ooxml.shapes.removeChildById(o.objectId,r):b("shape")}var Se="ald:advanced-ooxml-nodeview-action";function re(e){return typeof e=="object"&&e!==null}function xt(e){if(!re(e)||typeof e.family!="string"||typeof e.action!="string"||typeof e.objectId!="string")return!1;switch(e.action){case"replace-math-model":return e.family==="math"&&re(e.model);case"set-math-plain-text":return e.family==="math"&&typeof e.text=="string"&&(e.displayMode==="inline"||e.displayMode==="block");case"replace-chart-model":return e.family==="chart"&&re(e.model);case"replace-shape-model":return e.family==="shape"&&re(e.model);case"apply-math-edits":return e.family==="math"&&re(e.model)&&Array.isArray(e.edits);case"apply-chart-edits":return e.family==="chart"&&re(e.model)&&Array.isArray(e.edits);case"apply-shape-edits":return e.family==="shape"&&re(e.model)&&Array.isArray(e.edits);case"remove-advanced-ooxml":return e.family==="math"||e.family==="chart"||e.family==="shape";default:return!1}}function $(e,t){e.dispatchEvent(new CustomEvent(Se,{bubbles:!0,cancelable:!0,detail:t}))}import{readSyntheticSideStoryDocOriginPath as ao}from"@datalking/begonia-doc-service/v1";var io="Detached side-story surfaces are read-only. Route mutations through the host document controller.";function lo(e){return ao(e?.document??null)!=null}function co(e){return e?lo(e)?io:e.editable?null:"Document is read-only in the current document mode.":"Editor is not ready."}function yt(e){return co(e)==null}function St(e,t){return{surface:e,documentApi:t,context:{source:"browser-ooxml-nodeview"},runMutation(o,n){if(yt(e)){if(e.trackingEnabled){o();return}n()}}}}function le(e,t){e.runMutation(()=>{e.documentApi.ooxml.removeByIdTracked(t,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.removeById(t)})}function Te(e,t){switch(t.action){case"replace-chart-model":e.runMutation(()=>{e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.replaceModelById(t.objectId,t.model)});return;case"apply-chart-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-metadata":e.runMutation(()=>{e.documentApi.ooxml.charts.setMetadataByIdTracked(t.objectId,r,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setMetadataById(t.objectId,r)});return;case"set-text-body":e.runMutation(()=>{e.documentApi.ooxml.charts.setTextBodyByIdTracked(t.objectId,r.textBody,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setTextBodyById(t.objectId,r.textBody)});return;case"set-plot-area":e.runMutation(()=>{e.documentApi.ooxml.charts.setPlotAreaByIdTracked(t.objectId,r.plotArea,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setPlotAreaById(t.objectId,r.plotArea)});return;case"set-legend":e.runMutation(()=>{e.documentApi.ooxml.charts.setLegendByIdTracked(t.objectId,r.legend,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setLegendById(t.objectId,r.legend)});return;case"set-series":e.runMutation(()=>{e.documentApi.ooxml.charts.setSeriesByIdTracked(t.objectId,r.target,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setSeriesById(t.objectId,r.target,r.series)});return;case"set-series-list":e.runMutation(()=>{e.documentApi.ooxml.charts.setSeriesListByIdTracked(t.objectId,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setSeriesListById(t.objectId,r.series)});return;case"upsert-series":e.runMutation(()=>{e.documentApi.ooxml.charts.upsertSeriesByIdTracked(t.objectId,r.series,e.surface.participant,e.context,r.seriesId)},()=>{e.documentApi.ooxml.charts.upsertSeriesById(t.objectId,r.series,r.seriesId)});return;case"append-series":e.runMutation(()=>{e.documentApi.ooxml.charts.appendSeriesByIdTracked(t.objectId,r.series,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.appendSeriesById(t.objectId,r.series)});return;case"remove-series":e.runMutation(()=>{e.documentApi.ooxml.charts.removeSeriesByIdTracked(t.objectId,r.target,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.removeSeriesById(t.objectId,r.target)});return;case"set-axes":e.runMutation(()=>{e.documentApi.ooxml.charts.setAxesByIdTracked(t.objectId,r.axes,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.setAxesById(t.objectId,r.axes)});return;case"upsert-axis":e.runMutation(()=>{e.documentApi.ooxml.charts.upsertAxisByIdTracked(t.objectId,r.axis,e.surface.participant,e.context,r.axisId)},()=>{e.documentApi.ooxml.charts.upsertAxisById(t.objectId,r.axis,r.axisId)});return;case"remove-axis":e.runMutation(()=>{e.documentApi.ooxml.charts.removeAxisByIdTracked(t.objectId,r.axisId,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.removeAxisById(t.objectId,r.axisId)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.charts.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.charts.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":le(e,t.objectId);return}}function De(e,t){switch(t.action){case"replace-math-model":e.runMutation(()=>{e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.replaceModelById(t.objectId,t.model)});return;case"set-math-plain-text":e.runMutation(()=>{e.documentApi.ooxml.math.setPlainTextByIdTracked(t.objectId,t.text,e.surface.participant,e.context,t.displayMode)},()=>{e.documentApi.ooxml.math.setPlainTextById(t.objectId,t.text,t.displayMode)});return;case"apply-math-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-display-mode":e.runMutation(()=>{e.documentApi.ooxml.math.setDisplayModeByIdTracked(t.objectId,r.displayMode,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.setDisplayModeById(t.objectId,r.displayMode)});return;case"set-plain-text":e.runMutation(()=>{e.documentApi.ooxml.math.setPlainTextByIdTracked(t.objectId,r.text,e.surface.participant,e.context,r.displayMode)},()=>{e.documentApi.ooxml.math.setPlainTextById(t.objectId,r.text,r.displayMode)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.math.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.math.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":le(e,t.objectId);return}}function Ne(e,t){switch(t.action){case"replace-shape-model":e.runMutation(()=>{e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.replaceModelById(t.objectId,t.model)});return;case"apply-shape-edits":if(e.surface.trackingEnabled){e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,t.model,e.surface.participant,e.context);return}t.edits.forEach(r=>{switch(r.type){case"set-metadata":e.runMutation(()=>{e.documentApi.ooxml.shapes.setMetadataByIdTracked(t.objectId,r,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setMetadataById(t.objectId,r)});return;case"set-watermark":e.runMutation(()=>{e.documentApi.ooxml.shapes.setWatermarkByIdTracked(t.objectId,r.isWatermark,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setWatermarkById(t.objectId,r.isWatermark)});return;case"set-text-body":e.runMutation(()=>{e.documentApi.ooxml.shapes.setTextBodyByIdTracked(t.objectId,r.paragraphs,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setTextBodyById(t.objectId,r.paragraphs)});return;case"set-geometry":e.runMutation(()=>{e.documentApi.ooxml.shapes.setGeometryByIdTracked(t.objectId,r.geometry,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setGeometryById(t.objectId,r.geometry)});return;case"set-transform":e.runMutation(()=>{e.documentApi.ooxml.shapes.setTransformByIdTracked(t.objectId,r.transform,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setTransformById(t.objectId,r.transform)});return;case"set-fill":e.runMutation(()=>{e.documentApi.ooxml.shapes.setFillByIdTracked(t.objectId,r.fill,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setFillById(t.objectId,r.fill)});return;case"set-stroke":e.runMutation(()=>{e.documentApi.ooxml.shapes.setStrokeByIdTracked(t.objectId,r.stroke,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setStrokeById(t.objectId,r.stroke)});return;case"set-effects":e.runMutation(()=>{e.documentApi.ooxml.shapes.setEffectsByIdTracked(t.objectId,r.effects,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setEffectsById(t.objectId,r.effects)});return;case"set-anchor":e.runMutation(()=>{e.documentApi.ooxml.shapes.setAnchorByIdTracked(t.objectId,r.anchor,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setAnchorById(t.objectId,r.anchor)});return;case"set-children":e.runMutation(()=>{e.documentApi.ooxml.shapes.setChildrenByIdTracked(t.objectId,r.children,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setChildrenById(t.objectId,r.children)});return;case"set-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.setChildByIdTracked(t.objectId,r.target,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setChildById(t.objectId,r.target,r.child)});return;case"append-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.appendChildByIdTracked(t.objectId,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.appendChildById(t.objectId,r.child)});return;case"append-child-to-parent":e.runMutation(()=>{e.documentApi.ooxml.shapes.appendChildToParentByIdTracked(t.objectId,r.parentTarget,r.child,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.appendChildToParentById(t.objectId,r.parentTarget,r.child)});return;case"move-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.moveChildByIdTracked(t.objectId,r.target,e.surface.participant,e.context,{parentId:r.parentTarget,beforeId:r.beforeTarget})},()=>{e.documentApi.ooxml.shapes.moveChildById(t.objectId,r.target,{parentId:r.parentTarget,beforeId:r.beforeTarget})});return;case"remove-child":e.runMutation(()=>{e.documentApi.ooxml.shapes.removeChildByIdTracked(t.objectId,r.target,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.removeChildById(t.objectId,r.target)});return;case"set-connector":e.runMutation(()=>{e.documentApi.ooxml.shapes.setConnectorByIdTracked(t.objectId,r.connector,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setConnectorById(t.objectId,r.connector)});return;case"set-picture":e.runMutation(()=>{e.documentApi.ooxml.shapes.setPictureByIdTracked(t.objectId,r.picture,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setPictureById(t.objectId,r.picture)});return;case"set-word-art":e.runMutation(()=>{e.documentApi.ooxml.shapes.setWordArtByIdTracked(t.objectId,r.wordArt,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.setWordArtById(t.objectId,r.wordArt)});return;case"replace-model":e.runMutation(()=>{e.documentApi.ooxml.shapes.replaceModelByIdTracked(t.objectId,r.model,e.surface.participant,e.context)},()=>{e.documentApi.ooxml.shapes.replaceModelById(t.objectId,r.model)});return}});return;case"remove-advanced-ooxml":le(e,t.objectId);return}}function so(e,t){let r=St(e,t),o=e.view?.dom??null;if(!o)return()=>{};let n=c=>{let d=c instanceof CustomEvent?c.detail:null;if(xt(d))switch(c.preventDefault(),c.stopPropagation(),d.family){case"math":if(d.action==="remove-advanced-ooxml"){De(r,{family:"math",action:d.action,objectId:d.objectId});return}De(r,d);return;case"chart":if(d.action==="remove-advanced-ooxml"){Te(r,{family:"chart",action:d.action,objectId:d.objectId});return}Te(r,d);return;case"shape":if(d.action==="remove-advanced-ooxml"){Ne(r,{family:"shape",action:d.action,objectId:d.objectId});return}Ne(r,d);return}};return o.addEventListener(Se,n),()=>{o.removeEventListener(Se,n)}}import{normalizeOoxmlChartModel as Io}from"@datalking/begonia-engine";import{Schema as uo}from"prosemirror-model";import{EditorState as po}from"prosemirror-state";import{EditorView as mo}from"prosemirror-view";var ho=["display:grid","gap:8px","padding:10px","border:1px solid #dbe3ea","border-radius:12px","background:#f8fafc"].join(";"),fo=["font-size:11px","font-weight:700","letter-spacing:0.08em","text-transform:uppercase","color:#334155"].join(";"),xo=["display:grid","gap:8px","padding-left:8px"].join(";"),yo=["display:grid","gap:4px"].join(";"),So=["font-size:11px","font-weight:600","letter-spacing:0.06em","text-transform:uppercase","color:#64748b"].join(";"),bo=["min-height:36px","padding:8px 10px","border:1px solid #cbd5e1","border-radius:10px","background:#ffffff","font-size:12px","color:#0f172a","white-space:pre-wrap"].join(";"),go=["display:grid","gap:10px","outline:none"].join(";"),W=new uo({nodes:{doc:{content:"entry*"},section:{group:"entry",content:"entry*",attrs:{key:{default:""},label:{default:"Section"}},parseDOM:[{tag:"section[data-ald-structured-section]",getAttrs:e=>{let t=e;return{key:t.dataset.key??"",label:t.dataset.label??"Section"}}}],toDOM(e){return["section",{"data-ald-structured-section":"true","data-key":e.attrs.key,"data-label":e.attrs.label,style:ho},["div",{style:fo},e.attrs.label],["div",{style:xo},0]]}},field:{group:"entry",content:"text*",marks:"",parseDOM:[{tag:"div[data-ald-structured-field]",getAttrs:e=>{let t=e;return{key:t.dataset.key??"",label:t.dataset.label??"Field"}}}],toDOM(e){return["div",{"data-ald-structured-field":"true","data-key":e.attrs.key,"data-label":e.attrs.label,style:yo},["div",{style:So},e.attrs.label],["div",{style:bo},0]]}},text:{}}});function Ao(e){return W.nodes.field.create({key:e.key,label:e.label},e.value?W.text(e.value):void 0)}function wo(e){let t=e.children.map(je);return W.nodes.section.create({key:e.key,label:e.label},t)}function je(e){return e.type==="field"?Ao(e):wo(e)}function vo(e){return W.nodes.doc.create(null,e.map(je))}function bt(e){return e.content.content.map(t=>wt(t)).filter(t=>t!==null)}function wt(e){return e.type===W.nodes.field?{type:"field",key:String(e.attrs.key??""),label:String(e.attrs.label??"Field"),value:e.textContent}:e.type===W.nodes.section?{type:"section",key:String(e.attrs.key??""),label:String(e.attrs.label??"Section"),children:e.content.content.map(t=>wt(t)).filter(t=>t!==null)}:null}function gt(e){return po.create({schema:W,doc:vo(e)})}function Eo(e){let{$from:t}=e.selection;for(let r=t.depth;r>0;r-=1)if(t.node(r).type===W.nodes.section)return t.end(r)-1;return e.doc.content.size}function Bo(e){let{$from:t}=e.selection;for(let r=t.depth;r>0;r-=1){let o=t.node(r);if(o.type===W.nodes.field||o.type===W.nodes.section)return{from:t.before(r),to:t.before(r)+o.nodeSize}}return null}function At(e){let{$from:t}=e.selection,r=[],o=e.doc;for(let n=1;n<=t.depth;n+=1){if(t.node(n).type!==W.nodes.section)continue;let c=String(t.node(n).attrs.key??"").trim();c.length>0&&r.push(c),o=t.node(n)}return{sectionKeys:r,containerKey:r[r.length-1]??null,childKeys:o.content.content.map(n=>String(n.attrs.key??"").trim()).filter(n=>n.length>0)}}function Co(e){Object.assign(e.style,{display:"grid",gap:"10px",padding:"10px",borderRadius:"12px",border:"1px solid #dbe3ea",background:"#ffffff",minHeight:"160px",boxSizing:"border-box",overflow:"auto"})}function a(e,t,r=""){return{type:"field",key:e,label:t,value:r}}function l(e,t,r=[]){return{type:"section",key:e,label:t,children:[...r]}}function ce(e,t,r={}){Co(e);let o,n=()=>{r.onSelectionChange?.(At(o.state))};return o=new mo(e,{dispatchTransaction(c){let d=o.state.apply(c);o.updateState(d),c.docChanged&&r.onChange?.({entries:bt(d.doc)}),(c.docChanged||c.selectionSet)&&n()},state:gt(t),attributes:{style:go,class:"ald-advanced-ooxml-subtree-editor"}}),n(),{dom:e,appendEntry(c){let d=je(c),u=Eo(o.state);o.dispatch(o.state.tr.insert(u,d)),o.focus()},destroy(){o.destroy()},focus(){o.focus()},readEntries(){return bt(o.state.doc)},readSelection(){return At(o.state)},removeSelectedEntry(){let c=Bo(o.state);return c?(o.dispatch(o.state.tr.delete(c.from,c.to)),o.focus(),!0):!1},setEntries(c){o.updateState(gt(c)),n()}}}function h(e){let t=e.trim();return t.length>0?t:null}function v(e){let t=e.trim();if(!t)return null;let r=Number(t);return Number.isFinite(r)?r:null}function M(e){let t=e.trim().toLowerCase();return t==="true"?!0:t==="false"?!1:null}function D(e){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function N(e){return e==null?"":JSON.stringify(e,null,2)}function i(e,t){let r=e.find(o=>o.type==="field"&&o.key===t);return r?.type==="field"?r.value:""}function z(e,t){return e.filter(r=>r.type==="section"&&r.key===t)}function Pe(e,t){return z(e,t)[0]??null}function vt(e){return e.type==="field"?e.value.trim().length>0:e.children.some(t=>vt(t))}function Mo(e){return e.some(t=>vt(t))}function j(e,t){let r=Pe(e,t);return r&&Mo(r.children)?r:null}function se(e,t,r){let o=r?.paragraphs?.length?r.paragraphs:r?.plainText?[r.plainText]:[];return l(e,t,(o.length>0?o:[""]).map(n=>a("paragraph","Paragraph",n)))}function be(e){if(!e)return null;let t=e.children.filter(r=>r.type==="field"&&r.key==="paragraph").map(r=>r.value);return t.length===0?null:{paragraphs:t,plainText:t.join(`
2
+ `)}}function ge(e,t){return l(e,t,[a("paragraph","Paragraph","")])}function Oo(e){return l("marker","Marker",[a("symbol","Symbol",e.marker?.symbol??""),a("size","Size",e.marker?.size==null?"":String(e.marker.size))])}function ko(e){return l("data-labels","Data Labels",[a("show-value","Show Value",e.dataLabels?.showValue==null?"":String(e.dataLabels.showValue)),a("show-category","Show Category",e.dataLabels?.showCategory==null?"":String(e.dataLabels.showCategory)),a("show-series-name","Show Series Name",e.dataLabels?.showSeriesName==null?"":String(e.dataLabels.showSeriesName)),a("show-percentage","Show Percentage",e.dataLabels?.showPercentage==null?"":String(e.dataLabels.showPercentage)),a("position","Position",e.dataLabels?.position??""),a("separator","Separator",e.dataLabels?.separator??"")])}function To(e){return l("series","Series",[a("id","Series Id",e.id??""),a("order","Order",e.order==null?"":String(e.order)),a("name","Name",e.name??""),a("categories","Categories",e.categories.join(", ")),a("values","Values",e.values.map(t=>t==null?"":String(t)).join(", ")),a("color","Color",e.color??""),a("smooth","Smooth",e.smooth==null?"":String(e.smooth)),a("explosion","Explosion",e.explosion==null?"":String(e.explosion)),Oo(e),ko(e)])}function Do(e){return l("axis","Axis",[a("id","Axis Id",e.id??""),a("kind","Kind",e.kind??""),a("title","Title",e.title??""),a("format-code","Format Code",e.formatCode??""),a("orientation","Orientation",e.orientation??""),a("visible","Visible",e.visible==null?"":String(e.visible)),a("minimum","Minimum",e.minimum==null?"":String(e.minimum)),a("maximum","Maximum",e.maximum==null?"":String(e.maximum)),a("major-unit","Major Unit",e.majorUnit==null?"":String(e.majorUnit)),a("minor-unit","Minor Unit",e.minorUnit==null?"":String(e.minorUnit)),a("crosses-at","Crosses At",e.crossesAt==null?"":String(e.crossesAt)),a("major-gridlines","Major Gridlines",e.majorGridlines==null?"":String(e.majorGridlines)),a("minor-gridlines","Minor Gridlines",e.minorGridlines==null?"":String(e.minorGridlines))])}function No(e){return l("legend","Legend",[a("visible","Visible",e.legend==null?"":String(e.legend.visible)),a("position","Position",e.legend?.position??""),a("overlay","Overlay",e.legend?.overlay==null?"":String(e.legend.overlay))])}function jo(e){return l("plot-area","Plot Area",[a("stacked","Stacked",e.plotArea?.stacked==null?"":String(e.plotArea.stacked)),a("percent-stacked","Percent Stacked",e.plotArea?.percentStacked==null?"":String(e.plotArea.percentStacked)),a("vary-colors","Vary Colors",e.plotArea?.varyColors==null?"":String(e.plotArea.varyColors)),a("hole-size","Hole Size",e.plotArea?.holeSize==null?"":String(e.plotArea.holeSize))])}function Po(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Ro(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{let r=Number(t);return Number.isFinite(r)?r:null})}function Vo(e){return e.length>0?e:null}function Lo(e){let t=j(e,"marker"),r=j(e,"data-labels");return{id:h(i(e,"id")),order:v(i(e,"order")),name:h(i(e,"name")),categories:Po(i(e,"categories")),values:Ro(i(e,"values")),color:h(i(e,"color")),marker:t?{symbol:h(i(t.children,"symbol"))??"unknown",size:v(i(t.children,"size"))}:null,dataLabels:r?{showValue:M(i(r.children,"show-value")),showCategory:M(i(r.children,"show-category")),showSeriesName:M(i(r.children,"show-series-name")),showPercentage:M(i(r.children,"show-percentage")),position:h(i(r.children,"position")),separator:Vo(i(r.children,"separator"))}:null,smooth:M(i(e,"smooth")),explosion:v(i(e,"explosion"))}}function Ho(e){let t=i(e,"kind"),r=i(e,"orientation");return{id:h(i(e,"id")),kind:t==="category"||t==="value"||t==="series"||t==="date"?t:"unknown",title:h(i(e,"title")),formatCode:h(i(e,"format-code")),orientation:r==="minMax"||r==="maxMin"?r:null,visible:M(i(e,"visible")),minimum:v(i(e,"minimum")),maximum:v(i(e,"maximum")),majorUnit:v(i(e,"major-unit")),minorUnit:v(i(e,"minor-unit")),crossesAt:v(i(e,"crosses-at")),majorGridlines:M(i(e,"major-gridlines")),minorGridlines:M(i(e,"minor-gridlines"))}}function Re(e){return[a("title","Title",e.title??""),a("chart-type","Chart Type",e.chartType??""),a("subtitle","Subtitle",e.subtitle??""),se("text-body","Text Body",e.textBody),jo(e),...e.series.map(t=>To(t)),...e.axes.map(t=>Do(t)),No(e)]}function Ve(e,t){let r=j(e,"text-body"),o=j(e,"plot-area"),n=j(e,"legend");return Io({...t,title:h(i(e,"title")),chartType:h(i(e,"chart-type")),subtitle:h(i(e,"subtitle")),textBody:be(r),plotArea:o?{stacked:M(i(o.children,"stacked")),percentStacked:M(i(o.children,"percent-stacked")),varyColors:M(i(o.children,"vary-colors")),holeSize:v(i(o.children,"hole-size"))}:null,series:z(e,"series").map(c=>Lo(c.children)),axes:z(e,"axis").map(c=>Ho(c.children)),legend:n?{visible:M(i(n.children,"visible"))!==!1,position:h(i(n.children,"position"))??"unknown",overlay:M(i(n.children,"overlay"))}:null},t.title??"Chart")}function Fo(){return l("series","Series",[a("id","Series Id",""),a("order","Order",""),a("name","Name",""),a("categories","Categories",""),a("values","Values",""),a("color","Color",""),a("smooth","Smooth",""),a("explosion","Explosion",""),l("marker","Marker",[a("symbol","Symbol",""),a("size","Size","")]),l("data-labels","Data Labels",[a("show-value","Show Value",""),a("show-category","Show Category",""),a("show-series-name","Show Series Name",""),a("show-percentage","Show Percentage",""),a("position","Position",""),a("separator","Separator","")])])}function Uo(){return l("axis","Axis",[a("id","Axis Id",""),a("kind","Kind","category"),a("title","Title",""),a("format-code","Format Code",""),a("orientation","Orientation",""),a("visible","Visible",""),a("minimum","Minimum",""),a("maximum","Maximum",""),a("major-unit","Major Unit",""),a("minor-unit","Minor Unit",""),a("crosses-at","Crosses At",""),a("major-gridlines","Major Gridlines",""),a("minor-gridlines","Minor Gridlines","")])}function zo(){return l("legend","Legend",[a("visible","Visible","true"),a("position","Position","right"),a("overlay","Overlay","")])}function Wo(){return l("plot-area","Plot Area",[a("stacked","Stacked",""),a("percent-stacked","Percent Stacked",""),a("vary-colors","Vary Colors",""),a("hole-size","Hole Size","")])}function Ko(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function Go(e){return new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))}function qo(e){return e==null}function Et(e={}){let t=Ko(e.containerKey),r=Go(e.childKeys),o=n=>r.has(n);return t==="text-body"?[{label:"Paragraph",createEntry:()=>a("paragraph","Paragraph","")}]:qo(t)?[{label:"Series",createEntry:Fo},{label:"Axis",createEntry:Uo},...o("legend")?[]:[{label:"Legend",createEntry:zo}],...o("plot-area")?[]:[{label:"Plot Area",createEntry:Wo}],...o("text-body")?[]:[{label:"Text Body",createEntry:()=>ge("text-body","Text Body")}]]:[]}import{normalizeOoxmlMathModel as vn}from"@datalking/begonia-engine";import{createOoxmlMathTextNode as Jo}from"@datalking/begonia-engine";var $o=new Set(["numerator","denominator","body","degree","base","superscript-slot","subscript-slot","lower","upper","name","argument","matrix-cell","equation-row"]);function Le(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function Bt(e){let t=Le(e);return t==null||$o.has(t)}function He(e){return Jo(e)}function Fe(){return He("")}function Xo(e=""){return a("text","Text",e)}function C(e,t){return l(e,t,[Xo()])}function Ct(e){throw new Error(`Unsupported math node type: ${JSON.stringify(e)}.`)}function P(e){return Bt(e)}function Yo(){return l("fraction","Fraction",[C("numerator","Numerator"),C("denominator","Denominator")])}function _o(){return l("radical","Radical",[C("body","Body"),l("degree","Degree",[])])}function Zo(){return l("superscript","Superscript",[C("base","Base"),C("superscript-slot","Superscript")])}function Qo(){return l("subscript","Subscript",[C("base","Base"),C("subscript-slot","Subscript")])}function en(){return l("subsup","Subscript and Superscript",[C("base","Base"),C("subscript-slot","Subscript"),C("superscript-slot","Superscript")])}function tn(){return l("preSubSup","Pre-Sub/Superscript",[C("base","Base"),C("subscript-slot","Subscript"),C("superscript-slot","Superscript")])}function rn(){return l("matrix","Matrix",[l("matrix-row","Row",[l("matrix-cell","Cell",[a("text","Text","")])])])}function on(){return l("equationArray","Equation Array",[l("equation-row","Row",[a("text","Text","")])])}function nn(){return l("delimiter","Delimiter",[a("begin","Begin Delimiter","("),a("end","End Delimiter",")"),C("body","Body")])}function an(){return l("operator","Operator",[a("operator-symbol","Operator","sum"),C("body","Body"),l("lower","Lower",[]),l("upper","Upper",[])])}function ln(){return l("nary","N-ary Operator",[a("operator-symbol","Operator","prod"),C("body","Body"),l("subscript-slot","Subscript",[]),l("superscript-slot","Superscript",[])])}function cn(){return l("limitLower","Lower Limit",[C("base","Base"),C("lower","Lower")])}function sn(){return l("limitUpper","Upper Limit",[C("base","Base"),C("upper","Upper")])}function dn(){return l("function","Function",[C("name","Name"),C("argument","Argument")])}function un(){return l("accent","Accent",[a("accent-symbol","Accent","hat"),C("body","Body")])}function pn(){return l("bar","Bar",[a("bar-position","Position","top"),C("body","Body")])}function mn(){return l("box","Box",[a("border-box","Border Box","true"),C("body","Body")])}function hn(){return l("groupCharacter","Group Character",[a("group-character","Character","_"),a("group-position","Position","bottom"),C("body","Body")])}function fn(){return l("phantom","Phantom",[a("zero-width","Zero Width","false"),a("zero-ascent","Zero Ascent","false"),a("zero-descent","Zero Descent","false"),a("transparent","Transparent","true"),C("body","Body")])}function xn(){return l("matrix-row","Row",[l("matrix-cell","Cell",[a("text","Text","")])])}function yn(){return l("matrix-cell","Cell",[a("text","Text","")])}function Sn(){return l("equation-row","Row",[a("text","Text","")])}var bn=[{label:"Text",createEntry:()=>a("text","Text",""),supportsContainer:P},{label:"Fraction",createEntry:Yo,supportsContainer:P},{label:"Radical",createEntry:_o,supportsContainer:P},{label:"Superscript",createEntry:Zo,supportsContainer:P},{label:"Subscript",createEntry:Qo,supportsContainer:P},{label:"Sub+Sup",createEntry:en,supportsContainer:P},{label:"Pre-Sub/Sup",createEntry:tn,supportsContainer:P},{label:"Matrix",createEntry:rn,supportsContainer:P},{label:"Matrix Row",createEntry:xn,supportsContainer:e=>e==="matrix"},{label:"Matrix Cell",createEntry:yn,supportsContainer:e=>e==="matrix-row"},{label:"Equation Array",createEntry:on,supportsContainer:P},{label:"Equation Row",createEntry:Sn,supportsContainer:e=>e==="equationArray"},{label:"Delimiter",createEntry:nn,supportsContainer:P},{label:"Operator",createEntry:an,supportsContainer:P},{label:"N-ary",createEntry:ln,supportsContainer:P},{label:"Lower Limit",createEntry:cn,supportsContainer:P},{label:"Upper Limit",createEntry:sn,supportsContainer:P},{label:"Function",createEntry:dn,supportsContainer:P},{label:"Accent",createEntry:un,supportsContainer:P},{label:"Bar",createEntry:pn,supportsContainer:P},{label:"Box",createEntry:mn,supportsContainer:P},{label:"Group Char",createEntry:hn,supportsContainer:P},{label:"Phantom",createEntry:fn,supportsContainer:P}];function Ue(e={}){let t=Le(e.containerKey);return bn.filter(r=>r.supportsContainer(t)).map(({label:r,createEntry:o})=>({label:r,createEntry:o}))}function B(e,t){return Pe(e,t)?.children??[]}function gn(e){let t=e.map(r=>wn(r)).filter(r=>r!==null);return t.length===0?Fe():t.length===1?t[0]:{type:"sequence",items:t}}function Ae(e){return e.length>0?E(e):null}function An(e){let t=z(e,"matrix-cell").map(r=>E(r.children));return t.length>0?t:[Fe()]}function wn(e){if(e.type==="field")return e.key==="text"?He(e.value):null;switch(e.key){case"fraction":return{type:"fraction",numerator:E(B(e.children,"numerator")),denominator:E(B(e.children,"denominator"))};case"radical":{let t=B(e.children,"degree");return{type:"radical",body:E(B(e.children,"body")),degree:t.length>0?E(t):null}}case"superscript":return{type:"superscript",base:E(B(e.children,"base")),superscript:E(B(e.children,"superscript-slot"))};case"subscript":return{type:"subscript",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot"))};case"subsup":return{type:"subsup",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot")),superscript:E(B(e.children,"superscript-slot"))};case"preSubSup":return{type:"preSubSup",base:E(B(e.children,"base")),subscript:E(B(e.children,"subscript-slot")),superscript:E(B(e.children,"superscript-slot"))};case"matrix":return{type:"matrix",rows:z(e.children,"matrix-row").map(t=>An(t.children))};case"equationArray":return{type:"equationArray",rows:z(e.children,"equation-row").map(t=>E(t.children))};case"delimiter":return{type:"delimiter",begin:h(i(e.children,"begin")),end:h(i(e.children,"end")),body:E(B(e.children,"body"))};case"operator":return{type:"operator",operator:h(i(e.children,"operator-symbol")),body:E(B(e.children,"body")),lower:Ae(B(e.children,"lower")),upper:Ae(B(e.children,"upper"))};case"nary":return{type:"nary",operator:h(i(e.children,"operator-symbol")),body:E(B(e.children,"body")),subscript:Ae(B(e.children,"subscript-slot")),superscript:Ae(B(e.children,"superscript-slot"))};case"limitLower":return{type:"limitLower",base:E(B(e.children,"base")),lower:E(B(e.children,"lower"))};case"limitUpper":return{type:"limitUpper",base:E(B(e.children,"base")),upper:E(B(e.children,"upper"))};case"function":return{type:"function",name:E(B(e.children,"name")),argument:E(B(e.children,"argument"))};case"accent":return{type:"accent",accent:h(i(e.children,"accent-symbol")),body:E(B(e.children,"body"))};case"bar":{let t=i(e.children,"bar-position").trim().toLowerCase();return{type:"bar",position:t==="top"||t==="bottom"?t:"unknown",body:E(B(e.children,"body"))}}case"box":return{type:"box",body:E(B(e.children,"body")),borderBox:M(i(e.children,"border-box"))};case"groupCharacter":{let t=i(e.children,"group-position").trim().toLowerCase();return{type:"groupCharacter",character:h(i(e.children,"group-character")),position:t==="top"||t==="bottom"?t:"unknown",body:E(B(e.children,"body"))}}case"phantom":return{type:"phantom",body:E(B(e.children,"body")),zeroWidth:M(i(e.children,"zero-width")),zeroAscent:M(i(e.children,"zero-ascent")),zeroDescent:M(i(e.children,"zero-descent")),transparent:M(i(e.children,"transparent"))};default:return e.children.length>0?E(e.children):null}}function E(e){return gn(e)}function w(e){switch(e.type){case"sequence":return e.items.flatMap(t=>w(t));case"text":return[a("text","Text",e.value)];case"fraction":return[l("fraction","Fraction",[l("numerator","Numerator",w(e.numerator)),l("denominator","Denominator",w(e.denominator))])];case"radical":return[l("radical","Radical",[l("body","Body",w(e.body)),l("degree","Degree",e.degree?w(e.degree):[])])];case"superscript":return[l("superscript","Superscript",[l("base","Base",w(e.base)),l("superscript-slot","Superscript",w(e.superscript))])];case"subscript":return[l("subscript","Subscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript))])];case"subsup":return[l("subsup","Subscript and Superscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript)),l("superscript-slot","Superscript",w(e.superscript))])];case"preSubSup":return[l("preSubSup","Pre-Sub/Superscript",[l("base","Base",w(e.base)),l("subscript-slot","Subscript",w(e.subscript)),l("superscript-slot","Superscript",w(e.superscript))])];case"matrix":return[l("matrix","Matrix",e.rows.map(t=>l("matrix-row","Row",t.map(r=>l("matrix-cell","Cell",w(r))))))];case"equationArray":return[l("equationArray","Equation Array",e.rows.map(t=>l("equation-row","Row",w(t))))];case"delimiter":return[l("delimiter","Delimiter",[a("begin","Begin Delimiter",e.begin??""),a("end","End Delimiter",e.end??""),l("body","Body",w(e.body))])];case"operator":return[l("operator","Operator",[a("operator-symbol","Operator",e.operator??""),l("body","Body",w(e.body)),l("lower","Lower",e.lower?w(e.lower):[]),l("upper","Upper",e.upper?w(e.upper):[])])];case"nary":return[l("nary","N-ary Operator",[a("operator-symbol","Operator",e.operator??""),l("body","Body",w(e.body)),l("subscript-slot","Subscript",e.subscript?w(e.subscript):[]),l("superscript-slot","Superscript",e.superscript?w(e.superscript):[])])];case"limitLower":return[l("limitLower","Lower Limit",[l("base","Base",w(e.base)),l("lower","Lower",w(e.lower))])];case"limitUpper":return[l("limitUpper","Upper Limit",[l("base","Base",w(e.base)),l("upper","Upper",w(e.upper))])];case"function":return[l("function","Function",[l("name","Name",w(e.name)),l("argument","Argument",w(e.argument))])];case"accent":return[l("accent","Accent",[a("accent-symbol","Accent",e.accent??""),l("body","Body",w(e.body))])];case"bar":return[l("bar","Bar",[a("bar-position","Position",e.position),l("body","Body",w(e.body))])];case"box":return[l("box","Box",[a("border-box","Border Box",e.borderBox==null?"":String(e.borderBox)),l("body","Body",w(e.body))])];case"groupCharacter":return[l("groupCharacter","Group Character",[a("group-character","Character",e.character??""),a("group-position","Position",e.position),l("body","Body",w(e.body))])];case"phantom":return[l("phantom","Phantom",[a("zero-width","Zero Width",e.zeroWidth==null?"":String(e.zeroWidth)),a("zero-ascent","Zero Ascent",e.zeroAscent==null?"":String(e.zeroAscent)),a("zero-descent","Zero Descent",e.zeroDescent==null?"":String(e.zeroDescent)),a("transparent","Transparent",e.transparent==null?"":String(e.transparent)),l("body","Body",w(e.body))])]}return Ct(e)}function ze(e){return[a("display-mode","Display Mode",e.displayMode),...w(e.root)]}function Mt(e){let r=i(e,"display-mode").trim().toLowerCase()==="block"?"block":"inline",o=e.filter(n=>!(n.type==="field"&&n.key==="display-mode"));return vn({displayMode:r,root:E(o)},"",r)}function It(e){return l("shape-child","Child Object",[a("kind","Kind",e.kind??""),a("id","Id",e.id??""),a("label","Label",e.label??""),se("text-body","Text Body",e.textBody),We(e.geometry),Ke(e.transform),Ge(e.groupTransform??null),qe(e.fill??null),Je(e.stroke??null),$e(e.effects??null),Xe(e.connector),Ye(e.picture),_e(e.wordArt),...e.children.map(t=>It(t))])}function We(e){return l("geometry","Geometry",[a("preset","Preset",e?.preset??""),a("custom-path-count","Custom Path Count",e?.customPathCount==null?"":String(e.customPathCount)),a("adjustments","Adjustments",e?.adjustments.join(", ")??""),a("custom-geometry-json","Custom Geometry JSON",N(e?.customGeometry??null))])}function Ke(e){return l("transform","Transform",[a("width-emu","Width (EMU)",e?.widthEmu==null?"":String(e.widthEmu)),a("height-emu","Height (EMU)",e?.heightEmu==null?"":String(e.heightEmu)),a("offset-x-emu","Offset X (EMU)",e?.offsetXEmu==null?"":String(e.offsetXEmu)),a("offset-y-emu","Offset Y (EMU)",e?.offsetYEmu==null?"":String(e.offsetYEmu)),a("rotation","Rotation",e?.rotation==null?"":String(e.rotation)),a("flip-h","Flip H",e?.flipH==null?"":String(e.flipH)),a("flip-v","Flip V",e?.flipV==null?"":String(e.flipV))])}function Ge(e){return l("group-transform","Group Transform",[a("child-offset-x-emu","Child Offset X (EMU)",e?.childOffsetXEmu==null?"":String(e.childOffsetXEmu)),a("child-offset-y-emu","Child Offset Y (EMU)",e?.childOffsetYEmu==null?"":String(e.childOffsetYEmu)),a("child-width-emu","Child Width (EMU)",e?.childWidthEmu==null?"":String(e.childWidthEmu)),a("child-height-emu","Child Height (EMU)",e?.childHeightEmu==null?"":String(e.childHeightEmu))])}function qe(e){return l("fill","Fill",[a("kind","Kind",e?.kind??""),a("color","Color",e?.color??""),a("secondary-color","Secondary Color",e?.secondaryColor??""),a("opacity","Opacity",e?.opacity==null?"":String(e.opacity)),a("gradient-angle","Gradient Angle",e?.gradientAngle==null?"":String(e.gradientAngle)),a("gradient-path","Gradient Path",e?.gradientPath??""),a("pattern-preset","Pattern Preset",e?.patternPreset??""),a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("color-source-json","Color Source JSON",N(e?.colorSource??null)),a("secondary-color-source-json","Secondary Color Source JSON",N(e?.secondaryColorSource??null)),a("gradient-stops-json","Gradient Stops JSON",e?N(e.gradientStops??[]):""),a("picture-fill-json","Picture Fill JSON",N(e?.pictureFill??null))])}function Je(e){return l("stroke","Stroke",[a("kind","Kind",e?.kind??""),a("color","Color",e?.color??""),a("width-emu","Width (EMU)",e?.widthEmu==null?"":String(e.widthEmu)),a("dash","Dash",e?.dash??""),a("cap","Cap",e?.cap??""),a("join","Join",e?.join??""),a("opacity","Opacity",e?.opacity==null?"":String(e.opacity)),a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("compound","Compound",e?.compound??""),a("color-source-json","Color Source JSON",N(e?.colorSource??null)),a("head-end-json","Head End JSON",N(e?.headEnd??null)),a("tail-end-json","Tail End JSON",N(e?.tailEnd??null))])}function $e(e){return l("effects","Effects",[a("style-ref-index","Style Ref Index",e?.styleRefIndex==null?"":String(e.styleRefIndex)),a("style-ref-color-source-json","Style Ref Color Source JSON",N(e?.styleRefColorSource??null)),a("effect-nodes-json","Effect Nodes JSON",e?N(e.effectNodes??[]):""),a("glow-json","Glow JSON",N(e?.glow??null)),a("outer-shadow-json","Outer Shadow JSON",N(e?.outerShadow??null)),a("inner-shadow-json","Inner Shadow JSON",N(e?.innerShadow??null)),a("soft-edge-json","Soft Edge JSON",N(e?.softEdge??null)),a("blur-json","Blur JSON",N(e?.blur??null)),a("reflection-json","Reflection JSON",N(e?.reflection??null)),a("preset-shadow-json","Preset Shadow JSON",N(e?.presetShadow??null)),a("effect-dag-json","Effect DAG JSON",N(e?.effectDag??null))])}function En(e){return l("anchor","Anchor",[a("kind","Kind",e?.kind??""),a("wrap","Wrap",e?.wrap??""),a("behind-doc","Behind Doc",e?.behindDoc==null?"":String(e.behindDoc)),a("allow-overlap","Allow Overlap",e?.allowOverlap==null?"":String(e.allowOverlap)),a("layout-in-cell","Layout In Cell",e?.layoutInCell==null?"":String(e.layoutInCell)),a("relative-height","Relative Height",e?.relativeHeight==null?"":String(e.relativeHeight)),a("dist-top-emu","Dist Top (EMU)",e?.distTopEmu==null?"":String(e.distTopEmu)),a("dist-bottom-emu","Dist Bottom (EMU)",e?.distBottomEmu==null?"":String(e.distBottomEmu)),a("dist-left-emu","Dist Left (EMU)",e?.distLeftEmu==null?"":String(e.distLeftEmu)),a("dist-right-emu","Dist Right (EMU)",e?.distRightEmu==null?"":String(e.distRightEmu)),a("position-h","Position H",e?.positionH??""),a("position-v","Position V",e?.positionV??""),a("offset-x-emu","Anchor Offset X (EMU)",e?.offsetXEmu==null?"":String(e.offsetXEmu)),a("offset-y-emu","Anchor Offset Y (EMU)",e?.offsetYEmu==null?"":String(e.offsetYEmu)),a("align-h","Align H",e?.alignH??""),a("align-v","Align V",e?.alignV??"")])}function Xe(e){return l("connector","Connector",[a("connector-type","Connector Type",e?.connectorType??""),a("begin-shape-id","Begin Shape Id",e?.beginShapeId??""),a("end-shape-id","End Shape Id",e?.endShapeId??"")])}function Ye(e){return l("picture","Picture",[a("src","Source",e?.src??""),a("alt","Alt",e?.alt??""),a("title","Title",e?.title??""),a("relationship-id","Relationship Id",e?.relationshipId??""),a("blip-fill-json","Blip Fill JSON",N(e?.blipFill??null)),a("hyperlink-url","Hyperlink URL",e?.hyperlink?.url??""),a("hyperlink-tooltip","Hyperlink Tooltip",e?.hyperlink?.tooltip??"")])}function _e(e){return l("word-art","WordArt",[a("text","Text",e?.text??""),a("preset","Preset",e?.preset??"")])}function we(e){return[a("label","Label",e.label??""),a("shape-type","Shape Type",e.shapeType??""),a("group-kind","Group Kind",e.groupKind??""),a("is-watermark","Is Watermark",e.isWatermark==null?"":String(e.isWatermark)),se("text-body","Text Body",e.textBody),We(e.geometry),Ke(e.transform),Ge(e.groupTransform??null),qe(e.fill),Je(e.stroke),$e(e.effects??null),En(e.anchor),Xe(e.connector),Ye(e.picture),_e(e.wordArt),...e.children.map(t=>It(t))]}function oe(e){return l("shape-child","Child Object",[a("kind","Kind",e),a("id","Id",""),a("label","Label",""),se("text-body","Text Body",null),We(null),Ke(null),Ge(null),qe(null),Je(null),$e(null),Xe(null),Ye(null),_e(null)])}function Bn(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:null}function Cn(e){return new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))}function Mn(){return[{label:"Child Shape",createEntry:()=>oe("shape")},{label:"Child Group",createEntry:()=>oe("group")},{label:"Text Box",createEntry:()=>oe("textBox")},{label:"Connector",createEntry:()=>oe("connector")},{label:"Picture",createEntry:()=>oe("picture")},{label:"WordArt",createEntry:()=>oe("wordArt")}]}function Ze(e={}){let t=Bn(e.containerKey),r=Cn(e.childKeys),o=(t==null||t==="shape-child")&&!r.has("text-body");return t==="text-body"?[{label:"Paragraph",createEntry:()=>a("paragraph","Paragraph","")}]:t!=null&&t!=="shape-child"?[]:[...o?[{label:"Text Body",createEntry:()=>ge("text-body","Text Body")}]:[],...Mn()]}import{normalizeOoxmlShapeModel as In}from"@datalking/begonia-engine";function On(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Ot(e){return{kind:h(i(e,"kind"))??"unknown",color:h(i(e,"color")),secondaryColor:h(i(e,"secondary-color")),opacity:v(i(e,"opacity")),gradientAngle:v(i(e,"gradient-angle")),gradientPath:h(i(e,"gradient-path")),patternPreset:h(i(e,"pattern-preset")),styleRefIndex:v(i(e,"style-ref-index")),colorSource:D(i(e,"color-source-json")),secondaryColorSource:D(i(e,"secondary-color-source-json")),gradientStops:D(i(e,"gradient-stops-json"))??[],pictureFill:D(i(e,"picture-fill-json"))}}function kt(e){return{kind:h(i(e,"kind"))??"unknown",color:h(i(e,"color")),widthEmu:v(i(e,"width-emu")),dash:h(i(e,"dash")),cap:h(i(e,"cap")),join:h(i(e,"join")),opacity:v(i(e,"opacity")),styleRefIndex:v(i(e,"style-ref-index")),compound:h(i(e,"compound")),colorSource:D(i(e,"color-source-json")),headEnd:D(i(e,"head-end-json")),tailEnd:D(i(e,"tail-end-json"))}}function Tt(e){return{styleRefIndex:v(i(e,"style-ref-index")),styleRefColorSource:D(i(e,"style-ref-color-source-json")),effectNodes:D(i(e,"effect-nodes-json"))??[],glow:D(i(e,"glow-json")),outerShadow:D(i(e,"outer-shadow-json")),innerShadow:D(i(e,"inner-shadow-json")),softEdge:D(i(e,"soft-edge-json")),blur:D(i(e,"blur-json")),reflection:D(i(e,"reflection-json")),presetShadow:D(i(e,"preset-shadow-json")),effectDag:D(i(e,"effect-dag-json"))}}function Dt(e){let t=j(e,"geometry");return t?{preset:h(i(t.children,"preset")),customPathCount:v(i(t.children,"custom-path-count")),adjustments:On(i(t.children,"adjustments")),customGeometry:D(i(t.children,"custom-geometry-json"))}:null}function Nt(e){let t=j(e,"transform");return t?{widthEmu:v(i(t.children,"width-emu")),heightEmu:v(i(t.children,"height-emu")),offsetXEmu:v(i(t.children,"offset-x-emu")),offsetYEmu:v(i(t.children,"offset-y-emu")),rotation:v(i(t.children,"rotation")),flipH:M(i(t.children,"flip-h")),flipV:M(i(t.children,"flip-v"))}:null}function jt(e){let t=j(e,"group-transform");return t?{childOffsetXEmu:v(i(t.children,"child-offset-x-emu")),childOffsetYEmu:v(i(t.children,"child-offset-y-emu")),childWidthEmu:v(i(t.children,"child-width-emu")),childHeightEmu:v(i(t.children,"child-height-emu"))}:null}function Pt(e){let t=j(e,"connector");return t?{connectorType:h(i(t.children,"connector-type")),beginShapeId:h(i(t.children,"begin-shape-id")),endShapeId:h(i(t.children,"end-shape-id"))}:null}function Rt(e){let t=j(e,"picture");if(!t)return null;let r=h(i(t.children,"hyperlink-url"));return{src:h(i(t.children,"src")),alt:h(i(t.children,"alt")),title:h(i(t.children,"title")),relationshipId:h(i(t.children,"relationship-id")),blipFill:D(i(t.children,"blip-fill-json")),hyperlink:r?{url:r,tooltip:h(i(t.children,"hyperlink-tooltip"))}:null}}function Vt(e){let t=j(e,"word-art");return t?{text:h(i(t.children,"text")),preset:h(i(t.children,"preset"))}:null}function Lt(e){return be(z(e,"text-body")[0]??null)}function kn(e){let t=j(e,"anchor");return t?{kind:h(i(t.children,"kind"))??"unknown",wrap:h(i(t.children,"wrap"))??"unknown",behindDoc:M(i(t.children,"behind-doc")),allowOverlap:M(i(t.children,"allow-overlap")),layoutInCell:M(i(t.children,"layout-in-cell")),relativeHeight:v(i(t.children,"relative-height")),distTopEmu:v(i(t.children,"dist-top-emu")),distBottomEmu:v(i(t.children,"dist-bottom-emu")),distLeftEmu:v(i(t.children,"dist-left-emu")),distRightEmu:v(i(t.children,"dist-right-emu")),positionH:h(i(t.children,"position-h")),positionV:h(i(t.children,"position-v")),offsetXEmu:v(i(t.children,"offset-x-emu")),offsetYEmu:v(i(t.children,"offset-y-emu")),alignH:h(i(t.children,"align-h")),alignV:h(i(t.children,"align-v"))}:null}function Tn(e){return e==="shape"||e==="group"||e==="textBox"||e==="connector"||e==="picture"||e==="wordArt"}function Ht(e){let t=j(e,"fill"),r=j(e,"stroke"),o=j(e,"effects"),n=i(e,"kind");return{kind:Tn(n)?n:"unknown",id:h(i(e,"id")),label:h(i(e,"label")),textBody:Lt(e),geometry:Dt(e),transform:Nt(e),groupTransform:jt(e),fill:t?Ot(t.children):null,stroke:r?kt(r.children):null,effects:o?Tt(o.children):null,connector:Pt(e),picture:Rt(e),wordArt:Vt(e),children:z(e,"shape-child").map(c=>Ht(c.children))}}function ve(e,t){let r=j(e,"fill"),o=j(e,"stroke"),n=j(e,"effects");return In({...t,label:h(i(e,"label")),shapeType:h(i(e,"shape-type")),groupKind:h(i(e,"group-kind")),isWatermark:M(i(e,"is-watermark")),textBody:Lt(e),geometry:Dt(e),transform:Nt(e),groupTransform:jt(e),fill:r?Ot(r.children):null,stroke:o?kt(o.children):null,effects:n?Tt(n.children):null,anchor:kn(e),connector:Pt(e),picture:Rt(e),wordArt:Vt(e),children:z(e,"shape-child").map(c=>Ht(c.children))},t.label??"Shape")}function I(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Dn(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function Z(e){return new Set(e).size===e.length}function ye(e,t){let r=new Set(t),o=e.filter(u=>r.has(u)),n=new Set(e),c=t.filter(u=>n.has(u));if(!Dn(o,c))return!1;let d=t.findIndex(u=>!n.has(u));return d===-1||t.slice(d).every(u=>!n.has(u))}function Ft(e){return e.map((t,r)=>t.id??`shape-child-${r+1}`)}function Ut(e,t){return I({...e,children:[]},{...t,children:[]})}function Qe(e,t,r){for(let o=0;o<e.length;o+=1){let n=e[o],c=n.id?.trim(),d=e[o+1]?.id?.trim()??null;if(!c||r.has(c)||e[o+1]&&!d||(r.set(c,{child:n,parentId:t,beforeId:d}),!Qe(n.children,c,r)))return!1}return!0}function Nn(e,t){return e.size===t.size&&[...t.keys()].every(r=>e.has(r))}function jn(e,t){return{...t,children:[...e.children]}}function zt(e,t,r){t.forEach(o=>{let n=o.id?.trim();if(!n)return;let c=e.get(n);c&&!Ut(c.child,o)&&r.push({type:"set-child",target:n,child:jn(c.child,o)}),zt(e,o.children,r)})}function Wt(e,t,r,o){let n=null;for(let c=t.length-1;c>=0;c-=1){let d=t[c],u=d.id?.trim();if(!u)continue;let p=e.get(u);p&&(p.parentId!==r||p.beforeId!==n)&&o.push({type:"move-child",target:u,parentTarget:r,beforeTarget:n}),Wt(e,d.children,u,o),n=u}}function Pn(e,t){let r=new Map,o=new Map;if(!Qe(e,null,r)||!Qe(t,null,o)||!Nn(r,o))return null;let n=[];return zt(r,t,n),Wt(r,t,null,n),n}function Rn(e,t,r){return t==null||r==null?[{type:"set-children",children:[...e]}]:[{type:"set-child",target:t,child:r}]}function Kt(e,t,r,o){if(I(e,t))return[];let n=Ft(e),c=Ft(t);if(!Z(n)||!Z(c)||!ye(n,c))return Rn(t,r,o);let d=new Map(e.map((y,g)=>[n[g],y])),u=new Map(t.map((y,g)=>[c[g],y])),p=[];for(let y=n.length-1;y>=0;y-=1){let g=n[y];u.has(g)||p.push({type:"remove-child",target:g})}return c.forEach(y=>{let g=u.get(y),m=d.get(y);if(!m){p.push(r==null?{type:"append-child",child:g}:{type:"append-child-to-parent",parentTarget:r,child:g});return}if(!Ut(m,g)){p.push({type:"set-child",target:y,child:g});return}p.push(...Kt(m.children,g.children,y,g))}),p}function Gt(e,t){if(I(e,t))return[];if(!I(e.groupTransform,t.groupTransform))return[{type:"replace-model",model:t}];let r=[];(e.label!==t.label||e.shapeType!==t.shapeType||e.groupKind!==t.groupKind)&&r.push({type:"set-metadata",label:t.label,shapeType:t.shapeType,groupKind:t.groupKind}),(e.isWatermark??!1)!==(t.isWatermark??!1)&&r.push({type:"set-watermark",isWatermark:t.isWatermark??!1}),I(e.textBody,t.textBody)||r.push({type:"set-text-body",paragraphs:t.textBody?.paragraphs?[...t.textBody.paragraphs]:[]}),I(e.geometry,t.geometry)||r.push({type:"set-geometry",geometry:t.geometry}),I(e.transform,t.transform)||r.push({type:"set-transform",transform:t.transform}),I(e.fill,t.fill)||r.push({type:"set-fill",fill:t.fill}),I(e.stroke,t.stroke)||r.push({type:"set-stroke",stroke:t.stroke}),I(e.effects,t.effects)||r.push({type:"set-effects",effects:t.effects??null}),I(e.anchor,t.anchor)||r.push({type:"set-anchor",anchor:t.anchor}),I(e.connector,t.connector)||r.push({type:"set-connector",connector:t.connector}),I(e.picture,t.picture)||r.push({type:"set-picture",picture:t.picture}),I(e.wordArt,t.wordArt)||r.push({type:"set-word-art",wordArt:t.wordArt});let o=Pn(e.children,t.children);return o?(r.push(...o),r):(r.push(...Kt(e.children,t.children,null,null)),r)}import{createOoxmlFamilyEnvelope as _t}from"@datalking/begonia-engine";function ne(){return{Element:typeof Element<"u"?Element:void 0,Node:typeof Node<"u"?Node:void 0,HTMLAnchorElement:typeof HTMLAnchorElement<"u"?HTMLAnchorElement:void 0,HTMLInputElement:typeof HTMLInputElement<"u"?HTMLInputElement:void 0,HTMLTextAreaElement:typeof HTMLTextAreaElement<"u"?HTMLTextAreaElement:void 0,HTMLSelectElement:typeof HTMLSelectElement<"u"?HTMLSelectElement:void 0,HTMLButtonElement:typeof HTMLButtonElement<"u"?HTMLButtonElement:void 0}}function et(e,t){if(!t)return!1;try{return e instanceof t}catch{return!1}}function qt(e){if(typeof e!="object"||e===null)return null;try{let t=e.nodeType;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return null}}function Vn(e){if(typeof e!="object"||e===null)return null;try{let t=e.localName;if(typeof t=="string"&&t.length>0)return t.toLowerCase();let r=e.tagName;return typeof r=="string"&&r.length>0?r.toLowerCase():null}catch{return null}}function de(e,t=ne()){if(et(e,t.Node))return!0;let r=qt(e);return r!==null&&r>=1&&r<=12}function Ln(e,t=ne()){return et(e,t.Element)?!0:qt(e)===1}function Ee(e,t,r,o){return et(e,r)?!0:Ln(e,o)&&Vn(e)===t}function Hn(e,t=ne()){return Ee(e,"input",t.HTMLInputElement,t)}function Fn(e,t=ne()){return Ee(e,"textarea",t.HTMLTextAreaElement,t)}function Un(e,t=ne()){return Ee(e,"select",t.HTMLSelectElement,t)}function zn(e,t=ne()){return Ee(e,"button",t.HTMLButtonElement,t)}function Jt(e,t=ne()){return Hn(e,t)||Fn(e,t)||Un(e,t)||zn(e,t)}function Wn(e,t){e.disabled=!t,e.style.opacity=t?"1":"0.65",e.style.cursor=t?"pointer":"default"}function Kn(e,t){e.textContent=t?"Local subtree edits pending. Leave this card or press Cmd/Ctrl+Enter to apply.":"Auto-applies when you leave this card. Apply is still available for an immediate commit.",e.style.color=t?"#0f766e":"#64748b",e.style.fontWeight=t?"600":"400"}function ue(e){let t=!1,r=!1,o=null,n=()=>{o!==null&&(window.clearTimeout(o),o=null)},c=()=>{Wn(e.applyButton,r),Kn(e.status,r)},d=()=>{if(n(),t||!r)return!1;try{let g=e.onCommit();return r=!1,c(),g}catch(g){throw c(),g}},u=()=>{t||!r||(n(),o=window.setTimeout(()=>{o=null,e.root.contains(document.activeElement)||d()},0))},p=()=>{u()},y=g=>{r&&(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),d())};return e.root.addEventListener("focusout",p),e.root.addEventListener("keydown",y),c(),{destroy(){t=!0,n(),e.root.removeEventListener("focusout",p),e.root.removeEventListener("keydown",y)},flush:d,markDirty(){t||r||(r=!0,c())},reset(){n(),r=!1,c()}}}function q(e,t){return Object.assign(e.style,t),e}function pe(e,t=!1){let r=document.createElement(e);return r.contentEditable="false",q(r,{display:t?"inline-flex":"grid",gap:"8px",padding:"10px",border:"1px solid #cbd5e1",borderRadius:"14px",background:"#f8fafc",margin:t?"0 4px":"8px 0",minWidth:t?"280px":"100%",boxSizing:"border-box",verticalAlign:"middle"}),r}function me(e,t){let r=document.createElement("div");q(r,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let o=document.createElement("strong");o.textContent=e,q(o,{fontSize:"12px",color:"#0f172a"});let n=document.createElement("span");return n.textContent=t,q(n,{fontSize:"11px",fontWeight:"600",color:"#475569",background:"#e2e8f0",borderRadius:"999px",padding:"2px 8px"}),r.append(o,n),{header:r,heading:o}}function he(){let e=document.createElement("div");return q(e,{fontSize:"11px",color:"#64748b"}),e}function ae(e){let t=document.createElement("section");q(t,{display:"grid",gap:"8px",padding:"10px",borderRadius:"12px",background:"#ffffff",border:"1px solid #e2e8f0"});let r=document.createElement("div");return r.textContent=e,q(r,{fontSize:"11px",fontWeight:"700",letterSpacing:"0.08em",textTransform:"uppercase",color:"#475569"}),t.append(r),{section:t,title:r}}function J(e){let t=document.createElement("div");return t.textContent=e,q(t,{fontSize:"11px",color:"#64748b"}),t}function X(){let e=document.createElement("div");return q(e,{display:"flex",gap:"8px",justifyContent:"flex-end",flexWrap:"wrap"}),e}function L(e,t="default"){let r=document.createElement("button");return r.type="button",r.textContent=e,q(r,{padding:"6px 12px",borderRadius:"999px",border:t==="danger"?"1px solid #fecaca":"1px solid #99f6e4",background:t==="danger"?"#fff1f2":"#f0fdfa",color:t==="danger"?"#be123c":"#0f766e",fontSize:"12px",fontWeight:"600",cursor:"pointer"}),r}function fe(e){return Jt(e)}import{listOoxmlChartAxisIds as $t,listOoxmlChartSeriesIds as Xt}from"@datalking/begonia-engine";function Gn(e,t){if(I(e.series,t.series))return[];let r=Xt(e),o=Xt(t);if(!Z(r)||!Z(o)||!ye(r,o))return[{type:"set-series-list",series:[...t.series]}];let n=new Map(e.series.map((u,p)=>[r[p],u])),c=new Map(t.series.map((u,p)=>[o[p],u])),d=[];for(let u=r.length-1;u>=0;u-=1){let p=r[u];c.has(p)||d.push({type:"remove-series",target:p})}return o.forEach(u=>{let p=c.get(u),y=n.get(u);if(!y){d.push({type:"append-series",series:p});return}I(y,p)||d.push({type:"set-series",target:u,series:p})}),d}function qn(e,t){if(I(e.axes,t.axes))return[];let r=$t(e),o=$t(t);if(!Z(r)||!Z(o)||!ye(r,o))return[{type:"set-axes",axes:[...t.axes]}];let n=new Map(e.axes.map((u,p)=>[r[p],u])),c=new Map(t.axes.map((u,p)=>[o[p],u])),d=[];for(let u=r.length-1;u>=0;u-=1){let p=r[u];c.has(p)||d.push({type:"remove-axis",axisId:p})}return o.forEach(u=>{let p=c.get(u),y=n.get(u);(!y||!I(y,p))&&d.push({type:"upsert-axis",axisId:u,axis:p})}),d}function Yt(e,t){if(I(e,t))return[];let r=[];return(e.title!==t.title||e.chartType!==t.chartType||e.subtitle!==t.subtitle)&&r.push({type:"set-metadata",title:t.title,chartType:t.chartType,subtitle:t.subtitle}),I(e.textBody,t.textBody)||r.push({type:"set-text-body",textBody:t.textBody}),I(e.plotArea,t.plotArea)||r.push({type:"set-plot-area",plotArea:t.plotArea}),I(e.legend,t.legend)||r.push({type:"set-legend",legend:t.legend}),r.push(...qn(e,t)),r.push(...Gn(e,t)),r}function tt(e){let t=String(e.attrs.label??"Chart"),r=String(e.attrs.text??""),o=_t("chart",{title:t,textBody:r?{plainText:r,paragraphs:[r]}:null},{label:t,text:r}),n=_t("chart",e.attrs.familyData,{label:t,text:r})??o;return{objectId:String(e.attrs.objectId??""),label:t,model:n.data.model??o.data.model,evidence:n.evidence}}function Jn(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%"}),e}function Zt(){return e=>{let t=e,r=pe("div"),{header:o,heading:n}=me("Chart","chart"),c=he(),{section:d}=ae("Native Subtree"),u=J("Edit chart metadata, series, axes, legend, and plot area as a structured nested tree. Use insert buttons at the current subtree selection. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),p=X();p.style.justifyContent="flex-start";let y=L("Remove Selected","danger"),g=Jn(),m=X();m.style.justifyContent="space-between",m.style.alignItems="center";let s=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),O=L("Apply"),G=L("Remove Chart","danger");s.style.marginRight="auto",m.append(s,O,G),d.append(u,p,g,y),r.append(o,c,d,m);let R=null,ee=(f,k)=>{p.replaceChildren(),Et({containerKey:f,childKeys:k}).forEach(F=>{let T=L(F.label);T.addEventListener("click",()=>{H.appendEntry(F.createEntry())}),p.append(T)})},H=ce(g,[],{onChange(){R?.markDirty()},onSelectionChange(f){ee(f.containerKey,f.childKeys)}});y.addEventListener("click",()=>{H.removeSelectedEntry()}),R=ue({applyButton:O,onCommit:()=>{let f=tt(t),k=Ve(H.readEntries(),f.model),F=Yt(f.model,k);return F.length===0?!1:($(r,{family:"chart",action:"apply-chart-edits",objectId:f.objectId,model:k,edits:F}),!0)},root:r,status:s});let te=f=>{t=f;let k=tt(f);n.textContent=k.label,c.textContent=`${k.evidence.chartType??"chart"} | ${k.evidence.seriesCount} series | ${k.evidence.axisCount} axes`,R?.reset(),H.setEntries(Re(k.model))};return O.addEventListener("click",()=>{R?.flush()}),G.addEventListener("click",()=>{R?.reset();let f=tt(t);$(r,{family:"chart",action:"remove-advanced-ooxml",objectId:f.objectId})}),te(e),{dom:r,destroy(){R?.destroy(),H.destroy()},update(f){return f.type!==t.type?!1:(te(f),!0)},stopEvent(f){return fe(f.target)||de(f.target)&&g.contains(f.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{createOoxmlFamilyEnvelope as er,normalizeOoxmlMathModel as $n}from"@datalking/begonia-engine";function Qt(e,t){if(I(e,t))return[];if(e.root.type==="text"&&t.root.type==="text"){let r=e.root.value,o=t.root.value;return r!==o?[{type:"set-plain-text",text:o,displayMode:t.displayMode}]:e.displayMode!==t.displayMode?[{type:"set-display-mode",displayMode:t.displayMode}]:[]}return t.root.type==="text"?[{type:"set-plain-text",text:t.root.value,displayMode:t.displayMode}]:I(e.root,t.root)&&e.displayMode!==t.displayMode?[{type:"set-display-mode",displayMode:t.displayMode}]:[{type:"replace-model",model:t}]}function rt(e){let t=String(e.attrs.text??""),r=String(e.attrs.label??"Equation"),o=er("math",{plainText:t,displayMode:"inline"},{label:r,text:t}),n=er("math",e.attrs.familyData,{label:r,text:t})??o,c=$n(n.data,n.data.plainText??t,n.data.displayMode??"inline");return{objectId:String(e.attrs.objectId??""),label:r,model:c,evidence:n.evidence}}function Xn(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%",maxWidth:"720px"}),e}function tr(){return e=>{let t=e,r=pe("span",!0);Object.assign(r.style,{display:"inline-grid",width:"min(720px, 100%)",verticalAlign:"top"});let{header:o,heading:n}=me("Equation","math"),c=he(),{section:d}=ae("Native Subtree"),u=J("Edit the equation as a nested ProseMirror tree. Insert structures into the selected slot. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),p=X();p.style.justifyContent="flex-start";let y=L("Remove Selected","danger"),g=Xn(),m=X();m.style.justifyContent="space-between",m.style.alignItems="center";let s=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),O=L("Apply"),G=L("Remove Equation","danger");s.style.marginRight="auto",m.append(s,O,G),d.append(u,p,g,y),r.append(o,c,d,m);let R=null,ee=f=>{p.replaceChildren(),Ue({containerKey:f}).forEach(k=>{let F=L(k.label);F.addEventListener("click",()=>{H.appendEntry(k.createEntry())}),p.append(F)})},H=ce(g,[],{onChange(){R?.markDirty()},onSelectionChange(f){ee(f.containerKey)}});y.addEventListener("click",()=>{H.removeSelectedEntry()}),R=ue({applyButton:O,onCommit:()=>{let f=rt(t),k=Mt(H.readEntries()),F=Qt(f.model,k);return F.length===0?!1:($(r,{family:"math",action:"apply-math-edits",objectId:f.objectId,model:k,edits:F}),!0)},root:r,status:s});let te=f=>{t=f;let k=rt(f);n.textContent=k.label,c.textContent=`${k.evidence.displayMode} | root ${k.evidence.rootType} | ${k.evidence.structureCount} structures`,R?.reset(),H.setEntries(ze(k.model))};return O.addEventListener("click",()=>{R?.flush()}),G.addEventListener("click",()=>{R?.reset();let f=rt(t);$(r,{family:"math",action:"remove-advanced-ooxml",objectId:f.objectId})}),te(e),{dom:r,destroy(){R?.destroy(),H.destroy()},update(f){return f.type!==t.type?!1:(te(f),!0)},stopEvent(f){return fe(f.target)||de(f.target)&&g.contains(f.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{createOoxmlFamilyEnvelope as rr,createOoxmlShapePreview as Yn}from"@datalking/begonia-engine";function ot(e){let t=String(e.attrs.label??"Shape"),r=String(e.attrs.text??""),o=rr("shape",{label:t,textBody:r?{plainText:r,paragraphs:[r]}:null},{label:t,text:r}),n=rr("shape",e.attrs.familyData,{label:t,text:r})??o;return{objectId:String(e.attrs.objectId??""),label:t,model:n.data.model??o.data.model,evidence:n.evidence}}function _n(){let e=document.createElement("div");return Object.assign(e.style,{width:"100%"}),e}function Zn(){let e=document.createElement("div");return Object.assign(e.style,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"84px",padding:"12px",borderRadius:"12px",background:"linear-gradient(180deg, #ffffff, #f8fafc)",border:"1px solid #e2e8f0"}),e}function Qn(e,t,r,o){let n=Yn(o,{idPrefix:t||r,maxWidth:280,maxHeight:180});return e.dataset.previewKind=n.kind,e.dataset.previewSupported=String(n.supported),e.innerHTML=n.svg,n}function or(){return e=>{let t=e,r=pe("div"),{header:o,heading:n}=me("Shape","shape"),c=he(),{section:d}=ae("Visual Preview"),u=J("Preview uses begonia\u2019s clean-room SVG geometry renderer for preset, connector, group, and custom-path shape families."),p=Zn(),{section:y}=ae("Native Subtree"),g=J("Edit the shape object graph, text boxes, connector data, pictures, and child objects in a nested ProseMirror subtree. Changes auto-apply when you leave the card or press Cmd/Ctrl+Enter."),m=X();m.style.justifyContent="flex-start";let s=L("Remove Selected","danger"),O=_n(),G=X();G.style.justifyContent="space-between",G.style.alignItems="center";let R=J("Auto-applies when you leave this card. Apply is still available for an immediate commit."),ee=L("Apply"),H=L("Remove Shape","danger");R.style.marginRight="auto",G.append(R,ee,H),d.append(u,p),y.append(g,m,O,s),r.append(o,c,d,y,G);let Y=null,te=(T,U)=>{m.replaceChildren(),Ze({containerKey:T,childKeys:U}).forEach(_=>{let ct=L(_.label);ct.addEventListener("click",()=>{f.appendEntry(_.createEntry())}),m.append(ct)})},f=ce(O,[],{onChange(){Y?.markDirty()},onSelectionChange(T){te(T.containerKey,T.childKeys)}});s.addEventListener("click",()=>{f.removeSelectedEntry()}),Y=ue({applyButton:ee,onCommit:()=>{let T=ot(t),U=ve(f.readEntries(),T.model),_=Gt(T.model,U);return _.length===0?!1:($(r,{family:"shape",action:"apply-shape-edits",objectId:T.objectId,model:U,edits:_}),!0)},root:r,status:R});let F=T=>{t=T;let U=ot(T);n.textContent=U.label;let _=Qn(p,U.objectId,U.label,U.model);c.textContent=`${U.evidence.shapeType??"shape"} | ${U.evidence.childCount} child objects | ${U.evidence.anchorKind} | preview ${_.kind}${_.supported?"":" fallback"}`,Y?.reset(),f.setEntries(we(U.model))};return ee.addEventListener("click",()=>{Y?.flush()}),H.addEventListener("click",()=>{Y?.reset();let T=ot(t);$(r,{family:"shape",action:"remove-advanced-ooxml",objectId:T.objectId})}),F(e),{dom:r,destroy(){Y?.destroy(),f.destroy()},update(T){return T.type!==t.type?!1:(F(T),!0)},stopEvent(T){return fe(T.target)||de(T.target)&&O.contains(T.target)},ignoreMutation(){return!0},selectNode(){r.style.borderColor="#0f766e"},deselectNode(){r.style.borderColor="#cbd5e1"}}}}import{inlineOoxmlDrawingMetadata as ea}from"@datalking/begonia-editor-adapters";function nr(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function ta(){let e=document.createElement("span");return e.contentEditable="false",e.className="ald-editor-inline-drawing",Object.assign(e.style,{display:"inline-block",boxSizing:"border-box",margin:"0 2px",lineHeight:"0",maxWidth:"100%",verticalAlign:"baseline"}),e}function ar(e,t){let r=ea(t),o=r?.label||String(t.attrs.label??"Drawing"),n=r?.family??(t.attrs.family==="chart"?"chart":"shape"),c=r?.drawing,d=nr(r?.width??c?.width,80),u=nr(r?.height??c?.height,40);if(e.dataset.family=n,e.dataset.objectId=r?.objectId??String(t.attrs.objectId??""),e.setAttribute("aria-label",o),e.title=o,e.style.width=`${d}px`,e.style.height=`${u}px`,e.style.border=c?"0":"1px solid #94a3b8",e.style.background=c?"transparent":"#f8fafc",!c?.svg){e.replaceChildren();let y=document.createElement("span");y.textContent=o,Object.assign(y.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",color:"#334155",fontSize:"12px",lineHeight:"1.2",overflow:"hidden"}),e.append(y);return}e.innerHTML=c.svg;let p=e.querySelector("svg");p&&(p.setAttribute("width","100%"),p.setAttribute("height","100%"),p.setAttribute("aria-hidden","true"),Object.assign(p.style,{display:"block"}))}function ir(){return e=>{let t=e,r=ta();return ar(r,e),{dom:r,update(o){return o.type!==t.type?!1:(t=o,ar(r,o),!0)},ignoreMutation(){return!0},selectNode(){r.style.outline="2px solid #0f766e",r.style.outlineOffset="2px"},deselectNode(){r.style.outline="",r.style.outlineOffset=""}}}}var nt="browser-advanced-ooxml-nodeviews";function lr(){return{id:nt,createPlugins(){return[]},createNodeViews(){return{ooxml_math:tr(),ooxml_chart:Zt(),ooxml_shape:or(),inline_ooxml_drawing:ir()}}}}function ra(e=[]){return e.some(t=>t.id===nt)?[...e]:[...e,lr()]}import{collectOoxmlMathStructures as oa,countOoxmlChartCategories as na,normalizeOoxmlChartModel as aa,normalizeOoxmlMathModel as ia,normalizeOoxmlShapeModel as la}from"@datalking/begonia-engine";function Be(e){return e.trackingEnabled??e.toolbar?.trackingEnabled??!1}function Ce(e){return e.documentMode==="editing"||e.documentMode==="suggesting"||e.documentMode==="viewing"?e.documentMode:"editing"}function ca(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="math")return null;let r=ia(t.familyData??{plainText:t.text,displayMode:"inline"},t.text,"inline");return{family:"math",record:t,model:r,plainText:t.familyData?.plainText??t.text,displayMode:r.displayMode,structures:t.familyData?.structures?.length?t.familyData.structures:oa(r),trackingEnabled:Be(e),documentMode:Ce(e)}}function sa(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="chart")return null;let r=aa(t.familyData?.model??t.familyData??{title:t.label,textBody:{plainText:t.text}},t.label);return{family:"chart",record:t,model:r,series:r.series,seriesCount:r.series.length,categoryCount:na(r),trackingEnabled:Be(e),documentMode:Ce(e)}}function da(e){let t=e.advancedOoxml.selected;if(!t||t.family!=="shape")return null;let r=la(t.familyData?.model??t.familyData??{label:t.label,textBody:t.text?{plainText:t.text,paragraphs:[t.text]}:null},t.label);return{family:"shape",record:t,model:r,trackingEnabled:Be(e),documentMode:Ce(e)}}function Me(e="editing",t=!1){return{selected:null,documentMode:e,trackingEnabled:t}}function at(e){return{selected:ca(e)??sa(e)??da(e),trackingEnabled:Be(e),documentMode:Ce(e)}}function Ie(e){return structuredClone(e)}function ua(e){return"host"in e}function Oe(e){return e?ua(e)?e.host:e:null}var pa=Symbol.for("@datalking/begonia-browser-sdk/browser-editor-v1-runtime"),cr=new WeakMap,ma=new WeakMap;function it(e){return!e||typeof e!="object"?null:e[pa]??null}function ha(e){return"host"in e}function lt(e){if(!e)return null;if(ha(e))return ma.get(e)??it(e)??cr.get(e.host)??it(e.host)??null;let t=Oe(e);return t?cr.get(t)??it(t)??null:null}function sr(e){return lt(e)?.advancedOoxmlActions??null}function A(e){return{changed:!1,reason:e}}function fa(e){let t=e,r=Oe(t),o=lt(t),n=sr(t),c=o?.controller.documentApi??{},d=()=>{let s=o?.controller.getState();return s?at(s):Me()},u=d(),p=new Set,y=()=>{u=d();for(let s of[...p])s(Ie(u))},g=r?.session.subscribe(()=>y())??(()=>{}),m="Advanced OOXML editing requires a mounted browser editor backend.";return{actor:o?.controller.actor??null,documentApi:c,getSnapshot(){return u=d(),Ie(u)},subscribe(s){return p.add(s),s(Ie(u)),()=>{p.delete(s)}},replaceSelectedMathModel(s){return n?n.replaceSelectedMathModel(s):A(m)},setSelectedMathPlainText(s,O){return n?n.setSelectedMathPlainText(s,O):A(m)},setSelectedMathDisplayMode(s){return n?n.setSelectedMathDisplayMode(s):A(m)},replaceSelectedChartModel(s){return n?n.replaceSelectedChartModel(s):A(m)},setSelectedChartMetadata(s){return n?n.setSelectedChartMetadata(s):A(m)},appendSelectedChartSeries(s){return n?n.appendSelectedChartSeries(s):A(m)},setSelectedChartSeriesList(s){return n?n.setSelectedChartSeriesList(s):A(m)},setSelectedChartTitle(s){return n?n.setSelectedChartTitle(s):A(m)},setSelectedChartTextBody(s){return n?n.setSelectedChartTextBody(s):A(m)},setSelectedChartSeries(s,O){return n?n.setSelectedChartSeries(s,O):A(m)},upsertSelectedChartSeries(s,O){return n?n.upsertSelectedChartSeries(s,O):A(m)},removeSelectedChartSeries(s){return n?n.removeSelectedChartSeries(s):A(m)},appendSelectedChartAxis(s){return n?n.appendSelectedChartAxis(s):A(m)},setSelectedChartAxes(s){return n?n.setSelectedChartAxes(s):A(m)},upsertSelectedChartAxis(s,O){return n?n.upsertSelectedChartAxis(s,O):A(m)},removeSelectedChartAxis(s){return n?n.removeSelectedChartAxis(s):A(m)},setSelectedChartLegend(s){return n?n.setSelectedChartLegend(s):A(m)},setSelectedChartPlotArea(s){return n?n.setSelectedChartPlotArea(s):A(m)},replaceSelectedShapeModel(s){return n?n.replaceSelectedShapeModel(s):A(m)},setSelectedShapeMetadata(s){return n?n.setSelectedShapeMetadata(s):A(m)},setSelectedShapeWatermark(s){return n?n.setSelectedShapeWatermark(s):A(m)},setSelectedShapeTextBody(s){return n?n.setSelectedShapeTextBody(s):A(m)},setSelectedShapeGeometry(s){return n?n.setSelectedShapeGeometry(s):A(m)},setSelectedShapeTransform(s){return n?n.setSelectedShapeTransform(s):A(m)},setSelectedShapeFill(s){return n?n.setSelectedShapeFill(s):A(m)},setSelectedShapeStroke(s){return n?n.setSelectedShapeStroke(s):A(m)},setSelectedShapeAnchor(s){return n?n.setSelectedShapeAnchor(s):A(m)},setSelectedShapeConnector(s){return n?n.setSelectedShapeConnector(s):A(m)},setSelectedShapePicture(s){return n?n.setSelectedShapePicture(s):A(m)},setSelectedShapeWordArt(s){return n?n.setSelectedShapeWordArt(s):A(m)},setSelectedShapeChildren(s){return n?n.setSelectedShapeChildren(s):A(m)},setSelectedShapeChild(s,O){return n?n.setSelectedShapeChild(s,O):A(m)},appendSelectedShapeChild(s){return n?n.appendSelectedShapeChild(s):A(m)},appendSelectedShapeChildToParent(s,O){return n?n.appendSelectedShapeChildToParent(s,O):A(m)},moveSelectedShapeChild(s,O){return n?n.moveSelectedShapeChild(s,O):A(m)},removeSelectedShapeChild(s){return n?n.removeSelectedShapeChild(s):A(m)},removeSelected(){return n?n.removeSelectedAdvancedOoxml():A(m)},destroy(){g(),p.clear(),u=Me()}}}function V(e){let t=e.trim();return t.length>0?t:null}function xa(e){return e===!0?"true":e===!1?"false":"unknown"}function K(e){return e==="true"?!0:e==="false"?!1:null}function dr(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}function ya(e){let t=dr(e);return t.length===0?null:{paragraphs:t,plainText:t.join(`
3
+ `)}}function Sa(e){let t=dr(e);return t.length===0?null:{paragraphs:t,plainText:t.join(`
4
+ `)}}function ba(e){return e.series.map(t=>({id:t.id??"",order:t.order==null?"":String(t.order),name:t.name??"",categories:t.categories.join(", "),values:t.values.map(r=>r==null?"":String(r)).join(", ")}))}function ga(e){return e.axes.map(t=>({id:t.id??"",kind:t.kind??"unknown",title:t.title??"",formatCode:t.formatCode??"",orientation:t.orientation??"unknown"}))}function Aa(e){return{enabled:e.legend?"true":"false",visible:e.legend?.visible===!1?"false":"true",position:e.legend?.position??"unknown",overlay:xa(e.legend?.overlay)}}function wa(e){return[...e,{id:"",order:e.length===0?"0":String(e.length),name:"",categories:"",values:""}]}function va(e){return[...e,{id:"",kind:"category",title:"",formatCode:"",orientation:"unknown"}]}function Ea(e){return{id:V(e.id),order:e.order.trim()?Number(e.order):null,name:V(e.name),categories:e.categories.split(",").map(t=>t.trim()).filter(t=>t.length>0),values:e.values.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{let r=Number(t);return Number.isFinite(r)?r:null}),color:null,marker:null,dataLabels:null,smooth:null,explosion:null}}function Ba(e){return{id:V(e.id),kind:e.kind==="category"||e.kind==="value"||e.kind==="series"||e.kind==="date"?e.kind:"unknown",title:V(e.title),formatCode:V(e.formatCode),orientation:e.orientation==="minMax"||e.orientation==="maxMin"?e.orientation:null,visible:null,minimum:null,maximum:null,majorUnit:null,minorUnit:null,crossesAt:null,majorGridlines:null,minorGridlines:null}}function Ca(e){return e.enabled==="false"?null:{visible:e.visible!=="false",position:e.position,overlay:K(e.overlay)}}function Ma(e,t,r,o,n,c={}){return{...e,title:V(t),chartType:V(r),textBody:ya(o),series:n.map(Ea),axes:c.axes?c.axes.map(Ba):e.axes,legend:c.legend?Ca(c.legend):e.legend}}function Q(e){let t=e.trim();if(!t)return null;let r=Number(t);return Number.isFinite(r)?r:null}function Ia(e,t){let r=V(t.geometryPreset),o=Q(t.geometryCustomPathCount??""),n=Q(t.strokeWidthEmu),c=Q(t.widthEmu),d=Q(t.heightEmu),u=Q(t.offsetXEmu??""),p=Q(t.offsetYEmu??""),y=Q(t.rotation),g=Q(t.anchorRelativeHeight??"");return{...e,label:V(t.label),shapeType:V(t.shapeType),textBody:Sa(t.textBody),geometry:r||o!=null?{preset:r,customPathCount:o,adjustments:[]}:null,fill:V(t.fillColor)||t.fillKind!=="unknown"?{kind:t.fillKind,color:V(t.fillColor),secondaryColor:null,opacity:null}:null,stroke:V(t.strokeColor)||V(t.strokeDash)||n!=null?{color:V(t.strokeColor),widthEmu:n,dash:V(t.strokeDash),cap:null,join:null}:null,transform:c!=null||d!=null||u!=null||p!=null||y!=null||K(t.flipH??"unknown")!=null||K(t.flipV??"unknown")!=null?{widthEmu:c,heightEmu:d,offsetXEmu:u,offsetYEmu:p,rotation:y,flipH:K(t.flipH??"unknown"),flipV:K(t.flipV??"unknown")}:null,anchor:t.anchorKind!=="unknown"||t.anchorWrap!=="unknown"||K(t.anchorBehindDoc??"unknown")!=null||K(t.anchorAllowOverlap??"unknown")!=null||K(t.anchorLayoutInCell??"unknown")!=null||g!=null?{...e.anchor,kind:t.anchorKind,wrap:t.anchorWrap,behindDoc:K(t.anchorBehindDoc??"unknown"),allowOverlap:K(t.anchorAllowOverlap??"unknown"),layoutInCell:K(t.anchorLayoutInCell??"unknown"),relativeHeight:g,distTopEmu:e.anchor?.distTopEmu??null,distBottomEmu:e.anchor?.distBottomEmu??null,distLeftEmu:e.anchor?.distLeftEmu??null,distRightEmu:e.anchor?.distRightEmu??null,positionH:e.anchor?.positionH??null,positionV:e.anchor?.positionV??null,offsetXEmu:e.anchor?.offsetXEmu??null,offsetYEmu:e.anchor?.offsetYEmu??null,alignH:e.anchor?.alignH??null,alignV:e.anchor?.alignV??null}:null}}export{va as appendEmptyAxisDraft,wa as appendEmptySeriesDraft,Sr as appendMathToCurrentTextblock,br as appendMathToCurrentTextblockTracked,jr as appendSelectedChartAxis,Or as appendSelectedChartSeries,to as appendSelectedShapeChild,ro as appendSelectedShapeChildToParent,ga as axisDraftsFromModel,Se as browserAdvancedOoxmlNodeViewActionEvent,nt as browserAdvancedOoxmlSurfaceFeatureId,Ve as chartModelFromStructuredEntries,Re as chartStructuredEntriesFromModel,fa as createBrowserAdvancedOoxmlInspectorController,lr as createBrowserAdvancedOoxmlSurfaceFeature,Et as createChartSubtreeInsertions,Ue as createMathSubtreeInsertions,Ze as createShapeSubtreeInsertions,$ as dispatchBrowserAdvancedOoxmlNodeViewAction,Me as emptyBrowserAdvancedOoxmlInspectorSnapshot,vr as insertChartAfterCurrentBlock,Er as insertChartAfterCurrentBlockTracked,Hr as insertShapeAfterCurrentBlock,Fr as insertShapeAfterCurrentBlockTracked,so as installBrowserAdvancedOoxmlNodeViewBridge,xt as isBrowserAdvancedOoxmlNodeViewActionDetail,Aa as legendDraftFromModel,Mt as mathModelFromStructuredEntries,ze as mathStructuredEntriesFromModel,Ma as mergeChartModelWithDrafts,Ia as mergeShapeModelWithDrafts,oo as moveSelectedShapeChild,Gt as planShapeNodeViewEdits,at as readBrowserAdvancedOoxmlInspectorSnapshot,xe as readSelectedAdvancedOoxmlRecord,yr as removeSelectedAdvancedOoxml,Rr as removeSelectedChartAxis,Nr as removeSelectedChartSeries,no as removeSelectedShapeChild,Br as replaceSelectedChartModel,gr as replaceSelectedMathModel,Ur as replaceSelectedShapeModel,ba as seriesDraftsFromModel,Pr as setSelectedChartAxes,Vr as setSelectedChartLegend,Cr as setSelectedChartMetadata,Lr as setSelectedChartPlotArea,Tr as setSelectedChartSeries,kr as setSelectedChartSeriesList,Ir as setSelectedChartTextBody,Mr as setSelectedChartTitle,wr as setSelectedMathDisplayMode,Ar as setSelectedMathPlainText,Xr as setSelectedShapeAnchor,eo as setSelectedShapeChild,Qr as setSelectedShapeChildren,Yr as setSelectedShapeConnector,Jr as setSelectedShapeFill,Gr as setSelectedShapeGeometry,zr as setSelectedShapeMetadata,_r as setSelectedShapePicture,$r as setSelectedShapeStroke,Kr as setSelectedShapeTextBody,qr as setSelectedShapeTransform,Wr as setSelectedShapeWatermark,Zr as setSelectedShapeWordArt,ve as shapeModelFromStructuredEntries,we as shapeStructuredEntriesFromModel,xr as updateSelectedAdvancedOoxml,ft as upsertSelectedChartAxis,Dr as upsertSelectedChartSeries,ra as withBrowserAdvancedOoxmlSurfaceFeature};
@@ -0,0 +1,7 @@
1
+ export * from './paginated-editing-types.ts';
2
+ export * from './paginated-editing-session.ts';
3
+ export * from './paginated-input-bridge.ts';
4
+ export * from './paginated-caret-reveal.ts';
5
+ export * from './paginated-table-boundary-keys.ts';
6
+ export * from './paginated-table-boundary-keyboard.ts';
7
+ export * from './paginated-column-keyboard.ts';
@@ -0,0 +1,51 @@
1
+ import type { PaginatedEditingScrollHost } from './paginated-editing-types.ts';
2
+ export interface CreatePaginatedCaretRevealerInput {
3
+ getScrollHost: () => PaginatedEditingScrollHost | null;
4
+ getCaretElement: () => HTMLElement | null;
5
+ marginPx?: number;
6
+ maxStep?: number;
7
+ }
8
+ export interface PaginatedCaretRevealer {
9
+ /** Scrolls the host so the painted caret clears its comfort margin. */
10
+ reveal(): boolean;
11
+ destroy(): void;
12
+ }
13
+ interface RectLike {
14
+ top: number;
15
+ height: number;
16
+ }
17
+ interface HorizontalRectLike {
18
+ left: number;
19
+ width: number;
20
+ }
21
+ /**
22
+ * Computes the scroll adjustment from two measured boxes.
23
+ *
24
+ * Split out from the DOM reads so the arithmetic is testable without a layout
25
+ * engine: `caret` and `viewport` only need top/height.
26
+ */
27
+ export declare function resolvePaginatedCaretRevealFromRects(input: {
28
+ caret: RectLike;
29
+ viewport: RectLike;
30
+ scrollOffset?: number;
31
+ scrollExtent?: number;
32
+ marginPx?: number;
33
+ maxStep?: number;
34
+ }): number | null;
35
+ /**
36
+ * Same reveal arithmetic on the horizontal axis.
37
+ *
38
+ * `resolvePaginatedRevealScrollDelta` is written against vertical wording
39
+ * (top/height), but it is pure interval math: feeding it left/width answers the
40
+ * horizontal question, which is what horizontal and book layout need.
41
+ */
42
+ export declare function resolvePaginatedCaretRevealFromHorizontalRects(input: {
43
+ caret: HorizontalRectLike;
44
+ viewport: HorizontalRectLike;
45
+ scrollOffset?: number;
46
+ scrollExtent?: number;
47
+ marginPx?: number;
48
+ maxStep?: number;
49
+ }): number | null;
50
+ export declare function createPaginatedCaretRevealer(input: CreatePaginatedCaretRevealerInput): PaginatedCaretRevealer;
51
+ export {};