@datalking/begonia-react 0.1.0 → 0.2.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/PaginatedLayoutView.d.ts +2 -2
- package/dist/binding/VirtualPagedPreview.d.ts +4 -1
- package/dist/binding/begonia-theme-style.d.ts +12 -0
- package/dist/binding/index.d.ts +2 -0
- package/dist/binding/paginated-preview-defaults.d.ts +2 -1
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-text.d.ts +2 -2
- package/dist/chunk-ORLGCG23.js +1 -0
- package/dist/editor-surface.css +233 -0
- package/dist/index.js +1 -1
- package/dist/v1.js +1 -1
- package/package.json +17 -16
- package/dist/chunk-IEHE33P5.js +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { PdfViewerController, PdfViewerPageFrame } from '@datalking/begonia-pdf-viewer';
|
|
3
|
+
import type { BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
3
4
|
export interface BegoniaPdfViewerProps {
|
|
4
5
|
controller: PdfViewerController;
|
|
5
6
|
height?: number | string;
|
|
@@ -7,7 +8,9 @@ export interface BegoniaPdfViewerProps {
|
|
|
7
8
|
pageGap?: number;
|
|
8
9
|
className?: string;
|
|
9
10
|
style?: CSSProperties;
|
|
11
|
+
/** Theme preset id, theme object, or token patch applied to this viewer. */
|
|
12
|
+
theme?: BegoniaThemeInput;
|
|
10
13
|
emptyLabel?: string;
|
|
11
14
|
renderPageOverlay?: (frame: PdfViewerPageFrame) => ReactNode;
|
|
12
15
|
}
|
|
13
|
-
export declare function BegoniaPdfViewer({ controller, height, scale, pageGap, className, style, emptyLabel, renderPageOverlay, }: BegoniaPdfViewerProps): import("react").JSX.Element;
|
|
16
|
+
export declare function BegoniaPdfViewer({ controller, height, scale, pageGap, className, style, theme, emptyLabel, renderPageOverlay, }: BegoniaPdfViewerProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EditorLayoutAdapter, LayoutProjection, LayoutResolutionOptions, ResolvedLayoutProjection } from '@datalking/begonia-layout-contracts';
|
|
2
2
|
import { type VirtualPagedPreviewProps } from './VirtualPagedPreview.tsx';
|
|
3
3
|
import type { VirtualPagedPreviewPositionHitEvent } from './virtual-paged-preview-interaction.ts';
|
|
4
|
-
type PreviewProps = Pick<VirtualPagedPreviewProps, 'version' | 'measureText' | 'scrollHost' | 'height' | 'width' | 'scale' | 'pageGap' | 'windowPages' | 'overscan' | 'virtualize' | 'layoutMode' | 'flowMode' | 'anchorPageNumber' | 'initialViewportAnchor' | 'viewportRequestKey' | 'pinnedPageNumbers' | 'emptyLabel' | 'onViewportChange'>;
|
|
4
|
+
type PreviewProps = Pick<VirtualPagedPreviewProps, 'version' | 'measureText' | 'scrollHost' | 'height' | 'width' | 'scale' | 'pageGap' | 'windowPages' | 'overscan' | 'virtualize' | 'layoutMode' | 'flowMode' | 'anchorPageNumber' | 'initialViewportAnchor' | 'viewportRequestKey' | 'pinnedPageNumbers' | 'theme' | 'emptyLabel' | 'onViewportChange'>;
|
|
5
5
|
export type PaginatedLayoutViewProps<TSource = unknown> = PreviewProps & {
|
|
6
6
|
projection?: LayoutProjection | null;
|
|
7
7
|
adapter?: EditorLayoutAdapter<TSource>;
|
|
@@ -11,5 +11,5 @@ export type PaginatedLayoutViewProps<TSource = unknown> = PreviewProps & {
|
|
|
11
11
|
onLayoutChange?: (layout: ResolvedLayoutProjection | null) => void;
|
|
12
12
|
onProjectionPositionHit?: (event: VirtualPagedPreviewPositionHitEvent) => boolean | void;
|
|
13
13
|
};
|
|
14
|
-
export declare function PaginatedLayoutView<TSource = unknown>({ projection, adapter, source, version, options, measureText, onLayoutChange, scrollHost, height, width, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, emptyLabel, onViewportChange, onProjectionPositionHit, }: PaginatedLayoutViewProps<TSource>): import("react").JSX.Element;
|
|
14
|
+
export declare function PaginatedLayoutView<TSource = unknown>({ projection, adapter, source, version, options, measureText, onLayoutChange, scrollHost, height, width, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, theme, emptyLabel, onViewportChange, onProjectionPositionHit, }: PaginatedLayoutViewProps<TSource>): import("react").JSX.Element;
|
|
15
15
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LayoutProjection, LayoutProjectionOptions } from '@datalking/begonia-layout-contracts';
|
|
3
3
|
import type { LayoutFlowMode, LayoutRenderMode, PageViewportAnchor, PageViewportMetrics, VirtualPageFrame } from '@datalking/begonia-layout-renderer';
|
|
4
|
+
import type { BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
4
5
|
import type { VirtualPagedPreviewPositionHitEvent } from './virtual-paged-preview-interaction.ts';
|
|
5
6
|
export interface VirtualPagedPreviewProps {
|
|
6
7
|
projection: LayoutProjection | null;
|
|
@@ -25,9 +26,11 @@ export interface VirtualPagedPreviewProps {
|
|
|
25
26
|
initialViewportAnchor?: PageViewportAnchor | null;
|
|
26
27
|
viewportRequestKey?: string | number | null;
|
|
27
28
|
pinnedPageNumbers?: readonly number[];
|
|
29
|
+
/** Theme preset id, theme object, or token patch applied to this preview. */
|
|
30
|
+
theme?: BegoniaThemeInput;
|
|
28
31
|
emptyLabel?: string;
|
|
29
32
|
onViewportChange?: (state: PageViewportMetrics) => void;
|
|
30
33
|
renderPageOverlay?: (frame: VirtualPageFrame, scale: number) => ReactNode;
|
|
31
34
|
onProjectionPositionHit?: (event: VirtualPagedPreviewPositionHitEvent) => boolean | void;
|
|
32
35
|
}
|
|
33
|
-
export declare function VirtualPagedPreview({ projection, version, measureText, measurementEpoch, height, width, scrollHost, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, emptyLabel, onViewportChange, renderPageOverlay, onProjectionPositionHit, }: VirtualPagedPreviewProps): import("react").JSX.Element;
|
|
36
|
+
export declare function VirtualPagedPreview({ projection, version, measureText, measurementEpoch, height, width, scrollHost, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, theme, emptyLabel, onViewportChange, renderPageOverlay, onProjectionPositionHit, }: VirtualPagedPreviewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
3
|
+
export interface BegoniaThemeRootProps {
|
|
4
|
+
style: CSSProperties;
|
|
5
|
+
'data-begonia-theme'?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Root props for a themed component: the theme's `--ald-*` custom properties
|
|
9
|
+
* plus a `data-begonia-theme` marker. Without a `theme`, the base style is
|
|
10
|
+
* returned untouched so variables applied by a host keep working.
|
|
11
|
+
*/
|
|
12
|
+
export declare function begoniaThemeRootProps(theme: BegoniaThemeInput | null | undefined, baseStyle?: CSSProperties): BegoniaThemeRootProps;
|
package/dist/binding/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { PaginatedLayoutView } from './PaginatedLayoutView.tsx';
|
|
|
4
4
|
export type { PaginatedLayoutViewProps } from './PaginatedLayoutView.tsx';
|
|
5
5
|
export { VirtualPagedPreview } from './VirtualPagedPreview.tsx';
|
|
6
6
|
export type { VirtualPagedPreviewProps } from './VirtualPagedPreview.tsx';
|
|
7
|
+
export { begoniaThemeRootProps } from './begonia-theme-style.ts';
|
|
8
|
+
export type { BegoniaThemeRootProps } from './begonia-theme-style.ts';
|
|
7
9
|
export { useBrowserEditorUi } from './use-browser-editor-ui.ts';
|
|
8
10
|
export type { BrowserEditorHostRef, UseBrowserEditorUiOptions, UseBrowserEditorUiResult, } from './use-browser-editor-ui.ts';
|
|
9
11
|
export { useEditorUiController } from './use-editor-ui-controller.ts';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/** Vertical gap between page frames (matches superdoc's paginated layout). */
|
|
2
|
+
export declare const DEFAULT_VIRTUAL_PAGED_PREVIEW_PAGE_GAP = 24;
|
|
2
3
|
export declare function resolveVirtualPagedPreviewPageGap(value: number | null | undefined): number;
|
|
@@ -17,10 +17,10 @@ declare function baseBlockStyle(block: PageBlockPlacement, scale: number, conten
|
|
|
17
17
|
paddingBottom: number;
|
|
18
18
|
fontSize: number;
|
|
19
19
|
lineHeight: string;
|
|
20
|
-
fontFamily: "\"Times New Roman\", serif";
|
|
20
|
+
fontFamily: "var(--ald-font-doc, \"Times New Roman\", serif)";
|
|
21
21
|
whiteSpace: 'pre-wrap';
|
|
22
22
|
wordBreak: 'break-word';
|
|
23
|
-
color: "#
|
|
23
|
+
color: "var(--ald-doc-heading, #2f2417)" | "var(--ald-doc-text, #1f2937)";
|
|
24
24
|
fontWeight: number;
|
|
25
25
|
textAlign: import("csstype").Property.TextAlign | undefined;
|
|
26
26
|
direction: import("csstype").Property.Direction | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSyncExternalStore as En}from"react";import{useEffect as yr,useRef as Et}from"react";import{begoniaThemeVars as br,resolveBegoniaTheme as wr}from"@datalking/begonia-browser-sdk";function de(e,t){if(e==null)return{style:t??{}};let r=wr(e);return{style:{...t,...br(r)},"data-begonia-theme":r.id}}import{useCallback as xr,useRef as Ct,useSyncExternalStore as Pr}from"react";function Oe(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 s=0;s<e.length;s+=1)if(!Oe(e[s],t[s]))return!1;return!0}if(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype)return!1;let r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;let n=e,i=t;for(let s of r)if(!Object.prototype.hasOwnProperty.call(i,s)||!Oe(n[s],i[s]))return!1;return!0}function hr(e,t){let r=Ct(0),a=xr(n=>{if(!e)return()=>{};let i=!0,s=e.subscribe(p=>{if(i){t.current.controller===e&&t.current.token===r.current&&!Oe(t.current.snapshot,p)&&(r.current+=1,t.current={controller:e,token:r.current,snapshot:p},n());return}r.current+=1,t.current={controller:e,token:r.current,snapshot:p},n()});return i=!1,s},[t,e]);return Pr(a,()=>r.current,()=>r.current)}function N(e){let t=Ct({controller:null,token:-1,snapshot:null}),r=hr(e,t),a=t.current;if(a.controller===e&&a.token===r)return a.snapshot;let n=e?.getSnapshot()??null;return t.current={controller:e,token:r,snapshot:n},n}function He(e,t){let r=N(e);return r==null?null:t(r)}import{jsx as ue,jsxs as Ce}from"react/jsx-runtime";function Sr(e){return typeof e=="number"?`${e}px`:e}function kr(e,t){return{pageNumber:e.pageNumber,width:e.width,height:e.height,rotation:e.rotation,scale:t}}function Vt(e,t){return`${e??"pdf"}:${t}`}function Lt({controller:e,height:t=720,scale:r=1,pageGap:a=24,className:n,style:i,theme:s,emptyLabel:p="No PDF document loaded.",renderPageOverlay:m}){He(e,d=>[d.status,d.pageCount,d.fingerprint,d.error,d.textLayerEnabled,d.outputScale,d.renderVersion,...d.pages.map(v=>`${v.pageNumber}:${v.width}:${v.height}:${v.rotation}`)].join("|"));let u=e.getSnapshot(),c=Et(new Map),l=Et(new Map);yr(()=>{if(u.status!=="ready")return;let d=!1;return(async()=>{for(let y of u.pages){if(d)return;let w=Vt(u.fingerprint,y.pageNumber),f=c.current.get(w);f&&await e.renderPage(y.pageNumber,f,{scale:r,textLayer:l.current.get(w)??null})}})(),()=>{d=!0}},[e,r,u.fingerprint,u.pages,u.renderVersion,u.status]);let o=de(s);return Ce("div",{className:n,"data-begonia-theme":o["data-begonia-theme"],style:{overflow:"auto",height:Sr(t),background:"var(--ald-canvas, linear-gradient(180deg, #dbe4f0 0%, #eef2f7 100%))",borderRadius:"var(--ald-canvas-radius, 18px)",padding:20,...o.style,...i},children:[u.status==="error"?ue("div",{style:{color:"#991b1b",padding:16},children:u.error??"Failed to load PDF."}):null,u.status==="loading"?ue("div",{style:{color:"#334155",padding:16},children:"Loading PDF\u2026"}):null,u.status==="idle"&&u.pages.length===0?ue("div",{style:{color:"#475569",padding:16},children:p}):null,ue("div",{style:{display:"grid",gap:`${a}px`,justifyContent:"center"},children:u.pages.map(d=>{let v=Vt(u.fingerprint,d.pageNumber),y=d.width*r,w=d.height*r;return Ce("section",{"aria-label":`PDF page ${d.pageNumber}`,children:[Ce("div",{style:{color:"var(--ald-text-muted, #334155)",fontSize:12,margin:"0 0 8px 6px"},children:["Page ",d.pageNumber]}),Ce("div",{style:{position:"relative",width:y,height:w,background:"var(--ald-page-bg, #fff)",borderRadius:"var(--ald-page-radius, 14px)",overflow:"hidden",boxShadow:"var(--ald-page-shadow, 0 18px 40px rgba(15, 23, 42, 0.14))"},children:[ue("canvas",{ref:f=>{f?c.current.set(v,f):c.current.delete(v)},style:{display:"block",width:y,height:w}}),ue("div",{ref:f=>{f?l.current.set(v,f):l.current.delete(v)},style:{position:"absolute",inset:0,pointerEvents:u.textLayerEnabled?"auto":"none"}}),m?ue("div",{style:{position:"absolute",inset:0},children:m(kr(d,r))}):null]})]},v)})})]})}import{useEffect as ho,useLayoutEffect as at,useMemo as yo,useRef as it}from"react";import{createPaginatedLayoutPreviewController as So,createDefaultPaginatedLayoutMeasureText as ko}from"@datalking/begonia-layout-renderer";import{useEffect as vo,useRef as q}from"react";import{createDefaultPaginatedLayoutMeasureText as bo,normalizeRenderScale as wo,resolveVirtualPagedPreviewContentLayout as xo}from"@datalking/begonia-layout-renderer";import{DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE as _e,DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX as Rr,WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX as Fe,resolvePaginatedLayoutViewOptions as Tr,resolveVirtualPagedPreviewVirtualization as Kn}from"@datalking/begonia-layout-renderer";function Bt(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):24}import{resolvePaginatedPreviewFlowMode as je,resolveRequestedPaginatedLayoutFlowMode as Cr}from"@datalking/begonia-layout-renderer";import{useEffect as It,useLayoutEffect as Nt,useRef as Mt}from"react";import{createVirtualPagedPreviewController as Er,resolveVirtualPagedPreviewObservedScrollHost as Vr}from"@datalking/begonia-layout-renderer";function Lr(e,t){return Vr(e,t)}function At(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 Dt({projection:e,version:t=null,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w}){let f=Mt(null),x=Mt(null);(!x.current||x.current.isDestroyed?.()===!0)&&(x.current=Er(At({projection:e,version:t,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w})));let b=x.current,R=N(b)??b.getSnapshot();return Nt(()=>{b.setInput(At({projection:e,version:t,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w}))},[b,e,t,r,a,n,i,s,p,m,u,c,l,o,d,v]),Nt(()=>{let g=b.bindViewport({getExplicitScrollHost:()=>y,getPreviewHost:()=>f.current});return()=>{g.cleanup()}},[b,y]),It(()=>w?b.subscribeViewport(w):()=>{},[b,w]),It(()=>()=>{b.destroy()},[b]),{hostRef:f,resolveObservedScrollHost(){return b.resolveObservedScrollHost()??Lr(y,f.current)},deferredProjection:R.deferredProjection,renderState:R.renderState}}import{drawingFragmentOffsetY as oo,drawingFragmentVisibleHeight as no,resolveRenderableTableRows as ao}from"@datalking/begonia-layout-contracts";import{listProjectionPageBlocks as io,resolvePageColumnSeparatorSegments as lo,resolvePaginatedPageContentLeftOrigin as so}from"@datalking/begonia-page-layout";import{drawingSceneTransform as Br}from"@datalking/begonia-layout-contracts";import{jsx as ce,jsxs as Ht}from"react/jsx-runtime";function Ir(e,t){return(t??e.label??"Shape").trim()||"Shape"}function Nr(e){return e.fill??e.fillColor??"none"}function Mr(e){return e==="butt"||e==="round"||e==="square"||e==="inherit"?e:void 0}function Ar(e){return e==="miter"||e==="round"||e==="bevel"||e==="inherit"?e:void 0}function Dr(e,t){let r={fill:Nr(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:Mr(e.strokeLinecap),strokeLinejoin:Ar(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"?ce("rect",{...r,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"?ce("ellipse",{...r,cx:e.cx??0,cy:e.cy??0,rx:e.rx??0,ry:e.ry??0},t):ce("path",{...r,d:e.d??""},t)}function Or(e,t){return ce("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((r,a)=>ce("tspan",{x:e.centerX,y:e.startY+a*e.lineHeight,children:r},`${t}-${a}`))},t)}function Ot(e,t){let r=Br(e);return Ht("g",{transform:r||void 0,opacity:e.opacity??void 0,style:e.filter?{filter:e.filter}:void 0,children:[e.primitives.map((a,n)=>Dr(a,`${t}-primitive-${n}`)),e.children.map((a,n)=>Ot(a,`${t}-child-${n}`)),e.text?Or(e.text,`${t}-text`):null]},t)}function Ee({drawing:e,width:t,height:r,className:a,style:n,label:i}){let s=Math.max(1,Number(t??e.width??1)),p=Math.max(1,Number(r??e.height??1)),m=Ir(e,i);return Ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:p,viewBox:e.viewBox,role:"img","aria-label":m,preserveAspectRatio:"xMidYMid meet",className:a||void 0,style:n,children:[ce("title",{children:m}),e.defs?.trim()?ce("defs",{dangerouslySetInnerHTML:{__html:e.defs}}):null,Ot(e.scene,"drawing-root")]})}import{createVirtualPagedPreviewDragSession as $e,isVirtualPagedPreviewFrameTarget as Ue,VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE as We}from"@datalking/begonia-layout-renderer";import{PREVIEW_TABLE_CELL_HORIZONTAL_PADDING as ze,PREVIEW_TABLE_CELL_VERTICAL_PADDING as Ge}from"@datalking/begonia-layout-renderer";import{inlineRevisionSpanDisplayLayer as Gr,inlineRevisionSpanHasKind as Ze,resolveMeasuredLineSliceVisibleRange as Kr,resolveMeasuredLineSlicePaintSpans as qr,resolveMeasuredLineSlicePaintText as Zr,sliceInlineRevisionSpansByOffsets as Yr}from"@datalking/begonia-layout-contracts";import{createVirtualPagedPreviewInlineNodeAttributes as Xr}from"@datalking/begonia-layout-renderer";function Ve(e){return Number.isFinite(e)&&e>0?e:1}function K(e,t){return e*Ve(t)}function _t(e,t){let r=Ve(t);return{fontSize:typeof e.fontSize=="number"?`${e.fontSize*r}px`:void 0,letterSpacing:typeof e.letterSpacing=="number"?`${e.letterSpacing*r}px`:void 0}}import{jsx as Ke}from"react/jsx-runtime";function Le(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Pe(e,t,r){let a=e?.inlineObject?.kind==="image"?e.inlineObject:null;if(a){let p=Le(a.width),m=Le(a.height);return Ke("img",{className:"ald-inline-image",src:a.src,alt:a.alt??"",title:a.title??void 0,"data-image-id":a.objectId??void 0,width:p==null?void 0:K(p,r),height:m==null?void 0:K(m,r),style:{display:"inline-block",verticalAlign:"baseline",objectFit:"contain"}})}let n=e?.inlineObject?.kind==="drawing"?e.inlineObject:null;if(!n)return t;if(!n.drawing)return n.label||"Drawing";let i=K(Le(n.width)??n.drawing.width,r),s=K(Le(n.height)??n.drawing.height,r);return Ke("span",{className:`ald-inline-drawing ald-inline-${n.family}`,"data-family":n.family,"data-object-id":n.objectId??void 0,style:{display:"inline-block",width:i,height:s,verticalAlign:"baseline",lineHeight:0},children:Ke(Ee,{drawing:n.drawing,width:i,height:s,className:"ald-inline-drawing-svg",style:{display:"block",width:i,height:s}})})}import{resolveMeasuredLineSliceVisibleRange as Ft,resolveMeasuredLineSlicePaintSpans as Hr,resolveMeasuredLineSlicePaintText as _r,resolveTextLineAdvanceHeight as Fr,sliceInlineRevisionSpansByOffsets as jr}from"@datalking/begonia-layout-contracts";import{resolveProjectionLineMeasuredGeometry as $r,resolveTextLineFrame as jt}from"@datalking/begonia-page-layout";import{jsx as qe}from"react/jsx-runtime";function $t(e,t,r){if(!e.inlineSpans||e.inlineSpans.length===0||r<=t)return null;let a=e.lineSlices?.[0]?.fromOffset??0,n=Math.max(0,t-a),i=Math.max(n,r-a);return jr(e.inlineSpans,n,i)}function Ur(e,t,r,a){let n=Ft(a),i=jt(e,t),s=Number.isFinite(a.lineIndex)?a.lineIndex:t,p=Number.isFinite(a.lineCount)?a.lineCount:r;return{pageNumber:0,sectionIndex:0,sectionPageNumber:0,region:"body",blockIndex:0,fragmentIndex:e.fragmentIndex,columnIndex:e.columnIndex,lineIndex:s,lineCount:p,from:e.from+a.fromOffset,to:e.from+a.toOffset,left:0,top:0,width:Math.max(0,i.availableWidth),height:Math.max(1,e.lineHeight),text:n.text,logicalText:n.text,discretionaryHyphen:a.discretionaryHyphen===!0,nodeType:e.type,align:e.align??null,direction:e.direction??null,fontSize:e.fontSize??null,tabs:e.tabs??null,inlineSpans:$t(e,n.fromOffset,n.toOffset),continuesToNext:e.continuesToNext,label:n.text.trim()||e.text}}function Wr(e,t,r,a){let n=i=>i==="tab"||i==="space";return t.map((i,s)=>{let p=a+i.fromOffset,m=a+i.toOffset,u=i.span?e.interactiveInlineNodeSpanProps(i.span,p,m):null,c=i.leader==="dot"?".":i.leader==="hyphen"?"-":i.leader==="underscore"?"_":null,l=c?c.repeat(Math.max(1,Math.floor(i.width/Math.max(1,i.fontSize*.33)))):"\xA0";return qe("span",{style:{...i.span?e.inlineSpanStyle(e.block,i.span,e.scale):{fontWeight:i.bold?700:400,fontStyle:i.italic?"italic":"normal",fontVariantCaps:i.smallCaps?"small-caps":void 0,fontFamily:i.fontFamily??void 0,fontSize:`${K(i.fontSize,e.scale)}px`,letterSpacing:typeof i.letterSpacing=="number"?`${K(i.letterSpacing,e.scale)}px`:void 0},pointerEvents:u?"auto":void 0,display:n(i.kind)?"inline-block":void 0,width:n(i.kind)?K(i.width,e.scale):void 0,minWidth:n(i.kind)?K(i.width,e.scale):void 0,whiteSpace:i.kind==="tab"?"nowrap":i.kind==="space"?"pre":void 0,overflow:i.kind==="tab"?"hidden":void 0},...u??{},children:i.kind==="tab"?l:Pe(i.span,i.text,e.scale)},`${r}-${s}`)})}function zr(e,t,r,a){let n=r;return t.map((i,s)=>{let p=n;n+=i.text.length;let m=n,u=e.interactiveInlineNodeSpanProps(i,p,m);return qe("span",{style:{...e.inlineSpanStyle(e.block,i,e.scale),pointerEvents:u?"auto":void 0},...u??{},children:Pe(i,i.text,e.scale)},`${a}-${s}`)})}function Ut(e){let t=e.block.lineSlices??null;return!t||t.length===0?null:t.map((r,a)=>{let n=Ft(r),i=_r(r),s=jt(e.block,a),p=Fr(s,e.block.lineHeight,e.block.lineSpacingRule),m=s.leftInset*e.scale,u=Hr(r,$t(e.block,n.fromOffset,n.toOffset)??[]),c=n.text.length>0||(u?.length??0)>0,l=(e.block.textOffsetBase??0)+n.fromOffset,o=$r(Ur(e.block,a,t.length,r),e.measureText,e.measurementEpoch),d=o&&o.pieces.length>0?Wr(e,o.pieces,`${e.block.from}-${e.block.fragmentIndex}-line-${a}`,l):u&&u.length>0?zr(e,u,l,`${e.block.from}-${e.block.fragmentIndex}-line-${a}`):c?i:" ";return qe("span",{style:{display:"block",paddingLeft:Math.max(0,m),marginLeft:Math.min(0,m),paddingRight:s.rightInset*e.scale,minHeight:Math.max(1,p*e.scale),whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:d},`${e.block.from}-${e.block.fragmentIndex}-line-${a}`)})}import{jsx as et}from"react/jsx-runtime";function Xe(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 Jr(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 Qr(e){return e.direction==="ltr"||e.direction==="rtl"?e.direction:void 0}function eo(e){return e==="insert"?{background:"var(--ald-revision-insert-bg, rgba(15, 118, 110, 0.12))",textDecoration:"underline",textDecorationColor:"var(--ald-revision-insert-text, #0f766e)"}:e==="delete"?{background:"var(--ald-revision-delete-bg, rgba(185, 28, 28, 0.09))",textDecoration:"line-through",textDecorationColor:"var(--ald-revision-delete-text, #b91c1c)"}:e==="format"?{background:"var(--ald-revision-format-bg, rgba(217, 119, 6, 0.1))",textDecoration:"underline",textDecorationColor:"var(--ald-revision-format-text, #92400e)"}:null}function to(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))].join(" ")}function Wt(e,t,r=1){let a=Ve(r),n=Gr(t),i=eo(n?.revisionKind??t.revisionKind??null)??{},s=typeof i=="object"&&i&&"textDecoration"in i?String(i.textDecoration):void 0,p=typeof i=="object"&&i&&"textDecorationColor"in i?String(i.textDecorationColor):void 0,m=Ze(t,"insert"),u=Ze(t,"delete"),c=Ze(t,"format"),l=t.smallCaps?"small-caps":void 0,o=t.textTransform&&t.textTransform!=="none"?t.textTransform:void 0,d=n?.revisionKind==="format"?"dotted":void 0;return{...i,fontWeight:t.bold||e.type==="heading"?700:400,fontStyle:t.italic?"italic":"normal",fontVariantCaps:l,textTransform:o,textDecoration:to([s,m||c?"underline":null,u?"line-through":null,t.underline?"underline":null,t.strike?"line-through":null,t.href?"underline":null]),textDecorationThickness:t.underline||t.href||m||c?"2px":void 0,textDecorationStyle:d,textDecorationColor:p??(t.href?"var(--ald-link, #155e75)":void 0),color:t.color??(t.href?"var(--ald-link, #155e75)":void 0),backgroundColor:t.highlight??void 0,fontFamily:t.fontFamily??void 0,..._t(t,a)}}function zt(e,t,r,a=null){let n=typeof e.sourceNodeType=="string"&&e.sourceNodeType.length>0?e.sourceNodeType:null;return!(n!=null&&e.sourceNodeSelectable===!0)||r<=t?null:Xr({nodeType:n,objectId:e.sourceObjectId??null,fromOffset:t,toOffset:r,tableOriginRow:a?.originRow??null,tableOriginColumn:a?.originColumn??null})}function Gt(e,t,r,a){let n=Ut({block:e,scale:t,measureText:r,measurementEpoch:a,inlineSpanStyle:Wt,interactiveInlineNodeSpanProps:zt});return n||(!e.inlineSpans||e.inlineSpans.length===0?e.renderedText:Ye(e,e.inlineSpans,`${e.from}-${e.to}`,e.textOffsetBase??0,null,t))}function ro(e,t,r){return Yr(e,t,r)}function Ye(e,t,r,a=0,n=null,i=1){if(!t||t.length===0)return null;let s=a;return t.map((p,m)=>{let u=s;s+=p.text.length;let l=zt(p,u,s,n);return et("span",{style:{...Wt(e,p,i),pointerEvents:l?"auto":void 0},...l??{},children:Pe(p,p.text,i)},`${r}-${m}`)})}function Kt(e,t,r,a){let{layout:n,text:i}=t,s=n?.lineSlices??null;if(s&&s.length>0)return s.map((m,u)=>{let c=Kr(m),l=Zr(m),o=qr(m,ro(n?.inlineSpans??null,c.fromOffset,c.toOffset)??[]);return et("span",{style:{display:"block"},children:o&&o.length>0?Ye(e,o,`${r}-line-${u}`,c.fromOffset,t,a):l||" "},`${r}-line-${u}`)});let p=Ye(e,n?.inlineSpans??null,r,0,t,a);return p||(n?.text??i)}function qt(e){let t=Array.isArray(e.tableColumnWidths)?e.tableColumnWidths:null;if(!t||t.length===0)return null;let r=t.reduce((a,n)=>a+Math.max(0,Number(n??0)),0);return r<=0?null:t.map((a,n)=>et("col",{style:{width:`${Math.max(0,Number(a??0))/r*100}%`}},`${e.from}-col-${n}`))}function Je(e,t,r){return(e-t)*r}function Qe(e,t,r){return(t+e)*r}function he(e,t,r=0,a=0){let n=!!(e.lineSlices&&e.lineSlices.length>0);return{position:"absolute",top:Je(e.top,r,t),left:Qe(e.left,a,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??Xe(e))*t,lineHeight:`${e.lineHeight*t}px`,fontFamily:'var(--ald-font-doc, "Times New Roman", serif)',whiteSpace:"pre-wrap",wordBreak:"break-word",color:e.type==="heading"?"var(--ald-doc-heading, #2f2417)":"var(--ald-doc-text, #1f2937)",fontWeight:e.type==="heading"?700:400,textAlign:Jr(e),direction:Qr(e),pointerEvents:"none",overflow:"hidden",paddingLeft:n?0:void 0,paddingRight:n?0:void 0}}import{jsx as L,jsxs as tt}from"react/jsx-runtime";function uo({block:e,scale:t,contentTop:r,contentLeft:a}){let n=he(e,t,r,a);return L("div",{style:n,children:e.assetSrc?L("img",{src:e.assetSrc,alt:"",style:{width:"100%",height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),objectFit:"contain",borderRadius:12,border:"var(--ald-image-border, 1px solid rgba(92, 70, 43, 0.14))",background:"#fff"}}):L("div",{style:{height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),borderRadius:12,border:"var(--ald-image-placeholder-border, 1px dashed rgba(92, 70, 43, 0.24))",background:"var(--ald-image-placeholder-bg, rgba(245, 158, 11, 0.08))",display:"grid",placeItems:"center",color:"var(--ald-image-placeholder-text, #8a5b12)",fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase"},children:"Image"})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function co({block:e,scale:t,contentTop:r,contentLeft:a}){let n=he(e,t,r,a),i=Math.max(0,Math.min(Number(e.tableHeaderRowCount??0),e.tableRows?.length??0)),s=qt(e),p=Ge*t,m=ze*t,u=ao(e);return L("div",{style:n,children:tt("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:Math.max(9,Xe(e)*t),background:"#fff"},children:[s?L("colgroup",{children:s}):null,L("tbody",{children:u.map(c=>L("tr",{children:c.cells.map(l=>{let o=c.fragmentRowIndex<i?"th":"td";return L(o,{colSpan:l.colSpan>1?l.colSpan:void 0,rowSpan:l.rowSpanInFragment>1?l.rowSpanInFragment:void 0,style:{border:"var(--ald-table-border, 1px solid rgba(92, 70, 43, 0.18))",padding:`${p}px ${m}px`,verticalAlign:"top",fontWeight:c.fragmentRowIndex<i?700:void 0,textAlign:"left",background:c.fragmentRowIndex<i?"var(--ald-table-header-bg, rgba(226, 232, 240, 0.65))":void 0},children:Kt(e,l,`${e.from}-${c.fragmentRowIndex}-${l.physicalIndex}`,t)},`${e.from}-${c.fragmentRowIndex}-${l.physicalIndex}-${l.originColumn}`)})},`${e.from}-${c.fragmentRowIndex}-${c.sourceRowIndex}`))})]})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function po({block:e,scale:t,contentTop:r,contentLeft:a}){let n=Math.max(24,Number(e.drawing?.width??e.drawing?.intrinsicWidth??e.width??0))*t,i=Math.max(24,Number(e.drawing?.height??e.drawing?.intrinsicHeight??e.estimatedHeight??0))*t,s=oo(e)*t,p=Math.max(1,no(e)*t||i),m=s>0||p<i,u={...he(e,t,r,a),minHeight:p},c=e.drawing?.scene&&e.drawing.viewBox?L(Ee,{drawing:e.drawing,width:n,height:i,className:"ald-drawing-scene-svg",style:{display:"block",width:"100%",height:"100%"}}):L("div",{style:{width:"100%",height:"100%"},dangerouslySetInnerHTML:{__html:e.drawing?.svg??""}});return L("div",{style:u,children:e.drawing?L("div",{style:{width:n,height:p,maxWidth:"100%",overflow:m?"hidden":void 0},children:L("div",{style:{width:n,height:i,transform:m?`translateY(-${s}px)`:void 0,transformOrigin:m?"top left":void 0},children:c})}):L("div",{style:{width:n,height:i,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 mo({block:e,scale:t,contentTop:r,contentLeft:a,measureText:n,measurementEpoch:i}){return e.drawing?L(po,{block:e,scale:t,contentTop:r,contentLeft:a}):e.type==="image"?L(uo,{block:e,scale:t,contentTop:r,contentLeft:a}):e.type==="table"&&e.tableRows?L(co,{block:e,scale:t,contentTop:r,contentLeft:a}):L("div",{style:he(e,t,r,a),children:Gt(e,t,n,i)},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function fo({page:e,scale:t,contentTop:r,contentLeft:a}){return lo(e).map(n=>L("div",{"data-ald-column-separator":"true",style:{position:"absolute",top:Je(n.top,r,t),left:Qe(n.left,a,t),height:Math.max(1,n.height*t),width:1,background:"var(--ald-column-separator, rgba(31, 41, 55, 0.7))",pointerEvents:"none"}},`separator-${n.regionIndex}-${n.separatorIndex}-${n.top}`))}function Be({frame:e,scale:t,measureText:r,measurementEpoch:a,offsetTop:n=0,offsetLeft:i=0,flowMode:s="paginated",renderPageOverlay:p,onProjectionPositionHit:m}){let u=e.page,c=s==="web"?e.contentTop:0,l=s==="web"?-e.contentLeft:so(u),o=io(u);return tt("article",{[We]:"true",style:{position:"absolute",top:e.top-n,left:e.left-i,width:e.width,height:e.height,boxSizing:"border-box",background:s==="web"?"transparent":"var(--ald-page-bg, #fffdfa)",border:s==="web"?"none":"var(--ald-page-border, 1px solid rgba(92, 70, 43, 0.14))",borderRadius:s==="web"?0:"var(--ald-page-radius, 20px)",boxShadow:s==="web"?"none":"var(--ald-page-shadow, 0 18px 40px rgba(69, 47, 16, 0.12))",overflow:"hidden",cursor:m?"text":void 0},children:[s==="paginated"?tt("div",{style:{display:"var(--ald-page-label-display, block)",position:"absolute",top:10,right:14,fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--ald-page-label-color, #8a5b12)"},children:["Page ",u.pageNumber]}):null,L(fo,{page:u,scale:t,contentTop:c,contentLeft:l}),o.map(d=>L(mo,{block:d,scale:t,contentTop:c,contentLeft:l,measureText:r,measurementEpoch:a},`${d.from}-${d.to}-${d.fragmentIndex}-${d.top}`)),p?L("div",{style:{position:"absolute",inset:0},children:p(e,t)}):null]})}import{bindVirtualPagedPreviewWindowDragListeners as rt}from"@datalking/begonia-layout-renderer";import{Fragment as Po,jsx as $,jsxs as ot}from"react/jsx-runtime";function nt({projection:e,version:t=null,measureText:r,measurementEpoch:a,height:n=720,width:i,scrollHost:s=null,scale:p=_e,pageGap:m=24,windowPages:u=5,overscan:c=2,virtualize:l=!0,layoutMode:o="vertical",flowMode:d,anchorPageNumber:v=null,initialViewportAnchor:y=null,viewportRequestKey:w=null,pinnedPageNumbers:f,theme:x,emptyLabel:b="No paginated preview available yet.",onViewportChange:R,renderPageOverlay:g,onProjectionPositionHit:E}){let k=wo(p),B=q(null);B.current===null&&(B.current=bo());let H=r??B.current??void 0,I=je(e,d),{hostRef:Q,resolveObservedScrollHost:oe,deferredProjection:z,renderState:M}=Dt({projection:e,version:t,height:n,width:i,scale:k,pageGap:m,windowPages:u,overscan:c,virtualize:l,layoutMode:o,flowMode:I,anchorPageNumber:v,initialViewportAnchor:y,viewportRequestKey:w,pinnedPageNumbers:f,scrollHost:s,onViewportChange:R}),G=q(null),le=q(H),Re=q(a),ve=q([]),be=q(k),S=q(I),ee=q(E),we=q(null),Te=q($e({getProjection:()=>G.current,getMountedFrames:()=>ve.current,getMeasureText:()=>le.current,getMeasurementEpoch:()=>Re.current,getScale:()=>be.current,getFlowMode:()=>S.current,getPaginatedHorizontalOrigin:()=>"frame",getInteractionRoot:()=>Q.current,getScrollHost:()=>oe(),dispatchPositionHit(h){return ee.current?.(h)}}));G.current=z,le.current=H,Re.current=a,ve.current=M.window.mountedFrames,be.current=k,S.current=I,ee.current=E,vo(()=>{let h=Te.current;return()=>{let j=we.current;we.current=null,j?.(),h.destroy()}},[]);let me=xo({renderState:M,flowMode:I}),cr=me.useSpacerWindow,se=me.spacerWindowLayout,pr=se.mountedWindowLayout,mr={height:s?void 0:n,width:s?void 0:i,overflow:s?"visible":"auto",borderRadius:"var(--ald-canvas-radius, 18px)",background:I==="web"?"var(--ald-web-canvas, linear-gradient(180deg, rgba(247, 248, 250, 0.92), rgba(241, 245, 249, 0.88)))":"var(--ald-canvas, linear-gradient(180deg, rgba(242, 236, 225, 0.92), rgba(235, 227, 214, 0.86)))",border:I==="web"?"var(--ald-web-canvas-border, 1px solid rgba(148, 163, 184, 0.18))":"var(--ald-canvas-border, 1px solid rgba(92, 70, 43, 0.12))"},fr={width:me.contentWidth,margin:"0 auto",padding:I==="web"?`20px ${Fe}px 28px`:"20px 0 28px"},gr={position:"relative",width:me.layoutSurfaceWidth>0?me.layoutSurfaceWidth:void 0,minHeight:me.layoutSurfaceHeight,margin:"0 auto"},vr=h=>{if(!E||h.button!==0||!Ue(h.target))return;let j=()=>{let ne=we.current;we.current=null,ne?.()},xe=()=>{Te.current.handleMouseUp(),j()};j();let De=Te.current.handleMouseDown({clientX:h.clientX,clientY:h.clientY,button:h.button,buttons:h.buttons,detail:h.detail,shiftKey:h.shiftKey,target:h.target});if(!De.started){De.handled&&h.preventDefault();return}let Tt=h.currentTarget.ownerDocument.defaultView;Tt&&(we.current=rt({view:Tt,onMouseMove(ne){if((ne.buttons&1)!==1){xe();return}Te.current.handleMouseMove({clientX:ne.clientX,clientY:ne.clientY,buttons:ne.buttons,target:ne.target})&&ne.preventDefault()},onStop(){xe()}}).cleanup),De.handled&&h.preventDefault()};return $("div",{...de(x,mr),children:!z||z.pages.length===0?$("div",{style:{minHeight:n,display:"grid",placeItems:"center",color:"var(--ald-text-muted, #6b5a46)",padding:24},children:b}):$("div",{style:fr,children:$("div",{ref:Q,onMouseDown:E?vr:void 0,style:gr,children:cr?ot(Po,{children:[$("div",{"data-begonia-virtual-spacer":"top",style:{height:se.topSpacerHeight,width:"100%",overflowAnchor:"none"}}),ot("div",{style:{display:"flex",width:"100%",direction:"ltr",overflowAnchor:"none"},children:[$("div",{"data-begonia-virtual-spacer":"left",style:{width:se.leftSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}}),$("div",{style:{position:"relative",height:se.mountedSurfaceHeight,width:se.mountedSurfaceWidth,flex:"0 0 auto"},children:pr.clusters.map(h=>{let j=h.leadingGap;return ot("div",{style:{position:"absolute",top:h.offsetTop,left:h.offsetLeft,width:h.width,height:h.height},children:[j?$("div",{"data-begonia-virtual-spacer":"gap","data-begonia-gap-from":String(j.fromPageIndex),"data-begonia-gap-to":String(j.toPageIndex),style:{position:"absolute",top:j.top,left:j.left,width:j.width,height:j.height,overflowAnchor:"none"}}):null,h.frames.map(xe=>$(Be,{frame:xe,scale:k,measureText:H,measurementEpoch:a,flowMode:I,offsetTop:h.top,offsetLeft:h.left,renderPageOverlay:g,onProjectionPositionHit:E},`page-${xe.page.pageNumber}`))]},`cluster-${h.startIndex}-${h.endIndex}`)})}),$("div",{"data-begonia-virtual-spacer":"right",style:{width:se.rightSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}})]}),$("div",{"data-begonia-virtual-spacer":"bottom",style:{height:se.bottomSpacerHeight,width:"100%",overflowAnchor:"none"}})]}):M.window.mountedFrames.map(h=>$(Be,{frame:h,scale:k,measureText:H,measurementEpoch:a,flowMode:I,renderPageOverlay:g,onProjectionPositionHit:E},`page-${h.page.pageNumber}`))})})})}import{jsx as Zt}from"react/jsx-runtime";function Ro(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 lt({projection:e=null,adapter:t,source:r=null,version:a,options:n,measureText:i,onLayoutChange:s,scrollHost:p,height:m,width:u,scale:c,pageGap:l,windowPages:o,overscan:d,virtualize:v,layoutMode:y,flowMode:w,anchorPageNumber:f,initialViewportAnchor:x,viewportRequestKey:b,pinnedPageNumbers:R,theme:g,emptyLabel:E,onViewportChange:k,onProjectionPositionHit:B}){let H=it(null),I=it(null);I.current===null&&(I.current=ko());let Q=i??I.current??void 0,oe=yo(()=>Ro({projection:e,adapter:t,source:r,version:a,options:n,flowMode:w,scale:c,measureText:Q}),[t,Q,w,n,e,c,r,a]),z=it(null);(!z.current||z.current.isDestroyed?.()===!0)&&(z.current=So(oe));let M=z.current,G=N(M)??M.getSnapshot();return at(()=>{M.setInput(oe)},[M,oe]),at(()=>{let le=M.bindHost({getHost:()=>H.current,getScrollHost:()=>p??null});return()=>{le.cleanup()}},[M,p]),at(()=>{s?.(G.resolvedLayout)},[s,G.resolvedLayout]),ho(()=>()=>{M.destroy()},[M]),Zt("div",{ref:H,style:{width:"100%"},children:Zt(nt,{projection:G.previewProjection,version:a??null,measureText:Q,scrollHost:p,height:m,width:u,scale:c,pageGap:l,windowPages:o,overscan:d,virtualize:v,layoutMode:y,flowMode:G.requestedFlowMode,anchorPageNumber:f,initialViewportAnchor:x,viewportRequestKey:b,pinnedPageNumbers:R,theme:g,emptyLabel:E,onViewportChange:k,onProjectionPositionHit:B})})}import{useEffect as pe,useLayoutEffect as Yt,useMemo as Xt,useReducer as To,useRef as Z}from"react";import{createBrowserEditorMount as Co}from"@datalking/begonia-browser-sdk";var te=Symbol("browser-editor-ui-callback-unset");function st({onEditorChange:e,onHostChange:t,onSnapshotChange:r,...a}){let n=Xt(()=>({backend:a.backend,backendInput:a.backendInput}),[a.backend,a.backendInput]),i=Z(null);i.current||(i.current=Co(n));let s=i.current,p=Z(null),[m,u]=To(k=>k+1,0),c=Xt(()=>({getSnapshot:()=>s.getSnapshot(),subscribe:k=>s.subscribe(k)}),[m,s]),l=N(c)??s.getSnapshot(),o=l.ui,d=l.host,v=l.snapshot,y=Z(e),w=Z(t),f=Z(r),x=Z(te),b=Z(te),R=Z(te),g=Z(null),E=Z(null);if(!E.current){let k=(B=>{g.current!==B&&(g.current=B,s.setHost(B),u())});Object.defineProperty(k,"current",{configurable:!0,enumerable:!0,get(){return g.current},set(B){k(B)}}),E.current=k}return Yt(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[s]),pe(()=>{y.current=e},[e]),pe(()=>{w.current=t},[t]),pe(()=>{f.current=r},[r]),Yt(()=>{s.setInput(n.backendInput)},[s,n]),pe(()=>{if(x.current===o||x.current===te&&o==null){x.current=o;return}x.current=o,y.current?.(o)},[o]),pe(()=>{if(b.current===d||b.current===te&&d==null){b.current=d;return}b.current=d,w.current?.(d)},[d]),pe(()=>{if(R.current===v||R.current===te&&v==null){R.current=v;return}R.current=v,f.current?.(v)},[v]),pe(()=>()=>{let k=setTimeout(()=>{p.current===k&&(p.current=null,x.current!==te&&x.current!==null&&y.current?.(null),b.current!==te&&b.current!==null&&w.current?.(null),R.current!==te&&R.current!==null&&f.current?.(null),x.current=null,b.current=null,R.current=null,s.destroy())},0);p.current=k},[s]),{hostRef:E.current,ui:o,host:d,snapshot:v}}import{createEditorUiController as Lo}from"@datalking/begonia-editor-ui";import{useEffect as Eo,useMemo as Vo}from"react";function Jt(e,t){let r=Vo(e,t);return Eo(()=>()=>{r?.destroy()},[r]),r}function dt(e,t=null){let r=Jt(()=>Lo(e),[e]),a=t??r,n=N(a)??a.getSnapshot();return{controller:a,snapshot:n}}import{resolveVirtualPagedPreviewPositionHit as Bo,resolveVirtualPagedPreviewPositionHitInMountedFrames as Io}from"@datalking/begonia-layout-renderer";import{applyVirtualPagedPreviewAutoscroll as No,createVirtualPagedPreviewAutoscrollController as Mo,resolveVirtualPagedPreviewAutoscrollDelta as Ao}from"@datalking/begonia-layout-renderer";import{resolveVirtualPagedPreviewRenderState as Do}from"@datalking/begonia-layout-renderer";import{cloneVirtualPagedPreviewAnchor as Pi,cloneVirtualPagedPreviewMetrics as Oo,cloneVirtualPagedPreviewSnapshot as hi,normalizeVirtualPagedPreviewPinnedPageIndexes as Ho,normalizeVirtualPagedPreviewRequestKey as _o,resolveVirtualPagedPreviewHostMeasurement as Fo,resolveVirtualPagedPreviewResizeObserver as jo,sameVirtualPagedPreviewAnchor as yi,sameVirtualPagedPreviewMetrics as $o,sameVirtualPagedPreviewSnapshot as Si}from"@datalking/begonia-layout-renderer";import{createVirtualPagedPreviewSessionState as Uo,resolveVirtualPagedPreviewSessionCommit as Wo,resolveVirtualPagedPreviewSessionViewportEmission as zo}from"@datalking/begonia-layout-renderer";import{useEffect as Qt,useLayoutEffect as Go,useMemo as ut,useRef as er}from"react";import{createBrowserPaginatedPreviewController as Ko,resolveBrowserPaginatedPreviewBindingProjection as qo}from"@datalking/begonia-browser-sdk/preview";import{resolveBrowserEditorPreviewBinding as Zo}from"@datalking/begonia-browser-sdk";import{createDefaultPaginatedLayoutMeasureText as Yo}from"@datalking/begonia-layout-renderer";import{jsx as Qo}from"react/jsx-runtime";function Xo(e){return{adapter:e.adapter??null,source:e.source??null,version:e.version??null,options:e.options??null}}function Jo(e){return{editor:e.editor,source:e.source,explicitProjection:e.projection??null,explicitScale:e.scale,pageGap:Bt(e.pageGap),explicitFlowMode:e.flowMode,explicitLayoutMode:e.layoutMode,explicitAnchorPageNumber:e.anchorPageNumber,controllerNavigationMode:e.controllerNavigationMode,syncViewportToEditor:e.syncViewportToEditor,pinnedPageNumbers:e.pinnedPageNumbers,layoutResolutionIdentity:e.layoutResolutionIdentity}}function tr({editor:e,scale:t,flowMode:r,anchorPageNumber:a,controllerNavigationMode:n="consume",syncViewportToEditor:i=!0,onViewportChange:s,onLayoutChange:p,onProjectionPositionHit:m,...u}){let c=ut(()=>Xo(u),[u.adapter,u.options,u.source,u.version]),l=ut(()=>Jo({...u,editor:e,scale:t,flowMode:r,anchorPageNumber:a,controllerNavigationMode:n,syncViewportToEditor:i,layoutResolutionIdentity:c}),[a,n,e,r,c,u.layoutMode,u.pageGap,u.pinnedPageNumbers,u.projection,t,i]),o=er(null);(!o.current||o.current.isDestroyed?.()===!0)&&(o.current=Ko(l));let d=o.current,v=N(d)??d.getSnapshot(),y=u.projection??null,w=ut(()=>Zo(e),[e]),f=er(null);f.current===null&&(f.current=Yo());let x=u.measureText??f.current??void 0;return Go(()=>{d.setInput(l)},[d,l]),Qt(()=>()=>{d.destroy()},[d]),Qt(()=>{if(w?.setResolvedProjection)return w.setResolvedProjection(qo({binding:w,source:u.source,explicitProjection:y,resolvedProjection:v.previewProjection}),{measureText:x,measurementEpoch:u.options?.measurementEpoch}),()=>{w.setResolvedProjection?.(null,null)}},[u.source,y,x,u.options?.measurementEpoch,w,v.previewProjection]),Qo(lt,{...u,projection:y,layoutMode:v.viewModel.layoutMode,flowMode:v.viewModel.flowMode,scale:v.viewModel.scale,anchorPageNumber:v.viewModel.anchorPageNumber,initialViewportAnchor:v.viewModel.initialViewportAnchor,viewportRequestKey:v.viewModel.viewportRequestKey,pinnedPageNumbers:v.pinnedPageNumbers,onLayoutChange:b=>{d.setResolvedProjection(b),p?.(b)},onViewportChange:b=>{d.observeViewport(b,v.viewportResetVersion),s?.(b)},onProjectionPositionHit:b=>{let R=d.resolvePositionHitEvent(b),g=d.handlePositionHit(R),E=m?.(R);return g||E===!0}},v.viewportResetVersion)}import{jsx as tn}from"react/jsx-runtime";function en(...e){return e.filter(Boolean).join(" ")}function T({active:e,mixed:t=!1,disabled:r=!1,label:a,onClick:n,title:i}){return tn("button",{type:"button","aria-pressed":t?"mixed":e,disabled:r,title:i,className:en("inline-flex h-7 min-w-7 items-center justify-center rounded-[var(--ald-control-radius,9999px)] px-2.5 text-xs font-semibold transition disabled:pointer-events-none disabled:opacity-40",t?"bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)] shadow-[inset_0_0_0_1px_var(--ald-accent,#0f766e)]":e?"bg-[var(--ald-toolbar-active-bg,#0f766e)] text-[var(--ald-toolbar-active-text,#ffffff)]":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"),onClick:n,children:a})}import{jsx as fe,jsxs as rn}from"react/jsx-runtime";function Ie(...e){return e.filter(Boolean).join(" ")}function U({children:e,pressed:t=!1,disabled:r=!1,title:a,ariaLabel:n,onClick:i}){return fe("button",{type:"button","aria-pressed":t==="mixed"?"mixed":t,"aria-label":n,title:a,disabled:r,onClick:i,className:Ie("inline-flex h-8 min-w-8 items-center justify-center gap-1 rounded-[var(--ald-control-radius,9999px)] px-2 text-xs font-semibold transition disabled:pointer-events-none disabled:opacity-40",t==="mixed"?"bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)] shadow-[inset_0_0_0_1px_var(--ald-accent,#0f766e)]":t?"bg-[var(--ald-toolbar-active-bg,#0f766e)] text-[var(--ald-toolbar-active-text,#ffffff)]":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"),children:e})}function _(){return fe("span",{"aria-hidden":"true",className:"mx-1 inline-block h-5 w-px shrink-0 self-center bg-[var(--ald-border,#e2e8f0)]"})}function ge({value:e,options:t,disabled:r=!1,title:a,ariaLabel:n,widthClass:i="min-w-0 max-w-40",onChange:s}){let p=t.find(m=>m.value===e);return rn("label",{className:Ie("inline-flex h-8 items-center gap-1.5 rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] px-2 text-xs text-[var(--ald-toolbar-text,#334155)] transition has-[select:disabled]:opacity-40 has-[select:focus-visible]:border-[var(--ald-accent,#0f766e)]",i),children:[p?.swatch?fe("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-[2px] border border-[var(--ald-border,#e2e8f0)]",style:{background:p.swatch}}):null,fe("select",{"aria-label":n,title:a,disabled:r,value:e,onChange:m=>s(m.target.value),className:"w-full cursor-pointer appearance-none truncate bg-transparent text-xs font-medium outline-none",children:t.map(m=>fe("option",{value:m.value,children:m.label},m.value))}),fe("span",{"aria-hidden":"true",className:"pointer-events-none shrink-0 text-[8px] text-[var(--ald-text-muted,#64748b)]",children:"\u25BC"})]})}import{jsx as re,jsxs as on}from"react/jsx-runtime";function ct({controller:e}){let t=N(e);if(!e||!t?.enabled)return null;let r=t.suppressInternalExternal;return on("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[re("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Comments"}),re(T,{active:t.visible,label:"Show",onClick:()=>e.setCommentsVisible(!0)}),re(T,{active:!t.visible,label:"Hide",onClick:()=>e.setCommentsVisible(!1)}),re(T,{active:t.showResolved,label:"Resolved",onClick:()=>e.setCommentsShowResolved(!t.showResolved)}),re(_,{}),re("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Scope"}),re(T,{active:t.visibility==="all",disabled:r,label:"All",onClick:()=>e.setCommentsVisibility("all")}),re(T,{active:t.visibility==="internal",disabled:r,label:"Internal",onClick:()=>e.setCommentsVisibility("internal")}),re(T,{active:t.visibility==="external",label:"External",onClick:()=>e.setCommentsVisibility("external")})]})}import{jsx as A,jsxs as F}from"react/jsx-runtime";function Ne(...e){return e.filter(Boolean).join(" ")}function pt({comments:e,permissionsByCommentId:t,activeCommentId:r=null,canCreateComment:a=!1,createCommentDisabledReason:n=null,onCreateComment:i,onSelectComment:s,onToggleCommentInternal:p,onReplyComment:m,onResolveComment:u,onReopenComment:c}){return F("aside",{className:"grid gap-3","aria-label":"Comments sidebar",children:[F("header",{className:"flex items-center justify-between",children:[F("div",{children:[A("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Comments"}),F("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," thread",e.length===1?"":"s"]})]}),i?A("button",{type:"button",disabled:!a,title:n??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>i(),children:"New Comment"}):null]}),F("div",{className:"grid gap-3",children:[e.length===0?A("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No comment threads."}):null,e.map(l=>{let o=t?.[l.id]??null;return F("section",{className:Ne("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",r===l.id?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[F("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>s?.(l.id),children:[F("div",{className:"flex items-center justify-between gap-3",children:[A("strong",{className:"text-sm text-[var(--ald-text,#0f172a)]",children:l.authorName??l.authorId??"Unknown author"}),F("div",{className:"flex items-center gap-2",children:[A("span",{className:Ne("rounded-full px-2 py-1 text-[11px] font-semibold",l.isInternal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:l.isInternal?"Internal":"External"}),A("span",{className:Ne("rounded-full px-2 py-1 text-[11px] font-semibold",l.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:l.resolved?"Resolved":"Open"})]})]}),A("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:l.text||"Empty comment"}),F("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[l.entries.length," message",l.entries.length===1?"":"s"]})]}),A("div",{className:"grid gap-2",children:l.entries.map(d=>F("article",{className:Ne("rounded-2xl px-3 py-2 text-sm",d.parentId==null?"bg-[var(--ald-surface-muted,#f8fafc)] text-[var(--ald-text,#334155)]":"bg-slate-100/80 text-slate-600"),children:[F("div",{className:"flex items-center justify-between gap-3",children:[A("strong",{className:"text-[11px] uppercase tracking-[0.12em] text-[var(--ald-text-muted,#94a3b8)]",children:d.parentId==null?"Thread":"Reply"}),A("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:d.authorName??d.authorId??"Unknown"})]}),A("p",{children:d.text||"Empty entry"})]},d.id))}),F("div",{className:"flex flex-wrap gap-2",children:[p?A("button",{type:"button",disabled:o?!o.toggleInternal.allowed:!1,title:o?.toggleInternal.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p(l.id,!l.isInternal),children:l.isInternal?"Mark External":"Mark Internal"}):null,A("button",{type:"button",disabled:o?!o.reply.allowed:!1,title:o?.reply.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>m?.(l.id),children:"Reply"}),l.resolved?A("button",{type:"button",disabled:o?!o.reopen.allowed:!1,title:o?.reopen.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>c?.(l.id),children:"Reopen"}):A("button",{type:"button",disabled:o?!o.resolve.allowed:!1,title:o?.resolve.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>u?.(l.id),children:"Resolve"})]})]},l.id)})]})]})}import{Fragment as Me,jsx as P,jsxs as W}from"react/jsx-runtime";var mt=[{value:"",label:"Theme font"},{value:"Aptos",label:"Aptos"},{value:"Calibri",label:"Calibri"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Segoe UI",label:"Segoe UI"},{value:"Times New Roman",label:"Times New Roman"},{value:"Georgia",label:"Georgia"},{value:"Garamond",label:"Garamond"},{value:"Courier New",label:"Courier New"},{value:"Verdana",label:"Verdana"}],nn=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],ft=[{value:"",label:"Automatic",swatch:null},{value:"#000000",label:"Black",swatch:"#000000"},{value:"#404040",label:"Dark gray",swatch:"#404040"},{value:"#c00000",label:"Dark red",swatch:"#c00000"},{value:"#ed7d31",label:"Orange",swatch:"#ed7d31"},{value:"#ffc000",label:"Yellow",swatch:"#ffc000"},{value:"#538135",label:"Green",swatch:"#538135"},{value:"#0070c0",label:"Blue",swatch:"#0070c0"},{value:"#7030a0",label:"Purple",swatch:"#7030a0"}],gt=[{value:"",label:"No highlight",swatch:null},{value:"#ffff00",label:"Yellow",swatch:"#ffff00"},{value:"#00ff00",label:"Bright green",swatch:"#00ff00"},{value:"#00ffff",label:"Turquoise",swatch:"#00ffff"},{value:"#ff00ff",label:"Pink",swatch:"#ff00ff"},{value:"#92d0ff",label:"Blue",swatch:"#92d0ff"},{value:"#ffb3b3",label:"Light red",swatch:"#ffb3b3"}],rr=[{command:"paragraph",label:"Body text"},{command:"heading-1",label:"Heading 1"},{command:"heading-2",label:"Heading 2"},{command:"heading-3",label:"Heading 3"},{command:"bullet-list",label:"Bulleted list"},{command:"numbered-list",label:"Numbered list"}];function an(e){let t=rr.find(r=>e(r.command)?.active===!0);return t?t.command:""}function ln(e){let t=[...nn];return e!=null&&!t.includes(e)&&(t.push(e),t.sort((r,a)=>r-a)),t.map(r=>String(r))}function vt({editorHost:e,controller:t=null,linkActions:r=null,leadingActions:a=null,trailingActions:n=null,showTrackingToggle:i=!0,showSelectionReviewActions:s=!0,showRichFormatControls:p=!0}){let{controller:m,snapshot:u}=dt(e,t);function c(g,E){return m.execute(g,E)}function l(g){return u.commands[g]??null}function o(g,E){if(g==="link-set"||g==="link-clear"){if(!r){if(g==="link-set"){let B=l("link-set"),H=typeof B?.value=="string"?String(B.value):"",I=typeof window<"u"?window.prompt(E??"Enter link URL",H):null;if(!I)return;c(g,{href:I});return}c(g);return}let k=r.captureEffectiveSelectionHandle({includeText:!0});if(!k)return;try{if(g==="link-set"){let B=l("link-set"),H=typeof B?.value=="string"?String(B.value):"",I=typeof window<"u"?window.prompt(E??"Enter link URL",H):null;if(!I)return;r.setLinkFromHandle(k,I);return}r.clearLinkFromHandle(k)}finally{r.releaseSelectionHandle(k)}return}c(g)}let d=u.selection?.formatting??null,v=u.selection==null,y=v?"":an(l),w=mt.some(g=>g.value===d?.fontFamily)?mt:[...mt,...d?.fontFamily?[{value:d.fontFamily,label:d.fontFamily}]:[]],f=d?.fontSize!=null?String(d.fontSize):"",x=ln(d?.fontSize??null),b=d?.color?.toLowerCase()??"",R=d?.highlight?.toLowerCase()??"";return W("div",{className:"grid gap-3",role:"toolbar","aria-label":"Editor formatting toolbar",children:[a?P("div",{className:"flex flex-wrap gap-2",children:a}):null,W("div",{className:Ie("flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5"),children:[P(U,{pressed:!1,disabled:l("undo")?.disabled,title:"Undo (Ctrl+Z)",ariaLabel:"Undo",onClick:()=>o("undo"),children:W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M6.5 3 3 6.5 6.5 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),P("path",{d:"M3 6.5h6a4 4 0 0 1 0 8H6",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}),P(U,{pressed:!1,disabled:l("redo")?.disabled,title:"Redo (Ctrl+Y)",ariaLabel:"Redo",onClick:()=>o("redo"),children:W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M9.5 3 13 6.5 9.5 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),P("path",{d:"M13 6.5H7a4 4 0 0 0 0 8h3",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}),P(_,{}),P(ge,{ariaLabel:"Paragraph style",title:"Paragraph style",value:y,disabled:v,widthClass:"w-32",options:[{value:"",label:"Style"},...rr.map(g=>({value:g.command,label:g.label}))],onChange:g=>{g&&o(g)}}),p?W(Me,{children:[P(ge,{ariaLabel:"Font family",title:"Font family",value:d?.mixed?.fontFamily?"":d?.fontFamily??"",disabled:v,widthClass:"w-36",options:d?.mixed?.fontFamily?[{value:"",label:"Multiple fonts"},...w.slice(1)]:w,onChange:g=>c("font-family",g||null)}),P(ge,{ariaLabel:"Font size",title:"Font size (points)",value:d?.mixed?.fontSize?"":f,disabled:v,widthClass:"w-20",options:d?.mixed?.fontSize?["",...x].map(g=>({value:g,label:g||"Multiple"})):[{value:"",label:"Size"},...x.map(g=>({value:g,label:g}))],onChange:g=>c("font-size",g?Number(g):null)})]}):null,P(_,{}),P(U,{pressed:l("bold")?.mixed?"mixed":l("bold")?.active,disabled:l("bold")?.disabled,title:"Bold (Ctrl+B)",ariaLabel:"Bold",onClick:()=>o("bold"),children:P("span",{className:"font-bold",children:"B"})}),P(U,{pressed:l("italic")?.mixed?"mixed":l("italic")?.active,disabled:l("italic")?.disabled,title:"Italic (Ctrl+I)",ariaLabel:"Italic",onClick:()=>o("italic"),children:P("span",{className:"font-serif italic",children:"I"})}),P(U,{pressed:l("underline")?.mixed?"mixed":l("underline")?.active,disabled:l("underline")?.disabled,title:"Underline (Ctrl+U)",ariaLabel:"Underline",onClick:()=>o("underline"),children:P("span",{className:"underline",children:"U"})}),P(U,{pressed:l("strikethrough")?.mixed?"mixed":l("strikethrough")?.active,disabled:l("strikethrough")?.disabled,title:"Strikethrough",ariaLabel:"Strikethrough",onClick:()=>o("strikethrough"),children:P("span",{className:"line-through",children:"S"})}),p?W(Me,{children:[P(_,{}),P(ge,{ariaLabel:"Text color",title:"Text color",value:d?.mixed?.color?"":b,disabled:v,widthClass:"w-32",options:ft.some(g=>g.value===b)?ft:[{value:b,label:b,swatch:b},...ft],onChange:g=>c("text-color",g?g.toLowerCase():null)}),P(ge,{ariaLabel:"Highlight color",title:"Highlight color",value:d?.mixed?.highlight?"":R,disabled:v,widthClass:"w-36",options:gt.some(g=>g.value===R)?gt:[{value:R,label:R,swatch:R},...gt],onChange:g=>c("highlight-color",g?g.toLowerCase():null)})]}):null,P(_,{}),W(U,{pressed:l("link-set")?.active,disabled:l("link-set")?.disabled,title:"Insert or edit a link",ariaLabel:"Insert link",onClick:()=>o("link-set","Enter a URL or #bookmark target"),children:[W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M6 10a3 3 0 0 1 0-4.2l1.8-1.8a3 3 0 0 1 4.2 4.2l-.9.9",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),P("path",{d:"M10 6a3 3 0 0 1 0 4.2l-1.8 1.8a3 3 0 0 1-4.2-4.2l.9-.9",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),"Link"]}),P(U,{pressed:!1,disabled:l("link-clear")?.disabled,title:"Remove link",ariaLabel:"Remove link",onClick:()=>o("link-clear"),children:"Unlink"}),i?W(Me,{children:[P(_,{}),P(U,{pressed:u.trackingEnabled,title:"Toggle tracked changes",ariaLabel:"Track changes",onClick:()=>o("tracking-toggle"),children:"Tracking"}),s?W(Me,{children:[W(U,{pressed:!1,disabled:l("track-changes-accept-selection")?.disabled,title:"Accept tracked change in selection",ariaLabel:"Accept tracked change in selection",onClick:()=>o("track-changes-accept-selection"),children:[P("span",{className:"text-emerald-600",children:"\u2713"})," Accept"]}),W(U,{pressed:!1,disabled:l("track-changes-reject-selection")?.disabled,title:"Reject tracked change in selection",ariaLabel:"Reject tracked change in selection",onClick:()=>o("track-changes-reject-selection"),children:[P("span",{className:"text-rose-600",children:"\u2715"})," Reject"]})]}):null]}):null]}),n?P("div",{className:"flex flex-wrap gap-2",children:n}):null]})}import{useEffect as sn,useRef as dn}from"react";import{jsx as Ae,jsxs as cn}from"react/jsx-runtime";function un(e){return e==="success"?"text-emerald-700 hover:bg-emerald-50":e==="danger"?"text-rose-700 hover:bg-rose-50":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"}function bt({state:e}){let t=dn(null),r=e.context.host.overlays.closeContextMenu;return sn(()=>{let a=i=>{t.current?.contains(i.target)||r?.()},n=i=>{i.key==="Escape"&&r?.()};return window.addEventListener("mousedown",a),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",n)}},[r]),Ae("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-2 shadow-2xl",style:{left:e.context.position.left,top:e.context.position.top},children:Ae("div",{className:"grid gap-2",children:e.sections.map(a=>cn("section",{className:"grid gap-1 border-b border-[var(--ald-border,#e2e8f0)] pb-2 last:border-b-0 last:pb-0",children:[a.label?Ae("h3",{className:"px-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-[var(--ald-text-muted,#64748b)]",children:a.label}):null,a.items.map(n=>Ae("button",{type:"button",disabled:!n.enabled,title:n.disabledReason??void 0,className:`rounded-2xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-45 ${un(n.tone)}`,onClick:()=>{n.enabled&&(n.action(e.context),r?.())},children:n.label},n.id))]},a.id))})})}import{useEffect as or,useRef as pn}from"react";import{jsx as ae,jsxs as wt}from"react/jsx-runtime";function mn(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 fn(e){typeof navigator>"u"||!navigator.clipboard?.writeText||await navigator.clipboard.writeText(e)}function xt({state:e}){let t=pn(null),r=e.host.activeLink,a=e.host.overlays.closeLinkPopover;return or(()=>{let n=s=>{t.current?.contains(s.target)||a?.()},i=s=>{s.key==="Escape"&&a?.()};return window.addEventListener("mousedown",n),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",i)}},[a]),or(()=>{if(e.resolution.type!=="external"||!t.current)return;let n=e.resolution.render({container:t.current,closePopover:()=>a?.(),controller:r,href:e.href,title:e.title})??{};return()=>{n.destroy?.()}},[a,r,e]),e.resolution.type==="external"?ae("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-3 shadow-2xl",style:{left:e.position.left,top:e.position.top}}):ae("div",{ref:t,className:"fixed z-50 min-w-[260px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-2xl",style:{left:e.position.left,top:e.position.top},children:wt("div",{className:"grid gap-3",children:[wt("div",{className:"grid gap-1",children:[ae("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ald-text-muted,#64748b)]",children:"Link"}),ae("code",{className:"break-all text-sm text-[var(--ald-text,#1e293b)]",children:e.href})]}),wt("div",{className:"flex flex-wrap gap-2",children:[ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>mn(e),children:"Open"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>fn(e.href),children:"Copy"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-sky-200 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700",onClick:()=>{let n=typeof window<"u"?window.prompt("Edit link URL",e.href):null;n&&r.updateActiveLink(n,e.title)},children:"Edit"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.clearActiveLink(),children:"Remove"})]})]})})}import{jsx as Y,jsxs as gn}from"react/jsx-runtime";function Pt({controller:e}){let t=N(e);if(!e||!t)return null;let{documentMode:r,trackChanges:a}=t,n=r==="viewing",i=a.enabled;return gn("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[Y("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Mode"}),Y(T,{active:r==="editing",label:"Edit",onClick:()=>e.setDocumentMode("editing")}),Y(T,{active:r==="suggesting",disabled:!i,label:"Suggest",onClick:()=>e.setDocumentMode("suggesting")}),Y(T,{active:n,label:"View",onClick:()=>e.setDocumentMode("viewing")}),Y(_,{}),Y("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Markup"}),Y(T,{active:a.mode==="review",label:"Review",onClick:()=>e.setTrackChangesDisplayMode("review")}),Y(T,{active:a.mode==="original",disabled:!n,label:"Original",onClick:()=>e.setTrackChangesDisplayMode("original")}),Y(T,{active:a.mode==="final",disabled:!n,label:"Final",onClick:()=>e.setTrackChangesDisplayMode("final")}),Y(T,{active:a.mode==="off",label:"Hide",onClick:()=>e.setTrackChangesDisplayMode("off")})]})}import{resolveBrowserViewIntentPatch as ye,resolveBrowserViewIntentSnapshot as vn,resolveBrowserViewLayoutMode as bn,resolveBrowserViewZoomMode as wn,resolveBrowserZoomStep as ar}from"@datalking/begonia-browser-sdk/editor";function nr(e){return e==="web"?"Sets the paginated layout that will be restored when you switch back to paged view.":void 0}import{jsx as D,jsxs as ir}from"react/jsx-runtime";var Se=Object.freeze([50,75,100,125,150,200]);function ht({controller:e}){let t=N(e);if(!e||!t?.zoom)return null;let r=vn(t),{flowMode:a}=r,n=bn(r),i=nr(a),s=t.zoom.percent,p=t.zoom.mode,m=t.zoom.viewportMetrics?.fitZoom??null;return ir("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"View"}),D(T,{active:a==="web",label:"Web",onClick:()=>e.setViewState(ye(r,{type:"flow",flowMode:"web"}))}),D(T,{active:a==="paginated",label:"Paged",onClick:()=>e.setViewState(ye(r,{type:"flow",flowMode:"paginated"}))}),D(_,{}),D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Layout"}),D(T,{active:n==="vertical",label:"Vertical",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"vertical"}))}),D(T,{active:n==="horizontal",label:"Horizontal",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"horizontal"}))}),D(T,{active:n==="book",label:"Book",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"book"}))}),D(_,{}),D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Zoom"}),D(T,{active:p==="fit-width",label:m==null?"Fit":`Fit ${Math.round(m)}%`,onClick:()=>e.setZoomMode(wn({zoomMode:p})),title:m==null?"Fit to the measured preview width once the paginated preview is ready.":void 0}),D(T,{active:!1,disabled:s<=(Se[0]??s),label:"\u2212",onClick:()=>e.setViewState({zoomPercent:ar(s,Se,-1)})}),ir("span",{className:"min-w-11 text-center text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",children:[Math.round(s),"%"]}),D(T,{active:p==="manual"&&s===100,label:"100%",onClick:()=>e.setViewState({zoomPercent:100})}),D(T,{active:!1,disabled:s>=(Se[Se.length-1]??s),label:"+",onClick:()=>e.setViewState({zoomPercent:ar(s,Se,1)})})]})}import{jsx as X,jsxs as J}from"react/jsx-runtime";function lr(...e){return e.filter(Boolean).join(" ")}function xn(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function sr(e){return!!(e.relatedKinds?.includes("insert")&&e.relatedKinds?.includes("delete"))}function yt({revisions:e,permissionsByRevisionId:t,activeRevisionId:r=null,onAcceptRevision:a,onRejectRevision:n,onRevealRevision:i,onAcceptAll:s,onRejectAll:p}){let m=e.every(c=>t?.[c.id]?.accept.allowed??!0),u=e.every(c=>t?.[c.id]?.reject.allowed??!0);return J("aside",{className:"grid gap-3","aria-label":"Review panel",children:[J("header",{className:"flex items-end justify-between gap-3",children:[J("div",{children:[X("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review"}),J("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," pending revision",e.length===1?"":"s"]})]}),e.length>0?J("div",{className:"flex gap-2",children:[X("button",{type:"button",disabled:!m,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:s,children:"Accept all"}),X("button",{type:"button",disabled:!u,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,children:"Reject all"})]}):null]}),J("div",{className:"grid gap-3",children:[e.length===0?X("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No pending revisions."}):null,e.map(c=>{let l=t?.[c.id],o=r===c.id;return J("section",{className:lr("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",o?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[J("div",{className:"flex items-center justify-between gap-3",children:[X("span",{className:lr("rounded-full px-2 py-1 text-[11px] font-semibold",sr(c)?"bg-amber-100 text-amber-700":c.kind==="insert"?"bg-emerald-100 text-emerald-700":c.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"),children:sr(c)?"Replace":xn(c.kind)}),X("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:c.authorName||c.authorId})]}),X("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:c.text||"Formatting change"}),c.prompt?J("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",c.prompt]}):null,J("div",{className:"flex gap-2",children:[i?X("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>i(c),children:"Reveal"}):null,X("button",{type:"button",disabled:l?!l.accept.allowed:!1,title:l?.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:()=>a?.(c.id),children:"Accept"}),X("button",{type:"button",disabled:l?!l.reject.allowed:!1,title:l?.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:()=>n?.(c.id),children:"Reject"})]})]},c.id)})]})]})}import{jsx as V,jsxs as C}from"react/jsx-runtime";function ie(...e){return e.filter(Boolean).join(" ")}function Pn(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 hn(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function dr(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function yn(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function St(e,t){return e.relatedKinds.includes(t)||e.revision.kind===t}function kt(e){if(!e)return"Unknown time";let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Sn(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 kn(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 Rn(e){return e.deleted?"Deleted":e.resolved?"Resolved":"Open"}function Tn(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 Cn(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 Rt({timeline:e,summary:t=null,activeCommentId:r=null,activeRevisionId:a=null,onSelectComment:n,onReplyComment:i,onResolveComment:s,onReopenComment:p,onAcceptRevision:m,onRejectRevision:u,onRevealRevision:c}){let l=t??{total:e.length,revisions:e.filter(o=>o.kind==="revision").length,insertions:e.filter(o=>o.kind==="revision"&&St(o,"insert")).length,deletions:e.filter(o=>o.kind==="revision"&&St(o,"delete")).length,formatting:e.filter(o=>o.kind==="revision"&&St(o,"format")).length,commentThreads:e.filter(o=>o.kind==="comment-thread").length,openCommentThreads:e.filter(o=>o.kind==="comment-thread"&&!o.resolved&&!o.deleted).length,resolvedCommentThreads:e.filter(o=>o.kind==="comment-thread"&&o.resolved&&!o.deleted).length,deletedCommentThreads:e.filter(o=>o.kind==="comment-thread"&&o.deleted).length,commentReplies:e.filter(o=>o.kind==="comment-reply").length,commentEdits:e.filter(o=>o.kind==="comment-edit").length,commentStatusChanges:e.filter(o=>o.kind==="comment-status").length,commentVisibilityChanges:e.filter(o=>o.kind==="comment-visibility").length,commentRemovals:e.filter(o=>o.kind==="comment-removal").length};return C("aside",{className:"grid gap-3","aria-label":"Review timeline panel",children:[V("header",{className:"grid gap-1",children:C("div",{className:"flex items-end justify-between gap-3",children:[C("div",{children:[V("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review Timeline"}),C("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[l.total," review item",l.total===1?"":"s"]})]}),C("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-[var(--ald-text-muted,#64748b)]",children:[C("span",{children:[l.revisions," revision",l.revisions===1?"":"s"]}),C("span",{children:[l.openCommentThreads," open thread",l.openCommentThreads===1?"":"s"]}),C("span",{children:[l.commentReplies," repl",l.commentReplies===1?"y":"ies"]})]})]})}),C("div",{className:"grid gap-3",children:[e.length===0?V("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No review activity yet."}):null,e.map(o=>{if(o.kind==="revision"){let w=o.permissions,f=a===o.revisionId;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",f?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("div",{className:"flex items-center justify-between gap-3",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",dr(o)?"bg-amber-100 text-amber-700":Pn(o.revision.kind)),children:dr(o)?"Replace":hn(o.revision.kind)}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text||"Formatting change"}),o.excerpt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.excerpt]}):null,o.revision.prompt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",o.revision.prompt]}):null,V("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:kt(o.sortAt)}),C("div",{className:"flex gap-2",children:[c?V("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>c(o),children:"Reveal"}):null,V("button",{type:"button",disabled:w?!w.accept.allowed:!1,title:w?.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:()=>m?.(o.revisionId),children:"Accept"}),V("button",{type:"button",disabled:w?!w.reject.allowed:!1,title:w?.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:()=>u?.(o.revisionId),children:"Reject"})]})]},o.id)}if(o.kind==="revision-decision"){let w=o.decision==="accept",f=yn(o),x=a===o.revisionId,b=f?`${w?"Accepted":"Rejected"} Replace`:o.relatedKinds.includes("format")?`${w?"Accepted":"Rejected"} Format`:`${w?"Accepted":"Rejected"} ${o.revisionKind==="delete"?"Delete":"Insert"}`;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",x?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("div",{className:"flex items-center justify-between gap-3",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",w?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700"),children:b}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text}),o.excerpt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.excerpt]}):null,C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[kt(o.sortAt)," \xB7 ",o.memberCount," member",o.memberCount===1?"":"s"]}),c?V("div",{className:"flex gap-2",children:V("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>c(o),children:"Reveal"})}):null]},o.id)}let d=o.threadPermissions,v=r===o.commentId,y=!o.deleted;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",v?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>n?.(o.commentId),children:[C("div",{className:"flex items-center justify-between gap-3",children:[C("div",{className:"flex items-center gap-2",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",kn(o)),children:Sn(o)}),V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",o.deleted?"bg-rose-100 text-rose-700":o.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:Rn(o)}),V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",o.internal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:o.internal?"Internal":"External"})]}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text||"Empty comment"}),o.target?.text?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.target.text]}):null,C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[kt(o.sortAt)," \xB7 ",Tn(o)," \xB7"," ",Cn(o)]})]}),C("div",{className:"flex flex-wrap gap-2",children:[V("button",{type:"button",disabled:!y||(d?!d.reply.allowed:!1),title:d?.reply.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>i?.(o.commentId),children:"Reply"}),o.deleted?null:o.resolved?V("button",{type:"button",disabled:d?!d.reopen.allowed:!1,title:d?.reopen.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p?.(o.commentId),children:"Reopen"}):V("button",{type:"button",disabled:d?!d.resolve.allowed:!1,title:d?.resolve.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>s?.(o.commentId),children:"Resolve"})]})]},o.id)})]})]})}import{Fragment as Mn,jsx as O,jsxs as ke}from"react/jsx-runtime";function Vn(...e){return e.filter(Boolean).join(" ")}var ur={linkPopover:null,contextMenu:null};function Ln(e){return En(t=>e?.overlayState.subscribe(t)??(()=>{}),()=>e?.overlayState.getSnapshot()??ur,()=>ur)}function Bn(e){return e?e===!0?{enabled:!0,projection:void 0}:{...e,enabled:e.enabled??!0}:null}function In(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 Nn({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:a,paginatedPreview:n,showToolbar:i=!0,showRichFormatControls:s=!0,showViewControls:p=!0,showReviewControls:m=!0,showComments:u=!0,showCommentDisplayControls:c=!0,showReview:l=!0,showReviewTimeline:o=!0,sidebarStart:d=null,theme:v,className:y}){let{hostRef:w,ui:f,snapshot:x}=st({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:a}),b=Ln(f),R=f?.preview.readLayoutAdapter()??null,g=f?.preview.readLayoutSource()??null,E=Bn(n),k=E?.enabled??!1,B=!!d||o||u||l,H=E?.projection??null,{enabled:I,...Q}=E??{},oe=x?.comments.activeCommentId??null,z=S=>{let ee=typeof window<"u"?window.prompt("Reply to comment"):null;!ee||!f||f.comments.reply(S,ee)},M=In(x),G=M==null,le=S=>{f&&f.comments.reveal(S)},Re=()=>{if(!f||!G)return;let S=typeof window<"u"?window.prompt("New comment"):null;if(!S)return;let ee=f.comments.create(S)},ve=S=>{f&&f.trackChanges.reveal(S)},be=de(v,{fontFamily:'var(--ald-font-ui, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif)'});return ke("div",{className:Vn("grid gap-4",y),"data-begonia-theme":be["data-begonia-theme"],style:be.style,children:[i?O(vt,{editorHost:f?.session??null,controller:f,showRichFormatControls:s,trailingActions:ke(Mn,{children:[p?O(ht,{controller:f?.view??null}):null,m?O(Pt,{controller:f?.documentMode??null}):null]})}):null,ke("div",{className:k?B?"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)]":B?"grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]":"grid gap-4",children:[O("div",{className:"rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-[var(--ald-shadow,0_1px_3px_0_rgba(0,0,0,0.1),0_1px_2px_-1px_rgba(0,0,0,0.1))]",children:O("div",{className:"editor-frame",children:O("div",{ref:w,className:"editor-host"})})}),k?O("div",{className:"rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-[var(--ald-shadow,0_1px_3px_0_rgba(0,0,0,0.1),0_1px_2px_-1px_rgba(0,0,0,0.1))]",children:O(tr,{...Q,theme:Q.theme??v,editor:f,adapter:H?void 0:R??void 0,source:g})}):null,B?ke("div",{className:"grid gap-4",children:[d,o?O(Rt,{timeline:x?.review.timeline??[],summary:x?.review.summary??null,activeCommentId:oe,activeRevisionId:x?.review.activeRevisionId??null,onSelectComment:le,onReplyComment:z,onResolveComment:S=>f?.comments.resolve(S),onReopenComment:S=>f?.comments.reopen(S),onAcceptRevision:S=>f?.reviewActions.acceptRevision(S),onRejectRevision:S=>f?.reviewActions.rejectRevision(S),onRevealRevision:ve}):null,u?ke("div",{className:"grid gap-3",children:[c?O(ct,{controller:f?.commentsDisplay??null}):null,O(pt,{comments:x?.comments.items??[],permissionsByCommentId:x?.comments.permissions??{},activeCommentId:oe,canCreateComment:G,createCommentDisabledReason:M,onCreateComment:f?Re:void 0,onSelectComment:le,onToggleCommentInternal:(S,ee)=>f?.comments.setInternal(S,ee),onReplyComment:z,onResolveComment:S=>f?.comments.resolve(S),onReopenComment:S=>f?.comments.reopen(S)})]}):null,l?O(yt,{revisions:x?.review.revisions??[],permissionsByRevisionId:x?.review.permissions??{},activeRevisionId:x?.review.activeRevisionId??null,onAcceptRevision:S=>f?.reviewActions.acceptRevision(S),onRejectRevision:S=>f?.reviewActions.rejectRevision(S),onAcceptAll:()=>f?.reviewActions.acceptAll(),onRejectAll:()=>f?.reviewActions.rejectAll(),onRevealRevision:ve}):null]}):null]}),b.linkPopover?O(xt,{state:b.linkPopover}):null,b.contextMenu?O(bt,{state:b.contextMenu}):null]})}import{createPdfViewerController as fs}from"@datalking/begonia-pdf-viewer";export{de as a,N as b,He as c,Lt as d,_e as e,Rr as f,Fe as g,Tr as h,je as i,Cr as j,$e as k,Ue as l,We as m,ze as n,Ge as o,rt as p,nt as q,lt as r,st as s,Jt as t,dt as u,Bo as v,Io as w,No as x,Mo as y,Ao as z,Do as A,Oo as B,Ho as C,_o as D,Fo as E,jo as F,$o as G,Uo as H,Wo as I,zo as J,tr as K,T as L,ct as M,pt as N,vt as O,bt as P,xt as Q,Pt as R,ht as S,yt as T,Rt as U,Nn as V,fs as W};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Begonia editor surface styles.
|
|
3
|
+
*
|
|
4
|
+
* Base styling for the editable ProseMirror surface (`.ald-editor`), its
|
|
5
|
+
* host frame, and inline revision/collaboration marks. Every color, font,
|
|
6
|
+
* radius, and shadow reads a `--ald-*` theme variable with the original
|
|
7
|
+
* begonia look as the fallback, so the surface is themeable end to end while
|
|
8
|
+
* remaining a visual no-op for hosts that set no variables.
|
|
9
|
+
*
|
|
10
|
+
* Import from the host app:
|
|
11
|
+
* import '@datalking/begonia-react/editor-surface.css';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
.editor-frame {
|
|
15
|
+
min-height: 430px;
|
|
16
|
+
border-radius: var(--ald-radius, 1.75rem);
|
|
17
|
+
border: 1px solid var(--ald-border, rgba(148, 163, 184, 0.24));
|
|
18
|
+
background: var(
|
|
19
|
+
--ald-surface-muted,
|
|
20
|
+
radial-gradient(circle at top, rgba(13, 148, 136, 0.08), transparent 24%),
|
|
21
|
+
linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%)
|
|
22
|
+
);
|
|
23
|
+
padding: 1rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.editor-host {
|
|
27
|
+
min-height: 398px;
|
|
28
|
+
overflow: auto;
|
|
29
|
+
border-radius: var(--ald-page-radius, 1.25rem);
|
|
30
|
+
border: 1px solid var(--ald-border, rgba(148, 163, 184, 0.3));
|
|
31
|
+
background: var(--ald-surface, white);
|
|
32
|
+
box-shadow: var(
|
|
33
|
+
--ald-shadow,
|
|
34
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.85),
|
|
35
|
+
0 16px 36px rgba(15, 23, 42, 0.05)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ald-editor.ProseMirror {
|
|
40
|
+
min-height: 398px;
|
|
41
|
+
padding: 2rem 2.25rem 3rem;
|
|
42
|
+
outline: none;
|
|
43
|
+
color: var(--ald-doc-text, #1e293b);
|
|
44
|
+
font-family: var(
|
|
45
|
+
--ald-font-doc,
|
|
46
|
+
'Iowan Old Style',
|
|
47
|
+
'Source Han Serif SC',
|
|
48
|
+
'Noto Serif CJK SC',
|
|
49
|
+
'Songti SC',
|
|
50
|
+
'STSong',
|
|
51
|
+
'SimSun',
|
|
52
|
+
'Baskerville',
|
|
53
|
+
'Times New Roman',
|
|
54
|
+
serif
|
|
55
|
+
);
|
|
56
|
+
font-size: 18px;
|
|
57
|
+
line-height: 1.72;
|
|
58
|
+
word-break: break-word;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ald-editor.ProseMirror ::selection {
|
|
62
|
+
background: var(--ald-accent-muted, rgba(13, 148, 136, 0.16));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ald-editor p {
|
|
66
|
+
margin: 0 0 1em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ald-editor strong {
|
|
70
|
+
font-weight: 700;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ald-editor em {
|
|
74
|
+
font-style: italic;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ald-editor u {
|
|
78
|
+
text-decoration-thickness: 2px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ald-editor a {
|
|
82
|
+
color: var(--ald-link, #0f766e);
|
|
83
|
+
text-decoration-thickness: 2px;
|
|
84
|
+
text-underline-offset: 2px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ald-editor span[data-ald-text-style] {
|
|
88
|
+
border-radius: 0.12em;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ald-editor ul,
|
|
92
|
+
.ald-editor ol {
|
|
93
|
+
margin: 0 0 1em;
|
|
94
|
+
padding-left: 1.55em;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ald-editor li {
|
|
98
|
+
margin: 0 0 0.35em;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ald-editor h1,
|
|
102
|
+
.ald-editor h2,
|
|
103
|
+
.ald-editor h3,
|
|
104
|
+
.ald-editor h4,
|
|
105
|
+
.ald-editor h5,
|
|
106
|
+
.ald-editor h6 {
|
|
107
|
+
margin: 0 0 0.66em;
|
|
108
|
+
line-height: 1.08;
|
|
109
|
+
letter-spacing: -0.03em;
|
|
110
|
+
color: var(--ald-doc-heading, #020617);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.ald-editor h1 {
|
|
114
|
+
font-size: 2.1em;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.ald-editor h2 {
|
|
118
|
+
font-size: 1.68em;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ald-editor h3 {
|
|
122
|
+
font-size: 1.34em;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.ald-editor .ald-table,
|
|
126
|
+
.ald-editor table {
|
|
127
|
+
width: 100%;
|
|
128
|
+
margin: 0 0 1.2em;
|
|
129
|
+
border-collapse: collapse;
|
|
130
|
+
table-layout: fixed;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.ald-editor td {
|
|
134
|
+
border: var(--ald-table-border, 1px solid rgba(148, 163, 184, 0.35));
|
|
135
|
+
padding: 10px 12px;
|
|
136
|
+
vertical-align: top;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* Explicit page-break marker. The default theme keeps begonia's dashed
|
|
141
|
+
* marker box; a theme like `microsoft-word` swaps it for Word's look —
|
|
142
|
+
* a thin dotted gray rule flanking a small centered label — purely by
|
|
143
|
+
* setting `--ald-page-break-*` variables. Flex layout is a no-op for the
|
|
144
|
+
* default marker (the flanking pseudo-elements are not generated).
|
|
145
|
+
*/
|
|
146
|
+
.ald-editor .ald-page-break,
|
|
147
|
+
.ald-editor [data-ald-page-break] {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 10px;
|
|
151
|
+
margin: 1.5em 0;
|
|
152
|
+
padding: var(--ald-page-break-padding, 10px 12px);
|
|
153
|
+
border-top: var(
|
|
154
|
+
--ald-page-break-rule-top,
|
|
155
|
+
2px dashed rgba(13, 148, 136, 0.4)
|
|
156
|
+
);
|
|
157
|
+
border-bottom: var(
|
|
158
|
+
--ald-page-break-rule-bottom,
|
|
159
|
+
2px dashed rgba(13, 148, 136, 0.18)
|
|
160
|
+
);
|
|
161
|
+
color: var(--ald-page-break-label-color, #0f766e);
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
font-family: var(
|
|
164
|
+
--ald-font-ui,
|
|
165
|
+
'Inter',
|
|
166
|
+
'Segoe UI Variable',
|
|
167
|
+
'Helvetica Neue',
|
|
168
|
+
sans-serif
|
|
169
|
+
);
|
|
170
|
+
font-weight: var(--ald-page-break-label-weight, 700);
|
|
171
|
+
letter-spacing: 0.12em;
|
|
172
|
+
text-transform: var(--ald-page-break-label-transform, uppercase);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.ald-editor .ald-page-break::before,
|
|
176
|
+
.ald-editor .ald-page-break::after,
|
|
177
|
+
.ald-editor [data-ald-page-break]::before,
|
|
178
|
+
.ald-editor [data-ald-page-break]::after {
|
|
179
|
+
content: var(--ald-page-break-flank-content, none);
|
|
180
|
+
flex: 1 1 0;
|
|
181
|
+
border-top: var(--ald-page-break-flank-rule, 1px dotted #a6a6a6);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ald-revision-insert {
|
|
185
|
+
text-decoration: underline;
|
|
186
|
+
text-decoration-thickness: 2px;
|
|
187
|
+
text-decoration-color: var(--ald-revision-insert-text, #0f766e);
|
|
188
|
+
background: var(--ald-revision-insert-bg, rgba(13, 148, 136, 0.12));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.ald-revision-delete {
|
|
192
|
+
text-decoration: line-through;
|
|
193
|
+
text-decoration-thickness: 2px;
|
|
194
|
+
text-decoration-color: var(--ald-revision-delete-text, #be123c);
|
|
195
|
+
background: var(--ald-revision-delete-bg, rgba(244, 63, 94, 0.09));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.ald-cursor {
|
|
199
|
+
position: relative;
|
|
200
|
+
margin-left: -1px;
|
|
201
|
+
margin-right: -1px;
|
|
202
|
+
border-left: 2px solid;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.ald-cursor-label {
|
|
206
|
+
position: absolute;
|
|
207
|
+
top: -1.45em;
|
|
208
|
+
left: -1px;
|
|
209
|
+
padding: 2px 7px;
|
|
210
|
+
border-radius: 999px;
|
|
211
|
+
color: white;
|
|
212
|
+
font-size: 11px;
|
|
213
|
+
font-family: var(
|
|
214
|
+
--ald-font-ui,
|
|
215
|
+
'Inter',
|
|
216
|
+
'Segoe UI Variable',
|
|
217
|
+
'Helvetica Neue',
|
|
218
|
+
sans-serif
|
|
219
|
+
);
|
|
220
|
+
font-weight: 700;
|
|
221
|
+
white-space: nowrap;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@media (max-width: 860px) {
|
|
225
|
+
.editor-frame {
|
|
226
|
+
padding: 0.75rem;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.ald-editor.ProseMirror {
|
|
230
|
+
padding: 1.5rem 1.25rem 2.25rem;
|
|
231
|
+
font-size: 17px;
|
|
232
|
+
}
|
|
233
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,
|
|
1
|
+
import{A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,J as I,M as J,N as K,O as L,P as M,Q as N,R as O,S as P,T as Q,U as R,V as S,W as T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u as t,v as u,w as v,x as w,y as x,z as y}from"./chunk-ORLGCG23.js";export{S as BegoniaBrowserEditor,d as BegoniaPdfViewer,J as BrowserCommentsDisplayControls,M as BrowserContextMenu,N as BrowserLinkPopover,O as BrowserReviewDisplayControls,P as BrowserViewControls,K as CommentsSidebar,e as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,f as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,L as EditorToolbar,n as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,o as PREVIEW_TABLE_CELL_VERTICAL_PADDING,r as PaginatedLayoutView,Q as ReviewPanel,R as ReviewTimelinePanel,m as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,q as VirtualPagedPreview,g as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,w as applyVirtualPagedPreviewAutoscroll,a as begoniaThemeRootProps,p as bindVirtualPagedPreviewWindowDragListeners,A as cloneVirtualPagedPreviewMetrics,T as createPdfViewerController,x as createVirtualPagedPreviewAutoscrollController,k as createVirtualPagedPreviewDragSession,G as createVirtualPagedPreviewSessionState,l as isVirtualPagedPreviewFrameTarget,B as normalizeVirtualPagedPreviewPinnedPageIndexes,C as normalizeVirtualPagedPreviewRequestKey,h as resolvePaginatedLayoutViewOptions,i as resolvePaginatedPreviewFlowMode,j as resolveRequestedPaginatedLayoutFlowMode,y as resolveVirtualPagedPreviewAutoscrollDelta,D as resolveVirtualPagedPreviewHostMeasurement,u as resolveVirtualPagedPreviewPositionHit,v as resolveVirtualPagedPreviewPositionHitInMountedFrames,z as resolveVirtualPagedPreviewRenderState,E as resolveVirtualPagedPreviewResizeObserver,H as resolveVirtualPagedPreviewSessionCommit,I as resolveVirtualPagedPreviewSessionViewportEmission,F as sameVirtualPagedPreviewMetrics,s as useBrowserEditorUi,b as useControllerSnapshot,c as useControllerSnapshotSignal,t as useEditorUiController};
|
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{A as $t,B as Ut,C as jt,D as Ht,E as zt,F as Kt,G as Vt,H as Xt,I as qt,J as Gt,K as ue,L,M as _t,N as Yt,O as Jt,P as Qt,Q as Zt,R as er,S as tr,T as rr,U as or,V as pe,W as ar,a as vt,b as V,c as X,d as le,e as ht,f as wt,g as yt,h as Bt,i as kt,j as Pt,k as Nt,l as St,m as Ct,n as Et,o as At,p as Ot,q as de,r as Rt,s as Mt,t as ce,u as Dt,v as It,w as Tt,x as Ft,y as Wt,z as Lt}from"./chunk-ORLGCG23.js";import{useEffect as oe,useMemo as ae,useState as qe}from"react";import{createBrowserEditorBackendAdapter as Ge,resolveBrowserEditorUiController as _e}from"@datalking/begonia-browser/v1";import{useEffect as We,useMemo as Le}from"react";import{summarizeReviewTimeline as $e}from"@datalking/begonia-document-api/review";import{createBrowserAdvancedOoxmlInspectorController as Ue}from"@datalking/begonia-browser/ooxml";import{emptyBrowserAdvancedOoxmlInspectorSnapshot as je}from"@datalking/begonia-browser/ooxml";import{useState as F}from"react";import{appendEmptyAxisDraft as Oe,appendEmptySeriesDraft as Re,axisDraftsFromModel as Me,legendDraftFromModel as De,mergeChartModelWithDrafts as Ie,seriesDraftsFromModel as Te}from"@datalking/begonia-browser/ooxml";import{jsx as c,jsxs as v}from"react/jsx-runtime";function me({controller:e,selection:t}){let[r,a]=F(t.model.title??""),[i,l]=F(t.model.chartType??""),[o,n]=F(t.model.textBody?.plainText??""),[x,u]=F(Te(t.model)),[g,S]=F(Me(t.model)),[w,y]=F(De(t.model)),f=(s,p)=>u(d=>d.map((k,P)=>P===s?{...k,...p}:k)),h=(s,p)=>S(d=>d.map((k,P)=>P===s?{...k,...p}:k));return v("div",{className:"grid gap-3",children:[v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Title"}),c("input",{value:r,onChange:s=>a(s.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 md:grid-cols-2",children:[v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Type"}),c("input",{value:i,onChange:s=>l(s.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:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Coverage"}),v("div",{className:"flex flex-wrap gap-2",children:[v("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.seriesCount," series"]}),v("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.categoryCount," categories"]})]})]})]}),v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),c("textarea",{value:o,onChange:s=>n(s.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",children:[v("div",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Series"}),c("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>u(s=>Re(s)),children:"Add series"})]}),x.length===0?c("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((s,p)=>v("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[v("div",{className:"grid gap-2 md:grid-cols-3",children:[c("input",{value:s.name,onChange:d=>f(p,{name:d.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"}),c("input",{value:s.id,onChange:d=>f(p,{id:d.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"}),c("input",{value:s.order,onChange:d=>f(p,{order:d.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"})]}),c("input",{value:s.categories,onChange:d=>f(p,{categories:d.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"}),c("input",{value:s.values,onChange:d=>f(p,{values:d.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"}),c("div",{className:"flex justify-end",children:c("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(d=>d.filter((k,P)=>P!==p)),children:"Remove row"})})]},`${t.record.objectId}-${p}`))]}),v("div",{className:"grid gap-2",children:[v("div",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Axes"}),c("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>S(s=>Oe(s)),children:"Add axis"})]}),g.length===0?c("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((s,p)=>v("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[v("div",{className:"grid gap-2 md:grid-cols-2",children:[c("input",{value:s.id,onChange:d=>h(p,{id:d.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"}),c("input",{value:s.title,onChange:d=>h(p,{title:d.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"})]}),v("div",{className:"grid gap-2 md:grid-cols-3",children:[v("select",{value:s.kind,onChange:d=>h(p,{kind:d.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:[c("option",{value:"category",children:"Category"}),c("option",{value:"value",children:"Value"}),c("option",{value:"series",children:"Series"}),c("option",{value:"date",children:"Date"}),c("option",{value:"unknown",children:"Unknown"})]}),v("select",{value:s.orientation,onChange:d=>h(p,{orientation:d.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:[c("option",{value:"unknown",children:"Orientation"}),c("option",{value:"minMax",children:"Min to Max"}),c("option",{value:"maxMin",children:"Max to Min"})]}),c("input",{value:s.formatCode,onChange:d=>h(p,{formatCode:d.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"})]}),c("div",{className:"flex justify-end",children:c("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:()=>S(d=>d.filter((k,P)=>P!==p)),children:"Remove axis"})})]},`${t.record.objectId}-axis-${p}`))]}),v("div",{className:"grid gap-2",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Legend"}),v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("select",{value:w.enabled,onChange:s=>y(p=>({...p,enabled:s.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:[c("option",{value:"true",children:"Enabled"}),c("option",{value:"false",children:"Absent"})]}),v("select",{value:w.visible,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,visible:s.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:[c("option",{value:"true",children:"Visible"}),c("option",{value:"false",children:"Hidden"})]})]}),v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("select",{value:w.position,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,position:s.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:[c("option",{value:"unknown",children:"Position"}),c("option",{value:"left",children:"Left"}),c("option",{value:"right",children:"Right"}),c("option",{value:"top",children:"Top"}),c("option",{value:"bottom",children:"Bottom"}),c("option",{value:"topRight",children:"Top Right"})]}),v("select",{value:w.overlay,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,overlay:s.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:[c("option",{value:"unknown",children:"Overlay"}),c("option",{value:"true",children:"Overlay"}),c("option",{value:"false",children:"No overlay"})]})]})]}),c("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(Ie(t.model,r,i,o,x,{axes:g,legend:w})),children:"Apply chart"})]})}import{useState as be}from"react";import{jsx as R,jsxs as $}from"react/jsx-runtime";function xe({controller:e,selection:t}){let[r,a]=be(t.plainText),[i,l]=be(t.displayMode);return $("div",{className:"grid gap-3",children:[$("div",{className:"grid gap-1",children:[R("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Equation Text"}),R("textarea",{value:r,onChange:o=>a(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"})]}),$("div",{className:"grid gap-1",children:[R("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Display Mode"}),$("select",{value:i,onChange:o=>l(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:[R("option",{value:"inline",children:"Inline"}),R("option",{value:"block",children:"Block"})]})]}),$("div",{className:"grid gap-1",children:[R("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Detected Structures"}),R("div",{className:"flex flex-wrap gap-2",children:t.structures.length===0?R("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=>R("span",{className:"rounded-full bg-sky-100 px-2 py-1 text-[11px] font-semibold text-sky-700",children:o},o))})]}),R("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,i),children:"Apply equation"})]})}import{useState as A}from"react";import{mergeShapeModelWithDrafts as Fe}from"@datalking/begonia-browser/ooxml";import{jsx as m,jsxs as B}from"react/jsx-runtime";function ge({controller:e,selection:t}){let[r,a]=A(t.model.label??""),[i,l]=A(t.model.shapeType??""),[o,n]=A(t.model.textBody?.plainText??""),[x,u]=A(t.model.geometry?.preset??""),[g,S]=A(t.model.fill?.kind??"unknown"),[w,y]=A(t.model.fill?.color??""),[f,h]=A(t.model.stroke?.color??""),[s,p]=A(t.model.stroke?.widthEmu==null?"":String(t.model.stroke.widthEmu)),[d,k]=A(t.model.stroke?.dash??""),[P,D]=A(t.model.transform?.widthEmu==null?"":String(t.model.transform.widthEmu)),[M,E]=A(t.model.transform?.heightEmu==null?"":String(t.model.transform.heightEmu)),[O,Z]=A(t.model.transform?.rotation==null?"":String(t.model.transform.rotation)),[T,ee]=A(t.model.anchor?.kind??"unknown"),[z,te]=A(t.model.anchor?.wrap??"unknown");return B("div",{className:"grid gap-3",children:[B("div",{className:"grid gap-2 md:grid-cols-2",children:[B("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=>a(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"})]}),B("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:i,onChange:b=>l(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"})]})]}),B("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=>n(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"})]}),B("div",{className:"grid gap-2 md:grid-cols-2",children:[B("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"})]}),B("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=>y(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"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Kind"}),B("select",{value:g,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",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"})]})]}),B("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:f,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"})]}),B("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:d,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"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("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:s,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"})]}),B("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:P,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"})]}),B("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:M,onChange:b=>E(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"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("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=>Z(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"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Anchor Kind"}),B("select",{value:T,onChange:b=>ee(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"})]})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Wrap"}),B("select",{value:z,onChange:b=>te(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(Fe(t.model,{label:r,shapeType:i,textBody:o,geometryPreset:x,fillKind:g,fillColor:w,strokeColor:f,strokeWidthEmu:s,strokeDash:d,widthEmu:P,heightEmu:M,rotation:O,anchorKind:T,anchorWrap:z})),children:"Apply shape"})]})}import{jsx as C,jsxs as N}from"react/jsx-runtime";function q(...e){return e.filter(Boolean).join(" ")}function He(e){return`${e.family}:${e.record.objectId}:${JSON.stringify(e.model)}`}function ze(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 Ke(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 Ve(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 Xe(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 re({editor:e,className:t}){let r=Le(()=>e?Ue(e):null,[e]),a=V(r)??je();We(()=>()=>{r?.destroy()},[r]);let i=a.selected,l=i?He(i):null,o=r&&i?r.documentApi.review.timelineByObject(i.record.objectId,{actor:r.actor??void 0,enforceVisibilityPolicy:!0,sort:"desc"}):[],n=$e(o),x=o.slice(0,4);return N("aside",{className:q("grid gap-3",t),"aria-label":"Advanced OOXML inspector",children:[C("header",{className:"grid gap-1",children:N("div",{className:"flex items-center justify-between gap-3",children:[N("div",{children:[C("h2",{className:"text-sm font-semibold text-slate-900",children:"Advanced OOXML"}),C("p",{className:"text-xs text-slate-500",children:"Structured editor for selected math, chart, and shape nodes."})]}),C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",a.trackingEnabled?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"),children:a.trackingEnabled?"Tracking On":"Direct Edit"})]})}),!i||!r?C("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."}):N("section",{className:"grid gap-4 rounded-3xl border border-slate-200 bg-white px-4 py-4 shadow-sm",children:[N("div",{className:"grid gap-2",children:[N("div",{className:"flex items-center justify-between gap-3",children:[N("div",{className:"flex items-center gap-2",children:[C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",ze(i.family)),children:i.family}),C("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-600",children:i.documentMode})]}),C("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"})]}),N("div",{className:"grid gap-1 text-[11px] text-slate-500",children:[N("span",{children:["Object: ",i.record.objectId]}),N("span",{children:["Path: ",i.record.path.join(".")]})]})]}),i.family==="math"?C(xe,{controller:r,selection:i},l??void 0):null,i.family==="chart"?C(me,{controller:r,selection:i},l??void 0):null,i.family==="shape"?C(ge,{controller:r,selection:i},l??void 0):null,C("p",{className:"text-[11px] text-slate-500",children:a.trackingEnabled?"Inspector edits flow through tracked OOXML replacements so accept/reject stays available.":"Inspector edits apply directly to the selected OOXML object."}),N("section",{className:"grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[N("div",{className:"flex items-end justify-between gap-3",children:[N("div",{children:[C("h3",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-600",children:"Object Review"}),N("p",{className:"text-xs text-slate-500",children:[n.total," linked item",n.total===1?"":"s"]})]}),N("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[N("span",{children:[n.revisions," revision",n.revisions===1?"":"s"]}),N("span",{children:[n.commentThreads," thread",n.commentThreads===1?"":"s"]}),N("span",{children:[n.commentReplies," repl",n.commentReplies===1?"y":"ies"]})]})]}),x.length===0?C("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."}):C("div",{className:"grid gap-2",children:x.map(u=>N("div",{className:"grid gap-1 rounded-2xl border border-slate-200 bg-white px-3 py-3",children:[N("div",{className:"flex items-center justify-between gap-3",children:[C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",Ke(u)),children:Ve(u)}),C("span",{className:"text-[11px] text-slate-400",children:u.authorName??u.authorId??"Unknown"})]}),C("p",{className:"text-xs text-slate-700",children:u.text||"Formatting change"}),C("p",{className:"text-[11px] text-slate-500",children:Xe(u)})]},u.id))})]})]})]})}import{jsx as fe}from"react/jsx-runtime";function Ye(e){return _e(e)}function Je({room:e,actor:t,collaborative:r,collaborationSession:a,documentMode:i,enableEmbeddedAdvancedOoxmlEditors:l=!0,features:o,fitWidthOptions:n,flowMode:x,initialContent:u,layoutMode:g,modules:S,onEditorChange:w,onTransaction:y,onUpdate:f,participant:h,permissionResolver:s,onControllerChange:p,onStateChange:d,schema:k,showAdvancedOoxmlInspector:P=!0,trackingEnabled:D=!0,viewSelect:M=!0,zoomMode:E,zoomPercent:O,...Z}){let[T,ee]=qe(null),z=ae(()=>Ge(),[]),te=ae(()=>({room:e,actor:t,collaborative:r,collaborationSession:a,documentMode:i,enableEmbeddedAdvancedOoxmlEditors:l,features:o,fitWidthOptions:n,flowMode:x,initialContent:u,layoutMode:g,modules:S,onTransaction:y,onUpdate:f,participant:h,permissionResolver:s,schema:k,trackingEnabled:D,viewSelect:M,zoomMode:E,zoomPercent:O}),[e,t,r,a,i,l,o,n,x,u,g,S,y,f,h,s,k,D,M,E,O]),b=ae(()=>Ye(T),[T]);return oe(()=>{p?.(b)},[b,p]),oe(()=>{if(d){if(!b){d(null);return}return d(b.getState()),b.subscribe(K=>{d(K)})}},[b,d]),oe(()=>()=>{p?.(null),d?.(null)},[p,d]),fe(pe,{...Z,backend:z,backendInput:te,sidebarStart:P?fe(re,{editor:T}):null,onEditorChange:K=>{ee(K),w?.(K)}})}import{jsx as _,jsxs as Ze}from"react/jsx-runtime";function ne(e,t){return typeof window<"u"?window.prompt(e,t):null}function G(e,t){return e?.commands[t]??null}function Qe({editor:e,snapshot:t}){if(!e||!t||!t.selection)return null;let r=t.selection.formatting,a=!t.editable,i=(y,f)=>{a||e.execute(y,f)},l=G(t,"text-color"),o=G(t,"highlight-color"),n=G(t,"font-size"),x=G(t,"font-family"),u=a?"Document is read-only in the current document mode.":void 0,g=(y,f,h)=>{let s=ne(`${y}. Enter a CSS color value or "none" to clear.`,f??"");if(s==null)return;let p=s.trim(),d=p.length===0||p.toLowerCase()==="none"?null:p;i(h,d)},S=()=>{let y=ne('Set font size in points. Enter "none" to clear.',r.fontSize==null?"":String(r.fontSize));if(y==null)return;let f=y.trim();if(!f||f.toLowerCase()==="none"){i("font-size",null);return}let h=Number(f.replace(/pt$/i,"").trim());Number.isFinite(h)&&h>0&&i("font-size",h)},w=()=>{let y=ne('Set font family. Enter "none" to clear.',r.fontFamily??"");if(y==null)return;let f=y.trim();i("font-family",!f||f.toLowerCase()==="none"?null:f)};return Ze("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:[_(L,{active:l?.active??r.color!=null,mixed:l?.mixed??r.mixed?.color===!0,disabled:a||l?.disabled,label:r.color?`Text ${r.color}`:"Text Color",title:u,onClick:()=>g("Set text color",r.color,"text-color")}),_(L,{active:o?.active??r.highlight!=null,mixed:o?.mixed??r.mixed?.highlight===!0,disabled:a||o?.disabled,label:r.highlight?`Highlight ${r.highlight}`:"Highlight",title:u,onClick:()=>g("Set highlight color",r.highlight,"highlight-color")}),_(L,{active:n?.active??r.fontSize!=null,mixed:n?.mixed??r.mixed?.fontSize===!0,disabled:a||n?.disabled,label:r.fontSize!=null?`Size ${r.fontSize}`:"Font Size",title:u,onClick:S}),_(L,{active:x?.active??r.fontFamily!=null,mixed:x?.mixed??r.mixed?.fontFamily===!0,disabled:a||x?.disabled,label:r.fontFamily?`Font ${r.fontFamily}`:"Font Family",title:u,onClick:w})]})}import{useEffect as U,useRef as se}from"react";import{createDocumentSurface as at}from"@datalking/begonia-engine";import{useRef as et}from"react";var tt=Object.freeze([]);function rt(e){return e?.length?e:tt}function ot(e,t){return e.length===t.length&&e.every((r,a)=>Object.is(r,t[a]))}function Y(e){let t=rt(e),r=et(t);return ot(r.current,t)||(r.current=t),r.current}import{jsx as ve}from"react/jsx-runtime";function he({room:e,collaborative:t,participant:r,schema:a,trackingEnabled:i=!0,editable:l=!0,features:o,onSurfaceReady:n}){let x=se(null),u=se(null),g=se(n),S=Y(o);return U(()=>{g.current=n},[n]),U(()=>{if(!x.current)return;let w=at({element:x.current,participant:r,schema:a,collaborative:t??e,trackingEnabled:i,editable:l,features:S});return u.current=w,g.current?.(w),()=>{u.current=null,g.current?.(null),w.destroy()}},[t,e,a,S]),U(()=>{u.current?.setParticipant(r)},[r.color,r.id,r.name]),U(()=>{u.current?.setTrackingEnabled(i)},[i]),U(()=>{u.current?.setEditable(l)},[l]),ve("div",{className:"editor-frame",children:ve("div",{ref:x,className:"editor-host"})})}import{createBrowserEditorUiFromController as nt}from"@datalking/begonia-browser/v1";import{jsx as st}from"react/jsx-runtime";function we({editor:e,...t}){let r=ce(()=>e?nt(e):null,[e]);return st(ue,{...t,editor:r})}import{useRef as it}from"react";import{jsx as j,jsxs as Be}from"react/jsx-runtime";function J(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 lt(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 dt(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 ct(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 ut(e){return e.points.map((t,r)=>`${r===0?"M":"L"} ${t.x*100} ${t.y*100}`).join(" ")}function pt(e,t){return e.annotations.filter(r=>r.pageNumber===t)}function ye(e,t,r){return e.kind==="stroke"?j("path",{"data-annotation-kind":e.kind,d:ut(e),stroke:e.color,strokeOpacity:e.opacity,strokeWidth:e.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke",onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id):e.kind==="text"?j("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:lt(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)},children:e.text},e.id):e.kind==="highlight"?j("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:ct(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id):j("img",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,alt:e.label,src:e.src,style:dt(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id)}function Q({pageNumber:e,controller:t,snapshot:r}){let a=it(null),i=pt(r,e),l=r.activeStroke?.pageNumber===e?r.activeStroke:null;return Be("div",{style:{position:"absolute",inset:0,pointerEvents:r.enabled?"auto":"none",opacity:r.opacity},onPointerDown:o=>{if(!r.enabled)return;let n=J(o,o.currentTarget);if(r.tool==="draw"){o.currentTarget.setPointerCapture(o.pointerId),t.beginStroke(e,n);return}if(r.tool==="erase"){o.currentTarget.setPointerCapture(o.pointerId),t.eraseAt(e,n);return}if(r.tool==="text"){t.addText(e,n);return}if(r.tool==="highlight"){t.addHighlight(e,n);return}t.selectAnnotation(null)},onPointerMove:o=>{if(!r.enabled)return;let n=J(o,o.currentTarget);if(r.tool==="draw"&&r.activeStroke&&o.buttons===1){t.appendStroke(n);return}if(r.tool==="erase"&&o.buttons===1){t.eraseAt(e,n);return}a.current&&a.current.pageNumber===e&&o.buttons===1&&(t.moveAnnotation(a.current.annotationId,{x:n.x-a.current.lastPoint.x,y:n.y-a.current.lastPoint.y}),a.current={...a.current,lastPoint:n})},onPointerUp:o=>{r.tool==="draw"&&t.commitStroke(),a.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 n=J(o,o.currentTarget),x=o.dataTransfer.getData("application/sticker"),u=o.dataTransfer.getData("application/comment");if(x){t.placeSticker(e,n,x);return}if(u){let g=r.comments.find(S=>S.id===u);g&&t.addText(e,n,g.text)}},children:[Be("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",overflow:"visible"},children:[i.filter(o=>o.kind==="stroke").map(o=>ye(o,o.id===r.selectedAnnotationId,n=>t.selectAnnotation(n.id))),l?j("path",{d:l.points.map((o,n)=>`${n===0?"M":"L"} ${o.x*100} ${o.y*100}`).join(" "),stroke:l.color,strokeOpacity:l.opacity,strokeWidth:l.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}):null]}),i.filter(o=>o.kind!=="stroke").map(o=>ye(o,o.id===r.selectedAnnotationId,(n,x)=>{t.selectAnnotation(n.id);let u=x.currentTarget.parentElement,g=u instanceof HTMLElement?J(x,u):n.kind==="text"||n.kind==="sticker"||n.kind==="highlight"?{x:n.x,y:n.y}:{x:0,y:0};a.current={annotationId:n.id,pageNumber:e,lastPoint:g}}))]})}import{jsx as ke}from"react/jsx-runtime";function Pe({viewer:e,controller:t,...r}){X(t,i=>i.version);let a=t.getSnapshot();return ke(le,{controller:e,...r,renderPageOverlay:i=>ke(Q,{pageNumber:i.pageNumber,controller:t,snapshot:a})})}import{jsx as ie}from"react/jsx-runtime";function Ne({projection:e,controller:t,height:r=720,scrollHost:a=null,scale:i=.52,pageGap:l=28,windowPages:o=5,overscan:n=2,virtualize:x=!0,layoutMode:u="vertical",flowMode:g,anchorPageNumber:S=null,pinnedPageNumbers:w,emptyLabel:y="No paginated preview available yet.",onViewportChange:f,className:h,style:s}){X(t,d=>d.version);let p=t.getSnapshot();return ie("div",{className:h,style:s,children:ie(de,{projection:e,version:p.version,height:r,scrollHost:a,scale:i,pageGap:l,windowPages:o,overscan:n,virtualize:x,layoutMode:u,flowMode:g,anchorPageNumber:S,pinnedPageNumbers:w,emptyLabel:y,onViewportChange:f,renderPageOverlay:d=>ie(Q,{pageNumber:d.page.pageNumber,controller:t,snapshot:p})})})}import{useEffect as H,useLayoutEffect as Se,useMemo as Ce,useReducer as mt,useRef as I}from"react";import{createBrowserEditorMountController as bt}from"@datalking/begonia-browser/v1";var W=Symbol("browser-editor-callback-unset");function xt(e,t){return{...e,features:t}}function Ee({zoomPercent:e,zoomMode:t,fitWidthOptions:r,onControllerChange:a,onStateChange:i,...l}){let o=Y(l.features),n=Ce(()=>xt({...l,zoomPercent:e,zoomMode:t,fitWidthOptions:r},o),[l.actor,l.collaborative,l.collaborationSession,l.documentMode,l.enableEmbeddedAdvancedOoxmlEditors,l.flowMode,r,l.initialContent,l.layoutMode,l.modules,l.onTransaction,l.onUpdate,l.participant,l.permissionResolver,l.room,l.schema,l.surfaceFactory,l.trackingEnabled,l.viewSelect,o,t,e]),x=I(null);x.current||(x.current=bt(n));let u=x.current,g=I(null),[S,w]=mt(E=>E+1,0),y=Ce(()=>({getSnapshot:()=>u.getSnapshot(),subscribe:E=>u.subscribe(E)}),[u,S]),f=V(y)??u.getSnapshot(),h=f.controller,s=f.state,p=I(a),d=I(i),k=I(W),P=I(W),D=I(null),M=I(null);if(!M.current){let E=(O=>{D.current!==O&&(D.current=O,u.setHost(O),w())});Object.defineProperty(E,"current",{configurable:!0,enumerable:!0,get(){return D.current},set(O){E(O)}}),M.current=E}return Se(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[u]),H(()=>{p.current=a},[a]),H(()=>{d.current=i},[i]),Se(()=>{u.setInput(n)},[u,n]),H(()=>{if(k.current===h||k.current===W&&h==null){k.current=h;return}k.current=h,p.current?.(h)},[h]),H(()=>{if(P.current===s||P.current===W&&s==null){P.current=s;return}P.current=s,d.current?.(s)},[s]),H(()=>()=>{let E=setTimeout(()=>{g.current===E&&(g.current=null,k.current!==W&&k.current!==null&&p.current?.(null),P.current!==W&&P.current!==null&&d.current?.(null),k.current=null,P.current=null,u.destroy())},0);g.current=E},[u]),{hostRef:M.current,controller:h,state:s}}import{useSyncExternalStore as gt}from"react";import{readBrowserEditorDocument as ft}from"@datalking/begonia-browser/v1";function Ae(e){return gt(t=>e?.subscribe(t)??(()=>{}),()=>ft(e),()=>null)}export{Je as BegoniaBrowserEditor,le as BegoniaPdfViewer,re as BrowserAdvancedOoxmlInspector,_t as BrowserCommentsDisplayControls,Qt as BrowserContextMenu,Zt as BrowserLinkPopover,we as BrowserPaginatedPreview,er as BrowserReviewDisplayControls,Qe as BrowserRichFormatControls,tr as BrowserViewControls,Pe as BrowserWhiteboardPdfPreview,Ne as BrowserWhiteboardPreview,Yt as CommentsSidebar,ht as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,wt as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,he as DocumentReactMount,Jt as EditorToolbar,Et as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,At as PREVIEW_TABLE_CELL_VERTICAL_PADDING,Rt as PaginatedLayoutView,rr as ReviewPanel,or as ReviewTimelinePanel,Ct as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,de as VirtualPagedPreview,yt as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,Ft as applyVirtualPagedPreviewAutoscroll,vt as begoniaThemeRootProps,Ot as bindVirtualPagedPreviewWindowDragListeners,Ut as cloneVirtualPagedPreviewMetrics,ar as createPdfViewerController,Wt as createVirtualPagedPreviewAutoscrollController,Nt as createVirtualPagedPreviewDragSession,Xt as createVirtualPagedPreviewSessionState,St as isVirtualPagedPreviewFrameTarget,jt as normalizeVirtualPagedPreviewPinnedPageIndexes,Ht as normalizeVirtualPagedPreviewRequestKey,Bt as resolvePaginatedLayoutViewOptions,kt as resolvePaginatedPreviewFlowMode,Pt as resolveRequestedPaginatedLayoutFlowMode,Lt as resolveVirtualPagedPreviewAutoscrollDelta,zt as resolveVirtualPagedPreviewHostMeasurement,It as resolveVirtualPagedPreviewPositionHit,Tt as resolveVirtualPagedPreviewPositionHitInMountedFrames,$t as resolveVirtualPagedPreviewRenderState,Kt as resolveVirtualPagedPreviewResizeObserver,qt as resolveVirtualPagedPreviewSessionCommit,Gt as resolveVirtualPagedPreviewSessionViewportEmission,Vt as sameVirtualPagedPreviewMetrics,Ee as useBrowserEditorController,Ae as useBrowserEditorDocument,Mt as useBrowserEditorUi,V as useControllerSnapshot,X as useControllerSnapshotSignal,Dt as useEditorUiController};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalking/begonia-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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,30 @@
|
|
|
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-ui": "0.
|
|
42
|
-
"@datalking/begonia-engine": "0.
|
|
43
|
-
"@datalking/begonia-layout-bridge": "0.
|
|
44
|
-
"@datalking/begonia-layout-contracts": "0.
|
|
45
|
-
"@datalking/begonia-layout-renderer": "0.
|
|
46
|
-
"@datalking/begonia-page-layout": "0.
|
|
47
|
-
"@datalking/begonia-pdf-viewer": "0.
|
|
37
|
+
"@datalking/begonia-browser": "0.2.0",
|
|
38
|
+
"@datalking/begonia-browser-sdk": "0.2.0",
|
|
39
|
+
"@datalking/begonia-doc-service": "0.2.0",
|
|
40
|
+
"@datalking/begonia-document-api": "0.2.0",
|
|
41
|
+
"@datalking/begonia-editor-adapters": "0.2.0",
|
|
42
|
+
"@datalking/begonia-editor-ui": "0.2.0",
|
|
43
|
+
"@datalking/begonia-engine": "0.2.0",
|
|
44
|
+
"@datalking/begonia-layout-bridge": "0.2.0",
|
|
45
|
+
"@datalking/begonia-layout-contracts": "0.2.0",
|
|
46
|
+
"@datalking/begonia-layout-renderer": "0.2.0",
|
|
47
|
+
"@datalking/begonia-page-layout": "0.2.0",
|
|
48
|
+
"@datalking/begonia-pdf-viewer": "0.2.0",
|
|
48
49
|
"prosemirror-model": "^1.22.3"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
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};
|