@docx-editor.dev/pro 2.27.0 → 2.28.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 (84) hide show
  1. package/dist/chunk-CNXDNDD3.js +1 -0
  2. package/dist/{chunk-PVRTSPHN.cjs → chunk-FD2KDBHX.cjs} +1 -1
  3. package/dist/chunk-JRHEYVVY.cjs +1 -0
  4. package/dist/chunk-L567WP3J.js +5 -0
  5. package/dist/chunk-MJECUVHQ.cjs +5 -0
  6. package/dist/chunk-MWO2ZUEJ.js +1 -0
  7. package/dist/chunk-N34IUO36.cjs +1 -0
  8. package/dist/chunk-OT5R3IYV.cjs +1 -0
  9. package/dist/chunk-P2EF7WMV.js +1 -0
  10. package/dist/chunk-Q5JTCGJI.js +1 -0
  11. package/dist/chunk-SNQCYZLT.js +1 -0
  12. package/dist/chunk-ZSAAX6HV.cjs +1 -0
  13. package/dist/collaboration/hocuspocus.cjs +1 -1
  14. package/dist/collaboration/hocuspocus.d.cts +18 -11
  15. package/dist/collaboration/hocuspocus.d.ts +18 -11
  16. package/dist/collaboration/hocuspocus.js +1 -1
  17. package/dist/collaboration/index.cjs +2 -2
  18. package/dist/collaboration/index.d.cts +333 -18
  19. package/dist/collaboration/index.d.ts +333 -18
  20. package/dist/collaboration/index.js +2 -2
  21. package/dist/collaboration/webrtc.cjs +2 -2
  22. package/dist/collaboration/webrtc.d.cts +26 -3
  23. package/dist/collaboration/webrtc.d.ts +26 -3
  24. package/dist/collaboration/webrtc.js +2 -2
  25. package/dist/{collaboration-module-DlSv0oAd.d.cts → collaboration-module-DWn2heE1.d.cts} +1 -0
  26. package/dist/{collaboration-module-DlSv0oAd.d.ts → collaboration-module-DWn2heE1.d.ts} +1 -0
  27. package/dist/{define-custom-node-DUJ4ZZdo.d.ts → define-custom-node-CNRQG1TI.d.cts} +12 -4
  28. package/dist/{define-custom-node-DG5gpRa5.d.cts → define-custom-node-D0c36PpZ.d.ts} +12 -4
  29. package/dist/document-session-3VC43WNI.cjs +1 -0
  30. package/dist/{document-session-BKKfJzKB.d.cts → document-session-Bxs4_GgX.d.ts} +55 -33
  31. package/dist/document-session-J2YKWERI.js +1 -0
  32. package/dist/{document-session-BQ4nBDTd.d.ts → document-session-_v9vqiSX.d.cts} +55 -33
  33. package/dist/document-session-options-CfKypp9c.d.cts +37 -0
  34. package/dist/document-session-options-DelOC7PX.d.ts +37 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.cts +29 -4
  37. package/dist/index.d.ts +29 -4
  38. package/dist/index.js +1 -1
  39. package/dist/react/hocuspocus.cjs +1 -1
  40. package/dist/react/hocuspocus.d.cts +52 -8
  41. package/dist/react/hocuspocus.d.ts +52 -8
  42. package/dist/react/hocuspocus.js +1 -1
  43. package/dist/react/index.cjs +2 -2
  44. package/dist/react/index.d.cts +354 -156
  45. package/dist/react/index.d.ts +354 -156
  46. package/dist/react/index.js +2 -2
  47. package/dist/react/webrtc.cjs +1 -1
  48. package/dist/react/webrtc.d.cts +35 -7
  49. package/dist/react/webrtc.d.ts +35 -7
  50. package/dist/react/webrtc.js +1 -1
  51. package/dist/{session-okdqygLg.d.cts → types-6EmrEn4n.d.cts} +26 -4
  52. package/dist/{session-okdqygLg.d.ts → types-6EmrEn4n.d.ts} +26 -4
  53. package/dist/{session-B-ds4k64.d.cts → types-BQ1vBt5Q.d.cts} +32 -54
  54. package/dist/{session-B-ds4k64.d.ts → types-BQ1vBt5Q.d.ts} +32 -54
  55. package/dist/vue/hocuspocus.cjs +1 -1
  56. package/dist/vue/hocuspocus.d.cts +52 -7
  57. package/dist/vue/hocuspocus.d.ts +52 -7
  58. package/dist/vue/hocuspocus.js +1 -1
  59. package/dist/vue/index.cjs +2 -2
  60. package/dist/vue/index.d.cts +235 -24
  61. package/dist/vue/index.d.ts +235 -24
  62. package/dist/vue/index.js +2 -2
  63. package/dist/vue/webrtc.cjs +1 -1
  64. package/dist/vue/webrtc.d.cts +36 -6
  65. package/dist/vue/webrtc.d.ts +36 -6
  66. package/dist/vue/webrtc.js +1 -1
  67. package/package.json +4 -4
  68. package/dist/chunk-6CDC4KCE.js +0 -4
  69. package/dist/chunk-6SR5OK66.cjs +0 -4
  70. package/dist/chunk-GDTCNTK7.cjs +0 -1
  71. package/dist/chunk-HJB77VBO.js +0 -1
  72. package/dist/chunk-HZEWGK5A.cjs +0 -4
  73. package/dist/chunk-Q4YPX2DT.cjs +0 -1
  74. package/dist/chunk-Q7P2DQ33.js +0 -1
  75. package/dist/chunk-RGR2BLZD.js +0 -4
  76. package/dist/chunk-W3V54DWZ.js +0 -1
  77. package/dist/document-session-32FPPQHT.js +0 -1
  78. package/dist/document-session-32ULDU2C.js +0 -1
  79. package/dist/document-session-HCU2O55L.cjs +0 -1
  80. package/dist/document-session-ZOM2KHHX.cjs +0 -1
  81. package/dist/hocuspocus-BMF7MTMJ.js +0 -1
  82. package/dist/hocuspocus-JPJOC6ZV.cjs +0 -1
  83. package/dist/webrtc-MM3LDVLU.cjs +0 -2
  84. package/dist/webrtc-RYONN7E7.js +0 -2
@@ -1,2 +1,2 @@
1
- import {j,e,c,q as q$1,k}from'../chunk-Q7P2DQ33.js';export{o as reviewModule}from'../chunk-Q7P2DQ33.js';import {b,a}from'../chunk-HJB77VBO.js';export{b as collaborationModule}from'../chunk-Q2VBO66F.js';import {createContext,useMemo,useEffect,useCallback,useRef,useContext,useSyncExternalStore,useState,isValidElement,cloneElement,useId,Children,Fragment as Fragment$1}from'react';import {useDocxEditor,useEditorState,useTranslation,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useReviewAuthors,Slot,notificationYieldsToTask,useContextMenuTarget,ContextMenuItem,DocxEditorRoot}from'@docx-editor.dev/react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import {safeParticipantColor}from'@docx-editor.dev/core/collaboration';import {customNodePayloadsByControl}from'@docx-editor.dev/core/store';import {partOfNodeId}from'@docx-editor.dev/core/editor';var dn=new Set(["List","Markers","AddComment","Draft","Balloon"]),mn=new Set(["Card","Empty"]);function ke(e,t){let n=t==="root"?dn:mn,o={},a=[],r=s=>{if(Array.isArray(s)){for(let l of s)r(l);return}if(!isValidElement(s)){s!=null&&s!==false&&a.push(s);return}if(s.type===Fragment$1){r(s.props.children);return}let i=s.type.docxReviewPart;i&&n.has(i)?o[i]=s:a.push(s);};return r(e),{parts:o,rest:a}}function at(e,t){if(!t)return e;let n=e.props.className;return cloneElement(e,{className:`${t}${n?` ${n}`:""}`})}var fn={scale:96/72,top:0,left:null,compactCardLeft:null},vn=16,we=300,pn=12,De=600;function eo(e,t,n,o,a=false){let[r,s]=useState(fn);return useEffect(()=>{let i=t.current;if(!e||!i)return;let l=i.offsetParent,c=l?.querySelector(".docx-paginated-surface")??null,m=()=>{s(p=>{let y=c&&l?c.getBoundingClientRect():null,b=y&&l?l.getBoundingClientRect():null,C=y&&b&&l?y.right-b.left-l.clientLeft+l.scrollLeft+vn:null,w={scale:e.getRenderScale(),top:y&&b&&l?y.top-b.top-l.clientTop+l.scrollTop:0,left:C,compactCardLeft:C===null||!l?null:l.scrollLeft+l.clientWidth-C-we-pn};return p.scale===w.scale&&p.top===w.top&&p.left===w.left&&p.compactCardLeft===w.compactCardLeft?p:w});};m();let d=new ResizeObserver(m);if(l&&d.observe(l),c&&d.observe(c),!a||!l)return ()=>d.disconnect();let f=0,u=()=>{f===0&&(f=requestAnimationFrame(()=>{f=0,m();}));};return l.addEventListener("scroll",u,{passive:true}),()=>{f!==0&&cancelAnimationFrame(f),l.removeEventListener("scroll",u),d.disconnect();}},[e,t,n,o,a]),r}function to(e,t,n){let[o,a]=useState(null);return useEffect(()=>{let r=t.current,s=r?.offsetParent;if(!s)return;let i=0,l=()=>{i=0,a(f=>{let u=s.scrollTop-De,p=s.scrollTop+s.clientHeight+De;return f&&f.top===u&&f.bottom===p?f:{top:u,bottom:p}});},c=0,m=()=>{i===0&&(i=requestAnimationFrame(l)),r?.setAttribute("data-scrolling",""),window.clearTimeout(c),c=window.setTimeout(()=>r?.removeAttribute("data-scrolling"),150);};l(),s.addEventListener("scroll",m,{passive:true});let d=new ResizeObserver(m);return d.observe(s),()=>{i!==0&&cancelAnimationFrame(i),window.clearTimeout(c),s.removeEventListener("scroll",m),d.disconnect();}},[e,t,n]),o}function oo(e){let t=useRef(new WeakMap),n=useRef(new Map),o=useRef(null),a=useCallback((r,s)=>{let i=n.current.get(s);if(!r){i&&(o.current?.unobserve(i),t.current.delete(i),n.current.delete(s));return}typeof ResizeObserver>"u"||(e(s,r.offsetHeight),o.current??=new ResizeObserver(l=>{for(let c of l){let m=t.current.get(c.target);m&&e(m,c.target.offsetHeight);}}),!(i===r&&t.current.get(r)===s)&&(i&&(o.current.unobserve(i),t.current.delete(i)),t.current.set(r,s),n.current.set(s,r),o.current.observe(r)));},[e]);return useEffect(()=>()=>{o.current?.disconnect(),n.current.clear();},[]),a}function Cn(e){let t=false;return ()=>{if(!t){if(!notificationYieldsToTask()){e();return}t=true,setTimeout(()=>{t=false,e();},0);}}}function hn(e){let t=e.snapshot?.();return JSON.stringify(t?.hiddenReviewAuthors??[])}function Te(e){let t=useDocxEditor();return no(t,e)}function no(e,t){let n=useCallback(w=>{if(!e)return ()=>{};let h=false,D=Cn(()=>{h||w();}),E=e.on("change",D),x=e.on("selectionChange",D),_=e.on("error",D);return ()=>{h=true,E(),x(),_();}},[e]),o=useSyncExternalStore(n,()=>e?`${e.getReviewRevision()}:${e.getEditingMode()}:${hn(e)}`:"none",()=>"none"),a=useMemo(()=>e?e.getReviewItems(t).filter(w=>w.item.kind!=="custom"||w.item.carded):[],[e,o,t]),r=useMemo(()=>a.find(w=>w.isActive)?.key??null,[a]),s=useCallback((w,h)=>e?e.setActiveReviewItem(w,h).ok:false,[e]),i=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.acceptReviewItem(w.key).ok,[e]),l=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.rejectReviewItem(w.key).ok,[e]),c=useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,true).ok,[e]),m=useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,false).ok,[e]),d=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,f=useCallback(w=>!e||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:e.deleteReviewItem(w.key).ok,[e]),u=useCallback((w,h,D)=>h.trim().length===0||!e?false:e.replyToReviewItem(w.key,h,D).ok,[e]),p=useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,o]),y=useCallback((w,h)=>w.trim().length===0||!e?false:e.addComment(w,h).ok,[e]),b=useMemo(()=>e?e.isReviewPaneOpen():true,[e,o]),C=useCallback(w=>{!e||e.isReviewPaneOpen()===w||e.exec({type:"toggleReviewPane"});},[e]);return useMemo(()=>({items:a,activeKey:r,setActive:s,accept:i,reject:l,resolve:c,reopen:m,commentResolutionDisabledReason:d,remove:f,reply:u,selectionAnchorY:p,comment:y,paneOpen:b,setPaneOpen:C,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[a,r,s,i,l,c,m,d,f,u,p,y,b,C,e])}function xn(e,t,n={}){let o=n.gap??8,a=n.scale??1,r=n.defaultHeight??0;return useMemo(()=>{let s=new Map,i=Number.NEGATIVE_INFINITY;for(let l of e){let c=l.anchorY===null?Number.isFinite(i)?i:0:Math.max(l.anchorY,i);s.set(l.key,c),i=c+((t.get(l.key)??r)+o)/a;}return s},[e,t,o,a,r])}var st=8;function lt(e,t){return e?.color??`var(--doc-review-author-${t%st})`}function le(e,t,n){return e?{"--doc-review-author-current":lt(t,n)}:{}}function ye(e,t){return (e?.slot??t)%st}function ro(e,t,n,o){let a=useRef(new Map);return useMemo(()=>{let r=new Map;for(let i of e)r.set(i.author,i);let s=[...t.map(i=>i.author),o?.getConfiguredAuthor()];for(let i of s){if(!i||r.has(i))continue;let l=n.get(i)??0,c=o?.getReviewAuthorStyle(i),m=c?.color??`var(--doc-review-author-${l%st})`,d=a.current.get(i),f=d!==void 0&&d.slot===l&&d.color===m&&d.style===c?d:{author:i,slot:l,color:m,...c?{style:c}:{}};a.current.set(i,f),r.set(i,f);}return r},[e,t,n,o])}var q=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),io="M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z",ao="M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",In="M880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Re="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",Le=()=>jsxs("span",{className:"docx-review__resolved-icon",children:[jsx("span",{className:"docx-review__resolved-comment",children:q(In)}),jsx("span",{className:"docx-review__resolved-tick",children:q(Re)})]}),so="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z",lo="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",co="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Nn="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",Pn="M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 78t85.5 30q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-341q0 86-61.5 133.5T486-160ZM80-520v-80h800v80H80Zm402-360q66 0 116 30t74 84l-88 38q-11-28-38.5-47T480-794q-42 0-72 19t-30 51q0 15 6 27t18 22H272q-6-13-9-27t-3-30q0-70 55-114t167-44Z",_n="M360-160q-83 0-141.5-58.5T160-360v-360q0-83 58.5-141.5T360-920q83 0 141.5 58.5T560-720v360q0 83-58.5 141.5T360-160Zm0-80q50 0 85-35t35-85v-360q0-50-35-85t-85-35q-50 0-85 35t-35 85v360q0 50 35 85t85 35Zm300 80q29 0 49.5-20.5T730-230q0-22-12.5-40T684-296l-64-32v-232l100 100q23 23 51.5 35.5T832-412v-80q-17 0-32-6.5T773-517L633-657q-12-12-27.5-17.5T573-680h-13v520h100ZM360-720Z",Sn="M580-360q-25 0-42.5-17.5T520-420v-160q0-25 17.5-42.5T580-640h160q25 0 42.5 17.5T800-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T720-320v-40H580Zm-360 0q-25 0-42.5-17.5T160-420v-160q0-25 17.5-42.5T220-640h160q25 0 42.5 17.5T440-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T360-320v-40H220Z";function uo(e){if(e.kind==="comment")return ao;if(e.kind==="custom")return e.item.icon??Sn;switch(e.revisionKind){case "insert":case "moveTo":return Nn;case "delete":case "moveFrom":return Pn;case "format":return _n;default:return ao}}function Tn(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function On(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=Tn(t[o],e[o]):o==="className"?n[o]=[e[o],t[o]].filter(Boolean).join(" "):o==="style"&&(n[o]={...e[o],...t[o]});return n}function vo(e){return e==="Enter"||e===" "}function Ln(e){return vo(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function fo(e){return e.type==="button"}function Kn(e,t){return e.type==="a"||t.href!=null}function $n(e,t,n,o){let a=r=>{typeof n=="function"&&n(r);};return {onClick:r=>{typeof e=="function"&&e(r),r.defaultPrevented||a(r),o&&r.preventDefault();},onKeyDown:r=>{if(typeof t=="function"&&t(r),!vo(r.key))return;r.defaultPrevented||a(r),o&&r.preventDefault();}}}function te({engineDisabled:e,disabledReason:t,slotProps:n,children:o}){let a=Children.only(o);if(!isValidElement(a))return null;let r=a.props,s=On(n,r);if(!e){if(!fo(a)){let i=$n(r.onClick,r.onKeyDown,n.onClick,Kn(a,r));s.onClick=i.onClick,s.onKeyDown=i.onKeyDown;}return cloneElement(a,s)}if(fo(a))s.disabled=true,delete s["aria-disabled"];else {delete s.disabled,s["aria-disabled"]=true,s["data-disabled"]="",s.tabIndex=-1,s.href=void 0,s.role===void 0&&(s.role="button");let i=s.onKeyDown;s.onKeyDown=l=>{Ln(l)||typeof i=="function"&&i(l);};}return t&&(s.title=t),s.onClick=i=>{i.preventDefault(),i.stopPropagation();},cloneElement(a,s)}var yo=createContext({key:null,open:()=>{},close:()=>{}});function Ro({items:e,children:t}){let[n,o]=useState(null);useEffect(()=>{n!==null&&!e.some(r=>r.key===n&&r.kind==="comment"&&r.resolved)&&o(null);},[e,n]);let a=useMemo(()=>({key:n,open:r=>o(r),close:()=>o(null)}),[n]);return jsx(yo.Provider,{value:a,children:t})}function ct(){return useContext(yo)}function bo({label:e,statusLabel:t,entryKey:n,onActivate:o,onDeactivate:a,children:r,...s}){let i=ct(),l=useRef(null);return useEffect(()=>{let c=m=>{let d=l.current;d?.open&&m.target instanceof Node&&!d.contains(m.target)&&(i.close(),a());};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[i,a]),jsxs("details",{ref:l,...s,open:i.key===n,onToggle:c=>{c.currentTarget.open?(i.open(n),o()):(i.close(),a());},children:[jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsx("span",{className:"docx-review__resolved-status",children:t}),Le()]}),r]})}function go(e){function t({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||c.resolved)return null;let d=m("comments.resolve"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-resolve","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.resolve(c);}};return a?jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsx("button",{...p,children:i??s??q(Re)})}t.docxReviewPart="Resolve";function n({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||!c.resolved)return null;let d=m("comments.reopen"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-reopen","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.reopen(c);}};return a?jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsx("button",{...p,children:i??s??q(so)})}return n.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:n}}function xo(e){function t({top:o=0,left:a=null,className:r,hidden:s}){let{review:i,endDraft:l,measure:c,readOnly:m,draftAuthor:d,draftAuthorInfo:f,draftAuthorSlot:u}=e.useRail(),p=e.useLabel(),[y,b]=useState(""),[C,w]=useState(false),h=useRef(null),D=useId();useEffect(()=>{m||h.current?.focus({preventScroll:true});},[]);let E=useCallback(()=>{if(m||y.trim().length===0)return;let x=i.comment(y.trim());w(!x),x&&(b(""),l());},[m,y,i,l]);return s?null:jsx("div",{className:`docx-review__slot${r?` ${r}`:""}${a===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:o,...a===null?{}:{left:a,width:we}},ref:x=>{c(x,e.composeKey);},children:jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...d?{"data-review-author":d,"data-review-author-slot":u}:{},style:le(d??void 0,f,u),children:jsxs("form",{className:"docx-review__reply-box",onSubmit:x=>{x.preventDefault(),E();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:D,children:p("comments.addComment")}),jsx("input",{id:D,ref:h,"data-testid":"review-draft-input",className:"docx-review__input",value:y,placeholder:p("comments.addComment"),readOnly:m,...C?{"aria-invalid":true}:{},onChange:x=>{m||(w(false),b(x.target.value));},onKeyDown:x=>{if(x.key==="Escape"){x.preventDefault(),l();return}m||x.key!=="Enter"||(x.preventDefault(),E());}}),jsxs("div",{className:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:l,children:p("common.cancel")}),jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:m||y.trim().length===0,title:m?p("editingMode.viewingHint"):void 0,children:p("common.comment")})]}),C?jsx("span",{className:"docx-review__refused",role:"alert",children:p("review.commentRefused")}):null]})})})}t.docxReviewPart="Draft";function n({className:o,hidden:a,children:r}){let{review:s,readOnly:i}=e.useRail(),l=e.useItem(),c=e.useLabel(),[m,d]=useState(""),[f,u]=useState(false),p=useId(),y=useCallback(()=>{if(!l||i||m.trim().length===0)return;let b=s.reply(l,m.trim());u(!b),b&&d("");},[l,i,m,s]);return a||!l||!l.isActive||l.kind==="comment"&&l.resolved?null:r?jsx(Fragment,{children:r}):jsxs("form",{className:`docx-review__reply-box${o?` ${o}`:""}`,onSubmit:b=>{b.preventDefault(),y();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:p,children:c("comments.replyPlaceholder")}),jsx("input",{id:p,"data-testid":"review-reply-input",className:"docx-review__input",value:m,placeholder:c("comments.replyPlaceholder"),readOnly:i,...f?{"aria-invalid":true,"data-refused":""}:{},onChange:b=>{i||(u(false),d(b.target.value));},onClick:b=>b.stopPropagation(),onKeyDown:b=>{i||b.key!=="Enter"||(b.preventDefault(),y());}}),jsxs("div",{className:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:b=>{b.stopPropagation(),d(""),u(false),s.setActive(null);},children:c("common.cancel")}),jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__submit",disabled:i||m.trim().length===0,title:i?c("editingMode.viewingHint"):void 0,children:c("review.reply")})]}),f?jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:c("review.replyRefused")}):null]})}return n.docxReviewPart="Reply",{ReviewDraft:t,ReviewReply:n}}function ut(e,t,n=1){if(e==="paragraphMark"){let o=n>1;return t==="delete"?o?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?o?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?o?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":o?"revisions.paragraphMarksInserted":"revisions.paragraphMarkInserted"}switch(e){case "insert":return "review.inserted";case "delete":return "review.deleted";case "replace":return "review.replaced";case "moveFrom":return "review.movedFrom";case "moveTo":return "review.movedTo";case "format":return "revisions.runPropertiesChanged";default:return "review.structural"}}function jn(e){return ut(e.revisionKind,e.markDirection,e.ranges.length)}function zn(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function Ao(e,t){if(e.revisionKind==="structural"&&e.structuralChanges?.length)return e.structuralChanges.map(r=>t(`revisions.structuralDetails.${r}`)).join(", ");let n=`${t(jn(e))}${zn(e)}`;if(e.revisionKind!=="format")return n;let a=[...(e.formattingLanguages??[]).map(r=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(r).minimize().toString())??r}catch{return r}}),...(e.formattingChanges??[]).map(r=>Wn(r,t))];return a.length?`${n}: ${a.join(", ")}`:n}function Wn(e,t){let{property:n,value:o}=e;if(o!==null&&(n==="bold"||n==="italic"||n==="strike"))return t(`revisions.formattingDetails.${o==="true"?n:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[n]}`);let a=o??t("revisions.formattingDetails.default");return o!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(n)?a=`${o} ${t("revisions.formattingDetails.points")}`:/^(left|center|right|both|start|end|none|single|double|auto)$/.test(o)?a=t(`revisions.formattingDetails.${o}`):n==="color"&&/^[0-9a-f]{6}$/i.test(o)&&(a=`#${o.toUpperCase()}`)),`${t(`revisions.formattingDetails.${n}`)}: ${a}`}function dt(e,t,n){let o=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=e.ownerDocument.defaultView?.innerHeight??1/0,s=Number(e.dataset.reviewStart??e.dataset.start),i=Number(e.dataset.reviewEnd??e.dataset.end);return {revisionId:e.dataset.revisionId,...e.dataset.formattingKind?{formattingKind:e.dataset.formattingKind}:{},author:e.dataset.reviewAuthor??"",...e.dataset.revisionDate!==void 0?{date:e.dataset.revisionDate}:{},...e.dataset.revisionKind!==void 0?{kind:e.dataset.revisionKind}:{},structuralSite:n,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(s)?{start:s}:{},...Number.isFinite(i)?{end:i}:{},left:a.left-o.left,top:a.top-o.top,bottom:a.bottom-o.top,above:a.bottom+220>r}}function Gn(e){return e==="format"||e==="structural"}function Eo(e,t,n){return e.kind!=="revision"||!Gn(e.revisionKind)?false:!(n&&t.some(o=>o.id===e.id))}function Io(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let n=t.item.addresses;if(n.length===0)return null;let o=new Set(n.map(r=>r.id)),a=t.item.formattingKind;for(let r of e.querySelectorAll("[data-revision-id]")){if(!(r instanceof HTMLElement))continue;let s=r.dataset.revisionId;if(!s||!o.has(s)||!n.some(c=>c.id===s&&c.author===(r.dataset.reviewAuthor??"")&&(c.date??"")===(r.dataset.revisionDate??"")))continue;let l=r.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&r.dataset.revisionKind==="format"&&r.dataset.formattingKind===a)return r}return null}function No(e,t){let n=null,o=false,a=null,r=false,s=null,i=false;for(let l of t)if(!(l.kind!=="revision"||l.item.kind!=="revision")&&!(e.formattingKind&&l.item.formattingKind!==e.formattingKind)){for(let c of l.item.addresses)if(c.id===e.revisionId){if(c.author===e.author){if(c.date===e.date)return l;n===null?n=l:n!==l&&(o=true);}a===null?a=l:a!==l&&(r=true);}if(!(e.paragraphId===void 0||e.start===void 0||e.end===void 0||l.revisionKind!=="format"&&l.revisionKind!=="structural")){for(let c of l.item.ranges)if(c.start.paragraphId===e.paragraphId&&c.start.offset<e.end&&c.end.offset>e.start){s===null?s=l:s!==l&&(i=true);break}}}return n!==null&&!o?n:a!==null&&!r?a:s!==null&&!i?s:null}function Po(e){return e.kind==="revision"&&e.item.kind==="revision"&&e.revisionKind==="format"&&e.item.ranges.length>0&&(e.item.formattingKind==="rPrChange"||e.item.formattingKind==="pPrChange")}var ar=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,ir=e=>e.editingMode==="viewing",pt=createContext(null),P=createContext(null);function sr(){return useContext(P)}function lr(e){let{authorInfo:t}=H();return e===void 0?void 0:t.get(e)}var He="\0compose",cr=72,ur=64,dr=480,mr=30,fr=Object.freeze({placement:false});function wt(e,t){return e.kind!=="comment"?false:e.parentId!==void 0?t.has(e.parentId):e.parentRevisionId!==void 0?t.has(e.parentRevisionId):false}function yt(e){return new Set(e.map(t=>t.id))}function W(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function H(){let e=useContext(pt);return e||vr}function V(){let{t:e}=useContext(pt)??{},{t}=useTranslation();return useCallback(n=>e?.(n)??t(n),[e,t])}var{ReviewResolve:ko,ReviewReopen:Do}=go({useReview:()=>H().review,useItem:()=>useContext(P),useLabel:V,guardMousedown:W}),{ReviewDraft:To,ReviewReply:Oo}=xo({useRail:H,useItem:()=>useContext(P),useLabel:V,guardMousedown:W,composeKey:He}),vr={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,paneOpen:true,setPaneOpen:()=>{},ready:false},allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{}};function pr({className:e,furniture:t,asChild:n,hidden:o,children:a,t:r,card:s,preset:i=true,stack:l=true,gap:c=8,filter:m,structural:d=true,formatting:f=false}){let u=useDocxEditor(),p=useEditorState(ar),y=useEditorState(ir),b=useMemo(()=>{let R=[];return d||R.push("structural"),f||R.push("format"),R.length>0?R:void 0},[d,f]),C=useMemo(()=>({excludeRevisionKinds:b?.filter(R=>R!=="format")}),[b]);useEffect(()=>(u?.setReviewActivationExclusions(b??null,{formattingKinds:["rPrChange","pPrChange"]}),()=>u?.setReviewActivationExclusions(null)),[u,b]);let w=Te(fr),h=Te(C),D=h.setPaneOpen,{t:E}=useTranslation(),x=useCallback(R=>r?.(R)??E(R),[r,E]),_=useRef(null),U=useContext(ReviewRailContext);useEffect(()=>U?.register(),[U]);let L=h.paneOpen,G=useReviewGutter(),S=L&&G.inlineEnd>0&&G.inlineEnd<REVIEW_PANE_GUTTER,F=L&&!S,M=useMemo(()=>h.items.filter(R=>(f||!Po(R))&&(!m||m(R))),[h.items,m,f]),B=useSyncExternalStore(useCallback(R=>u?.on("selectionChange",R)??(()=>{}),[u]),()=>u?.getConfiguredAuthor()??null,()=>null),Ne=useMemo(()=>{let R=new Map;for(let g of M)g.author&&!R.has(g.author)&&R.set(g.author,R.size);return B&&!R.has(B)&&R.set(B,R.size),R},[M,B]),St=useMemo(()=>{let R=new Map;for(let g of M)R.set(g.id,g);return R},[M]),[Mt,Go]=useState(()=>new Map),Qo=useCallback((R,g)=>{g<=0||Go(I=>{if(I.get(R)===g)return I;let T=new Map(I);return T.set(R,g),T});},[]),kt=oo(Qo),N=eo(u,_,M,!p&&!o,S),fe=to(u,_,!p&&!o);useEffect(()=>{let R=_.current;if(!u||!R)return;let g=I=>{let T=I.target;if(!(T instanceof Node)||R.contains(T))return;let O=R.offsetParent;!O||!O.contains(T)||O.querySelector(".docx-paginated-surface")?.contains(T)||u.setActiveReviewItem(null);};return document.addEventListener("mousedown",g,true),()=>document.removeEventListener("mousedown",g,true)},[u,p,o]);let[j,Je]=useState(null),Xe=useRef(null),Q=useCallback(()=>{let R=Xe.current;R&&(R.editor.releaseSelection(R.pin),Xe.current=null);},[]),Pe=useCallback(()=>{if(!u||y)return;let R=u.getSelectionPlacement()?.anchorY??null;if(R===null)return;Q();let g=u.retainSelection();g&&(Xe.current={editor:u,pin:g},D(true),Je(R));},[u,y,Q,D]);useEffect(()=>{if(!(o||y))return U?.registerCommentDraft(Pe)},[Pe,o,y,U]);let Dt=useCallback(()=>{Q(),Je(null),u?.focus();},[u,Q]);useEffect(()=>Q,[Q]),useEffect(()=>{L||j===null||(Q(),Je(null));},[L,j,Q]);let et=j??h.selectionAnchorY,z=useMemo(()=>{let R=yt(M);return M.filter(g=>!wt(g,R))},[M]),Tt=useMemo(()=>{if(j===null)return z;let R=z.findIndex(I=>I.anchorY!==null&&I.anchorY>j),g={key:He,anchorY:j};return R===-1?[...z,g]:[...z.slice(0,R),g,...z.slice(R)]},[z,j]),Ot=useMemo(()=>{let R=new Map(Mt);for(let g of z){if(R.has(g.key))continue;let I=g.text.length+(g.kind==="revision"?g.replacedText?.length??0:0),T=Math.min(6,Math.max(1,Math.ceil(I/36)));R.set(g.key,64+T*20);}return R},[Mt,z]),{stacked:tt,collapsedKeys:Lt}=useMemo(()=>{let R=N.scale,g=new Map,I=new Set,T=Number.NEGATIVE_INFINITY;for(let O of Tt){let Me=O.anchorY===null?Number.isFinite(T)?T:0:Math.max(O.anchorY,T);g.set(O.key,Me);let on=O.anchorY===null?0:(Me-O.anchorY)*R,nn="isActive"in O&&O.isActive,Yt=on>dr&&!nn&&O.key!==He;Yt&&I.add(O.key);let rn=Yt?ur:Ot.get(O.key)??cr;T=Me+(rn+c)/R;}return {stacked:g,collapsedKeys:I}},[Tt,Ot,c,N.scale]),ot=et===null?null:N.top+(S?et:tt.get(He)??et)*N.scale,ve=s?.className,Jo=useReviewAuthors(),nt=ro(Jo,M,Ne,u),Kt=B?Ne.get(B)??0:0,$t=B?nt.get(B):void 0,Xo=useMemo(()=>({t:r,cardClassName:ve,readOnly:y,review:{...h,items:M},allItems:w.items,authorSlots:Ne,authorInfo:nt,draftAuthor:B,draftAuthorInfo:$t,draftAuthorSlot:Kt,byId:St,measure:kt,beginDraft:Pe,endDraft:Dt}),[r,ve,y,h,w.items,M,Ne,nt,B,$t,Kt,St,kt,Pe,Dt]);if(o||p)return null;let Ht={ref:_,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":M.length,"data-open":F?"":void 0,"data-compact":S?"":void 0,role:"region","aria-label":x("review.ariaLabel"),onMouseDown:W,style:N.left===null?void 0:{left:N.left,right:"auto"}},J=typeof a=="function"?{parts:{},rest:a}:ke(a,"root"),X=J.parts,pe=(R,g)=>{if(!(R in X))return g;let I=X[R];return !isValidElement(I)||!isValidElement(g)?I:cloneElement(I,{...g.props,...I.props})},qt=jsxs(Fragment,{children:[i||"AddComment"in X?pe("AddComment",jsx(bt,{top:ot,drafting:j!==null})):null,!L||j===null||ot===null||!i&&!("Draft"in X)?null:pe("Draft",jsx(To,{top:ot,left:S?N.compactCardLeft:null})),i||"Balloon"in X?pe("Balloon",jsx(gt,{})):null]}),en=jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe,children:J.rest}),Vt=jsx(Rt,{scale:N.scale,offset:N.top,window:fe}),ee=S?z.find(R=>R.key===h.activeKey)??null:null,Ut=ee===null?null:ee.anchorY!==null?N.top+ee.anchorY*N.scale:fe!==null?fe.top+De+24:null,_e=n?null:J.rest,Se=typeof _e=="function"?null:ke(_e,"list"),Ft=typeof _e=="function"?ee&&_e(ee):Se?.parts.Card&&isValidElement(Se.parts.Card)?at(Se.parts.Card,ve):i?jsx(Ve,{...ve?{className:ve}:{},children:Se?.rest}):null,Bt=ee&&Ut!==null&&N.compactCardLeft!==null&&Ft?jsx(P.Provider,{value:ee,children:jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:Ut,left:N.compactCardLeft,width:we},children:Ft})}):null,tn=F?i||"List"in X?pe("List",en):typeof J.rest=="function"?null:J.rest:i||"Markers"in X?jsxs(Fragment,{children:[pe("Markers",Vt),Bt]}):typeof J.rest=="function"?null:J.rest;return jsx(Ro,{items:M,children:jsx(pt.Provider,{value:Xo,children:n&&isValidElement(a)?jsx(Slot,{...Ht,children:cloneElement(a,void 0,a.props.children,i?F?jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe}):jsxs(Fragment,{children:[Vt,Bt]}):null,qt)}):jsxs("aside",{...Ht,children:[F&&t!==void 0?jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,tn,qt]})})})}function qe({stack:e=true,positions:t,collapsed:n,scale:o=1,offset:a=0,window:r=null,children:s,className:i,hidden:l}){let{review:c,measure:m,cardClassName:d}=H();if(l)return null;let f=typeof s=="function"?null:ke(s,"list"),u=yt(c.items),p=c.items.filter(y=>!wt(y,u));return p.length===0?typeof s=="function"?null:f?.parts.Empty??jsx(Ct,{}):jsx("div",{className:`docx-review__list${i?` ${i}`:""}`,children:p.map(y=>{let b=e?t?.get(y.key)??y.anchorY:y.anchorY,C=b==null?null:a+b*o;if(C!==null&&r&&(C<r.top||C>r.bottom))return null;let w=C===null?{}:{position:"absolute",top:C};return jsx(P.Provider,{value:y,children:jsx("div",{className:"docx-review__slot",style:w,...n?.has(y.key)?{"data-collapsed":""}:{},ref:h=>{m(h,y.key);},children:typeof s=="function"?s(y):f?.parts.Card&&isValidElement(f.parts.Card)?at(f.parts.Card,d):jsx(Ve,{...d?{className:d}:{},children:f?.rest})})},y.key)})})}qe.docxReviewPart="List";function Rt({scale:e=1,offset:t=0,window:n=null,className:o,hidden:a,icon:r}){let{review:s,authorSlots:i,authorInfo:l}=H(),c=ct(),m=V(),{roots:d,stackedTops:f}=useMemo(()=>{let u=yt(s.items),p=s.items.filter(C=>!wt(C,u)),y=new Map,b=Number.NEGATIVE_INFINITY;for(let C of p){if(C.anchorY===null)continue;let w=Math.max(t+C.anchorY*e,b);y.set(C.key,w),b=w+mr;}return {roots:p,stackedTops:y}},[s.items,t,e]);return a?null:jsx("div",{className:`docx-review__markers${o?` ${o}`:""}`,children:d.map(u=>{let p=f.get(u.key);return p===void 0||n&&(p<n.top||p>n.bottom)?null:jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":u.kind==="revision"?u.revisionKind:u.kind,...u.author?{"data-review-author":u.author,"data-review-author-slot":ye(l.get(u.author),i.get(u.author)??0)}:{},style:{position:"absolute",top:p,...u.author?{"--doc-review-author-current":lt(l.get(u.author),i.get(u.author)??0)}:{}},title:u.author?`${u.author}: ${u.text}`:u.text,"aria-label":`${m("review.showPane")}: ${u.author?`${u.author}. `:""}${u.text}`,onMouseDown:W,onClick:()=>{u.kind==="comment"&&u.resolved&&c.open(u.key),s.setPaneOpen(true),s.setActive(u.key);},children:(typeof r=="function"?r(u):r)??(u.kind==="comment"&&u.resolved?Le():q(uo(u)))},u.key)})})}Rt.docxReviewPart="Markers";function bt({top:e=null,drafting:t=false,className:n,hidden:o,children:a}){let{beginDraft:r,readOnly:s}=H(),i=V();if(o||t||e===null||s)return null;let l={type:"button",className:`docx-review__add${n?` ${n}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":i("common.comment"),title:i("common.comment"),onMouseDown:W,onClick:r};return a?jsx(Slot,{...l,children:a}):jsx("button",{...l,children:q(io)})}bt.docxReviewPart="AddComment";function gt({className:e,hidden:t}){let{review:n,allItems:o,authorSlots:a,authorInfo:r}=H(),s=V(),i=useRef(null),[l,c]=useState(null),m=useRef(null),d=useEditorState(E=>E.reviewDisplayMode??"all-markup");useEffect(()=>{m.current=null,c(null);},[d]);let f=o.find(E=>E.isActive)??null,u=useRef(f);u.current=f;let p=f?.key??null,y=f!==null&&Eo(f,n.items,n.paneOpen),b=useRef(false);b.current=l!==null,useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let U=(G,S)=>{m.current=null,c(dt(G,x,S));},L=G=>{let S=G.target;if(!(S instanceof Element)||E.contains(S))return;let F=S.closest("[data-revision-id]");if(F instanceof HTMLElement&&_.contains(F)){let M=F.classList.contains("docx-table-row--revision");if(F.dataset.revisionKind==="format"||M){U(F,M);return}}b.current&&(m.current=null,c(null));};return _.addEventListener("pointerdown",L,true),_.addEventListener("mousedown",L,true),()=>{_.removeEventListener("pointerdown",L,true),_.removeEventListener("mousedown",L,true);}},[]),useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let U=u.current;if(!U){m.current!==null&&(m.current=null,c(null));return}if(!y){m.current=null,c(null);return}m.current=U.key,c(null);let L=false,G=requestAnimationFrame(()=>{if(L)return;let S=Io(_,U);if(!S){c(null);return}c(dt(S,x,S.classList.contains("docx-table-row--revision")));});return ()=>{L=true,cancelAnimationFrame(G);}},[d,p,y]);let C=useMemo(()=>l?No(l,o):null,[o,l]),w=C&&(C.revisionKind==="format"||C.revisionKind==="structural")?C:null,h=useRef(false);if(useEffect(()=>{if(w){h.current=true;return}h.current&&(h.current=false,c(null));},[w]),t)return null;let D=l?.kind==="format"?"format":"structural";return jsx("div",{ref:i,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:l===null||d!=="all-markup"||w&&n.items.some(E=>E.id===w.id)&&n.paneOpen?null:jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",style:{left:l.left,top:l.above?l.top-6:l.bottom+6,transform:l.above?"translateY(-100%)":void 0},onMouseDown:W,children:w?jsx(P.Provider,{value:w,children:jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":w.revisionKind??"revision",...w.author?{"data-review-author":w.author,"data-review-author-slot":ye(r.get(w.author),a.get(w.author)??0)}:{},style:le(w.author,r.get(w.author),a.get(w.author)??0),onClick:()=>n.setActive(w.key),children:[jsxs("div",{className:"docx-review__head",children:[jsx(ge,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(Ce,{}),jsx(he,{})]}),w.kind==="revision"&&!w.readOnly?jsxs("div",{className:"docx-review__actions",children:[jsx(Ue,{}),jsx(Fe,{})]}):null]}),jsx(xe,{})]})}):jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":D,...l.author?{"data-review-author":l.author,"data-review-author-slot":ye(r.get(l.author),a.get(l.author)??0)}:{},style:le(l.author,r.get(l.author),a.get(l.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:wr(l.author)}),jsxs("div",{className:"docx-review__meta",children:[jsx("span",{className:"docx-review__author",children:l.author||s("comments.unknown")}),l.date?jsx(yr,{raw:l.date}):null]})]}),jsx("div",{className:"docx-review__summary",children:jsx("span",{className:"docx-review__label","data-kind":D,children:s(ut(D))})})]})})})}gt.docxReviewPart="Balloon";function wr(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function yr({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsx("time",{className:"docx-review__time",dateTime:e,children:Lo.format(t)})}function Ct({className:e,hidden:t,children:n}){let o=V();return t?null:jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:n??o("review.empty")})}Ct.docxReviewPart="Empty";function Ve({className:e,asChild:t,hidden:n,children:o}){let{review:a,authorSlots:r,authorInfo:s}=H(),i=useContext(P),l=useId(),c=V();if(n||!i)return null;let m=r.get(i.author)??0,d=!t&&i.kind==="comment"&&i.resolved,f={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...d?{}:{"aria-labelledby":`${l}-author ${l}-summary`},"data-kind":i.kind==="revision"?i.revisionKind??"revision":i.kind,...i.author?{"data-review-author":i.author,"data-review-author-slot":ye(s.get(i.author),m)}:{},...i.kind==="custom"&&i.item.kind==="custom"?{"data-node-name":i.item.name}:{},...i.isActive?{"data-active":""}:{},...i.kind==="comment"&&i.resolved?{"data-resolved":""}:{},...d?{"data-resolved-miniature":""}:{},style:le(i.author,s.get(i.author),m),...d?{}:{tabIndex:0,role:"button"},id:l,...d?{}:{onMouseDown:u=>{u.target?.closest("[data-review-selectable]")||u.currentTarget.focus({preventScroll:true});},onClick:()=>a.setActive(i.key),onKeyDown:u=>{u.target===u.currentTarget&&(u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),a.setActive(i.key)));}}};return t?jsx(Slot,{...f,children:o}):d?jsx(bo,{...f,label:c("review.showResolvedComment"),statusLabel:c("review.resolved"),entryKey:i.key,onActivate:()=>a.setActive(i.key),onDeactivate:()=>a.setActive(null),children:jsx(So,{children:o})}):jsx("div",{...f,children:jsx(So,{children:o})})}Ve.docxReviewPart="Card";function So({children:e}){let t=useContext(P),n=useMemo(()=>Rr(e),[e]),o=(r,s)=>r in n?n[r]:s;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let r=t.item;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[o("Avatar",null),jsx("div",{className:"docx-review__meta",children:o("Author",jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:r.title}))})]}),o("Summary",r.detail?jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{className:"docx-review__text",children:r.detail})}):null),n.__extra]})}let a=t.kind==="revision"&&!t.readOnly;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[o("Avatar",jsx(ge,{})),jsxs("div",{className:"docx-review__meta",children:[o("Author",jsx(Ce,{})),o("Time",jsx(he,{}))]}),a||t.kind==="comment"?jsxs("div",{className:"docx-review__actions",children:[o("Accept",jsx(Ue,{})),o("Reject",jsx(Fe,{})),o("Resolve",jsx(ko,{})),o("Reopen",jsx(Do,{})),o("Delete",t.kind==="comment"?jsx(Be,{}):null)]}):null]}),o("Summary",jsx(xe,{})),o("Replies",jsx(ht,{})),o("Reply",jsx(Oo,{})),n.__extra]})}function Rr(e){let t={},n=[],o=a=>{if(Array.isArray(a)){a.forEach(o);return}if(!a||typeof a!="object"||!("type"in a)){a&&n.push(a);return}if(a.type===Fragment$1){o(a.props.children);return}let r=a.type.docxReviewPart;r?t[r]=a:n.push(a);};return o(e),n.length>0&&(t.__extra=n),t}function ge({className:e,asChild:t,hidden:n,children:o}){let{authorInfo:a}=H(),r=useContext(P);if(n||!r||o===void 0&&!r.initials)return null;let s={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsx(Slot,{...s,children:o});let i=a.get(r.author)?.style?.avatarUrl,l=o??(i?jsx("img",{className:"docx-review__avatar-img",src:i,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??r.initials;return jsx("span",{...s,children:l})}ge.docxReviewPart="Avatar";function Ce({className:e,asChild:t,hidden:n,children:o}){let a=useContext(P),r=V();if(n||!a)return null;let s=a.author||r("comments.unknown"),i={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsx(Slot,{...i,children:o}):jsx("span",{...i,children:o??s})}Ce.docxReviewPart="Author";function he({className:e,asChild:t,hidden:n,children:o}){let a=useContext(P);if(n||!a)return null;let r=a.date;if(!r)return null;let s=new Date(r);if(Number.isNaN(s.getTime()))return null;let i={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:r};return t?jsx(Slot,{...i,children:o}):jsx("time",{...i,children:o??Lo.format(s)})}he.docxReviewPart="Time";var Lo=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function xe({className:e,asChild:t,hidden:n,children:o}){let a=useContext(P),r=V();if(n||!a)return null;let s=a.text,i=a.kind!=="revision"?null:Ao(a.item,r),l=a.kind==="revision"&&a.revisionKind==="replace",c={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsx(Slot,{...c,children:o}):jsx("div",{...c,children:o??(l?jsxs("span",{className:"docx-review__text",children:[r("review.replaced")," ",jsxs("span",{className:"docx-review__removed",children:['"',a.replacedText,'"']})," ",r("review.replacedWith")," ",jsxs("span",{className:"docx-review__added",children:['"',s,'"']})]}):jsxs(Fragment,{children:[i?jsx("span",{className:"docx-review__label","data-kind":a.kind==="revision"?a.revisionKind:"revision",children:i}):null,s?jsx("span",{className:"docx-review__text",children:s}):null]}))})}xe.docxReviewPart="Summary";function Ue({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=useContext(P),l=V();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.accept"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.accept(i);}};return t?jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsx("button",{...d,children:a??o??q(Re)})}Ue.docxReviewPart="Accept";function Fe({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=useContext(P),l=V();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.reject"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.reject(i);}};return t?jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsx("button",{...d,children:a??o??q(lo)})}Fe.docxReviewPart="Reject";function Be({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=useContext(P),{t:l}=useTranslation();if(n||!i||i.kind==="custom"||i.kind==="revision"&&i.readOnly)return null;let c=i.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.remove(i);}};return t?jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsx("button",{...d,children:a??o??q(co)})}Be.docxReviewPart="Delete";function ht({className:e,hidden:t}){let{byId:n}=H(),o=useContext(P);if(t||!o||o.kind==="custom")return null;let a=o.replyIds.map(r=>n.get(r)).filter(r=>r!==void 0);return a.length===0?null:jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:a.map(r=>jsx(P.Provider,{value:r,children:jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",children:[jsxs("div",{className:"docx-review__head",children:[jsx(ge,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(Ce,{}),jsx(he,{})]}),jsx("div",{className:"docx-review__actions",children:jsx(Be,{})})]}),jsx(xe,{})]})},r.key))})}ht.docxReviewPart="Replies";var br=Object.assign(pr,{List:qe,Empty:Ct,Card:Ve,Avatar:ge,Author:Ce,Time:he,Summary:xe,Accept:Ue,Reject:Fe,Resolve:ko,Reopen:Do,Delete:Be,Replies:ht,Reply:Oo,Markers:Rt,AddComment:bt,Draft:To,Balloon:gt});var Ae=8;function Ko(e){let t=/^var\(--doc-review-author-(\d{1,2})\)$/.exec(e);return t?Number(t[1])%Ae:null}function Ze(e,t,n,o){let a=new Map(e.map(i=>[i.author,i])),r=new Map,s=new Map;for(let i of t){if(s.has(i.actorId))continue;let l=safeParticipantColor(o?.(i.name));if(l!==void 0){s.set(i.actorId,{color:l,slot:Ko(l)});continue}let c=safeParticipantColor(i.color);if(c!==void 0){s.set(i.actorId,{color:c,slot:null});continue}let m=a.get(i.name),d=safeParticipantColor(n?.(i.name));if(d!==void 0){s.set(i.actorId,{color:d,slot:Ko(d)??(m?m.slot%Ae:null)});continue}if(m!==void 0){let u=m.slot%Ae;s.set(i.actorId,{color:safeParticipantColor(m.color)??`var(--doc-review-author-${u})`,slot:u});continue}let f=r.get(i.name);f===void 0&&(f=e.length+r.size,r.set(i.name,f)),s.set(i.actorId,{color:`var(--doc-review-author-${f%Ae})`,slot:f%Ae});}return s}function xt(e,t,n,o){return Ze(e,[t],n,o).get(t.actorId)}function At(e){let t=e.trim().split(/\s+/,2),n="";for(let o of t){let a=[...o][0];a!==void 0&&(n+=a.toUpperCase());}return n}function $o(e){return [...e].sort((t,n)=>{if(t.isLocal!==n.isLocal)return t.isLocal?-1:1;let o=t.name.localeCompare(n.name);return o!==0?o:t.actorId<n.actorId?-1:t.actorId>n.actorId?1:0})}function je(e,t,n){for(let o of e)if(o.author===t)return o.style?.avatarUrl;return n?.(t)?.avatarUrl}var hr=e=>e.collaborationStatus;function ae(){let e=useDocxEditor();return useEditorState(hr),e?.collaborationSession()??null}var Et=Object.freeze([]);function Er(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let n=0;n<e.length;n+=1){let o=e[n],a=t[n];if(o.actorId!==a.actorId||o.name!==a.name||o.color!==a.color||o.role!==a.role||o.isLocal!==a.isLocal)return false}return true}function Ho(e,t){if(!e)return t.current=Et,Et;let n=e.participants();return Er(t.current,n)?t.current:(t.current=n,n)}function ze(e){let t=ae(),n=e===void 0?t:e,o=useRef(Et);return useSyncExternalStore(a=>n?.subscribeParticipants(()=>a())??(()=>{}),()=>Ho(n,o),()=>Ho(n,o))}var qo=createContext(null);function Tr(e){return {"--doc-collaboration-accent":e.color}}function Vo(e){return e!==void 0?{avatarUrl:e}:{}}function Uo({participant:e,className:t,children:n}){let o=useDocxEditor(),a=useReviewAuthors(),s=useContext(qo)?.get(e.actorId)??xt(a,e,o?l=>o.presenceColorFor(l):void 0,o?l=>o.getReviewAuthorStyle(l)?.color:void 0),i=Or(e.name);return jsx("span",{className:`docx-collaboration-avatar${t?` ${t}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...s.slot!==null?{"data-collaboration-author-slot":s.slot}:{},title:e.name,role:"img","aria-label":e.name,style:Tr(s),children:n??(i!==void 0?jsx("img",{className:"docx-collaboration-avatar__image",src:i,alt:""}):At(e.name))})}function Or(e){let t=useDocxEditor(),n=useReviewAuthors();return je(n,e,t?o=>t.getReviewAuthorStyle(o):void 0)}function Lr({session:e,max:t,className:n,children:o}){let a=useDocxEditor(),r=ze(e),s=useReviewAuthors(),{t:i}=useTranslation(),l=useMemo(()=>Ze(s,r,a?p=>a.presenceColorFor(p):void 0,a?p=>a.getReviewAuthorStyle(p)?.color:void 0),[s,r,a]),c=useMemo(()=>{let p=a?b=>a.getReviewAuthorStyle(b):void 0,y=new Map;for(let b of r){if(y.has(b.name))continue;let C=je(s,b.name,p);C!==void 0&&y.set(b.name,C);}return y},[a,r,s]),m=useMemo(()=>$o(r),[r]);if(m.length===0)return null;let d=t===void 0?m:m.slice(0,Math.max(0,t)),f=m.length-d.length,u=i("collaboration.moreParticipants",{count:f});return jsxs("span",{className:`docx-collaboration-avatars${n?` ${n}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":i("collaboration.participants"),children:[jsx(qo.Provider,{value:l,children:d.map(p=>o?jsx(Fragment$1,{children:o({participant:p,color:l.get(p.actorId).color,initials:At(p.name),...Vo(c.get(p.name))})},p.actorId):jsx(Uo,{participant:p},p.actorId))}),f>0?jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:u,role:"img","aria-label":u,children:`+${f}`}):null]})}var We=Object.freeze([]);function Kr(){return We}function $r(){let e=useRef(null);if(e.current===null){let t=We,n=false,o=new Set;e.current={subscribe:a=>(o.add(a),()=>o.delete(a)),read:()=>t,write:a=>{t=a.length===0?We:a,!n&&(n=true,queueMicrotask(()=>{n=false;for(let r of [...o])r();}));}};}return e.current}function Hr({session:e,children:t}){let n=useDocxEditor(),o=ae(),a=e===void 0?o:e,r=ze(a),s=useReviewAuthors(),i=$r(),l=useSyncExternalStore(i.subscribe,i.read,Kr);if(useEffect(()=>{if(!(!n||!a))return n.setRemoteCaretLabelHost({publish:i.write}),()=>{n.setRemoteCaretLabelHost(null),i.write(We);}},[n,a,i]),l.length===0)return null;let c=Ze(s,r);return jsx(Fragment,{children:l.map(m=>{let{selection:d}=m,f=r.find(y=>y.actorId===d.actorId)??null,u=m.element.style.getPropertyValue("--doc-remote-color"),p=u!==""?u:c.get(d.actorId)?.color??xt(s,{actorId:d.actorId,name:d.name,...d.color!==void 0?{color:d.color}:{},isLocal:false}).color;return createPortal(t?t({selection:d,participant:f,color:p,...Vo(je(s,d.name,n?y=>n.getReviewAuthorStyle(y):void 0))}):d.name,m.element,d.actorId)})})}var qr=Object.freeze({CaretLabels:Hr,Avatars:Lr,Avatar:Uo});function Ee(e){let t=useDocxEditor();return useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(j),[e,t])}var jr=".docx-content-control-boundary";function de(e,t){let{node:n,definition:o,controlId:a}=e,r=a?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===a):void 0;if(r&&r.kind==="custom"){let l=r.item;return {...n,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...a?{nodeId:a}:{}}}let s=a?zr(t,a,o):void 0,i=o.fromDocx?o.fromDocx({attrs:n.attrs,text:"",...s===void 0?{}:{data:s}}):n.attrs;return i===null?null:{...n,attrs:i,...s===void 0?{}:{data:s},...a?{nodeId:a}:{}}}function zr(e$1,t,n){let o=e$1?.surface;if(!o)return;let a=partOfNodeId(o.session,t),r=customNodePayloadsByControl(o.session.currentPackage(),(a??o.session.part()).name,o.session.part().name).get(t);if(!r)return;let s=e(n.schema,r.data);return s.ok?s.value:void 0}function me(e,t){let n=e?.closest?.(jr),o=n?.closest(".docx-content-control-chrome"),a=o?.getAttribute("data-tag"),r=a?c(a):null;if(!n||!r||!a)return null;let s=t.find(i=>i.tagPrefix===r.prefix&&i.name===r.name);return s?{node:{name:r.name,attrs:r.attrs,tag:a,rect:n.getBoundingClientRect()},definition:s,controlId:o?.getAttribute("data-docx-content-control")??null}:null}var Nt=".docx-content-control-boundary",Gr=e=>{if(!k.test(e.tagPrefix)||!k.test(e.name))return [];let t=`${e.tagPrefix}:${e.name}`;return [`.docx-content-control-chrome[data-tag="${t}"]`,`.docx-content-control-chrome[data-tag^="${t}?"]`]};function Qr(e){let{onNodeClick:t,onNodeHover:n}=e,o=useDocxEditor(),a=Ee(e.nodes);return useEffect(()=>{let r=document.createElement("style"),s=[];for(let i of a){let l=Gr(i);if(l.length===0)continue;let c=i.chrome?.color!==void 0&&CSS.supports("color",i.chrome.color)?i.chrome.color:"var(--doc-accent)";s.push(`${l.map(m=>`${m} ${Nt}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${c} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return r.textContent=s.join(`
2
- `),document.head.append(r),()=>r.remove()},[a]),useEffect(()=>{let r=null,s=null,i=d=>me(document.elementFromPoint(d.clientX,d.clientY),a),l=d=>{let f=d.button===0?i(d):null;r=f?.controlId??null,s=f?.node.tag??null;},c=d=>{let f=r,u=s;if(r=null,s=null,u===null)return;let p=i(d);if(!p||p.node.tag!==u||f!==null&&p.controlId!==f)return;let y=de(p,o);y&&(p.definition.onClick?.(y),t?.(y));},m=d=>{let f=me(d.target,a);if(!f||d.relatedTarget?.closest?.(Nt)===d.target.closest(Nt))return;let p=de(f,o);p&&(f.definition.onHover?.(p),n?.(p));};return document.addEventListener("pointerdown",l,true),document.addEventListener("pointerup",c,true),document.addEventListener("mouseover",m),()=>{document.removeEventListener("pointerdown",l,true),document.removeEventListener("pointerup",c,true),document.removeEventListener("mouseover",m);}},[a,o,t,n]),null}var oa=e=>e.editingMode==="viewing";function Zo(e){let{onEditNode:t,onRemoveRefused:n,remove:o=true}=e,a=Ee(e.nodes),r=useContextMenuTarget(),s=useDocxEditor(),{t:i}=useTranslation(),l=useMemo(()=>r?me(r,a):null,[r,a]),c=useMemo(()=>l?de(l,s):null,[l,s]),m=useEditorState(oa),d=useMemo(()=>!l?.definition.reviewCard||!c?null:l.definition.reviewCard({attrs:c.attrs,text:c.text??"",...c.data===void 0?{}:{data:c.data}}),[l,c]);if(!l||!c)return null;let{definition:f}=l,u=f.label??f.name,p=!m&&(f.onEdit!==void 0||t!==void 0),y=!m&&o&&c.nodeId!==void 0&&s!==null;return !d&&!p&&!y?null:jsxs(Fragment,{children:[d?jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsx("span",{className:"docx-contextmenu__custom-title",children:d.title}),d.detail?jsx("span",{className:"docx-contextmenu__custom-detail",children:d.detail}):null]}):null,p?jsx(ContextMenuItem,{label:i("contextMenu.editCustomNode",{label:u}),className:"docx-contextmenu__custom-edit",onSelect:()=>{f.onEdit?.(c),t?.(c,f);}}):null,y?jsx(ContextMenuItem,{label:i("contextMenu.removeCustomNode",{label:u}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let b=q$1(s,c.nodeId);b.ok||n?.(c,b.reason);}}):null,jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}Zo.docxRowPlacement="start";var _t=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,attached:false});function jo(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function ia(e,t){return e.status===t.status&&jo(e.reason,t.reason)&&jo(e.lastFailure,t.lastFailure)}function sa(e){return e.attached??false}function zo(e,t){if(!e)return t.current=_t,_t;let n=e.statusSnapshot(),o=sa(e);if(ia(t.current,n)&&t.current.attached===o)return t.current;let a=Object.freeze({status:n.status,reason:n.reason,lastFailure:n.lastFailure,live:n.status==="ready",diverged:n.status==="error"||n.status==="destroyed",attached:o});return t.current=a,a}function la(e){let t=ae(),n=e===void 0?t:e,o=useRef(_t);return useSyncExternalStore(a=>n?.subscribeStatus(()=>a())??(()=>{}),()=>zo(n,o),()=>zo(n,o))}function ua({collaboration:e,fallback:t=null,author:n,children:o,...a}){let{document:r,modules:s,session:i}=e;if(!r)return jsx(Fragment,{children:t});let l=n??i?.identity.name;return jsx(DocxEditorRoot,{document:r,modules:s,...l!==void 0?{author:l}:{},...a,children:o},i?.sessionId??"local")}var va=Symbol("useDocumentCollaboration.createRoom");async function pa(e){let{createDocumentCollaboration:t}=await import('../document-session-32FPPQHT.js');return t(e)}function wa(e){return e[va]??pa}function ya(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function Ra(e={}){let t=useId(),n=b({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:wa(e),hostModules:e.modules??a,autoRoom:e.room??null,autoKey:ya(e.room??null),rejoinOptionsOf:o=>({...o,bootstrap:{kind:"join"}}),identityOf:o=>o.identity});return useMemo(()=>({document:n.document,modules:n.modules,session:n.session,pending:n.pending,error:n.error,connect:n.connect,leave:n.leave}),[n])}export{Qr as CustomNodeChrome,Zo as CustomNodeContextMenu,qr as DocxEditorCollaboration,ua as DocxEditorCollaborationRoot,br as DocxEditorReview,de as activatedCustomNodeOf,me as resolveCustomNodeActivation,ze as useCollaborationParticipants,ae as useCollaborationSession,la as useCollaborationStatus,Ee as useCustomNodeDefinitions,Ra as useDocumentCollaboration,Te as useReview,lr as useReviewAuthor,sr as useReviewItem,no as useReviewOf,xn as useStackedReviewPositions};
1
+ import {b as b$1,a as a$1}from'../chunk-MWO2ZUEJ.js';import {b,c,d,a,k,j as j$2,f,g,e as e$1,i,h}from'../chunk-P2EF7WMV.js';import {j as j$1,e,c as c$1,q as q$1,k as k$1}from'../chunk-Q5JTCGJI.js';export{o as reviewModule}from'../chunk-Q5JTCGJI.js';export{b as collaborationModule}from'../chunk-Q2VBO66F.js';import {createContext,useMemo,useEffect,useCallback,useRef,useContext,useSyncExternalStore,useState,isValidElement,cloneElement,useId,Children,Fragment as Fragment$1}from'react';import {reviewPaneListsItem,partOfNodeId}from'@docx-editor.dev/core/editor';import {useDocxEditor,useEditorState,useTranslation,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useEditorEvent,useReviewAuthors,Slot,notificationYieldsToTask,useContextMenuTarget,ContextMenuItem,DocxEditorRoot}from'@docx-editor.dev/react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import {customNodePayloadsByControl}from'@docx-editor.dev/core/store';var ir=new Set(["List","Markers","AddComment","Draft","Balloon"]),ar=new Set(["Card","Empty"]);function We(e,t){let o=t==="root"?ir:ar,n={},r=[],i=a=>{if(Array.isArray(a)){for(let l of a)i(l);return}if(!isValidElement(a)){a!=null&&a!==false&&r.push(a);return}if(a.type===Fragment$1){i(a.props.children);return}let s=a.type.docxReviewPart;s&&o.has(s)?n[s]=a:r.push(a);};return i(e),{parts:n,rest:r}}function Rt(e,t){if(!t)return e;let o=e.props.className;return cloneElement(e,{className:`${t}${o?` ${o}`:""}`})}function Lo(e,t){if(!isValidElement(t))return {template:e,fromList:false,hidden:false};let{children:o,hidden:n}=t.props;return {template:o===void 0?e:o,fromList:o!==void 0,hidden:n===true}}var sr={scale:96/72,top:0,left:null,compactCardLeft:null},lr=16,Ge=300,cr=12,yt=600;function $o(e,t,o,n,r=false){let[i,a]=useState(sr);return useEffect(()=>{let s=t.current;if(!e||!s)return;let l=s.offsetParent,u=l?.querySelector(".docx-paginated-surface")??null,m=()=>{a(d=>{let R=u&&l?u.getBoundingClientRect():null,y=R&&l?l.getBoundingClientRect():null,h=R&&y&&l?R.right-y.left-l.clientLeft+l.scrollLeft+lr:null,x={scale:e.getRenderScale(),top:R&&y&&l?R.top-y.top-l.clientTop+l.scrollTop:0,left:h,compactCardLeft:h===null||!l?null:l.scrollLeft+l.clientWidth-h-Ge-cr};return d.scale===x.scale&&d.top===x.top&&d.left===x.left&&d.compactCardLeft===x.compactCardLeft?d:x});};m();let c=new ResizeObserver(m);if(l&&c.observe(l),u&&c.observe(u),!r||!l)return ()=>c.disconnect();let v=0,f=()=>{v===0&&(v=requestAnimationFrame(()=>{v=0,m();}));};return l.addEventListener("scroll",f,{passive:true}),()=>{v!==0&&cancelAnimationFrame(v),l.removeEventListener("scroll",f),c.disconnect();}},[e,t,o,n,r]),i}function Vo(e,t,o){let[n,r]=useState(null);return useEffect(()=>{let i=t.current,a=i?.offsetParent;if(!a)return;let s=0,l=()=>{s=0,r(v=>{let f=a.scrollTop-yt,d=a.scrollTop+a.clientHeight+yt;return v&&v.top===f&&v.bottom===d?v:{top:f,bottom:d}});},u=0,m=()=>{s===0&&(s=requestAnimationFrame(l)),i?.setAttribute("data-scrolling",""),window.clearTimeout(u),u=window.setTimeout(()=>i?.removeAttribute("data-scrolling"),150);};l(),a.addEventListener("scroll",m,{passive:true});let c=new ResizeObserver(m);return c.observe(a),()=>{s!==0&&cancelAnimationFrame(s),window.clearTimeout(u),a.removeEventListener("scroll",m),c.disconnect();}},[e,t,o]),n}function qo(e){let t=useRef(new WeakMap),o=useRef(new Map),n=useRef(null),r=useCallback((i,a)=>{let s=o.current.get(a);if(!i){s&&(n.current?.unobserve(s),t.current.delete(s),o.current.delete(a));return}typeof ResizeObserver>"u"||(e(a,i.offsetHeight),n.current??=new ResizeObserver(l=>{for(let u of l){let m=t.current.get(u.target);m&&e(m,u.target.offsetHeight);}}),!(s===i&&t.current.get(i)===a)&&(s&&(n.current.unobserve(s),t.current.delete(s)),t.current.set(i,a),o.current.set(a,i),n.current.observe(i)));},[e]);return useEffect(()=>()=>{n.current?.disconnect(),o.current.clear();},[]),r}function fr(e){let t=false;return ()=>{if(!t){if(!notificationYieldsToTask()){e();return}t=true,setTimeout(()=>{t=false,e();},0);}}}function pr(e){let t=e.snapshot?.();return JSON.stringify(t?.hiddenReviewAuthors??[])}function bt(e){let t=useDocxEditor();return Fo(t,e)}function Fo(e,t){let o=useCallback(p=>{if(!e)return ()=>{};let N=false,V=fr(()=>{N||p();}),Q=e.on("change",V),A=e.on("selectionChange",V),ie=e.on("error",V);return ()=>{N=true,Q(),A(),ie();}},[e]),n=useSyncExternalStore(o,()=>e?`${e.getReviewRevision()}:${e.getEditingMode()}:${pr(e)}`:"none",()=>"none"),r=useMemo(()=>e?e.getReviewItems(t).filter(p=>p.item.kind!=="custom"||p.item.carded):[],[e,n,t]),i=useMemo(()=>r.find(p=>p.isActive)?.key??null,[r]),a$1=useCallback(p=>{if(!e)return ()=>{};let N=e.on("selectionChange",p),V=e.on("change",p);return ()=>{N(),V();}},[e]),s=useSyncExternalStore(a$1,()=>e?e.getActivatedReviewItemKey(t):null,()=>null),l=useCallback((p,N)=>e?e.setActiveReviewItem(p,N).ok:false,[e]),u=useCallback(p=>!e||p.kind!=="revision"||p.readOnly?false:e.acceptReviewItem(p.key).ok,[e]),m=useCallback(p=>!e||p.kind!=="revision"||p.readOnly?false:e.rejectReviewItem(p.key).ok,[e]),c=useCallback((p,N)=>a(e,p,N),[e]),v=useCallback(p=>!e||p.kind!=="comment"?false:e.setCommentResolved(p.key,true).ok,[e]),f=useCallback(p=>!e||p.kind!=="comment"?false:e.setCommentResolved(p.key,false).ok,[e]),d=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,R=useCallback(p=>!e||p.kind==="custom"||p.kind==="revision"&&p.readOnly?false:e.deleteReviewItem(p.key).ok,[e]),y=useCallback((p,N,V)=>N.trim().length===0||!e?false:e.replyToReviewItem(p.key,N,V).ok,[e]),h=useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,n]),x=useCallback((p,N)=>p.trim().length===0||!e?false:e.addComment(p,N).ok,[e]),T=useMemo(()=>e?e.isReviewPaneOpen():true,[e,n]),S=useCallback(p=>{!e||e.isReviewPaneOpen()===p||e.exec({type:"toggleReviewPane"});},[e]);return useMemo(()=>({items:r,activeKey:i,activatedKey:s,setActive:l,accept:u,reject:m,adopt:c,resolve:v,reopen:f,commentResolutionDisabledReason:d,remove:R,reply:y,selectionAnchorY:h,comment:x,paneOpen:T,setPaneOpen:S,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[r,i,s,l,u,m,c,v,f,d,R,y,h,x,T,S,e])}function wr(e,t,o={}){let n=o.gap??8,r=o.scale??1,i=o.defaultHeight??0;return useMemo(()=>{let a=new Map,s=Number.NEGATIVE_INFINITY;for(let l of e){let u=l.anchorY===null?Number.isFinite(s)?s:0:Math.max(l.anchorY,s);a.set(l.key,u),s=u+((t.get(l.key)??i)+n)/r;}return a},[e,t,n,r,i])}var Yt=8;function Zt(e,t){return e?.color??`var(--doc-review-author-${t%Yt})`}function ce(e,t,o){return e?{"--doc-review-author-current":Zt(t,o)}:{}}function be(e,t){return (e?.slot??t)%Yt}function Uo(e,t,o,n){let r=useRef(new Map);return useMemo(()=>{let i=new Map;for(let s of e)i.set(s.author,s);let a=[...t.map(s=>s.author),n?.getConfiguredAuthor()];for(let s of a){if(!s||i.has(s))continue;let l=o.get(s)??0,u=n?.getReviewAuthorStyle(s),m=u?.color??`var(--doc-review-author-${l%Yt})`,c=r.current.get(s),v=c!==void 0&&c.slot===l&&c.color===m&&c.style===u?c:{author:s,slot:l,color:m,...u?{style:u}:{}};r.current.set(s,v),i.set(s,v);}return i},[e,t,o,n])}var q=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),Zo="M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z",Yo="M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",br="M880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Me="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",gt=()=>jsxs("span",{className:"docx-review__resolved-icon",children:[jsx("span",{className:"docx-review__resolved-comment",children:q(br)}),jsx("span",{className:"docx-review__resolved-tick",children:q(Me)})]}),jo="M120-160v-640l760 320-760 320Zm80-120 474-200-474-200v140l240 60-240 60v140Zm0 0v-400 400Z",Ct=(e,t,o)=>jsxs("span",{className:"docx-review__badge","data-testid":"review-badge",...o?{"data-resolved":""}:{},"aria-hidden":"true",children:[o?q(Me):jsx("span",{className:"docx-review__badge-initials",children:e||"?"}),t>0?jsx("span",{className:"docx-review__badge-count","data-testid":"review-badge-count",children:t>9?"9+":t}):null]}),zo="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z",Wo="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",Go="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",gr="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",Cr="M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 78t85.5 30q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-341q0 86-61.5 133.5T486-160ZM80-520v-80h800v80H80Zm402-360q66 0 116 30t74 84l-88 38q-11-28-38.5-47T480-794q-42 0-72 19t-30 51q0 15 6 27t18 22H272q-6-13-9-27t-3-30q0-70 55-114t167-44Z",hr="M360-160q-83 0-141.5-58.5T160-360v-360q0-83 58.5-141.5T360-920q83 0 141.5 58.5T560-720v360q0 83-58.5 141.5T360-160Zm0-80q50 0 85-35t35-85v-360q0-50-35-85t-85-35q-50 0-85 35t-35 85v360q0 50 35 85t85 35Zm300 80q29 0 49.5-20.5T730-230q0-22-12.5-40T684-296l-64-32v-232l100 100q23 23 51.5 35.5T832-412v-80q-17 0-32-6.5T773-517L633-657q-12-12-27.5-17.5T573-680h-13v520h100ZM360-720Z",xr="M580-360q-25 0-42.5-17.5T520-420v-160q0-25 17.5-42.5T580-640h160q25 0 42.5 17.5T800-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T720-320v-40H580Zm-360 0q-25 0-42.5-17.5T160-420v-160q0-25 17.5-42.5T220-640h160q25 0 42.5 17.5T440-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T360-320v-40H220Z";function jt(e){if(e.kind==="comment")return Yo;if(e.kind==="custom")return e.item.icon??xr;switch(e.revisionKind){case "insert":case "moveTo":return gr;case "delete":case "moveFrom":return Cr;case "format":return hr;default:return Yo}}function Ir(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function Nr(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=Ir(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function en(e){return e==="Enter"||e===" "}function Pr(e){return en(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function Jo(e){return e.type==="button"}function _r(e,t){return e.type==="a"||t.href!=null}function Sr(e,t,o,n){let r=i=>{typeof o=="function"&&o(i);};return {onClick:i=>{typeof e=="function"&&e(i),i.defaultPrevented||r(i),n&&i.preventDefault();},onKeyDown:i=>{if(typeof t=="function"&&t(i),!en(i.key))return;i.defaultPrevented||r(i),n&&i.preventDefault();}}}function ge({engineDisabled:e,disabledReason:t,slotProps:o,children:n}){let r=Children.only(n);if(!isValidElement(r))return null;let i=r.props,a=Nr(o,i);if(!e){if(!Jo(r)){let s=Sr(i.onClick,i.onKeyDown,o.onClick,_r(r,i));a.onClick=s.onClick,a.onKeyDown=s.onKeyDown;}return cloneElement(r,a)}if(Jo(r))a.disabled=true,delete a["aria-disabled"];else {delete a.disabled,a["aria-disabled"]=true,a["data-disabled"]="",a.tabIndex=-1,a.href=void 0,a.role===void 0&&(a.role="button");let s=a.onKeyDown;a.onKeyDown=l=>{Pr(l)||typeof s=="function"&&s(l);};}return t&&(a.title=t),a.onClick=s=>{s.preventDefault(),s.stopPropagation();},cloneElement(r,a)}var nn=createContext({key:null,open:()=>{},close:()=>{}});function rn({items:e,children:t}){let[o,n]=useState(null);useEffect(()=>{o!==null&&!e.some(i=>i.key===o&&i.kind==="comment"&&i.resolved)&&n(null);},[e,o]);let r=useMemo(()=>({key:o,open:i=>n(i),close:()=>n(null)}),[o]);return jsx(nn.Provider,{value:r,children:t})}function zt(){return useContext(nn)}function an({label:e,statusLabel:t,entryKey:o,badge:n=false,onActivate:r,onDeactivate:i,children:a,...s}){let l=zt(),u=useRef(null);return useEffect(()=>{let m=c=>{let v=u.current;v?.open&&c.target instanceof Node&&!v.contains(c.target)&&(l.close(),i());};return document.addEventListener("pointerdown",m,true),()=>document.removeEventListener("pointerdown",m,true)},[l,i]),jsxs("details",{ref:u,...s,open:l.key===o,onToggle:m=>{m.currentTarget.open?(l.open(o),r()):(l.close(),i());},children:[jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsx("span",{className:"docx-review__resolved-status",children:t}),n?Ct("",0,true):gt()]}),a]})}function sn(e){function t({className:n,asChild:r,hidden:i,children:a,icon:s}){let l=e.useReview(),u=e.useItem(),m=e.useLabel();if(i||!u||u.kind!=="comment"||u.resolved)return null;let c=m("comments.resolve"),v=l.commentResolutionDisabledReason!==null,f=v?m("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-resolve","aria-label":c,title:f??c,disabled:v,onMouseDown:e.guardMousedown,onClick:R=>{R.stopPropagation(),!v&&l.resolve(u);}};return r?jsx(ge,{engineDisabled:v,disabledReason:f,slotProps:d,children:a}):jsx("button",{...d,children:s??a??q(Me)})}t.docxReviewPart="Resolve";function o({className:n,asChild:r,hidden:i,children:a,icon:s}){let l=e.useReview(),u=e.useItem(),m=e.useLabel();if(i||!u||u.kind!=="comment"||!u.resolved)return null;let c=m("comments.reopen"),v=l.commentResolutionDisabledReason!==null,f=v?m("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-reopen","aria-label":c,title:f??c,disabled:v,onMouseDown:e.guardMousedown,onClick:R=>{R.stopPropagation(),!v&&l.reopen(u);}};return r?jsx(ge,{engineDisabled:v,disabledReason:f,slotProps:d,children:a}):jsx("button",{...d,children:s??a??q(zo)})}return o.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:o}}function ht(e,t,o){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=e.closest(".docx-editor__scroll-container"),a=i?.getBoundingClientRect(),s=(a?.left??n.left)-n.left,l=i&&i.clientWidth>0?i.clientWidth:a?.width??0,u=e.ownerDocument.defaultView?.innerHeight??1/0,m=Number(e.dataset.reviewStart??e.dataset.start),c=Number(e.dataset.reviewEnd??e.dataset.end);return {revisionId:e.dataset.revisionId,...e.dataset.formattingKind?{formattingKind:e.dataset.formattingKind}:{},author:e.dataset.reviewAuthor??"",...e.dataset.revisionDate!==void 0?{date:e.dataset.revisionDate}:{},...e.dataset.revisionKind!==void 0?{kind:e.dataset.revisionKind}:{},structuralSite:o,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(m)?{start:m}:{},...Number.isFinite(c)?{end:c}:{},left:r.left-n.left,right:r.right-n.left,top:r.top-n.top,bottom:r.bottom-n.top,above:r.bottom+220>u,rtl:e.ownerDocument.defaultView?.getComputedStyle(e).direction==="rtl",visibleLeft:s,visibleRight:l>0?s+l:Number.POSITIVE_INFINITY}}function ln(e,t){let o=e.visibleRight-e.visibleLeft-16,n=Number.isFinite(o)&&o>0?Math.min(t,o):t,r=e.rtl?e.right-n:e.left,i=e.visibleLeft+8,a=e.visibleRight-8-n;return {left:Math.min(Math.max(r,i),Math.max(a,i)),width:n}}function Lr(e,t,o){let n=null;for(let r of e.querySelectorAll("[data-revision-id]")){if(!(r instanceof HTMLElement)||r.dataset.revisionId!==t.revisionId||(r.dataset.reviewAuthor??"")!==t.author||r.dataset.formattingKind!==t.formattingKind||r.classList.contains("docx-table-row--revision")!==t.structuralSite)continue;let i=Number(r.dataset.reviewStart??r.dataset.start);if(r.dataset.paragraphId===t.paragraphId&&i===t.start)return r;n??=r;}return n??(o?Wt(e,o):null)}var Kr=["left","right","top","bottom","above","rtl","visibleLeft","visibleRight"];function cn(e,t,o,n){let r=Lr(t,e,n);if(!r)return e;let i=ht(r,o,e.structuralSite);return Kr.every(a=>i[a]===e[a])?e:{...e,...i}}function xt(e,t="pane"){return e===void 0?false:t==="balloons"||e==="format"||e==="structural"}function un(e,t,o,n="pane",r=false){return e.kind!=="revision"||!xt(e.revisionKind,n)?false:n==="balloons"?r:!(o&&t.some(i=>i.id===e.id))}function Hr(e){return e.dataset.revisionKind!=="format"&&!e.classList.contains("docx-table-row--revision")}function Wt(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let o=t.item.addresses;if(o.length===0)return null;let n=new Set(o.map(i=>i.id)),r=t.item.formattingKind;for(let i of e.querySelectorAll("[data-revision-id]")){if(!(i instanceof HTMLElement))continue;let a=i.dataset.revisionId;if(!a||!n.has(a)||!o.some(u=>u.id===a&&u.author===(i.dataset.reviewAuthor??"")&&(u.date??"")===(i.dataset.revisionDate??"")))continue;let l=i.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&i.dataset.revisionKind==="format"&&i.dataset.formattingKind===r||!xt(t.revisionKind)&&Hr(i))return i}return null}function dn(e,t){let o=null,n=false,r=null,i=false,a=null,s=false;for(let l of t)if(!(l.kind!=="revision"||l.item.kind!=="revision")&&!(e.formattingKind&&l.item.formattingKind!==e.formattingKind)){for(let u of l.item.addresses)if(u.id===e.revisionId){if(u.author===e.author){if(u.date===e.date)return l;o===null?o=l:o!==l&&(n=true);}r===null?r=l:r!==l&&(i=true);}if(!(e.paragraphId===void 0||e.start===void 0||e.end===void 0||l.revisionKind!=="format"&&l.revisionKind!=="structural")){for(let u of l.item.ranges)if(u.start.paragraphId===e.paragraphId&&u.start.offset<e.end&&u.end.offset>e.start){a===null?a=l:a!==l&&(s=true);break}}}return o!==null&&!n?o:r!==null&&!i?r:a!==null&&!s?a:null}function mn(e){return e.kind==="revision"&&e.item.kind==="revision"&&e.revisionKind==="format"&&e.item.ranges.length>0&&(e.item.formattingKind==="rPrChange"||e.item.formattingKind==="pPrChange")}var Qe=createContext(null),D=createContext(null);function fn(){return useContext(D)}function pn(e){let t=useContext(Qe),o=useReviewAuthors();if(e!==void 0)return t?t.authorInfo.get(e):o.find(n=>n.author===e)}function Z(){let e=useContext(Qe);return e||Fr}function Br(e,t){return t?e.replace(/\{(\w+)\}/g,(o,n)=>Object.hasOwn(t,n)?String(t[n]):o):e}function j(){let{t:e}=useContext(Qe)??{},{t}=useTranslation();return useCallback((o,n)=>{let r=e?.(o);return r!==void 0?Br(r,n):t(o,n)},[e,t])}var Fr={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,adopt:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,activatedKey:null,paneOpen:true,setPaneOpen:()=>{},ready:false},allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{},commentMarkers:"icon",revisionsIn:"pane"};var wn=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,Rn=e=>e.reviewPane.opening,yn=e=>e.reviewPane.revisionsIn,bn=e=>e.reviewPane.commentMarkers,gn=e=>e.editingMode==="viewing",Te="\0compose";var Cn=Object.freeze({placement:false}),hn=Object.freeze({placement:false,pairReplacements:true});function Xe(e,t){return e.kind!=="comment"?false:e.parentId!==void 0?t.has(e.parentId):e.parentRevisionId!==void 0?t.has(e.parentRevisionId):false}function Je(e){return new Set(e.map(t=>t.id))}function ee(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function At(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(o=>o[0].toUpperCase()).join("")}var It=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Nn(e){function t({top:a=0,left:s=null,className:l,hidden:u}){let{review:m,endDraft:c,measure:v,readOnly:f,draftAuthor:d,draftAuthorInfo:R,draftAuthorSlot:y}=e.useRail(),h=e.useLabel(),[x,T]=useState(""),[S,p]=useState(false),N=useRef(null),V=useId();useEffect(()=>{f||N.current?.focus({preventScroll:true});},[]);let Q=useCallback(()=>{if(f||x.trim().length===0)return;let A=m.comment(x.trim());p(!A),A&&(T(""),c());},[f,x,m,c]);return u?null:jsx("div",{className:`docx-review__slot${l?` ${l}`:""}${s===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:a,...s===null?{}:{left:s,width:Ge}},ref:A=>{v(A,e.composeKey);},children:jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...d?{"data-review-author":d,"data-review-author-slot":y}:{},style:ce(d??void 0,R,y),children:jsxs("form",{className:"docx-review__reply-box",onSubmit:A=>{A.preventDefault(),Q();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:V,children:h("comments.addComment")}),jsx("input",{id:V,ref:N,"data-testid":"review-draft-input",className:"docx-review__input",value:x,placeholder:h("comments.addComment"),readOnly:f,...S?{"aria-invalid":true}:{},onChange:A=>{f||(p(false),T(A.target.value));},onKeyDown:A=>{if(A.key==="Escape"){A.preventDefault(),c();return}f||A.key!=="Enter"||(A.preventDefault(),Q());}}),jsxs("div",{className:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:c,children:h("common.cancel")}),jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:f||x.trim().length===0,title:f?h("editingMode.viewingHint"):void 0,children:h("common.comment")})]}),S?jsx("span",{className:"docx-review__refused",role:"alert",children:h("review.commentRefused")}):null]})})})}t.docxReviewPart="Draft";function o(a){let{review:s,readOnly:l}=e.useRail(),[u,m]=useState(""),[c,v]=useState(false),f=useCallback(()=>{if(!a||l||u.trim().length===0)return;let d=s.reply(a,u.trim());v(!d),d&&m("");},[a,l,u,s]);return {draft:u,setDraft:m,refused:c,setRefused:v,submit:f}}function n({state:a,className:s,onCancel:l}){let{readOnly:u,draftAuthor:m,draftAuthorInfo:c,draftAuthorSlot:v}=e.useRail(),f=e.useLabel(),d=useId(),{draft:R,setDraft:y,refused:h,setRefused:x,submit:T}=a,S=c?.style?.avatarUrl;return jsxs("form",{className:`docx-review__reply-box${s?` ${s}`:""}`,"data-reply-line":"",onSubmit:p=>{p.preventDefault(),T();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:f("comments.replyPlaceholder")}),m?jsx("span",{className:"docx-review__avatar docx-review__reply-avatar","data-testid":"review-reply-avatar","aria-hidden":"true",style:ce(m,c,v),children:S?jsx("img",{className:"docx-review__avatar-img",src:S,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):At(m)}):null,jsx("input",{id:d,"data-testid":"review-reply-input",className:"docx-review__input",value:R,placeholder:f("comments.replyPlaceholder"),readOnly:u,...h?{"aria-invalid":true,"data-refused":""}:{},onChange:p=>{u||(x(false),y(p.target.value));},onClick:p=>p.stopPropagation(),onKeyDown:p=>{if(p.key==="Escape"&&!p.nativeEvent.isComposing){if(R.length>0){p.preventDefault(),y(""),x(false);return}if(l){p.preventDefault(),l();return}}u||p.key!=="Enter"||(p.preventDefault(),T());}}),R.length>0?jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:p=>{p.stopPropagation(),y(""),x(false),l?.();},children:f("common.cancel")}):null,jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__send","aria-label":f("review.reply"),disabled:u||R.trim().length===0,title:f(u?"editingMode.viewingHint":"review.reply"),children:q(jo)}),h?jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:f("review.replyRefused")}):null]})}function r({className:a,hidden:s,children:l}){let{review:u}=e.useRail(),m=e.useItem(),c=o(m);return s||!m||!m.isActive||m.kind==="comment"&&m.resolved?null:l?jsx(Fragment,{children:l}):jsx(n,{state:c,className:a,onCancel:()=>u.setActive(null)})}r.docxReviewPart="Reply";function i({entry:a,orphaned:s=false,onDraft:l}){let u=e.useLabel(),m=o(s?null:a),c=m.draft.trim().length>0;return useEffect(()=>l?.(c),[c,l]),jsxs(Fragment,{children:[jsx(n,{state:m}),s?jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-orphaned",children:u("review.replyTargetResolved")}):null]})}return {ReviewDraft:t,ReviewReply:r,ReviewBalloonReply:i}}function Gt(e,t,o=1){if(e==="paragraphMark"){let n=o>1;return t==="delete"?n?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?n?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?n?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":n?"revisions.paragraphMarksInserted":"revisions.paragraphMarkInserted"}switch(e){case "insert":return "review.inserted";case "delete":return "review.deleted";case "replace":return "review.replaced";case "moveFrom":return "review.movedFrom";case "moveTo":return "review.movedTo";case "format":return "revisions.runPropertiesChanged";default:return "review.structural"}}function Yr(e){return Gt(e.revisionKind,e.markDirection,e.ranges.length)}function Zr(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function et(e,t){if(e.revisionKind==="structural"&&e.structuralChanges?.length)return e.structuralChanges.map(i=>t(`revisions.structuralDetails.${i}`)).join(", ");let o=`${t(Yr(e))}${Zr(e)}`;if(e.revisionKind!=="format")return o;let r=[...(e.formattingLanguages??[]).map(i=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(i).minimize().toString())??i}catch{return i}}),...(e.formattingChanges??[]).map(i=>jr(i,t))];return r.length?`${o}: ${r.join(", ")}`:o}function jr(e,t){let{property:o,value:n}=e;if(n!==null&&(o==="bold"||o==="italic"||o==="strike"))return t(`revisions.formattingDetails.${n==="true"?o:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[o]}`);let r=n??t("revisions.formattingDetails.default");return n!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(o)?r=`${n} ${t("revisions.formattingDetails.points")}`:(o==="direction"?n==="rtl"||n==="ltr":/^(left|center|right|both|start|end|none|single|double|auto)$/.test(n))?r=t(`revisions.formattingDetails.${n}`):o==="color"&&/^[0-9a-f]{6}$/i.test(n)&&(r=`#${n.toUpperCase()}`)),`${t(`revisions.formattingDetails.${o}`)}: ${r}`}var{ReviewResolve:Xt,ReviewReopen:Jt}=sn({useReview:()=>Z().review,useItem:()=>useContext(D),useLabel:j,guardMousedown:ee}),{ReviewDraft:eo,ReviewReply:to,ReviewBalloonReply:_n}=Nn({useRail:Z,useItem:()=>useContext(D),useLabel:j,guardMousedown:ee,composeKey:Te});function ot({className:e,hidden:t,children:o}){let n=j();return t?null:jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:o??n("review.empty")})}ot.docxReviewPart="Empty";function Oe({className:e,asChild:t,hidden:o,children:n}){let{review:r,authorSlots:i,authorInfo:a,commentMarkers:s}=Z(),l=useContext(D),u=useId(),m=j();if(o||!l)return null;let c$1=i.get(l.author)??0,v=!t&&l.kind==="comment"&&l.resolved,f={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...v?{}:{"aria-labelledby":`${u}-author ${u}-summary`},"data-kind":l.kind==="revision"?l.revisionKind??"revision":l.kind,...l.author?{"data-review-author":l.author,"data-review-author-slot":be(a.get(l.author),c$1)}:{},...l.kind==="custom"&&l.item.kind==="custom"?{"data-node-name":l.item.name}:{},...l.isActive?{"data-active":""}:{},...l.kind==="comment"&&l.resolved?{"data-resolved":""}:{},...v?{"data-resolved-miniature":""}:{},style:ce(l.author,a.get(l.author),c$1),...v?{}:{tabIndex:0,role:"button"},id:u,...v?{}:{onMouseDown:d$1=>{d(d$1.target)||d$1.currentTarget.focus({preventScroll:true});},onClick:d=>{!c(d.target)&&!l.isActive&&r.setActive(l.key);},onKeyDown:d=>{d.target===d.currentTarget&&(d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),r.setActive(l.key)));}}};return t?jsx(Slot,{...f,children:n}):v?jsx(an,{...f,label:m("review.showResolvedComment"),statusLabel:m("review.resolved"),entryKey:l.key,badge:s==="initials",onActivate:()=>r.setActive(l.key),onDeactivate:()=>r.setActive(null),children:jsx(Pn,{children:n})}):jsx("div",{...f,children:jsx(Pn,{children:n})})}Oe.docxReviewPart="Card";function Pn({children:e}){let t=useContext(D),o=useMemo(()=>Xr(e),[e]),n=(i,a)=>i in o?o[i]:a;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let i=t.item;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",null),jsx("div",{className:"docx-review__meta",children:n("Author",jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:i.title}))})]}),n("Summary",i.detail?jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{className:"docx-review__text",children:i.detail})}):null),o.__extra]})}let r=t.kind==="revision"&&!t.readOnly;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",jsx(Ce,{})),jsxs("div",{className:"docx-review__meta",children:[n("Author",jsx(he,{})),n("Time",jsx(xe,{}))]}),r||t.kind==="comment"?jsxs("div",{className:"docx-review__actions",children:[n("Accept",jsx(Le,{})),n("Reject",jsx(Ke,{})),n("Resolve",jsx(Xt,{})),n("Reopen",jsx(Jt,{})),n("Delete",t.kind==="comment"?jsx(nt,{}):null)]}):null]}),n("Summary",jsx(we,{})),n("Replies",jsx(He,{})),n("Reply",jsx(to,{})),o.__extra]})}function Xr(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===Fragment$1){n(r.props.children);return}let i=r.type.docxReviewPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Ce({className:e,asChild:t,hidden:o,children:n}){let{authorInfo:r}=Z(),i=useContext(D);if(o||!i||n===void 0&&!i.initials)return null;let a={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsx(Slot,{...a,children:n});let s=r.get(i.author)?.style?.avatarUrl,l=n??(s?jsx("img",{className:"docx-review__avatar-img",src:s,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??i.initials;return jsx("span",{...a,children:l})}Ce.docxReviewPart="Avatar";function he({className:e,asChild:t,hidden:o,children:n}){let r=useContext(D),i=j();if(o||!r)return null;let a=r.author||i("comments.unknown"),s={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsx(Slot,{...s,children:n}):jsx("span",{...s,children:n??a})}he.docxReviewPart="Author";function xe({className:e,asChild:t,hidden:o,children:n}){let r=useContext(D);if(o||!r)return null;let i=r.date;if(!i)return null;let a=new Date(i);if(Number.isNaN(a.getTime()))return null;let s={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:i};return t?jsx(Slot,{...s,children:n}):jsx("time",{...s,children:n??It.format(a)})}xe.docxReviewPart="Time";function we({className:e,asChild:t,hidden:o,children:n}){let r=useContext(D),i=j();if(o||!r)return null;let a=r.text,s=r.kind!=="revision"?null:et(r.item,i),l=r.kind==="revision"&&r.revisionKind==="replace",u={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsx(Slot,{...u,children:n}):jsx("div",{...u,children:n??(l?jsxs("span",{className:"docx-review__text",children:[i("review.replaced")," ",jsxs("span",{className:"docx-review__removed",children:['"',r.replacedText,'"']})," ",i("review.replacedWith")," ",jsxs("span",{className:"docx-review__added",children:['"',a,'"']})]}):jsxs(Fragment,{children:[s?jsx("span",{className:"docx-review__label","data-kind":r.kind==="revision"?r.revisionKind:"revision",children:s}):null,a?jsx("span",{className:"docx-review__text",children:a}):null]}))})}we.docxReviewPart="Summary";function Le({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Z(),s=useContext(D),l=j();if(o||!s||s.kind!=="revision"||s.readOnly)return null;let u=l("review.accept"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":u,title:m??u,disabled:i,onMouseDown:ee,onClick:v=>{v.stopPropagation(),!i&&a.accept(s);}};return t?jsx(ge,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??q(Me)})}Le.docxReviewPart="Accept";function Ke({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Z(),s=useContext(D),l=j();if(o||!s||s.kind!=="revision"||s.readOnly)return null;let u=l("review.reject"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":u,title:m??u,disabled:i,onMouseDown:ee,onClick:v=>{v.stopPropagation(),!i&&a.reject(s);}};return t?jsx(ge,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??q(Wo)})}Ke.docxReviewPart="Reject";function nt({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Z(),s=useContext(D),{t:l}=useTranslation();if(o||!s||s.kind==="custom"||s.kind==="revision"&&s.readOnly)return null;let u=s.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":u,title:m??u,disabled:i,onMouseDown:ee,onClick:v=>{v.stopPropagation(),!i&&a.remove(s);}};return t?jsx(ge,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??q(Go)})}nt.docxReviewPart="Delete";function He({className:e,hidden:t}){let{byId:o,authorSlots:n,authorInfo:r}=Z(),i=useContext(D);if(t||!i||i.kind==="custom")return null;let a=i.replyIds.map(s=>o.get(s)).filter(s=>s!==void 0);return a.length===0?null:jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:a.map(s=>jsx(D.Provider,{value:s,children:jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",...s.author?{"data-review-author":s.author,"data-review-author-slot":be(r.get(s.author),n.get(s.author)??0)}:{},style:ce(s.author,r.get(s.author),n.get(s.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx(Ce,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(he,{}),jsx(xe,{})]}),jsx("div",{className:"docx-review__actions",children:jsx(nt,{})})]}),jsx(we,{})]})},s.key))})}He.docxReviewPart="Replies";function rt({stack:e=true,positions:t,collapsed:o,scale:n=1,offset:r=0,window:i=null,children:a,className:s,hidden:l}){let{review:u,measure:m,cardClassName:c}=Z();if(l)return null;let v=typeof a=="function"?null:We(a,"list"),f=Je(u.items),d=u.items.filter(R=>!Xe(R,f));return d.length===0?typeof a=="function"?null:v?.parts.Empty??jsx(ot,{}):jsx("div",{className:`docx-review__list${s?` ${s}`:""}`,children:d.map(R=>{let y=e?t?.get(R.key)??R.anchorY:R.anchorY,h=y==null?null:r+y*n;if(h!==null&&i&&(h<i.top||h>i.bottom))return null;let x=h===null?{}:{position:"absolute",top:h};return jsx(D.Provider,{value:R,children:jsx("div",{className:"docx-review__slot",style:x,...o?.has(R.key)?{"data-collapsed":""}:{},ref:T=>{m(T,R.key);},children:typeof a=="function"?a(R):v?.parts.Card&&isValidElement(v.parts.Card)?Rt(v.parts.Card,c):jsx(Oe,{...c?{className:c}:{},children:v?.rest})})},R.key)})})}rt.docxReviewPart="List";function _t({scale:e=1,offset:t=0,window:o=null,className:n,hidden:r,icon:i}){let{review:a,authorSlots:s,authorInfo:l,commentMarkers:u}=Z(),m=zt(),c=j(),{roots:v,stackedTops:f}=useMemo(()=>{let d=Je(a.items),R=a.items.filter(x=>!Xe(x,d)),y=new Map,h=Number.NEGATIVE_INFINITY;for(let x of R){if(x.anchorY===null)continue;let T=Math.max(t+x.anchorY*e,h);y.set(x.key,T),h=T+30;}return {roots:R,stackedTops:y}},[a.items,t,e]);return r?null:jsx("div",{className:`docx-review__markers${n?` ${n}`:""}`,children:v.map(d=>{let R=f.get(d.key);if(R===void 0||o&&(R<o.top||R>o.bottom))return null;let y=typeof i=="function"?i(d):i,h=y==null&&u==="initials"&&d.kind==="comment";return jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":d.kind==="revision"?d.revisionKind:d.kind,...h?{"data-marker":"initials"}:{},...d.author?{"data-review-author":d.author,"data-review-author-slot":be(l.get(d.author),s.get(d.author)??0)}:{},style:{position:"absolute",top:R,...d.author?{"--doc-review-author-current":Zt(l.get(d.author),s.get(d.author)??0)}:{}},title:d.author?`${d.author}: ${d.text}`:d.text,"aria-label":ri(d,c),onMouseDown:ee,onClick:()=>{d.kind==="comment"&&d.resolved&&m.open(d.key),a.setPaneOpen(true),a.setActive(d.key);},children:y??(d.kind!=="comment"?q(jt(d)):h?Ct(d.initials,d.replyIds.length,d.resolved):d.resolved?gt():q(jt(d)))},d.key)})})}_t.docxReviewPart="Markers";function ri(e,t){let o=[`${t("review.showPane")}: ${e.author?`${e.author}. `:""}${e.text}`];return e.kind==="comment"&&e.resolved&&o.push(t("review.resolved")),e.kind==="comment"&&e.replyIds.length>0&&o.push(t("review.replyCount",{count:e.replyIds.length})),o.join(". ")}function St({top:e=null,drafting:t=false,className:o,hidden:n,children:r}){let{beginDraft:i,readOnly:a}=Z(),s=j();if(n||t||e===null||a)return null;let l={type:"button",className:`docx-review__add${o?` ${o}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":s("common.comment"),title:s("common.comment"),onMouseDown:ee,onClick:i};return r?jsx(Slot,{...l,children:r}):jsx("button",{...l,children:q(Zo)})}St.docxReviewPart="AddComment";function kt({className:e,hidden:t}){let o=useDocxEditor(),n=useRef(o);n.current=o;let{review:r,allItems:i,authorSlots:a,authorInfo:s,revisionsIn:l}=Z(),u=j(),m=useRef(null),[c,v]=useState(null),f=useRef(null),d=useEditorState(C=>C.reviewDisplayMode??"all-markup"),R=r.activatedKey!==null;useEffect(()=>{f.current=null,v(null);},[d]);let[y,h]=useState(0),x=useRef(false),T=useRef(null);useEditorEvent("reviewItemReveal",()=>{x.current=A.current==="balloons",h(C=>C+1);});let S=i.find(C=>C.isActive)??null,p=useRef(S);p.current=S;let N=S?.key??null,V=S!==null&&un(S,r.items,r.paneOpen,l,R),Q=useRef(false);Q.current=c!==null;let A=useRef(l);A.current=l;let ie=useMemo(()=>c?dn(c,i):null,[i,c]),P=ie&&xt(ie.revisionKind,l)?ie:null,Fe=useRef(null);Fe.current=P?.key??null,useEffect(()=>{let C=m.current,L=C?.closest(".docx-review"),K=L?.closest(".docx-editor__scroll-container")??L?.offsetParent;if(!C||!L||!K)return;let $=()=>{f.current=null,v(null);},k=F=>{let ve=F.target;if(!(ve instanceof Element)||C.contains(ve))return;x.current=false;let le=ve.closest("[data-revision-id]");if(le instanceof HTMLElement&&K.contains(le)){let fe=le.classList.contains("docx-table-row--revision");if(le.dataset.revisionKind==="format"||fe||A.current==="balloons"){f.current=null,v(ht(le,L,fe));return}}Q.current&&$();},oe=F=>{A.current!=="balloons"||!Q.current||F.target instanceof Node&&C.contains(F.target)||$();},se=F=>{if(F.key!=="Escape"||F.defaultPrevented||F.isComposing||A.current!=="balloons"||!Q.current||!(F.target instanceof Node)||!K.contains(F.target))return;let ve=C.contains(C.ownerDocument.activeElement);$(),ve&&n.current?.focus();};return K.addEventListener("pointerdown",k,true),K.addEventListener("mousedown",k,true),K.addEventListener("beforeinput",oe,true),C.ownerDocument.addEventListener("keydown",se),()=>{K.removeEventListener("pointerdown",k,true),K.removeEventListener("mousedown",k,true),K.removeEventListener("beforeinput",oe,true),C.ownerDocument.removeEventListener("keydown",se);}},[]),useEffect(()=>{let C=m.current,L=C?.closest(".docx-review"),K=L?.closest(".docx-editor__scroll-container")??L?.offsetParent;if(!C||!L||!K)return;let $=p.current;if(!$){f.current!==null&&(f.current=null,v(null));return}if(!V){if(l==="balloons"&&Fe.current===$.key)return;f.current=null,v(null);return}if(Q.current&&f.current===$.key)return;f.current=$.key,v(null);let k=false,oe=requestAnimationFrame(()=>{if(k)return;let se=Wt(K,$);if(!se){v(null);return}v(ht(se,L,se.classList.contains("docx-table-row--revision")));});return ()=>{k=true,cancelAnimationFrame(oe);}},[d,N,V,l,y]);let de=useEditorState(C=>C.zoom),[Ie,ct]=useState(0);useEditorEvent("change",()=>ct(C=>C+1));let O=useRef(P);O.current=P;let Ne=c!==null;useEffect(()=>{if(!Ne)return;let C=m.current?.closest(".docx-review"),L=C?.closest(".docx-editor__scroll-container")??C?.offsetParent;if(!C||!L)return;let K=()=>v(oe=>oe&&cn(oe,L,C,O.current)),$=requestAnimationFrame(K),k=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{cancelAnimationFrame($),$=requestAnimationFrame(K);});return k?.observe(L),()=>{cancelAnimationFrame($),k?.disconnect();}},[Ne,de,Ie]);let Pe=useRef(false),Ue=useRef(null);P&&(Ue.current=P);let Ye=useRef(false),B=!P&&c!==null&&l==="balloons"&&Ye.current?Ue.current:null,me=useRef(B);me.current=B;let ut=useCallback(C=>{Ye.current=C,!C&&me.current!==null&&v(null);},[]);useEffect(()=>{if(P){Pe.current=true;return}Pe.current&&(Pe.current=false,me.current===null&&v(null));},[P]);let _=P??B,dt=c!==null&&l==="balloons"?P?.key:void 0;if(useEffect(()=>{dt===void 0||!x.current||(x.current=false,T.current?.focus({preventScroll:true}));},[dt,y]),t)return null;let Ze=c?.kind==="format"?"format":"structural",mt=c!==null&&!_&&c.kind!=="format"&&!c.structuralSite,I=l==="balloons"&&_!==null,ae=P===null&&B!==null,X=c?ln(c,I?300:280):null,_e=!(c===null||d!=="all-markup"||mt||_&&r.items.some(C=>C.id===_.id)&&r.paneOpen),je=_e&&I&&P&&P.item.kind==="revision"?u("review.changeAnnouncement",{change:et(P.item,u),author:P.author||u("comments.unknown"),text:P.text}):"";return jsxs("div",{ref:m,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:[jsx("span",{className:"docx-editor-sr-only","aria-live":"polite","data-testid":"review-balloon-live",children:je}),!_e||c===null?null:jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",...I?{"data-variant":"change"}:{},style:{left:X.left,width:X.width,top:c.above?c.top-6:c.bottom+6,transform:c.above?"translateY(-100%)":void 0},onMouseDown:ee,children:_?jsx(D.Provider,{value:_,children:jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":_.revisionKind??"revision",..._.author?{"data-review-author":_.author,"data-review-author-slot":be(s.get(_.author),a.get(_.author)??0)}:{},...I?{ref:T,role:"dialog",tabIndex:-1,"aria-label":u("review.trackedChange")}:{},style:ce(_.author,s.get(_.author),a.get(_.author)??0),onClick:I||ae?void 0:()=>r.setActive(_.key),children:[jsxs("div",{className:"docx-review__head",children:[jsx(Ce,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(he,{}),jsx(xe,{})]}),_.kind==="revision"&&!_.readOnly&&!ae?jsxs("div",{className:"docx-review__actions",children:[jsx(Le,{}),jsx(Ke,{})]}):null]}),I?jsx(ii,{entry:_}):jsx(we,{}),I?jsxs(Fragment,{children:[jsx(He,{}),jsx(_n,{entry:_,orphaned:ae,onDraft:ut},_.key)]}):null]})}):jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":Ze,...c.author?{"data-review-author":c.author,"data-review-author-slot":be(s.get(c.author),a.get(c.author)??0)}:{},style:ce(c.author,s.get(c.author),a.get(c.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:At(c.author)}),jsxs("div",{className:"docx-review__meta",children:[jsx("span",{className:"docx-review__author",children:c.author||u("comments.unknown")}),c.date?jsx(ai,{raw:c.date}):null]})]}),jsx("div",{className:"docx-review__summary",children:jsx("span",{className:"docx-review__label","data-kind":Ze,children:u(Gt(Ze))})})]})})]})}kt.docxReviewPart="Balloon";function ii({entry:e}){let t=j(),o=e.revisionKind;if(o==="replace")return jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":"replace",children:t("review.replaced")})," ",jsx("del",{className:"docx-review__removed",children:e.replacedText})," ",jsx("ins",{className:"docx-review__added",children:e.text})]});let n=o==="insert"||o==="moveTo";return !n&&o!=="delete"&&o!=="moveFrom"?jsx(we,{}):jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":o,children:et(e.item,t)})," ",n?jsx("ins",{className:"docx-review__added",children:e.text}):jsx("del",{className:"docx-review__removed",children:e.text})]})}function ai({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsx("time",{className:"docx-review__time",dateTime:e,children:It.format(t)})}function hi({className:e,furniture:t,asChild:o,hidden:n,children:r,t:i,card:a,preset:s=true,stack:l=true,gap:u=8,filter:m,structural:c=true,formatting:v=false}){let f=useDocxEditor(),d=useEditorState(wn),R=useEditorState(gn),y=useEditorState(yn),h=useEditorState(bn),x=useMemo(()=>{let w=[];return c||w.push("structural"),v||w.push("format"),w.length>0?w:void 0},[c,v]),T=useMemo(()=>({excludeRevisionKinds:x?.filter(w=>w!=="format")}),[x]);useEffect(()=>(f?.setReviewActivationExclusions(x??null,{formattingKinds:["rPrChange","pPrChange"]}),()=>f?.setReviewActivationExclusions(null)),[f,x]);let S=bt(y==="balloons"?hn:Cn),p=bt(T),N=p.setPaneOpen,{t:V}=useTranslation(),Q=useCallback(w=>i?.(w)??V(w),[i,V]),A=useRef(null),ie=useContext(ReviewRailContext);useEffect(()=>ie?.register(),[ie]);let P=p.paneOpen,Fe=useReviewGutter(),de=P&&Fe.inlineEnd>0&&Fe.inlineEnd<REVIEW_PANE_GUTTER,Ie=P&&!de,ct=useMemo(()=>y==="balloons"?new Map(S.items.map(w=>[w.id,w])):null,[S.items,y]),O=useMemo(()=>p.items.filter(w=>reviewPaneListsItem(y,ct?.get(w.id)??w)&&(v||!mn(w))&&(!m||m(w))),[p.items,m,v,y,ct]),Ne=useRef(O);Ne.current=O;let Pe=useEditorState(Rn),Ue=useRef(Pe);Ue.current=Pe,useEditorEvent("reviewItemReveal",({key:w})=>{n||Ue.current==="manual"||Ne.current.some(g=>g.key===w)&&N(true);});let Ye=useRef(P);Ye.current=P,useEffect(()=>{let w=A.current;if(!(!f||!w||d||n))return b(w,f,g=>{Ye.current||Ne.current.some(M=>M.key===g)&&N(true);})},[f,d,n,N]);let B=useSyncExternalStore(useCallback(w=>f?.on("selectionChange",w)??(()=>{}),[f]),()=>f?.getConfiguredAuthor()??null,()=>null),me=useMemo(()=>{let w=new Map;for(let g of O)g.author&&!w.has(g.author)&&w.set(g.author,w.size);return B&&!w.has(B)&&w.set(B,w.size),w},[O,B]),ut=useMemo(()=>{let w=new Map;for(let g of O)w.set(g.id,g);if(y==="balloons")for(let g of S.items)w.has(g.id)||w.set(g.id,g);return w},[O,y,S.items]),[_,dt]=useState(()=>new Map),Ze=useCallback((w,g)=>{g<=0||dt(M=>{if(M.get(w)===g)return M;let U=new Map(M);return U.set(w,g),U});},[]),mt=qo(Ze),I=$o(f,A,O,!d&&!n,de),ae=Vo(f,A,!d&&!n);useEffect(()=>{let w=A.current;if(!f||!w)return;let g=M=>{let U=M.target;if(!(U instanceof Node)||w.contains(U))return;let Y=w.offsetParent;!Y||!Y.contains(U)||Y.querySelector(".docx-paginated-surface")?.contains(U)||f.setActiveReviewItem(null);};return document.addEventListener("mousedown",g,true),()=>document.removeEventListener("mousedown",g,true)},[f,d,n]);let[X,_e]=useState(null),je=useRef(null),C=useCallback(()=>{let w=je.current;w&&(w.editor.releaseSelection(w.pin),je.current=null);},[]),L=useCallback(()=>{if(!f||R)return;let w=f.getSelectionPlacement()?.anchorY??null;if(w===null)return;C();let g=f.retainSelection();g&&(je.current={editor:f,pin:g},N(true),_e(w));},[f,R,C,N]);useEffect(()=>{if(!(n||R))return ie?.registerCommentDraft(L)},[L,n,R,ie]);let K=useCallback(()=>{C(),_e(null),f?.focus();},[f,C]);useEffect(()=>C,[C]),useEffect(()=>{P||X===null||(C(),_e(null));},[P,X,C]);let $=X??p.selectionAnchorY,k=useMemo(()=>{let w=Je(O);return O.filter(g=>!Xe(g,w))},[O]),oe=useMemo(()=>{if(X===null)return k;let w=k.findIndex(M=>M.anchorY!==null&&M.anchorY>X),g={key:Te,anchorY:X};return w===-1?[...k,g]:[...k.slice(0,w),g,...k.slice(w)]},[k,X]),se=useMemo(()=>{let w=new Map(_);for(let g of k){if(w.has(g.key))continue;let M=g.text.length+(g.kind==="revision"?g.replacedText?.length??0:0),U=Math.min(6,Math.max(1,Math.ceil(M/36)));w.set(g.key,64+U*20);}return w},[_,k]),{stacked:F,collapsedKeys:ve}=useMemo(()=>{let w=I.scale,g=new Map,M=new Set,U=Number.NEGATIVE_INFINITY;for(let Y of oe){let pt=Y.anchorY===null?Number.isFinite(U)?U:0:Math.max(Y.anchorY,U);g.set(Y.key,pt);let Xn=Y.anchorY===null?0:(pt-Y.anchorY)*w,Jn="isActive"in Y&&Y.isActive,Co=Xn>480&&!Jn&&Y.key!==Te;Co&&M.add(Y.key);let er=Co?64:se.get(Y.key)??72;U=pt+(er+u)/w;}return {stacked:g,collapsedKeys:M}},[oe,se,u,I.scale]),le=$===null?null:I.top+(de?$:F.get(Te)??$)*I.scale,fe=a?.className,zn=useReviewAuthors(),Ht=Uo(zn,O,me,f),vo=B?me.get(B)??0:0,fo=B?Ht.get(B):void 0,Wn=useMemo(()=>({t:i,cardClassName:fe,readOnly:R,review:{...p,items:O},allItems:S.items,authorSlots:me,authorInfo:Ht,draftAuthor:B,draftAuthorInfo:fo,draftAuthorSlot:vo,byId:ut,measure:mt,beginDraft:L,endDraft:K,commentMarkers:h,revisionsIn:y}),[i,fe,R,p,S.items,O,me,Ht,B,fo,vo,ut,mt,L,K,h,y]);if(n||d)return null;let po={ref:A,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":O.length,"data-open":Ie?"":void 0,"data-compact":de?"":void 0,role:"region","aria-label":Q("review.ariaLabel"),onMouseDown:ee,style:I.left===null?void 0:{left:I.left,right:"auto"}},Re=typeof r=="function"?{parts:{},rest:r}:We(r,"root"),pe=Re.parts,ze=(w,g)=>{if(!(w in pe))return g;let M=pe[w];return !isValidElement(M)||!isValidElement(g)?M:cloneElement(M,{...g.props,...M.props})},wo=jsxs(Fragment,{children:[s||"AddComment"in pe?ze("AddComment",jsx(St,{top:le,drafting:X!==null})):null,!P||X===null||le===null||!s&&!("Draft"in pe)?null:ze("Draft",jsx(eo,{top:le,left:de?I.compactCardLeft:null})),s||"Balloon"in pe?ze("Balloon",jsx(kt,{})):null]}),Gn=jsx(rt,{stack:l,positions:F,collapsed:ve,scale:I.scale,offset:I.top,window:ae,children:Re.rest}),Ro=jsx(_t,{scale:I.scale,offset:I.top,window:ae}),ye=de?k.find(w=>w.key===p.activeKey)??null:null,yo=ye===null?null:ye.anchorY!==null?I.top+ye.anchorY*I.scale:ae!==null?ae.top+yt+24:null,$t=Lo(Re.rest,pe.List),vt=o?null:$t.template,ft=typeof vt=="function"?null:We(vt,"list"),bo=$t.hidden?null:typeof vt=="function"?ye&&vt(ye):ft?.parts.Card&&isValidElement(ft.parts.Card)?Rt(ft.parts.Card,fe):s||$t.fromList?jsx(Oe,{...fe?{className:fe}:{},children:ft?.rest}):null,go=ye&&yo!==null&&I.compactCardLeft!==null&&bo?jsx(D.Provider,{value:ye,children:jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:yo,left:I.compactCardLeft,width:Ge},children:bo})}):null,Qn=Ie?s||"List"in pe?ze("List",Gn):typeof Re.rest=="function"?null:Re.rest:s||"Markers"in pe?jsxs(Fragment,{children:[ze("Markers",Ro),go]}):typeof Re.rest=="function"?null:Re.rest;return jsx(rn,{items:O,children:jsx(Qe.Provider,{value:Wn,children:o&&isValidElement(r)?jsx(Slot,{...po,children:cloneElement(r,void 0,r.props.children,s?Ie?jsx(rt,{stack:l,positions:F,collapsed:ve,scale:I.scale,offset:I.top,window:ae}):jsxs(Fragment,{children:[Ro,go]}):null,wo)}):jsxs("aside",{...po,children:[Ie&&t!==void 0?jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,Qn,wo]})})})}var xi=Object.assign(hi,{List:rt,Empty:ot,Card:Oe,Avatar:Ce,Author:he,Time:xe,Summary:we,Accept:Le,Reject:Ke,Resolve:Xt,Reopen:Jt,Delete:nt,Replies:He,Reply:to,Markers:_t,AddComment:St,Draft:eo,Balloon:kt});var Ii=e=>e.collaborationStatus;function ue(){let e=useDocxEditor();return useEditorState(Ii),e?.collaborationSession()??null}var ro=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,recovering:false,waiting:false,failureCount:0,attached:false});function On(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function _i(e,t){return e.status===t.status&&On(e.reason,t.reason)&&On(e.lastFailure,t.lastFailure)&&e.failureCount===(t.failureCount??0)&&e.recovering===(t.recovering??false)&&e.waiting===(t.waiting??false)}function Si(e){return e.attached??false}function Ln(e,t){if(!e)return t.current=ro,ro;let o=e.statusSnapshot(),n=Si(e);if(_i(t.current,o)&&t.current.attached===n)return t.current;let r=Object.freeze({status:o.status,reason:o.reason,lastFailure:o.lastFailure,live:o.status==="ready",diverged:o.status==="destroyed"||o.status==="error"&&o.recovering!==true,recovering:o.status==="error"&&o.recovering===true,waiting:o.waiting===true,failureCount:o.failureCount??0,attached:n});return t.current=r,r}function io(e){let t=ue(),o=e===void 0?t:e,n=useRef(ro);return useSyncExternalStore(r=>o?.subscribeStatus(()=>r())??(()=>{}),()=>Ln(o,n),()=>Ln(o,n))}function Hn({session:e,onRejoin:t,className:o,children:n}){let{t:r}=useTranslation(),i=ue(),a=e===void 0?i:e,s=io(a),l=Li(a?.sessionId??null,s.failureCount,s.status),u=Oi(s.waiting);if(!a||s.status==="inactive")return null;let m=k({status:s.status,reasonCode:(s.reason??s.lastFailure)?.code,recovering:s.recovering,waiting:s.waiting,stalled:u,refusedRecently:l,offlineEditing:a.offlineEditing!==false}),c=m?r(j$2[m]):"",v=m==="outOfSync"||m==="stalled"?t:void 0,f=null;return m&&n?f=n({kind:m,message:c,...v?{rejoin:v}:{}}):m&&(f=jsxs(Fragment,{children:[jsx("span",{className:"docx-collaboration-status__message",children:c}),v?jsx("button",{type:"button",className:"docx-collaboration-status__action",onClick:v,children:r("collaboration.status.rejoin")}):null]})),jsx("div",{className:`docx-collaboration-status${o?` ${o}`:""}`,...m?{"data-collaboration-status":m}:{},role:"status",children:f})}function Oi(e){let[t,o]=useState(false);return useEffect(()=>{if(o(false),!e)return;let n=setTimeout(()=>o(true),1e4);return ()=>clearTimeout(n)},[e]),e&&t}function Li(e,t,o){let n=useRef({sessionId:e,failureCount:t}),[r,i]=useState(0);return useEffect(()=>{let a=n.current;if(n.current={sessionId:e,failureCount:t},a.sessionId!==e){i(0);return}t<=a.failureCount||(o==="ready"||o==="disconnected")&&i(t);},[e,t,o]),useEffect(()=>{if(r===0)return;let a=setTimeout(()=>i(0),6e3);return ()=>clearTimeout(a)},[r]),r!==0}var lo=Object.freeze([]);function qi(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let o=0;o<e.length;o+=1){let n=e[o],r=t[o];if(n.actorId!==r.actorId||n.name!==r.name||n.color!==r.color||n.role!==r.role||n.isLocal!==r.isLocal)return false}return true}function $n(e,t){if(!e)return t.current=lo,lo;let o=e.participants();return qi(t.current,o)?t.current:(t.current=o,o)}function Tt(e){let t=ue(),o=e===void 0?t:e,n=useRef(lo);return useSyncExternalStore(r=>o?.subscribeParticipants(()=>r())??(()=>{}),()=>$n(o,n),()=>$n(o,n))}var Vn=createContext(null);function Gi(e){return {"--doc-collaboration-accent":e.color}}function qn(e){return e!==void 0?{avatarUrl:e}:{}}function Bn({participant:e,className:t,children:o}){let n=useDocxEditor(),r=useReviewAuthors(),a=useContext(Vn)?.get(e.actorId)??f(r,e,n?l=>n.presenceColorFor(l):void 0,n?l=>n.getReviewAuthorStyle(l)?.color:void 0),s=Qi(e.name);return jsx("span",{className:`docx-collaboration-avatar${t?` ${t}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...a.slot!==null?{"data-collaboration-author-slot":a.slot}:{},title:e.name,role:"img","aria-label":e.name,style:Gi(a),children:o??(s!==void 0?jsx("img",{className:"docx-collaboration-avatar__image",src:s,alt:""}):g(e.name))})}function Qi(e){let t=useDocxEditor(),o=useReviewAuthors();return i(o,e,t?n=>t.getReviewAuthorStyle(n):void 0)}function Xi({session:e,max:t,className:o,children:n}){let r=useDocxEditor(),i$1=Tt(e),a=useReviewAuthors(),{t:s}=useTranslation(),l=useMemo(()=>e$1(a,i$1,r?d=>r.presenceColorFor(d):void 0,r?d=>r.getReviewAuthorStyle(d)?.color:void 0),[a,i$1,r]),u=useMemo(()=>{let d=r?y=>r.getReviewAuthorStyle(y):void 0,R=new Map;for(let y of i$1){if(R.has(y.name))continue;let h=i(a,y.name,d);h!==void 0&&R.set(y.name,h);}return R},[r,i$1,a]),m=useMemo(()=>h(i$1),[i$1]);if(m.length===0)return null;let c=t===void 0?m:m.slice(0,Math.max(0,t)),v=m.length-c.length,f=s("collaboration.moreParticipants",{count:v});return jsxs("span",{className:`docx-collaboration-avatars${o?` ${o}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":s("collaboration.participants"),children:[jsx(Vn.Provider,{value:l,children:c.map(d=>n?jsx(Fragment$1,{children:n({participant:d,color:l.get(d.actorId).color,initials:g(d.name),...qn(u.get(d.name))})},d.actorId):jsx(Bn,{participant:d},d.actorId))}),v>0?jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:f,role:"img","aria-label":f,children:`+${v}`}):null]})}var Ot=Object.freeze([]);function Ji(){return Ot}function ea(){let e=useRef(null);if(e.current===null){let t=Ot,o=false,n=new Set;e.current={subscribe:r=>(n.add(r),()=>n.delete(r)),read:()=>t,write:r=>{t=r.length===0?Ot:r,!o&&(o=true,queueMicrotask(()=>{o=false;for(let i of [...n])i();}));}};}return e.current}function ta({session:e,children:t}){let o=useDocxEditor(),n=ue(),r=e===void 0?n:e,i$1=Tt(r),a=useReviewAuthors(),s=ea(),l=useSyncExternalStore(s.subscribe,s.read,Ji);if(useEffect(()=>{if(!(!o||!r))return o.setRemoteCaretLabelHost({publish:s.write}),()=>{o.setRemoteCaretLabelHost(null),s.write(Ot);}},[o,r,s]),l.length===0)return null;let u=e$1(a,i$1);return jsx(Fragment,{children:l.map(m=>{let{selection:c}=m,v=i$1.find(R=>R.actorId===c.actorId)??null,f$1=m.element.style.getPropertyValue("--doc-remote-color"),d=f$1!==""?f$1:u.get(c.actorId)?.color??f(a,{actorId:c.actorId,name:c.name,...c.color!==void 0?{color:c.color}:{},isLocal:false}).color;return createPortal(t?t({selection:c,participant:v,color:d,...qn(i(a,c.name,o?R=>o.getReviewAuthorStyle(R):void 0))}):c.name,m.element,c.actorId)})})}var oa=Object.freeze({CaretLabels:ta,Avatars:Xi,Avatar:Bn,Status:Hn});function st(e){let t=useDocxEditor();return useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(j$1),[e,t])}var ca=".docx-content-control-boundary";function qe(e,t){let{node:o,definition:n,controlId:r}=e,i=r?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===r):void 0;if(i&&i.kind==="custom"){let l=i.item;return {...o,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...r?{nodeId:r}:{}}}let a=r?ua(t,r,n):void 0,s=n.fromDocx?n.fromDocx({attrs:o.attrs,text:"",...a===void 0?{}:{data:a}}):o.attrs;return s===null?null:{...o,attrs:s,...a===void 0?{}:{data:a},...r?{nodeId:r}:{}}}function ua(e$1,t,o){let n=e$1?.surface;if(!n)return;let r=partOfNodeId(n.session,t),i=customNodePayloadsByControl(n.session.currentPackage(),(r??n.session.part()).name,n.session.part().name).get(t);if(!i)return;let a=e(o.schema,i.data);return a.ok?a.value:void 0}function Be(e,t){let o=e?.closest?.(ca),n=o?.closest(".docx-content-control-chrome"),r=n?.getAttribute("data-tag"),i=r?c$1(r):null;if(!o||!i||!r)return null;let a=t.find(s=>s.tagPrefix===i.prefix&&s.name===i.name);return a?{node:{name:i.name,attrs:i.attrs,tag:r,rect:o.getBoundingClientRect()},definition:a,controlId:n?.getAttribute("data-docx-content-control")??null}:null}var uo=".docx-content-control-boundary",ma=e=>{if(!k$1.test(e.tagPrefix)||!k$1.test(e.name))return [];let t=`${e.tagPrefix}:${e.name}`;return [`.docx-content-control-chrome[data-tag="${t}"]`,`.docx-content-control-chrome[data-tag^="${t}?"]`]};function va(e){let{onNodeClick:t,onNodeHover:o}=e,n=useDocxEditor(),r=st(e.nodes);return useEffect(()=>{let i=document.createElement("style"),a=[];for(let s of r){let l=ma(s);if(l.length===0)continue;let u=s.chrome?.color!==void 0&&CSS.supports("color",s.chrome.color)?s.chrome.color:"var(--doc-accent)";a.push(`${l.map(m=>`${m} ${uo}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${u} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return i.textContent=a.join(`
2
+ `),document.head.append(i),()=>i.remove()},[r]),useEffect(()=>{let i=null,a=null,s=c=>Be(document.elementFromPoint(c.clientX,c.clientY),r),l=c=>{let v=c.button===0?s(c):null;i=v?.controlId??null,a=v?.node.tag??null;},u=c=>{let v=i,f=a;if(i=null,a=null,f===null)return;let d=s(c);if(!d||d.node.tag!==f||v!==null&&d.controlId!==v)return;let R=qe(d,n);R&&(d.definition.onClick?.(R),t?.(R));},m=c=>{let v=Be(c.target,r);if(!v||c.relatedTarget?.closest?.(uo)===c.target.closest(uo))return;let d=qe(v,n);d&&(v.definition.onHover?.(d),o?.(d));};return document.addEventListener("pointerdown",l,true),document.addEventListener("pointerup",u,true),document.addEventListener("mouseover",m),()=>{document.removeEventListener("pointerdown",l,true),document.removeEventListener("pointerup",u,true),document.removeEventListener("mouseover",m);}},[r,n,t,o]),null}var ya=e=>e.editingMode==="viewing";function Zn(e){let{onEditNode:t,onRemoveRefused:o,remove:n=true}=e,r=st(e.nodes),i=useContextMenuTarget(),a=useDocxEditor(),{t:s}=useTranslation(),l=useMemo(()=>i?Be(i,r):null,[i,r]),u=useMemo(()=>l?qe(l,a):null,[l,a]),m=useEditorState(ya),c=useMemo(()=>!l?.definition.reviewCard||!u?null:l.definition.reviewCard({attrs:u.attrs,text:u.text??"",...u.data===void 0?{}:{data:u.data}}),[l,u]);if(!l||!u)return null;let{definition:v}=l,f=v.label??v.name,d=!m&&(v.onEdit!==void 0||t!==void 0),R=!m&&n&&u.nodeId!==void 0&&a!==null;return !c&&!d&&!R?null:jsxs(Fragment,{children:[c?jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsx("span",{className:"docx-contextmenu__custom-title",children:c.title}),c.detail?jsx("span",{className:"docx-contextmenu__custom-detail",children:c.detail}):null]}):null,d?jsx(ContextMenuItem,{label:s("contextMenu.editCustomNode",{label:f}),className:"docx-contextmenu__custom-edit",onSelect:()=>{v.onEdit?.(u),t?.(u,v);}}):null,R?jsx(ContextMenuItem,{label:s("contextMenu.removeCustomNode",{label:f}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let y=q$1(a,u.nodeId);y.ok||o?.(u,y.reason);}}):null,jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}Zn.docxRowPlacement="start";function Ca({collaboration:e,fallback:t=null,author:o,children:n,...r}){let{document:i,modules:a,session:s}=e;if(!i)return jsx(Fragment,{children:t});let l=o??s?.identity.name;return jsx(DocxEditorRoot,{document:i,modules:a,...l!==void 0?{author:l}:{},...r,children:n},s?.sessionId??"local")}var Aa=Symbol("useDocumentCollaboration.createRoom");async function Ia(e){let{createDocumentCollaboration:t}=await import('../document-session-J2YKWERI.js');return t(e)}function Na(e){return e[Aa]??Ia}function Pa(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function _a(e={}){let t=useId(),o=b$1({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:Na(e),hostModules:e.modules??a$1,autoRoom:e.room??null,autoKey:Pa(e.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity});return useMemo(()=>({document:o.document,modules:o.modules,session:o.session,pending:o.pending,error:o.error,connect:o.connect,leave:o.leave}),[o])}export{va as CustomNodeChrome,Zn as CustomNodeContextMenu,oa as DocxEditorCollaboration,Ca as DocxEditorCollaborationRoot,xi as DocxEditorReview,qe as activatedCustomNodeOf,Be as resolveCustomNodeActivation,Tt as useCollaborationParticipants,ue as useCollaborationSession,io as useCollaborationStatus,st as useCustomNodeDefinitions,_a as useDocumentCollaboration,bt as useReview,pn as useReviewAuthor,fn as useReviewItem,Fo as useReviewOf,wr as useStackedReviewPositions};
@@ -1 +1 @@
1
- 'use strict';var chunkGDTCNTK7_cjs=require('../chunk-GDTCNTK7.cjs');require('../chunk-QLZH2Q2C.cjs');var react=require('react');var s=Symbol("useWebrtcCollaboration.createRoom");function c(o){return o?`${o.signaling?o.signaling.join(","):""}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function d(o){let{createWebrtcCollaboration:t}=await import('../collaboration/webrtc.cjs');return t(o)}function b(o){return o[s]??d}function p(o={}){let t=react.useId(),e=chunkGDTCNTK7_cjs.b({ownerKey:`react-webrtc:${t}`,hookName:"useWebrtcCollaboration",createRoom:b(o),hostModules:o.modules??chunkGDTCNTK7_cjs.a,autoRoom:o.room??null,autoKey:c(o.room??null),rejoinOptionsOf:r=>({...r,bootstrap:{kind:"join"}}),identityOf:r=>r.identity});return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}exports.useWebrtcCollaboration=p;
1
+ 'use strict';var chunkOT5R3IYV_cjs=require('../chunk-OT5R3IYV.cjs');require('../chunk-QLZH2Q2C.cjs');var react=require('react');var u=Symbol("useWebrtcCollaboration.createRoom");function p(o){return o?`${o.signaling?o.signaling.join(","):""}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function C(o){let{createWebrtcCollaboration:t}=await import('../collaboration/webrtc.cjs');return t(o)}function m(o){return o[u]??C}function W(o={}){let t=react.useId(),e=chunkOT5R3IYV_cjs.b({ownerKey:`react-webrtc:${t}`,hookName:"useWebrtcCollaboration",createRoom:m(o),hostModules:o.modules??chunkOT5R3IYV_cjs.a,autoRoom:o.room??null,autoKey:p(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room,s=react.useCallback(n=>r?.subscribeUnsyncedChanges?.(n)??(()=>{}),[r]),a=react.useSyncExternalStore(s,()=>r?.unsyncedChanges?.()??0,()=>0);return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:a,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,a])}exports.useWebrtcCollaboration=W;
@@ -1,25 +1,40 @@
1
+ /**
2
+ * `@docx-editor.dev/pro/react/webrtc` — React hook that owns a WebRTC room.
3
+ *
4
+ * Import this subpath only when you use WebRTC. `@docx-editor.dev/pro/react`
5
+ * does not load a network provider.
6
+ *
7
+ * @packageDocumentation
8
+ * @public
9
+ */
1
10
  import * as Y from 'yjs';
2
11
  import { WebrtcProvider } from 'y-webrtc';
3
12
  import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
4
13
  import { EditorModule } from '@docx-editor.dev/core/editor';
5
- import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-B-ds4k64.cjs';
6
- export { b as CollaborationIdentityUpdate } from '../session-B-ds4k64.cjs';
7
- import 'y-protocols/awareness';
14
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-BQ1vBt5Q.cjs';
15
+ export { b as CollaborationIdentityUpdate } from '../types-BQ1vBt5Q.cjs';
8
16
 
9
17
  /** Bootstrap for one WebRTC room. @public */
10
18
  type UseWebrtcCollaborationBootstrap = CollaborationBootstrap;
11
19
  /** Arguments for {@link UseWebrtcCollaborationReturn.connect}. @public */
12
20
  interface UseWebrtcCollaborationConnectOptions {
21
+ /** Room id shared by every peer. Make one with `createCollaborationRoomId`. */
13
22
  readonly roomId: string;
23
+ /** The local participant. Recorded as the author of this replica's changes. */
14
24
  readonly identity: CollaborationIdentity;
25
+ /** Whether to seed the room, join it, or let the peers decide. */
15
26
  readonly bootstrap: UseWebrtcCollaborationBootstrap;
16
27
  /**
17
28
  * Admit local edits while the transport is `disconnected`. Buffered updates merge on
18
- * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
29
+ * reconnect. On by default; pass `false` to pause editing while disconnected. See
30
+ * {@link CreateDocumentCollaborationOptions.offlineEditing}.
19
31
  */
20
32
  readonly offlineEditing?: boolean;
33
+ /** Signaling server URLs. Omitted, the room uses the public demo endpoints and warns once. */
21
34
  readonly signaling?: readonly string[];
35
+ /** STUN and TURN servers for the peer connections. Pass TURN servers in production. */
22
36
  readonly iceServers?: readonly RTCIceServer[];
37
+ /** Signaling encryption key. Every peer passes the same value. */
23
38
  readonly password?: string;
24
39
  }
25
40
  /** Input for {@link useWebrtcCollaboration}. @public */
@@ -32,13 +47,18 @@ interface UseWebrtcCollaborationOptions {
32
47
  /**
33
48
  * Connect this room on mount. Omit it and call
34
49
  * {@link UseWebrtcCollaborationReturn.connect} after the user chooses a room.
50
+ * A different room, server, bootstrap kind, or `actorId` leaves the old room and
51
+ * connects the new one, and `null` leaves. A room opened with `connect` stays.
35
52
  */
36
53
  readonly room?: UseWebrtcCollaborationConnectOptions | null;
37
54
  }
38
55
  /** Values {@link useWebrtcCollaboration} returns. @public */
39
56
  interface UseWebrtcCollaborationReturn {
57
+ /** The room's document as `.docx` bytes to mount. Null until the room is ready. */
40
58
  readonly document: Uint8Array | null;
59
+ /** Modules to pass to the editor. They include the collaboration module once ready. */
41
60
  readonly modules: readonly EditorModule[];
61
+ /** The live session for status and presence. Null while no room is connected. */
42
62
  readonly session: CollaborationSession | null;
43
63
  /**
44
64
  * The room's shared Yjs document, owned by the hook. Null while no room is connected.
@@ -54,7 +74,15 @@ interface UseWebrtcCollaborationReturn {
54
74
  * introspection). The hook destroys it on leave and unmount.
55
75
  */
56
76
  readonly provider: WebrtcProvider | null;
77
+ /** True while a connect is in progress. */
57
78
  readonly pending: boolean;
79
+ /**
80
+ * Local changes no peer has received: made while no peer was connected, and not synced
81
+ * since. A WebRTC room has no server, so these changes exist only in this browser, and
82
+ * closing the page loses them. Warn before the page closes while it is above zero.
83
+ */
84
+ readonly unsyncedChanges: number;
85
+ /** The connect failure or session failure, or null. Check it before `document`. */
58
86
  readonly error: CollaborationFailure | null;
59
87
  /**
60
88
  * Connect a room. RESOLVES with the failure, or null on success — it does not reject.
@@ -68,8 +96,8 @@ interface UseWebrtcCollaborationReturn {
68
96
  * Destroy the room and carry on editing locally.
69
97
  *
70
98
  * The current bytes live in the editor, not in this hook, so the argument is required:
71
- * pass `await editor.save()` to keep what the room typed. The hook remounts the editor
72
- * from exactly these bytes.
99
+ * pass the bytes `editor.save()` resolves with, as `new Uint8Array(saved)` after a `null`
100
+ * check, to keep what the room typed. The hook remounts the editor from exactly these bytes.
73
101
  */
74
102
  readonly leave: (nextDocument: Uint8Array) => void;
75
103
  /**
@@ -77,7 +105,7 @@ interface UseWebrtcCollaborationReturn {
77
105
  * again to the same room with the same identity, signaling, and password.
78
106
  *
79
107
  * The reconnect always uses bootstrap `{ kind: 'join' }`, because an active room still
80
- * exists on the other peers. When no peer holds the room any more, the join rejects with
108
+ * exists on the other peers. When no peer holds the room any more, the rejoin resolves with
81
109
  * `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
82
110
  * stays mounted locally. A connect that failed also counts as the prior attempt, so
83
111
  * rejoin retries it as a joiner.
@@ -1,25 +1,40 @@
1
+ /**
2
+ * `@docx-editor.dev/pro/react/webrtc` — React hook that owns a WebRTC room.
3
+ *
4
+ * Import this subpath only when you use WebRTC. `@docx-editor.dev/pro/react`
5
+ * does not load a network provider.
6
+ *
7
+ * @packageDocumentation
8
+ * @public
9
+ */
1
10
  import * as Y from 'yjs';
2
11
  import { WebrtcProvider } from 'y-webrtc';
3
12
  import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
4
13
  import { EditorModule } from '@docx-editor.dev/core/editor';
5
- import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-B-ds4k64.js';
6
- export { b as CollaborationIdentityUpdate } from '../session-B-ds4k64.js';
7
- import 'y-protocols/awareness';
14
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-BQ1vBt5Q.js';
15
+ export { b as CollaborationIdentityUpdate } from '../types-BQ1vBt5Q.js';
8
16
 
9
17
  /** Bootstrap for one WebRTC room. @public */
10
18
  type UseWebrtcCollaborationBootstrap = CollaborationBootstrap;
11
19
  /** Arguments for {@link UseWebrtcCollaborationReturn.connect}. @public */
12
20
  interface UseWebrtcCollaborationConnectOptions {
21
+ /** Room id shared by every peer. Make one with `createCollaborationRoomId`. */
13
22
  readonly roomId: string;
23
+ /** The local participant. Recorded as the author of this replica's changes. */
14
24
  readonly identity: CollaborationIdentity;
25
+ /** Whether to seed the room, join it, or let the peers decide. */
15
26
  readonly bootstrap: UseWebrtcCollaborationBootstrap;
16
27
  /**
17
28
  * Admit local edits while the transport is `disconnected`. Buffered updates merge on
18
- * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
29
+ * reconnect. On by default; pass `false` to pause editing while disconnected. See
30
+ * {@link CreateDocumentCollaborationOptions.offlineEditing}.
19
31
  */
20
32
  readonly offlineEditing?: boolean;
33
+ /** Signaling server URLs. Omitted, the room uses the public demo endpoints and warns once. */
21
34
  readonly signaling?: readonly string[];
35
+ /** STUN and TURN servers for the peer connections. Pass TURN servers in production. */
22
36
  readonly iceServers?: readonly RTCIceServer[];
37
+ /** Signaling encryption key. Every peer passes the same value. */
23
38
  readonly password?: string;
24
39
  }
25
40
  /** Input for {@link useWebrtcCollaboration}. @public */
@@ -32,13 +47,18 @@ interface UseWebrtcCollaborationOptions {
32
47
  /**
33
48
  * Connect this room on mount. Omit it and call
34
49
  * {@link UseWebrtcCollaborationReturn.connect} after the user chooses a room.
50
+ * A different room, server, bootstrap kind, or `actorId` leaves the old room and
51
+ * connects the new one, and `null` leaves. A room opened with `connect` stays.
35
52
  */
36
53
  readonly room?: UseWebrtcCollaborationConnectOptions | null;
37
54
  }
38
55
  /** Values {@link useWebrtcCollaboration} returns. @public */
39
56
  interface UseWebrtcCollaborationReturn {
57
+ /** The room's document as `.docx` bytes to mount. Null until the room is ready. */
40
58
  readonly document: Uint8Array | null;
59
+ /** Modules to pass to the editor. They include the collaboration module once ready. */
41
60
  readonly modules: readonly EditorModule[];
61
+ /** The live session for status and presence. Null while no room is connected. */
42
62
  readonly session: CollaborationSession | null;
43
63
  /**
44
64
  * The room's shared Yjs document, owned by the hook. Null while no room is connected.
@@ -54,7 +74,15 @@ interface UseWebrtcCollaborationReturn {
54
74
  * introspection). The hook destroys it on leave and unmount.
55
75
  */
56
76
  readonly provider: WebrtcProvider | null;
77
+ /** True while a connect is in progress. */
57
78
  readonly pending: boolean;
79
+ /**
80
+ * Local changes no peer has received: made while no peer was connected, and not synced
81
+ * since. A WebRTC room has no server, so these changes exist only in this browser, and
82
+ * closing the page loses them. Warn before the page closes while it is above zero.
83
+ */
84
+ readonly unsyncedChanges: number;
85
+ /** The connect failure or session failure, or null. Check it before `document`. */
58
86
  readonly error: CollaborationFailure | null;
59
87
  /**
60
88
  * Connect a room. RESOLVES with the failure, or null on success — it does not reject.
@@ -68,8 +96,8 @@ interface UseWebrtcCollaborationReturn {
68
96
  * Destroy the room and carry on editing locally.
69
97
  *
70
98
  * The current bytes live in the editor, not in this hook, so the argument is required:
71
- * pass `await editor.save()` to keep what the room typed. The hook remounts the editor
72
- * from exactly these bytes.
99
+ * pass the bytes `editor.save()` resolves with, as `new Uint8Array(saved)` after a `null`
100
+ * check, to keep what the room typed. The hook remounts the editor from exactly these bytes.
73
101
  */
74
102
  readonly leave: (nextDocument: Uint8Array) => void;
75
103
  /**
@@ -77,7 +105,7 @@ interface UseWebrtcCollaborationReturn {
77
105
  * again to the same room with the same identity, signaling, and password.
78
106
  *
79
107
  * The reconnect always uses bootstrap `{ kind: 'join' }`, because an active room still
80
- * exists on the other peers. When no peer holds the room any more, the join rejects with
108
+ * exists on the other peers. When no peer holds the room any more, the rejoin resolves with
81
109
  * `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
82
110
  * stays mounted locally. A connect that failed also counts as the prior attempt, so
83
111
  * rejoin retries it as a joiner.
@@ -1 +1 @@
1
- import {b as b$1,a}from'../chunk-HJB77VBO.js';import'../chunk-Q2VBO66F.js';import {useId,useMemo}from'react';var s=Symbol("useWebrtcCollaboration.createRoom");function c(o){return o?`${o.signaling?o.signaling.join(","):""}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function d(o){let{createWebrtcCollaboration:t}=await import('../collaboration/webrtc.js');return t(o)}function b(o){return o[s]??d}function p(o={}){let t=useId(),e=b$1({ownerKey:`react-webrtc:${t}`,hookName:"useWebrtcCollaboration",createRoom:b(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:c(o.room??null),rejoinOptionsOf:r=>({...r,bootstrap:{kind:"join"}}),identityOf:r=>r.identity});return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}export{p as useWebrtcCollaboration};
1
+ import {b,a}from'../chunk-MWO2ZUEJ.js';import'../chunk-Q2VBO66F.js';import {useId,useCallback,useSyncExternalStore,useMemo}from'react';var u=Symbol("useWebrtcCollaboration.createRoom");function p(o){return o?`${o.signaling?o.signaling.join(","):""}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function C(o){let{createWebrtcCollaboration:t}=await import('../collaboration/webrtc.js');return t(o)}function m(o){return o[u]??C}function W(o={}){let t=useId(),e=b({ownerKey:`react-webrtc:${t}`,hookName:"useWebrtcCollaboration",createRoom:m(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:p(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room,s=useCallback(n=>r?.subscribeUnsyncedChanges?.(n)??(()=>{}),[r]),a$1=useSyncExternalStore(s,()=>r?.unsyncedChanges?.()??0,()=>0);return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:a$1,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,a$1])}export{W as useWebrtcCollaboration};