@datalking/begonia-react 0.1.1 → 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.
- package/dist/binding/BegoniaPdfViewer.d.ts +4 -1
- package/dist/binding/BrowserPaginatedEditorSurface.d.ts +44 -0
- package/dist/binding/HeaderFooterScratchMount.d.ts +25 -0
- package/dist/binding/PaginatedLayoutView.d.ts +21 -2
- package/dist/binding/PaginatedPageOverlayView.d.ts +44 -0
- package/dist/binding/VirtualPagedPreview.d.ts +38 -1
- package/dist/binding/begonia-theme-style.d.ts +12 -0
- package/dist/binding/browser-header-footer-bands.d.ts +98 -0
- package/dist/binding/browser-header-footer-format-bar.d.ts +21 -0
- package/dist/binding/browser-paginated-preview-drag-state.d.ts +2 -0
- package/dist/binding/headless.d.ts +1 -1
- package/dist/binding/index.d.ts +4 -0
- package/dist/binding/paginated-preview-doc-style.d.ts +40 -0
- package/dist/binding/paginated-preview-font-family.d.ts +19 -0
- package/dist/binding/paginated-scroll-axis-host.d.ts +32 -0
- package/dist/binding/preview-link-activation.d.ts +71 -0
- package/dist/binding/resolve-snapshot-comment-state.d.ts +32 -0
- package/dist/binding/use-browser-header-footer-editing.d.ts +114 -0
- package/dist/binding/use-header-footer-scratch-surface.d.ts +48 -0
- package/dist/binding/use-owned-destroyable.d.ts +9 -0
- package/dist/binding/use-undo-redo-hotkeys.d.ts +45 -0
- package/dist/binding/useVirtualPagedPreviewState.d.ts +13 -3
- package/dist/binding/v1.d.ts +16 -0
- package/dist/binding/virtual-paged-preview-comment-highlight.d.ts +33 -0
- package/dist/binding/virtual-paged-preview-drag-session.d.ts +1 -1
- package/dist/binding/virtual-paged-preview-interaction.d.ts +2 -2
- package/dist/binding/virtual-paged-preview-list-marker.d.ts +42 -0
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-text.d.ts +21 -6
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-views.d.ts +18 -2
- package/dist/binding/virtual-paged-preview-review-attributes.d.ts +78 -0
- package/dist/binding/virtual-paged-preview-text-lines.d.ts +4 -0
- package/dist/chunk-LIAB6VEG.js +1 -0
- package/dist/editor-surface.css +457 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/v1.d.ts +4 -2
- package/dist/v1.js +1 -1
- package/package.json +19 -16
- package/dist/binding/paginated-preview-defaults.d.ts +0 -2
- package/dist/binding/virtual-paged-preview-table-metrics.d.ts +0 -1
- package/dist/chunk-IEHE33P5.js +0 -1
package/dist/v1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as It,B as Tt,C as Wt,D as Lt,E as Ft,F as $t,G as Ut,H as jt,I as Ht,J as ie,K as Kt,L as Vt,M as zt,N as Xt,O as qt,P as Ce,Q as Gt,R as _t,S as Yt,T as Jt,U as le,V as Qt,a as V,b as z,c as ae,d as mt,e as bt,f as xt,g as gt,h as ft,i as vt,j as wt,k as ht,l as yt,m as Bt,n as kt,o as Pt,p as ne,q as Nt,r as Ct,s as se,t as St,u as Et,v as At,w as Ot,x as Mt,y as Dt,z as Rt}from"./chunk-IEHE33P5.js";import{useEffect as ee,useMemo as te,useState as Ve}from"react";import{createBrowserEditorBackendAdapter as ze,resolveBrowserEditorUiController as Xe}from"@datalking/begonia-browser/v1";import{useEffect as Ie,useMemo as Te}from"react";import{summarizeReviewTimeline as We}from"@datalking/begonia-document-api/review";import{createBrowserAdvancedOoxmlInspectorController as Le}from"@datalking/begonia-browser/ooxml";import{emptyBrowserAdvancedOoxmlInspectorSnapshot as Fe}from"@datalking/begonia-browser/ooxml";import{useState as W}from"react";import{appendEmptyAxisDraft as Se,appendEmptySeriesDraft as Ee,axisDraftsFromModel as Ae,legendDraftFromModel as Oe,mergeChartModelWithDrafts as Me,seriesDraftsFromModel as De}from"@datalking/begonia-browser/ooxml";import{jsx as i,jsxs as f}from"react/jsx-runtime";function de({controller:e,selection:t}){let[r,s]=W(t.model.title??""),[d,c]=W(t.model.chartType??""),[o,a]=W(t.model.textBody?.plainText??""),[x,u]=W(De(t.model)),[g,N]=W(Ae(t.model)),[w,A]=W(Oe(t.model)),C=(n,p)=>u(l=>l.map((y,B)=>B===n?{...y,...p}:y)),h=(n,p)=>N(l=>l.map((y,B)=>B===n?{...y,...p}:y));return f("div",{className:"grid gap-3",children:[f("div",{className:"grid gap-1",children:[i("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Title"}),i("input",{value:r,onChange:n=>s(n.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),f("div",{className:"grid gap-1 md:grid-cols-2",children:[f("div",{className:"grid gap-1",children:[i("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Type"}),i("input",{value:d,onChange:n=>c(n.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),f("div",{className:"grid gap-1",children:[i("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Coverage"}),f("div",{className:"flex flex-wrap gap-2",children:[f("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.seriesCount," series"]}),f("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.categoryCount," categories"]})]})]})]}),f("div",{className:"grid gap-1",children:[i("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),i("textarea",{value:o,onChange:n=>a(n.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),f("div",{className:"grid gap-2",children:[f("div",{className:"flex items-center justify-between gap-3",children:[i("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Series"}),i("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>u(n=>Ee(n)),children:"Add series"})]}),x.length===0?i("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart series yet."}):null,x.map((n,p)=>f("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[f("div",{className:"grid gap-2 md:grid-cols-3",children:[i("input",{value:n.name,onChange:l=>C(p,{name:l.target.value}),placeholder:"Series name",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),i("input",{value:n.id,onChange:l=>C(p,{id:l.target.value}),placeholder:"Series id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),i("input",{value:n.order,onChange:l=>C(p,{order:l.target.value}),placeholder:"Order",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),i("input",{value:n.categories,onChange:l=>C(p,{categories:l.target.value}),placeholder:"Categories, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),i("input",{value:n.values,onChange:l=>C(p,{values:l.target.value}),placeholder:"Values, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),i("div",{className:"flex justify-end",children:i("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>u(l=>l.filter((y,B)=>B!==p)),children:"Remove row"})})]},`${t.record.objectId}-${p}`))]}),f("div",{className:"grid gap-2",children:[f("div",{className:"flex items-center justify-between gap-3",children:[i("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Axes"}),i("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>N(n=>Se(n)),children:"Add axis"})]}),g.length===0?i("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart axes yet."}):null,g.map((n,p)=>f("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[f("div",{className:"grid gap-2 md:grid-cols-2",children:[i("input",{value:n.id,onChange:l=>h(p,{id:l.target.value}),placeholder:"Axis id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),i("input",{value:n.title,onChange:l=>h(p,{title:l.target.value}),placeholder:"Axis title",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),f("div",{className:"grid gap-2 md:grid-cols-3",children:[f("select",{value:n.kind,onChange:l=>h(p,{kind:l.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[i("option",{value:"category",children:"Category"}),i("option",{value:"value",children:"Value"}),i("option",{value:"series",children:"Series"}),i("option",{value:"date",children:"Date"}),i("option",{value:"unknown",children:"Unknown"})]}),f("select",{value:n.orientation,onChange:l=>h(p,{orientation:l.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[i("option",{value:"unknown",children:"Orientation"}),i("option",{value:"minMax",children:"Min to Max"}),i("option",{value:"maxMin",children:"Max to Min"})]}),i("input",{value:n.formatCode,onChange:l=>h(p,{formatCode:l.target.value}),placeholder:"Format code",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),i("div",{className:"flex justify-end",children:i("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>N(l=>l.filter((y,B)=>B!==p)),children:"Remove axis"})})]},`${t.record.objectId}-axis-${p}`))]}),f("div",{className:"grid gap-2",children:[i("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Legend"}),f("div",{className:"grid gap-2 md:grid-cols-2",children:[f("select",{value:w.enabled,onChange:n=>A(p=>({...p,enabled:n.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[i("option",{value:"true",children:"Enabled"}),i("option",{value:"false",children:"Absent"})]}),f("select",{value:w.visible,disabled:w.enabled==="false",onChange:n=>A(p=>({...p,visible:n.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[i("option",{value:"true",children:"Visible"}),i("option",{value:"false",children:"Hidden"})]})]}),f("div",{className:"grid gap-2 md:grid-cols-2",children:[f("select",{value:w.position,disabled:w.enabled==="false",onChange:n=>A(p=>({...p,position:n.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[i("option",{value:"unknown",children:"Position"}),i("option",{value:"left",children:"Left"}),i("option",{value:"right",children:"Right"}),i("option",{value:"top",children:"Top"}),i("option",{value:"bottom",children:"Bottom"}),i("option",{value:"topRight",children:"Top Right"})]}),f("select",{value:w.overlay,disabled:w.enabled==="false",onChange:n=>A(p=>({...p,overlay:n.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[i("option",{value:"unknown",children:"Overlay"}),i("option",{value:"true",children:"Overlay"}),i("option",{value:"false",children:"No overlay"})]})]})]}),i("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedChartModel(Me(t.model,r,d,o,x,{axes:g,legend:w})),children:"Apply chart"})]})}import{useState as ce}from"react";import{jsx as M,jsxs as F}from"react/jsx-runtime";function ue({controller:e,selection:t}){let[r,s]=ce(t.plainText),[d,c]=ce(t.displayMode);return F("div",{className:"grid gap-3",children:[F("div",{className:"grid gap-1",children:[M("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Equation Text"}),M("textarea",{value:r,onChange:o=>s(o.target.value),rows:4,className:"min-h-24 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),F("div",{className:"grid gap-1",children:[M("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Display Mode"}),F("select",{value:d,onChange:o=>c(o.target.value==="block"?"block":"inline"),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[M("option",{value:"inline",children:"Inline"}),M("option",{value:"block",children:"Block"})]})]}),F("div",{className:"grid gap-1",children:[M("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Detected Structures"}),M("div",{className:"flex flex-wrap gap-2",children:t.structures.length===0?M("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Plain text"}):t.structures.map(o=>M("span",{className:"rounded-full bg-sky-100 px-2 py-1 text-[11px] font-semibold text-sky-700",children:o},o))})]}),M("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.setSelectedMathPlainText(r,d),children:"Apply equation"})]})}import{useState as E}from"react";import{mergeShapeModelWithDrafts as Re}from"@datalking/begonia-browser/ooxml";import{jsx as m,jsxs as v}from"react/jsx-runtime";function pe({controller:e,selection:t}){let[r,s]=E(t.model.label??""),[d,c]=E(t.model.shapeType??""),[o,a]=E(t.model.textBody?.plainText??""),[x,u]=E(t.model.geometry?.preset??""),[g,N]=E(t.model.fill?.kind??"unknown"),[w,A]=E(t.model.fill?.color??""),[C,h]=E(t.model.stroke?.color??""),[n,p]=E(t.model.stroke?.widthEmu==null?"":String(t.model.stroke.widthEmu)),[l,y]=E(t.model.stroke?.dash??""),[B,R]=E(t.model.transform?.widthEmu==null?"":String(t.model.transform.widthEmu)),[D,S]=E(t.model.transform?.heightEmu==null?"":String(t.model.transform.heightEmu)),[O,Y]=E(t.model.transform?.rotation==null?"":String(t.model.transform.rotation)),[T,J]=E(t.model.anchor?.kind??"unknown"),[H,Q]=E(t.model.anchor?.wrap??"unknown");return v("div",{className:"grid gap-3",children:[v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Label"}),m("input",{value:r,onChange:b=>s(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Type"}),m("input",{value:d,onChange:b=>c(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),m("textarea",{value:o,onChange:b=>a(b.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Geometry Preset"}),m("input",{value:x,onChange:b=>u(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Color"}),m("input",{value:w,onChange:b=>A(b.target.value),placeholder:"FFF2CC",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),v("div",{className:"grid gap-2 md:grid-cols-3",children:[v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Kind"}),v("select",{value:g,onChange:b=>N(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"solid",children:"Solid"}),m("option",{value:"scheme",children:"Scheme"}),m("option",{value:"none",children:"None"})]})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Color"}),m("input",{value:C,onChange:b=>h(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Dash"}),m("input",{value:l,onChange:b=>y(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),v("div",{className:"grid gap-2 md:grid-cols-3",children:[v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Width (EMU)"}),m("input",{value:n,onChange:b=>p(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Width (EMU)"}),m("input",{value:B,onChange:b=>R(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Height (EMU)"}),m("input",{value:D,onChange:b=>S(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),v("div",{className:"grid gap-2 md:grid-cols-3",children:[v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Rotation"}),m("input",{value:O,onChange:b=>Y(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Anchor Kind"}),v("select",{value:T,onChange:b=>J(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"inline",children:"Inline"}),m("option",{value:"anchor",children:"Anchor"})]})]}),v("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Wrap"}),v("select",{value:H,onChange:b=>Q(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"none",children:"None"}),m("option",{value:"square",children:"Square"}),m("option",{value:"tight",children:"Tight"}),m("option",{value:"through",children:"Through"}),m("option",{value:"topAndBottom",children:"Top and Bottom"})]})]})]}),m("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedShapeModel(Re(t.model,{label:r,shapeType:d,textBody:o,geometryPreset:x,fillKind:g,fillColor:w,strokeColor:C,strokeWidthEmu:n,strokeDash:l,widthEmu:B,heightEmu:D,rotation:O,anchorKind:T,anchorWrap:H})),children:"Apply shape"})]})}import{jsx as P,jsxs as k}from"react/jsx-runtime";function X(...e){return e.filter(Boolean).join(" ")}function $e(e){return`${e.family}:${e.record.objectId}:${JSON.stringify(e.model)}`}function Ue(e){return e==="math"?"bg-sky-100 text-sky-700":e==="chart"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700"}function je(e){return e.kind==="revision"?e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"bg-amber-100 text-amber-700":e.revision.kind==="insert"?"bg-emerald-100 text-emerald-700":e.revision.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700":e.kind==="revision-decision"?e.decision==="accept"?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700":e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function He(e){if(e.kind==="revision")return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"Replace":e.revision.kind==="insert"?"Insert":e.revision.kind==="delete"?"Delete":"Format";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function Ke(e){if(e.kind==="revision")return e.revision.prompt??e.excerpt??e.authorName??e.authorId??"Tracked change";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-status"?e.status==="resolved"?"Resolved thread":e.status==="open"?"Reopened thread":"Status change":e.kind==="comment-visibility"?e.internalAfter?"Made internal":"Made external":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Removed thread":"Removed reply":e.authorName??e.authorId??"Review activity"}function Z({editor:e,className:t}){let r=Te(()=>e?Le(e):null,[e]),s=V(r)??Fe();Ie(()=>()=>{r?.destroy()},[r]);let d=s.selected,c=d?$e(d):null,o=r&&d?r.documentApi.review.timelineByObject(d.record.objectId,{actor:r.actor??void 0,enforceVisibilityPolicy:!0,sort:"desc"}):[],a=We(o),x=o.slice(0,4);return k("aside",{className:X("grid gap-3",t),"aria-label":"Advanced OOXML inspector",children:[P("header",{className:"grid gap-1",children:k("div",{className:"flex items-center justify-between gap-3",children:[k("div",{children:[P("h2",{className:"text-sm font-semibold text-slate-900",children:"Advanced OOXML"}),P("p",{className:"text-xs text-slate-500",children:"Structured editor for selected math, chart, and shape nodes."})]}),P("span",{className:X("rounded-full px-2 py-1 text-[11px] font-semibold",s.trackingEnabled?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"),children:s.trackingEnabled?"Tracking On":"Direct Edit"})]})}),!d||!r?P("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"Select an equation, chart, or shape in the editor to inspect and edit its structured OOXML model."}):k("section",{className:"grid gap-4 rounded-3xl border border-slate-200 bg-white px-4 py-4 shadow-sm",children:[k("div",{className:"grid gap-2",children:[k("div",{className:"flex items-center justify-between gap-3",children:[k("div",{className:"flex items-center gap-2",children:[P("span",{className:X("rounded-full px-2 py-1 text-[11px] font-semibold",Ue(d.family)),children:d.family}),P("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-600",children:d.documentMode})]}),P("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.removeSelected(),children:"Remove"})]}),k("div",{className:"grid gap-1 text-[11px] text-slate-500",children:[k("span",{children:["Object: ",d.record.objectId]}),k("span",{children:["Path: ",d.record.path.join(".")]})]})]}),d.family==="math"?P(ue,{controller:r,selection:d},c??void 0):null,d.family==="chart"?P(de,{controller:r,selection:d},c??void 0):null,d.family==="shape"?P(pe,{controller:r,selection:d},c??void 0):null,P("p",{className:"text-[11px] text-slate-500",children:s.trackingEnabled?"Inspector edits flow through tracked OOXML replacements so accept/reject stays available.":"Inspector edits apply directly to the selected OOXML object."}),k("section",{className:"grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[k("div",{className:"flex items-end justify-between gap-3",children:[k("div",{children:[P("h3",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-600",children:"Object Review"}),k("p",{className:"text-xs text-slate-500",children:[a.total," linked item",a.total===1?"":"s"]})]}),k("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[k("span",{children:[a.revisions," revision",a.revisions===1?"":"s"]}),k("span",{children:[a.commentThreads," thread",a.commentThreads===1?"":"s"]}),k("span",{children:[a.commentReplies," repl",a.commentReplies===1?"y":"ies"]})]})]}),x.length===0?P("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-white px-3 py-4 text-xs text-slate-500",children:"No tracked review activity is currently linked to this OOXML object."}):P("div",{className:"grid gap-2",children:x.map(u=>k("div",{className:"grid gap-1 rounded-2xl border border-slate-200 bg-white px-3 py-3",children:[k("div",{className:"flex items-center justify-between gap-3",children:[P("span",{className:X("rounded-full px-2 py-1 text-[11px] font-semibold",je(u)),children:He(u)}),P("span",{className:"text-[11px] text-slate-400",children:u.authorName??u.authorId??"Unknown"})]}),P("p",{className:"text-xs text-slate-700",children:u.text||"Formatting change"}),P("p",{className:"text-[11px] text-slate-500",children:Ke(u)})]},u.id))})]})]})]})}import{jsx as me}from"react/jsx-runtime";function qe(e){return Xe(e)}function Ge({room:e,actor:t,collaborative:r,collaborationSession:s,documentMode:d,enableEmbeddedAdvancedOoxmlEditors:c=!0,features:o,fitWidthOptions:a,flowMode:x,initialContent:u,layoutMode:g,modules:N,onEditorChange:w,onTransaction:A,onUpdate:C,participant:h,permissionResolver:n,onControllerChange:p,onStateChange:l,schema:y,showAdvancedOoxmlInspector:B=!0,trackingEnabled:R=!0,viewSelect:D=!0,zoomMode:S,zoomPercent:O,...Y}){let[T,J]=Ve(null),H=te(()=>ze(),[]),Q=te(()=>({room:e,actor:t,collaborative:r,collaborationSession:s,documentMode:d,enableEmbeddedAdvancedOoxmlEditors:c,features:o,fitWidthOptions:a,flowMode:x,initialContent:u,layoutMode:g,modules:N,onTransaction:A,onUpdate:C,participant:h,permissionResolver:n,schema:y,trackingEnabled:R,viewSelect:D,zoomMode:S,zoomPercent:O}),[e,t,r,s,d,c,o,a,x,u,g,N,A,C,h,n,y,R,D,S,O]),b=te(()=>qe(T),[T]);return ee(()=>{p?.(b)},[b,p]),ee(()=>{if(l){if(!b){l(null);return}return l(b.getState()),b.subscribe(K=>{l(K)})}},[b,l]),ee(()=>()=>{p?.(null),l?.(null)},[p,l]),me(le,{...Y,backend:H,backendInput:Q,sidebarStart:B?me(Z,{editor:T}):null,onEditorChange:K=>{J(K),w?.(K)}})}import{useEffect as $,useRef as re}from"react";import{createDocumentSurface as Ze}from"@datalking/begonia-engine";import{useRef as _e}from"react";var Ye=Object.freeze([]);function Je(e){return e?.length?e:Ye}function Qe(e,t){return e.length===t.length&&e.every((r,s)=>Object.is(r,t[s]))}function q(e){let t=Je(e),r=_e(t);return Qe(r.current,t)||(r.current=t),r.current}import{jsx as be}from"react/jsx-runtime";function xe({room:e,collaborative:t,participant:r,schema:s,trackingEnabled:d=!0,editable:c=!0,features:o,onSurfaceReady:a}){let x=re(null),u=re(null),g=re(a),N=q(o);return $(()=>{g.current=a},[a]),$(()=>{if(!x.current)return;let w=Ze({element:x.current,participant:r,schema:s,collaborative:t??e,trackingEnabled:d,editable:c,features:N});return u.current=w,g.current?.(w),()=>{u.current=null,g.current?.(null),w.destroy()}},[t,e,s,N]),$(()=>{u.current?.setParticipant(r)},[r.color,r.id,r.name]),$(()=>{u.current?.setTrackingEnabled(d)},[d]),$(()=>{u.current?.setEditable(c)},[c]),be("div",{className:"editor-frame",children:be("div",{ref:x,className:"editor-host"})})}import{createBrowserEditorUiFromController as et}from"@datalking/begonia-browser/v1";import{jsx as tt}from"react/jsx-runtime";function ge({editor:e,...t}){let r=se(()=>e?et(e):null,[e]);return tt(ie,{...t,editor:r})}import{useRef as rt}from"react";import{jsx as U,jsxs as ve}from"react/jsx-runtime";function G(e,t){let r=t.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-r.left)/Math.max(1,r.width))),y:Math.min(1,Math.max(0,(e.clientY-r.top)/Math.max(1,r.height)))}}function ot(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,minHeight:`${e.minHeight*100}%`,color:e.color,fontSize:`calc(${e.fontSize*100}% + 10px)`,lineHeight:1.2,padding:"4px 6px",borderRadius:10,background:t?"rgba(255,255,255,0.86)":"rgba(255,255,255,0.72)",border:t?"1px solid rgba(14, 116, 144, 0.45)":"1px solid rgba(148, 163, 184, 0.28)",boxShadow:t?"0 6px 18px rgba(14, 116, 144, 0.16)":"0 4px 12px rgba(15, 23, 42, 0.08)",cursor:"move",userSelect:"none",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}}function at(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:12,boxShadow:t?"0 10px 20px rgba(14, 116, 144, 0.18)":"0 4px 10px rgba(15, 23, 42, 0.10)",outline:t?"2px solid rgba(14, 116, 144, 0.48)":"none",cursor:"move",userSelect:"none",objectFit:"contain"}}function nt(e,t){return{position:"absolute",zIndex:0,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:8,background:e.color,opacity:e.opacity,boxShadow:t?"0 0 0 2px rgba(14, 116, 144, 0.4)":"inset 0 0 0 1px rgba(120, 53, 15, 0.08)",mixBlendMode:"multiply",cursor:"move",userSelect:"none"}}function st(e){return e.points.map((t,r)=>`${r===0?"M":"L"} ${t.x*100} ${t.y*100}`).join(" ")}function it(e,t){return e.annotations.filter(r=>r.pageNumber===t)}function fe(e,t,r){return e.kind==="stroke"?U("path",{"data-annotation-kind":e.kind,d:st(e),stroke:e.color,strokeOpacity:e.opacity,strokeWidth:e.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke",onPointerDown:s=>{s.stopPropagation(),r(e,s)}},e.id):e.kind==="text"?U("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:ot(e,t),onPointerDown:s=>{s.stopPropagation(),r(e,s)},children:e.text},e.id):e.kind==="highlight"?U("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:nt(e,t),onPointerDown:s=>{s.stopPropagation(),r(e,s)}},e.id):U("img",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,alt:e.label,src:e.src,style:at(e,t),onPointerDown:s=>{s.stopPropagation(),r(e,s)}},e.id)}function _({pageNumber:e,controller:t,snapshot:r}){let s=rt(null),d=it(r,e),c=r.activeStroke?.pageNumber===e?r.activeStroke:null;return ve("div",{style:{position:"absolute",inset:0,pointerEvents:r.enabled?"auto":"none",opacity:r.opacity},onPointerDown:o=>{if(!r.enabled)return;let a=G(o,o.currentTarget);if(r.tool==="draw"){o.currentTarget.setPointerCapture(o.pointerId),t.beginStroke(e,a);return}if(r.tool==="erase"){o.currentTarget.setPointerCapture(o.pointerId),t.eraseAt(e,a);return}if(r.tool==="text"){t.addText(e,a);return}if(r.tool==="highlight"){t.addHighlight(e,a);return}t.selectAnnotation(null)},onPointerMove:o=>{if(!r.enabled)return;let a=G(o,o.currentTarget);if(r.tool==="draw"&&r.activeStroke&&o.buttons===1){t.appendStroke(a);return}if(r.tool==="erase"&&o.buttons===1){t.eraseAt(e,a);return}s.current&&s.current.pageNumber===e&&o.buttons===1&&(t.moveAnnotation(s.current.annotationId,{x:a.x-s.current.lastPoint.x,y:a.y-s.current.lastPoint.y}),s.current={...s.current,lastPoint:a})},onPointerUp:o=>{r.tool==="draw"&&t.commitStroke(),s.current=null,o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId)},onDragOver:o=>{r.enabled&&o.preventDefault()},onDrop:o=>{if(!r.enabled)return;o.preventDefault();let a=G(o,o.currentTarget),x=o.dataTransfer.getData("application/sticker"),u=o.dataTransfer.getData("application/comment");if(x){t.placeSticker(e,a,x);return}if(u){let g=r.comments.find(N=>N.id===u);g&&t.addText(e,a,g.text)}},children:[ve("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",overflow:"visible"},children:[d.filter(o=>o.kind==="stroke").map(o=>fe(o,o.id===r.selectedAnnotationId,a=>t.selectAnnotation(a.id))),c?U("path",{d:c.points.map((o,a)=>`${a===0?"M":"L"} ${o.x*100} ${o.y*100}`).join(" "),stroke:c.color,strokeOpacity:c.opacity,strokeWidth:c.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}):null]}),d.filter(o=>o.kind!=="stroke").map(o=>fe(o,o.id===r.selectedAnnotationId,(a,x)=>{t.selectAnnotation(a.id);let u=x.currentTarget.parentElement,g=u instanceof HTMLElement?G(x,u):a.kind==="text"||a.kind==="sticker"||a.kind==="highlight"?{x:a.x,y:a.y}:{x:0,y:0};s.current={annotationId:a.id,pageNumber:e,lastPoint:g}}))]})}import{jsx as we}from"react/jsx-runtime";function he({viewer:e,controller:t,...r}){z(t,d=>d.version);let s=t.getSnapshot();return we(ae,{controller:e,...r,renderPageOverlay:d=>we(_,{pageNumber:d.pageNumber,controller:t,snapshot:s})})}import{jsx as oe}from"react/jsx-runtime";function ye({projection:e,controller:t,height:r=720,scrollHost:s=null,scale:d=.52,pageGap:c=28,windowPages:o=5,overscan:a=2,virtualize:x=!0,layoutMode:u="vertical",flowMode:g,anchorPageNumber:N=null,pinnedPageNumbers:w,emptyLabel:A="No paginated preview available yet.",onViewportChange:C,className:h,style:n}){z(t,l=>l.version);let p=t.getSnapshot();return oe("div",{className:h,style:n,children:oe(ne,{projection:e,version:p.version,height:r,scrollHost:s,scale:d,pageGap:c,windowPages:o,overscan:a,virtualize:x,layoutMode:u,flowMode:g,anchorPageNumber:N,pinnedPageNumbers:w,emptyLabel:A,onViewportChange:C,renderPageOverlay:l=>oe(_,{pageNumber:l.page.pageNumber,controller:t,snapshot:p})})})}import{useEffect as j,useLayoutEffect as Be,useMemo as ke,useReducer as lt,useRef as I}from"react";import{createBrowserEditorMountController as dt}from"@datalking/begonia-browser/v1";var L=Symbol("browser-editor-callback-unset");function ct(e,t){return{...e,features:t}}function Pe({zoomPercent:e,zoomMode:t,fitWidthOptions:r,onControllerChange:s,onStateChange:d,...c}){let o=q(c.features),a=ke(()=>ct({...c,zoomPercent:e,zoomMode:t,fitWidthOptions:r},o),[c.actor,c.collaborative,c.collaborationSession,c.documentMode,c.enableEmbeddedAdvancedOoxmlEditors,c.flowMode,r,c.initialContent,c.layoutMode,c.modules,c.onTransaction,c.onUpdate,c.participant,c.permissionResolver,c.room,c.schema,c.surfaceFactory,c.trackingEnabled,c.viewSelect,o,t,e]),x=I(null);x.current||(x.current=dt(a));let u=x.current,g=I(null),[N,w]=lt(S=>S+1,0),A=ke(()=>({getSnapshot:()=>u.getSnapshot(),subscribe:S=>u.subscribe(S)}),[u,N]),C=V(A)??u.getSnapshot(),h=C.controller,n=C.state,p=I(s),l=I(d),y=I(L),B=I(L),R=I(null),D=I(null);if(!D.current){let S=(O=>{R.current!==O&&(R.current=O,u.setHost(O),w())});Object.defineProperty(S,"current",{configurable:!0,enumerable:!0,get(){return R.current},set(O){S(O)}}),D.current=S}return Be(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[u]),j(()=>{p.current=s},[s]),j(()=>{l.current=d},[d]),Be(()=>{u.setInput(a)},[u,a]),j(()=>{if(y.current===h||y.current===L&&h==null){y.current=h;return}y.current=h,p.current?.(h)},[h]),j(()=>{if(B.current===n||B.current===L&&n==null){B.current=n;return}B.current=n,l.current?.(n)},[n]),j(()=>()=>{let S=setTimeout(()=>{g.current===S&&(g.current=null,y.current!==L&&y.current!==null&&p.current?.(null),B.current!==L&&B.current!==null&&l.current?.(null),y.current=null,B.current=null,u.destroy())},0);g.current=S},[u]),{hostRef:D.current,controller:h,state:n}}import{useSyncExternalStore as ut}from"react";import{readBrowserEditorDocument as pt}from"@datalking/begonia-browser/v1";function Ne(e){return ut(t=>e?.subscribe(t)??(()=>{}),()=>pt(e),()=>null)}export{Ge as BegoniaBrowserEditor,ae as BegoniaPdfViewer,Z as BrowserAdvancedOoxmlInspector,Kt as BrowserCommentsDisplayControls,Xt as BrowserContextMenu,qt as BrowserLinkPopover,ge as BrowserPaginatedPreview,Gt as BrowserReviewDisplayControls,Ce as BrowserRichFormatControls,_t as BrowserViewControls,he as BrowserWhiteboardPdfPreview,ye as BrowserWhiteboardPreview,Vt as CommentsSidebar,mt as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,bt as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,xe as DocumentReactMount,zt as EditorToolbar,Bt as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,kt as PREVIEW_TABLE_CELL_VERTICAL_PADDING,Nt as PaginatedLayoutView,Yt as ReviewPanel,Jt as ReviewTimelinePanel,yt as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,ne as VirtualPagedPreview,xt as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,Ot as applyVirtualPagedPreviewAutoscroll,Pt as bindVirtualPagedPreviewWindowDragListeners,It as cloneVirtualPagedPreviewMetrics,Qt as createPdfViewerController,Mt as createVirtualPagedPreviewAutoscrollController,wt as createVirtualPagedPreviewDragSession,Ut as createVirtualPagedPreviewSessionState,ht as isVirtualPagedPreviewFrameTarget,Tt as normalizeVirtualPagedPreviewPinnedPageIndexes,Wt as normalizeVirtualPagedPreviewRequestKey,gt as resolvePaginatedLayoutViewOptions,ft as resolvePaginatedPreviewFlowMode,vt as resolveRequestedPaginatedLayoutFlowMode,Dt as resolveVirtualPagedPreviewAutoscrollDelta,Lt as resolveVirtualPagedPreviewHostMeasurement,Et as resolveVirtualPagedPreviewPositionHit,At as resolveVirtualPagedPreviewPositionHitInMountedFrames,Rt as resolveVirtualPagedPreviewRenderState,Ft as resolveVirtualPagedPreviewResizeObserver,jt as resolveVirtualPagedPreviewSessionCommit,Ht as resolveVirtualPagedPreviewSessionViewportEmission,$t as sameVirtualPagedPreviewMetrics,Pe as useBrowserEditorController,Ne as useBrowserEditorDocument,Ct as useBrowserEditorUi,V as useControllerSnapshot,z as useControllerSnapshotSignal,St as useEditorUiController};
|
|
1
|
+
import{$ as cn,A as zo,B as Vo,C as _o,D as Go,E as Xo,F as Yo,G as qo,H as Jo,I as Qo,J as Zo,K as en,L as ie,M as Me,N as Y,O as se,P as V,Q as Oe,R as tn,S as rn,T as on,U as nn,V as Le,W as ye,X as an,Y as sn,Z as ln,_ as dn,a as Po,aa as un,b as ne,ba as pn,c as ae,ca as Ue,d as De,da as mn,e as ko,f as Co,g as Eo,h as Fo,i as Ho,j as No,k as To,l as Ao,m as Do,n as Ro,o as Io,p as Mo,q as Re,r as Oo,s as Ie,t as Lo,u as X,v as Uo,w as Wo,x as Ko,y as $o,z as jo}from"./chunk-LIAB6VEG.js";import{useEffect as Be,useMemo as Pe,useState as $t}from"react";import{createBrowserEditorBackendAdapter as jt,resolveBrowserEditorUiController as zt}from"@datalking/begonia-browser/v1";import{useEffect as At,useMemo as Dt}from"react";import{summarizeReviewTimeline as Rt}from"@datalking/begonia-document-api/review";import{createBrowserAdvancedOoxmlInspectorController as It}from"@datalking/begonia-browser/ooxml";import{emptyBrowserAdvancedOoxmlInspectorSnapshot as Mt}from"@datalking/begonia-browser/ooxml";import{useState as _}from"react";import{appendEmptyAxisDraft as kt,appendEmptySeriesDraft as Ct,axisDraftsFromModel as Et,legendDraftFromModel as Ft,mergeChartModelWithDrafts as Ht,seriesDraftsFromModel as Nt}from"@datalking/begonia-browser/ooxml";import{jsx as g,jsxs as E}from"react/jsx-runtime";function We({controller:e,selection:t}){let[r,n]=_(t.model.title??""),[o,s]=_(t.model.chartType??""),[i,a]=_(t.model.textBody?.plainText??""),[l,d]=_(Nt(t.model)),[p,k]=_(Et(t.model)),[u,b]=_(Ft(t.model)),h=(c,f)=>d(m=>m.map((C,v)=>v===c?{...C,...f}:C)),S=(c,f)=>k(m=>m.map((C,v)=>v===c?{...C,...f}:C));return E("div",{className:"grid gap-3",children:[E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Title"}),g("input",{value:r,onChange:c=>n(c.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-1 md:grid-cols-2",children:[E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Type"}),g("input",{value:o,onChange:c=>s(c.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-1",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Coverage"}),E("div",{className:"flex flex-wrap gap-2",children:[E("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.seriesCount," series"]}),E("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.categoryCount," categories"]})]})]})]}),E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),g("textarea",{value:i,onChange:c=>a(c.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-2",children:[E("div",{className:"flex items-center justify-between gap-3",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Series"}),g("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>d(c=>Ct(c)),children:"Add series"})]}),l.length===0?g("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart series yet."}):null,l.map((c,f)=>E("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[E("div",{className:"grid gap-2 md:grid-cols-3",children:[g("input",{value:c.name,onChange:m=>h(f,{name:m.target.value}),placeholder:"Series name",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.id,onChange:m=>h(f,{id:m.target.value}),placeholder:"Series id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.order,onChange:m=>h(f,{order:m.target.value}),placeholder:"Order",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),g("input",{value:c.categories,onChange:m=>h(f,{categories:m.target.value}),placeholder:"Categories, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.values,onChange:m=>h(f,{values:m.target.value}),placeholder:"Values, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("div",{className:"flex justify-end",children:g("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>d(m=>m.filter((C,v)=>v!==f)),children:"Remove row"})})]},`${t.record.objectId}-${f}`))]}),E("div",{className:"grid gap-2",children:[E("div",{className:"flex items-center justify-between gap-3",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Axes"}),g("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>k(c=>kt(c)),children:"Add axis"})]}),p.length===0?g("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart axes yet."}):null,p.map((c,f)=>E("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[E("div",{className:"grid gap-2 md:grid-cols-2",children:[g("input",{value:c.id,onChange:m=>S(f,{id:m.target.value}),placeholder:"Axis id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.title,onChange:m=>S(f,{title:m.target.value}),placeholder:"Axis title",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-2 md:grid-cols-3",children:[E("select",{value:c.kind,onChange:m=>S(f,{kind:m.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"category",children:"Category"}),g("option",{value:"value",children:"Value"}),g("option",{value:"series",children:"Series"}),g("option",{value:"date",children:"Date"}),g("option",{value:"unknown",children:"Unknown"})]}),E("select",{value:c.orientation,onChange:m=>S(f,{orientation:m.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"unknown",children:"Orientation"}),g("option",{value:"minMax",children:"Min to Max"}),g("option",{value:"maxMin",children:"Max to Min"})]}),g("input",{value:c.formatCode,onChange:m=>S(f,{formatCode:m.target.value}),placeholder:"Format code",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),g("div",{className:"flex justify-end",children:g("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>k(m=>m.filter((C,v)=>v!==f)),children:"Remove axis"})})]},`${t.record.objectId}-axis-${f}`))]}),E("div",{className:"grid gap-2",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Legend"}),E("div",{className:"grid gap-2 md:grid-cols-2",children:[E("select",{value:u.enabled,onChange:c=>b(f=>({...f,enabled:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"true",children:"Enabled"}),g("option",{value:"false",children:"Absent"})]}),E("select",{value:u.visible,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,visible:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"true",children:"Visible"}),g("option",{value:"false",children:"Hidden"})]})]}),E("div",{className:"grid gap-2 md:grid-cols-2",children:[E("select",{value:u.position,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,position:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"unknown",children:"Position"}),g("option",{value:"left",children:"Left"}),g("option",{value:"right",children:"Right"}),g("option",{value:"top",children:"Top"}),g("option",{value:"bottom",children:"Bottom"}),g("option",{value:"topRight",children:"Top Right"})]}),E("select",{value:u.overlay,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,overlay:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"unknown",children:"Overlay"}),g("option",{value:"true",children:"Overlay"}),g("option",{value:"false",children:"No overlay"})]})]})]}),g("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedChartModel(Ht(t.model,r,o,i,l,{axes:p,legend:u})),children:"Apply chart"})]})}import{useState as Ke}from"react";import{jsx as O,jsxs as q}from"react/jsx-runtime";function $e({controller:e,selection:t}){let[r,n]=Ke(t.plainText),[o,s]=Ke(t.displayMode);return q("div",{className:"grid gap-3",children:[q("div",{className:"grid gap-1",children:[O("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Equation Text"}),O("textarea",{value:r,onChange:i=>n(i.target.value),rows:4,className:"min-h-24 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),q("div",{className:"grid gap-1",children:[O("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Display Mode"}),q("select",{value:o,onChange:i=>s(i.target.value==="block"?"block":"inline"),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[O("option",{value:"inline",children:"Inline"}),O("option",{value:"block",children:"Block"})]})]}),q("div",{className:"grid gap-1",children:[O("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Detected Structures"}),O("div",{className:"flex flex-wrap gap-2",children:t.structures.length===0?O("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Plain text"}):t.structures.map(i=>O("span",{className:"rounded-full bg-sky-100 px-2 py-1 text-[11px] font-semibold text-sky-700",children:i},i))})]}),O("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.setSelectedMathPlainText(r,o),children:"Apply equation"})]})}import{useState as R}from"react";import{mergeShapeModelWithDrafts as Tt}from"@datalking/begonia-browser/ooxml";import{jsx as w,jsxs as H}from"react/jsx-runtime";function je({controller:e,selection:t}){let[r,n]=R(t.model.label??""),[o,s]=R(t.model.shapeType??""),[i,a]=R(t.model.textBody?.plainText??""),[l,d]=R(t.model.geometry?.preset??""),[p,k]=R(t.model.fill?.kind??"unknown"),[u,b]=R(t.model.fill?.color??""),[h,S]=R(t.model.stroke?.color??""),[c,f]=R(t.model.stroke?.widthEmu==null?"":String(t.model.stroke.widthEmu)),[m,C]=R(t.model.stroke?.dash??""),[v,N]=R(t.model.transform?.widthEmu==null?"":String(t.model.transform.widthEmu)),[P,T]=R(t.model.transform?.heightEmu==null?"":String(t.model.transform.heightEmu)),[x,y]=R(t.model.transform?.rotation==null?"":String(t.model.transform.rotation)),[F,I]=R(t.model.anchor?.kind??"unknown"),[W,K]=R(t.model.anchor?.wrap??"unknown");return H("div",{className:"grid gap-3",children:[H("div",{className:"grid gap-2 md:grid-cols-2",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Label"}),w("input",{value:r,onChange:B=>n(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Type"}),w("input",{value:o,onChange:B=>s(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),w("textarea",{value:i,onChange:B=>a(B.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-2 md:grid-cols-2",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Geometry Preset"}),w("input",{value:l,onChange:B=>d(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Color"}),w("input",{value:u,onChange:B=>b(B.target.value),placeholder:"FFF2CC",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Kind"}),H("select",{value:p,onChange:B=>k(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"solid",children:"Solid"}),w("option",{value:"scheme",children:"Scheme"}),w("option",{value:"none",children:"None"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Color"}),w("input",{value:h,onChange:B=>S(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Dash"}),w("input",{value:m,onChange:B=>C(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Width (EMU)"}),w("input",{value:c,onChange:B=>f(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Width (EMU)"}),w("input",{value:v,onChange:B=>N(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Height (EMU)"}),w("input",{value:P,onChange:B=>T(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Rotation"}),w("input",{value:x,onChange:B=>y(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Anchor Kind"}),H("select",{value:F,onChange:B=>I(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"inline",children:"Inline"}),w("option",{value:"anchor",children:"Anchor"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Wrap"}),H("select",{value:W,onChange:B=>K(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"none",children:"None"}),w("option",{value:"square",children:"Square"}),w("option",{value:"tight",children:"Tight"}),w("option",{value:"through",children:"Through"}),w("option",{value:"topAndBottom",children:"Top and Bottom"})]})]})]}),w("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedShapeModel(Tt(t.model,{label:r,shapeType:o,textBody:i,geometryPreset:l,fillKind:p,fillColor:u,strokeColor:h,strokeWidthEmu:c,strokeDash:m,widthEmu:v,heightEmu:P,rotation:x,anchorKind:F,anchorWrap:W})),children:"Apply shape"})]})}import{jsx as D,jsxs as A}from"react/jsx-runtime";function le(...e){return e.filter(Boolean).join(" ")}function Ot(e){return`${e.family}:${e.record.objectId}:${JSON.stringify(e.model)}`}function Lt(e){return e==="math"?"bg-sky-100 text-sky-700":e==="chart"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700"}function Ut(e){return e.kind==="revision"?e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"bg-amber-100 text-amber-700":e.revision.kind==="insert"?"bg-emerald-100 text-emerald-700":e.revision.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700":e.kind==="revision-decision"?e.decision==="accept"?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700":e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function Wt(e){if(e.kind==="revision")return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"Replace":e.revision.kind==="insert"?"Insert":e.revision.kind==="delete"?"Delete":"Format";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function Kt(e){if(e.kind==="revision")return e.revision.prompt??e.excerpt??e.authorName??e.authorId??"Tracked change";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-status"?e.status==="resolved"?"Resolved thread":e.status==="open"?"Reopened thread":"Status change":e.kind==="comment-visibility"?e.internalAfter?"Made internal":"Made external":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Removed thread":"Removed reply":e.authorName??e.authorId??"Review activity"}function Se({editor:e,className:t}){let r=Dt(()=>e?It(e):null,[e]),n=ne(r)??Mt();At(()=>()=>{r?.destroy()},[r]);let o=n.selected,s=o?Ot(o):null,i=r&&o?r.documentApi.review.timelineByObject(o.record.objectId,{actor:r.actor??void 0,enforceVisibilityPolicy:!0,sort:"desc"}):[],a=Rt(i),l=i.slice(0,4);return A("aside",{className:le("grid gap-3",t),"aria-label":"Advanced OOXML inspector",children:[D("header",{className:"grid gap-1",children:A("div",{className:"flex items-center justify-between gap-3",children:[A("div",{children:[D("h2",{className:"text-sm font-semibold text-slate-900",children:"Advanced OOXML"}),D("p",{className:"text-xs text-slate-500",children:"Structured editor for selected math, chart, and shape nodes."})]}),D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",n.trackingEnabled?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"),children:n.trackingEnabled?"Tracking On":"Direct Edit"})]})}),!o||!r?D("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"Select an equation, chart, or shape in the editor to inspect and edit its structured OOXML model."}):A("section",{className:"grid gap-4 rounded-3xl border border-slate-200 bg-white px-4 py-4 shadow-sm",children:[A("div",{className:"grid gap-2",children:[A("div",{className:"flex items-center justify-between gap-3",children:[A("div",{className:"flex items-center gap-2",children:[D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",Lt(o.family)),children:o.family}),D("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-600",children:o.documentMode})]}),D("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.removeSelected(),children:"Remove"})]}),A("div",{className:"grid gap-1 text-[11px] text-slate-500",children:[A("span",{children:["Object: ",o.record.objectId]}),A("span",{children:["Path: ",o.record.path.join(".")]})]})]}),o.family==="math"?D($e,{controller:r,selection:o},s??void 0):null,o.family==="chart"?D(We,{controller:r,selection:o},s??void 0):null,o.family==="shape"?D(je,{controller:r,selection:o},s??void 0):null,D("p",{className:"text-[11px] text-slate-500",children:n.trackingEnabled?"Inspector edits flow through tracked OOXML replacements so accept/reject stays available.":"Inspector edits apply directly to the selected OOXML object."}),A("section",{className:"grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[A("div",{className:"flex items-end justify-between gap-3",children:[A("div",{children:[D("h3",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-600",children:"Object Review"}),A("p",{className:"text-xs text-slate-500",children:[a.total," linked item",a.total===1?"":"s"]})]}),A("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[A("span",{children:[a.revisions," revision",a.revisions===1?"":"s"]}),A("span",{children:[a.commentThreads," thread",a.commentThreads===1?"":"s"]}),A("span",{children:[a.commentReplies," repl",a.commentReplies===1?"y":"ies"]})]})]}),l.length===0?D("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-white px-3 py-4 text-xs text-slate-500",children:"No tracked review activity is currently linked to this OOXML object."}):D("div",{className:"grid gap-2",children:l.map(d=>A("div",{className:"grid gap-1 rounded-2xl border border-slate-200 bg-white px-3 py-3",children:[A("div",{className:"flex items-center justify-between gap-3",children:[D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",Ut(d)),children:Wt(d)}),D("span",{className:"text-[11px] text-slate-400",children:d.authorName??d.authorId??"Unknown"})]}),D("p",{className:"text-xs text-slate-700",children:d.text||"Formatting change"}),D("p",{className:"text-[11px] text-slate-500",children:Kt(d)})]},d.id))})]})]})]})}import{jsx as ze}from"react/jsx-runtime";function Vt(e){return zt(e)}function _t({room:e,actor:t,collaborative:r,collaborationSession:n,documentMode:o,enableEmbeddedAdvancedOoxmlEditors:s=!0,features:i,fitWidthOptions:a,flowMode:l,initialContent:d,layoutMode:p,modules:k,onEditorChange:u,onTransaction:b,onUpdate:h,participant:S,permissionResolver:c,onControllerChange:f,onStateChange:m,schema:C,showAdvancedOoxmlInspector:v=!0,trackingEnabled:N=!0,viewSelect:P=!0,zoomMode:T,zoomPercent:x,...y}){let[F,I]=$t(null),W=Pe(()=>jt(),[]),K=Pe(()=>({room:e,actor:t,collaborative:r,collaborationSession:n,documentMode:o,enableEmbeddedAdvancedOoxmlEditors:s,features:i,fitWidthOptions:a,flowMode:l,initialContent:d,layoutMode:p,modules:k,onTransaction:b,onUpdate:h,participant:S,permissionResolver:c,schema:C,trackingEnabled:N,viewSelect:P,zoomMode:T,zoomPercent:x}),[e,t,r,n,o,s,i,a,l,d,p,k,b,h,S,c,C,N,P,T,x]),B=Pe(()=>Vt(F),[F]);return Be(()=>{f?.(B)},[B,f]),Be(()=>{if(m){if(!B){m(null);return}return m(B.getState()),B.subscribe(oe=>{m(oe)})}},[B,m]),Be(()=>()=>{f?.(null),m?.(null)},[f,m]),ze(Ue,{...y,backend:W,backendInput:K,sidebarStart:v?ze(Se,{editor:F}):null,onEditorChange:oe=>{I(oe),u?.(oe)}})}import{jsx as ce,jsxs as Xt}from"react/jsx-runtime";function ke(e,t){return typeof window<"u"?window.prompt(e,t):null}function de(e,t){return e?.commands[t]??null}function Gt({editor:e,snapshot:t}){if(!e||!t||!t.selection)return null;let r=t.selection.formatting,n=!t.editable,o=(b,h)=>{n||e.execute(b,h)},s=de(t,"text-color"),i=de(t,"highlight-color"),a=de(t,"font-size"),l=de(t,"font-family"),d=n?"Document is read-only in the current document mode.":void 0,p=(b,h,S)=>{let c=ke(`${b}. Enter a CSS color value or "none" to clear.`,h??"");if(c==null)return;let f=c.trim(),m=f.length===0||f.toLowerCase()==="none"?null:f;o(S,m)},k=()=>{let b=ke('Set font size in points. Enter "none" to clear.',r.fontSize==null?"":String(r.fontSize));if(b==null)return;let h=b.trim();if(!h||h.toLowerCase()==="none"){o("font-size",null);return}let S=Number(h.replace(/pt$/i,"").trim());Number.isFinite(S)&&S>0&&o("font-size",S)},u=()=>{let b=ke('Set font family. Enter "none" to clear.',r.fontFamily??"");if(b==null)return;let h=b.trim();o("font-family",!h||h.toLowerCase()==="none"?null:h)};return Xt("div",{className:"flex flex-wrap gap-2 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] p-2",children:[ce(Y,{active:s?.active??r.color!=null,mixed:s?.mixed??r.mixed?.color===!0,disabled:n||s?.disabled,label:r.color?`Text ${r.color}`:"Text Color",title:d,onClick:()=>p("Set text color",r.color,"text-color")}),ce(Y,{active:i?.active??r.highlight!=null,mixed:i?.mixed??r.mixed?.highlight===!0,disabled:n||i?.disabled,label:r.highlight?`Highlight ${r.highlight}`:"Highlight",title:d,onClick:()=>p("Set highlight color",r.highlight,"highlight-color")}),ce(Y,{active:a?.active??r.fontSize!=null,mixed:a?.mixed??r.mixed?.fontSize===!0,disabled:n||a?.disabled,label:r.fontSize!=null?`Size ${r.fontSize}`:"Font Size",title:d,onClick:k}),ce(Y,{active:l?.active??r.fontFamily!=null,mixed:l?.mixed??r.mixed?.fontFamily===!0,disabled:n||l?.disabled,label:r.fontFamily?`Font ${r.fontFamily}`:"Font Family",title:d,onClick:u})]})}import{useEffect as J,useRef as Ce}from"react";import{createDocumentSurface as Zt}from"@datalking/begonia-engine";import{useRef as Yt}from"react";var qt=Object.freeze([]);function Jt(e){return e?.length?e:qt}function Qt(e,t){return e.length===t.length&&e.every((r,n)=>Object.is(r,t[n]))}function ue(e){let t=Jt(e),r=Yt(t);return Qt(r.current,t)||(r.current=t),r.current}import{jsx as Ve}from"react/jsx-runtime";function _e({room:e,collaborative:t,participant:r,schema:n,trackingEnabled:o=!0,editable:s=!0,features:i,onSurfaceReady:a}){let l=Ce(null),d=Ce(null),p=Ce(a),k=ue(i);return J(()=>{p.current=a},[a]),J(()=>{if(!l.current)return;let u=Zt({element:l.current,participant:r,schema:n,collaborative:t??e,trackingEnabled:o,editable:s,features:k});return d.current=u,p.current?.(u),()=>{d.current=null,p.current?.(null),u.destroy()}},[t,e,n,k]),J(()=>{d.current?.setParticipant(r)},[r.color,r.id,r.name]),J(()=>{d.current?.setTrackingEnabled(o)},[o]),J(()=>{d.current?.setEditable(s)},[s]),Ve("div",{className:"editor-frame",children:Ve("div",{ref:l,className:"editor-host"})})}import{createBrowserEditorUiFromController as er}from"@datalking/begonia-browser/v1";import{jsx as tr}from"react/jsx-runtime";function Ge({editor:e,...t}){let r=X(()=>e?er(e):null,[e]);return tr(ie,{...t,editor:r})}import{useCallback as j,useEffect as Ee,useMemo as vr,useRef as Fe,useState as wr,useSyncExternalStore as tt}from"react";import{createBrowserEditorUiFromController as yr}from"@datalking/begonia-browser/v1";import{createPaginatedEditingSession as Sr,installPaginatedColumnKeyboard as Br,installPaginatedTableBoundaryKeyboard as Pr,isSameLayoutDocument as kr}from"@datalking/begonia-browser-sdk";import{PAGINATED_EDITING_HOST_CLASS as Cr,resolvePaginatedEditingHostStyle as Er}from"@datalking/begonia-layout-renderer";import{useCallback as Q,useRef as Xe,useState as Ye}from"react";import{initialBandPressTracker as rr,resolveBandPress as or,resolveFooterBand as nr,resolveHeaderBand as ar}from"@datalking/begonia-browser-sdk";import{Fragment as xr,jsx as $,jsxs as pe}from"react/jsx-runtime";var ir=500,sr=400,lr="var(--ald-band-accent, #4472c4)",dr={position:"absolute",inset:0,pointerEvents:"none"};function cr(e,t,r,n){let o=r?{...e.kind==="footer"?{top:void 0,bottom:(n-e.top-e.height)*t}:{top:e.top*t},height:"auto",minHeight:e.height*t,display:"flex",flexDirection:"column",justifyContent:e.kind==="footer"?"flex-end":"flex-start"}:{};return{position:"absolute",left:e.left*t,top:e.top*t,width:e.width*t,height:e.height*t,...o,pointerEvents:"auto"}}function ur(e,t){return{position:"relative",width:"100%",...e.kind==="header"?{marginTop:e.contentTop*t}:{},minHeight:e.contentHeight*t,cursor:"auto"}}function pr(e){return{position:"absolute",left:0,right:0,...e.kind==="header"?{bottom:"100%",marginBottom:4}:{top:"100%",marginTop:4},display:"flex",justifyContent:"flex-end",pointerEvents:"none",zIndex:2}}function mr(e,t){return{position:"absolute",left:0,right:0,[e.kind==="header"?"bottom":"top"]:0,height:1,background:t?lr:"rgba(68, 114, 196, 0.35)",opacity:t?1:.9,pointerEvents:"none"}}function fr(e,t){return{position:"absolute",left:0,right:0,top:0,height:e.height*t,border:"var(--ald-band-hover-border, 1px dashed rgba(51, 102, 255, 0.8))",borderRadius:2,pointerEvents:"none"}}function gr(e,t){let r=e.height*t,n=4*t,o=22*t,s=28*t,i=-n-o,a=r+n;return{position:"absolute",left:0,...e.top*t>=s?{top:i}:{top:a},padding:"3px 7px",borderRadius:2,fontSize:12,lineHeight:"16px",whiteSpace:"nowrap",color:"var(--ald-band-hint-fg, #ffffff)",background:"var(--ald-band-hint-bg, rgba(18, 22, 33, 0.85))",pointerEvents:"none"}}function br(e,t){let r=e.kind==="header"?e.top:e.marginDistance,n=r*t>=28*t?{top:-(23*t+4*t)}:{top:e.height*t+4*t};return{position:"absolute",left:0,...e.kind==="footer"&&r*t>=28*t?{bottom:-(23*t+4*t)}:n,padding:"3px 10px",borderRadius:6,fontSize:13*t,lineHeight:"17px",whiteSpace:"nowrap",color:"var(--ald-band-banner-fg, #ffffff)",background:"var(--ald-band-banner-bg, #1b3fbf)",pointerEvents:"none"}}function Qe(e){return e?.activeTarget!=null}function qe(e,t,r){return e==null||e.kind!==r||e.sectionIndex!==t.sectionIndex?!1:e.pageNumber==null||e.pageNumber===t.pageNumber}function Je({band:e,page:t,scale:r,open:n,props:o}){let s=e.kind==="header"?"Edit page header":"Edit page footer",i=o.disabled===!0,[a,l]=Ye(!1),[d,p]=Ye(!1),k=Xe(rr),u=Xe(0),b=o.doublePressIntervalMs??ir,h=Q(()=>{if(o.disabled===!0)return;let P=Date.now();P-u.current<sr||(u.current=P,o.onActivateBand?.(e.kind,t))},[e.kind,t,o]),S=Q(P=>{P.stopPropagation();let T=or(k.current,{primary:P.button===0,detail:P.detail,time:Date.now(),x:P.clientX,y:P.clientY,intervalMs:b});k.current=T.tracker,!(!T.open||n)&&(P.preventDefault(),h())},[h,b,n]),c=Q(P=>{P.stopPropagation()},[]),f=Q(P=>{P.stopPropagation(),n||h()},[h,n]),m=Q(P=>{o.disabled!==!0&&(n||(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),P.stopPropagation(),h()))},[h,n,o.disabled]),C=(a||d)&&!n&&!i,v=d?e.kind==="header"?"Press Enter to edit header":"Press Enter to edit footer":e.kind==="header"?"Double-click to edit header":"Double-click to edit footer",N=n;return pe("div",{role:"button",tabIndex:i?-1:0,"aria-label":s,"aria-disabled":i?!0:void 0,"data-begonia-header-footer-band":e.kind,"data-begonia-header-footer-page":t.pageNumber,"data-begonia-header-footer-band-open":n?"true":void 0,onPointerDown:S,onMouseDown:c,onDoubleClick:f,onKeyDown:m,onPointerEnter:()=>l(!0),onPointerLeave:()=>l(!1),onFocus:()=>p(!0),onBlur:()=>p(!1),className:se("transition-colors duration-150 outline-none","cursor-default"),style:{...cr(e,r,n,t.pageSize.height),background:n?"var(--ald-band-active-bg, var(--ald-page-bg, #fffdfa))":"transparent"},children:[N?$("div",{"data-begonia-header-footer-rule":"true",style:mr(e,n),"aria-hidden":"true"}):null,C?pe(xr,{children:[$("div",{"data-begonia-header-footer-hover":"true",style:fr(e,r),"aria-hidden":"true"}),$("div",{"data-begonia-header-footer-hint":"true",style:gr(e,r),"aria-hidden":"true",children:v})]}):null,n?pe("div",{"data-begonia-header-footer-banner":"true",style:br(e,r),"aria-hidden":"true",children:[e.kind==="header"?"Editing Header":"Editing Footer"," (",o.activeTarget?.slot??"default",") Page ",t.pageNumber," \u2013 Press Esc to return"]}):null,n&&o.activeBandContent?$("div",{"data-begonia-header-footer-editor":"true",style:ur(e,r),children:o.activeBandContent}):null,n&&o.activeBandToolbar?$("div",{"data-begonia-header-footer-toolbar":"true",style:pr(e),children:o.activeBandToolbar}):null]})}var hr={header:!0,footer:!0};function me(e){let{frame:t,activeTarget:r}=e,n=t.page,o=e.resolveSlots?.(n)??hr,s=o.header?ar(n):null,i=o.footer?nr(n):null;return!s&&!i?null:pe("div",{style:dr,"data-begonia-header-footer-bands":"true",children:[s?$(Je,{band:s,page:n,scale:e.scale,open:qe(r,n,"header"),props:e}):null,i?$(Je,{band:i,page:n,scale:e.scale,open:qe(r,n,"footer"),props:e}):null]})}import{Fragment as Ze,jsx as Z,jsxs as et}from"react/jsx-runtime";function Fr(e,t){let r=Fe(null),n=j(()=>{let o=t?.preview.readLayoutSource()??null,s=r.current;return o&&s&&kr(s,o)?s:(r.current=o,o)},[t]);return tt(j(o=>e?e.subscribe(o):()=>{},[e]),n,()=>null)}var Hr=Er(),Nr=Hr;function Tr({hostRef:e,hostClassName:t}){return Z("div",{ref:e,className:[Cr,t].filter(Boolean).join(" "),style:Nr})}function rt({editor:e,hostRef:t,hostClassName:r,surfaceId:n,...o}){let s=Fe(null),i=j(v=>{s.current=v,t(v)},[t]),a=X(()=>e?yr(e):null,[e]),l=X(()=>a&&e?Sr({editor:{selection:a.selection,preview:a.preview},focus:()=>{e.surface.focus()},getEditorHost:()=>s.current,editorId:n}):null,[e,a]);Ee(()=>{if(e)return Pr({getView:()=>{try{return e.surface.view??null}catch{return null}},ownerDocument:s.current?.ownerDocument??null})},[e]),Ee(()=>{if(!(!e||!a))return Br({getView:()=>{try{return e.surface.view??null}catch{return null}},getProjection:()=>{try{return a.preview.getResolvedProjection?.()??null}catch{return null}},getMeasurement:()=>{try{return a.preview.getResolvedProjectionGeometryOptions?.()??null}catch{return null}},ownerDocument:s.current?.ownerDocument??null})},[e,a]);let d=Fr(e,a),p=a?.preview.readLayoutAdapter()??o.adapter??void 0,k=a?d:o.source??null,u=tt(j(v=>l?l.subscribe(v):()=>{},[l]),()=>l?.getSnapshot()??null,()=>null),[b,h]=wr(null);Ee(()=>{if(!e){h(null);return}let v=()=>{let N=e.getState();h({comments:{items:N.comments,activeCommentIds:N.activeCommentIds??[]}})};return v(),e.subscribe(v)},[e]);let S=Fe(null),c=j(v=>{!l||S.current===v||(S.current=v,l.attachScrollHost(v),l.reveal())},[l]),f=j(v=>{l?.attachPreviewHost(v)},[l]),m=j(()=>{l?.releaseComposition()},[l]),C=vr(()=>l?(v,N)=>et(Ze,{children:[o.headerFooter?Z(me,{...o.headerFooter,frame:v,scale:N}):null,Z(Ie,{frame:v,scale:N,overlay:u?.overlay??null,flowMode:o.flowMode??"paginated",composing:u?.composing??!1,compositionText:u?.compositionText??"",caretVisible:(u?.focused??!1)&&!Qe(o.headerFooter)})]}):void 0,[o.flowMode,o.headerFooter,l,u?.composing,u?.compositionText,u?.focused,u?.overlay]);return et(Ze,{children:[Z(Tr,{hostRef:i,hostClassName:r}),Z(ie,{...o,deferLayout:u?.compositionHeld??!1,onDeferralRelease:m,resolveCommentState:o.resolveCommentState??Me(b,null),editor:a,adapter:p,source:k,renderPageOverlay:C,onResolvedScrollHostChange:c,onResolvedPreviewHostChange:f,onProjectionContextMenu:(v,N)=>e?.openContextMenuAt(N)===!0})]})}import{useRef as Ar}from"react";import{jsx as ee,jsxs as nt}from"react/jsx-runtime";function fe(e,t){let r=t.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-r.left)/Math.max(1,r.width))),y:Math.min(1,Math.max(0,(e.clientY-r.top)/Math.max(1,r.height)))}}function Dr(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,minHeight:`${e.minHeight*100}%`,color:e.color,fontSize:`calc(${e.fontSize*100}% + 10px)`,lineHeight:1.2,padding:"4px 6px",borderRadius:10,background:t?"rgba(255,255,255,0.86)":"rgba(255,255,255,0.72)",border:t?"1px solid rgba(14, 116, 144, 0.45)":"1px solid rgba(148, 163, 184, 0.28)",boxShadow:t?"0 6px 18px rgba(14, 116, 144, 0.16)":"0 4px 12px rgba(15, 23, 42, 0.08)",cursor:"move",userSelect:"none",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}}function Rr(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:12,boxShadow:t?"0 10px 20px rgba(14, 116, 144, 0.18)":"0 4px 10px rgba(15, 23, 42, 0.10)",outline:t?"2px solid rgba(14, 116, 144, 0.48)":"none",cursor:"move",userSelect:"none",objectFit:"contain"}}function Ir(e,t){return{position:"absolute",zIndex:0,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:8,background:e.color,opacity:e.opacity,boxShadow:t?"0 0 0 2px rgba(14, 116, 144, 0.4)":"inset 0 0 0 1px rgba(120, 53, 15, 0.08)",mixBlendMode:"multiply",cursor:"move",userSelect:"none"}}function Mr(e){return e.points.map((t,r)=>`${r===0?"M":"L"} ${t.x*100} ${t.y*100}`).join(" ")}function Or(e,t){return e.annotations.filter(r=>r.pageNumber===t)}function ot(e,t,r){return e.kind==="stroke"?ee("path",{"data-annotation-kind":e.kind,d:Mr(e),stroke:e.color,strokeOpacity:e.opacity,strokeWidth:e.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke",onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id):e.kind==="text"?ee("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:Dr(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)},children:e.text},e.id):e.kind==="highlight"?ee("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:Ir(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id):ee("img",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,alt:e.label,src:e.src,style:Rr(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id)}function ge({pageNumber:e,controller:t,snapshot:r}){let n=Ar(null),o=Or(r,e),s=r.activeStroke?.pageNumber===e?r.activeStroke:null;return nt("div",{style:{position:"absolute",inset:0,pointerEvents:r.enabled?"auto":"none",opacity:r.opacity},onPointerDown:i=>{if(!r.enabled)return;let a=fe(i,i.currentTarget);if(r.tool==="draw"){i.currentTarget.setPointerCapture(i.pointerId),t.beginStroke(e,a);return}if(r.tool==="erase"){i.currentTarget.setPointerCapture(i.pointerId),t.eraseAt(e,a);return}if(r.tool==="text"){t.addText(e,a);return}if(r.tool==="highlight"){t.addHighlight(e,a);return}t.selectAnnotation(null)},onPointerMove:i=>{if(!r.enabled)return;let a=fe(i,i.currentTarget);if(r.tool==="draw"&&r.activeStroke&&i.buttons===1){t.appendStroke(a);return}if(r.tool==="erase"&&i.buttons===1){t.eraseAt(e,a);return}n.current&&n.current.pageNumber===e&&i.buttons===1&&(t.moveAnnotation(n.current.annotationId,{x:a.x-n.current.lastPoint.x,y:a.y-n.current.lastPoint.y}),n.current={...n.current,lastPoint:a})},onPointerUp:i=>{r.tool==="draw"&&t.commitStroke(),n.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId)},onDragOver:i=>{r.enabled&&i.preventDefault()},onDrop:i=>{if(!r.enabled)return;i.preventDefault();let a=fe(i,i.currentTarget),l=i.dataTransfer.getData("application/sticker"),d=i.dataTransfer.getData("application/comment");if(l){t.placeSticker(e,a,l);return}if(d){let p=r.comments.find(k=>k.id===d);p&&t.addText(e,a,p.text)}},children:[nt("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",overflow:"visible"},children:[o.filter(i=>i.kind==="stroke").map(i=>ot(i,i.id===r.selectedAnnotationId,a=>t.selectAnnotation(a.id))),s?ee("path",{d:s.points.map((i,a)=>`${a===0?"M":"L"} ${i.x*100} ${i.y*100}`).join(" "),stroke:s.color,strokeOpacity:s.opacity,strokeWidth:s.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}):null]}),o.filter(i=>i.kind!=="stroke").map(i=>ot(i,i.id===r.selectedAnnotationId,(a,l)=>{t.selectAnnotation(a.id);let d=l.currentTarget.parentElement,p=d instanceof HTMLElement?fe(l,d):a.kind==="text"||a.kind==="sticker"||a.kind==="highlight"?{x:a.x,y:a.y}:{x:0,y:0};n.current={annotationId:a.id,pageNumber:e,lastPoint:p}}))]})}import{jsx as at}from"react/jsx-runtime";function it({viewer:e,controller:t,...r}){ae(t,o=>o.version);let n=t.getSnapshot();return at(De,{controller:e,...r,renderPageOverlay:o=>at(ge,{pageNumber:o.pageNumber,controller:t,snapshot:n})})}import{jsx as He}from"react/jsx-runtime";function st({projection:e,controller:t,height:r=720,scrollHost:n=null,scale:o=.52,pageGap:s=28,windowPages:i=5,overscan:a=2,virtualize:l=!0,layoutMode:d="vertical",flowMode:p,anchorPageNumber:k=null,pinnedPageNumbers:u,emptyLabel:b="No paginated preview available yet.",onViewportChange:h,className:S,style:c}){ae(t,m=>m.version);let f=t.getSnapshot();return He("div",{className:S,style:c,children:He(Re,{projection:e,version:f.version,height:r,scrollHost:n,scale:o,pageGap:s,windowPages:i,overscan:a,virtualize:l,layoutMode:d,flowMode:p,anchorPageNumber:k,pinnedPageNumbers:u,emptyLabel:b,onViewportChange:h,renderPageOverlay:m=>He(ge,{pageNumber:m.page.pageNumber,controller:t,snapshot:f})})})}import{useEffect as Lr,useRef as Ur}from"react";import{createDocumentSurface as Wr}from"@datalking/begonia-engine";import{toHeaderFooterParagraphAlignment as Kr}from"@datalking/begonia-browser-sdk";import{documentWideMutationEffect as $r}from"@datalking/begonia-editor-contracts";var jr={position:"absolute",left:"-10000px",top:"0",width:"600px",height:"200px",overflow:"hidden",pointerEvents:"none"};function zr(e){let t=e[0]?.type.schema;return t?t.nodes.doc.create(null,e):null}function be(e,t){let r=document.createElement("div");Object.assign(r.style,jr),document.body.appendChild(r);let n=zr(t),o=Wr({element:r,participant:e,...n?{initialContent:n}:{},trackingEnabled:!1,editable:!0}),s=!1,i=()=>{s||(s=!0,o.destroy(),r.remove())};return{element:r,runtime:o,surface:{readDocument:()=>o.document,replaceDocument:a=>o.replaceDocument(a,{origin:"editor",intent:"replace-header-footer-scratch-document",effects:[$r("content")]}),focus:()=>o.focus(),destroy:i,subscribe:a=>o.subscribe(a),toggleInlineFormat:a=>{switch(a){case"bold":return o.toggleBold();case"italic":return o.toggleItalic();case"underline":return o.toggleUnderline();case"strike":return o.toggleStrike();default:return!1}},readInlineFormat:()=>{let{bold:a,italic:l,underline:d,strike:p}=o.describeSelection().formatting;return{bold:a,italic:l,underline:d,strike:p}},applyTextColor:a=>o.setTextStyle({color:a}),readTextColor:()=>o.describeSelection().formatting.color,setParagraphAlignment:a=>o.setAlignment(a),readParagraphAlignment:()=>Kr(o.describeSelection().block?.align)},destroy:i}}function lt(e){let t=Ur(null);return Lr(()=>{if(e)return t.current=e(),()=>{t.current?.destroy(),t.current=null}},[e]),t}import{Fragment as ct,jsx as M,jsxs as he}from"react/jsx-runtime";var Vr=[{key:"bold",label:"B",title:"Bold",style:{fontWeight:700}},{key:"italic",label:"I",title:"Italic",style:{fontStyle:"italic"}},{key:"underline",label:"U",title:"Underline",style:{textDecoration:"underline"}},{key:"strike",label:"S",title:"Strikethrough",style:{textDecoration:"line-through"}}],_r=[{align:"left",title:"Align left",rules:[[0,12],[0,7],[0,12]]},{align:"center",title:"Align center",rules:[[0,12],[2.5,7],[0,12]]},{align:"right",title:"Align right",rules:[[0,12],[5,7],[0,12]]},{align:"justify",title:"Justify",rules:[[0,12],[0,12],[0,12]]}],Gr={display:"flex",alignItems:"center",gap:2,padding:2,borderRadius:4,background:"var(--ald-band-toolbar-bg, rgba(255, 255, 255, 0.92))",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.16)",pointerEvents:"auto",zIndex:2};function ut(e){e.preventDefault(),e.stopPropagation()}function pt(e,t){return{minWidth:18,height:18,padding:"0 4px",border:"1px solid "+(e?"var(--ald-band-accent, #4472c4)":"transparent"),borderRadius:3,background:e?"rgba(68, 114, 196, 0.14)":"transparent",color:e?"var(--ald-band-accent, #4472c4)":"#334155",font:"600 11px/1 ui-sans-serif, system-ui, sans-serif",cursor:t?"default":"pointer",opacity:t?.5:1,pointerEvents:"auto"}}var Xr={display:"inline-flex",alignItems:"center",gap:2},dt={width:1,height:12,margin:"0 2px",background:"var(--ald-band-border, #cbd5e1)"},Yr={display:"inline-flex",alignItems:"center",gap:3,height:18,padding:"0 3px",border:"1px solid var(--ald-band-border, #cbd5e1)",borderRadius:3,background:"var(--ald-surface, #ffffff)",pointerEvents:"auto"},qr={width:9,height:9,flexShrink:0,borderRadius:2,border:"1px solid rgba(15, 23, 42, 0.25)"},Jr={height:16,maxWidth:62,border:"none",background:"transparent",color:"#334155",font:"600 11px/1 ui-sans-serif, system-ui, sans-serif",cursor:"pointer",outline:"none"};function mt(e){let{format:t,onToggle:r,alignment:n=null,onAlignmentChange:o,textColor:s=null,onTextColorChange:i,disabled:a=!1,scale:l=1}=e;return he("div",{"data-begonia-header-footer-format":"true",role:"toolbar","aria-label":"Header and footer text style",style:{...Gr,transform:l!==1?`scale(${l})`:void 0},onMouseDown:d=>d.stopPropagation(),children:[Vr.map(({key:d,label:p,style:k,title:u})=>M("button",{type:"button",title:u,"aria-label":u,"aria-pressed":t[d],"data-begonia-header-footer-format-key":d,disabled:a,style:{...pt(t[d],a),...k},onMouseDown:ut,onClick:()=>r(d),children:p},d)),i?he(ct,{children:[M("span",{"aria-hidden":!0,style:dt}),M(Qr,{value:s??"",disabled:a,onChange:i})]}):null,o?he(ct,{children:[M("span",{"aria-hidden":!0,style:dt}),M(Zr,{alignment:n,disabled:a,onAlignmentChange:o})]}):null]})}function Qr(e){let{value:t,disabled:r,onChange:n}=e,o=ye(t)??"",s=Le(o),i=s.find(l=>l.value===o),a=i?.label??"Automatic";return he("label",{title:`Text color: ${a}`,style:{...Yr,opacity:r?.5:1},children:[M("span",{"aria-hidden":!0,style:{...qr,background:i?.swatch??"transparent"}}),M("select",{"aria-label":"Text color",title:`Text color: ${a}`,disabled:r,value:o,onChange:l=>n(ye(l.target.value)),style:Jr,children:s.map(l=>M("option",{value:l.value,children:l.label},l.value))})]})}function Zr(e){let{alignment:t,disabled:r,onAlignmentChange:n}=e;return M("span",{role:"group","aria-label":"Paragraph alignment",style:Xr,children:_r.map(({align:o,title:s,rules:i})=>{let a=t===o;return M("button",{type:"button",title:s,"aria-label":s,"aria-pressed":a,"data-begonia-header-footer-align":o,disabled:r,style:pt(a,r),onMouseDown:ut,onClick:()=>n(o),children:M("svg",{"aria-hidden":!0,viewBox:"0 0 12 12",width:11,height:11,style:{display:"block"},children:i.map(([l,d],p)=>M("rect",{x:l,y:1+p*3.6,width:d,height:1.4,rx:.7,fill:"currentColor"},p))})},o)})})}import{headerFooterSlotLabel as Te}from"@datalking/begonia-browser-sdk";import{Fragment as oo,jsx as L,jsxs as xe}from"react/jsx-runtime";var eo=["default","first","even"],to=["header","footer"];function Ne(){}function ro(e){return e.target?Te(e.target.kind,e.target.slot):null}function ft({editState:e,availableSlots:t,variants:r=null,linkState:n=null,disabled:o=!1,onOpen:s,onClose:i,onToggleTitlePage:a,onToggleOddEven:l,onToggleLinkToPrevious:d}){let p=e.phase==="editing"||e.phase==="saving",k=ro(e);return xe(oo,{children:[L(Oe,{}),r?xe("span",{role:"group","aria-label":"Page variants",className:"flex items-center gap-0.5",children:[L(V,{ariaLabel:"Different first page",title:"Different first page",pressed:r.titlePage,disabled:o||!a,onClick:a??Ne,children:"1st"}),L(V,{ariaLabel:"Different odd and even pages",title:"Different odd and even pages",pressed:r.oddEven,disabled:o||!l,onClick:l??Ne,children:"Odd/even"})]}):null,to.map(u=>xe("span",{role:"group","aria-label":u==="header"?"Header":"Footer",className:"flex items-center gap-0.5",children:[L(V,{ariaLabel:u==="header"?"Edit header":"Edit footer",title:u==="header"?"Edit header":"Edit footer",pressed:p&&e.target?.kind===u,disabled:o,onClick:()=>s(u,"default"),children:u==="header"?"H":"F"}),eo.filter(b=>b!=="default").map(b=>L(V,{ariaLabel:`${Te(u,b)}`,title:Te(u,b),pressed:p&&e.target?.kind===u&&e.target?.slot===b,disabled:o||!t[b],onClick:()=>s(u,b),children:b==="first"?"1":"2"},b))]},u)),p&&n&&n.available?L("span",{role:"group","aria-label":"Section link",className:"flex items-center gap-0.5",children:L(V,{ariaLabel:"Link to Previous",title:"Link to Previous",pressed:n.linked,disabled:o||!d,onClick:d??Ne,children:"Link"})}):null,p?xe("span",{className:se("ml-1 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium","bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)]"),"aria-live":"polite",children:[k,L("button",{type:"button",onClick:i,className:"rounded-full px-1 text-[11px] font-semibold underline","aria-label":"Close header or footer editing",children:"Close"})]}):null]})}import{useEffect as no,useRef as ao}from"react";import{jsx as io}from"react/jsx-runtime";function gt({mount:e,autoFocus:t=!0}){let r=ao(null);return no(()=>{let n=r.current;if(!(!n||!e))return e.removeAttribute("style"),n.appendChild(e),t&&e.querySelector('[contenteditable="true"]')?.focus(),()=>{e.parentElement===n&&e.remove()}},[t,e]),io("div",{ref:r,"data-begonia-header-footer-scratch":"true",style:{minHeight:24,width:"100%"}})}import{useCallback as z,useEffect as ve,useMemo as so,useRef as Ae,useState as te}from"react";import{createHeaderFooterEditingController as lo,EMPTY_HEADER_FOOTER_INLINE_FORMAT as we,initialHeaderFooterEditState as bt,resolveHeaderFooterPress as co}from"@datalking/begonia-browser-sdk";import{isInPaginatedUiSurface as uo,PAGINATED_BAND_DATA_ATTRIBUTE as ht,PAGINATED_BAND_ROOT_DATA_ATTRIBUTE as po}from"@datalking/begonia-layout-renderer";import{createEditorUiHost as mo}from"@datalking/begonia-engine";function vt({controller:e,onCommitted:t,readSectionIndex:r}){let[n,o]=te(bt),[s,i]=te(null),[a,l]=te(we),[d,p]=te(null),[k,u]=te(null),b=Ae(null),h=Ae(null),S=Ae(t);S.current=t,ve(()=>{if(!e){b.current=null,o(bt);return}let x=lo({readApi:()=>e.documentApi,createScratchSurface:F=>{let I=be(e.surface?.participant??fo,F);return h.current=I,i(I.element),I.surface}});b.current=x;let y=x.subscribe(()=>{o(x.getState())});return o(x.getState()),()=>{y(),x.destroy(),h.current?.destroy(),h.current=null,b.current=null,i(null)}},[e]);let c=z((x,y)=>{let F=b.current;F&&(F.openAtPage(x,y),o(F.getState()))},[]),f=z((x,y,F)=>{let I=b.current;if(!I||!e)return;let W=F?.sectionIndex??r?.()??0;I.openSlot(W,x,y,F?.pageNumber??null),o(I.getState())},[e,r]),m=z(()=>{let x=b.current;if(!x)return;let y=x.commit();o(x.getState()),y&&S.current?.()},[]),C=z((x={})=>{let y=b.current;if(!y)return;let F=x.restoreFocus!==!1,I=y.close();o(y.getState()),I&&S.current?.(),F&&queueMicrotask(()=>{let K=e?.surface?.view?.dom;if(K&&typeof K.focus=="function"){K.focus({preventScroll:!0});return}e?.surface?.focus()})},[e]);ve(()=>{if(!n.phase||n.phase==="idle")return;let x=y=>{y.key==="Escape"&&C()};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[C,n.phase]),ve(()=>{if(n.phase!=="editing"&&n.phase!=="saving")return;let x=y=>{co({target:y.target,insideActiveBand:xt(y.target,!0),insideAnyBand:xt(y.target,!1),insideChrome:uo(y.target)})==="exit"&&C({restoreFocus:!1})};return document.addEventListener("pointerdown",x),()=>{document.removeEventListener("pointerdown",x)}},[C,n.phase]);let v=so(()=>mo(h.current?.runtime??null),[s]);ve(()=>{let x=h.current?.surface;if(!x?.readInlineFormat){l(we),p(null),u(null);return}let y=()=>{l(x.readInlineFormat?.()??we),p(x.readParagraphAlignment?.()??null),u(x.readTextColor?.()??null)};return y(),x.subscribe?.(y)},[s]);let N=z(x=>{let y=h.current?.surface;if(!y?.toggleInlineFormat)return!1;let F=y.toggleInlineFormat(x);return l(y.readInlineFormat?.()??we),F},[]),P=z(x=>{let y=h.current?.surface;if(!y?.applyTextColor)return!1;let F=y.applyTextColor(x);return u(y.readTextColor?.()??null),F},[]),T=z(x=>{let y=h.current?.surface;if(!y?.setParagraphAlignment)return!1;let F=y.setParagraphAlignment(x);return p(y.readParagraphAlignment?.()??null),F},[]);return{state:n,active:n.phase==="editing"||n.phase==="saving",openAtPage:c,openSlot:f,commit:m,close:C,editorMount:s,inlineFormat:a,toggleInlineFormat:N,textColor:k,applyTextColor:P,paragraphAlignment:d,setParagraphAlignment:T,toolbarHost:v,reason:n.error??b.current?.readLastReason()??null}}function xt(e,t){if(!e||typeof e!="object")return!1;let r=e.closest;if(typeof r!="function")return!1;let n=t?`[${ht}][data-begonia-header-footer-band-open="true"]`:`[${ht}], [${po}]`;return r.call(e,n)!=null}var fo={id:"header-footer-editor",name:"Header editor",color:"#0f766e"};import{useEffect as re,useLayoutEffect as wt,useMemo as yt,useReducer as go,useRef as U}from"react";import{createBrowserEditorMountController as bo}from"@datalking/begonia-browser/v1";var G=Symbol("browser-editor-callback-unset");function ho(e,t){return{...e,features:t}}function St({zoomPercent:e,zoomMode:t,fitWidthOptions:r,onControllerChange:n,onStateChange:o,...s}){let i=ue(s.features),a=yt(()=>ho({...s,zoomPercent:e,zoomMode:t,fitWidthOptions:r},i),[s.actor,s.collaborative,s.collaborationSession,s.documentMode,s.enableEmbeddedAdvancedOoxmlEditors,s.flowMode,r,s.initialContent,s.layoutMode,s.modules,s.onTransaction,s.onUpdate,s.participant,s.permissionResolver,s.room,s.schema,s.surfaceFactory,s.trackingEnabled,s.viewSelect,i,t,e]),l=U(null);l.current||(l.current=bo(a));let d=l.current,p=U(null),[k,u]=go(T=>T+1,0),b=yt(()=>({getSnapshot:()=>d.getSnapshot(),subscribe:T=>d.subscribe(T)}),[d,k]),h=ne(b)??d.getSnapshot(),S=h.controller,c=h.state,f=U(n),m=U(o),C=U(G),v=U(G),N=U(null),P=U(null);if(!P.current){let T=(x=>{N.current!==x&&(N.current=x,d.setHost(x),u())});Object.defineProperty(T,"current",{configurable:!0,enumerable:!0,get(){return N.current},set(x){T(x)}}),P.current=T}return wt(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[d]),re(()=>{f.current=n},[n]),re(()=>{m.current=o},[o]),wt(()=>{d.setInput(a)},[d,a]),re(()=>{if(C.current===S||C.current===G&&S==null){C.current=S;return}C.current=S,f.current?.(S)},[S]),re(()=>{if(v.current===c||v.current===G&&c==null){v.current=c;return}v.current=c,m.current?.(c)},[c]),re(()=>()=>{let T=setTimeout(()=>{p.current===T&&(p.current=null,C.current!==G&&C.current!==null&&f.current?.(null),v.current!==G&&v.current!==null&&m.current?.(null),C.current=null,v.current=null,d.destroy())},0);p.current=T},[d]),{hostRef:P.current,controller:S,state:c}}import{useSyncExternalStore as xo}from"react";import{readBrowserEditorDocument as vo}from"@datalking/begonia-browser/v1";function Bt(e){return xo(t=>e?.subscribe(t)??(()=>{}),()=>vo(e),()=>null)}import{useEffect as wo,useMemo as yo,useRef as So}from"react";import{resolveBrowserHistoryShortcut as Bo}from"@datalking/begonia-browser";function Pt({history:e,enabled:t=!0,ownerDocument:r,ownsFocus:n}){let o=yo(()=>e?i=>{let a=i==="undo"?e.undo:e.redo;return typeof a!="function"?!1:a.call(e)===!0}:null,[e]),s=So(null);s.current=n??null,wo(()=>{if(!t||!o)return;let i=r??(typeof document>"u"?null:document);if(!i)return;let a=l=>{let d=Bo(l);if(!d)return;let p=s.current;p&&!p(l)||o(d)&&l.preventDefault()};return i.addEventListener("keydown",a,!0),()=>{i.removeEventListener("keydown",a,!0)}},[t,r,o,s])}export{_t as BegoniaBrowserEditor,De as BegoniaPdfViewer,Se as BrowserAdvancedOoxmlInspector,tn as BrowserCommentsDisplayControls,sn as BrowserContextMenu,me as BrowserHeaderFooterBands,ft as BrowserHeaderFooterControls,mt as BrowserHeaderFooterFormatBar,ln as BrowserLinkPopover,rt as BrowserPaginatedEditorSurface,Ge as BrowserPaginatedPreview,dn as BrowserReviewDisplayControls,Gt as BrowserRichFormatControls,cn as BrowserViewControls,it as BrowserWhiteboardPdfPreview,st as BrowserWhiteboardPreview,rn as CommentsSidebar,ko as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,Co as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,_e as DocumentReactMount,an as EditorToolbar,on as EditorToolbarBlockControls,nn as EditorToolbarInsertControls,gt as HeaderFooterScratchMount,Zo as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,en as PREVIEW_TABLE_CELL_VERTICAL_PADDING,Oo as PaginatedLayoutView,Ie as PaginatedPageOverlayView,un as ReviewPanel,pn as ReviewTimelinePanel,Do as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,Re as VirtualPagedPreview,Eo as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,Wo as applyVirtualPagedPreviewAutoscroll,Po as begoniaThemeRootProps,Mo as bindVirtualPagedPreviewWindowDragListeners,zo as cloneVirtualPagedPreviewMetrics,be as createHeaderFooterScratchSurface,mn as createPdfViewerController,Ko as createVirtualPagedPreviewAutoscrollController,To as createVirtualPagedPreviewDragSession,qo as createVirtualPagedPreviewSessionState,Ao as isVirtualPagedPreviewFrameTarget,Vo as normalizeVirtualPagedPreviewPinnedPageIndexes,_o as normalizeVirtualPagedPreviewRequestKey,Fo as resolvePaginatedLayoutViewOptions,Ho as resolvePaginatedPreviewFlowMode,No as resolveRequestedPaginatedLayoutFlowMode,Me as resolveSnapshotCommentState,$o as resolveVirtualPagedPreviewAutoscrollDelta,Go as resolveVirtualPagedPreviewHostMeasurement,Ro as resolveVirtualPagedPreviewPositionHit,Io as resolveVirtualPagedPreviewPositionHitInMountedFrames,jo as resolveVirtualPagedPreviewRenderState,Xo as resolveVirtualPagedPreviewResizeObserver,Jo as resolveVirtualPagedPreviewSessionCommit,Qo as resolveVirtualPagedPreviewSessionViewportEmission,Yo as sameVirtualPagedPreviewMetrics,St as useBrowserEditorController,Bt as useBrowserEditorDocument,Lo as useBrowserEditorUi,vt as useBrowserHeaderFooterEditing,ne as useControllerSnapshot,ae as useControllerSnapshotSignal,Uo as useEditorUiController,lt as useHeaderFooterScratchSurface,Pt as useUndoRedoHotkeys};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalking/begonia-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React editor for begonia: paginated view, comments/review panels, PDF viewer",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,29 +22,32 @@
|
|
|
22
22
|
"./v1": {
|
|
23
23
|
"types": "./dist/v1.d.ts",
|
|
24
24
|
"import": "./dist/v1.js"
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
"./editor-surface.css": "./dist/editor-surface.css"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
28
29
|
"access": "public"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
|
-
"build": "node ../../scripts/run-tsup.mjs src/index.ts src/v1.ts --format esm --dts --clean",
|
|
32
|
-
"build:test": "tsup src/index.ts src/v1.ts --format esm",
|
|
32
|
+
"build": "node ../../scripts/run-tsup.mjs src/index.ts src/v1.ts --format esm --dts --clean && node -e \"require('node:fs').copyFileSync('src/editor-surface.css','dist/editor-surface.css')\"",
|
|
33
|
+
"build:test": "tsup src/index.ts src/v1.ts --format esm && node -e \"require('node:fs').copyFileSync('src/editor-surface.css','dist/editor-surface.css')\"",
|
|
33
34
|
"typecheck": "tsc --noEmit"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@datalking/begonia-browser": "0.
|
|
37
|
-
"@datalking/begonia-browser-sdk": "0.
|
|
38
|
-
"@datalking/begonia-doc-service": "0.
|
|
39
|
-
"@datalking/begonia-document-api": "0.
|
|
40
|
-
"@datalking/begonia-editor-adapters": "0.
|
|
41
|
-
"@datalking/begonia-editor-
|
|
42
|
-
"@datalking/begonia-
|
|
43
|
-
"@datalking/begonia-
|
|
44
|
-
"@datalking/begonia-layout-
|
|
45
|
-
"@datalking/begonia-layout-
|
|
46
|
-
"@datalking/begonia-
|
|
47
|
-
"@datalking/begonia-
|
|
37
|
+
"@datalking/begonia-browser": "0.3.0",
|
|
38
|
+
"@datalking/begonia-browser-sdk": "0.3.0",
|
|
39
|
+
"@datalking/begonia-doc-service": "0.3.0",
|
|
40
|
+
"@datalking/begonia-document-api": "0.3.0",
|
|
41
|
+
"@datalking/begonia-editor-adapters": "0.3.0",
|
|
42
|
+
"@datalking/begonia-editor-contracts": "0.3.0",
|
|
43
|
+
"@datalking/begonia-editor-ui": "0.3.0",
|
|
44
|
+
"@datalking/begonia-engine": "0.3.0",
|
|
45
|
+
"@datalking/begonia-layout-bridge": "0.3.0",
|
|
46
|
+
"@datalking/begonia-layout-contracts": "0.3.0",
|
|
47
|
+
"@datalking/begonia-layout-renderer": "0.3.0",
|
|
48
|
+
"@datalking/begonia-page-layout": "0.3.0",
|
|
49
|
+
"@datalking/begonia-pdf-viewer": "0.3.0",
|
|
50
|
+
"@datalking/begonia-table-render": "0.3.0",
|
|
48
51
|
"prosemirror-model": "^1.22.3"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { PREVIEW_TABLE_CELL_HORIZONTAL_PADDING, PREVIEW_TABLE_CELL_VERTICAL_PADDING, } from '@datalking/begonia-layout-renderer';
|
package/dist/chunk-IEHE33P5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useSyncExternalStore as br}from"react";import{useEffect as go,useRef as St}from"react";import{useCallback as mo,useRef as ht,useSyncExternalStore as po}from"react";function Le(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let l=0;l<e.length;l+=1)if(!Le(e[l],t[l]))return!1;return!0}if(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype)return!1;let o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;let r=e,a=t;for(let l of o)if(!Object.prototype.hasOwnProperty.call(a,l)||!Le(r[l],a[l]))return!1;return!0}function fo(e,t){let o=ht(0),i=mo(r=>{if(!e)return()=>{};let a=!0,l=e.subscribe(m=>{if(a){t.current.controller===e&&t.current.token===o.current&&!Le(t.current.snapshot,m)&&(o.current+=1,t.current={controller:e,token:o.current,snapshot:m},r());return}o.current+=1,t.current={controller:e,token:o.current,snapshot:m},r()});return a=!1,l},[t,e]);return po(i,()=>o.current,()=>o.current)}function B(e){let t=ht({controller:null,token:-1,snapshot:null}),o=fo(e,t),i=t.current;if(i.controller===e&&i.token===o)return i.snapshot;let r=e?.getSnapshot()??null;return t.current={controller:e,token:o,snapshot:r},r}function Ie(e,t){let o=B(e);return o==null?null:t(o)}import{jsx as ae,jsxs as ye}from"react/jsx-runtime";function wo(e){return typeof e=="number"?`${e}px`:e}function bo(e,t){return{pageNumber:e.pageNumber,width:e.width,height:e.height,rotation:e.rotation,scale:t}}function Rt(e,t){return`${e??"pdf"}:${t}`}function Ct({controller:e,height:t=720,scale:o=1,pageGap:i=24,className:r,style:a,emptyLabel:l="No PDF document loaded.",renderPageOverlay:m}){Ie(e,s=>[s.status,s.pageCount,s.fingerprint,s.error,s.textLayerEnabled,s.outputScale,s.renderVersion,...s.pages.map(n=>`${n.pageNumber}:${n.width}:${n.height}:${n.rotation}`)].join("|"));let f=e.getSnapshot(),p=St(new Map),u=St(new Map);return go(()=>{if(f.status!=="ready")return;let s=!1;return(async()=>{for(let d of f.pages){if(s)return;let g=Rt(f.fingerprint,d.pageNumber),w=p.current.get(g);w&&await e.renderPage(d.pageNumber,w,{scale:o,textLayer:u.current.get(g)??null})}})(),()=>{s=!0}},[e,o,f.fingerprint,f.pages,f.renderVersion,f.status]),ye("div",{className:r,style:{overflow:"auto",height:wo(t),background:"linear-gradient(180deg, #dbe4f0 0%, #eef2f7 100%)",borderRadius:18,padding:20,...a},children:[f.status==="error"?ae("div",{style:{color:"#991b1b",padding:16},children:f.error??"Failed to load PDF."}):null,f.status==="loading"?ae("div",{style:{color:"#334155",padding:16},children:"Loading PDF\u2026"}):null,f.status==="idle"&&f.pages.length===0?ae("div",{style:{color:"#475569",padding:16},children:l}):null,ae("div",{style:{display:"grid",gap:`${i}px`,justifyContent:"center"},children:f.pages.map(s=>{let n=Rt(f.fingerprint,s.pageNumber),d=s.width*o,g=s.height*o;return ye("section",{"aria-label":`PDF page ${s.pageNumber}`,children:[ye("div",{style:{color:"#334155",fontSize:12,margin:"0 0 8px 6px"},children:["Page ",s.pageNumber]}),ye("div",{style:{position:"relative",width:d,height:g,background:"#fff",borderRadius:14,overflow:"hidden",boxShadow:"0 18px 40px rgba(15, 23, 42, 0.14)"},children:[ae("canvas",{ref:w=>{w?p.current.set(n,w):p.current.delete(n)},style:{display:"block",width:d,height:g}}),ae("div",{ref:w=>{w?u.current.set(n,w):u.current.delete(n)},style:{position:"absolute",inset:0,pointerEvents:f.textLayerEnabled?"auto":"none"}}),m?ae("div",{style:{position:"absolute",inset:0},children:m(bo(s,o))}):null]})]},n)})})]})}import{useEffect as fn,useLayoutEffect as Qe,useMemo as gn,useRef as et}from"react";import{createPaginatedLayoutPreviewController as wn,createDefaultPaginatedLayoutMeasureText as bn}from"@datalking/begonia-layout-renderer";import{useEffect as dn,useRef as W}from"react";import{createDefaultPaginatedLayoutMeasureText as un,normalizeRenderScale as cn,resolveVirtualPagedPreviewContentLayout as mn}from"@datalking/begonia-layout-renderer";import{DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE as Ne,DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX as vo,WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX as Me,resolvePaginatedLayoutViewOptions as Po,resolveVirtualPagedPreviewVirtualization as Nr}from"@datalking/begonia-layout-renderer";function kt(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):28}import{resolvePaginatedPreviewFlowMode as Ae,resolveRequestedPaginatedLayoutFlowMode as xo}from"@datalking/begonia-layout-renderer";import{useEffect as Tt,useLayoutEffect as Et,useRef as Vt}from"react";import{createVirtualPagedPreviewController as yo,resolveVirtualPagedPreviewObservedScrollHost as ho}from"@datalking/begonia-layout-renderer";function So(e,t){return ho(e,t)}function Bt(e){return{projection:e.projection,version:e.version??null,height:e.height,width:e.width,scale:e.scale,pageGap:e.pageGap,windowPages:e.windowPages,overscan:e.overscan,virtualize:e.virtualize,layoutMode:e.layoutMode,flowMode:e.flowMode,anchorPageNumber:e.anchorPageNumber,initialViewportAnchor:e.initialViewportAnchor,viewportRequestKey:e.viewportRequestKey,pinnedPageNumbers:e.pinnedPageNumbers}}function Lt({projection:e,version:t=null,height:o,width:i,scale:r,pageGap:a,windowPages:l,overscan:m,virtualize:f,layoutMode:p,flowMode:u,anchorPageNumber:s,initialViewportAnchor:n,viewportRequestKey:d,pinnedPageNumbers:g,scrollHost:w,onViewportChange:c}){let b=Vt(null),P=Vt(null);P.current||(P.current=yo(Bt({projection:e,version:t,height:o,width:i,scale:r,pageGap:a,windowPages:l,overscan:m,virtualize:f,layoutMode:p,flowMode:u,anchorPageNumber:s,initialViewportAnchor:n,viewportRequestKey:d,pinnedPageNumbers:g,scrollHost:w,onViewportChange:c})));let v=P.current,k=B(v)??v.getSnapshot();return Et(()=>{v.setInput(Bt({projection:e,version:t,height:o,width:i,scale:r,pageGap:a,windowPages:l,overscan:m,virtualize:f,layoutMode:p,flowMode:u,anchorPageNumber:s,initialViewportAnchor:n,viewportRequestKey:d,pinnedPageNumbers:g,scrollHost:w,onViewportChange:c}))},[v,e,t,o,i,r,a,l,m,f,p,u,s,n,d,g]),Et(()=>{let T=v.bindViewport({getExplicitScrollHost:()=>w,getPreviewHost:()=>b.current});return()=>{T.cleanup()}},[v,w]),Tt(()=>c?v.subscribeViewport(c):()=>{},[v,c]),Tt(()=>()=>{v.destroy()},[v]),{hostRef:b,resolveObservedScrollHost(){return v.resolveObservedScrollHost()??So(w,b.current)},deferredProjection:k.deferredProjection,renderState:k.renderState}}import{drawingFragmentOffsetY as Xo,drawingFragmentVisibleHeight as Yo,resolveRenderableTableRows as Jo}from"@datalking/begonia-layout-contracts";import{listProjectionPageBlocks as Qo,resolvePageColumnSeparatorSegments as en,resolvePaginatedPageContentLeftOrigin as tn}from"@datalking/begonia-page-layout";import{drawingSceneTransform as Ro}from"@datalking/begonia-layout-contracts";import{jsx as le,jsxs as Nt}from"react/jsx-runtime";function Co(e,t){return(t??e.label??"Shape").trim()||"Shape"}function ko(e){return e.fill??e.fillColor??"none"}function To(e){return e==="butt"||e==="round"||e==="square"||e==="inherit"?e:void 0}function Eo(e){return e==="miter"||e==="round"||e==="bevel"||e==="inherit"?e:void 0}function Vo(e,t){let o={fill:ko(e),fillOpacity:e.fillOpacity??void 0,stroke:e.stroke??"none",strokeOpacity:e.strokeOpacity??void 0,strokeWidth:e.strokeWidth??void 0,strokeDasharray:e.strokeDasharray??void 0,strokeLinecap:To(e.strokeLinecap),strokeLinejoin:Eo(e.strokeLinejoin),markerStart:e.markerStart??void 0,markerEnd:e.markerEnd??void 0,fillRule:e.fillRule??void 0,clipRule:e.clipRule??void 0,vectorEffect:e.stroke&&e.stroke!=="none"?"non-scaling-stroke":void 0};return e.kind==="rect"?le("rect",{...o,x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0,rx:e.rx??void 0,ry:e.ry??void 0},t):e.kind==="ellipse"?le("ellipse",{...o,cx:e.cx??0,cy:e.cy??0,rx:e.rx??0,ry:e.ry??0},t):le("path",{...o,d:e.d??""},t)}function Bo(e,t){return le("text",{x:e.centerX,y:e.startY,fill:e.fill,fontSize:e.fontSize,fontFamily:e.fontFamily,fontWeight:e.fontWeight,textAnchor:"middle",dominantBaseline:"middle",paintOrder:"stroke",stroke:e.stroke??void 0,strokeWidth:e.strokeWidth??void 0,children:e.lines.map((o,i)=>le("tspan",{x:e.centerX,y:e.startY+i*e.lineHeight,children:o},`${t}-${i}`))},t)}function It(e,t){let o=Ro(e);return Nt("g",{transform:o||void 0,opacity:e.opacity??void 0,style:e.filter?{filter:e.filter}:void 0,children:[e.primitives.map((i,r)=>Vo(i,`${t}-primitive-${r}`)),e.children.map((i,r)=>It(i,`${t}-child-${r}`)),e.text?Bo(e.text,`${t}-text`):null]},t)}function he({drawing:e,width:t,height:o,className:i,style:r,label:a}){let l=Math.max(1,Number(t??e.width??1)),m=Math.max(1,Number(o??e.height??1)),f=Co(e,a);return Nt("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:m,viewBox:e.viewBox,role:"img","aria-label":f,preserveAspectRatio:"xMidYMid meet",className:i||void 0,style:r,children:[le("title",{children:f}),e.defs?.trim()?le("defs",{dangerouslySetInnerHTML:{__html:e.defs}}):null,It(e.scene,"drawing-root")]})}import{createVirtualPagedPreviewDragSession as De,isVirtualPagedPreviewFrameTarget as Oe,VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE as He}from"@datalking/begonia-layout-renderer";import{PREVIEW_TABLE_CELL_HORIZONTAL_PADDING as Fe,PREVIEW_TABLE_CELL_VERTICAL_PADDING as je}from"@datalking/begonia-layout-renderer";import{inlineRevisionSpanDisplayLayer as Fo,inlineRevisionSpanHasKind as Ue,resolveMeasuredLineSliceVisibleRange as jo,resolveMeasuredLineSlicePaintSpans as _o,resolveMeasuredLineSlicePaintText as $o,sliceInlineRevisionSpansByOffsets as Uo}from"@datalking/begonia-layout-contracts";import{createVirtualPagedPreviewInlineNodeAttributes as Wo}from"@datalking/begonia-layout-renderer";function Se(e){return Number.isFinite(e)&&e>0?e:1}function U(e,t){return e*Se(t)}function Mt(e,t){let o=Se(t);return{fontSize:typeof e.fontSize=="number"?`${e.fontSize*o}px`:void 0,letterSpacing:typeof e.letterSpacing=="number"?`${e.letterSpacing*o}px`:void 0}}import{jsx as _e}from"react/jsx-runtime";function Re(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function pe(e,t,o){let i=e?.inlineObject?.kind==="image"?e.inlineObject:null;if(i){let m=Re(i.width),f=Re(i.height);return _e("img",{className:"ald-inline-image",src:i.src,alt:i.alt??"",title:i.title??void 0,"data-image-id":i.objectId??void 0,width:m==null?void 0:U(m,o),height:f==null?void 0:U(f,o),style:{display:"inline-block",verticalAlign:"baseline",objectFit:"contain"}})}let r=e?.inlineObject?.kind==="drawing"?e.inlineObject:null;if(!r)return t;if(!r.drawing)return r.label||"Drawing";let a=U(Re(r.width)??r.drawing.width,o),l=U(Re(r.height)??r.drawing.height,o);return _e("span",{className:`ald-inline-drawing ald-inline-${r.family}`,"data-family":r.family,"data-object-id":r.objectId??void 0,style:{display:"inline-block",width:a,height:l,verticalAlign:"baseline",lineHeight:0},children:_e(he,{drawing:r.drawing,width:a,height:l,className:"ald-inline-drawing-svg",style:{display:"block",width:a,height:l}})})}import{resolveMeasuredLineSliceVisibleRange as At,resolveMeasuredLineSlicePaintSpans as Lo,resolveMeasuredLineSlicePaintText as Io,resolveTextLineAdvanceHeight as No,sliceInlineRevisionSpansByOffsets as Mo}from"@datalking/begonia-layout-contracts";import{resolveProjectionLineMeasuredGeometry as Ao,resolveTextLineFrame as Dt}from"@datalking/begonia-page-layout";import{jsx as $e}from"react/jsx-runtime";function Ot(e,t,o){if(!e.inlineSpans||e.inlineSpans.length===0||o<=t)return null;let i=e.lineSlices?.[0]?.fromOffset??0,r=Math.max(0,t-i),a=Math.max(r,o-i);return Mo(e.inlineSpans,r,a)}function Do(e,t,o,i){let r=At(i),a=Dt(e,t),l=Number.isFinite(i.lineIndex)?i.lineIndex:t,m=Number.isFinite(i.lineCount)?i.lineCount:o;return{pageNumber:0,sectionIndex:0,sectionPageNumber:0,region:"body",blockIndex:0,fragmentIndex:e.fragmentIndex,columnIndex:e.columnIndex,lineIndex:l,lineCount:m,from:e.from+i.fromOffset,to:e.from+i.toOffset,left:0,top:0,width:Math.max(0,a.availableWidth),height:Math.max(1,e.lineHeight),text:r.text,logicalText:r.text,discretionaryHyphen:i.discretionaryHyphen===!0,nodeType:e.type,align:e.align??null,direction:e.direction??null,fontSize:e.fontSize??null,tabs:e.tabs??null,inlineSpans:Ot(e,r.fromOffset,r.toOffset),continuesToNext:e.continuesToNext,label:r.text.trim()||e.text}}function Oo(e,t,o,i){let r=a=>a==="tab"||a==="space";return t.map((a,l)=>{let m=i+a.fromOffset,f=i+a.toOffset,p=a.span?e.interactiveInlineNodeSpanProps(a.span,m,f):null,u=a.leader==="dot"?".":a.leader==="hyphen"?"-":a.leader==="underscore"?"_":null,s=u?u.repeat(Math.max(1,Math.floor(a.width/Math.max(1,a.fontSize*.33)))):"\xA0";return $e("span",{style:{...a.span?e.inlineSpanStyle(e.block,a.span,e.scale):{fontWeight:a.bold?700:400,fontStyle:a.italic?"italic":"normal",fontVariantCaps:a.smallCaps?"small-caps":void 0,fontFamily:a.fontFamily??void 0,fontSize:`${U(a.fontSize,e.scale)}px`,letterSpacing:typeof a.letterSpacing=="number"?`${U(a.letterSpacing,e.scale)}px`:void 0},pointerEvents:p?"auto":void 0,display:r(a.kind)?"inline-block":void 0,width:r(a.kind)?U(a.width,e.scale):void 0,minWidth:r(a.kind)?U(a.width,e.scale):void 0,whiteSpace:a.kind==="tab"?"nowrap":a.kind==="space"?"pre":void 0,overflow:a.kind==="tab"?"hidden":void 0},...p??{},children:a.kind==="tab"?s:pe(a.span,a.text,e.scale)},`${o}-${l}`)})}function Ho(e,t,o,i){let r=o;return t.map((a,l)=>{let m=r;r+=a.text.length;let f=r,p=e.interactiveInlineNodeSpanProps(a,m,f);return $e("span",{style:{...e.inlineSpanStyle(e.block,a,e.scale),pointerEvents:p?"auto":void 0},...p??{},children:pe(a,a.text,e.scale)},`${i}-${l}`)})}function Ht(e){let t=e.block.lineSlices??null;return!t||t.length===0?null:t.map((o,i)=>{let r=At(o),a=Io(o),l=Dt(e.block,i),m=No(l,e.block.lineHeight,e.block.lineSpacingRule),f=l.leftInset*e.scale,p=Lo(o,Ot(e.block,r.fromOffset,r.toOffset)??[]),u=r.text.length>0||(p?.length??0)>0,s=(e.block.textOffsetBase??0)+r.fromOffset,n=Ao(Do(e.block,i,t.length,o),e.measureText,e.measurementEpoch),d=n&&n.pieces.length>0?Oo(e,n.pieces,`${e.block.from}-${e.block.fragmentIndex}-line-${i}`,s):p&&p.length>0?Ho(e,p,s,`${e.block.from}-${e.block.fragmentIndex}-line-${i}`):u?a:" ";return $e("span",{style:{display:"block",paddingLeft:Math.max(0,f),marginLeft:Math.min(0,f),paddingRight:l.rightInset*e.scale,minHeight:Math.max(1,m*e.scale),whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:d},`${e.block.from}-${e.block.fragmentIndex}-line-${i}`)})}import{jsx as qe}from"react/jsx-runtime";function ze(e){return e.type==="heading"?Math.max(13,Math.round(e.lineHeight*.9)):e.type==="footnote_reference"?Math.max(9,Math.round(e.lineHeight*.75)):Math.max(10,Math.round(e.lineHeight*.82))}function zo(e){switch(e.align){case"left":case"right":case"center":case"justify":case"start":case"end":return e.align;case"both":return"justify";default:return}}function Go(e){return e.direction==="ltr"||e.direction==="rtl"?e.direction:void 0}function Ko(e){return e==="insert"?{background:"rgba(15, 118, 110, 0.12)",textDecoration:"underline",textDecorationColor:"#0f766e"}:e==="delete"?{background:"rgba(185, 28, 28, 0.09)",textDecoration:"line-through",textDecorationColor:"#b91c1c"}:e==="format"?{background:"rgba(217, 119, 6, 0.1)",textDecoration:"underline",textDecorationColor:"#92400e"}:null}function qo(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))].join(" ")}function Ft(e,t,o=1){let i=Se(o),r=Fo(t),a=Ko(r?.revisionKind??t.revisionKind??null)??{},l=typeof a=="object"&&a&&"textDecoration"in a?String(a.textDecoration):void 0,m=typeof a=="object"&&a&&"textDecorationColor"in a?String(a.textDecorationColor):void 0,f=Ue(t,"insert"),p=Ue(t,"delete"),u=Ue(t,"format"),s=t.smallCaps?"small-caps":void 0,n=t.textTransform&&t.textTransform!=="none"?t.textTransform:void 0,d=r?.revisionKind==="format"?"dotted":void 0;return{...a,fontWeight:t.bold||e.type==="heading"?700:400,fontStyle:t.italic?"italic":"normal",fontVariantCaps:s,textTransform:n,textDecoration:qo([l,f||u?"underline":null,p?"line-through":null,t.underline?"underline":null,t.strike?"line-through":null,t.href?"underline":null]),textDecorationThickness:t.underline||t.href||f||u?"2px":void 0,textDecorationStyle:d,textDecorationColor:m??(t.href?"#155e75":void 0),color:t.color??(t.href?"#155e75":void 0),backgroundColor:t.highlight??void 0,fontFamily:t.fontFamily??void 0,...Mt(t,i)}}function jt(e,t,o,i=null){let r=typeof e.sourceNodeType=="string"&&e.sourceNodeType.length>0?e.sourceNodeType:null;return!(r!=null&&e.sourceNodeSelectable===!0)||o<=t?null:Wo({nodeType:r,objectId:e.sourceObjectId??null,fromOffset:t,toOffset:o,tableOriginRow:i?.originRow??null,tableOriginColumn:i?.originColumn??null})}function _t(e,t,o,i){let r=Ht({block:e,scale:t,measureText:o,measurementEpoch:i,inlineSpanStyle:Ft,interactiveInlineNodeSpanProps:jt});return r||(!e.inlineSpans||e.inlineSpans.length===0?e.renderedText:We(e,e.inlineSpans,`${e.from}-${e.to}`,e.textOffsetBase??0,null,t))}function Zo(e,t,o){return Uo(e,t,o)}function We(e,t,o,i=0,r=null,a=1){if(!t||t.length===0)return null;let l=i;return t.map((m,f)=>{let p=l;l+=m.text.length;let s=jt(m,p,l,r);return qe("span",{style:{...Ft(e,m,a),pointerEvents:s?"auto":void 0},...s??{},children:pe(m,m.text,a)},`${o}-${f}`)})}function $t(e,t,o,i){let{layout:r,text:a}=t,l=r?.lineSlices??null;if(l&&l.length>0)return l.map((f,p)=>{let u=jo(f),s=$o(f),n=_o(f,Zo(r?.inlineSpans??null,u.fromOffset,u.toOffset)??[]);return qe("span",{style:{display:"block"},children:n&&n.length>0?We(e,n,`${o}-line-${p}`,u.fromOffset,t,i):s||" "},`${o}-line-${p}`)});let m=We(e,r?.inlineSpans??null,o,0,t,i);return m||(r?.text??a)}function Ut(e){let t=Array.isArray(e.tableColumnWidths)?e.tableColumnWidths:null;if(!t||t.length===0)return null;let o=t.reduce((i,r)=>i+Math.max(0,Number(r??0)),0);return o<=0?null:t.map((i,r)=>qe("col",{style:{width:`${Math.max(0,Number(i??0))/o*100}%`}},`${e.from}-col-${r}`))}function Ge(e,t,o){return(e-t)*o}function Ke(e,t,o){return(t+e)*o}function fe(e,t,o=0,i=0){let r=!!(e.lineSlices&&e.lineSlices.length>0);return{position:"absolute",top:Ge(e.top,o,t),left:Ke(e.left,i,t),width:Math.max(1,e.width*t),minHeight:Math.max(1,e.estimatedHeight*t),paddingBottom:Math.max(2,Math.round(t*4)),fontSize:(e.fontSize??ze(e))*t,lineHeight:`${e.lineHeight*t}px`,fontFamily:'"Times New Roman", serif',whiteSpace:"pre-wrap",wordBreak:"break-word",color:e.type==="heading"?"#2f2417":"#1f2937",fontWeight:e.type==="heading"?700:400,textAlign:zo(e),direction:Go(e),pointerEvents:"none",overflow:"hidden",paddingLeft:r?0:void 0,paddingRight:r?0:void 0}}import{jsx as C,jsxs as Ze}from"react/jsx-runtime";function on({block:e,scale:t,contentTop:o,contentLeft:i}){let r=fe(e,t,o,i);return C("div",{style:r,children:e.assetSrc?C("img",{src:e.assetSrc,alt:"",style:{width:"100%",height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),objectFit:"contain",borderRadius:12,border:"1px solid rgba(92, 70, 43, 0.14)",background:"#fff"}}):C("div",{style:{height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),borderRadius:12,border:"1px dashed rgba(92, 70, 43, 0.24)",background:"rgba(245, 158, 11, 0.08)",display:"grid",placeItems:"center",color:"#8a5b12",fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase"},children:"Image"})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function nn({block:e,scale:t,contentTop:o,contentLeft:i}){let r=fe(e,t,o,i),a=Math.max(0,Math.min(Number(e.tableHeaderRowCount??0),e.tableRows?.length??0)),l=Ut(e),m=je*t,f=Fe*t,p=Jo(e);return C("div",{style:r,children:Ze("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:Math.max(9,ze(e)*t),background:"#fff"},children:[l?C("colgroup",{children:l}):null,C("tbody",{children:p.map(u=>C("tr",{children:u.cells.map(s=>{let n=u.fragmentRowIndex<a?"th":"td";return C(n,{colSpan:s.colSpan>1?s.colSpan:void 0,rowSpan:s.rowSpanInFragment>1?s.rowSpanInFragment:void 0,style:{border:"1px solid rgba(92, 70, 43, 0.18)",padding:`${m}px ${f}px`,verticalAlign:"top",fontWeight:u.fragmentRowIndex<a?700:void 0,textAlign:"left",background:u.fragmentRowIndex<a?"rgba(226, 232, 240, 0.65)":void 0},children:$t(e,s,`${e.from}-${u.fragmentRowIndex}-${s.physicalIndex}`,t)},`${e.from}-${u.fragmentRowIndex}-${s.physicalIndex}-${s.originColumn}`)})},`${e.from}-${u.fragmentRowIndex}-${u.sourceRowIndex}`))})]})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function rn({block:e,scale:t,contentTop:o,contentLeft:i}){let r=Math.max(24,Number(e.drawing?.width??e.drawing?.intrinsicWidth??e.width??0))*t,a=Math.max(24,Number(e.drawing?.height??e.drawing?.intrinsicHeight??e.estimatedHeight??0))*t,l=Xo(e)*t,m=Math.max(1,Yo(e)*t||a),f=l>0||m<a,p={...fe(e,t,o,i),minHeight:m},u=e.drawing?.scene&&e.drawing.viewBox?C(he,{drawing:e.drawing,width:r,height:a,className:"ald-drawing-scene-svg",style:{display:"block",width:"100%",height:"100%"}}):C("div",{style:{width:"100%",height:"100%"},dangerouslySetInnerHTML:{__html:e.drawing?.svg??""}});return C("div",{style:p,children:e.drawing?C("div",{style:{width:r,height:m,maxWidth:"100%",overflow:f?"hidden":void 0},children:C("div",{style:{width:r,height:a,transform:f?`translateY(-${l}px)`:void 0,transformOrigin:f?"top left":void 0},children:u})}):C("div",{style:{width:r,height:a,borderRadius:12,border:"1px dashed rgba(92, 70, 43, 0.24)",background:"rgba(226, 232, 240, 0.58)",display:"grid",placeItems:"center",color:"#475569",fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase"},children:"Shape"})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function an({block:e,scale:t,contentTop:o,contentLeft:i,measureText:r,measurementEpoch:a}){return e.drawing?C(rn,{block:e,scale:t,contentTop:o,contentLeft:i}):e.type==="image"?C(on,{block:e,scale:t,contentTop:o,contentLeft:i}):e.type==="table"&&e.tableRows?C(nn,{block:e,scale:t,contentTop:o,contentLeft:i}):C("div",{style:fe(e,t,o,i),children:_t(e,t,r,a)},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function ln({page:e,scale:t,contentTop:o,contentLeft:i}){return en(e).map(r=>C("div",{"data-ald-column-separator":"true",style:{position:"absolute",top:Ge(r.top,o,t),left:Ke(r.left,i,t),height:Math.max(1,r.height*t),width:1,background:"rgba(31, 41, 55, 0.7)",pointerEvents:"none"}},`separator-${r.regionIndex}-${r.separatorIndex}-${r.top}`))}function Ce({frame:e,scale:t,measureText:o,measurementEpoch:i,offsetTop:r=0,offsetLeft:a=0,flowMode:l="paginated",renderPageOverlay:m,onProjectionPositionHit:f}){let p=e.page,u=l==="web"?e.contentTop:0,s=l==="web"?-e.contentLeft:tn(p),n=Qo(p);return Ze("article",{[He]:"true",style:{position:"absolute",top:e.top-r,left:e.left-a,width:e.width,height:e.height,boxSizing:"border-box",background:l==="web"?"transparent":"#fffdfa",border:l==="web"?"none":"1px solid rgba(92, 70, 43, 0.14)",borderRadius:l==="web"?0:20,boxShadow:l==="web"?"none":"0 18px 40px rgba(69, 47, 16, 0.12)",overflow:"hidden",cursor:f?"text":void 0},children:[l==="paginated"?Ze("div",{style:{position:"absolute",top:10,right:14,fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase",color:"#8a5b12"},children:["Page ",p.pageNumber]}):null,C(ln,{page:p,scale:t,contentTop:u,contentLeft:s}),n.map(d=>C(an,{block:d,scale:t,contentTop:u,contentLeft:s,measureText:o,measurementEpoch:i},`${d.from}-${d.to}-${d.fragmentIndex}-${d.top}`)),m?C("div",{style:{position:"absolute",inset:0},children:m(e,t)}):null]})}import{bindVirtualPagedPreviewWindowDragListeners as Xe}from"@datalking/begonia-layout-renderer";import{Fragment as pn,jsx as F,jsxs as Ye}from"react/jsx-runtime";function Je({projection:e,version:t=null,measureText:o,measurementEpoch:i,height:r=720,width:a,scrollHost:l=null,scale:m=Ne,pageGap:f=28,windowPages:p=5,overscan:u=2,virtualize:s=!0,layoutMode:n="vertical",flowMode:d,anchorPageNumber:g=null,initialViewportAnchor:w=null,viewportRequestKey:c=null,pinnedPageNumbers:b,emptyLabel:P="No paginated preview available yet.",onViewportChange:v,renderPageOverlay:k,onProjectionPositionHit:T}){let L=cn(m),E=W(null);E.current===null&&(E.current=un());let I=o??E.current??void 0,D=Ae(e,d),{hostRef:J,resolveObservedScrollHost:Q,deferredProjection:_,renderState:N}=Lt({projection:e,version:t,height:r,width:a,scale:L,pageGap:f,windowPages:p,overscan:u,virtualize:s,layoutMode:n,flowMode:D,anchorPageNumber:g,initialViewportAnchor:w,viewportRequestKey:c,pinnedPageNumbers:b,scrollHost:l,onViewportChange:v}),$=W(null),re=W(I),Pe=W(i),ue=W([]),h=W(L),q=W(D),xt=W(T),ce=W(null),xe=W(De({getProjection:()=>$.current,getMountedFrames:()=>ue.current,getMeasureText:()=>re.current,getMeasurementEpoch:()=>Pe.current,getScale:()=>h.current,getFlowMode:()=>q.current,getPaginatedHorizontalOrigin:()=>"frame",getInteractionRoot:()=>J.current,getScrollHost:()=>Q(),dispatchPositionHit(x){return xt.current?.(x)}}));$.current=_,re.current=I,Pe.current=i,ue.current=N.window.mountedFrames,h.current=L,q.current=D,xt.current=T,dn(()=>{let x=xe.current;return()=>{let H=ce.current;ce.current=null,H?.(),x.destroy()}},[]);let de=mn({renderState:N,flowMode:D}),io=de.useSpacerWindow,ie=de.spacerWindowLayout,ao=ie.mountedWindowLayout,lo={height:l?void 0:r,width:l?void 0:a,overflow:l?"visible":"auto",borderRadius:18,background:D==="web"?"linear-gradient(180deg, rgba(247, 248, 250, 0.92), rgba(241, 245, 249, 0.88))":"linear-gradient(180deg, rgba(242, 236, 225, 0.92), rgba(235, 227, 214, 0.86))",border:D==="web"?"1px solid rgba(148, 163, 184, 0.18)":"1px solid rgba(92, 70, 43, 0.12)"},so={width:de.contentWidth,margin:"0 auto",padding:D==="web"?`20px ${Me}px 28px`:"20px 0 28px"},uo={position:"relative",width:de.layoutSurfaceWidth>0?de.layoutSurfaceWidth:void 0,minHeight:de.layoutSurfaceHeight,margin:"0 auto"},co=x=>{if(!T||x.button!==0||!Oe(x.target))return;let H=()=>{let ee=ce.current;ce.current=null,ee?.()},me=()=>{xe.current.handleMouseUp(),H()};H();let Be=xe.current.handleMouseDown({clientX:x.clientX,clientY:x.clientY,button:x.button,buttons:x.buttons,detail:x.detail,shiftKey:x.shiftKey,target:x.target});if(!Be.started){Be.handled&&x.preventDefault();return}let yt=x.currentTarget.ownerDocument.defaultView;yt&&(ce.current=Xe({view:yt,onMouseMove(ee){if((ee.buttons&1)!==1){me();return}xe.current.handleMouseMove({clientX:ee.clientX,clientY:ee.clientY,buttons:ee.buttons,target:ee.target})&&ee.preventDefault()},onStop(){me()}}).cleanup),Be.handled&&x.preventDefault()};return F("div",{style:lo,children:!_||_.pages.length===0?F("div",{style:{minHeight:r,display:"grid",placeItems:"center",color:"#6b5a46",padding:24},children:P}):F("div",{style:so,children:F("div",{ref:J,onMouseDown:T?co:void 0,style:uo,children:io?Ye(pn,{children:[F("div",{"data-begonia-virtual-spacer":"top",style:{height:ie.topSpacerHeight,width:"100%",overflowAnchor:"none"}}),Ye("div",{style:{display:"flex",width:"100%",direction:"ltr",overflowAnchor:"none"},children:[F("div",{"data-begonia-virtual-spacer":"left",style:{width:ie.leftSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}}),F("div",{style:{position:"relative",height:ie.mountedSurfaceHeight,width:ie.mountedSurfaceWidth,flex:"0 0 auto"},children:ao.clusters.map(x=>{let H=x.leadingGap;return Ye("div",{style:{position:"absolute",top:x.offsetTop,left:x.offsetLeft,width:x.width,height:x.height},children:[H?F("div",{"data-begonia-virtual-spacer":"gap","data-begonia-gap-from":String(H.fromPageIndex),"data-begonia-gap-to":String(H.toPageIndex),style:{position:"absolute",top:H.top,left:H.left,width:H.width,height:H.height,overflowAnchor:"none"}}):null,x.frames.map(me=>F(Ce,{frame:me,scale:L,measureText:I,measurementEpoch:i,flowMode:D,offsetTop:x.top,offsetLeft:x.left,renderPageOverlay:k,onProjectionPositionHit:T},`page-${me.page.pageNumber}`))]},`cluster-${x.startIndex}-${x.endIndex}`)})}),F("div",{"data-begonia-virtual-spacer":"right",style:{width:ie.rightSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}})]}),F("div",{"data-begonia-virtual-spacer":"bottom",style:{height:ie.bottomSpacerHeight,width:"100%",overflowAnchor:"none"}})]}):N.window.mountedFrames.map(x=>F(Ce,{frame:x,scale:L,measureText:I,measurementEpoch:i,flowMode:D,renderPageOverlay:k,onProjectionPositionHit:T},`page-${x.page.pageNumber}`))})})})}import{jsx as Wt}from"react/jsx-runtime";function vn(e){return{projection:e.projection??null,adapter:e.adapter,source:e.source??null,version:e.version??null,options:e.options,flowMode:e.flowMode,scale:e.scale,measureText:e.measureText}}function tt({projection:e=null,adapter:t,source:o=null,version:i,options:r,measureText:a,onLayoutChange:l,scrollHost:m,height:f,width:p,scale:u,pageGap:s,windowPages:n,overscan:d,virtualize:g,layoutMode:w,flowMode:c,anchorPageNumber:b,initialViewportAnchor:P,viewportRequestKey:v,pinnedPageNumbers:k,emptyLabel:T,onViewportChange:L,onProjectionPositionHit:E}){let I=et(null),D=et(null);D.current===null&&(D.current=bn());let J=a??D.current??void 0,Q=gn(()=>vn({projection:e,adapter:t,source:o,version:i,options:r,flowMode:c,scale:u,measureText:J}),[t,J,c,r,e,u,o,i]),_=et(null);_.current||(_.current=wn(Q));let N=_.current,$=B(N)??N.getSnapshot();return Qe(()=>{N.setInput(Q)},[N,Q]),Qe(()=>{let re=N.bindHost({getHost:()=>I.current,getScrollHost:()=>m??null});return()=>{re.cleanup()}},[N,m]),Qe(()=>{l?.($.resolvedLayout)},[l,$.resolvedLayout]),fn(()=>()=>{N.destroy()},[N]),Wt("div",{ref:I,style:{width:"100%"},children:Wt(Je,{projection:$.previewProjection,version:i??null,measureText:J,scrollHost:m,height:f,width:p,scale:u,pageGap:s,windowPages:n,overscan:d,virtualize:g,layoutMode:w,flowMode:$.requestedFlowMode,anchorPageNumber:b,initialViewportAnchor:P,viewportRequestKey:v,pinnedPageNumbers:k,emptyLabel:T,onViewportChange:L,onProjectionPositionHit:E})})}import{useEffect as se,useLayoutEffect as zt,useMemo as Gt,useReducer as Pn,useRef as z}from"react";import{createBrowserEditorMount as xn}from"@datalking/begonia-browser-sdk";var Z=Symbol("browser-editor-ui-callback-unset");function ot({onEditorChange:e,onHostChange:t,onSnapshotChange:o,...i}){let r=Gt(()=>({backend:i.backend,backendInput:i.backendInput}),[i.backend,i.backendInput]),a=z(null);a.current||(a.current=xn(r));let l=a.current,m=z(null),[f,p]=Pn(E=>E+1,0),u=Gt(()=>({getSnapshot:()=>l.getSnapshot(),subscribe:E=>l.subscribe(E)}),[f,l]),s=B(u)??l.getSnapshot(),n=s.ui,d=s.host,g=s.snapshot,w=z(e),c=z(t),b=z(o),P=z(Z),v=z(Z),k=z(Z),T=z(null),L=z(null);if(!L.current){let E=(I=>{T.current!==I&&(T.current=I,l.setHost(I),p())});Object.defineProperty(E,"current",{configurable:!0,enumerable:!0,get(){return T.current},set(I){E(I)}}),L.current=E}return zt(()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},[l]),se(()=>{w.current=e},[e]),se(()=>{c.current=t},[t]),se(()=>{b.current=o},[o]),zt(()=>{l.setInput(r.backendInput)},[l,r]),se(()=>{if(P.current===n||P.current===Z&&n==null){P.current=n;return}P.current=n,w.current?.(n)},[n]),se(()=>{if(v.current===d||v.current===Z&&d==null){v.current=d;return}v.current=d,c.current?.(d)},[d]),se(()=>{if(k.current===g||k.current===Z&&g==null){k.current=g;return}k.current=g,b.current?.(g)},[g]),se(()=>()=>{let E=setTimeout(()=>{m.current===E&&(m.current=null,P.current!==Z&&P.current!==null&&w.current?.(null),v.current!==Z&&v.current!==null&&c.current?.(null),k.current!==Z&&k.current!==null&&b.current?.(null),P.current=null,v.current=null,k.current=null,l.destroy())},0);m.current=E},[l]),{hostRef:L.current,ui:n,host:d,snapshot:g}}import{createEditorUiController as Sn}from"@datalking/begonia-editor-ui";import{useEffect as yn,useMemo as hn}from"react";function Kt(e,t){let o=hn(e,t);return yn(()=>()=>{o?.destroy()},[o]),o}function nt(e,t=null){let o=Kt(()=>Sn(e),[e]),i=t??o,r=B(i)??i.getSnapshot();return{controller:i,snapshot:r}}import{resolveVirtualPagedPreviewPositionHit as Rn,resolveVirtualPagedPreviewPositionHitInMountedFrames as Cn}from"@datalking/begonia-layout-renderer";import{applyVirtualPagedPreviewAutoscroll as kn,createVirtualPagedPreviewAutoscrollController as Tn,resolveVirtualPagedPreviewAutoscrollDelta as En}from"@datalking/begonia-layout-renderer";import{resolveVirtualPagedPreviewRenderState as Vn}from"@datalking/begonia-layout-renderer";import{cloneVirtualPagedPreviewAnchor as ia,cloneVirtualPagedPreviewMetrics as Bn,cloneVirtualPagedPreviewSnapshot as aa,normalizeVirtualPagedPreviewPinnedPageIndexes as Ln,normalizeVirtualPagedPreviewRequestKey as In,resolveVirtualPagedPreviewHostMeasurement as Nn,resolveVirtualPagedPreviewResizeObserver as Mn,sameVirtualPagedPreviewAnchor as la,sameVirtualPagedPreviewMetrics as An,sameVirtualPagedPreviewSnapshot as sa}from"@datalking/begonia-layout-renderer";import{createVirtualPagedPreviewSessionState as Dn,resolveVirtualPagedPreviewSessionCommit as On,resolveVirtualPagedPreviewSessionViewportEmission as Hn}from"@datalking/begonia-layout-renderer";import{useEffect as qt,useLayoutEffect as Fn,useMemo as rt,useRef as Zt}from"react";import{createBrowserPaginatedPreviewController as jn,resolveBrowserPaginatedPreviewBindingProjection as _n}from"@datalking/begonia-browser-sdk/preview";import{resolveBrowserEditorPreviewBinding as $n}from"@datalking/begonia-browser-sdk";import{createDefaultPaginatedLayoutMeasureText as Un}from"@datalking/begonia-layout-renderer";import{jsx as Gn}from"react/jsx-runtime";function Wn(e){return{adapter:e.adapter??null,source:e.source??null,version:e.version??null,options:e.options??null}}function zn(e){return{editor:e.editor,source:e.source,explicitProjection:e.projection??null,explicitScale:e.scale,pageGap:kt(e.pageGap),explicitFlowMode:e.flowMode,explicitLayoutMode:e.layoutMode,explicitAnchorPageNumber:e.anchorPageNumber,controllerNavigationMode:e.controllerNavigationMode,syncViewportToEditor:e.syncViewportToEditor,pinnedPageNumbers:e.pinnedPageNumbers,layoutResolutionIdentity:e.layoutResolutionIdentity}}function Xt({editor:e,scale:t,flowMode:o,anchorPageNumber:i,controllerNavigationMode:r="consume",syncViewportToEditor:a=!0,onViewportChange:l,onLayoutChange:m,onProjectionPositionHit:f,...p}){let u=rt(()=>Wn(p),[p.adapter,p.options,p.source,p.version]),s=rt(()=>zn({...p,editor:e,scale:t,flowMode:o,anchorPageNumber:i,controllerNavigationMode:r,syncViewportToEditor:a,layoutResolutionIdentity:u}),[i,r,e,o,u,p.layoutMode,p.pageGap,p.pinnedPageNumbers,p.projection,t,a]),n=Zt(null);n.current||(n.current=jn(s));let d=n.current,g=B(d)??d.getSnapshot(),w=p.projection??null,c=rt(()=>$n(e),[e]),b=Zt(null);b.current===null&&(b.current=Un());let P=p.measureText??b.current??void 0;return Fn(()=>{d.setInput(s)},[d,s]),qt(()=>()=>{d.destroy()},[d]),qt(()=>{if(c?.setResolvedProjection)return c.setResolvedProjection(_n({binding:c,source:p.source,explicitProjection:w,resolvedProjection:g.previewProjection}),{measureText:P,measurementEpoch:p.options?.measurementEpoch}),()=>{c.setResolvedProjection?.(null,null)}},[p.source,w,P,p.options?.measurementEpoch,c,g.previewProjection]),Gn(tt,{...p,projection:w,layoutMode:g.viewModel.layoutMode,flowMode:g.viewModel.flowMode,scale:g.viewModel.scale,anchorPageNumber:g.viewModel.anchorPageNumber,initialViewportAnchor:g.viewModel.initialViewportAnchor,viewportRequestKey:g.viewModel.viewportRequestKey,pinnedPageNumbers:g.pinnedPageNumbers,onLayoutChange:v=>{d.setResolvedProjection(v),m?.(v)},onViewportChange:v=>{d.observeViewport(v,g.viewportResetVersion),l?.(v)},onProjectionPositionHit:v=>{let k=d.resolvePositionHitEvent(v),T=d.handlePositionHit(k),L=f?.(k);return T||L===!0}},g.viewportResetVersion)}import{jsx as qn}from"react/jsx-runtime";function Kn(...e){return e.filter(Boolean).join(" ")}function y({active:e,mixed:t=!1,disabled:o=!1,label:i,onClick:r,title:a}){return qn("button",{type:"button","aria-pressed":t?"mixed":e,disabled:o,title:a,className:Kn("inline-flex items-center justify-center rounded-full border px-3 py-1.5 text-xs font-semibold transition disabled:pointer-events-none disabled:opacity-45",t?"border-teal-700 bg-teal-50 text-teal-900 shadow-sm":e?"border-teal-700 bg-teal-700 text-white shadow-sm":"border-slate-200 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50"),onClick:r,children:i})}import{jsx as te,jsxs as it}from"react/jsx-runtime";function at({controller:e}){let t=B(e);if(!e||!t?.enabled)return null;let o=t.suppressInternalExternal;return it("div",{className:"grid gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-3",children:[it("div",{className:"flex flex-wrap items-center gap-2",children:[te("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Comments"}),te(y,{active:t.visible,label:"Show",onClick:()=>e.setCommentsVisible(!0)}),te(y,{active:!t.visible,label:"Hide",onClick:()=>e.setCommentsVisible(!1)}),te(y,{active:t.showResolved,label:"Resolved",onClick:()=>e.setCommentsShowResolved(!t.showResolved)})]}),it("div",{className:"flex flex-wrap items-center gap-2",children:[te("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Scope"}),te(y,{active:t.visibility==="all",disabled:o,label:"All",onClick:()=>e.setCommentsVisibility("all")}),te(y,{active:t.visibility==="internal",disabled:o,label:"Internal",onClick:()=>e.setCommentsVisibility("internal")}),te(y,{active:t.visibility==="external",label:"External",onClick:()=>e.setCommentsVisibility("external")})]})]})}import{jsx as M,jsxs as O}from"react/jsx-runtime";function ke(...e){return e.filter(Boolean).join(" ")}function lt({comments:e,permissionsByCommentId:t,activeCommentId:o=null,canCreateComment:i=!1,createCommentDisabledReason:r=null,onCreateComment:a,onSelectComment:l,onToggleCommentInternal:m,onReplyComment:f,onResolveComment:p,onReopenComment:u}){return O("aside",{className:"grid gap-3","aria-label":"Comments sidebar",children:[O("header",{className:"flex items-center justify-between",children:[O("div",{children:[M("h2",{className:"text-sm font-semibold text-slate-900",children:"Comments"}),O("p",{className:"text-xs text-slate-500",children:[e.length," thread",e.length===1?"":"s"]})]}),a?M("button",{type:"button",disabled:!i,title:r??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>a(),children:"New Comment"}):null]}),O("div",{className:"grid gap-3",children:[e.length===0?M("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"No comment threads."}):null,e.map(s=>{let n=t?.[s.id]??null;return O("section",{className:ke("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",o===s.id?"border-teal-300 bg-teal-50/70":"border-slate-200 bg-white"),children:[O("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>l?.(s.id),children:[O("div",{className:"flex items-center justify-between gap-3",children:[M("strong",{className:"text-sm text-slate-900",children:s.authorName??s.authorId??"Unknown author"}),O("div",{className:"flex items-center gap-2",children:[M("span",{className:ke("rounded-full px-2 py-1 text-[11px] font-semibold",s.isInternal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:s.isInternal?"Internal":"External"}),M("span",{className:ke("rounded-full px-2 py-1 text-[11px] font-semibold",s.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:s.resolved?"Resolved":"Open"})]})]}),M("p",{className:"text-sm text-slate-700",children:s.text||"Empty comment"}),O("span",{className:"text-[11px] text-slate-400",children:[s.entries.length," message",s.entries.length===1?"":"s"]})]}),M("div",{className:"grid gap-2",children:s.entries.map(d=>O("article",{className:ke("rounded-2xl px-3 py-2 text-sm",d.parentId==null?"bg-slate-50 text-slate-700":"bg-slate-100/80 text-slate-600"),children:[O("div",{className:"flex items-center justify-between gap-3",children:[M("strong",{className:"text-[11px] uppercase tracking-[0.12em] text-slate-400",children:d.parentId==null?"Thread":"Reply"}),M("span",{className:"text-[11px] text-slate-400",children:d.authorName??d.authorId??"Unknown"})]}),M("p",{children:d.text||"Empty entry"})]},d.id))}),O("div",{className:"flex flex-wrap gap-2",children:[m?M("button",{type:"button",disabled:n?!n.toggleInternal.allowed:!1,title:n?.toggleInternal.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>m(s.id,!s.isInternal),children:s.isInternal?"Mark External":"Mark Internal"}):null,M("button",{type:"button",disabled:n?!n.reply.allowed:!1,title:n?.reply.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>f?.(s.id),children:"Reply"}),s.resolved?M("button",{type:"button",disabled:n?!n.reopen.allowed:!1,title:n?.reopen.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>u?.(s.id),children:"Reopen"}):M("button",{type:"button",disabled:n?!n.resolve.allowed:!1,title:n?.resolve.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p?.(s.id),children:"Resolve"})]})]},s.id)})]})]})}import{Fragment as Xn,jsx as V,jsxs as X}from"react/jsx-runtime";function Zn(...e){return e.filter(Boolean).join(" ")}function st({editorHost:e,controller:t=null,linkActions:o=null,leadingActions:i=null,trailingActions:r=null,showTrackingToggle:a=!0,showSelectionReviewActions:l=!0}){let{controller:m,snapshot:f}=nt(e,t);function p(d,g){return m.execute(d,g)}function u(d){return f.commands[d]}function s(d,g){if(d==="link-set"||d==="link-clear"){if(!o){if(d==="link-set"){let c=u("link-set"),b=typeof c?.value=="string"?String(c.value):"",P=typeof window<"u"?window.prompt(g??"Enter link URL",b):null;if(!P)return;p(d,{href:P});return}p(d);return}let w=o.captureEffectiveSelectionHandle({includeText:!0});if(!w)return;try{if(d==="link-set"){let c=u("link-set"),b=typeof c?.value=="string"?String(c.value):"",P=typeof window<"u"?window.prompt(g??"Enter link URL",b):null;if(!P)return;o.setLinkFromHandle(w,P);return}o.clearLinkFromHandle(w)}finally{o.releaseSelectionHandle(w)}return}p(d)}function n({command:d,label:g,promptLabel:w}){let c=u(d);return V("button",{type:"button","aria-pressed":c?.mixed?"mixed":c?.active,className:Zn("inline-flex items-center justify-center rounded-full border px-3.5 py-2 text-sm font-semibold transition disabled:pointer-events-none disabled:opacity-50",c?.mixed?"border-teal-700 bg-teal-50 text-teal-900 shadow-sm":c?.active?"border-teal-700 bg-teal-700 text-white shadow-sm":"border-slate-200 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50"),disabled:c?.disabled,onClick:()=>s(d,w),children:g})}return X("div",{className:"grid gap-3",role:"toolbar","aria-label":"Editor formatting toolbar",children:[i?V("div",{className:"flex flex-wrap gap-2",children:i}):null,X("div",{className:"flex flex-wrap gap-2.5",children:[X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"undo",label:"Undo"}),V(n,{command:"redo",label:"Redo"})]}),X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"bold",label:"Bold"}),V(n,{command:"italic",label:"Italic"}),V(n,{command:"underline",label:"Underline"}),V(n,{command:"strikethrough",label:"Strike"})]}),X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"paragraph",label:"Body"}),V(n,{command:"heading-1",label:"H1"}),V(n,{command:"heading-2",label:"H2"}),V(n,{command:"heading-3",label:"H3"})]}),X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"bullet-list",label:"Bullets"}),V(n,{command:"numbered-list",label:"Numbers"})]}),X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"link-set",label:"Link",promptLabel:"Enter a URL or #bookmark target"}),V(n,{command:"link-clear",label:"Unlink"})]}),a?X("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[V(n,{command:"tracking-toggle",label:f.trackingEnabled?"Tracking On":"Tracking Off"}),l?X(Xn,{children:[V(n,{command:"track-changes-accept-selection",label:"Accept Selection"}),V(n,{command:"track-changes-reject-selection",label:"Reject Selection"})]}):null]}):null]}),r?V("div",{className:"flex flex-wrap gap-2",children:r}):null]})}import{useEffect as Yn,useRef as Jn}from"react";import{jsx as Te,jsxs as er}from"react/jsx-runtime";function Qn(e){return e==="success"?"text-emerald-700 hover:bg-emerald-50":e==="danger"?"text-rose-700 hover:bg-rose-50":"text-slate-700 hover:bg-slate-50"}function dt({state:e}){let t=Jn(null),o=e.context.host.overlays.closeContextMenu;return Yn(()=>{let i=a=>{t.current?.contains(a.target)||o?.()},r=a=>{a.key==="Escape"&&o?.()};return window.addEventListener("mousedown",i),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",i),window.removeEventListener("keydown",r)}},[o]),Te("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-3xl border border-slate-200 bg-white p-2 shadow-2xl",style:{left:e.context.position.left,top:e.context.position.top},children:Te("div",{className:"grid gap-2",children:e.sections.map(i=>er("section",{className:"grid gap-1 border-b border-slate-100 pb-2 last:border-b-0 last:pb-0",children:[i.label?Te("h3",{className:"px-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-slate-400",children:i.label}):null,i.items.map(r=>Te("button",{type:"button",disabled:!r.enabled,title:r.disabledReason??void 0,className:`rounded-2xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-45 ${Qn(r.tone)}`,onClick:()=>{r.enabled&&(r.action(e.context),o?.())},children:r.label},r.id))]},i.id))})})}import{useEffect as Yt,useRef as tr}from"react";import{jsx as oe,jsxs as ut}from"react/jsx-runtime";function or(e){if(!(typeof window>"u")){if(e.isAnchorLink){window.location.hash=e.href.slice(1);return}window.open(e.href,"_blank","noopener,noreferrer")}}async function nr(e){typeof navigator>"u"||!navigator.clipboard?.writeText||await navigator.clipboard.writeText(e)}function ct({state:e}){let t=tr(null),o=e.host.activeLink,i=e.host.overlays.closeLinkPopover;return Yt(()=>{let r=l=>{t.current?.contains(l.target)||i?.()},a=l=>{l.key==="Escape"&&i?.()};return window.addEventListener("mousedown",r),window.addEventListener("keydown",a),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",a)}},[i]),Yt(()=>{if(e.resolution.type!=="external"||!t.current)return;let r=e.resolution.render({container:t.current,closePopover:()=>i?.(),controller:o,href:e.href,title:e.title})??{};return()=>{r.destroy?.()}},[i,o,e]),e.resolution.type==="external"?oe("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-3xl border border-slate-200 bg-white p-3 shadow-2xl",style:{left:e.position.left,top:e.position.top}}):oe("div",{ref:t,className:"fixed z-50 min-w-[260px] rounded-3xl border border-slate-200 bg-white p-4 shadow-2xl",style:{left:e.position.left,top:e.position.top},children:ut("div",{className:"grid gap-3",children:[ut("div",{className:"grid gap-1",children:[oe("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400",children:"Link"}),oe("code",{className:"break-all text-sm text-slate-700",children:e.href})]}),ut("div",{className:"flex flex-wrap gap-2",children:[oe("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>or(e),children:"Open"}),oe("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>nr(e.href),children:"Copy"}),oe("button",{type:"button",className:"rounded-full border border-sky-200 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700",onClick:()=>{let r=typeof window<"u"?window.prompt("Edit link URL",e.href):null;r&&o.updateActiveLink(r,e.title)},children:"Edit"}),oe("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>o.clearActiveLink(),children:"Remove"})]})]})})}import{jsx as Ve,jsxs as rr}from"react/jsx-runtime";function mt(e,t){return typeof window<"u"?window.prompt(e,t):null}function Ee(e,t){return e?.commands[t]??null}function Jt({editor:e,snapshot:t}){if(!e||!t||!t.selection)return null;let o=t.selection.formatting,i=!t.editable,r=(d,g)=>{i||e.execute(d,g)},a=Ee(t,"text-color"),l=Ee(t,"highlight-color"),m=Ee(t,"font-size"),f=Ee(t,"font-family"),p=i?"Document is read-only in the current document mode.":void 0,u=(d,g,w)=>{let c=mt(`${d}. Enter a CSS color value or "none" to clear.`,g??"");if(c==null)return;let b=c.trim(),P=b.length===0||b.toLowerCase()==="none"?null:b;r(w,P)},s=()=>{let d=mt('Set font size in points. Enter "none" to clear.',o.fontSize==null?"":String(o.fontSize));if(d==null)return;let g=d.trim();if(!g||g.toLowerCase()==="none"){r("font-size",null);return}let w=Number(g.replace(/pt$/i,"").trim());Number.isFinite(w)&&w>0&&r("font-size",w)},n=()=>{let d=mt('Set font family. Enter "none" to clear.',o.fontFamily??"");if(d==null)return;let g=d.trim();r("font-family",!g||g.toLowerCase()==="none"?null:g)};return rr("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[Ve(y,{active:a?.active??o.color!=null,mixed:a?.mixed??o.mixed?.color===!0,disabled:i||a?.disabled,label:o.color?`Text ${o.color}`:"Text Color",title:p,onClick:()=>u("Set text color",o.color,"text-color")}),Ve(y,{active:l?.active??o.highlight!=null,mixed:l?.mixed??o.mixed?.highlight===!0,disabled:i||l?.disabled,label:o.highlight?`Highlight ${o.highlight}`:"Highlight",title:p,onClick:()=>u("Set highlight color",o.highlight,"highlight-color")}),Ve(y,{active:m?.active??o.fontSize!=null,mixed:m?.mixed??o.mixed?.fontSize===!0,disabled:i||m?.disabled,label:o.fontSize!=null?`Size ${o.fontSize}`:"Font Size",title:p,onClick:s}),Ve(y,{active:f?.active??o.fontFamily!=null,mixed:f?.mixed??o.mixed?.fontFamily===!0,disabled:i||f?.disabled,label:o.fontFamily?`Font ${o.fontFamily}`:"Font Family",title:p,onClick:n})]})}import{jsx as Y,jsxs as pt}from"react/jsx-runtime";function ft({controller:e}){let t=B(e);if(!e||!t)return null;let{documentMode:o,trackChanges:i}=t,r=o==="viewing",a=i.enabled;return pt("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[pt("div",{className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-2 py-1",children:[Y("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Mode"}),Y(y,{active:o==="editing",label:"Edit",onClick:()=>e.setDocumentMode("editing")}),Y(y,{active:o==="suggesting",disabled:!a,label:"Suggest",onClick:()=>e.setDocumentMode("suggesting")}),Y(y,{active:r,label:"View",onClick:()=>e.setDocumentMode("viewing")})]}),pt("div",{className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-2 py-1",children:[Y("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Markup"}),Y(y,{active:i.mode==="review",label:"Review",onClick:()=>e.setTrackChangesDisplayMode("review")}),Y(y,{active:i.mode==="original",disabled:!r,label:"Original",onClick:()=>e.setTrackChangesDisplayMode("original")}),Y(y,{active:i.mode==="final",disabled:!r,label:"Final",onClick:()=>e.setTrackChangesDisplayMode("final")}),Y(y,{active:i.mode==="off",label:"Hide",onClick:()=>e.setTrackChangesDisplayMode("off")})]})]})}import{resolveBrowserViewIntentPatch as ge,resolveBrowserViewIntentSnapshot as ir,resolveBrowserViewLayoutMode as ar,resolveBrowserViewZoomMode as lr,resolveBrowserZoomStep as eo}from"@datalking/begonia-browser-sdk/editor";function Qt(e){return e==="web"?"Sets the paginated layout that will be restored when you switch back to paged view.":void 0}import{jsx as j,jsxs as be}from"react/jsx-runtime";var we=Object.freeze([50,75,100,125,150,200]);function gt({controller:e}){let t=B(e);if(!e||!t?.zoom)return null;let o=ir(t),{flowMode:i}=o,r=ar(o),a=Qt(i),l=t.zoom.percent,m=t.zoom.mode,f=t.zoom.viewportMetrics?.fitZoom??null;return be("div",{className:"flex flex-wrap gap-2 rounded-[20px] border border-slate-200 bg-slate-50 p-2",children:[be("div",{className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-2 py-1",children:[j("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"View"}),j(y,{active:i==="web",label:"Web",onClick:()=>e.setViewState(ge(o,{type:"flow",flowMode:"web"}))}),j(y,{active:i==="paginated",label:"Paged",onClick:()=>e.setViewState(ge(o,{type:"flow",flowMode:"paginated"}))})]}),be("div",{className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-2 py-1",children:[j("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Layout"}),j(y,{active:r==="vertical",label:"Vertical",title:a,onClick:()=>e.setViewState(ge(o,{type:"layout",layoutMode:"vertical"}))}),j(y,{active:r==="horizontal",label:"Horizontal",title:a,onClick:()=>e.setViewState(ge(o,{type:"layout",layoutMode:"horizontal"}))}),j(y,{active:r==="book",label:"Book",title:a,onClick:()=>e.setViewState(ge(o,{type:"layout",layoutMode:"book"}))})]}),be("div",{className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-2 py-1",children:[j("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-400",children:"Zoom"}),j(y,{active:m==="fit-width",label:f==null?"Fit":`Fit ${Math.round(f)}%`,onClick:()=>e.setZoomMode(lr({zoomMode:m})),title:f==null?"Fit to the measured preview width once the paginated preview is ready.":void 0}),j(y,{active:!1,disabled:l<=(we[0]??l),label:"-",onClick:()=>e.setViewState({zoomPercent:eo(l,we,-1)})}),be("span",{className:"min-w-14 text-center text-xs font-semibold text-slate-700",children:[Math.round(l),"%"]}),j(y,{active:m==="manual"&&l===100,label:"100%",onClick:()=>e.setViewState({zoomPercent:100})}),j(y,{active:!1,disabled:l>=(we[we.length-1]??l),label:"+",onClick:()=>e.setViewState({zoomPercent:eo(l,we,1)})})]})]})}import{jsx as G,jsxs as K}from"react/jsx-runtime";function to(...e){return e.filter(Boolean).join(" ")}function sr(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function oo(e){return!!(e.relatedKinds?.includes("insert")&&e.relatedKinds?.includes("delete"))}function wt({revisions:e,permissionsByRevisionId:t,activeRevisionId:o=null,onAcceptRevision:i,onRejectRevision:r,onRevealRevision:a,onAcceptAll:l,onRejectAll:m}){let f=e.every(u=>t?.[u.id]?.accept.allowed??!0),p=e.every(u=>t?.[u.id]?.reject.allowed??!0);return K("aside",{className:"grid gap-3","aria-label":"Review panel",children:[K("header",{className:"flex items-end justify-between gap-3",children:[K("div",{children:[G("h2",{className:"text-sm font-semibold text-slate-900",children:"Review"}),K("p",{className:"text-xs text-slate-500",children:[e.length," pending revision",e.length===1?"":"s"]})]}),e.length>0?K("div",{className:"flex gap-2",children:[G("button",{type:"button",disabled:!f,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:l,children:"Accept all"}),G("button",{type:"button",disabled:!p,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:m,children:"Reject all"})]}):null]}),K("div",{className:"grid gap-3",children:[e.length===0?G("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"No pending revisions."}):null,e.map(u=>{let s=t?.[u.id],n=o===u.id;return K("section",{className:to("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",n?"border-teal-300 bg-teal-50/70":"border-slate-200 bg-white"),children:[K("div",{className:"flex items-center justify-between gap-3",children:[G("span",{className:to("rounded-full px-2 py-1 text-[11px] font-semibold",oo(u)?"bg-amber-100 text-amber-700":u.kind==="insert"?"bg-emerald-100 text-emerald-700":u.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"),children:oo(u)?"Replace":sr(u.kind)}),G("span",{className:"text-[11px] text-slate-400",children:u.authorName||u.authorId})]}),G("p",{className:"text-sm text-slate-700",children:u.text||"Formatting change"}),u.prompt?K("p",{className:"text-[11px] text-slate-400",children:["Prompt: ",u.prompt]}):null,K("div",{className:"flex gap-2",children:[a?G("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>a(u),children:"Reveal"}):null,G("button",{type:"button",disabled:s?!s.accept.allowed:!1,title:s?.accept.reason??void 0,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>i?.(u.id),children:"Accept"}),G("button",{type:"button",disabled:s?!s.reject.allowed:!1,title:s?.reject.reason??void 0,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>r?.(u.id),children:"Reject"})]})]},u.id)})]})]})}import{jsx as R,jsxs as S}from"react/jsx-runtime";function ne(...e){return e.filter(Boolean).join(" ")}function dr(e){return e==="insert"?"bg-emerald-100 text-emerald-700":e==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"}function ur(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function no(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function cr(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function bt(e,t){return e.relatedKinds.includes(t)||e.revision.kind===t}function vt(e){if(!e)return"Unknown time";let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function mr(e){return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function pr(e){return e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function fr(e){return e.deleted?"Deleted":e.resolved?"Resolved":"Open"}function gr(e){return e.kind==="comment-status"?e.status==="resolved"?"Resolved":e.status==="open"?"Reopened":"Status":e.kind==="comment-visibility"?e.internalAfter?"Made Internal":"Made External":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Thread Removed":"Reply Removed":e.kind==="comment-edit"?e.parentEntryId==null?"Thread Edited":"Reply Edited":e.kind==="comment-reply"?"Reply Added":"Thread Created"}function wr(e){return e.kind==="comment-status"?`${e.resolvedBefore?"Resolved":"Open"} -> ${e.resolvedAfter?"Resolved":"Open"}`:e.kind==="comment-visibility"?`${e.internalBefore?"Internal":"External"} -> ${e.internalAfter?"Internal":"External"}`:e.kind==="comment-removal"||e.kind==="comment-edit"||e.kind==="comment-reply"?`${e.entryCountBefore} -> ${e.entryCountAfter} message${e.entryCountAfter===1?"":"s"}`:`${e.entryCount} message${e.entryCount===1?"":"s"}`}function Pt({timeline:e,summary:t=null,activeCommentId:o=null,activeRevisionId:i=null,onSelectComment:r,onReplyComment:a,onResolveComment:l,onReopenComment:m,onAcceptRevision:f,onRejectRevision:p,onRevealRevision:u}){let s=t??{total:e.length,revisions:e.filter(n=>n.kind==="revision").length,insertions:e.filter(n=>n.kind==="revision"&&bt(n,"insert")).length,deletions:e.filter(n=>n.kind==="revision"&&bt(n,"delete")).length,formatting:e.filter(n=>n.kind==="revision"&&bt(n,"format")).length,commentThreads:e.filter(n=>n.kind==="comment-thread").length,openCommentThreads:e.filter(n=>n.kind==="comment-thread"&&!n.resolved&&!n.deleted).length,resolvedCommentThreads:e.filter(n=>n.kind==="comment-thread"&&n.resolved&&!n.deleted).length,deletedCommentThreads:e.filter(n=>n.kind==="comment-thread"&&n.deleted).length,commentReplies:e.filter(n=>n.kind==="comment-reply").length,commentEdits:e.filter(n=>n.kind==="comment-edit").length,commentStatusChanges:e.filter(n=>n.kind==="comment-status").length,commentVisibilityChanges:e.filter(n=>n.kind==="comment-visibility").length,commentRemovals:e.filter(n=>n.kind==="comment-removal").length};return S("aside",{className:"grid gap-3","aria-label":"Review timeline panel",children:[R("header",{className:"grid gap-1",children:S("div",{className:"flex items-end justify-between gap-3",children:[S("div",{children:[R("h2",{className:"text-sm font-semibold text-slate-900",children:"Review Timeline"}),S("p",{className:"text-xs text-slate-500",children:[s.total," review item",s.total===1?"":"s"]})]}),S("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[S("span",{children:[s.revisions," revision",s.revisions===1?"":"s"]}),S("span",{children:[s.openCommentThreads," open thread",s.openCommentThreads===1?"":"s"]}),S("span",{children:[s.commentReplies," repl",s.commentReplies===1?"y":"ies"]})]})]})}),S("div",{className:"grid gap-3",children:[e.length===0?R("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"No review activity yet."}):null,e.map(n=>{if(n.kind==="revision"){let c=n.permissions,b=i===n.revisionId;return S("section",{className:ne("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",b?"border-teal-300 bg-teal-50/70":"border-slate-200 bg-white"),children:[S("div",{className:"flex items-center justify-between gap-3",children:[R("span",{className:ne("rounded-full px-2 py-1 text-[11px] font-semibold",no(n)?"bg-amber-100 text-amber-700":dr(n.revision.kind)),children:no(n)?"Replace":ur(n.revision.kind)}),R("span",{className:"text-[11px] text-slate-400",children:n.authorName??n.authorId??"Unknown"})]}),R("p",{className:"text-sm text-slate-700",children:n.text||"Formatting change"}),n.excerpt?S("p",{className:"text-[11px] text-slate-500",children:["Target: ",n.excerpt]}):null,n.revision.prompt?S("p",{className:"text-[11px] text-slate-400",children:["Prompt: ",n.revision.prompt]}):null,R("p",{className:"text-[11px] text-slate-400",children:vt(n.sortAt)}),S("div",{className:"flex gap-2",children:[u?R("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>u(n),children:"Reveal"}):null,R("button",{type:"button",disabled:c?!c.accept.allowed:!1,title:c?.accept.reason??void 0,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>f?.(n.revisionId),children:"Accept"}),R("button",{type:"button",disabled:c?!c.reject.allowed:!1,title:c?.reject.reason??void 0,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p?.(n.revisionId),children:"Reject"})]})]},n.id)}if(n.kind==="revision-decision"){let c=n.decision==="accept",b=cr(n),P=i===n.revisionId,v=b?`${c?"Accepted":"Rejected"} Replace`:n.relatedKinds.includes("format")?`${c?"Accepted":"Rejected"} Format`:`${c?"Accepted":"Rejected"} ${n.revisionKind==="delete"?"Delete":"Insert"}`;return S("section",{className:ne("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",P?"border-teal-300 bg-teal-50/70":"border-slate-200 bg-white"),children:[S("div",{className:"flex items-center justify-between gap-3",children:[R("span",{className:ne("rounded-full px-2 py-1 text-[11px] font-semibold",c?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700"),children:v}),R("span",{className:"text-[11px] text-slate-400",children:n.authorName??n.authorId??"Unknown"})]}),R("p",{className:"text-sm text-slate-700",children:n.text}),n.excerpt?S("p",{className:"text-[11px] text-slate-500",children:["Target: ",n.excerpt]}):null,S("p",{className:"text-[11px] text-slate-400",children:[vt(n.sortAt)," \xB7 ",n.memberCount," member",n.memberCount===1?"":"s"]}),u?R("div",{className:"flex gap-2",children:R("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>u(n),children:"Reveal"})}):null]},n.id)}let d=n.threadPermissions,g=o===n.commentId,w=!n.deleted;return S("section",{className:ne("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",g?"border-teal-300 bg-teal-50/70":"border-slate-200 bg-white"),children:[S("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>r?.(n.commentId),children:[S("div",{className:"flex items-center justify-between gap-3",children:[S("div",{className:"flex items-center gap-2",children:[R("span",{className:ne("rounded-full px-2 py-1 text-[11px] font-semibold",pr(n)),children:mr(n)}),R("span",{className:ne("rounded-full px-2 py-1 text-[11px] font-semibold",n.deleted?"bg-rose-100 text-rose-700":n.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:fr(n)}),R("span",{className:ne("rounded-full px-2 py-1 text-[11px] font-semibold",n.internal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:n.internal?"Internal":"External"})]}),R("span",{className:"text-[11px] text-slate-400",children:n.authorName??n.authorId??"Unknown"})]}),R("p",{className:"text-sm text-slate-700",children:n.text||"Empty comment"}),n.target?.text?S("p",{className:"text-[11px] text-slate-500",children:["Target: ",n.target.text]}):null,S("p",{className:"text-[11px] text-slate-400",children:[vt(n.sortAt)," \xB7 ",gr(n)," \xB7"," ",wr(n)]})]}),S("div",{className:"flex flex-wrap gap-2",children:[R("button",{type:"button",disabled:!w||(d?!d.reply.allowed:!1),title:d?.reply.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>a?.(n.commentId),children:"Reply"}),n.deleted?null:n.resolved?R("button",{type:"button",disabled:d?!d.reopen.allowed:!1,title:d?.reopen.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>m?.(n.commentId),children:"Reopen"}):R("button",{type:"button",disabled:d?!d.resolve.allowed:!1,title:d?.resolve.reason??void 0,className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>l?.(n.commentId),children:"Resolve"})]})]},n.id)})]})]})}import{Fragment as Sr,jsx as A,jsxs as ve}from"react/jsx-runtime";function vr(...e){return e.filter(Boolean).join(" ")}var ro={linkPopover:null,contextMenu:null};function Pr(e){return br(t=>e?.overlayState.subscribe(t)??(()=>{}),()=>e?.overlayState.getSnapshot()??ro,()=>ro)}function xr(e){return e?e===!0?{enabled:!0,projection:void 0}:{...e,enabled:e.enabled??!0}:null}function yr(e){return e?e.editable?e.comments.enabled?e.comments.readOnly?"Comments are read-only in the current document mode.":e.selection?null:"Place the caret in text or select text before creating a comment.":"Comments are not enabled for the current editor session.":"Document is read-only in the current document mode.":"Editor is not ready."}function hr({backend:e,backendInput:t,onEditorChange:o,onSnapshotChange:i,paginatedPreview:r,showToolbar:a=!0,showRichFormatControls:l=!0,showViewControls:m=!0,showReviewControls:f=!0,showComments:p=!0,showCommentDisplayControls:u=!0,showReview:s=!0,showReviewTimeline:n=!0,sidebarStart:d=null,className:g}){let{hostRef:w,ui:c,snapshot:b}=ot({backend:e,backendInput:t,onEditorChange:o,onSnapshotChange:i}),P=Pr(c),v=c?.preview.readLayoutAdapter()??null,k=c?.preview.readLayoutSource()??null,T=xr(r),L=T?.enabled??!1,E=!!d||n||p||s,I=T?.projection??null,{enabled:D,...J}=T??{},Q=b?.comments.activeCommentId??null,_=h=>{let q=typeof window<"u"?window.prompt("Reply to comment"):null;!q||!c||c.comments.reply(h,q)},N=yr(b),$=N==null,re=h=>{c&&c.comments.reveal(h)},Pe=()=>{if(!c||!$)return;let h=typeof window<"u"?window.prompt("New comment"):null;if(!h)return;let q=c.comments.create(h)},ue=h=>{c&&c.trackChanges.reveal(h)};return ve("div",{className:vr("grid gap-4",g),children:[a?A(st,{editorHost:c?.session??null,controller:c,trailingActions:ve(Sr,{children:[l?A(Jt,{editor:c,snapshot:b}):null,m?A(gt,{controller:c?.view??null}):null,f?A(ft,{controller:c?.documentMode??null}):null]})}):null,ve("div",{className:L?E?"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.9fr)_320px]":"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.9fr)]":E?"grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]":"grid gap-4",children:[A("div",{className:"rounded-[28px] border border-slate-200 bg-white p-4 shadow-sm",children:A("div",{className:"editor-frame",children:A("div",{ref:w,className:"editor-host"})})}),L?A("div",{className:"rounded-[28px] border border-slate-200 bg-white p-4 shadow-sm",children:A(Xt,{...J,editor:c,adapter:I?void 0:v??void 0,source:k})}):null,E?ve("div",{className:"grid gap-4",children:[d,n?A(Pt,{timeline:b?.review.timeline??[],summary:b?.review.summary??null,activeCommentId:Q,activeRevisionId:b?.review.activeRevisionId??null,onSelectComment:re,onReplyComment:_,onResolveComment:h=>c?.comments.resolve(h),onReopenComment:h=>c?.comments.reopen(h),onAcceptRevision:h=>c?.reviewActions.acceptRevision(h),onRejectRevision:h=>c?.reviewActions.rejectRevision(h),onRevealRevision:ue}):null,p?ve("div",{className:"grid gap-3",children:[u?A(at,{controller:c?.commentsDisplay??null}):null,A(lt,{comments:b?.comments.items??[],permissionsByCommentId:b?.comments.permissions??{},activeCommentId:Q,canCreateComment:$,createCommentDisabledReason:N,onCreateComment:c?Pe:void 0,onSelectComment:re,onToggleCommentInternal:(h,q)=>c?.comments.setInternal(h,q),onReplyComment:_,onResolveComment:h=>c?.comments.resolve(h),onReopenComment:h=>c?.comments.reopen(h)})]}):null,s?A(wt,{revisions:b?.review.revisions??[],permissionsByRevisionId:b?.review.permissions??{},activeRevisionId:b?.review.activeRevisionId??null,onAcceptRevision:h=>c?.reviewActions.acceptRevision(h),onRejectRevision:h=>c?.reviewActions.rejectRevision(h),onAcceptAll:()=>c?.reviewActions.acceptAll(),onRejectAll:()=>c?.reviewActions.rejectAll(),onRevealRevision:ue}):null]}):null]}),P.linkPopover?A(ct,{state:P.linkPopover}):null,P.contextMenu?A(dt,{state:P.contextMenu}):null]})}import{createPdfViewerController as Zl}from"@datalking/begonia-pdf-viewer";export{B as a,Ie as b,Ct as c,Ne as d,vo as e,Me as f,Po as g,Ae as h,xo as i,De as j,Oe as k,He as l,Fe as m,je as n,Xe as o,Je as p,tt as q,ot as r,Kt as s,nt as t,Rn as u,Cn as v,kn as w,Tn as x,En as y,Vn as z,Bn as A,Ln as B,In as C,Nn as D,Mn as E,An as F,Dn as G,On as H,Hn as I,Xt as J,at as K,lt as L,st as M,dt as N,ct as O,Jt as P,ft as Q,gt as R,wt as S,Pt as T,hr as U,Zl as V};
|