@datalking/begonia-react 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/binding/BegoniaPdfViewer.d.ts +4 -1
  2. package/dist/binding/BrowserPaginatedEditorSurface.d.ts +44 -0
  3. package/dist/binding/HeaderFooterScratchMount.d.ts +25 -0
  4. package/dist/binding/PaginatedLayoutView.d.ts +21 -2
  5. package/dist/binding/PaginatedPageOverlayView.d.ts +44 -0
  6. package/dist/binding/VirtualPagedPreview.d.ts +38 -1
  7. package/dist/binding/begonia-theme-style.d.ts +12 -0
  8. package/dist/binding/browser-header-footer-bands.d.ts +98 -0
  9. package/dist/binding/browser-header-footer-format-bar.d.ts +21 -0
  10. package/dist/binding/browser-paginated-preview-drag-state.d.ts +2 -0
  11. package/dist/binding/headless.d.ts +1 -1
  12. package/dist/binding/index.d.ts +4 -0
  13. package/dist/binding/paginated-preview-doc-style.d.ts +40 -0
  14. package/dist/binding/paginated-preview-font-family.d.ts +19 -0
  15. package/dist/binding/paginated-scroll-axis-host.d.ts +32 -0
  16. package/dist/binding/preview-link-activation.d.ts +71 -0
  17. package/dist/binding/resolve-snapshot-comment-state.d.ts +32 -0
  18. package/dist/binding/use-browser-header-footer-editing.d.ts +114 -0
  19. package/dist/binding/use-header-footer-scratch-surface.d.ts +48 -0
  20. package/dist/binding/use-owned-destroyable.d.ts +9 -0
  21. package/dist/binding/use-undo-redo-hotkeys.d.ts +45 -0
  22. package/dist/binding/useVirtualPagedPreviewState.d.ts +13 -3
  23. package/dist/binding/v1.d.ts +16 -0
  24. package/dist/binding/virtual-paged-preview-comment-highlight.d.ts +33 -0
  25. package/dist/binding/virtual-paged-preview-drag-session.d.ts +1 -1
  26. package/dist/binding/virtual-paged-preview-interaction.d.ts +2 -2
  27. package/dist/binding/virtual-paged-preview-list-marker.d.ts +42 -0
  28. package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-text.d.ts +21 -6
  29. package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-views.d.ts +18 -2
  30. package/dist/binding/virtual-paged-preview-review-attributes.d.ts +78 -0
  31. package/dist/binding/virtual-paged-preview-text-lines.d.ts +4 -0
  32. package/dist/chunk-LIAB6VEG.js +1 -0
  33. package/dist/editor-surface.css +457 -0
  34. package/dist/index.d.ts +6 -0
  35. package/dist/index.js +1 -1
  36. package/dist/v1.d.ts +4 -2
  37. package/dist/v1.js +1 -1
  38. package/package.json +19 -16
  39. package/dist/binding/paginated-preview-defaults.d.ts +0 -2
  40. package/dist/binding/virtual-paged-preview-table-metrics.d.ts +0 -1
  41. package/dist/chunk-IEHE33P5.js +0 -1
@@ -0,0 +1 @@
1
+ import{useSyncExternalStore as Za}from"react";import{useEffect as Ro,useRef as or}from"react";import{begoniaThemeVars as yo,resolveBegoniaTheme as So}from"@datalking/begonia-browser-sdk";function he(e,t){if(e==null)return{style:t??{}};let r=So(e);return{style:{...t,...yo(r)},"data-begonia-theme":r.id}}import{useCallback as To,useRef as rr,useSyncExternalStore as ko}from"react";function it(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(!it(e[l],t[l]))return!1;return!0}if(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype)return!1;let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;let n=e,i=t;for(let l of r)if(!Object.prototype.hasOwnProperty.call(i,l)||!it(n[l],i[l]))return!1;return!0}function Co(e,t){let r=rr(0),o=To(n=>{if(!e)return()=>{};let i=!0,l=e.subscribe(u=>{if(i){t.current.controller===e&&t.current.token===r.current&&!it(t.current.snapshot,u)&&(r.current+=1,t.current={controller:e,token:r.current,snapshot:u},n());return}r.current+=1,t.current={controller:e,token:r.current,snapshot:u},n()});return i=!1,l},[t,e]);return ko(o,()=>r.current,()=>r.current)}function A(e){let t=rr({controller:null,token:-1,snapshot:null}),r=Co(e,t),o=t.current;if(o.controller===e&&o.token===r)return o.snapshot;let n=e?.getSnapshot()??null;return t.current={controller:e,token:r,snapshot:n},n}function at(e,t){let r=A(e);return r==null?null:t(r)}import{jsx as xe,jsxs as $e}from"react/jsx-runtime";function Eo(e){return typeof e=="number"?`${e}px`:e}function Io(e,t){return{pageNumber:e.pageNumber,width:e.width,height:e.height,rotation:e.rotation,scale:t}}function nr(e,t){return`${e??"pdf"}:${t}`}function ir({controller:e,height:t=720,scale:r=1,pageGap:o=24,className:n,style:i,theme:l,emptyLabel:u="No PDF document loaded.",renderPageOverlay:c}){at(e,s=>[s.status,s.pageCount,s.fingerprint,s.error,s.textLayerEnabled,s.outputScale,s.renderVersion,...s.pages.map(f=>`${f.pageNumber}:${f.width}:${f.height}:${f.rotation}`)].join("|"));let d=e.getSnapshot(),m=or(new Map),v=or(new Map);Ro(()=>{if(d.status!=="ready")return;let s=!1;return(async()=>{for(let g of d.pages){if(s)return;let b=nr(d.fingerprint,g.pageNumber),p=m.current.get(b);p&&await e.renderPage(g.pageNumber,p,{scale:r,textLayer:v.current.get(b)??null})}})(),()=>{s=!0}},[e,r,d.fingerprint,d.pages,d.renderVersion,d.status]);let a=he(l);return $e("div",{className:n,"data-begonia-theme":a["data-begonia-theme"],style:{overflow:"auto",height:Eo(t),background:"var(--ald-canvas, linear-gradient(180deg, #dbe4f0 0%, #eef2f7 100%))",borderRadius:"var(--ald-canvas-radius, 18px)",padding:20,...a.style,...i},children:[d.status==="error"?xe("div",{style:{color:"#991b1b",padding:16},children:d.error??"Failed to load PDF."}):null,d.status==="loading"?xe("div",{style:{color:"#334155",padding:16},children:"Loading PDF\u2026"}):null,d.status==="idle"&&d.pages.length===0?xe("div",{style:{color:"#475569",padding:16},children:u}):null,xe("div",{style:{display:"grid",gap:`${o}px`,justifyContent:"center"},children:d.pages.map(s=>{let f=nr(d.fingerprint,s.pageNumber),g=s.width*r,b=s.height*r;return $e("section",{"aria-label":`PDF page ${s.pageNumber}`,children:[$e("div",{style:{color:"var(--ald-text-muted, #334155)",fontSize:12,margin:"0 0 8px 6px"},children:["Page ",s.pageNumber]}),$e("div",{style:{position:"relative",width:g,height:b,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:[xe("canvas",{ref:p=>{p?m.current.set(f,p):m.current.delete(f)},style:{display:"block",width:g,height:b}}),xe("div",{ref:p=>{p?v.current.set(f,p):v.current.delete(f)},style:{position:"absolute",inset:0,pointerEvents:d.textLayerEnabled?"auto":"none"}}),c?xe("div",{style:{position:"absolute",inset:0},children:c(Io(s,r))}):null]})]},f)})})]})}import{useEffect as Ur,useLayoutEffect as Et,useMemo as Wr,useRef as Ie}from"react";import{createPaginatedLayoutPreviewController as bi,createDefaultPaginatedLayoutMeasureText as wi,IDLE_PAGINATED_LAYOUT_DEFERRAL as hi,reducePaginatedLayoutDeferral as zr}from"@datalking/begonia-layout-renderer";import{useEffect as kt,useRef as J,useState as ui}from"react";import{createDefaultPaginatedLayoutMeasureText as ci,normalizeRenderScale as pi,resolveDefaultRenderPageGap as mi,resolveVirtualPagedPreviewContentLayout as fi}from"@datalking/begonia-layout-renderer";import{DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE as lt,DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX as Lo,WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX as st,resolvePaginatedLayoutViewOptions as Bo,resolveVirtualPagedPreviewVirtualization as vl}from"@datalking/begonia-layout-renderer";function lr(e){return e==="horizontal"?"horizontal":"vertical"}var ar=new WeakMap;function sr(e,t){if(!e)return null;let r=ar.get(e);if(r&&r.axis===t)return r.wrapper;let o={get scrollTop(){return e.scrollTop},set scrollTop(n){e.scrollTop=n},get scrollHeight(){return e.scrollHeight},get scrollLeft(){return e.scrollLeft??0},set scrollLeft(n){e.scrollLeft=n},get scrollWidth(){return e.scrollWidth},scrollAxis:t,getBoundingClientRect:()=>{let n=e.getBoundingClientRect(),i=typeof n.width=="number"?n.width:0,l=typeof n.left=="number"?n.left:0;return{top:n.top,height:n.height,left:l,width:i>0?i:e.scrollWidth??0}}};return ar.set(e,{axis:t,wrapper:o}),o}import{resolvePaginatedPreviewFlowMode as dt,resolveRequestedPaginatedLayoutFlowMode as No}from"@datalking/begonia-layout-renderer";import{useCallback as dr,useEffect as ur,useLayoutEffect as cr,useRef as pr}from"react";import{createVirtualPagedPreviewController as Vo,resolveVirtualPagedPreviewObservedScrollHost as Mo}from"@datalking/begonia-layout-renderer";function Ao(e,t){return Mo(e,t)}function mr(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,interactionNavigationActive:e.interactionNavigationActive===!0}}function fr({projection:e,version:t=null,height:r,width:o,scale:n,pageGap:i,windowPages:l,overscan:u,virtualize:c,layoutMode:d,flowMode:m,anchorPageNumber:v,initialViewportAnchor:a,viewportRequestKey:s,pinnedPageNumbers:f,scrollHost:g,onViewportChange:b,interactionNavigationActive:p=!1}){let w=pr(null),T=pr(null);(!T.current||T.current.isDestroyed?.()===!0)&&(T.current=Vo(mr({projection:e,version:t,height:r,width:o,scale:n,pageGap:i,windowPages:l,overscan:u,virtualize:c,layoutMode:d,flowMode:m,anchorPageNumber:v,initialViewportAnchor:a,viewportRequestKey:s,pinnedPageNumbers:f,scrollHost:g,onViewportChange:b,interactionNavigationActive:p})));let S=T.current,D=A(S)??S.getSnapshot();cr(()=>{S.setInput(mr({projection:e,version:t,height:r,width:o,scale:n,pageGap:i,windowPages:l,overscan:u,virtualize:c,layoutMode:d,flowMode:m,anchorPageNumber:v,initialViewportAnchor:a,viewportRequestKey:s,pinnedPageNumbers:f,scrollHost:g,onViewportChange:b,interactionNavigationActive:p}))},[S,e,t,r,o,n,i,l,u,c,d,m,v,a,s,f,p]),cr(()=>{let E=S.bindViewport({getExplicitScrollHost:()=>g,getPreviewHost:()=>w.current});return()=>{E.cleanup()}},[S,g]),ur(()=>b?S.subscribeViewport(b):()=>{},[S,b]),ur(()=>()=>{S.destroy()},[S]);let L=dr(()=>S.resolveObservedScrollHost()??Ao(g,w.current),[S,g]),k=dr(E=>{S.setInteractionNavigationActive(E)},[S]);return{hostRef:w,resolveObservedScrollHost:L,deferredProjection:D.deferredProjection,renderState:D.renderState,setInteractionNavigationActive:k}}import{drawingFragmentOffsetY as Fn,drawingFragmentVisibleHeight as jn,resolveLayoutTableBlockMetrics as Hr,resolveRenderableTableRows as $n,resolveTableHeaderStyleRowCount as Un}from"@datalking/begonia-layout-contracts";import{listProjectionPageBlocks as Wn,resolveTableRowTextOffsets as zn,tableFragmentKey as Gn,resolvePageColumnSeparatorSegments as Kn,resolvePaginatedPageContentLeftOrigin as Yn}from"@datalking/begonia-page-layout";import{BEGONIA_BLOCK_POS_ATTRIBUTE as _r,BEGONIA_CELL_ROW_ATTRIBUTE as Xn,BEGONIA_CELL_TEXT_START_ATTRIBUTE as qn,BEGONIA_PROJECTION_OFFSET_ATTRIBUTE as Zn}from"@datalking/begonia-layout-renderer";import{PREVIEW_TABLE_CELL_HORIZONTAL_PADDING as Jn,PREVIEW_TABLE_CELL_VERTICAL_PADDING as Qn,resolvePreviewTableCellPadding as ei,resolveRowProjectionOffset as ti,resolveTableRowLineStarts as ri}from"@datalking/begonia-table-render";import{drawingSceneTransform as Oo}from"@datalking/begonia-layout-contracts";import{jsx as Pe,jsxs as vr}from"react/jsx-runtime";function Do(e,t){return(t??e.label??"Shape").trim()||"Shape"}function _o(e){return e.fill??e.fillColor??"none"}function Ho(e){return e==="butt"||e==="round"||e==="square"||e==="inherit"?e:void 0}function Fo(e){return e==="miter"||e==="round"||e==="bevel"||e==="inherit"?e:void 0}function jo(e,t){let r={fill:_o(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:Ho(e.strokeLinecap),strokeLinejoin:Fo(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"?Pe("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"?Pe("ellipse",{...r,cx:e.cx??0,cy:e.cy??0,rx:e.rx??0,ry:e.ry??0},t):Pe("path",{...r,d:e.d??""},t)}function $o(e,t){return Pe("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,o)=>Pe("tspan",{x:e.centerX,y:e.startY+o*e.lineHeight,children:r},`${t}-${o}`))},t)}function gr(e,t){let r=Oo(e);return vr("g",{transform:r||void 0,opacity:e.opacity??void 0,style:e.filter?{filter:e.filter}:void 0,children:[e.primitives.map((o,n)=>jo(o,`${t}-primitive-${n}`)),e.children.map((o,n)=>gr(o,`${t}-child-${n}`)),e.text?$o(e.text,`${t}-text`):null]},t)}function Ue({drawing:e,width:t,height:r,className:o,style:n,label:i}){let l=Math.max(1,Number(t??e.width??1)),u=Math.max(1,Number(r??e.height??1)),c=Do(e,i);return vr("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:u,viewBox:e.viewBox,role:"img","aria-label":c,preserveAspectRatio:"xMidYMid meet",className:o||void 0,style:n,children:[Pe("title",{children:c}),e.defs?.trim()?Pe("defs",{dangerouslySetInnerHTML:{__html:e.defs}}):null,gr(e.scene,"drawing-root")]})}var We="var(--ald-doc-text, #000000)",br="var(--ald-doc-heading, #000000)",ut="var(--ald-link, #0563c1)",wr='var(--ald-font-doc, "Aptos", Calibri, "Segoe UI", sans-serif)',hr="var(--ald-table-border, 1px solid rgba(0, 0, 0, 0.5))",xr="var(--ald-table-header-bg, rgba(226, 232, 240, 0.65))";import{listMarkerGutterWidth as Uo,resolveListMarkerPrefix as Wo}from"@datalking/begonia-layout-contracts";import{jsx as Go}from"react/jsx-runtime";function zo({block:e,gutterWidth:t,fontSize:r,color:o}){if(e.continuedFromPrevious)return null;let n=Wo(e);if(n.trim().length===0||t<=0)return null;let i=Math.max(2,r*.3),l={position:"absolute",left:0,top:0,width:Math.max(1,t),boxSizing:"border-box",paddingRight:i,textAlign:"right",whiteSpace:"pre",fontSize:r,lineHeight:"inherit",color:o,pointerEvents:"none",userSelect:"none"};return Go("span",{"aria-hidden":"true",style:l,children:n})}function Pr({block:e,scale:t}){if(!e.listKind)return null;let r=typeof e.fontSize=="number"&&e.fontSize>0?e.fontSize:e.lineHeight/1.5,o=Uo(e,r)*t;return zo({block:e,gutterWidth:o,fontSize:Math.max(1,r*t),color:We})}import{createVirtualPagedPreviewDragSession as ct,isVirtualPagedPreviewChromeTarget as yr,isVirtualPagedPreviewFrameTarget as ze,VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE as pt}from"@datalking/begonia-layout-renderer";import{BEGONIA_CELL_LINE_OFFSET_ATTRIBUTE as Cn,BEGONIA_PIECE_OFFSET_ATTRIBUTE as Rn}from"@datalking/begonia-layout-renderer";import{inlineRevisionSpanDisplayLayer as En,inlineRevisionSpanHasKind as bt,resolveMeasuredLineSlicePaintSpans as In,resolveMeasuredLineSlicePaintText as Ln,resolveMeasuredLineSlicePaintTextFromModel as Bn,resolveLayoutTableBlockMetrics as Br,sliceInlineRevisionSpansByOffsets as Nn}from"@datalking/begonia-layout-contracts";import{createVirtualPagedPreviewInlineNodeAttributes as Vn,resolvePreviewLeftPx as ht,resolvePreviewTopPx as xt}from"@datalking/begonia-layout-renderer";function Ge(e){return Number.isFinite(e)&&e>0?e:1}function ee(e,t){return e*Ge(t)}function Sr(e,t){let r=Ge(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 mt}from"react/jsx-runtime";function Ke(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Ae(e,t,r){let o=e?.inlineObject?.kind==="image"?e.inlineObject:null;if(o){let u=Ke(o.width),c=Ke(o.height);return mt("img",{className:"ald-inline-image",src:o.src,alt:o.alt??"",title:o.title??void 0,"data-image-id":o.objectId??void 0,width:u==null?void 0:ee(u,r),height:c==null?void 0:ee(c,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=ee(Ke(n.width)??n.drawing.width,r),l=ee(Ke(n.height)??n.drawing.height,r);return mt("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:l,verticalAlign:"baseline",lineHeight:0},children:mt(Ue,{drawing:n.drawing,width:i,height:l,className:"ald-inline-drawing-svg",style:{display:"block",width:i,height:l}})})}var Ko="data-comment-ids",Yo="data-track-change-ids",Xo="data-track-change-preferred-target-id";function gt(e){return!e.includes(",")}function ft(e,t){if(typeof t!="string")return;let r=t.trim();r.length===0||e.includes(r)||e.push(r)}function Tr(e){let t=[],r=e?.revisionLayers??[];for(let o of r)ft(t,o?.changeId);return t.length===0&&ft(t,e?.changeId),t}function qo(e){let o=(e?.revisionLayers??[]).find(n=>typeof n?.overlapParentId=="string"&&n.overlapParentId.trim().length>0&&n.revisionKind==="delete")?.changeId?.trim();return!o||!gt(o)?null:Tr(e).includes(o)?o:null}function Zo(e){let t=[];for(let r of e?.commentIds??[])ft(t,r);return t}function vt(e){return Zo(e).filter(gt)}function Oe(e){let t={},r=Tr(e).filter(gt);if(r.length>0){t[Yo]=r.join(",");let n=qo(e);n&&(t[Xo]=n)}let o=vt(e);return o.length>0&&(t[Ko]=o.join(",")),t}var Jo="--ald-comment-tint",Qo="#d97706",kr=["14%","26%"],en="38%",tn="7%";function rn(e,t){return e==="active"?en:e==="resolved"?tn:kr[Math.min(kr.length-1,Math.max(0,t-1))]}function Cr(e,t){let r=vt(e);if(r.length===0)return;let o="resolved";for(let i of r){let l=t?.(i)??"open";if(l==="active"){o="active";break}l==="open"&&(o="open")}let n=rn(o,r.length);return`inset 0 -0.55em 0 0 color-mix(in srgb, var(${Jo}, ${Qo}) ${n}, transparent)`}function on(e){let t=typeof e?.href=="string"?e.href.trim():"";return t.length===0?null:t.startsWith("#")?t.length>1?{href:t,isAnchor:!0}:null:{href:t,isAnchor:!1}}function nn(e){return e.ctrlKey===!0||e.metaKey===!0}function De(e){let t=on(e);return t?{attributes:{onClickCapture:r=>{nn(r)&&(r.preventDefault(),r.stopPropagation(),an(t))},"data-begonia-link-href":t.href},style:{cursor:"pointer",pointerEvents:"auto"}}:null}function an(e){if(!(typeof window>"u")){if(e.isAnchor){window.location.hash=e.href.slice(1);return}window.open(e.href,"_blank","noopener,noreferrer")}}import{BEGONIA_BLOCK_POS_ATTRIBUTE as ln,BEGONIA_LINE_INDEX_ATTRIBUTE as sn,BEGONIA_PROJECTION_OFFSET_ATTRIBUTE as dn}from"@datalking/begonia-layout-renderer";import{resolveBookmarkMarkers as un,resolveFormattingMarkGlyphs as cn,resolveMeasuredLineSliceVisibleRange as Rr,resolveMeasuredLineSlicePaintSpans as pn,resolveMeasuredLineSlicePaintText as mn,resolveTextLineAdvanceHeight as fn,sliceInlineRevisionSpansByOffsets as gn}from"@datalking/begonia-layout-contracts";import{resolveProjectionLineMeasuredGeometry as vn,resolveTextLineFrame as Er}from"@datalking/begonia-page-layout";import{jsx as Ye,jsxs as kn}from"react/jsx-runtime";function Ir(e,t,r){if(!e.inlineSpans||e.inlineSpans.length===0||r<=t)return null;let o=e.lineSlices?.[0]?.fromOffset??0,n=Math.max(0,t-o),i=Math.max(n,r-o);return gn(e.inlineSpans,n,i)}function bn(e,t,r,o){let n=Rr(o),i=Er(e,t),l=Number.isFinite(o.lineIndex)?o.lineIndex:t,u=Number.isFinite(o.lineCount)?o.lineCount:r;return{pageNumber:0,sectionIndex:0,sectionPageNumber:0,region:"body",blockIndex:0,fragmentIndex:e.fragmentIndex,columnIndex:e.columnIndex,lineIndex:l,lineCount:u,from:e.from+o.fromOffset,to:e.from+o.toOffset,left:0,top:0,width:Math.max(0,i.availableWidth),height:Math.max(1,e.lineHeight),text:n.text,logicalText:n.text,discretionaryHyphen:o.discretionaryHyphen===!0,nodeType:e.type,align:e.align??null,direction:e.direction??null,fontSize:e.fontSize??null,tabs:e.tabs??null,inlineSpans:Ir(e,n.fromOffset,n.toOffset),continuesToNext:e.continuesToNext,label:n.text.trim()||e.text}}function wn(e){let t={};return e.color&&(t.color=e.color),e.highlight&&(t.backgroundColor=e.highlight),t}function hn(e,t,r,o){let n=i=>i==="tab"||i==="space";return t.map((i,l)=>{let u=o+i.fromOffset,c=o+i.toOffset,d=i.span?e.interactiveInlineNodeSpanProps(i.span,u,c):null,m=De(i.span),v=i.leader==="dot"?".":i.leader==="hyphen"?"-":i.leader==="underscore"?"_":null,a=v?v.repeat(Math.max(1,Math.floor(i.width/Math.max(1,i.fontSize*.33)))):"\xA0";return Ye("span",{...Oe(i.span),style:{...wn(i),...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:`${ee(i.fontSize,e.scale)}px`,letterSpacing:typeof i.letterSpacing=="number"?`${ee(i.letterSpacing,e.scale)}px`:void 0},pointerEvents:d?"auto":void 0,...m?m.style:null,display:n(i.kind)?"inline-block":void 0,width:n(i.kind)?ee(i.width,e.scale):void 0,minWidth:n(i.kind)?ee(i.width,e.scale):void 0,whiteSpace:i.kind==="tab"?"nowrap":i.kind==="space"?"pre":void 0,overflow:i.kind==="tab"?"hidden":void 0},...d??{},...m?m.attributes:null,children:i.kind==="tab"?a:Ae(i.span,i.text,e.scale)},`${r}-${l}`)})}function xn(e,t,r,o){let n=r;return t.map((i,l)=>{let u=n;n+=i.text.length;let c=n,d=e.interactiveInlineNodeSpanProps(i,u,c),m=De(i);return Ye("span",{...Oe(i),style:{...e.inlineSpanStyle(e.block,i,e.scale),pointerEvents:d?"auto":void 0,...m?m.style:null},...d??{},...m?m.attributes:null,children:Ae(i,i.text,e.scale)},`${o}-${l}`)})}function Lr(e){let t=e.block.lineSlices??null;return!t||t.length===0?null:t.map((r,o)=>{let n=Rr(r),i=mn(r),l=Er(e.block,o),u=fn(l,e.block.lineHeight,e.block.lineSpacingRule),c=l.leftInset*e.scale,d=pn(r,Ir(e.block,n.fromOffset,n.toOffset)??[]),m=n.text.length>0||(d?.length??0)>0,v=(e.block.textOffsetBase??0)+n.fromOffset,a=vn(bn(e.block,o,t.length,r),e.measureText,e.measurementEpoch),s=a&&a.pieces.length>0?hn(e,a.pieces,`${e.block.from}-${e.block.fragmentIndex}-line-${o}`,v):d&&d.length>0?xn(e,d,v,`${e.block.from}-${e.block.fragmentIndex}-line-${o}`):m?i:" ";return kn("span",{[dn]:e.block.from+v,[ln]:e.block.from,[sn]:o,style:{display:"block",paddingLeft:Math.max(0,c),marginLeft:Math.min(0,c),paddingRight:l.rightInset*e.scale,minHeight:Math.max(1,u*e.scale),whiteSpace:"pre",overflowWrap:"normal",overflow:"hidden"},children:[s,Pn(e,r,l,o),yn(e,r,o)]},`${e.block.from}-${e.block.fragmentIndex}-line-${o}`)})}function Pn(e,t,r,o){if(!e.showFormattingMarks)return null;let n=cn({lineSlices:[{lineIndex:o,text:t.text,fromOffset:t.fromOffset,toOffset:t.toOffset}],endsBlock:!e.block.continuesToNext,showSpaces:!0,showTabs:!0,measurePrefixWidth:l=>Tn(e,l)});if(n.length===0)return null;let i=r.leftInset*e.scale;return n.map((l,u)=>Ye("span",{"aria-hidden":"true",style:{position:"absolute",left:i+l.left*e.scale,top:0,opacity:.5,pointerEvents:"none",color:"var(--ald-formatting-mark-color, #94a3b8)",fontSize:"0.85em",lineHeight:1,userSelect:"none"},children:l.glyph},`mark-${o}-${u}`))}function yn(e,t,r){if(!e.showBookmarks)return null;let o=Sn(e.block,t,r);return o.length===0?null:un({lineSlices:[{lineIndex:r,text:t.text,fromOffset:t.fromOffset,toOffset:t.toOffset}],bookmarkIdsByLine:new Map([[r,o]])}).map((i,l)=>Ye("span",{"aria-hidden":"true",title:i.name,style:{position:"absolute",left:0,top:0,width:"var(--ald-bookmark-marker, 6px)",height:"var(--ald-bookmark-marker, 6px)",borderRadius:1,backgroundColor:"var(--ald-bookmark-marker)",color:"var(--ald-bookmark-marker)",opacity:.8,pointerEvents:"none"}},`bookmark-${r}-${l}`))}function Sn(e,t,r){let o=e.inlineSpans;if(!o||o.length===0)return[];let n=[],i=0;for(let l of o){let u=l.text??"",c=i;i+=u.length;let d=l.bookmarkIds??[];if(d.length!==0&&c>=t.fromOffset&&c<t.toOffset)for(let m of d)n.includes(m)||n.push(m)}return n}function Tn(e,t){let r=e.measureText;if(!r||t.length===0)return 0;let o=r({text:t,nodeType:e.block.type??"paragraph",fontSize:e.block.fontSize??0,lineHeight:e.block.lineHeight??0,measurementEpoch:e.measurementEpoch??null});return typeof o=="number"&&Number.isFinite(o)?o:null}import{jsx as yt}from"react/jsx-runtime";function Pt(e){return typeof e.fontSize=="number"&&e.fontSize>0?e.fontSize: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 Mn(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 An(e){return e.direction==="ltr"||e.direction==="rtl"?e.direction:void 0}function On(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 Dn(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))].join(" ")}function Nr(e,t,r=1,o){let n=Ge(r),i=En(t),l=On(i?.revisionKind??t.revisionKind??null)??{},u=typeof l=="object"&&l&&"textDecoration"in l?String(l.textDecoration):void 0,c=typeof l=="object"&&l&&"textDecorationColor"in l?String(l.textDecorationColor):void 0,d=bt(t,"insert"),m=bt(t,"delete"),v=bt(t,"format"),a=Cr(t,o),s=t.smallCaps?"small-caps":void 0,f=t.textTransform&&t.textTransform!=="none"?t.textTransform:void 0,g=i?.revisionKind==="format"?"dotted":void 0;return{...l,fontWeight:t.bold||e.type==="heading"?700:400,fontStyle:t.italic?"italic":"normal",fontVariantCaps:s,textTransform:f,textDecoration:Dn([u,d||v?"underline":null,m?"line-through":null,t.underline?"underline":null,t.strike?"line-through":null,t.href?"underline":null]),textDecorationThickness:t.underline||t.href||d||v?"2px":void 0,textDecorationStyle:g,textDecorationColor:c??(t.href?ut:void 0),color:t.color??(t.href?ut:void 0),backgroundColor:t.highlight??void 0,boxShadow:a,fontFamily:t.fontFamily??void 0,...Sr(t,n)}}function Vr(e,t,r,o=null){let n=typeof e.sourceNodeType=="string"&&e.sourceNodeType.length>0?e.sourceNodeType:null;return!(n!=null&&e.sourceNodeSelectable===!0)||r<=t?null:Vn({nodeType:n,objectId:e.sourceObjectId??null,fromOffset:t,toOffset:r,tableOriginRow:o?.originRow??null,tableOriginColumn:o?.originColumn??null})}function Mr(e,t,r,o,n,i=!1,l=!1){let u=Lr({block:e,scale:t,measureText:r,measurementEpoch:o,showFormattingMarks:i,showBookmarks:l,inlineSpanStyle:(c,d,m)=>Nr(c,d,m,n),interactiveInlineNodeSpanProps:Vr});return u||(!e.inlineSpans||e.inlineSpans.length===0?e.renderedText:wt(e,e.inlineSpans,`${e.from}-${e.to}`,e.textOffsetBase??0,null,t,n))}function _n(e,t,r){return Nn(e,t,r)}function wt(e,t,r,o=0,n=null,i=1,l){if(!t||t.length===0)return null;let u=o;return t.map((c,d)=>{let m=u;u+=c.text.length;let a=Vr(c,m,u,n),s=De(c);return yt("span",{[Rn]:m,...Oe(c),style:{...Nr(e,c,i,l),pointerEvents:a||n?"auto":void 0,...s?s.style:null},...a??{},...s?s.attributes:null,children:Ae(c,c.text,i)},`${r}-${d}`)})}function Ar(e,t,r,o,n){let{layout:i,text:l}=t,u=i?.lineSlices??null;if(u&&u.length>0){let d=u[0]?.fromOffset??0,m=i?.text??l;return u.map((v,a)=>{let s=Bn(v,m,d),f={...v,text:s},g=Ln(f),b=In(f,_n(i?.inlineSpans??null,v.fromOffset-d,v.fromOffset-d+s.length)??[]);return yt("span",{style:{display:"block",whiteSpace:"pre",...t?{overflowWrap:"normal"}:null},[Cn]:v.fromOffset,"data-begonia-cell-line-index":a,children:b&&b.length>0?wt(e,b,`${r}-line-${a}`,v.fromOffset,t,o,n):g||" "},`${r}-line-${a}`)})}let c=wt(e,i?.inlineSpans??null,r,0,t,o,n);return c||(i?.text??l)}function Or(e,t){let r=Number(Br(e)?.width);if(!Number.isFinite(r)||r<=0)return;let o=Number.isFinite(t)&&t>0?t:1;return r*o}function Dr(e){let t=Br(e),r=Array.isArray(t?.columnWidths)?t.columnWidths:null;if(!r||r.length===0)return null;let o=r.reduce((n,i)=>n+Math.max(0,Number(i??0)),0);return o<=0?null:r.map((n,i)=>yt("col",{style:{width:`${Math.max(0,Number(n??0))/o*100}%`}},`${e.from}-col-${i}`))}function Hn(e){let t=Number(e.spacingBeforeOffset);return Number.isFinite(t)&&t>0?t:0}function _e(e,t,r=0,o=0){let n=!!(e.lineSlices&&e.lineSlices.length>0);return{boxSizing:"border-box",position:"absolute",top:xt(e.top,r,t),left:ht(e.left,o,t),width:Math.max(1,e.width*t),minHeight:Math.max(1,(e.estimatedHeight-Hn(e))*t),paddingBottom:0,fontSize:(e.fontSize??Pt(e))*t,lineHeight:`${e.lineHeight*t}px`,fontFamily:wr,whiteSpace:"pre-wrap",wordBreak:"break-word",color:e.type==="heading"?br:We,fontWeight:e.type==="heading"?700:400,textAlign:Mn(e),direction:An(e),pointerEvents:"none",overflow:"hidden",paddingLeft:n?0:void 0,paddingRight:n?0:void 0}}import{jsx as N,jsxs as Xe}from"react/jsx-runtime";function oi({block:e,scale:t,contentTop:r,contentLeft:o}){let n=_e(e,t,r,o);return N("div",{style:n,children:e.assetSrc?N("img",{src:e.assetSrc,alt:e.text&&e.text!=="Image"?e.text:"",style:{width:e.assetWidth!=null?Math.max(1,e.assetWidth*t):"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"}}):N("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 ni({block:e,scale:t,contentTop:r,contentLeft:o,resolveCommentState:n,rowOffsets:i}){let l=_e(e,t,r,o),u=Hr(e),c=Number(u?.headerStyleRowCount??u?.headerRowCount??0),d=Dr(e),m=ei(u?.cellMargins,{vertical:Qn,horizontal:Jn}),v=m.top*t,a=m.bottom*t,s=m.left*t,f=m.right*t,g=$n(e),b=ri(e,g.length);return N("div",{style:l,children:Xe("table",{style:{width:Or(e,t),borderCollapse:"collapse",tableLayout:"fixed",fontSize:Pt(e)*t,background:"#fff",direction:u?.direction==="rtl"?"rtl":"ltr"},children:[d?N("colgroup",{children:d}):null,N("tbody",{children:g.map(p=>N("tr",{style:{boxSizing:"border-box",height:u?.rowHeights?.[p.fragmentRowIndex]!=null?u.rowHeights[p.fragmentRowIndex]*t:void 0},[Zn]:ti(i,p.fragmentRowIndex,e.from+(b[p.fragmentRowIndex]??0)),[_r]:e.from,children:p.cells.map(w=>{let T=Un(p,c,g.length)>0;return N(T?"th":"td",{colSpan:w.colSpan>1?w.colSpan:void 0,rowSpan:w.rowSpanInFragment>1?w.rowSpanInFragment:void 0,[qn]:w.textStart,[_r]:e.from,[Xn]:p.sourceRowIndex,style:{border:hr,boxSizing:"border-box",lineHeight:`${Math.max(1,e.lineHeight*t-2)}px`,padding:`${v}px ${f}px ${a}px ${s}px`,verticalAlign:w.layout.verticalAlign??"top",fontWeight:T?700:void 0,textAlign:"left",background:T?xr:void 0},children:Ar(e,w,`${e.from}-${p.fragmentRowIndex}-${w.physicalIndex}`,t,n)},`${e.from}-${p.fragmentRowIndex}-${w.physicalIndex}-${w.originColumn}`)})},`${e.from}-${p.fragmentRowIndex}-${p.sourceRowIndex}`))})]})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function ii({block:e,scale:t,contentTop:r,contentLeft:o}){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,l=Fn(e)*t,u=Math.max(1,jn(e)*t||i),c=l>0||u<i,d={..._e(e,t,r,o),minHeight:u},m=e.drawing?.scene&&e.drawing.viewBox?N(Ue,{drawing:e.drawing,width:n,height:i,className:"ald-drawing-scene-svg",style:{display:"block",width:"100%",height:"100%"}}):N("div",{style:{width:"100%",height:"100%"},dangerouslySetInnerHTML:{__html:e.drawing?.svg??""}});return N("div",{style:d,children:e.drawing?N("div",{style:{width:n,height:u,maxWidth:"100%",overflow:c?"hidden":void 0},children:N("div",{style:{width:n,height:i,transform:c?`translateY(-${l}px)`:void 0,transformOrigin:c?"top left":void 0},children:m})}):N("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 ai({block:e,scale:t,contentTop:r,contentLeft:o,measureText:n,measurementEpoch:i,resolveCommentState:l,showFormattingMarks:u=!1,showBookmarks:c=!1,tableRowOffsets:d}){let m=Gn(e);return e.drawing?N(ii,{block:e,scale:t,contentTop:r,contentLeft:o}):e.type==="image"?N(oi,{block:e,scale:t,contentTop:r,contentLeft:o}):e.type==="table"&&Hr(e)?.rows?N(ni,{block:e,scale:t,contentTop:r,contentLeft:o,resolveCommentState:l,rowOffsets:d?.get(m)??null}):Xe("div",{style:_e(e,t,r,o),children:[Pr({block:e,scale:t}),Mr(e,t,n,i,l,u,c)]},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function li({page:e,scale:t,contentTop:r,contentLeft:o}){return Kn(e).map(n=>N("div",{"data-ald-column-separator":"true",style:{position:"absolute",top:xt(n.top,r,t),left:ht(n.left,o,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 qe({frame:e,projection:t,scale:r,measureText:o,measurementEpoch:n,resolveCommentState:i,offsetTop:l=0,offsetLeft:u=0,flowMode:c="paginated",renderPageOverlay:d,onProjectionPositionHit:m,showFormattingMarks:v=!1,showBookmarks:a=!1}){let s=e.page,f=c==="web"?e.contentTop:0,g=c==="web"?-e.contentLeft:Yn(s),b=Wn(s),p=zn(t,s);return Xe("article",{[pt]:"true",style:{position:"absolute",top:e.top-l,left:e.left-u,width:e.width,height:e.height,boxSizing:"border-box",background:c==="web"?"transparent":"var(--ald-page-bg, #fffdfa)",border:c==="web"?"none":"var(--ald-page-border, 1px solid rgba(92, 70, 43, 0.14))",borderRadius:c==="web"?0:"var(--ald-page-radius, 20px)",boxShadow:c==="web"?"none":"var(--ald-page-shadow, 0 18px 40px rgba(69, 47, 16, 0.12))",overflow:"hidden",cursor:m?"text":void 0},children:[c==="paginated"?Xe("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 ",s.pageNumber]}):null,N(li,{page:s,scale:r,contentTop:f,contentLeft:g}),b.map(w=>N(ai,{block:w,scale:r,contentTop:f,contentLeft:g,measureText:o,measurementEpoch:n,resolveCommentState:i,showFormattingMarks:v,showBookmarks:a,tableRowOffsets:p},`${w.from}-${w.to}-${w.fragmentIndex}-${w.top}`)),d?N("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:d(e,r)}):null]})}import{resolveVirtualPagedPreviewPointerHit as Fr,resolveVirtualPagedPreviewPositionHit as si,resolveVirtualPagedPreviewPositionHitInMountedFrames as di}from"@datalking/begonia-layout-renderer";import{bindVirtualPagedPreviewWindowDragListeners as St}from"@datalking/begonia-layout-renderer";var jr=!1;function Tt(e){jr=e}function $r(){return jr}import{Fragment as gi,jsx as Z,jsxs as Ct}from"react/jsx-runtime";function Rt({projection:e,version:t=null,measureText:r,measurementEpoch:o,resolveCommentState:n,showFormattingMarks:i=!1,showBookmarks:l=!1,height:u=720,width:c,scrollHost:d=null,scale:m=lt,pageGap:v,windowPages:a,overscan:s=2,virtualize:f=!0,layoutMode:g="vertical",flowMode:b,anchorPageNumber:p=null,initialViewportAnchor:w=null,viewportRequestKey:T=null,pinnedPageNumbers:S,theme:D,emptyLabel:L="No paginated preview available yet.",onViewportChange:k,renderPageOverlay:E,onProjectionPositionHit:M,onResolvedScrollHostChange:h,onResolvedPreviewHostChange:$,onProjectionContextMenu:z}){let _=pi(m),X=J(null);X.current===null&&(X.current=ci());let H=r??X.current??void 0,F=dt(e,b),[ge,ie]=ui(!1),{hostRef:G,resolveObservedScrollHost:y,deferredProjection:B,renderState:ce,setInteractionNavigationActive:ve}=fr({projection:e,version:t,height:u,width:c,scale:_,pageGap:v??mi(g,F),windowPages:a,overscan:s,virtualize:f,layoutMode:g,flowMode:F,anchorPageNumber:p,initialViewportAnchor:w,viewportRequestKey:T,pinnedPageNumbers:S,scrollHost:d,onViewportChange:k,interactionNavigationActive:ge}),ae=J(null),le=J(H),Q=J(o),Te=J([]),ke=J(_),be=J(F),Ce=J(M),Qt=J(z),Ve=J(null),er=()=>ct({getProjection:()=>ae.current,getMountedFrames:()=>Te.current,getMeasureText:()=>le.current,getMeasurementEpoch:()=>Q.current,getScale:()=>ke.current,getFlowMode:()=>be.current,getPaginatedHorizontalOrigin:()=>"frame",getInteractionRoot:()=>G.current,getScrollHost:()=>y(),dispatchPositionHit(x){return Ce.current?.(x)}}),Re=J(er());Re.current.isDestroyed()&&(Re.current=er()),ae.current=B,le.current=H,Q.current=o,Te.current=ce.window.mountedFrames,ke.current=_,be.current=F,Ce.current=M,Qt.current=z,kt(()=>{let x=Re.current;return()=>{let U=Ve.current;Ve.current=null,U?.(),x.destroy()}},[]),kt(()=>{if(h)return h(sr(y(),lr(g))),()=>{h(null)}},[g,h,y]),kt(()=>{if($)return $(G.current),()=>{$(null)}},[$,G]);let Ee=fi({renderState:ce,flowMode:F}),go=Ee.useSpacerWindow,we=Ee.spacerWindowLayout,vo=we.mountedWindowLayout,bo={height:d?void 0:u,width:d?void 0:c,overflow:d?"visible":"auto",borderRadius:"var(--ald-canvas-radius, 18px)",background:F==="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:F==="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))"},wo={width:Ee.contentWidth,margin:"0 auto",padding:F==="web"?`20px ${st}px 28px`:"20px 0 28px"},ho={position:"relative",width:Ee.layoutSurfaceWidth>0?Ee.layoutSurfaceWidth:void 0,minHeight:Ee.layoutSurfaceHeight,margin:"0 auto"},xo=x=>{if(!M||x.button!==0||!ze(x.target)||yr(x.target))return;let U=()=>{let pe=Ve.current;Ve.current=null,pe?.()},se=()=>{Re.current.handleMouseUp(),U(),Tt(!1),ie(!1),ve(!1)};U();let Me=Re.current.handleMouseDown({clientX:x.clientX,clientY:x.clientY,button:x.button,buttons:x.buttons,detail:x.detail,shiftKey:x.shiftKey,target:x.target});if(ie(!0),ve(!0),Me.started&&Tt(!0),!Me.started){Me.handled&&x.preventDefault();return}let tr=x.currentTarget.ownerDocument.defaultView;tr&&(Ve.current=St({view:tr,onMouseMove(pe){if((pe.buttons&1)!==1){se();return}Re.current.handleMouseMove({clientX:pe.clientX,clientY:pe.clientY,buttons:pe.buttons,target:pe.target})&&pe.preventDefault()},onStop(){se()}}).cleanup),Me.handled&&x.preventDefault()},Po=x=>{let U=Qt.current;if(!U||!ze(x.target))return;let se=Fr({getProjection:()=>ae.current,getMountedFrames:()=>Te.current,getMeasureText:()=>le.current,getMeasurementEpoch:()=>Q.current,getScale:()=>ke.current,getFlowMode:()=>be.current,getPaginatedHorizontalOrigin:()=>"frame",getInteractionRoot:()=>G.current},{clientX:x.clientX,clientY:x.clientY,clickCount:1,shiftKey:x.shiftKey,target:x.target});if(!se)return;Ce.current?.({...se,clickCount:1,shiftKey:!1}),U(se,{clientX:x.clientX,clientY:x.clientY})===!0&&x.preventDefault()};return Z("div",{...he(D,bo),children:!B||B.pages.length===0?Z("div",{style:{minHeight:u,display:"grid",placeItems:"center",color:"var(--ald-text-muted, #6b5a46)",padding:24},children:L}):Z("div",{style:wo,children:Z("div",{ref:G,onMouseDown:M?xo:void 0,onContextMenu:z?Po:void 0,style:ho,children:go?Ct(gi,{children:[Z("div",{"data-begonia-virtual-spacer":"top",style:{height:we.topSpacerHeight,width:"100%",overflowAnchor:"none"}}),Ct("div",{style:{display:"flex",width:"100%",direction:"ltr",overflowAnchor:"none"},children:[Z("div",{"data-begonia-virtual-spacer":"left",style:{width:we.leftSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}}),Z("div",{style:{position:"relative",height:we.mountedSurfaceHeight,width:we.mountedSurfaceWidth,flex:"0 0 auto"},children:vo.clusters.map(x=>{let U=x.leadingGap;return Ct("div",{style:{position:"absolute",top:x.offsetTop,left:x.offsetLeft,width:x.width,height:x.height},children:[U?Z("div",{"data-begonia-virtual-spacer":"gap","data-begonia-gap-from":String(U.fromPageIndex),"data-begonia-gap-to":String(U.toPageIndex),style:{position:"absolute",top:U.top,left:U.left,width:U.width,height:U.height,overflowAnchor:"none"}}):null,x.frames.map(se=>Z(qe,{frame:se,projection:e,scale:_,measureText:H,measurementEpoch:o,resolveCommentState:n,flowMode:F,offsetTop:x.top,offsetLeft:x.left,renderPageOverlay:E,onProjectionPositionHit:M,showFormattingMarks:i,showBookmarks:l},`page-${se.page.pageNumber}`))]},`cluster-${x.startIndex}-${x.endIndex}`)})}),Z("div",{"data-begonia-virtual-spacer":"right",style:{width:we.rightSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}})]}),Z("div",{"data-begonia-virtual-spacer":"bottom",style:{height:we.bottomSpacerHeight,width:"100%",overflowAnchor:"none"}})]}):ce.window.mountedFrames.map(x=>Z(qe,{frame:x,projection:e,scale:_,measureText:H,measurementEpoch:o,resolveCommentState:n,flowMode:F,renderPageOverlay:E,onProjectionPositionHit:M,showFormattingMarks:i,showBookmarks:l},`page-${x.page.pageNumber}`))})})})}import{begoniaThemeVars as vi}from"@datalking/begonia-browser-sdk";function Ze(e){try{let t=vi(e)["--ald-font-doc"];return typeof t=="string"&&t.trim().length>0?t.trim():null}catch{return null}}function Je(e,t){if(!e||!t)return e;let r=(i=>e({...i,fontFamily:i.fontFamily??t})),n=e.measureTextMetrics;return typeof n=="function"&&(r.measureTextMetrics=i=>n({...i,fontFamily:i.fontFamily??t})),r}import{jsx as Gr}from"react/jsx-runtime";function xi(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 It({projection:e=null,adapter:t,source:r=null,version:o,options:n,measureText:i,resolveCommentState:l,onLayoutChange:u,scrollHost:c,height:d,width:m,scale:v,pageGap:a,windowPages:s,overscan:f,virtualize:g,layoutMode:b,flowMode:p,anchorPageNumber:w,initialViewportAnchor:T,viewportRequestKey:S,pinnedPageNumbers:D,theme:L,emptyLabel:k,onViewportChange:E,renderPageOverlay:M,onResolvedScrollHostChange:h,onResolvedPreviewHostChange:$,onProjectionContextMenu:z,onProjectionPositionHit:_,deferLayout:X=!1,onDeferralRelease:H}){let F=Ie(null),ge=Ie(null);ge.current===null&&(ge.current=wi());let ie=Wr(()=>Je(i??ge.current??void 0,Ze(L)),[i,L]),G=Wr(()=>xi({projection:e,adapter:t,source:r,version:o,options:n,flowMode:p,scale:v,measureText:ie}),[t,ie,p,n,e,v,r,o]),y=Ie(null);(!y.current||y.current.isDestroyed?.()===!0)&&(y.current=bi(G));let B=y.current,ce=A(B)??B.getSnapshot(),ve=Ie(hi),ae=Ie(null),le=Ie(null);return Et(()=>{let Q=zr(ve.current,X?"compose":"input");if(ve.current=Q.state,Q.action==="apply"){B.setInput(G);return}if(Q.action==="store"){ae.current=G;return}if(Q.action!=="schedule-release")return;ae.current=G;let Te={cancelled:!1};le.current=Te;let ke=()=>{if(Te.cancelled)return;le.current=null,ve.current=zr(ve.current,"release").state;let Ce=ae.current;ae.current=null,B.isDestroyed?.()!==!0&&(Ce&&B.setInput(Ce),H?.())},be=typeof window>"u"?null:window;if(!be){ke();return}be.requestAnimationFrame(()=>{be.setTimeout(ke,0)})},[B,G,X,H]),Ur(()=>()=>{le.current&&(le.current.cancelled=!0,le.current=null),ae.current=null},[]),Et(()=>{let Q=B.bindHost({getHost:()=>F.current,getScrollHost:()=>c??null});return()=>{Q.cleanup()}},[B,c]),Et(()=>{u?.(ce.resolvedLayout)},[u,ce.resolvedLayout]),Ur(()=>()=>{B.destroy()},[B]),Gr("div",{ref:F,style:{width:"100%"},children:Gr(Rt,{projection:ce.previewProjection,version:o??null,measureText:ie,resolveCommentState:l,scrollHost:c,height:d,width:m,scale:v,pageGap:a,windowPages:s,overscan:f,virtualize:g,layoutMode:b,flowMode:ce.requestedFlowMode,anchorPageNumber:w,initialViewportAnchor:T,viewportRequestKey:S,pinnedPageNumbers:D,theme:L,emptyLabel:k,onViewportChange:E,renderPageOverlay:M,onResolvedScrollHostChange:h,onResolvedPreviewHostChange:$,onProjectionContextMenu:z,onProjectionPositionHit:_})})}import{useMemo as Kr}from"react";import{PAGINATED_CARET_ATTRIBUTE as Yr,PAGINATED_CELL_SELECTION_ATTRIBUTE as Pi,PAGINATED_COMPOSING_ATTRIBUTE as yi,PAGINATED_COMPOSITION_ATTRIBUTE as Si,PAGINATED_OVERLAY_ATTRIBUTE as Ti,PAGINATED_SELECTION_ATTRIBUTE as ki,resolvePaginatedCompositionGhost as Ci,resolvePaginatedFrameContentOrigin as Ri,resolvePaginatedOverlayForFrame as Ei}from"@datalking/begonia-layout-renderer";import{jsx as Le,jsxs as Xr}from"react/jsx-runtime";var Ii={position:"relative",width:"100%",height:"100%",pointerEvents:"none"};function Li(e){return{position:"absolute",left:e.left,top:e.top,width:e.width,height:e.height,background:"var(--ald-selection-bg, rgba(15, 118, 110, 0.22))",borderRadius:"var(--ald-selection-radius, 2px)"}}function Bi(e){return{position:"absolute",left:e.left,top:e.top,width:e.width,height:e.height,background:"var(--ald-cell-selection-bg, var(--ald-selection-bg, rgba(15, 118, 110, 0.22)))",borderRadius:"var(--ald-selection-radius, 2px)"}}function Ni(e){return{position:"absolute",left:e.left,top:e.top,margin:0,padding:0,width:e.width>0?e.width:void 0,height:e.lineHeight,background:"var(--ald-page-bg, #fffdfa)",fontSize:e.fontSize,lineHeight:`${e.lineHeight}px`,fontFamily:"var(--ald-font-doc, var(--ald-font-body, inherit))",color:"inherit",whiteSpace:"pre",overflow:e.bounded?"hidden":"visible",pointerEvents:"none"}}function Vi(e,t){return{display:"inline-block",width:0,height:e.lineHeight,borderRight:"var(--ald-caret-width, 2px) solid var(--ald-caret-color, #0f766e)",verticalAlign:"top",pointerEvents:"none",animationName:"none",visibility:t?"visible":"hidden"}}function Mi(){return{color:"inherit"}}function Ai(e,t,r){return{position:"absolute",left:e.left,top:e.top,width:"var(--ald-caret-width, 2px)",height:e.height,background:"var(--ald-caret-color, #0f766e)",borderRadius:"var(--ald-caret-radius, 1px)",boxShadow:"var(--ald-caret-shadow, 0 0 0 1px rgba(255, 253, 250, 0.9))",pointerEvents:"none",visibility:t||!r?"hidden":"visible"}}function Oi({frame:e,scale:t,overlay:r,flowMode:o="paginated",composing:n=!1,compositionText:i="",caretVisible:l=!0}){let u=Kr(()=>Ei({model:r,frame:e,scale:t,flowMode:o}),[e,o,r,t]),c=Kr(()=>{if(!e)return null;let d=Ri(e,o);return Ci({text:i,caret:u.caret,blocks:e.page?.blocks,scale:t,contentLeft:d.contentLeft,contentTop:d.contentTop,committed:!n})},[n,i,o,e,u.caret,t]);return u.selection.length===0&&!u.caret&&(u.cellSelection?.length??0)===0?null:Xr("div",{[Ti]:"true",[yi]:n?"true":void 0,style:Ii,children:[u.selection.map((d,m)=>Le("div",{[ki]:"true",style:Li(d)},`selection-${m}`)),(u.cellSelection??[]).map((d,m)=>Le("div",{[Pi]:"true",style:Bi(d)},`cell-selection-${m}`)),c?Xr("div",{[Si]:"true",style:Ni(c),children:[Le("span",{children:i}),Le("span",{[Yr]:"true",style:Vi(c,l)}),c.tail?Le("span",{style:Mi(),children:c.tail}):null]}):null,c?null:u.caret?Le("div",{[Yr]:"true",style:Ai(u.caret,n,l)}):null]})}import{useEffect as ye,useLayoutEffect as qr,useMemo as Zr,useReducer as Di,useRef as te}from"react";import{createBrowserEditorMount as _i}from"@datalking/begonia-browser-sdk";var de=Symbol("browser-editor-ui-callback-unset");function Lt({onEditorChange:e,onHostChange:t,onSnapshotChange:r,...o}){let n=Zr(()=>({backend:o.backend,backendInput:o.backendInput}),[o.backend,o.backendInput]),i=te(null);i.current||(i.current=_i(n));let l=i.current,u=te(null),[c,d]=Di(k=>k+1,0),m=Zr(()=>({getSnapshot:()=>l.getSnapshot(),subscribe:k=>l.subscribe(k)}),[c,l]),v=A(m)??l.getSnapshot(),a=v.ui,s=v.host,f=v.snapshot,g=te(e),b=te(t),p=te(r),w=te(de),T=te(de),S=te(de),D=te(null),L=te(null);if(!L.current){let k=(E=>{D.current!==E&&(D.current=E,l.setHost(E),d())});Object.defineProperty(k,"current",{configurable:!0,enumerable:!0,get(){return D.current},set(E){k(E)}}),L.current=k}return qr(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[l]),ye(()=>{g.current=e},[e]),ye(()=>{b.current=t},[t]),ye(()=>{p.current=r},[r]),qr(()=>{l.setInput(n.backendInput)},[l,n]),ye(()=>{if(w.current===a||w.current===de&&a==null){w.current=a;return}w.current=a,g.current?.(a)},[a]),ye(()=>{if(T.current===s||T.current===de&&s==null){T.current=s;return}T.current=s,b.current?.(s)},[s]),ye(()=>{if(S.current===f||S.current===de&&f==null){S.current=f;return}S.current=f,p.current?.(f)},[f]),ye(()=>()=>{let k=setTimeout(()=>{u.current===k&&(u.current=null,w.current!==de&&w.current!==null&&g.current?.(null),T.current!==de&&T.current!==null&&b.current?.(null),S.current!==de&&S.current!==null&&p.current?.(null),w.current=null,T.current=null,S.current=null,l.destroy())},0);u.current=k},[l]),{hostRef:L.current,ui:a,host:s,snapshot:f}}import{createEditorUiController as $i}from"@datalking/begonia-editor-ui";import{useEffect as Hi,useMemo as Fi,useRef as ji}from"react";function Jr(e,t){let r=Fi(e,t),o=ji(null);return Hi(()=>{let n=r;return o.current=n,()=>{o.current===n&&(o.current=null),queueMicrotask(()=>{o.current!==n&&n?.destroy()})}},[r]),r}function Bt(e,t=null){let r=Jr(()=>$i(e),[e]),o=t??r,n=A(o)??o.getSnapshot();return{controller:o,snapshot:n}}import{applyVirtualPagedPreviewAutoscroll as Ui,createVirtualPagedPreviewAutoscrollController as Wi,resolveVirtualPagedPreviewAutoscrollDelta as zi}from"@datalking/begonia-layout-renderer";import{PREVIEW_TABLE_CELL_HORIZONTAL_PADDING as Bd,PREVIEW_TABLE_CELL_VERTICAL_PADDING as Nd}from"@datalking/begonia-table-render";import{resolveVirtualPagedPreviewRenderState as Gi}from"@datalking/begonia-layout-renderer";import{cloneVirtualPagedPreviewAnchor as bd,cloneVirtualPagedPreviewMetrics as Ki,cloneVirtualPagedPreviewSnapshot as wd,normalizeVirtualPagedPreviewPinnedPageIndexes as Yi,normalizeVirtualPagedPreviewRequestKey as Xi,resolveVirtualPagedPreviewHostMeasurement as qi,resolveVirtualPagedPreviewResizeObserver as Zi,sameVirtualPagedPreviewAnchor as hd,sameVirtualPagedPreviewMetrics as Ji,sameVirtualPagedPreviewSnapshot as xd}from"@datalking/begonia-layout-renderer";import{createVirtualPagedPreviewSessionState as Qi,resolveVirtualPagedPreviewSessionCommit as ea,resolveVirtualPagedPreviewSessionViewportEmission as ta}from"@datalking/begonia-layout-renderer";import{useCallback as Nt,useEffect as Qr,useLayoutEffect as ra,useMemo as Qe,useRef as Vt}from"react";import{createBrowserPaginatedPreviewController as oa,resolveBrowserPaginatedPreviewBindingProjection as na}from"@datalking/begonia-browser-sdk/preview";import{resolveBrowserEditorPreviewBinding as ia}from"@datalking/begonia-browser-sdk";import{createDefaultPaginatedLayoutMeasureText as aa,resolveDefaultRenderPageGap as la}from"@datalking/begonia-layout-renderer";import{jsx as ua}from"react/jsx-runtime";function sa(e){return{adapter:e.adapter??null,source:e.source??null,version:e.version??null,options:e.options??null}}function da(e){return{editor:e.editor,source:e.source,explicitProjection:e.projection??null,explicitScale:e.scale,pageGap:e.pageGap??la(e.layoutMode??"vertical",e.flowMode??"paginated"),explicitFlowMode:e.flowMode,explicitLayoutMode:e.layoutMode,explicitAnchorPageNumber:e.anchorPageNumber,controllerNavigationMode:e.controllerNavigationMode,syncViewportToEditor:e.syncViewportToEditor,pinnedPageNumbers:e.pinnedPageNumbers,layoutResolutionIdentity:e.layoutResolutionIdentity}}function eo({editor:e,scale:t,flowMode:r,anchorPageNumber:o,controllerNavigationMode:n="consume",syncViewportToEditor:i=!0,onViewportChange:l,onLayoutChange:u,onProjectionPositionHit:c,...d}){let m=Qe(()=>sa(d),[d.adapter,d.options,d.source,d.version]),v=Qe(()=>da({...d,editor:e,scale:t,flowMode:r,anchorPageNumber:o,controllerNavigationMode:n,syncViewportToEditor:i,layoutResolutionIdentity:m}),[o,n,e,r,m,d.layoutMode,d.pageGap,d.pinnedPageNumbers,d.projection,t,i]),a=Vt(null);(!a.current||a.current.isDestroyed?.()===!0)&&(a.current=oa(v));let s=a.current,f=A(s)??s.getSnapshot(),g=d.projection??null,b=Qe(()=>ia(e),[e]),p=Vt(null);p.current===null&&(p.current=aa());let w=Qe(()=>Je(d.measureText??p.current??void 0,Ze(d.theme)),[d.measureText,d.theme]);ra(()=>{s.setInput(v)},[s,v]),Qr(()=>()=>{s.destroy()},[s]),Qr(()=>{if(b?.setResolvedProjection)return b.setResolvedProjection(na({binding:b,source:d.source,explicitProjection:g,resolvedProjection:f.previewProjection}),{measureText:w,measurementEpoch:d.options?.measurementEpoch}),()=>{b.setResolvedProjection?.(null,null)}},[d.source,g,w,d.options?.measurementEpoch,b,f.previewProjection]);let T=Nt(k=>{s.setResolvedProjection(k),u?.(k)},[s,u]),S=Nt(k=>{s.observeViewport(k,f.viewportResetVersion),l?.(k)},[s,l,f.viewportResetVersion]),D=Nt(k=>{let E=s.resolvePositionHitEvent(k),M=s.handlePositionHit(E),h=c?.(E);return M||h===!0},[s,c]),L=Vt(f.viewportResetVersion);return $r()||(L.current=f.viewportResetVersion),ua(It,{...d,projection:g,layoutMode:f.viewModel.layoutMode,flowMode:f.viewModel.flowMode,scale:f.viewModel.scale,anchorPageNumber:f.viewModel.anchorPageNumber,initialViewportAnchor:f.viewModel.initialViewportAnchor,viewportRequestKey:f.viewModel.viewportRequestKey,pinnedPageNumbers:f.pinnedPageNumbers,onLayoutChange:T,onViewportChange:S,onProjectionPositionHit:D},L.current)}function Mt(e,t){let r=new Map;for(let o of e?.comments.items??[])r.set(o.id,o.resolved||o.deletedAt!=null?"resolved":"open");for(let o of e?.comments.activeCommentIds??[])r.set(o,"active");return t!=null&&r.set(t,"active"),o=>r.get(o)??"open"}var ca=["input","textarea","select",'[contenteditable="true"]','[contenteditable=""]','[role="combobox"]','[role="listbox"]','[role="textbox"]'].join(", ");function pa(e){let t=e;return!t||typeof t.closest!="function"?!1:t.closest(ca)!==null}function et(e){pa(e.target)||e.preventDefault()}import{jsx as fa}from"react/jsx-runtime";function ma(...e){return e.filter(Boolean).join(" ")}function C({active:e,mixed:t=!1,disabled:r=!1,label:o,onClick:n,title:i}){return fa("button",{type:"button","aria-pressed":t?"mixed":e,disabled:r,title:i,className:ma("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)]"),onMouseDown:et,onClick:n,children:o})}import{jsx as Be,jsxs as ga}from"react/jsx-runtime";function tt(...e){return e.filter(Boolean).join(" ")}function O({children:e,pressed:t=!1,disabled:r=!1,title:o,ariaLabel:n,onClick:i}){return Be("button",{type:"button","aria-pressed":t==="mixed"?"mixed":t,"aria-label":n,title:o,disabled:r,onMouseDown:et,onClick:i,className:tt("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 V(){return Be("span",{"aria-hidden":"true",className:"mx-1 inline-block h-5 w-px shrink-0 self-center bg-[var(--ald-border,#e2e8f0)]"})}function Ne({value:e,options:t,disabled:r=!1,title:o,ariaLabel:n,widthClass:i="min-w-0 max-w-40",onChange:l}){let u=t.find(c=>c.value===e);return ga("label",{className:tt("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:[u?.swatch?Be("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-[2px] border border-[var(--ald-border,#e2e8f0)]",style:{background:u.swatch}}):null,Be("select",{"aria-label":n,title:o,disabled:r,value:e,onChange:c=>l(c.target.value),className:"w-full cursor-pointer appearance-none truncate bg-transparent text-xs font-medium outline-none",children:t.map(c=>Be("option",{value:c.value,children:c.label},c.value))}),Be("span",{"aria-hidden":"true",className:"pointer-events-none shrink-0 text-[8px] text-[var(--ald-text-muted,#64748b)]",children:"\u25BC"})]})}import{jsx as ue,jsxs as va}from"react/jsx-runtime";function At({controller:e}){let t=A(e);if(!e||!t?.enabled)return null;let r=t.suppressInternalExternal;return va("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:[ue("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Comments"}),ue(C,{active:t.visible,label:"Show",onClick:()=>e.setCommentsVisible(!0)}),ue(C,{active:!t.visible,label:"Hide",onClick:()=>e.setCommentsVisible(!1)}),ue(C,{active:t.showResolved,label:"Resolved",onClick:()=>e.setCommentsShowResolved(!t.showResolved)}),ue(V,{}),ue("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Scope"}),ue(C,{active:t.visibility==="all",disabled:r,label:"All",onClick:()=>e.setCommentsVisibility("all")}),ue(C,{active:t.visibility==="internal",disabled:r,label:"Internal",onClick:()=>e.setCommentsVisibility("internal")}),ue(C,{active:t.visibility==="external",label:"External",onClick:()=>e.setCommentsVisibility("external")})]})}import{jsx as j,jsxs as q}from"react/jsx-runtime";function rt(...e){return e.filter(Boolean).join(" ")}function Ot({comments:e,permissionsByCommentId:t,activeCommentId:r=null,canCreateComment:o=!1,createCommentDisabledReason:n=null,onCreateComment:i,onSelectComment:l,onToggleCommentInternal:u,onReplyComment:c,onResolveComment:d,onReopenComment:m,onDeleteComment:v}){return q("aside",{className:"grid gap-3","aria-label":"Comments sidebar",children:[q("header",{className:"flex items-center justify-between",children:[q("div",{children:[j("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Comments"}),q("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," thread",e.length===1?"":"s"]})]}),i?j("button",{type:"button",disabled:!o,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]}),q("div",{className:"grid gap-3",children:[e.length===0?j("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(a=>{let s=t?.[a.id]??null;return q("section",{className:rt("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",r===a.id?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[q("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>l?.(a.id),children:[q("div",{className:"flex items-center justify-between gap-3",children:[j("strong",{className:"text-sm text-[var(--ald-text,#0f172a)]",children:a.authorName??a.authorId??"Unknown author"}),q("div",{className:"flex items-center gap-2",children:[j("span",{className:rt("rounded-full px-2 py-1 text-[11px] font-semibold",a.isInternal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:a.isInternal?"Internal":"External"}),j("span",{className:rt("rounded-full px-2 py-1 text-[11px] font-semibold",a.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:a.resolved?"Resolved":"Open"})]})]}),j("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:a.text||"Empty comment"}),q("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[a.entries.length," message",a.entries.length===1?"":"s"]})]}),j("div",{className:"grid gap-2",children:a.entries.map(f=>q("article",{className:rt("rounded-2xl px-3 py-2 text-sm",f.parentId==null?"bg-[var(--ald-surface-muted,#f8fafc)] text-[var(--ald-text,#334155)]":"bg-slate-100/80 text-slate-600"),children:[q("div",{className:"flex items-center justify-between gap-3",children:[j("strong",{className:"text-[11px] uppercase tracking-[0.12em] text-[var(--ald-text-muted,#94a3b8)]",children:f.parentId==null?"Thread":"Reply"}),j("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:f.authorName??f.authorId??"Unknown"})]}),j("p",{children:f.text||"Empty entry"})]},f.id))}),q("div",{className:"flex flex-wrap gap-2",children:[u?j("button",{type:"button",disabled:s?!s.toggleInternal.allowed:!1,title:s?.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:()=>u(a.id,!a.isInternal),children:a.isInternal?"Mark External":"Mark Internal"}):null,j("button",{type:"button",disabled:s?!s.reply.allowed:!1,title:s?.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:()=>c?.(a.id),children:"Reply"}),a.resolved?j("button",{type:"button",disabled:s?!s.reopen.allowed:!1,title:s?.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:()=>m?.(a.id),children:"Reopen"}):j("button",{type:"button",disabled:s?!s.resolve.allowed:!1,title:s?.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:()=>d?.(a.id),children:"Resolve"}),v?j("button",{type:"button","data-comment-action":"delete",disabled:s?!s.remove.allowed:!1,title:s?.remove.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:()=>v(a.id),children:"Delete"}):null]})]},a.id)})]})]})}import{useEffect as ka,useRef as Ca}from"react";import{registerPaginatedUiSurface as Ra}from"@datalking/begonia-layout-renderer";import{Fragment as wa,jsx as ot,jsxs as ha}from"react/jsx-runtime";var to=[{id:"align-left",value:"left",label:"Align left",glyph:"\u2BC7"},{id:"align-center",value:"center",label:"Align center",glyph:"\u2261"},{id:"align-right",value:"right",label:"Align right",glyph:"\u2BC8"},{id:"align-justify",value:"justify",label:"Align justify",glyph:"\u2630"}];function ba(e){return e?e.mixed?"mixed":e.active:!1}function Dt({snapshot:e,execute:t}){let r=n=>e?.commands?.[n]??null,o=to.every(n=>r(n.id)?.disabled===!0);return ha(wa,{children:[to.map(n=>{let i=r(n.id);return ot(O,{ariaLabel:n.label,title:n.label,pressed:ba(i),disabled:i?i.disabled:o,onClick:()=>t(n.id),children:n.glyph},n.id)}),ot(V,{}),ot(O,{ariaLabel:"Decrease indent",title:"Decrease indent",disabled:r("indent-decrease")?.disabled??o,onClick:()=>t("indent-decrease"),children:"\u21E4"}),ot(O,{ariaLabel:"Increase indent",title:"Increase indent",disabled:r("indent-increase")?.disabled??o,onClick:()=>t("indent-increase"),children:"\u21E5"})]})}import{Fragment as Sa,jsx as _t,jsxs as Ta}from"react/jsx-runtime";var xa=[{id:"insert-table",label:"Insert table",glyph:"\u25A6"},{id:"insert-image",label:"Insert image",glyph:"\u{1F5BC}"}],Pa=[{id:"table-insert-row-above",label:"Insert row above",glyph:"\u2912"},{id:"table-insert-row-below",label:"Insert row below",glyph:"\u2913"},{id:"table-insert-column-left",label:"Insert column left",glyph:"\u21E4"},{id:"table-insert-column-right",label:"Insert column right",glyph:"\u21E5"},{id:"table-delete-row",label:"Delete row",glyph:"\u2421"},{id:"table-delete-column",label:"Delete column",glyph:"\u232B"},{id:"table-delete",label:"Delete table",glyph:"\u{1F5D1}"}],ya=[{id:"table-merge-cells",label:"Merge cells",glyph:"\u29C9"},{id:"table-split-cell",label:"Split cell",glyph:"\u29C8"}];function Ht({snapshot:e,execute:t}){let r=n=>e?.commands?.[n]??null,o=n=>{let i=r(n.id);return _t(O,{ariaLabel:n.label,title:n.label,disabled:i?i.disabled:!0,onClick:()=>t(n.id),children:n.glyph},n.id)};return Ta(Sa,{children:[xa.map(o),_t(V,{}),Pa.map(o),_t(V,{}),ya.map(o)]})}var 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"}];function ro(e){let t=e?.trim().toLowerCase()??"";return!t||Ft.some(r=>r.value===t)?Ft:[{value:t,label:t,swatch:t},...Ft]}function oo(e){let t=e.trim().toLowerCase();return t.length>0?t:null}import{Fragment as Se,jsx as P,jsxs as W}from"react/jsx-runtime";var no=typeof navigator<"u"&&typeof navigator.platform=="string"&&/mac/i.test(navigator.platform)?"Cmd":"Ctrl",jt=[{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"}],Ea=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],$t=[{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"}],io=[{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 Ia(e){let t=io.find(r=>e(r.command)?.active===!0);return t?t.command:""}function La(e){let t=[...Ea];return e!=null&&!t.includes(e)&&(t.push(e),t.sort((r,o)=>r-o)),t.map(r=>String(r))}function Ut({editorHost:e,controller:t=null,linkActions:r=null,leadingActions:o=null,trailingActions:n=null,showTrackingToggle:i=!0,showSelectionReviewActions:l=!0,showRichFormatControls:u=!0,showBlockControls:c=!0,showInsertControls:d=!1,onInsertImage:m,surfaceId:v}){let{controller:a,snapshot:s}=Bt(e,t);function f(h,$){return a.execute(h,$)}function g(h){return s.commands[h]??null}function b(h,$){if(h==="link-set"||h==="link-clear"){if(!r){if(h==="link-set"){let _=g("link-set"),X=typeof _?.value=="string"?String(_.value):"",H=typeof window<"u"?window.prompt($??"Enter link URL",X):null;if(!H)return;f(h,{href:H});return}f(h);return}let z=r.captureEffectiveSelectionHandle({includeText:!0});if(!z)return;try{if(h==="link-set"){let _=g("link-set"),X=typeof _?.value=="string"?String(_.value):"",H=typeof window<"u"?window.prompt($??"Enter link URL",X):null;if(!H)return;r.setLinkFromHandle(z,H);return}r.clearLinkFromHandle(z)}finally{r.releaseSelectionHandle(z)}return}f(h)}let p=s.selection?.formatting??null,w=s.selection==null,T=w?"":Ia(g),S=jt.some(h=>h.value===p?.fontFamily)?jt:[...jt,...p?.fontFamily?[{value:p.fontFamily,label:p.fontFamily}]:[]],D=p?.fontSize!=null?String(p.fontSize):"",L=Ca(null);ka(()=>{let h=L.current;if(h)return Ra(h,v)},[v]);let k=La(p?.fontSize??null),E=p?.color?.toLowerCase()??"",M=p?.highlight?.toLowerCase()??"";return W("div",{ref:L,className:"grid gap-3",role:"toolbar","aria-label":"Editor formatting toolbar",children:[o?P("div",{className:"flex flex-wrap gap-2",children:o}):null,W("div",{className:tt("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(O,{pressed:!1,disabled:g("undo")?.disabled,title:`Undo (${no}+Z)`,ariaLabel:"Undo",onClick:()=>b("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(O,{pressed:!1,disabled:g("redo")?.disabled,title:`Redo (${no}+Shift+Z)`,ariaLabel:"Redo",onClick:()=>b("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"})]})}),c?W(Se,{children:[P(V,{}),P(Dt,{snapshot:s,execute:f})]}):null,d?W(Se,{children:[P(V,{}),P(Ht,{snapshot:s,execute:h=>{if(h==="insert-image"&&m){m();return}f(h)}})]}):null,P(V,{}),P(Ne,{ariaLabel:"Paragraph style",title:"Paragraph style",value:T,disabled:w,widthClass:"w-32",options:[{value:"",label:"Style"},...io.map(h=>({value:h.command,label:h.label}))],onChange:h=>{h&&b(h)}}),u?W(Se,{children:[P(Ne,{ariaLabel:"Font family",title:"Font family",value:p?.mixed?.fontFamily?"":p?.fontFamily??"",disabled:w||g("font-family")?.disabled,widthClass:"w-36",options:p?.mixed?.fontFamily?[{value:"",label:"Multiple fonts"},...S.slice(1)]:S,onChange:h=>f("font-family",h||null)}),P(Ne,{ariaLabel:"Font size",title:"Font size (points)",value:p?.mixed?.fontSize?"":D,disabled:w||g("font-size")?.disabled,widthClass:"w-20",options:p?.mixed?.fontSize?["",...k].map(h=>({value:h,label:h||"Multiple"})):[{value:"",label:"Size"},...k.map(h=>({value:h,label:h}))],onChange:h=>f("font-size",h?Number(h):null)})]}):null,P(V,{}),P(O,{pressed:g("bold")?.mixed?"mixed":g("bold")?.active,disabled:g("bold")?.disabled,title:"Bold (Ctrl+B)",ariaLabel:"Bold",onClick:()=>b("bold"),children:P("span",{className:"font-bold",children:"B"})}),P(O,{pressed:g("italic")?.mixed?"mixed":g("italic")?.active,disabled:g("italic")?.disabled,title:"Italic (Ctrl+I)",ariaLabel:"Italic",onClick:()=>b("italic"),children:P("span",{className:"font-serif italic",children:"I"})}),P(O,{pressed:g("underline")?.mixed?"mixed":g("underline")?.active,disabled:g("underline")?.disabled,title:"Underline (Ctrl+U)",ariaLabel:"Underline",onClick:()=>b("underline"),children:P("span",{className:"underline",children:"U"})}),P(O,{pressed:g("strikethrough")?.mixed?"mixed":g("strikethrough")?.active,disabled:g("strikethrough")?.disabled,title:"Strikethrough",ariaLabel:"Strikethrough",onClick:()=>b("strikethrough"),children:P("span",{className:"line-through",children:"S"})}),u?W(Se,{children:[P(V,{}),P(Ne,{ariaLabel:"Text color",title:"Text color",value:p?.mixed?.color?"":E,disabled:w||g("text-color")?.disabled,widthClass:"w-32",options:ro(E),onChange:h=>f("text-color",oo(h))}),P(Ne,{ariaLabel:"Highlight color",title:"Highlight color",value:p?.mixed?.highlight?"":M,disabled:w||g("highlight-color")?.disabled,widthClass:"w-36",options:$t.some(h=>h.value===M)?$t:[{value:M,label:M,swatch:M},...$t],onChange:h=>f("highlight-color",h?h.toLowerCase():null)})]}):null,P(V,{}),W(O,{pressed:g("link-set")?.active,disabled:g("link-set")?.disabled,title:"Insert or edit a link",ariaLabel:"Insert link",onClick:()=>b("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(O,{pressed:!1,disabled:g("link-clear")?.disabled,title:"Remove link",ariaLabel:"Remove link",onClick:()=>b("link-clear"),children:"Unlink"}),i||l?W(Se,{children:[i?W(Se,{children:[P(V,{}),P(O,{pressed:s.trackingEnabled,title:"Toggle tracked changes",ariaLabel:"Track changes",onClick:()=>b("tracking-toggle"),children:"Tracking"})]}):null,l?W(Se,{children:[P(V,{}),W(O,{pressed:!1,disabled:g("track-changes-accept-selection")?.disabled,title:"Accept tracked change in selection",ariaLabel:"Accept tracked change in selection",onClick:()=>b("track-changes-accept-selection"),children:[P("span",{className:"text-emerald-600",children:"\u2713"})," Accept"]}),W(O,{pressed:!1,disabled:g("track-changes-reject-selection")?.disabled,title:"Reject tracked change in selection",ariaLabel:"Reject tracked change in selection",onClick:()=>b("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 Ba,useRef as Na}from"react";import{jsx as nt,jsxs as Ma}from"react/jsx-runtime";function Va(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 Wt({state:e}){let t=Na(null),r=e.context.host.overlays.closeContextMenu;return Ba(()=>{let o=i=>{t.current?.contains(i.target)||r?.()},n=i=>{i.key==="Escape"&&r?.()};return window.addEventListener("mousedown",o),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",n)}},[r]),nt("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:nt("div",{className:"grid gap-2",children:e.sections.map(o=>Ma("section",{className:"grid gap-1 border-b border-[var(--ald-border,#e2e8f0)] pb-2 last:border-b-0 last:pb-0",children:[o.label?nt("h3",{className:"px-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-[var(--ald-text-muted,#64748b)]",children:o.label}):null,o.items.map(n=>nt("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 ${Va(n.tone)}`,onClick:()=>{n.enabled&&(n.action(e.context),r?.())},children:n.label},n.id))]},o.id))})})}import{useEffect as ao,useRef as Aa}from"react";import{jsx as me,jsxs as zt}from"react/jsx-runtime";function Oa(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 Da(e){typeof navigator>"u"||!navigator.clipboard?.writeText||await navigator.clipboard.writeText(e)}function Gt({state:e}){let t=Aa(null),r=e.host.activeLink,o=e.host.overlays.closeLinkPopover;return ao(()=>{let n=l=>{t.current?.contains(l.target)||o?.()},i=l=>{l.key==="Escape"&&o?.()};return window.addEventListener("mousedown",n),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",i)}},[o]),ao(()=>{if(e.resolution.type!=="external"||!t.current)return;let n=e.resolution.render({container:t.current,closePopover:()=>o?.(),controller:r,href:e.href,title:e.title})??{};return()=>{n.destroy?.()}},[o,r,e]),e.resolution.type==="external"?me("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}}):me("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:zt("div",{className:"grid gap-3",children:[zt("div",{className:"grid gap-1",children:[me("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ald-text-muted,#64748b)]",children:"Link"}),me("code",{className:"break-all text-sm text-[var(--ald-text,#1e293b)]",children:e.href})]}),zt("div",{className:"flex flex-wrap gap-2",children:[me("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:()=>Oa(e),children:"Open"}),me("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:()=>Da(e.href),children:"Copy"}),me("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"}),me("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 re,jsxs as _a}from"react/jsx-runtime";function Kt({controller:e}){let t=A(e);if(!e||!t)return null;let{documentMode:r,trackChanges:o}=t,n=r==="viewing",i=o.enabled;return _a("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:"Mode"}),re(C,{active:r==="editing",label:"Edit",onClick:()=>e.setDocumentMode("editing")}),re(C,{active:r==="suggesting",disabled:!i,label:"Suggest",onClick:()=>e.setDocumentMode("suggesting")}),re(C,{active:n,label:"View",onClick:()=>e.setDocumentMode("viewing")}),re(V,{}),re("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Markup"}),re(C,{active:o.mode==="review",label:"Review",onClick:()=>e.setTrackChangesDisplayMode("review")}),re(C,{active:o.mode==="original",disabled:!n,label:"Original",onClick:()=>e.setTrackChangesDisplayMode("original")}),re(C,{active:o.mode==="final",disabled:!n,label:"Final",onClick:()=>e.setTrackChangesDisplayMode("final")}),re(C,{active:o.mode==="off",label:"Hide",onClick:()=>e.setTrackChangesDisplayMode("off")})]})}import{resolveBrowserViewIntentPatch as He,resolveBrowserViewIntentSnapshot as Ha,resolveBrowserViewLayoutMode as Fa,resolveBrowserViewZoomMode as ja,resolveBrowserZoomStep as so}from"@datalking/begonia-browser-sdk/editor";function lo(e){return e==="web"?"Sets the paginated layout that will be restored when you switch back to paged view.":void 0}import{jsx as K,jsxs as uo}from"react/jsx-runtime";var Fe=Object.freeze([50,75,100,125,150,200]);function Yt({controller:e}){let t=A(e);if(!e||!t?.zoom)return null;let r=Ha(t),{flowMode:o}=r,n=Fa(r),i=lo(o),l=t.zoom.percent,u=t.zoom.mode,c=t.zoom.viewportMetrics?.fitZoom??null;return uo("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:[K("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"View"}),K(C,{active:o==="web",label:"Web",onClick:()=>e.setViewState(He(r,{type:"flow",flowMode:"web"}))}),K(C,{active:o==="paginated",label:"Paged",onClick:()=>e.setViewState(He(r,{type:"flow",flowMode:"paginated"}))}),K(V,{}),K("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Layout"}),K(C,{active:n==="vertical",label:"Vertical",title:i,onClick:()=>e.setViewState(He(r,{type:"layout",layoutMode:"vertical"}))}),K(C,{active:n==="horizontal",label:"Horizontal",title:i,onClick:()=>e.setViewState(He(r,{type:"layout",layoutMode:"horizontal"}))}),K(C,{active:n==="book",label:"Book",title:i,onClick:()=>e.setViewState(He(r,{type:"layout",layoutMode:"book"}))}),K(V,{}),K("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Zoom"}),K(C,{active:u==="fit-width",label:c==null?"Fit":`Fit ${Math.round(c)}%`,onClick:()=>e.setZoomMode(ja({zoomMode:u})),title:c==null?"Fit to the measured preview width once the paginated preview is ready.":void 0}),K(C,{active:!1,disabled:l<=(Fe[0]??l),label:"\u2212",onClick:()=>e.setViewState({zoomPercent:so(l,Fe,-1)})}),uo("span",{className:"min-w-11 text-center text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",children:[Math.round(l),"%"]}),K(C,{active:u==="manual"&&l===100,label:"100%",onClick:()=>e.setViewState({zoomPercent:100})}),K(C,{active:!1,disabled:l>=(Fe[Fe.length-1]??l),label:"+",onClick:()=>e.setViewState({zoomPercent:so(l,Fe,1)})})]})}import{jsx as oe,jsxs as ne}from"react/jsx-runtime";function co(...e){return e.filter(Boolean).join(" ")}function $a(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function po(e){return!!(e.relatedKinds?.includes("insert")&&e.relatedKinds?.includes("delete"))}function Xt({revisions:e,permissionsByRevisionId:t,activeRevisionId:r=null,onAcceptRevision:o,onRejectRevision:n,onRevealRevision:i,onAcceptAll:l,onRejectAll:u}){let c=e.every(m=>t?.[m.id]?.accept.allowed??!0),d=e.every(m=>t?.[m.id]?.reject.allowed??!0);return ne("aside",{className:"grid gap-3","aria-label":"Review panel",children:[ne("header",{className:"flex items-end justify-between gap-3",children:[ne("div",{children:[oe("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review"}),ne("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," pending revision",e.length===1?"":"s"]})]}),e.length>0?ne("div",{className:"flex gap-2",children:[oe("button",{type:"button",disabled:!c,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"}),oe("button",{type:"button",disabled:!d,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,children:"Reject all"})]}):null]}),ne("div",{className:"grid gap-3",children:[e.length===0?oe("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(m=>{let v=t?.[m.id],a=r===m.id;return ne("section",{className:co("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",a?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[ne("div",{className:"flex items-center justify-between gap-3",children:[oe("span",{className:co("rounded-full px-2 py-1 text-[11px] font-semibold",po(m)?"bg-amber-100 text-amber-700":m.kind==="insert"?"bg-emerald-100 text-emerald-700":m.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"),children:po(m)?"Replace":$a(m.kind)}),oe("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:m.authorName||m.authorId})]}),oe("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:m.text||"Formatting change"}),m.prompt?ne("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",m.prompt]}):null,ne("div",{className:"flex gap-2",children:[i?oe("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(m),children:"Reveal"}):null,oe("button",{type:"button",disabled:v?!v.accept.allowed:!1,title:v?.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:()=>o?.(m.id),children:"Accept"}),oe("button",{type:"button",disabled:v?!v.reject.allowed:!1,title:v?.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?.(m.id),children:"Reject"})]})]},m.id)})]})]})}import{jsx as I,jsxs as R}from"react/jsx-runtime";function fe(...e){return e.filter(Boolean).join(" ")}function Ua(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 Wa(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function mo(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function za(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function qt(e,t){return e.relatedKinds.includes(t)||e.revision.kind===t}function Zt(e){if(!e)return"Unknown time";let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Ga(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 Ka(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 Ya(e){return e.deleted?"Deleted":e.resolved?"Resolved":"Open"}function Xa(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 qa(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 Jt({timeline:e,summary:t=null,activeCommentId:r=null,activeRevisionId:o=null,onSelectComment:n,onReplyComment:i,onResolveComment:l,onReopenComment:u,onAcceptRevision:c,onRejectRevision:d,onRevealRevision:m}){let v=t??{total:e.length,revisions:e.filter(a=>a.kind==="revision").length,insertions:e.filter(a=>a.kind==="revision"&&qt(a,"insert")).length,deletions:e.filter(a=>a.kind==="revision"&&qt(a,"delete")).length,formatting:e.filter(a=>a.kind==="revision"&&qt(a,"format")).length,commentThreads:e.filter(a=>a.kind==="comment-thread").length,openCommentThreads:e.filter(a=>a.kind==="comment-thread"&&!a.resolved&&!a.deleted).length,resolvedCommentThreads:e.filter(a=>a.kind==="comment-thread"&&a.resolved&&!a.deleted).length,deletedCommentThreads:e.filter(a=>a.kind==="comment-thread"&&a.deleted).length,commentReplies:e.filter(a=>a.kind==="comment-reply").length,commentEdits:e.filter(a=>a.kind==="comment-edit").length,commentStatusChanges:e.filter(a=>a.kind==="comment-status").length,commentVisibilityChanges:e.filter(a=>a.kind==="comment-visibility").length,commentRemovals:e.filter(a=>a.kind==="comment-removal").length};return R("aside",{className:"grid gap-3","aria-label":"Review timeline panel",children:[I("header",{className:"grid gap-1",children:R("div",{className:"flex items-end justify-between gap-3",children:[R("div",{children:[I("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review Timeline"}),R("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[v.total," review item",v.total===1?"":"s"]})]}),R("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-[var(--ald-text-muted,#64748b)]",children:[R("span",{children:[v.revisions," revision",v.revisions===1?"":"s"]}),R("span",{children:[v.openCommentThreads," open thread",v.openCommentThreads===1?"":"s"]}),R("span",{children:[v.commentReplies," repl",v.commentReplies===1?"y":"ies"]})]})]})}),R("div",{className:"grid gap-3",children:[e.length===0?I("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(a=>{if(a.kind==="revision"){let b=a.permissions,p=o===a.revisionId;return R("section",{className:fe("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",p?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[R("div",{className:"flex items-center justify-between gap-3",children:[I("span",{className:fe("rounded-full px-2 py-1 text-[11px] font-semibold",mo(a)?"bg-amber-100 text-amber-700":Ua(a.revision.kind)),children:mo(a)?"Replace":Wa(a.revision.kind)}),I("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:a.authorName??a.authorId??"Unknown"})]}),I("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:a.text||"Formatting change"}),a.excerpt?R("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",a.excerpt]}):null,a.revision.prompt?R("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",a.revision.prompt]}):null,I("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:Zt(a.sortAt)}),R("div",{className:"flex gap-2",children:[m?I("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:()=>m(a),children:"Reveal"}):null,I("button",{type:"button",disabled:b?!b.accept.allowed:!1,title:b?.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:()=>c?.(a.revisionId),children:"Accept"}),I("button",{type:"button",disabled:b?!b.reject.allowed:!1,title:b?.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:()=>d?.(a.revisionId),children:"Reject"})]})]},a.id)}if(a.kind==="revision-decision"){let b=a.decision==="accept",p=za(a),w=o===a.revisionId,T=p?`${b?"Accepted":"Rejected"} Replace`:a.relatedKinds.includes("format")?`${b?"Accepted":"Rejected"} Format`:`${b?"Accepted":"Rejected"} ${a.revisionKind==="delete"?"Delete":"Insert"}`;return R("section",{className:fe("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",w?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[R("div",{className:"flex items-center justify-between gap-3",children:[I("span",{className:fe("rounded-full px-2 py-1 text-[11px] font-semibold",b?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700"),children:T}),I("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:a.authorName??a.authorId??"Unknown"})]}),I("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:a.text}),a.excerpt?R("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",a.excerpt]}):null,R("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[Zt(a.sortAt)," \xB7 ",a.memberCount," member",a.memberCount===1?"":"s"]}),m?I("div",{className:"flex gap-2",children:I("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:()=>m(a),children:"Reveal"})}):null]},a.id)}let s=a.threadPermissions,f=r===a.commentId,g=!a.deleted;return R("section",{className:fe("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:[R("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>n?.(a.commentId),children:[R("div",{className:"flex items-center justify-between gap-3",children:[R("div",{className:"flex items-center gap-2",children:[I("span",{className:fe("rounded-full px-2 py-1 text-[11px] font-semibold",Ka(a)),children:Ga(a)}),I("span",{className:fe("rounded-full px-2 py-1 text-[11px] font-semibold",a.deleted?"bg-rose-100 text-rose-700":a.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:Ya(a)}),I("span",{className:fe("rounded-full px-2 py-1 text-[11px] font-semibold",a.internal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:a.internal?"Internal":"External"})]}),I("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:a.authorName??a.authorId??"Unknown"})]}),I("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:a.text||"Empty comment"}),a.target?.text?R("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",a.target.text]}):null,R("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[Zt(a.sortAt)," \xB7 ",Xa(a)," \xB7"," ",qa(a)]})]}),R("div",{className:"flex flex-wrap gap-2",children:[I("button",{type:"button",disabled:!g||(s?!s.reply.allowed:!1),title:s?.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?.(a.commentId),children:"Reply"}),a.deleted?null:a.resolved?I("button",{type:"button",disabled:s?!s.reopen.allowed:!1,title:s?.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:()=>u?.(a.commentId),children:"Reopen"}):I("button",{type:"button",disabled:s?!s.resolve.allowed:!1,title:s?.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:()=>l?.(a.commentId),children:"Resolve"})]})]},a.id)})]})]})}import{Fragment as ol,jsx as Y,jsxs as je}from"react/jsx-runtime";function Ja(...e){return e.filter(Boolean).join(" ")}var fo={linkPopover:null,contextMenu:null};function Qa(e){return Za(t=>e?.overlayState.subscribe(t)??(()=>{}),()=>e?.overlayState.getSnapshot()??fo,()=>fo)}function el(e){return e?e===!0?{enabled:!0,projection:void 0}:{...e,enabled:e.enabled??!0}:null}function tl(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 rl({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:o,paginatedPreview:n,showToolbar:i=!0,showRichFormatControls:l=!0,showViewControls:u=!0,showReviewControls:c=!0,showComments:d=!0,showCommentDisplayControls:m=!0,showReview:v=!0,showReviewTimeline:a=!0,sidebarStart:s=null,theme:f,className:g}){let{hostRef:b,ui:p,snapshot:w}=Lt({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:o}),T=Qa(p),S=p?.preview.readLayoutAdapter()??null,D=p?.preview.readLayoutSource()??null,L=el(n),k=L?.enabled??!1,E=!!s||a||d||v,M=L?.projection??null,{enabled:h,...$}=L??{},z=w?.comments.activeCommentId??null,_=y=>{let B=typeof window<"u"?window.prompt("Reply to comment"):null;!B||!p||p.comments.reply(y,B)},X=tl(w),H=X==null,F=y=>{p&&p.comments.reveal(y)},ge=()=>{if(!p||!H)return;let y=typeof window<"u"?window.prompt("New comment"):null;if(!y)return;let B=p.comments.create(y)},ie=y=>{p&&p.trackChanges.reveal(y)},G=he(f,{fontFamily:'var(--ald-font-ui, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif)'});return je("div",{className:Ja("grid gap-4",g),"data-begonia-theme":G["data-begonia-theme"],style:G.style,children:[i?Y(Ut,{editorHost:p?.session??null,controller:p,showRichFormatControls:l,trailingActions:je(ol,{children:[u?Y(Yt,{controller:p?.view??null}):null,c?Y(Kt,{controller:p?.documentMode??null}):null]})}):null,je("div",{className:k?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:[Y("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:Y("div",{className:"editor-frame",children:Y("div",{ref:b,className:"editor-host"})})}),k?Y("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:Y(eo,{...$,resolveCommentState:$.resolveCommentState??Mt(w,z),theme:$.theme??f,editor:p,adapter:M?void 0:S??void 0,source:D})}):null,E?je("div",{className:"grid gap-4",children:[s,a?Y(Jt,{timeline:w?.review.timeline??[],summary:w?.review.summary??null,activeCommentId:z,activeRevisionId:w?.review.activeRevisionId??null,onSelectComment:F,onReplyComment:_,onResolveComment:y=>p?.comments.resolve(y),onReopenComment:y=>p?.comments.reopen(y),onAcceptRevision:y=>p?.reviewActions.acceptRevision(y),onRejectRevision:y=>p?.reviewActions.rejectRevision(y),onRevealRevision:ie}):null,d?je("div",{className:"grid gap-3",children:[m?Y(At,{controller:p?.commentsDisplay??null}):null,Y(Ot,{comments:w?.comments.items??[],permissionsByCommentId:w?.comments.permissions??{},activeCommentId:z,canCreateComment:H,createCommentDisabledReason:X,onCreateComment:p?ge:void 0,onSelectComment:F,onToggleCommentInternal:(y,B)=>p?.comments.setInternal(y,B),onReplyComment:_,onResolveComment:y=>p?.comments.resolve(y),onReopenComment:y=>p?.comments.reopen(y)})]}):null,v?Y(Xt,{revisions:w?.review.revisions??[],permissionsByRevisionId:w?.review.permissions??{},activeRevisionId:w?.review.activeRevisionId??null,onAcceptRevision:y=>p?.reviewActions.acceptRevision(y),onRejectRevision:y=>p?.reviewActions.rejectRevision(y),onAcceptAll:()=>p?.reviewActions.acceptAll(),onRejectAll:()=>p?.reviewActions.rejectAll(),onRevealRevision:ie}):null]}):null]}),T.linkPopover?Y(Gt,{state:T.linkPopover}):null,T.contextMenu?Y(Wt,{state:T.contextMenu}):null]})}import{createPdfViewerController as Ac}from"@datalking/begonia-pdf-viewer";export{he as a,A as b,at as c,ir as d,lt as e,Lo as f,st as g,Bo as h,dt as i,No as j,ct as k,ze as l,pt as m,si as n,di as o,St as p,Rt as q,It as r,Oi as s,Lt as t,Jr as u,Bt as v,Ui as w,Wi as x,zi as y,Gi as z,Ki as A,Yi as B,Xi as C,qi as D,Zi as E,Ji as F,Qi as G,ea as H,ta as I,Bd as J,Nd as K,eo as L,Mt as M,C as N,tt as O,O as P,V as Q,At as R,Ot as S,Dt as T,Ht as U,ro as V,oo as W,Ut as X,Wt as Y,Gt as Z,Kt as _,Yt as $,Xt as aa,Jt as ba,rl as ca,Ac as da};