@docx-editor.dev/react 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import*as Ye from'react';import Ye__default,{createContext,useState,useEffect,forwardRef,useCallback,useRef,useId,useMemo,useContext,Children,Fragment as Fragment$1,useLayoutEffect,isValidElement,cloneElement,useSyncExternalStore,useImperativeHandle,Component}from'react';import {CHROME_MENUS,tableChromeIconPaths,chromeProbeForSlot,commandForSlotValue,FIT_WIDTH_ZOOM_MODE,sameZoomMode,AUTO_ZOOM_MODE,TABLE_BORDER_TARGET_OPTIONS,TABLE_BORDER_STYLE_OPTIONS,TABLE_BORDER_WIDTH_OPTIONS,runToolbarCommand,toolbarCommandState,commandForSlot,createDocxEditor,resolveZoomMode,defaultTableLabel,CHROME_GROUPS,chromeSlotId,IMAGE_WRAP_TARGETS,validateDrawingPositionInput,positionInputFromPropertiesCommand,DRAWING_REL_FROM_H,DRAWING_REL_FROM_V,formattingBarChromeGroups,DEFAULT_TABLE_CHROME_DRAFT,runTableChromeCommand,createImageOverlayScrollPort,captureImageMutationPreconditions,isStaleImageInteractionCommit,selectedDrawingOverlayTargetOf,IMAGE_OVERLAY_NUDGE_SHIFT_PT,IMAGE_OVERLAY_NUDGE_PT,computeImageResizeResult,resizePreservesAspect,computeMovedImagePosition,overlayFrameToSheetCssPixels,dragIndent,handlePosition,executeImageCommand,tableChromeToolbarState,ZOOM_MAX,ZOOM_MIN,cssPixelsToLayoutPoints,finalizeImageOverlayInteraction,SNAP_TWIPS_CM,SNAP_TWIPS_INCH,DEFAULT_IMAGE_RESOURCE_LIMITS,sniffImageMime,validateRasterHeader,tableChromeLabelKeyForTarget,composeFontConfiguration,mountPaginatedSurface,applyThemeTint,applyThemeShade,resolveThemeColorHex}from'@docx-editor.dev/core/editor';export{CHROME_GROUPS,CHROME_MENUS,MAX_RESOLVER_FAMILIES,PX_PER_CM,PX_PER_INCH,WORD_DEFAULT_FONT,chromeMenuSlots,commandForSlot,composeFontConfiguration,createFontSource,generateRulerTicks,loadFonts,rulerPageBox,runToolbarCommand,toolbarCommandState}from'@docx-editor.dev/core/editor';import {en as en$1,createT,deepMerge}from'@docx-editor.dev/i18n';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {cva}from'class-variance-authority';import {clsx}from'clsx';import*as pe from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var Kf=Object.defineProperty;var zf=(e,t,n)=>t in e?Kf(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var nt=(e,t,n)=>zf(e,typeof t!="symbol"?t+"":t,n);var pc="(prefers-color-scheme: dark)";function mc(){return typeof window<"u"&&typeof window.matchMedia=="function"}function fc(){return mc()?window.matchMedia(pc).matches:false}function gc(e,t){return e==="dark"||e==="system"&&t}function bc(e){if(!mc())return ()=>{};let t=window.matchMedia(pc);e(t.matches);let n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}var wi=createContext(null);function A(){return useContext(wi)}var St=createContext(null);var Mi=createContext(en$1),Ii=createContext("en");function wo({i18n:e,children:t}){let n=useContext(Mi),o=useContext(Ii),r=typeof e?._lang=="string"?e._lang:o,a=useMemo(()=>deepMerge(n,e),[n,e]);return jsx(Ii.Provider,{value:r,children:jsx(Mi.Provider,{value:a,children:t})})}function _(){let e=useContext(Mi),t=useContext(Ii);return {t:useMemo(()=>createT(e,t),[e,t])}}function Tc(e){let{t}=_();return useCallback((n,o)=>e?.get(n)??t(n,o),[e,t])}var sn=Object.freeze({scope:Object.freeze({kind:"body"}),isLoading:true,parseError:null,editable:false,zoom:1,selection:null,selectionCollapsed:true,formatting:null,table:null,tocContext:null,image:null,page:Object.freeze({current:0,total:0}),canUndo:false,canRedo:false});var jf=()=>{};function Qf(e){let t=false;return ()=>{if(t)return;t=true;let n=globalThis.navigator?.scheduling,o=()=>{t=false,e();};n?.isInputPending?.({includeContinuous:true})?setTimeout(o,0):queueMicrotask(o);}}function q(e,t=Object.is,n){let o=A(),r=n?.onSubscribe,a=n?.onUnsubscribe,i=useCallback(d=>{if(!o)return jf;let p=false;r?.();let f=Qf(()=>{p||d();}),m=[o.on("change",f),o.on("selectionChange",f),o.on("error",f)];return ()=>{p=true,a?.();for(let g of m)g();}},[o,r,a]),s=useMemo(()=>{let d=false,p,f;return m=>{if(d&&m===p)return f;let g=e(m);return d&&t(f,g)?(p=m,f):(d=true,p=m,f=g,g)}},[o,e,t]),c=useCallback(()=>s(o?o.snapshot():sn),[o,s]),l=useCallback(()=>s(sn),[s]);return useSyncExternalStore(i,c,l)}var Pc=12700,Cc=96;function o0(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function n0(e,t,n,o){let r=e*72/n,a=t*72/o;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(a*100)/100)}}function kr(e){let t=DEFAULT_IMAGE_RESOURCE_LIMITS;if(e.byteLength===0)return {ok:false,reasonKey:"imageInsert.errors.emptyFile"};if(e.byteLength>t.maxEncodedBytes)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let n=sniffImageMime(e);if(!o0(n))return n==="image/svg+xml"||n==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let o=validateRasterHeader(e,n);if(!o)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(o.pixelWidth*o.pixelHeight>t.maxPixels||o.pixelWidth>t.maxDimension||o.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:a,heightPoints:i}=n0(o.pixelWidth,o.pixelHeight,Cc,Cc);return Object.freeze({ok:true,bytes:e,mime:n,widthPoints:a,heightPoints:i})}function kt(e){return Math.round(e/Pc*100)/100}function cn(e){return Math.round(e*Pc)}var dn=createContext({t:void 0,onSave:void 0});function Ri(e){let{t}=_();return n=>e?.(n)??t(n)}function Y(){let{t:e}=useContext(dn);return Ri(e)}function d0(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function _i(e){return typeof e=="string"}function u0(e){return JSON.stringify(e,Object.keys(e).sort())}function ne(e){let t=A(),n=_i(e)?e:u0(e),o=useRef(e);o.current=e;let r=useCallback(s=>{let c=o.current;if(_i(c)){let d=toolbarCommandState(t,c);return {active:d.active,enabled:d.enabled,disabledReason:d.disabledReason}}if(!t)return {active:false,enabled:false,disabledReason:null};let l=t.can(c);return {active:t.isActive(c),enabled:l.ok,disabledReason:l.ok?null:l.reason??null}},[t,n]),a=q(r,d0),i=useCallback(()=>{let s=o.current;return _i(s)?runToolbarCommand(t,s).ok:t?t.exec(s).ok:false},[t,n]);return useMemo(()=>({execute:i,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason}),[i,a])}function g0(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function b0(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=g0(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 W({children:e,...t}){let n=Children.only(e);if(!isValidElement(n))return null;let o=n.props,r=b0(t,o),a=n.ref,i=t.ref;return (a||i)&&(r.ref=s=>{for(let c of [a,i])typeof c=="function"?c(s):c&&typeof c=="object"&&(c.current=s);}),cloneElement(n,r)}function ee(e){for(let t of CHROME_GROUPS)for(let n of t.controls)if(chromeSlotId(t,n)===e)return n;return null}function te(e){return e?jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsx("path",{d:t,fill:"currentColor"},t))}):null}function O(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Xt(e){let{slot:t,icon:n,asChild:o,className:r,children:a,hidden:i}=e,{execute:s,isActive:c,isEnabled:l,disabledReason:d}=ne(t),p=Y();if(i)return null;let f=ee(t),m=p(f?.labelKey??t),g=commandForSlot(t),u=g?.type==="toggleMark"||g?.type==="setAlignment",h={onClick:()=>s(),onMouseDown:O,disabled:!l,"data-slot":t,className:`docx-toolbar__button${r?` ${r}`:""}`,...c?{"data-active":""}:{},...l?{}:{"data-disabled":""},...u?{"aria-pressed":c}:{},"aria-label":m,title:d??m};return o?jsx(W,{...h,children:a}):jsx("button",{type:"button",...h,children:n??a??te(f?.paths)})}Xt.docxToolbarPart=true;var P0="image/png,image/jpeg,image/gif",Di=createContext(null);function _r(){let e=useContext(Di);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Li(){return useContext(Di)}function Nr({children:e}){let t=A(),{t:n}=_(),o=useRef(null),r=useRef(false),a=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),i=q(a,(u,h)=>u.enabled===h.enabled&&u.disabledReason===h.disabledReason),s=i.enabled,c=i.disabledReason,l=useCallback(async u=>{if(!t||r.current)return;let h=kr(u);if(!h.ok){window.alert(n(h.reasonKey));return}let b={type:"insertImage",data:h.bytes,mime:h.mime,widthPoints:h.widthPoints,heightPoints:h.heightPoints},v=t.canExecuteImageCommand?.(b);if(v&&!v.ok){window.alert(v.reason??n("imageInsert.errors.refused"));return}r.current=true;try{let C=await executeImageCommand(t,b);C.ok?t.focus():window.alert(C.reason??n("imageInsert.errors.refused"));}finally{r.current=false;}},[t,n]),d=useCallback(async u=>{let h=u?.[0];if(!h)return;let b=await h.arrayBuffer();await l(new Uint8Array(b));},[l]),p=useCallback(async u=>{if(!u)return;let h=[...u.files].find(b=>b.type.startsWith("image/"));if(h){await d([h]);return}for(let b of u.items){if(b.kind!=="file"||!b.type.startsWith("image/"))continue;let v=b.getAsFile();if(!v)continue;let C=await v.arrayBuffer();await l(new Uint8Array(C));return}},[l,d]),f=useCallback(()=>{s&&o.current?.click();},[s]),m=useCallback(async u=>{let h=u.currentTarget;await d(h.files),h.value="";},[d]),g=useMemo(()=>({openFilePicker:f,insertFromFileList:d,insertFromDataTransfer:p,isEnabled:s,disabledReason:c,inputRef:o,onInputChange:m}),[f,d,p,s,c,m]);return jsxs(Di.Provider,{value:g,children:[jsx("input",{ref:o,type:"file",accept:P0,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:m,onMouseDown:u=>u.stopPropagation()}),e]})}function Dr({className:e,hidden:t,asChild:n,children:o}){let{openFilePicker:r,isEnabled:a,disabledReason:i}=_r(),s=Y();if(t)return null;let c=ee("image.insert"),l=s(c?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":l,title:i??l,onMouseDown:O,onClick:r};return n?jsx(W,{...d,children:o}):jsx("button",{...d,children:o??te(c?.paths)})}Dr.docxSlot="image.insert";var un=Object.assign(Dr,{docxSlot:"image.insert"});var F0=["nw","n","ne","e","se","s","sw","w"],Nc=40,Dc=12;function A0(e){return `imageOverlay.handle.${e}`}function O0(e){switch(e){case "nw":case "se":return "nwse-resize";case "ne":case "sw":return "nesw-resize";case "n":case "s":return "ns-resize";default:return "ew-resize"}}function Z0(e){return {nw:{x:"0%",y:"0%"},n:{x:"50%",y:"0%"},ne:{x:"100%",y:"0%"},e:{x:"100%",y:"50%"},se:{x:"100%",y:"100%"},s:{x:"50%",y:"100%"},sw:{x:"0%",y:"100%"},w:{x:"0%",y:"50%"}}[e]}function B0(e,t){return e>0&&t>0?"se":e>0&&t<0?"ne":e<0&&t>0?"sw":e<0&&t<0?"nw":e>0?"e":e<0?"w":t>0?"s":"n"}function Hi({containerRef:e,portalRef:t,scrollPort:n}){let o=A(),{t:r}=_(),[a,i]=useState(null),[s,c]=useState(null),l=useRef(null);l.current=s;let d=useRef(null),p=useRef(null),f=useRef(null),m=useRef(null),g=useRef(null);useEffect(()=>{let S=e.current;if(!S)return;let y=x=>{let E=(x.target instanceof Element?x.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");m.current=E??null,E&&E===a?.id&&queueMicrotask(()=>f.current?.focus({preventScroll:true}));};return S.addEventListener("pointerdown",y,{capture:true}),()=>S.removeEventListener("pointerdown",y,{capture:true})},[e,a?.id]),useEffect(()=>{if(!o){i(null);return}let S=()=>{i(selectedDrawingOverlayTargetOf(o.surface));},y=()=>{queueMicrotask(S);};S();let x=[o.on("change",y),o.on("selectionChange",S)];return ()=>{for(let M of x)M();}},[o]),useEffect(()=>{if(n){g.current=n;return}let S=e.current;if(!S||!o?.surface)return;let y=S.closest(".docx-editor__scroll-container");if(!y)return;let x=o.surface.overlayCoordinates();return g.current=createImageOverlayScrollPort(y,x.paintScale),()=>{g.current=null;}},[e,o,n]);let u=useCallback(()=>{c(null),d.current=null;let S=p.current;if(p.current=null,S)try{S.releasePointerCapture(S._lastPointerId??0);}catch{}},[]),h=useCallback((S,y,x,M,E,w,N)=>{if(!o?.surface)return;let F=captureImageMutationPreconditions(o);if(!F)return;let H=o.surface.publishedLayout();d.current=Object.freeze({x:M,y:E}),p.current=w,w._lastPointerId=N;try{w.setPointerCapture(N);}catch{}c({session:Object.freeze({drawingNodeId:x.id,startBounds:Object.freeze({x:x.x,y:x.y,width:x.width,height:x.height}),startWidthEmu:x.widthEmu,startHeightEmu:x.heightEmu,startPosition:x.position,anchorFrameOrigin:x.anchorFrameOrigin,transform:x.transform,mode:S,handle:y,preconditions:F,layoutRevision:H.revision,packageRevision:o.surface.session.packageRevision(),kind:x.kind}),bounds:x,accumulatedScrollPt:0}),f.current?.focus({preventScroll:true});},[o]),b=useCallback((S,y,x,M,E)=>{if(!o)return;if(isStaleImageInteractionCommit(o,S)){u();return}S.mode==="resize"?o.exec({type:"setImageProperties",widthEmu:y,heightEmu:x,...E?.mode==="simple"?{horizontalEmu:E.horizontalEmu,verticalEmu:E.verticalEmu}:{},...E?.mode==="frame"?{...E.horizontalEmu!==void 0?{horizontalEmu:E.horizontalEmu}:{},...E.verticalEmu!==void 0?{verticalEmu:E.verticalEmu}:{}}:{}}):S.mode==="move"&&E&&o.exec({type:"setImagePosition",...E}),u();},[u,o]),v=useCallback(S=>{if(!o)return;let y=l.current?.bounds??selectedDrawingOverlayTargetOf(o.surface);if(!y)return;if(l.current&&S.key==="Escape"){S.preventDefault(),S.stopPropagation(),u();return}if(l.current)return;let x=S.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(S.key==="Delete"||S.key==="Backspace"){S.preventDefault(),S.stopPropagation(),o.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(S.key))return;S.preventDefault(),S.stopPropagation();let M=S.key==="ArrowLeft"?-x:S.key==="ArrowRight"?x:0,E=S.key==="ArrowUp"?-x:S.key==="ArrowDown"?x:0;if(S.altKey){if(!y.canResize)return;let N=B0(M,E),F=computeImageResizeResult({handle:N,startWidthEmu:y.widthEmu,startHeightEmu:y.heightEmu,startBounds:{x:y.x,y:y.y,width:y.width,height:y.height},startPosition:y.position,anchorFrameOrigin:y.anchorFrameOrigin,deltaXPt:M,deltaYPt:E,transform:y.transform,preserveAspect:resizePreservesAspect(N,y.aspectLocked,S.shiftKey),kind:y.kind});o.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(y.kind!=="anchored"||!y.canMove||!y.position)return;let w=computeMovedImagePosition(y.position,M,E);o.exec({type:"setImagePosition",...w});},[u,o]);useEffect(()=>{if(!s||!o?.surface)return;let S=o.surface.overlayCoordinates(),y=M=>{let E=l.current,w=d.current;if(!E||!w)return;let N=cssPixelsToLayoutPoints(M.clientX-w.x,S.paintScale),F=cssPixelsToLayoutPoints(M.clientY-w.y,S.paintScale);if(E.session.mode==="move"){let k=0,D=g.current,I=e.current?.closest(".docx-editor__scroll-container");if(D&&I){let z=I.getBoundingClientRect();M.clientY>z.bottom-Nc?k=Dc:M.clientY<z.top+Nc&&(k=-Dc),k!==0&&(k=D.scrollBy(k));}let R=E.accumulatedScrollPt+k;c({...E,accumulatedScrollPt:R,bounds:Object.freeze({...E.bounds,x:E.session.startBounds.x+N,y:E.session.startBounds.y+F+R})});return}if(!E.session.handle)return;let H=computeImageResizeResult({handle:E.session.handle,startWidthEmu:E.session.startWidthEmu,startHeightEmu:E.session.startHeightEmu,startBounds:E.session.startBounds,startPosition:E.session.startPosition,anchorFrameOrigin:E.session.anchorFrameOrigin,deltaXPt:N,deltaYPt:F,transform:E.session.transform,preserveAspect:resizePreservesAspect(E.session.handle,E.bounds.aspectLocked,M.shiftKey),kind:E.session.kind});c({...E,bounds:Object.freeze({...E.bounds,x:H.previewBounds.x,y:H.previewBounds.y,width:H.previewBounds.width,height:H.previewBounds.height,widthEmu:H.widthEmu,heightEmu:H.heightEmu})});},x=M=>{let E=l.current;if(E)if(M.type==="pointerup"){let w=cssPixelsToLayoutPoints(M.clientX-(d.current?.x??M.clientX),S.paintScale),N=cssPixelsToLayoutPoints(M.clientY-(d.current?.y??M.clientY),S.paintScale),F=finalizeImageOverlayInteraction({session:E.session,deltaXPt:w,deltaYPt:N,accumulatedScrollPt:E.accumulatedScrollPt,aspectLocked:E.bounds.aspectLocked,shiftKey:M.shiftKey,anchorFrameOrigin:E.session.anchorFrameOrigin});b(E.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else u();};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x);}},[u,b,e,o,s]),useEffect(()=>{!a||m.current!==a.id||(m.current=null,f.current?.focus({preventScroll:true}));},[a]);let C=s?.bounds??a,P=useMemo(()=>{if(!o?.surface||!C)return null;let S=o.surface.publishedLayout(),y=o.surface.overlayCoordinates(),x=overlayFrameToSheetCssPixels(S,{pageIndex:C.pageIndex,x:C.x,y:C.y,width:C.width,height:C.height},y),M=C.canResize,E=C.kind==="anchored"&&C.canMove;return jsxs("div",{ref:f,className:"docx-image-selection-overlay docx-editor-one-surface__overlay-control","data-drawing-node-id":C.id,tabIndex:0,onKeyDown:v,children:[jsx("div",{className:"docx-image-selection-overlay__frame",role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${x.left}px`,top:`${x.top}px`,width:`${x.width}px`,height:`${x.height}px`,cursor:E?"move":"default"},onPointerDown:w=>{O(w),!(!E||!C.position)&&w.button===0&&(w.preventDefault(),w.stopPropagation(),h("move",null,C,w.clientX,w.clientY,w.currentTarget,w.pointerId));}}),M?F0.map(w=>{let N=Z0(w);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(A0(w)),tabIndex:0,style:{left:`calc(${x.left}px + ${x.width}px * ${parseFloat(N.x)/100} - 5px)`,top:`calc(${x.top}px + ${x.height}px * ${parseFloat(N.y)/100} - 5px)`,cursor:O0(w)},onPointerDown:F=>{O(F),F.button===0&&(F.preventDefault(),F.stopPropagation(),h("resize",w,C,F.clientX,F.clientY,F.currentTarget,F.pointerId));}},w)}):null]})},[C,h,o,v,r]);return !P||!t.current?null:createPortal(P,t.current)}function Fr({className:e}){let t=A(),n=Li(),o=useRef(null),r=useRef(null);useLayoutEffect(()=>{let s=o.current;if(!(!t||!s))return t.attach(s),()=>{t.detach();}},[t]);let a=useCallback(s=>{if(!n?.isEnabled)return;let c=s.clipboardData;!c||![...c.items].some(d=>d.kind==="file"&&d.type.startsWith("image/"))||(s.preventDefault(),n.insertFromDataTransfer(c));},[n]),i=useCallback(s=>{!n?.isEnabled||![...s.dataTransfer.items].some(l=>l.kind==="file"&&l.type.startsWith("image/"))||(s.preventDefault(),n.insertFromDataTransfer(s.dataTransfer));},[n]);return jsxs("div",{ref:r,className:"docx-content-mount",children:[jsx("div",{ref:o,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:a,onDrop:i}),t?jsx(Hi,{containerRef:o,portalRef:r}):null]})}var V0=e=>e.isLoading;function Fi({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function $0({when:e=false,className:t,style:n,children:o}){let r=q(V0),{t:a}=_();return !e&&!r?null:jsx("div",{className:`docx-editor docx-editor__loading${t?` ${t}`:""}`,style:n,role:"status","aria-live":"polite",children:o??jsxs(Fragment,{children:[jsx(Fi,{}),jsx("span",{className:"docx-editor-sr-only",children:a("loading.label")})]})})}var Ai=Object.assign($0,{Spinner:Fi});var jt=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),J0=e=>e;function eg(){let e=n=>!!n&&(n.width>0||n.height>0);if(typeof document<"u"){let o=document.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(e(o))return {left:o.left,top:o.bottom}}let t=typeof window>"u"?null:window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0),o=n.getBoundingClientRect();if(e(o))return {left:o.left,top:o.bottom};let r=n.startContainer,i=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(i))return {left:i.left,top:i.bottom}}return null}var mn=createContext(null);function Zi(){let e=useContext(mn),t=Or(e===null);return e??t}function Or(e=true){let t=A(),[n,o]=useState(jt),r=useRef(n);r.current=n;let a=q(J0),i=t?t.can({type:"insertText",text:""}).ok:false,s=useCallback((b,v)=>{o({mode:b?"reading":"editing",link:b??null,anchor:v??null,text:b?.text??"",url:b?b.kind==="internal"?`#${b.anchor??""}`:b.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t]),c=useCallback(()=>{t?.surface?.releaseSelection(),o(jt);},[t]),l=useCallback(()=>{let b=eg(),v=t?.surface?.hyperlinks.linkAtCaret()??null;if(v){o({mode:"editing",link:v,anchor:b,text:v.text,url:v.kind==="internal"?`#${v.anchor??""}`:v.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let C=t?.query({type:"selectedText"})??"";t?.surface?.retainSelection(),o({mode:"editing",link:null,anchor:b,text:C,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t]);useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:b=>s(b.link,{left:b.rect.left,top:b.rect.bottom}),onRequest:l})},[t,e,s,l]),useEffect(()=>{let b=r.current;if(b.mode!=="reading"||!b.link)return;let v=t?.surface?.hyperlinks.linkAtCaret()??null;v&&v.id===b.link.id||o(jt);},[a,t]),useEffect(()=>{let b=r.current;if(b.mode!=="editing"||b.link)return;let v=t?.surface;!v||v.retainedSelection()||o(jt);},[a,t]);let d=useCallback(async()=>{let b=r.current.link?.href;if(!b)return false;try{await navigator.clipboard.writeText(b);}catch{return false}return o(v=>({...v,copied:true})),true},[]),p=useCallback(()=>{o(b=>({...b,mode:"editing",copied:false,error:false}));},[]),f=useCallback(b=>{o(v=>({...v,text:b,copied:false,error:false}));},[]),m=useCallback(b=>{o(v=>({...v,url:b,copied:false,error:false}));},[]),g=useCallback(()=>{let b=r.current,v=t?.surface?.hyperlinks;if(!v)return false;let C=b.url.trim();if(C.length===0)return o(y=>({...y,error:true})),false;let P=C.startsWith("#");return v.applyHyperlink({...P?{anchor:C.slice(1)}:{url:C},...b.text.trim().length>0?{text:b.text}:{}})?(c(),true):(o(y=>({...y,error:true})),false)},[t,c]),u=useCallback(()=>{let b=t?.surface?.hyperlinks,v=r.current.link;if(!b)return false;let C=b.removeHyperlink(v?.id);return C&&c(),C},[t,c]),h=useCallback(()=>{let b=t?.surface?.navigation,v=r.current.link;if(!b||!v)return false;if(v.kind==="internal"){let P=v.anchor?b.goToBookmark(v.anchor):false;return P&&o(jt),P}let C=b.openExternal(v.href);return C&&o(jt),C},[t]);return useMemo(()=>({state:n.mode==="closed"?jt:{...n,canEdit:i},open:s,openAtCaret:l,close:c,copy:d,beginEdit:p,setText:f,setUrl:m,commitEdit:g,unlink:u,openTarget:h}),[n,i,s,l,c,d,p,f,m,g,u,h])}var Be={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function rg(e){return e==="sdtLocked"||e==="sdtContentLocked"}function ag(e){return e==="contentLocked"||e==="sdtContentLocked"}function qi(e,t){return !e.ok&&e.code===t}function pt(){let e=useContext(Ki),t=Zr();return e??t}function Zr(){let e=A(),[t,n]=useState(false),[o,r]=useState(false),[a,i]=useState(false),s=q(x=>x),c=e?.surface??null,l=c?.contentControls;useEffect(()=>{r(l?.showAll()??c?.state().contentControls.showAll??false),i(l?.formFill()??c?.state().contentControls.formFill??false);},[s,l,c]);let d=useMemo(()=>{if(!e)return null;let x=l?.atCaret()??null;if(x){let I=l?.disabledReason(x.id,"edit")??null,R=l?.disabledReason(x.id,"remove")??null;return {id:x.id,tag:x.tag??null,alias:x.alias??null,controlType:x.controlType,locked:ag(x.effectiveLock)||I==="locked",removalLocked:rg(x.effectiveLock)||R==="locked",placeholder:x.placeholder,bound:x.bound||I==="bound",effectiveLock:x.effectiveLock}}let M=e.query({type:"contentControlAt"});if(!M)return null;let E=l?.disabledReason(M.id,"edit")??null,w=l?.disabledReason(M.id,"remove")??null,N=e.can({type:"setContentControlValue",value:""}),F=e.can({type:"removeContentControl"}),H=M.locked===true||E==="locked"||qi(N,"locked"),k=E==="bound"||qi(N,"bound"),D=w==="locked"||qi(F,"locked");return {id:M.id,tag:M.tag??null,alias:M.alias??null,controlType:M.controlType,locked:H,removalLocked:D,placeholder:false,bound:k,effectiveLock:null}},[e,s,l]),p=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,s]),f=useCallback(x=>{l?.setShowAll(x),r(x);},[l]),m=useCallback(x=>{l?.setFormFill(x),i(x);},[l]),g=useCallback(()=>f(!o),[f,o]),u=useCallback(()=>m(!a),[m,a]),h=useCallback(()=>n(true),[]),b=useCallback(()=>n(false),[]),v=useCallback(()=>n(x=>!x),[]),C=useMemo(()=>{if(!d)return "no content control at the current selection";if(l){let M=l.disabledReason(d.id,"edit");return M==="locked"?"the content control is locked":M==="bound"?"the content control is bound to external data":M==="notFound"?"the content control was not found":M}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let x=e.can({type:"setContentControlValue",value:""});return x.ok?null:x.reason},[d,l,e]),P=useMemo(()=>{if(!d)return "no content control at the current selection";if(l){let M=l.disabledReason(d.id,"remove");return M==="locked"?"the content control is locked":M==="notFound"?"the content control was not found":M}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let x=e.can({type:"removeContentControl"});return x.ok?null:x.reason},[d,l,e]),S=useCallback(x=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(l&&d){let M=l.disabledReason(d.id,"edit");if(M)return {ok:false,code:M==="bound"?"bound":M==="locked"?"locked":"notFound",reason:M==="bound"?"the content control is bound to external data":M==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:x})},[e,l,d]),y=useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(l){let x=d?.id;if(!x)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let M=l.disabledReason(x,"remove");return M?{ok:false,code:M==="locked"?"locked":"notFound",reason:M==="locked"?"the content control is locked":"the content control was not found"}:l.remove(x)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,l,d]);return useMemo(()=>({control:d,controls:p,showAll:o,formFill:a,inspectorOpen:t,canSetValue:C===null&&d!==null,canRemove:P===null&&d!==null,setValueDisabledReason:C,removeDisabledReason:P,setShowAll:f,toggleShowAll:g,setFormFill:m,toggleFormFill:u,openInspector:h,closeInspector:b,toggleInspector:v,remove:y,setValue:S}),[d,p,o,a,t,C,P,f,g,m,u,h,b,v,y,S])}var Ki=createContext(null);function Zc(){let e=0,t=null,n=new Set,o=new Set,r=a=>{for(let i of [...a])i();};return {getShift:()=>e,setShift(a){let i=Math.max(0,Math.round(a));i!==e&&(e=i,r(n));},subscribeShift(a){return n.add(a),()=>n.delete(a)},getViewport:()=>t,setViewport(a){a!==t&&(t=a,r(o));},subscribeViewport(a){return o.add(a),()=>o.delete(a)}}}var zi=createContext(null);function ko(){return useContext(zi)}var sg=()=>0,Bc=()=>()=>{};function Ro(){let e=ko(),t=useCallback(o=>e?e.subscribeShift(o):Bc(),[e]),n=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,n,sg)}function _o(){let e=ko(),t=useCallback(r=>e?e.subscribeViewport(r):Bc(),[e]),n=useCallback(()=>e?e.getViewport():null,[e]),o=useCallback(()=>null,[]);return useSyncExternalStore(t,n,o)}function mg(e,t){if(e===t)return true;let n=resolveZoomMode(e),o=resolveZoomMode(t);return n!==null&&o!==null&&sameZoomMode(n,o)}function qr(e){let{document:t,fonts:n,zoom:o,zoomMode:r,tableInteractionLabel:a,imageDecodePort:i,children:s}=e,{t:c}=_(),l=useCallback((v,C)=>c(v,C),[c]),d=useRef(e);d.current=e;let[p,f]=useState(null);useEffect(()=>{let v=d.current,C=v.translate??l,P=createDocxEditor({...v.document!==void 0?{document:v.document}:{},...v.fonts?{fonts:v.fonts}:{},...v.author!==void 0?{author:v.author}:{},...v.locale!==void 0?{locale:v.locale}:{},translate:C,...v.mode!==void 0?{mode:v.mode}:{},...v.modules!==void 0?{modules:v.modules}:{},...v.zoom!==void 0?{zoom:v.zoom}:{},...v.zoomMode!==void 0?{zoomMode:v.zoomMode}:{},...v.tableInteractionLabel?{tableInteractionLabel:v.tableInteractionLabel}:{},...v.imageDecodePort?{imageDecodePort:v.imageDecodePort}:{},onFontError:y=>d.current.onFontError?.(y)}),S=P.on("change",y=>d.current.onChange?.(y));return f(P),()=>{S(),P.destroy(),f(y=>y===P?null:y);}},[t,n,l,i]),useEffect(()=>{p&&d.current.onReady?.(p);},[p]);let m=useRef({editor:null,zoom:void 0,mode:void 0});useEffect(()=>{if(!p)return;m.current.editor!==p&&(m.current={editor:p,zoom:void 0,mode:void 0});let C=false;o!==void 0&&o!==m.current.zoom&&(m.current.zoom=o,p.setZoom(o),C=true);let P=m.current.mode,S=r!==void 0&&(P===void 0||!mg(P,r)),y=r===void 0?null:resolveZoomMode(r),x=C&&r!==void 0&&y!==null&&y.type==="fit";(S||x)&&(m.current.mode=r,p.setZoomMode(r));},[p,o,r]),useEffect(()=>{p&&p.setTableInteractionLabel(a??defaultTableLabel);},[p,a]);let[g,u]=useState(0),h=useMemo(()=>({mounted:g,register:()=>(u(v=>v+1),()=>u(v=>Math.max(0,v-1)))}),[g]),b=useMemo(Zc,[]);return jsx(St.Provider,{value:h,children:jsx(wi.Provider,{value:p,children:jsx(zi.Provider,{value:b,children:jsx(fg,{children:jsx(gg,{children:jsx(Nr,{children:s})})})})})})}function fg({children:e}){let t=Or(true);return jsx(mn.Provider,{value:t,children:e})}function gg({children:e}){let t=Zr();return jsx(Ki.Provider,{value:t,children:e})}var Kr=[.25,.5,.75,1,1.25,1.5,2];function bn(e,t){return t==="in"?Kr.find(o=>o>e+.001)??null:[...Kr].reverse().find(o=>o<e-.001)??null}function Vc(e,t){return e==="0"?1:e==="+"||e==="="?bn(t,"in")??t:e==="-"?bn(t,"out")??t:null}var Qt=createContext(false);function Xe(){return useContext(Qt)?"":"docx-editor "}var yg=e=>e.reviewPaneOpen??true,xg=e=>e.zoomMode?.type==="fit";function zr({className:e,style:t,children:n}){let o=Xe(),r=A(),a=q(yg),i=q(xg),c=(useContext(St)?.mounted??0)>0,l=ko(),d=Ro(),p=useCallback(m=>l?.setViewport(m),[l]),f=useCallback(m=>{if(!r||!(m.metaKey||m.ctrlKey)||m.altKey)return;let g=m.target;if(g instanceof Element&&g.closest('input, textarea, select, [role="dialog"]'))return;let u=Vc(m.key,r.getZoom());u!==null&&(m.preventDefault(),r.setZoom(u));},[r]);return jsx("div",{ref:p,"data-testid":"docx-editor-scroll",onKeyDownCapture:f,...c?{"data-review-pane":a?"open":"closed"}:{},...i?{"data-zoom-fit":""}:{},className:`${o}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${d}px`},children:jsx(Qt.Provider,{value:true,children:n})})}var Sg=sn;function Uc({ref:e,editorRef:t}){useImperativeHandle(e,()=>({load:n=>t.current?.load(n),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(n,o)=>t.current?.exec(n,o)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:n=>t.current?.snapshot(n)??Sg}),[t]);}var Mg=e=>e.editingMode??"editing",Wi=[{mode:"editing",labelKey:"editingMode.editing",hintKey:"editingMode.editingHint",path:"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"},{mode:"suggesting",labelKey:"editingMode.suggesting",hintKey:"editingMode.suggestingHint",path:"M240-400h122l40-40H240v40Zm0-100h222l40-40H240v40Zm0-100h322l40-40H240v40ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v320h-80v-320H160v525l46-45h274v80H240L80-80Zm520-80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T943-380L723-160H600Zm300-263-37-37 37 37ZM660-220h38l121-122-19-18-18-19-122 121v38Zm140-141-18-19 37 37-19-18Z"},{mode:"viewing",labelKey:"editingMode.viewing",hintKey:"editingMode.viewingHint",path:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Z"}],Ig="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function $r({className:e,hidden:t}){let n=A(),o=q(Mg),r=Y(),[a,i]=useState(false),s=useRef(null),c=useRef(null),l=useRef(null);useEffect(()=>{if(!a)return;let u=l.current?.querySelectorAll('[role="menuitemradio"]');(l.current?.querySelector('[aria-checked="true"]')??u?.[0]??void 0)?.focus();},[a]);let d=useCallback(u=>{let h=[...l.current?.querySelectorAll('[role="menuitemradio"]')??[]],b=h.indexOf(document.activeElement),v=C=>{u.preventDefault(),h[(C+h.length)%h.length]?.focus();};u.key==="ArrowDown"?v(b+1):u.key==="ArrowUp"?v(b-1):u.key==="Home"?v(0):u.key==="End"&&v(h.length-1);},[]);useEffect(()=>{if(!a)return;let u=b=>{let v=s.current;v&&b.target instanceof Node&&v.contains(b.target)||i(false);},h=b=>{b.key==="Escape"&&(b.preventDefault(),i(false));};return document.addEventListener("mousedown",u,true),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u,true),document.removeEventListener("keydown",h);}},[a]);let p=useCallback(u=>{i(false),runToolbarCommand(n,"review.editingMode",u),n?.focus();},[n]),f=toolbarCommandState(n,"review.editingMode"),m=useMemo(()=>Wi.find(u=>u.mode===o)??Wi[0],[o]);if(t)return null;let g=ee("review.editingMode");return jsxs("div",{ref:s,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxs("button",{ref:c,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":o,"aria-haspopup":"menu","aria-expanded":a,"aria-label":r(g?.labelKey??"editingMode.label"),disabled:!f.enabled,...f.disabledReason?{title:f.disabledReason}:{},onMouseDown:O,onClick:()=>i(u=>!u),children:[Ui(m.path),jsx("span",{className:"docx-toolbar__picker-value",children:r(m.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),a?jsx("div",{ref:l,className:"docx-toolbar__mode-menu",role:"menu","aria-label":r(g?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:d,children:Wi.map(u=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u.mode===o,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${u.mode}`,onMouseDown:O,onClick:()=>p(u.mode),children:[Ui(u.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:r(u.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:r(u.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:u.mode===o?Ui(Ig):null})]},u.mode))}):null]})}$r.docxSlot="review.editingMode";function Ui(e){return jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})})}function No(e,t){if(!isValidElement(e)||e.type!==Fragment$1)return null;let o=Children.toArray(e.props.children).map(t).filter(r=>r!==null);return o.length===1?o[0]:null}function Ur({entries:e,children:t,preset:n,keyOfEntry:o,keyOfChild:r,renderEntry:a}){if(!n)return t;let i=new Map,s=[];for(let p of Children.toArray(t)){let f=r(p);f?i.set(f,p):s.push(p);}let c=e.map((p,f)=>{let m=o(p,f),g=i.get(m);return g?jsx(Fragment$1,{children:g},m):jsx(Fragment$1,{children:a(p,f)},m)}),l=new Set(e.map(o)),d=[...i.entries()].filter(([p])=>!l.has(p)).map(([p,f])=>jsx(Fragment$1,{children:f},p));return jsxs(Fragment,{children:[c,d,s]})}var Ng=["zoom","script","format","list","alignment","styles","font","text","history"],Yi=new Set(["review"]),Xi=24,Qc=new Set;function Jc(e,t=Ng){let n=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...n]}function jc(e,t){let{widths:n,groups:o,order:r,fixed:a,more:i}=e,s=a;for(let l of o)s+=n.get(l)??0;if(s<=t)return Qc;s+=i;let c=new Set;for(let l of r){if(s<=t)break;let d=n.get(l);d===void 0||c.has(l)||(c.add(l),s-=d);}return c}function ed(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let n of e)if(!t.has(n))return false;return true}var td=ed;function od(e){if(!(e.available>0))return Qc;let t=jc(e,e.available),n=e.previous;if(!n||n.size===0||t.size>=n.size)return t;let o=jc(e,e.available-(e.hysteresis));return ed(o,n)?n:o}function nd(e,t,n,o){return e+t+n+o*2}function rd(e,t){return e+t}function Qi(e,t){return e+t}function ad(e){let t=Number.parseFloat(e.marginInlineStart||e.marginLeft),n=Number.parseFloat(e.marginInlineEnd||e.marginRight);return {start:Number.isFinite(t)?t:0,end:Number.isFinite(n)?n:0}}function ji(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function id(e){return ji(e.columnGap)}function ld(e,t){return e.clientWidth-ji(t.paddingLeft)-ji(t.paddingRight)}var vn="data-toolbar-group",yn="data-toolbar-fixed",el="data-toolbar-more",Fg=34,Ji=new Set;function cd(e,t,n){let o=useRef(null),r=useRef(new Map),a=useRef(Fg),[i,s]=useState(Ji),c=useRef(i);c.current=i;let l=useRef({groups:t,order:n});l.current={groups:t,order:n};let d=useCallback(()=>{let f=o.current;if(!f||!e)return;let m=getComputedStyle(f),g=id(m),u=ld(f,m),h=f.querySelector(".docx-toolbar__separator"),b=g*2;if(h){let y=getComputedStyle(h),x=ad(y);b=nd(h.offsetWidth,x.start,x.end,g);}for(let y of f.querySelectorAll(`[${vn}]`)){let x=y.getAttribute(vn);x&&y.offsetWidth>0&&r.current.set(x,rd(y.offsetWidth,b));}let v=0;for(let y of f.querySelectorAll(`[${yn}]`))y.offsetWidth>0&&(v+=Qi(y.offsetWidth,g));let C=f.querySelector(`[${el}]`);C&&C.offsetWidth>0&&(a.current=Qi(C.offsetWidth,g));let P={available:u,widths:r.current,groups:l.current.groups,order:l.current.order,fixed:v,more:a.current,previous:c.current,hysteresis:Xi},S=od(P);td(S,c.current)||(c.current=S,s(S));},[e]),p=useCallback(f=>{o.current=f;},[]);return useLayoutEffect(()=>{if(!e){c.current.size>0&&(c.current=Ji,s(Ji));return}d();},[e,d]),useEffect(()=>{let f=o.current;if(!e||!f||typeof ResizeObserver>"u")return;let m=0,g=new ResizeObserver(()=>{m===0&&(m=requestAnimationFrame(()=>{m=0,d();}));});g.observe(f);for(let u of f.querySelectorAll(`[${vn}], [${yn}]`))g.observe(u);return ()=>{m!==0&&cancelAnimationFrame(m),g.disconnect();}},[e,d,i]),{attach:p,overflow:i}}var Vg=["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"],ud=createContext({close:()=>{}});function $g(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function pd({label:e,children:t}){return jsxs("div",{className:"docx-toolbar__more-control",children:[jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function md({slot:e}){let t=Y(),{close:n}=useContext(ud),{execute:o,isActive:r,isEnabled:a,disabledReason:i}=ne(e),s=ee(e),c=commandForSlot(e),l=c?.type==="toggleMark"||c?.type==="setAlignment",d=t(s?.labelKey??e);return jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...i?{title:i}:{},...l?{"aria-pressed":r}:{},...r?{"data-active":""}:{},onMouseDown:O,onClick:p=>{o(),n(p.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:te(s?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:d})]})}function fd({sections:e,className:t}){let n=Y(),[o,r]=useState(false),a=useRef(null),i=useRef(null),s=useRef(null),c=useRef(false),l=useId(),d=n("formattingBar.more"),p=useCallback(g=>{r(false),g&&i.current?.focus();},[]),f=useMemo(()=>({close:p}),[p]);useEffect(()=>{if(!o)return;let g=u=>{let h=u.target;h instanceof Node&&a.current?.contains(h)||r(false);};return document.addEventListener("mousedown",g,true),()=>document.removeEventListener("mousedown",g,true)},[o]),useEffect(()=>{if(!o||!c.current)return;c.current=false;let g=s.current;g&&$g(g);},[o]);let m=g=>{g.key!=="Escape"||g.defaultPrevented||(g.preventDefault(),p(true));};return jsxs("div",{ref:a,className:`docx-toolbar__more${t?` ${t}`:""}`,[el]:"",children:[jsx("button",{ref:i,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?l:void 0,"aria-label":d,title:d,...o?{"data-active":""}:{},onMouseDown:O,onClick:()=>r(g=>!g),onKeyDown:g=>{g.key==="ArrowDown"&&(g.preventDefault(),c.current=true,r(true));},children:te(Vg)}),o?jsx(ud.Provider,{value:f,children:jsx("div",{ref:s,id:l,role:"dialog","aria-label":d,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",onKeyDown:m,children:e.map(g=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":n(g.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:n(g.labelKey)}),g.children]},g.id))})}):null]})}function Xg(e,t){return e.value===t.value&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function xn(e){let t=A(),n=useRef(e);n.current=e;let o=useCallback(s=>{let c=n.current,l=toolbarCommandState(t,c);return {value:l.value??null,enabled:l.enabled,disabledReason:l.disabledReason}},[t,e]),r=q(o,Xg),a=useMemo(()=>({execute:s=>runToolbarCommand(t,"image.wrap",s),value:r.value??null,options:IMAGE_WRAP_TARGETS,isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]),i=useMemo(()=>({execute:s=>runToolbarCommand(t,"image.altText",s),value:r.value,options:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]);return e==="image.wrap"?a:i}var ol=[{value:"inline",labelKey:"imageWrap.menu.inLineWithText",iconName:"wrap_text"},{value:"square",labelKey:"imageWrap.square",iconName:"crop_square"},{value:"squareLeft",labelKey:"imageWrap.menu.squareLeft",iconName:"format_image_left"},{value:"squareRight",labelKey:"imageWrap.menu.squareRight",iconName:"format_image_right"},{value:"tight",labelKey:"imageWrap.tight",iconName:"wrap_text"},{value:"through",labelKey:"imageWrap.through",iconName:"wrap_text"},{value:"topAndBottom",labelKey:"imageWrap.topAndBottom",iconName:"vertical_align_center"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function jr({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),a=Y(),{execute:i,value:s,isEnabled:c,disabledReason:l}=xn("image.wrap"),[d,p]=useState(false),f=useRef(null),m=useRef(null),g=useRef(null),u=useId(),h=useMemo(()=>ol.find(y=>y.value===s)??ol[0],[s]),b=ee("image.wrap"),v=a(b?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let y=M=>{let E=f.current;E&&M.target instanceof Node&&E.contains(M.target)||p(false);},x=M=>{M.key==="Escape"&&(M.preventDefault(),p(false),m.current?.focus());};return document.addEventListener("mousedown",y,true),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",y,true),document.removeEventListener("keydown",x);}},[d]);let C=useCallback(y=>{p(false),i(y);},[i]);if(t)return null;let P=r("imageWrap.tooltipPrefix",{label:r(h.labelKey)}),S={type:"button",ref:m,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!c,...c?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?u:void 0,"aria-label":v,title:l??P,onMouseDown:O,onClick:()=>p(y=>!y)};return jsxs("div",{ref:f,className:"docx-toolbar__image-wrap",children:[n?jsx(W,{...S,children:o}):jsx("button",{...S,children:o??te(b?.paths)}),d?jsx("div",{ref:g,id:u,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:y=>y.stopPropagation(),children:ol.map(y=>jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":s===y.value,...s===y.value?{"data-active":""}:{},onMouseDown:O,onClick:()=>C(y.value),children:r(y.labelKey)},y.value))}):null]})}jr.docxSlot="image.wrap";var Tn=Object.assign(jr,{docxSlot:"image.wrap"});function Qr({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),a=Y(),{execute:i,value:s,isEnabled:c,disabledReason:l}=xn("image.altText"),[d,p]=useState(false),[f,m]=useState(""),g=useRef(null),u=useRef(null),h=useId();useEffect(()=>{d&&m(s??"");},[d,s]),useEffect(()=>{if(!d)return;let S=x=>{let M=g.current;M&&x.target instanceof Node&&M.contains(x.target)||p(false);},y=x=>{x.key==="Escape"&&(x.preventDefault(),p(false),u.current?.focus());};return document.addEventListener("mousedown",S,true),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",S,true),document.removeEventListener("keydown",y);}},[d]);let b=useCallback(()=>{i(f),p(false);},[f,i]);if(t)return null;let v=ee("image.altText"),C=a(v?.labelKey??"formattingBar.altText"),P={type:"button",ref:u,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!c,...c?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?h:void 0,"aria-label":C,title:l??C,onMouseDown:O,onClick:()=>p(S=>!S)};return jsxs("div",{ref:g,className:"docx-toolbar__alt-text",children:[n?jsx(W,{...P,children:o}):jsx("button",{...P,children:o??C}),d?jsxs("div",{id:h,role:"dialog","aria-label":r("imageAltText.panelTitle"),className:"docx-toolbar__alt-text-panel",onMouseDown:S=>S.stopPropagation(),children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${h}-description`,children:r("imageAltText.description")}),jsx("textarea",{id:`${h}-description`,className:"docx-dialog__textarea",value:f,onChange:S=>m(S.target.value),placeholder:r("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>p(false),children:r("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:b,children:r("common.apply")})]})]}):null]})}Qr.docxSlot="image.altText";var Sn=Object.assign(Qr,{docxSlot:"image.altText"});var Sd=e=>e.image;function Td(e){return Array.from(e.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null||t===document.activeElement)}function ub(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function ll(e){let t=e.position;return !t||e.kind!=="anchored"?{positionMode:"frame",horizontalPoints:"",verticalPoints:"",relativeToH:"page",relativeToV:"line"}:t.mode==="simple"?{positionMode:"simple",horizontalPoints:t.horizontalEmu!==void 0?String(kt(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(kt(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(kt(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(kt(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function pb(e,t){let n=ll(t);return e.horizontalPoints!==n.horizontalPoints||e.verticalPoints!==n.verticalPoints||e.relativeToH!==n.relativeToH||e.relativeToV!==n.relativeToV}function Jr(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let n=cn(t);return Number.isInteger(n)?n:null}function mb(e,t){let n=ll(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let l=e.horizontalPoints!==n.horizontalPoints,d=e.verticalPoints!==n.verticalPoints,p=l?Jr(e.horizontalPoints):t.position?.horizontalEmu,f=d?Jr(e.verticalPoints):t.position?.verticalEmu;return l&&p===null?{ok:false}:d&&f===null?{ok:false}:p===void 0||f===void 0?{ok:false}:{ok:true,value:{horizontalEmu:p,verticalEmu:f}}}let o=e.horizontalPoints!==n.horizontalPoints,r=e.verticalPoints!==n.verticalPoints,a=e.relativeToH!==n.relativeToH,i=e.relativeToV!==n.relativeToV,s=o?Jr(e.horizontalPoints):t.position?.horizontalEmu,c=r?Jr(e.verticalPoints):t.position?.verticalEmu;return o&&s===null?{ok:false}:r&&c===null?{ok:false}:{ok:true,value:{...typeof s=="number"?{horizontalEmu:s}:{},...typeof c=="number"?{verticalEmu:c}:{},...a||o||r?{relativeToH:e.relativeToH}:{},...i||o||r?{relativeToV:e.relativeToV}:{}}}}function ea(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function ta(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function sl({open:e,onClose:t,className:n,triggerRef:o}){let r=A(),{t:a}=_(),i=q(Sd),s=useId(),c=useId(),l=useId(),d=useRef(null),p=useRef(null),f=useRef(null),m=useRef(null),[g,u]=useState(null),[h,b]=useState(null),v=p.current,C=v?.canCrop===false,P=v?.canResize===false,S=v?.locks.changeAspect===true,y=v?.kind==="anchored"&&v.canMove===true,x=v?.kind==="inline",M=v?.kind==="anchored"&&v.canMove===false;useEffect(()=>{if(!e){p.current=null,f.current=null,m.current=null;return}if(!i)return;if(p.current=i,r?.surface){let{anchor:z}=r.surface.state().selection;f.current={paragraphId:z.paragraphId,offset:z.offset},m.current=r.surface.session.packageRevision();}b(null);let I=ll(i),R=i.crop;u({widthPoints:String(kt(i.widthEmu)),heightPoints:String(kt(i.heightEmu)),cropLeft:String(R.left),cropTop:String(R.top),cropRight:String(R.right),cropBottom:String(R.bottom),title:i.title,description:i.description,hyperlink:i.hyperlink??"",wrap:i.wrap,lockAspect:i.locks.changeAspect,...I});},[e,i?.id,i?.widthEmu,i?.heightEmu,r]);let E=useCallback(()=>{o?.current?.focus(),r?.focus();},[r,o]),w=useCallback(()=>{t(),E();},[t,E]);useEffect(()=>{if(!e)return;let I=d.current;if(!I)return;let R=Td(I);(R.find($=>$.id==="image-prop-width"&&!$.hasAttribute("disabled"))??R.find($=>!$.hasAttribute("disabled"))??I).focus();let Z=$=>{if($.key==="Escape"){$.preventDefault(),w();return}if($.key!=="Tab")return;let Q=Td(I);if(Q.length===0)return;let Me=document.activeElement,se=Q.findIndex(Ce=>Ce===Me);if(se===-1)return;$.preventDefault();let Te=$.shiftKey?(se-1+Q.length)%Q.length:(se+1)%Q.length;Q[Te]?.focus();};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[e,w]);let N=useMemo(()=>{let I=v??i;return !I||I.widthEmu<=0?1:I.widthEmu/I.heightEmu},[i,v]),F=useCallback(I=>{u(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:I};let z=ta(I);if(z===null)return {...R,widthPoints:I};let Z=Math.round(z/N*100)/100;return {...R,widthPoints:I,heightPoints:String(Z)}});},[N]),H=useCallback(I=>{u(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:I};let z=ta(I);if(z===null)return {...R,heightPoints:I};let Z=Math.round(z*N*100)/100;return {...R,widthPoints:String(Z),heightPoints:I}});},[N]),k=useCallback(()=>{let I=p.current;if(!I?.intrinsic)return;let R=I.intrinsic.pixelWidth*72/I.intrinsic.dpiX,z=I.intrinsic.pixelHeight*72/I.intrinsic.dpiY;u(Z=>Z&&{...Z,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(z*100)/100)});},[i]),D=useCallback(()=>{let I=p.current,R=f.current,z=m.current;if(!r||!I||!g||!R||z===null)return;let Z={type:"setImageProperties",drawingNodeId:I.id,expectedPackageRevision:z,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!P){let Ce=ta(g.widthPoints),G=ta(g.heightPoints);if(Ce===null||G===null){b("imageProperties.errors.invalidDimensions");return}let B=cn(Ce),Pe=cn(G);B!==I.widthEmu&&(Z.widthEmu=B),Pe!==I.heightEmu&&(Z.heightEmu=Pe);}if(I.canCrop&&!C){let Ce=ea(g.cropLeft),G=ea(g.cropTop),B=ea(g.cropRight),Pe=ea(g.cropBottom);if(Ce===null||G===null||B===null||Pe===null){b("imageProperties.errors.invalidCrop");return}let Ue=I.crop;(Ce!==Ue.left||G!==Ue.top||B!==Ue.right||Pe!==Ue.bottom)&&(Z.crop={left:Ce,top:G,right:B,bottom:Pe});}g.title!==I.title&&(Z.title=g.title),g.description!==I.description&&(Z.description=g.description);let $=g.hyperlink.trim();if($!==(I.hyperlink??"")&&(Z.hyperlink=$===""?null:$),I.canChangeWrap&&g.wrap!==I.wrap&&(Z.wrap=g.wrap),I.kind==="anchored"&&I.canMove&&pb(g,I)){let Ce=mb(g,I);if(!Ce.ok){b("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(Ce.value,I))){b("imageProperties.errors.invalidPosition");return}Object.assign(Z,Ce.value);}if(!(Z.widthEmu!==void 0||Z.heightEmu!==void 0||Z.title!==void 0||Z.description!==void 0||Z.hyperlink!==void 0||Z.crop!==void 0||Z.wrap!==void 0||Z.horizontalEmu!==void 0||Z.verticalEmu!==void 0||Z.relativeToH!==void 0||Z.relativeToV!==void 0)){w();return}if(!r.can(Z).ok){b("imageProperties.errors.refused");return}if(!r.exec(Z).ok){b("imageProperties.errors.refused");return}w();},[r,g,C,P,w]);return !e||!g?null:jsx("div",{className:`docx-dialog-overlay${n?` ${n}`:""}`,onClick:w,onMouseDown:I=>{I.stopPropagation(),ub(I);},children:jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":s,className:"docx-dialog docx-image-properties-dialog",onClick:I=>I.stopPropagation(),onMouseDown:I=>I.stopPropagation(),children:[jsx("div",{id:s,className:"docx-dialog__header",children:a("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[h?jsx("p",{className:"docx-dialog__error",children:a(h)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:a("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:g.widthPoints,disabled:P,onChange:I=>F(I.target.value)}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:a("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:g.heightPoints,disabled:P,onChange:I=>H(I.target.value)}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:g.lockAspect,disabled:S,onChange:I=>u(R=>R&&{...R,lockAspect:I.target.checked})}),a("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:C||!v?.intrinsic,onClick:k,children:a("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.position")}),x?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.positionUnavailable")}):null,M?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.positionLocked")}):null,y?jsxs(Fragment,{children:[g.positionMode==="frame"?jsxs(Fragment,{children:[jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:a("imageProperties.relativeToHorizontal")}),jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:g.relativeToH??"page",onChange:I=>u(R=>R&&{...R,relativeToH:I.target.value}),children:DRAWING_REL_FROM_H.map(I=>jsx("option",{value:I,children:a(`dialogs.imagePosition.relativeOptions.${I}`)},I))})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:a("imageProperties.relativeToVertical")}),jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:g.relativeToV??"line",onChange:I=>u(R=>R&&{...R,relativeToV:I.target.value}),children:DRAWING_REL_FROM_V.map(I=>jsx("option",{value:I,children:a(`dialogs.imagePosition.relativeOptions.${I}`)},I))})]})]}):null,jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:a("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:g.horizontalPoints,onChange:I=>u(R=>R&&{...R,horizontalPoints:I.target.value})}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:a("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:g.verticalPoints,onChange:I=>u(R=>R&&{...R,verticalPoints:I.target.value})}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:a("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:g.title,onChange:I=>u(R=>R&&{...R,title:I.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:a("imageAltText.description")}),jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:g.description,onChange:I=>u(R=>R&&{...R,description:I.target.value}),placeholder:a("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:l,children:a("hyperlinkPopup.urlLabel")}),jsx("input",{id:l,className:"docx-dialog__input docx-dialog__input--full",value:g.hyperlink,onChange:I=>u(R=>R&&{...R,hyperlink:I.target.value}),placeholder:a("hyperlinkPopup.urlPlaceholder")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:a("formattingBar.imageWrap")}),jsx("select",{id:c,className:"docx-dialog__select docx-dialog__input--full",value:g.wrap,disabled:v?.canChangeWrap===false,onChange:I=>u(R=>R&&{...R,wrap:I.target.value}),children:IMAGE_WRAP_TARGETS.map(I=>jsx("option",{value:I,children:a(`imageWrap.targets.${I}`)},I))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:a("imageProperties.cropLeft")}),jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:C,value:g.cropLeft,onChange:I=>u(R=>R&&{...R,cropLeft:I.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:a("imageProperties.cropTop")}),jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:C,value:g.cropTop,onChange:I=>u(R=>R&&{...R,cropTop:I.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:a("imageProperties.cropRight")}),jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:C,value:g.cropRight,onChange:I=>u(R=>R&&{...R,cropRight:I.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:a("imageProperties.cropBottom")}),jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:C,value:g.cropBottom,onChange:I=>u(R=>R&&{...R,cropBottom:I.target.value})})]}),C?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:a("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:D,children:a("common.apply")})]})]})})}function oa({className:e,hidden:t,asChild:n,children:o}){let r=A(),{t:a}=_(),i=q(Sd),[s,c]=useState(false),l=useRef(null),d={type:"setImageProperties",description:"probe"},p=r&&i?r.can(d):null,f=p?.ok===true,m=p&&!p.ok?p.reason:null;if(t)return null;let g=ee("image.properties"),u={type:"button",ref:l,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!f,...f?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:m??a("formattingBar.imagePropertiesShortcut"),onMouseDown:O,onClick:()=>c(true)};return jsxs(Fragment,{children:[n?jsx(W,{...u,children:o}):jsx("button",{...u,children:o??te(g?.paths)}),jsx(sl,{open:s,onClose:()=>c(false),triggerRef:l})]})}oa.docxSlot="image.properties";var Pn=Object.assign(oa,{docxSlot:"image.properties"});function Ee(e){return Object.assign(n=>jsx(Xt,{slot:e,...n}),{docxSlot:e})}var Cd=Ee("history.undo"),Pd=Ee("history.redo"),Ed=Ee("text.bold"),wd=Ee("text.italic"),Md=Ee("text.underline"),Id=Ee("text.strike"),kd=Ee("format.clear"),Rd=Ee("script.super"),_d=Ee("script.sub"),Nd=Ee("alignment.left"),Dd=Ee("alignment.center"),Ld=Ee("alignment.right"),Hd=Ee("alignment.justify"),Fd=Ee("list.bullet"),Ad=Ee("list.numbered"),Od=Ee("list.outdent"),Zd=Ee("list.indent");var Bd=Ee("table.insert"),qd=Ee("review.comments");function bb({className:e,hidden:t,icon:n,asChild:o,children:r}){let a=A(),{openAtCaret:i}=Zi(),s=chromeProbeForSlot("text.link"),c=a&&s?a.can(s):null,l=c?.ok===true,d=c&&!c.ok?c.reason:null,p=Y();if(t)return null;let f=ee("text.link"),m=p(f?.labelKey??"text.link"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:d??m,onMouseDown:O,onClick:()=>i()};return o?jsx(W,{...g,children:r}):jsx("button",{...g,children:n??r??te(f?.paths)})}var cl=Object.assign(bb,{docxSlot:"text.link"});function hb({className:e,hidden:t}){let n=A(),{onSave:o}=useContext(dn),r=Y();if(t)return null;let a=ee("file.save"),i=r(a?.labelKey??"file.save"),s=!n||!o;return jsx("button",{type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"file.save",disabled:s,...s?{"data-disabled":""}:{},"aria-label":i,title:i,onMouseDown:O,onClick:()=>o?.(),children:te(a?.paths)})}var dl=Object.assign(hb,{docxSlot:"file.save"});function Ho({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}function Fo(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}var xb=e=>({zoom:e.zoom,mode:e.zoomMode}),Tb=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,zd={type:"fixed"};function ul(){let e=A(),{zoom:t,mode:n}=q(xb,Tb),o=useCallback(a=>{e?.setZoom(a);},[e]),r=useCallback(a=>{e?.setZoomMode(a);},[e]);return useMemo(()=>{let a=n??zd,i=bn(t,"out"),s=bn(t,"in");return {zoom:t,mode:a,isFit:a.type==="fit",setZoom:o,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(zd),o(1);},zoomIn:()=>s!==null&&o(s),zoomOut:()=>i!==null&&o(i),canZoomIn:!!e&&s!==null,canZoomOut:!!e&&i!==null,levels:Kr}},[e,t,n,o,r])}var Mn=2,In=3276,wn=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Pb=e=>e.formatting?.fontSizePt??null;function Wd(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function Ud(e,t,n){for(let o=t.length-1;o>=0;o-=1)if(t[o]<e)return t[o];return Math.max(e-1,n)}function Yd(e){return jsxs("span",{className:`docx-toolbar__stepper${e.className?` ${e.className}`:""}`,...e.slot!==void 0?{"data-slot":e.slot}:{},role:"group","aria-label":e.groupLabel,title:e.title??e.groupLabel,children:[jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:O,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:O,onClick:e.onIncrease,children:"+"})]})}function Eb(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let n=Number(t);if(!Number.isFinite(n))return null;let o=Math.round(n*2);return o<Mn||o>In?null:o}function wb({className:e,hidden:t}){let n=A(),o=q(Pb),{isEnabled:r,disabledReason:a}=ne("font.size"),i=Y(),[s,c]=useState(false),[l,d]=useState(null),p=useRef(null),f=useRef(null),m=useCallback(S=>{if(!n)return;let y=commandForSlotValue("font.size",S);y&&n.can(y).ok&&n.exec(y);},[n]),g=useCallback(S=>{m(Math.min(In,Math.max(Mn,Math.round(S*2))));},[m]),u=useCallback(S=>{c(false),d(null),f.current?.blur(),S&&Mb(p.current);},[]);if(useEffect(()=>{if(!s)return;let S=y=>{let x=p.current;x&&y.target instanceof Node&&x.contains(y.target)||(c(false),d(null));};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[s]),t)return null;let h=r&&o!==null,b=o===null?"\u2014":String(Math.round(o*2)/2),v=l??b,C=o===null?null:Math.round(o*2)/2,P=()=>{if(l===null)return;let S=Eb(l);S!==null&&m(S);};return jsxs("span",{ref:p,className:"docx-toolbar__font-size","data-slot":"font.size",title:a??void 0,children:[jsx(Yd,{className:e,groupLabel:i("fontSize.label"),decreaseLabel:i("fontSize.decrease"),increaseLabel:i("fontSize.increase"),middle:jsx("input",{ref:f,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:v,disabled:!r,role:"combobox","aria-expanded":s,"aria-haspopup":"listbox","aria-label":i("fontSize.label"),autoComplete:"off",onChange:S=>{d(S.target.value),c(true);},onFocus:S=>{S.target.select(),c(true);},onClick:()=>c(true),onKeyDown:S=>{S.key==="Enter"?(S.preventDefault(),P(),u(true)):S.key==="Escape"?(S.preventDefault(),u(true)):(S.key==="ArrowDown"||S.key==="ArrowUp")&&(S.preventDefault(),c(true),o!==null&&g(S.key==="ArrowDown"?Ud(o,wn,Mn/2):Wd(o,wn,In/2)));},onBlur:()=>{P(),d(null);}}),canDecrease:h&&Math.round(o*2)>Mn,canIncrease:h&&Math.round(o*2)<In,onDecrease:()=>g(Ud(o??0,wn,Mn/2)),onIncrease:()=>g(Wd(o??0,wn,In/2))}),s&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":i("fontSize.listLabel"),children:wn.map(S=>{let y=C===S;return jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>{g(S),u(true);},children:S},S)})}):null]})}function Mb(e){(Fo(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}var fl=Object.assign(wb,{docxSlot:"font.size"});function Ib({className:e,hidden:t}){let n=A(),{zoom:o,isFit:r,mode:a,setZoom:i,setMode:s,zoomIn:c,zoomOut:l,canZoomIn:d,canZoomOut:p,levels:f}=ul(),m=Y(),[g,u]=useState(false),h=useRef(null);useEffect(()=>{if(!g)return;let y=x=>{let M=h.current;M&&x.target instanceof Node&&M.contains(x.target)||u(false);};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[g]);let b=useCallback(y=>{u(false),i(y);},[i]),v=useCallback(y=>{u(false),s(y==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[s]);if(t)return null;let C=`${Math.round(o*100)}%`,P=sameZoomMode(a,AUTO_ZOOM_MODE),S=sameZoomMode(a,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(Yd,{className:e,groupLabel:m("zoom.zoomLevel"),decreaseLabel:m("zoom.zoomOut"),increaseLabel:m("zoom.zoomIn"),middle:jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!n,"aria-haspopup":"listbox","aria-expanded":g,"aria-label":m("zoom.zoomLevel"),onMouseDown:O,onClick:()=>u(y=>!y),children:[C,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:p,canIncrease:d,onDecrease:l,onIncrease:c}),g?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox","aria-label":m("zoom.zoomLevel"),children:[jsx("button",{type:"button",role:"option","aria-selected":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>v("auto"),children:m("zoom.automatic")}),jsx("button",{type:"button",role:"option","aria-selected":S,...S?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>v("fit-width"),children:m("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),f.map(y=>{let x=!r&&Math.abs(y-o)<.001;return jsx("button",{type:"button",role:"option","aria-selected":x,...x?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>b(y),children:`${Math.round(y*100)}%`},y)})]}):null]})}var gl=Object.assign(Ib,{docxSlot:"zoom.level"});var Db=[1,1.15,1.5,2,2.5,3],jd=10,Lb=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),Hb=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function Fb({className:e,hidden:t}){let n=A(),o=q(Lb,Hb),{isEnabled:r,disabledReason:a}=ne("list.lineSpacing"),i=Y(),[s,c]=useState(false),l=useRef(null);useEffect(()=>{if(!s)return;let h=b=>{let v=l.current;v&&b.target instanceof Node&&v.contains(b.target)||c(false);};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);let d=useCallback(h=>{if(c(false),!n)return;let b=commandForSlotValue("list.lineSpacing",h);b&&n.can(b).ok&&n.exec(b);},[n]),p=useCallback((h,b)=>{if(c(false),!n)return;let v={type:"setParagraphSpacing",[h]:b};n.can(v).ok&&n.exec(v);},[n]);if(t)return null;let f=ee("list.lineSpacing"),m=(o.spaceBeforePt??0)>0,g=(o.spaceAfterPt??0)>0,u=o.lineSpacing?.rule==="multiple"?o.lineSpacing?.value??null:null;return jsxs("span",{ref:l,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxs("button",{type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":s,"aria-label":i("lineSpacing.label"),title:a??i("lineSpacing.label"),onMouseDown:O,onClick:()=>c(h=>!h),children:[te(f?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s&&r?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[Db.map(h=>{let b=u===h;return jsx("button",{type:"button",role:"menuitemradio","aria-checked":b,...b?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>d(h),children:Number.isInteger(h*10)?h.toFixed(1):h.toFixed(2)},h)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>p("beforePt",m?null:jd),children:i(m?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>p("afterPt",g?null:jd),children:i(g?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var hl=Object.assign(Fb,{docxSlot:"list.lineSpacing"});var Kb=[{value:"C00000",labelKey:"colorPicker.colors.darkRed",css:"#c00000"},{value:"FF0000",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"FFC000",labelKey:"colorPicker.colors.orange",css:"#ffc000"},{value:"FFFF00",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"92D050",labelKey:"colorPicker.colors.lightGreen",css:"#92d050"},{value:"00B050",labelKey:"colorPicker.colors.green",css:"#00b050"},{value:"00B0F0",labelKey:"colorPicker.colors.lightBlue",css:"#00b0f0"},{value:"0070C0",labelKey:"colorPicker.colors.blue",css:"#0070c0"},{value:"002060",labelKey:"colorPicker.colors.darkBlue",css:"#002060"},{value:"7030A0",labelKey:"colorPicker.colors.purple",css:"#7030a0"}],Qd=[{value:"yellow",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"green",labelKey:"colorPicker.colors.brightGreen",css:"#00ff00"},{value:"cyan",labelKey:"colorPicker.colors.cyan",css:"#00ffff"},{value:"magenta",labelKey:"colorPicker.colors.magenta",css:"#ff00ff"},{value:"blue",labelKey:"colorPicker.colors.blue",css:"#0000ff"},{value:"red",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"darkBlue",labelKey:"colorPicker.colors.darkBlue",css:"#000080"},{value:"darkCyan",labelKey:"colorPicker.colors.darkCyan",css:"#008080"},{value:"darkGreen",labelKey:"colorPicker.colors.darkGreen",css:"#008000"},{value:"darkMagenta",labelKey:"colorPicker.colors.darkMagenta",css:"#800080"},{value:"darkRed",labelKey:"colorPicker.colors.darkRed",css:"#800000"},{value:"darkYellow",labelKey:"colorPicker.colors.darkYellow",css:"#808000"},{value:"darkGray",labelKey:"colorPicker.colors.darkGray",css:"#808080"},{value:"lightGray",labelKey:"colorPicker.colors.lightGray",css:"#c0c0c0"},{value:"black",labelKey:"colorPicker.colors.black",css:"#000000"},{value:"white",labelKey:"colorPicker.colors.white",css:"#ffffff"}],Jd=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],na=["colorPicker.theme.background1","colorPicker.theme.text1","colorPicker.theme.background2","colorPicker.theme.text2","colorPicker.theme.accent1","colorPicker.theme.accent2","colorPicker.theme.accent3","colorPicker.theme.accent4","colorPicker.theme.accent5","colorPicker.theme.accent6"],Dt=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Qe=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function zb(e){let t=[0,2,4].map(o=>parseInt(e.slice(o,o+2),16)),n=(Math.max(...t)+Math.min(...t))/2/255;return n===1?[Qe(5),Qe(15),Qe(25),Qe(35),Qe(50)]:n===0?[Dt(50),Dt(35),Dt(25),Dt(15),Dt(5)]:n>=.8?[Qe(10),Qe(25),Qe(50),Qe(75),Qe(90)]:[Dt(80),Dt(60),Dt(40),Qe(25),Qe(50)]}var Vb=/^[0-9A-Fa-f]{6}$/;function $b(e,t){let n="";for(let o=0;o<6;o+=2){let r=Math.round(t(parseInt(e.slice(o,o+2),16)));n+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return n.toUpperCase()}function Wb(e){let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return .299*t+.587*n+.114*o>230}function ra({value:e,css:t,title:n,selected:o,apply:r}){return jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":n,title:n,"data-value":e,...o?{"data-selected":""}:{},...Wb(t.replace("#",""))?{"data-light":""}:{},onMouseDown:O,onClick:()=>r(e)})}function Ub({apply:e,label:t,current:n,themeHexes:o}){let r=o.map(zb),a=[0,1,2,3,4];return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[o.map((i,s)=>jsx(ra,{value:i,css:`#${i.toLowerCase()}`,title:t(na[s]),selected:n===i,apply:e},`base-${s}`)),a.map(i=>o.map((s,c)=>{let l=r[c][i],d=$b(s,l.apply);return jsx(ra,{value:d,css:`#${d.toLowerCase()}`,title:`${t(na[c])}, ${t(l.labelKey)}`,selected:n===d,apply:e},`${i}-${c}`)}))]})]})}function Gb(e){let{apply:t,label:n,current:o}=e,[r,a]=useState(""),i=Vb.test(r);return jsxs(Fragment,{children:[jsx(Ub,{...e}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:n("colorPicker.standardColors")}),jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:Kb.map(s=>jsx(ra,{value:s.value,css:s.css,title:n(s.labelKey),selected:o===s.value,apply:t},s.value))})]}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:n("colorPicker.customColor")}),jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":n("colorPicker.customColor"),onChange:s=>a(s.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:s=>{s.key==="Enter"&&i&&t(r.toUpperCase());}}),jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!i,onMouseDown:O,onClick:()=>t(r.toUpperCase()),children:n("colorPicker.apply")})]})]})]})}function yl({apply:e,current:t}){let n=A(),o=Y(),r=n?.getDocumentThemeColors()??[],a=r.length===na.length?r.map(s=>s.hex):Jd,i=t?.toUpperCase()??null;return jsx(Gb,{apply:e,label:o,current:i,themeHexes:a})}var Yb=Qd.filter(e=>e.value!=="white");function Xb({apply:e,label:t,current:n}){return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:Yb.map(o=>jsx(ra,{value:o.value,css:o.css,title:t(o.labelKey),selected:n===o.value,apply:e},o.value))})]})}function eu(e){let{slot:t,defaultValue:n,cssOf:o,clear:r,body:a}=e,i=t==="text.color";return Object.assign(({className:c,hidden:l,icon:d})=>{let p=A(),{isEnabled:f,disabledReason:m}=ne(t),g=Y(),[u,h]=useState(false),[b,v]=useState(n),C=useRef(null),P=q(w=>{if(i){let N=w.formatting?.color;return N&&N.kind==="hex"?N.value.toUpperCase():null}return w.formatting?.highlight??null}),S=p?.getDocumentThemeColors()??[],y=S.length===na.length?S.map(w=>w.hex):Jd;useEffect(()=>{if(!u)return;let w=N=>{let F=C.current;F&&N.target instanceof Node&&F.contains(N.target)||h(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[u]);let x=useCallback(w=>{if(h(false),!p)return;let N=commandForSlotValue(t,w);N&&p.can(N).ok&&(p.exec(N),w!==r.value&&v(w));},[p]),M=useMemo(()=>ee(t),[]);if(l)return null;let E=g(M?.labelKey??t);return jsxs("div",{ref:C,className:`docx-toolbar__colorsplit${c?` ${c}`:""}`,"data-slot":t,children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!f,...f?{}:{"data-disabled":""},"aria-label":E,title:m??E,onMouseDown:O,onClick:()=>x(b),children:[d??te(M?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:o(b)},"aria-hidden":"true"})]}),jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!f,...f?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":u,"aria-label":E,title:m??E,onMouseDown:O,onClick:()=>h(w=>!w),children:"\u25BE"}),u?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":E,onMouseDown:O,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:O,onClick:()=>x(r.value),children:[jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),g(r.labelKey)]}),a({apply:x,label:g,current:P,themeHexes:y})]}):null]})},{docxSlot:t})}var jb=new Map(Qd.map(e=>[e.value,e.css])),xl=eu({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(yl,{apply:e.apply,current:e.current})}),Tl=eu({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>jb.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(Xb,{...e})});var oh=["alignment.left","alignment.center","alignment.right","alignment.justify"];function nh({className:e,hidden:t}){let n=ne("alignment.left"),o=ne("alignment.center"),r=ne("alignment.right"),a=ne("alignment.justify"),i=Y(),[s,c]=useState(false),l=useRef(null);if(useEffect(()=>{if(!s)return;let u=h=>{let b=l.current;b&&h.target instanceof Node&&b.contains(h.target)||c(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s]),t)return null;let d=[n,o,r,a],p=oh.map((u,h)=>({slot:u,control:ee(u),state:d[h]})),f=p.find(u=>u.state.isActive)??p[0],m=p.some(u=>u.state.isEnabled),g=i(f.control?.labelKey??f.slot);return jsxs("div",{ref:l,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!m,...m?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":s,"aria-label":g,title:m?g:f.state.disabledReason??g,onMouseDown:O,onClick:()=>c(u=>!u),children:[te(f.control?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:p.map(u=>{let h=i(u.control?.labelKey??u.slot);return jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":u.slot,disabled:!u.state.isEnabled,...u.state.isActive?{"data-active":""}:{},"aria-pressed":u.state.isActive,"aria-label":h,title:u.state.disabledReason??h,onMouseDown:O,onClick:()=>{u.state.execute(),c(false);},children:te(u.control?.paths)},u.slot)})}):null]})}var aa=Object.assign(nh,{docxSlot:"alignment"});function Cl(e){let{label:t,icon:n,active:o,disabled:r,disabledReason:a,onSelect:i,asChild:s,className:c,children:l}=e,d={type:"button",className:`docx-toolbar__button${c?` ${c}`:""}`,disabled:r,...o?{"data-active":""}:{},...r?{"data-disabled":""}:{},...o!==void 0?{"aria-pressed":o}:{},"aria-label":t,title:r?a??t:t,onMouseDown:p=>O(p),onClick:r?void 0:i};return s?jsx(W,{...d,children:l}):jsx("button",{...d,children:n??l})}var uh=Object.freeze([]),ph=e=>e.formatting?.fontFamily??null,mh=e=>e;function ia(){let e=A(),t=q(ph),n=q(mh),o=useMemo(()=>e&&!n.isLoading?e.getAvailableFonts():uh,[e,n]),{isEnabled:r}=ne("font.family"),a=useCallback(i=>{if(!e)return;let s=commandForSlotValue("font.family",i);s&&e.can(s).ok&&e.exec(s);},[e]);return useMemo(()=>({value:t,setValue:a,options:o,isEnabled:r}),[t,a,o,r])}var nu=createContext(null);function El(){return useContext(nu)}function wl({asChild:e,className:t,children:n}){let o=El(),r=Y();if(!o)return null;let a=r(ee("font.family")?.labelKey??"font.family"),i={onClick:()=>o.setOpen(!o.open),onMouseDown:O,disabled:!o.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":a,title:a},s=n??jsx("span",{children:o.value??"\u2014"});return e?jsx(W,{...i,children:s}):jsx("button",{type:"button",...i,children:s})}wl.docxToolbarPart=true;var fh=new Map([["arial","sansSerif"],["calibri","sansSerif"],["helvetica","sansSerif"],["verdana","sansSerif"],["open sans","sansSerif"],["roboto","sansSerif"],["times new roman","serif"],["georgia","serif"],["cambria","serif"],["garamond","serif"],["courier new","monospace"],["consolas","monospace"]]),gh=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function ru({asChild:e,className:t,children:n}){let o=El(),r=Y();if(!o||!o.open)return null;let a={role:"listbox",className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`,style:{position:"absolute",top:"100%",left:0,zIndex:30,minWidth:"100%",maxHeight:300,overflowY:"auto"}},i;return n!==void 0?i=n:i=gh.map(c=>({...c,fonts:o.options.filter(l=>(fh.get(l.toLowerCase())??"other")===c.category)})).filter(c=>c.fonts.length>0).map((c,l)=>jsxs("div",{role:"group",children:[l>0?jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}):null,c.labelKey?jsx("div",{className:"docx-toolbar__menu-label",children:r(c.labelKey)}):null,c.fonts.map(d=>jsx(au,{value:d},d))]},c.category)),e?jsx(W,{...a,children:i}):jsx("div",{...a,children:i})}function au({value:e,asChild:t,className:n,children:o}){let r=El();if(!r)return null;let a=r.value===e,i={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:O,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__font-family-item${n?` ${n}`:""}`},s=o??jsx("span",{style:{fontFamily:e},children:e});return t?jsx(W,{...i,children:s}):jsxs("button",{type:"button",...i,children:[s,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function bh({hidden:e,asChild:t,className:n,children:o}){let r=ia(),[a,i]=useState(false),s=useRef(null);useEffect(()=>{if(!a)return;let p=f=>{let m=s.current;m&&f.target instanceof Node&&m.contains(f.target)||i(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[a]);let c=useMemo(()=>({...r,open:a,setOpen:i}),[r,a]);if(e)return null;let l={className:`docx-toolbar__font-family${n?` ${n}`:""}`,"data-slot":"font.family",style:{position:"relative",display:"inline-block"}},d=o??jsxs(Fragment,{children:[jsx(wl,{}),jsx(ru,{})]});return jsx(nu.Provider,{value:c,children:t?jsx(W,{...l,ref:s,children:d}):jsx("div",{ref:s,...l,children:d})})}var Ml=Object.assign(bh,{docxSlot:"font.family",Trigger:wl,Content:ru,Item:au});function Eh(e){let t=e.fontSizePt;return {...e.fontFamily?{fontFamily:e.fontFamily}:{},...t?{fontSize:`${Math.min(Math.max(t,9),20)}px`}:{},...e.bold?{fontWeight:700}:{},...e.italic?{fontStyle:"italic"}:{},...e.color?{color:`#${e.color}`}:{}}}var wh=Object.freeze([]),Mh=e=>e.formatting?.styleId??null,Ih=e=>e;function la(){let e=A(),t=q(Mh),n=q(Ih),o=useMemo(()=>e&&!n.isLoading?e.getDocumentStyles().filter(i=>i.type==="paragraph").map(i=>({styleId:i.styleId,name:i.name,preview:i.preview})):wh,[e,n]),{isEnabled:r}=ne("styles.style"),a=useCallback(i=>{if(!e)return;let s=commandForSlotValue("styles.style",i);s&&e.can(s).ok&&e.exec(s);},[e]);return useMemo(()=>({value:t,setValue:a,options:o,isEnabled:r}),[t,a,o,r])}var iu=createContext(null);function Rl(){return useContext(iu)}function _l({asChild:e,className:t,children:n}){let o=Rl(),r=Y();if(!o)return null;let a=ee("styles.style"),i=r(a?.labelKey??"styles.style"),s={onClick:()=>o.setOpen(!o.open),onMouseDown:O,disabled:!o.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":i,title:i},c=o.options.find(d=>d.styleId===o.value),l=n??(o.value===null?jsx("span",{children:a?.valueKey?r(a.valueKey):"\u2014"}):jsx("span",{children:c?.name??o.value}));return e?jsx(W,{...s,children:l}):jsx("button",{type:"button",...s,children:l})}_l.docxToolbarPart=true;function lu({asChild:e,className:t,children:n}){let o=Rl();if(!o||!o.open)return null;let r={role:"listbox",className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`,style:{position:"absolute",top:"100%",left:0,zIndex:30,minWidth:"100%",maxHeight:300,overflowY:"auto"}},a=n??o.options.map(i=>jsx(su,{value:i.styleId},i.styleId));return e?jsx(W,{...r,children:a}):jsx("div",{...r,children:a})}function su({value:e,asChild:t,className:n,children:o}){let r=Rl();if(!r)return null;let a=r.value===e,i=r.options.find(l=>l.styleId===e),s={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:O,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${n?` ${n}`:""}`},c=o??jsx("span",{style:i?Eh(i.preview):void 0,children:i?.name??e});return t?jsx(W,{...s,children:c}):jsxs("button",{type:"button",...s,children:[c,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function kh({hidden:e,asChild:t,className:n,children:o}){let r=la(),[a,i]=useState(false),s=useRef(null);useEffect(()=>{if(!a)return;let p=f=>{let m=s.current;m&&f.target instanceof Node&&m.contains(f.target)||i(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[a]);let c=useMemo(()=>({...r,open:a,setOpen:i}),[r,a]);if(e)return null;let l={className:`docx-toolbar__style${n?` ${n}`:""}`,"data-slot":"styles.style",style:{position:"relative",display:"inline-block"}},d=o??jsxs(Fragment,{children:[jsx(_l,{}),jsx(lu,{})]});return jsx(iu.Provider,{value:c,children:t?jsx(W,{...l,ref:s,children:d}):jsx("div",{ref:s,...l,children:d})})}var Nl=Object.assign(kh,{docxSlot:"styles.style",Trigger:_l,Content:lu,Item:su});function du(e,t){let n=e;return Object.assign(({className:r,hidden:a,icon:i,asChild:s,children:c})=>{let{isEnabled:l,disabledReason:d}=ne(n),p=pt(),f=t==="showAll"?p.showAll:p.formFill,m=Y();if(a)return null;let g=ee(n),u=m(g?.labelKey??e),h={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!l,...l?{}:{"data-disabled":""},...f?{"data-active":""}:{},"aria-pressed":f,"aria-label":u,title:d??u,onMouseDown:O,onClick:()=>{t==="showAll"?p.toggleShowAll():p.toggleFormFill();}};return s?jsx(W,{...h,children:c}):jsx("button",{...h,children:i??c??te(g?.paths)})},{docxSlot:n})}function _h({className:e,hidden:t,icon:n,asChild:o,children:r}){let a=Be.inspector,{isEnabled:i,disabledReason:s}=ne(a),{inspectorOpen:c,openInspector:l}=pt(),d=Y();if(t)return null;let p=ee(a),f=d(p?.labelKey??"contentControl.inspector"),m={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Be.inspector,disabled:!i,...i?{}:{"data-disabled":""},...c?{"data-active":""}:{},"aria-pressed":c,"aria-label":f,title:s??f,onMouseDown:O,onClick:()=>l()};return o?jsx(W,{...m,children:r}):jsx("button",{...m,children:n??r??te(p?.paths)})}function Nh({className:e,hidden:t,icon:n,asChild:o,children:r}){let{canRemove:a,removeDisabledReason:i,remove:s}=pt(),c=Y();if(t)return null;let l=Be.remove,d=ee(l),p=c(d?.labelKey??"contentControl.remove"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Be.remove,disabled:!a,...a?{}:{"data-disabled":""},"aria-label":p,title:i??p,onMouseDown:O,onClick:()=>{s();}};return o?jsx(W,{...f,children:r}):jsx("button",{...f,children:n??r??te(d?.paths)})}var sa=du(Be.showAll,"showAll"),ca=du(Be.formFill,"formFill"),da=Object.assign(Nh,{docxSlot:Be.remove}),ua=Object.assign(_h,{docxSlot:Be.inspector}),uu={[Be.showAll]:sa,[Be.formFill]:ca,[Be.inspector]:ua,[Be.remove]:da};function Dl(e,t){let n=A(),o=useRef(t);o.current=t,useEffect(()=>{if(!n)return;let r=((...a)=>{o.current(...a);});return n.on(e,r)},[n,e]);}var Zh=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Hl=createContext(null);function vu(){let e=useContext(Hl);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function qh(e,t){let n=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",a=n?`${r}|${n.rows}|${n.columns}|${n.rowIndex}|${n.columnIndex}`:"",i=t.selection,s=i?`${i.from&&"paraId"in i.from?i.from.paraId:""}|${i.to&&"paraId"in i.to?i.to.paraId:""}|${t.selectionCollapsed}`:"",c=e?.getTableCellSelection()??null,l=c?`${c.tableId}|${c.rows.from}-${c.rows.to}|${c.columns.from}-${c.columns.to}|${c.cellIds.join(",")}`:"";return {tableKey:a,selectionKey:s,cellSelectionKey:l,editable:t.editable,editingMode:t.editingMode??"editing"}}function Kh(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function zh(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var bu={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function Vh(e,t){let n={};for(let o of Zh){let r=tableChromeToolbarState(e,o,t);n[o]={enabled:r.enabled,disabledReason:r.disabledReason};}return n}function Fl({children:e}){let t=A(),[n,o]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,a]=useState(bu);useEffect(()=>(()=>{}),[]);let i=q(useCallback(f=>({table:f.table,editable:f.editable,editingMode:f.editingMode??"editing",headParagraphId:f.selection?.to&&"paraId"in f.selection.to?f.selection.to.paraId:f.selection?.from&&"paraId"in f.selection.from?f.selection.from.paraId:""}),[]),Kh,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),s=useCallback(()=>{if(!t){a(bu);return}let f=qh(t,t.snapshot());a(m=>zh(m,f)?m:f);},[t]);useEffect(()=>{s();},[s,i]),Dl("selectionChange",useCallback(()=>{s();},[s]));let c=r.tableKey!=="",l=useMemo(()=>t?Vh(t,n):{},[t,n,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=useCallback((f,m)=>{if(!t)return;let{result:g,nextDraft:u}=runTableChromeCommand(t,f,m,n);g.ok&&u&&o(u);},[t,n]),p=useMemo(()=>({visible:c,draft:n,setDraft:o,slotState:f=>l[f]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[c,n,l,d]);return jsx(Hl.Provider,{value:p,children:e})}function $h(){let e=useContext(Hl);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function ma(e){let t=$h(),n=t.slotState(e);return useMemo(()=>({visible:t.visible,enabled:n.enabled,disabledReason:n.disabledReason,draft:t.draft,apply:o=>t.apply(e,o)}),[t,e,n])}var Uh='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Jt(e){return [...e.querySelectorAll(Uh)].filter(t=>t.closest('[role="menu"]')===e)}function Al(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function at(e,t,n){if(e.length===0)return false;let o=t?e.indexOf(t):-1,r=o===-1?n>0?0:e.length-1:(o+n+e.length)%e.length;return e[r]?.focus(),true}function it(e,t){let n=t==="first"?e[0]:e[e.length-1];return n?(n.focus(),true):false}function fa(e){(Fo(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Zl(e,t,n){useEffect(()=>{if(!e)return;let o=r=>{let a=n.current;a&&r.target instanceof Node&&a.contains(r.target)||t(false);};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t,n]);}function ga({enabled:e,disabledReason:t,ariaLabel:n}){let o=useId(),r=!e&&t?o:void 0;return {reasonId:o,shared:{type:"button",onMouseDown:O,"aria-label":n,...r?{"aria-describedby":r}:{},...t?{title:t}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:r&&t?jsx("span",{id:o,className:"docx-editor-sr-only",children:t}):null}}var Yh='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function yu(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,a=o.current;if(!r)return;let i=()=>[...r.querySelectorAll(Yh)].filter(l=>l.closest('[role="menu"]')===r);queueMicrotask(()=>{let l=i();(l.find(p=>p.hasAttribute("data-selected")||p.hasAttribute("data-active"))??l[0])?.focus();});let c=l=>{let d=i();if(l.key==="Escape"){l.preventDefault(),t(false),a?.focus();return}if(l.key==="ArrowDown"){l.preventDefault(),at(d,document.activeElement,1);return}if(l.key==="ArrowUp"){l.preventDefault(),at(d,document.activeElement,-1);return}if(l.key==="Home"){l.preventDefault(),it(d,"first");return}if(l.key==="End"){l.preventDefault(),it(d,"last");return}if(l.key==="Enter"||l.key===" "){let p=document.activeElement;p instanceof HTMLElement&&d.includes(p)&&(l.preventDefault(),p.click());}};return r.addEventListener("keydown",c),()=>r.removeEventListener("keydown",c)},[e,t,n,o]);}function xu(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,a=o.current;if(!r)return;let i=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(c=>c.closest('[role="dialog"]')===r);queueMicrotask(()=>{i()[0]?.focus();});let s=c=>{if(c.key==="Escape"){c.preventDefault(),t(false),a?.focus();return}if(c.key==="Enter"||c.key===" "){let l=document.activeElement,d=i();l instanceof HTMLElement&&d.includes(l)&&(c.preventDefault(),l.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,n,o]);}function Eu(e,t,n){if(e)return o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(!t));}}function ov(e){return te(tableChromeIconPaths(e))}function wu(){return createContext(null)}function Pt(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function ql(e,t,n){let o=wu();function r({hidden:s,asChild:c,className:l,children:d}){let{visible:p,enabled:f,disabledReason:m,draft:g,apply:u}=ma(e),[h,b]=useState(false),v=useRef(null),C=useRef(null);Zl(h,b,v);let P=useMemo(()=>({open:h,setOpen:b,enabled:f,disabledReason:m,apply:u,draft:g,triggerRef:C}),[h,f,m,u,g]);if(s||!p)return null;let S={className:`${t}${l?` ${l}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},y=d??jsxs(Fragment,{children:[jsx(a,{}),jsx(i,{})]});return jsx(o.Provider,{value:P,children:c?jsx(W,{...S,ref:v,children:y}):jsx("div",{ref:v,...S,children:y})})}function a({asChild:s,className:c,children:l}){let{open:d,setOpen:p,enabled:f,disabledReason:m,triggerRef:g}=Pt(o),u=Y(),h=ee(e),b=u(h?.labelKey??n),{shared:v,reasonNode:C}=ga({enabled:f,disabledReason:m,ariaLabel:b}),P={...v,ref:g,className:`docx-toolbar__button docx-table-chrome__trigger${c?` ${c}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:f?()=>p(!d):void 0,...s?{tabIndex:f?0:-1,role:"button",onKeyDown:Eu(f,d,p)}:{}},S=l??jsxs(Fragment,{children:[te(h?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return s?jsxs(Fragment,{children:[jsx(W,{...P,children:S}),C]}):jsxs("button",{...P,children:[S,C]})}a.docxToolbarPart=true;function i({asChild:s,className:c,children:l}){let{open:d,setOpen:p,enabled:f,triggerRef:m}=Pt(o),g=Y(),u=useRef(null);if(yu(d&&f,p,u,m),!d||!f)return null;let h=ee(e),b=g(h?.labelKey??n),v={ref:u,role:"menu","aria-label":b,className:`docx-table-chrome__panel${c?` ${c}`:""}`,onMouseDown:O};return s?jsx(W,{...v,children:l}):jsx("div",{...v,children:l})}return {Root:r,Trigger:a,Content:i,Ctx:o}}var Nn=ql("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Mu({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Pt(Nn.Ctx),s=Y(),c=TABLE_BORDER_TARGET_OPTIONS.find(f=>f.value===e);if(!c)return null;let l=c.value==="none"?false:c.value===i.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":l,"data-value":c.value,className:`docx-table-chrome__target-btn${n?` ${n}`:""}`,...l?{"data-active":""}:{},"aria-label":s(c.labelKey),title:s(c.labelKey),onMouseDown:O,onClick:()=>{a(false),r(c.value);}},p=o??ov(c.icon);return t?jsx(W,{...d,children:p}):jsx("button",{...d,children:p})}function Iu(e){let{children:t}=e;return jsx(Nn.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(n=>jsx(Mu,{value:n.value},n.value))})})}function nv(e){let{children:t}=e,n=t??jsxs(Fragment,{children:[jsx(Nn.Trigger,{}),jsx(Iu,{})]});return jsx(Nn.Root,{...e,children:n})}var An=Object.assign(nv,{docxSlot:"table.borderTarget",Trigger:Nn.Trigger,Content:Iu,Item:Mu}),Dn=ql("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function ku({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Pt(Dn.Ctx),s=Y(),c=TABLE_BORDER_STYLE_OPTIONS.find(f=>f.value===e);if(!c)return null;let l=c.value===i.spec.style,d={type:"button",role:"menuitemradio","aria-checked":l,...l?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:O,onClick:()=>{a(false),r(c.value);}},p=o??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${c.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:s(c.labelKey)})]});return t?jsx(W,{...d,children:p}):jsx("button",{...d,children:p})}function Ru(e){let{children:t}=e;return jsx(Dn.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(n=>jsx(ku,{value:n.value},n.value))})}function rv(e){let t=e.children??jsxs(Fragment,{children:[jsx(Dn.Trigger,{}),jsx(Ru,{})]});return jsx(Dn.Root,{...e,children:t})}var On=Object.assign(rv,{docxSlot:"table.borderStyle",Trigger:Dn.Trigger,Content:Ru,Item:ku}),Ln=ql("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function _u({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Pt(Ln.Ctx),s=Y(),c=Number(e),l=TABLE_BORDER_WIDTH_OPTIONS.find(m=>m.size===c);if(!l)return null;let d=l.size===i.spec.size,p={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:O,onClick:()=>{a(false),r(l.size);}},f=o??jsxs(Fragment,{children:[jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${l.previewThickness}px`},"aria-hidden":"true"}),jsx("span",{children:s(l.labelKey)})]});return t?jsx(W,{...p,children:f}):jsx("button",{...p,children:f})}function Nu(e){let{children:t}=e;return jsx(Ln.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(n=>jsx(_u,{value:String(n.size)},n.size))})}function av(e){let t=e.children??jsxs(Fragment,{children:[jsx(Ln.Trigger,{}),jsx(Nu,{})]});return jsx(Ln.Root,{...e,children:t})}var Zn=Object.assign(av,{docxSlot:"table.borderWidth",Trigger:Ln.Trigger,Content:Nu,Item:_u});function Du(e,t,n){let o=n?.defaultHex??"FF0000",r=wu();function a({hidden:d,asChild:p,className:f,children:m}){let{visible:g,enabled:u,disabledReason:h,draft:b,apply:v}=ma(e),[C,P]=useState(false),[S,y]=useState(o),x=useRef(null),M=useRef(null);Zl(C,P,x);let E=useMemo(()=>({open:C,setOpen:P,enabled:u,disabledReason:h,apply:v,draft:b,triggerRef:M,lastHex:S,setLastHex:y}),[C,u,h,v,b,S]);if(d||!g)return null;let w={className:`docx-toolbar__colorsplit docx-table-chrome${f?` ${f}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},N=m??jsxs(Fragment,{children:[jsx(i,{}),jsx(s,{}),jsx(c,{clearFill:n?.clearFill??false})]});return jsx(r.Provider,{value:E,children:p?jsx(W,{...w,ref:x,children:N}):jsx("div",{ref:x,...w,children:N})})}function i({asChild:d,className:p,children:f}){let{enabled:m,disabledReason:g,apply:u,draft:h,lastHex:b}=Pt(r),v=Y(),C=ee(e),P=v(C?.labelKey??t),{shared:S,reasonNode:y}=ga({enabled:m,disabledReason:g,ariaLabel:P}),x=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:b??o,M={...S,className:`docx-toolbar__button docx-toolbar__colorsplit-main${p?` ${p}`:""}`,onClick:m?()=>u({kind:"hex",value:x}):void 0},E=f??jsxs(Fragment,{children:[te(C?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${x.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(W,{...M,children:E}),y]}):jsxs("button",{...M,children:[E,y]})}i.docxToolbarPart=true;function s({asChild:d,className:p,children:f}){let{open:m,setOpen:g,enabled:u,disabledReason:h,triggerRef:b}=Pt(r),v=Y(),C=ee(e),P=v(C?.labelKey??t),{shared:S,reasonNode:y}=ga({enabled:u,disabledReason:h,ariaLabel:P}),x={...S,ref:b,className:`docx-toolbar__colorsplit-caret${p?` ${p}`:""}`,"aria-haspopup":"dialog","aria-expanded":m,onClick:u?()=>g(!m):void 0,...d?{tabIndex:u?0:-1,role:"button",onKeyDown:Eu(u,m,g)}:{}},M=f??"\u25BE";return d?jsxs(Fragment,{children:[jsx(W,{...x,children:M}),y]}):jsxs("button",{...x,children:[M,y]})}s.docxToolbarPart=true;function c({asChild:d,className:p,children:f,clearFill:m}){let{open:g,setOpen:u,enabled:h,apply:b,draft:v,triggerRef:C,lastHex:P,setLastHex:S}=Pt(r),y=Y(),x=useRef(null);if(xu(g&&h,u,x,C),!g||!h)return null;let M=y(t),E=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:P??o,w={ref:x,role:"dialog","aria-label":M,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${p?` ${p}`:""}`,onMouseDown:O},N=f??jsxs(Fragment,{children:[m?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:O,onClick:()=>{u(false),b(null),fa(C.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),y("table.clearCellFill")]}):null,jsx(yl,{apply:F=>{u(false),S?.(F),b({kind:"hex",value:F}),fa(C.current);},current:E})]});return d?jsx(W,{...w,children:N}):jsx("div",{...w,children:N})}function l({value:d,css:p,labelKey:f,asChild:m,className:g,children:u}){let{apply:h,setOpen:b,setLastHex:v,triggerRef:C}=Pt(r),P=Y(),S=p??`#${d.toLowerCase()}`,y=f?P(f):d,x={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${g?` ${g}`:""}`,style:{backgroundColor:S},"data-value":d,"aria-label":y,title:y,onMouseDown:O,onClick:()=>{b(false),v?.(d),h({kind:"hex",value:d}),fa(C.current);}};return m?jsx(W,{...x,children:u}):jsx("button",{...x,children:u})}return {Root:a,Main:i,Trigger:s,Content:c,Item:l,Ctx:r}}var Hn=Du("table.borderColor","table.borderColor",{defaultHex:"000000"});function iv(e){return jsx(Hn.Content,{...e,clearFill:false})}function lv(e){return jsx(Hn.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function sv(e){return jsx(Hn.Root,{...e})}var Bn=Object.assign(sv,{docxSlot:"table.borderColor",Trigger:Hn.Trigger,Content:iv,Item:lv,Main:Hn.Main}),Fn=Du("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function cv(e){return jsx(Fn.Content,{...e,clearFill:true})}function dv(e){return jsx(Fn.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function uv(e){return jsx(Fn.Root,{...e})}var qn=Object.assign(uv,{docxSlot:"table.cellFill",Trigger:Fn.Trigger,Content:cv,Item:dv,Main:Fn.Main});function Lu({overrides:e=new Map}){return vu()?jsxs(Fragment,{children:[jsx(Ho,{}),[An,Bn,On,Zn,qn].map(o=>{let r=e.get(o.docxSlot);return r?jsx(Fragment$1,{children:r},o.docxSlot):jsx(o,{},o.docxSlot)})]}):null}function Hu(){let e=Y(),{draft:t}=ma("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var Zu=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Bu={"zoom.level":gl,"styles.style":Nl,"font.family":Ml,"font.size":fl,"text.color":xl,"text.highlight":Tl,"text.link":cl,"list.lineSpacing":hl,"review.editingMode":$r,"file.save":dl,...uu,"table.borderTarget":An,"table.borderColor":Bn,"table.borderStyle":On,"table.borderWidth":Zn,"table.cellFill":qn,"image.insert":un,"image.properties":Pn,"image.wrap":Tn,"image.altText":Sn},Au=new Map;function fv(e){let t=Au.get(e);return t||(t=n=>jsx(Xt,{slot:e,...n}),Au.set(e,t)),t}function gv(e){return formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:aa}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(n=>{let o=chromeSlotId(t,n);return {slot:o,Part:Bu[o]??fv(o)}})})}var bv=e=>e.image;function hv(e){return e==="alignment"||e in Bu}function Vl(e){let t=No(e,Vl);if(t!==null)return t;if(!isValidElement(e))return null;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxToolbarPart===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function Kl(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Kl);let t=Vl(e);return t!=null&&Zu.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(Kl):false}function vv(e,t){return t?true:Children.toArray(e).some(Kl)}function yv(e){let t=Xe(),{className:n,t:o,onSave:r,preset:a=true,overflow:i=true,children:s}=e,c=useMemo(()=>({t:o,onSave:r}),[o,r]),l=Ri(o),d=q(bv),p=useMemo(()=>gv(d),[d]),f=useMemo(()=>new Set(p.flatMap(C=>C.entries.map(P=>P.slot))),[p]),m=useMemo(()=>p.map(C=>C.id).filter(C=>!Yi.has(C)),[p]),g=useMemo(()=>Jc(m),[m]),u=a&&i,{attach:h,overflow:b}=cd(u,m,g),v;if(!a)v=s;else {let C=Children.toArray(s),P=new Map,S=new Map,y=[];for(let N of C){let F=Vl(N);F&&f.has(F)?P.set(F,N):F&&Zu.includes(F)?S.set(F,N):y.push(N);}let x=N=>{let F=P.get(N.slot);if(F)return F;let H=N.Part;return jsx(H,{})},M=[],E=[],w=0;for(let N of p){if(b.has(N.id)){let H=N.entries.flatMap(k=>{let D=Tv(k,P,l,N.labelKey,x);return D===null?[]:[jsx(Fragment$1,{children:D},k.slot)]});if(H.length===0)continue;E.push({id:N.id,labelKey:N.labelKey,children:H});continue}w>0&&M.push(jsx(Ho,{},`separator-${N.id}`)),w+=1;let F=Yi.has(N.id);M.push(jsx("div",{className:"docx-toolbar__group",...F?{[yn]:""}:{[vn]:N.id},children:N.entries.map(H=>jsx(Fragment$1,{children:x(H)},H.slot))},N.id));}v=jsxs(Fragment,{children:[M,jsx(Lu,{overrides:S}),y.length>0?jsx("div",{className:"docx-toolbar__group",[yn]:"",children:y}):null,E.length>0?jsx(fd,{sections:E}):null]});}return jsx(dn.Provider,{value:c,children:jsx("div",{ref:h,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${n?` ${n}`:""}`,...u?{"data-overflow":""}:{},onMouseDown:O,children:vv(s,a)?jsx(Fl,{children:v}):v})})}function xv(e){return e?!!e.props.hidden:false}function Tv(e,t,n,o,r){let a=t.get(e.slot);return xv(a)?null:a||hv(e.slot)?jsx(pd,{label:Sv(n,e,o),children:r(e)}):jsx(md,{slot:e.slot})}function Sv(e,t,n){let o=t.slot==="alignment"?null:ee(t.slot);return e(o?.labelKey??n)}var zn=Object.assign(yv,{Button:Xt,Action:Cl,Separator:Ho,Undo:Cd,Redo:Pd,Bold:Ed,Italic:wd,Underline:Md,Strike:Id,Link:cl,ClearFormatting:kd,Superscript:Rd,Subscript:_d,Alignment:aa,AlignLeft:Nd,AlignCenter:Dd,AlignRight:Ld,AlignJustify:Hd,LineSpacing:hl,BulletList:Fd,NumberedList:Ad,Outdent:Od,Indent:Zd,ImageInsert:un,ImageProperties:Pn,ImageWrap:Tn,ImageAltText:Sn,TableInsert:Bd,TableBorderTarget:An,TableBorderColor:Bn,TableBorderStyle:On,TableBorderWidth:Zn,TableCellFill:qn,Comments:qd,FontFamily:Ml,FontSize:fl,FontColor:xl,Highlight:Tl,Zoom:gl,StylePicker:Nl,EditingMode:$r,Save:dl,ContentControlShowAll:sa,ContentControlFormFill:ca,ContentControlInspector:ua,ContentControlRemove:da});var wv=e=>e.pageSetup??null,Mv=e=>e.editable;function eo(){let e=A(),t=q(wv),n=q(Mv),o=useMemo(()=>n&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,n]),r=useCallback(a=>e?e.exec({...a.pageWidthTwips!==void 0?{pageWidth:a.pageWidthTwips}:{},...a.pageHeightTwips!==void 0?{pageHeight:a.pageHeightTwips}:{},...a.orientation!==void 0?{orientation:a.orientation}:{},...a.marginTopTwips!==void 0?{marginTop:a.marginTopTwips}:{},...a.marginRightTwips!==void 0?{marginRight:a.marginRightTwips}:{},...a.marginBottomTwips!==void 0?{marginBottom:a.marginBottomTwips}:{},...a.marginLeftTwips!==void 0?{marginLeft:a.marginLeftTwips}:{},...a.scope!==void 0?{scope:a.scope}:{},type:"setPageSetup"}).ok:false,[e]);return useMemo(()=>({pageSetup:t,isEnabled:o,apply:r}),[t,o,r])}var Wl=[{labelKey:"dialogs.pageSetup.pageSizes.letter",width:12240,height:15840},{labelKey:"dialogs.pageSetup.pageSizes.a4",width:11906,height:16838},{labelKey:"dialogs.pageSetup.pageSizes.legal",width:12240,height:20160},{labelKey:"dialogs.pageSetup.pageSizes.a3",width:16838,height:23811},{labelKey:"dialogs.pageSetup.pageSizes.a5",width:8391,height:11906},{labelKey:"dialogs.pageSetup.pageSizes.b5",width:9979,height:14175},{labelKey:"dialogs.pageSetup.pageSizes.executive",width:10440,height:15120}],Gu=1440,Iv=e=>Math.round(e/Gu*100)/100,kv=e=>Math.round(e*Gu);function Rv(e,t){let n=Math.min(e,t),o=Math.max(e,t);return Wl.findIndex(r=>Math.abs(r.width-n)<20&&Math.abs(r.height-o)<20)}var _v={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},Nv={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:400,maxWidth:480,width:"100%",margin:20},Dv={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600,color:"var(--doc-text)"},Lv={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},Vu={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},ba={display:"flex",alignItems:"center",gap:12},ha={width:80,fontSize:13,color:"var(--doc-text-muted)"},va={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Hv={fontSize:11,color:"var(--doc-text-muted)",width:16},Fv={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},$u={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Wu=12240,Uu=15840,Ht=1440;function Vn({open:e,onClose:t,className:n}){let{t:o}=_(),{pageSetup:r,isEnabled:a,apply:i}=eo(),[s,c]=useState(Wu),[l,d]=useState(Uu),[p,f]=useState("portrait"),[m,g]=useState(Ht),[u,h]=useState(Ht),[b,v]=useState(Ht),[C,P]=useState(Ht),[S,y]=useState("document"),x=useRef(null),M=useRef("no");useEffect(()=>{if(!e){M.current="no";return}if(M.current==="yes"&&r===null){M.current="no";return}M.current==="yes"||M.current==="loading"&&r===null||(c(r?.pageWidthTwips??Wu),d(r?.pageHeightTwips??Uu),f(r?.orientation??"portrait"),g(r?.marginsTwips.top??Ht),h(r?.marginsTwips.bottom??Ht),v(r?.marginsTwips.left??Ht),P(r?.marginsTwips.right??Ht),y("document"),M.current=r===null?"loading":"yes");},[e,r]),useEffect(()=>{e&&x.current?.focus();},[e]);let E=useCallback(k=>{let D=Wl[k];D&&(c(p==="landscape"?D.height:D.width),d(p==="landscape"?D.width:D.height));},[p]),w=useCallback(k=>{k!==p&&(f(k),c(l),d(s));},[p,s,l]),N=useCallback(()=>{i({pageWidthTwips:s,pageHeightTwips:l,orientation:p,marginTopTwips:m,marginRightTwips:C,marginBottomTwips:u,marginLeftTwips:b,scope:S})&&t();},[i,s,l,p,m,C,u,b,S,t]);if(!e)return null;let F=Rv(s,l),H=(k,D,I)=>jsxs("div",{style:ba,children:[jsx("label",{style:ha,children:o(`dialogs.pageSetup.${k}`)}),jsx("input",{type:"number",style:va,min:0,max:22,step:.1,value:Iv(D),onChange:R=>I(Math.max(0,kv(Number(R.target.value)||0))),"aria-label":o(`dialogs.pageSetup.${k}`)}),jsx("span",{style:Hv,children:"in"})]});return jsx("div",{className:n,style:_v,onClick:t,onKeyDown:k=>{k.key==="Escape"&&t(),k.key==="Enter"&&N();},children:jsxs("div",{ref:x,tabIndex:-1,style:Nv,onClick:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o("dialogs.pageSetup.title"),children:[jsx("div",{style:Dv,children:o("dialogs.pageSetup.title")}),jsxs("div",{style:Lv,children:[jsx("div",{style:Vu,children:o("dialogs.pageSetup.pageSize")}),jsxs("div",{style:ba,children:[jsx("label",{style:ha,children:o("dialogs.pageSetup.sizeLabel")}),jsxs("select",{style:va,value:F,onChange:k=>E(Number(k.target.value)),"aria-label":o("dialogs.pageSetup.sizeLabel"),children:[Wl.map((k,D)=>jsx("option",{value:D,children:o(k.labelKey)},k.labelKey)),F<0&&jsx("option",{value:-1,children:o("dialogs.pageSetup.custom")})]})]}),jsxs("div",{style:ba,children:[jsx("label",{style:ha,children:o("dialogs.pageSetup.orientation")}),jsxs("select",{style:va,value:p,onChange:k=>w(k.target.value),"aria-label":o("dialogs.pageSetup.orientation"),children:[jsx("option",{value:"portrait",children:o("dialogs.pageSetup.portrait")}),jsx("option",{value:"landscape",children:o("dialogs.pageSetup.landscape")})]})]}),jsx("div",{style:{...Vu,marginTop:4},children:o("dialogs.pageSetup.margins")}),H("top",m,g),H("bottom",u,h),H("left",b,v),H("right",C,P),jsxs("div",{style:ba,children:[jsx("label",{style:ha,children:o("dialogs.pageSetup.applyTo")}),jsxs("select",{style:va,value:S,onChange:k=>y(k.target.value),"aria-label":o("dialogs.pageSetup.applyTo"),children:[jsx("option",{value:"document",children:o("dialogs.pageSetup.applyToDocument")}),jsx("option",{value:"section",children:o("dialogs.pageSetup.applyToSection")})]})]})]}),jsxs("div",{style:Fv,children:[jsx("button",{type:"button",style:$u,onClick:t,children:o("common.cancel")}),jsx("button",{type:"button",style:{...$u,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:a?1:.5},disabled:!a,onClick:N,children:o("common.apply")})]})]})})}var $n=createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onReportIssue:void 0,reportIssue:void 0});function ft(){return useContext($n)}function Oe(){let{t:e}=ft(),{t}=_();return n=>e?.(n)??t(n)}var Zv=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,Bv=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var Yu=new TextEncoder;function qv(e,t){if(Yu.encode(e).length<=t)return e;let n=0,o="";for(let r of e){let a=Yu.encode(r).length;if(n+a>t)break;n+=a,o+=r;}return o}function Xu(e){let t=qv((e??"").replace(/\.docx$/i,"").replace(Bv," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||Zv.test(t)?"document.docx":`${t}.docx`}function ju(e,t){let n=URL.createObjectURL(new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})),o=document.createElement("a");o.href=n,o.download=t,o.click(),setTimeout(()=>URL.revokeObjectURL(n),0);}var Kv="https://github.com/eigenpal/docx-editor/issues/new";function zv(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Qu(e={}){let t=e.userAgent??(typeof navigator<"u"?navigator.userAgent:"unknown"),n=e.viewport??(typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??zv()}`,`- Viewport: ${n.width} x ${n.height}`,`- User agent: ${t}`,""].join(`
2
- `),a=new URLSearchParams({title:"[Bug] ",body:r});return `${Kv}?${a.toString()}`}function Wn(e){typeof window>"u"||window.open(Qu(e),"_blank","noopener,noreferrer");}var ya=6,Ul=6;function Le(e){let{icon:t,shortcut:n,disabled:o,title:r,active:a,selected:i,slot:s,onSelect:c,className:l,children:d}=e,p=useId(),f=o&&r?p:void 0;return jsxs("button",{type:"button",role:a===void 0?"menuitem":i===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${l?` ${l}`:""}`,tabIndex:-1,...s?{"data-slot":s}:{},...a?{"data-active":""}:{},...o?{"data-disabled":"","aria-disabled":true}:{},...a!==void 0?{"aria-checked":a}:{},...f?{"aria-describedby":f}:{},...r?{title:r}:{},onMouseDown:O,onClick:o?void 0:c,children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsx("span",{className:"docx-menubar__item-label",children:d}),n?jsx("span",{className:"docx-menubar__item-shortcut",children:n}):null,f?jsx("span",{id:p,className:"docx-editor-sr-only",children:r}):null]})}function Gn({label:e,labelKey:t,className:n,hidden:o,children:r}){let a=Oe();if(o)return null;let i=e??(t===void 0?void 0:a(t));return jsxs("div",{role:"group",className:`docx-menubar__group${n?` ${n}`:""}`,...i?{"aria-label":i}:{},children:[i?jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:i}):null,r]})}function gt({slot:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let{execute:a,isActive:i,isEnabled:s,disabledReason:c}=ne(e),{setOpenMenu:l}=ft(),d=Oe();if(r)return null;let p=ee(e),f=d(t??p?.labelKey??e),m=commandForSlot(e),g=m?.type==="toggleMark"||m?.type==="setAlignment",u=m?.type==="setAlignment";return jsx(Le,{slot:e,icon:te(p?.paths),...n?{shortcut:d(n)}:{},disabled:!s,...c?{title:c}:{},...g?{active:i}:{},...u?{selected:true}:{},onSelect:()=>{a(),l(null);},...o?{className:o}:{},children:f})}gt.docxMenuRow=true;function ep(e,t,n,o){return Object.assign(({className:a,hidden:i})=>{let s=ft(),c=Oe(),l=o(s);if(i)return null;let d=ee(e),p=c(t??d?.labelKey??e);return jsx(Le,{slot:e,icon:te(d?.paths),...n?{shortcut:c(n)}:{},disabled:!l,onSelect:()=>{l?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:p})},{docxSlot:e})}var Yl=ep("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Xl=ep("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function Yv({className:e,hidden:t}){let n=A(),o=ft(),r=Oe(),a=chromeProbeForSlot("file.pageSetup"),i=n&&a?n.can(a):null,s=i?.ok===true,c=i&&!i.ok?i.reason:null;if(t)return null;let l=ee("file.pageSetup"),d=r(l?.labelKey??"file.pageSetup"),p=s&&!!o.onPageSetup;return jsx(Le,{slot:"file.pageSetup",icon:te(l?.paths),disabled:!p,...c?{title:c}:{},onSelect:()=>{o.onPageSetup?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}var jl=Object.assign(Yv,{docxSlot:"file.pageSetup"});function Xv({className:e,hidden:t}){let{openFilePicker:n,isEnabled:o,disabledReason:r}=_r(),a=ft(),i=Oe();if(t)return null;let s=ee("image.insert"),c=i(s?.labelKey??"toolbar.image");return jsx(Le,{slot:"image.insert",icon:te(s?.paths),disabled:!o,...r?{title:r}:{},onSelect:()=>{n(),a.setOpenMenu(null);},...e?{className:e}:{},children:c})}var jv=Object.assign(Xv,{docxSlot:"image.insert"}),Un=8;function oo({labelKey:e,paths:t,className:n,children:o}){let r=Oe(),[a,i]=useState(false),s=useRef(null),c=useRef(null),l=useId(),d=r(e),[p,f]=useState(null);return useLayoutEffect(()=>{if(!a){f(null);return}let m=s.current,g=c.current,u=m?.ownerDocument.defaultView;if(!m||!g||!u)return;let h=m.getBoundingClientRect(),b=g.offsetWidth,v=g.offsetHeight,C=h.right+b>u.innerWidth-Un;f({left:C?Math.max(Un,h.left-b):Math.min(h.right,u.innerWidth-b-Un),top:Math.max(Un,Math.min(h.top-4,u.innerHeight-v-Un))});},[a]),jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),onKeyDown:m=>{m.key==="ArrowRight"&&document.activeElement===s.current?(m.preventDefault(),i(true),queueMicrotask(()=>{c.current&&it(Jt(c.current),"first");})):(m.key==="ArrowLeft"||m.key==="Escape")&&a&&(m.preventDefault(),m.stopPropagation(),i(false),s.current?.focus());},onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||i(false);},children:[jsxs("button",{ref:s,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?l:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:O,onFocus:()=>i(true),onClick:()=>i(true),children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:te(t)}),jsx("span",{className:"docx-menubar__item-label",children:d}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsx("div",{ref:c,id:l,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:p?{position:"fixed",left:p.left,top:p.top}:{position:"fixed",visibility:"hidden"},onKeyDown:m=>{let g=c.current;if(!g)return;let u=Jt(g);m.key==="ArrowDown"?(m.preventDefault(),m.stopPropagation(),at(u,document.activeElement,1)):m.key==="ArrowUp"&&(m.preventDefault(),m.stopPropagation(),at(u,document.activeElement,-1));},children:o}):null]})}function Ta({slot:e="table.insert",className:t}){let n=A(),{isEnabled:o}=ne(e),{setOpenMenu:r}=ft(),[a,i]=useState(null),[s,c]=useState({rows:1,cols:1}),l=useRef(null),d=useCallback((m,g)=>{if(!n||!o)return;let u={type:"insertTable",rows:m,cols:g};n.can(u).ok&&(n.exec(u),r(null),n.focus());},[n,o,r]),p=useCallback(m=>{c(g=>{let u={rows:Math.min(Ul,Math.max(1,g.rows+(m.rows??0))),cols:Math.min(ya,Math.max(1,m.toCol??g.cols+(m.cols??0)))};return i(u),queueMicrotask(()=>l.current?.querySelector(`[data-cell="${u.rows}x${u.cols}"]`)?.focus()),u});},[]),f=[];for(let m=1;m<=Ul;m+=1){let g=[];for(let u=1;u<=ya;u+=1){let h=!!a&&m<=a.rows&&u<=a.cols;g.push(jsx("button",{type:"button",role:"gridcell","data-cell":`${m}x${u}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===m&&s.cols===u?0:-1,...h?{"data-filled":""}:{},"aria-label":`${u} \xD7 ${m}`,onMouseDown:O,onMouseEnter:()=>i({rows:m,cols:u}),onFocus:()=>i({rows:m,cols:u}),onClick:()=>d(m,u)},u));}f.push(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:g},m));}return jsxs("div",{ref:l,role:"grid","aria-label":`${ya} \xD7 ${Ul}`,className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>i(null),onKeyDown:m=>{if(m.key==="ArrowRight")p({cols:1});else if(m.key==="ArrowLeft")p({cols:-1});else if(m.key==="ArrowDown")p({rows:1});else if(m.key==="ArrowUp")p({rows:-1});else if(m.key==="Home")p({toCol:1});else if(m.key==="End")p({toCol:ya});else return;m.preventDefault(),m.stopPropagation();},children:[jsx("div",{className:"docx-menubar__grid-cells",children:f}),jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function Qv({entry:e}){let{isEnabled:t}=ne(e.slot),n=ee(e.slot);return t?jsx(oo,{labelKey:e.labelKey??n?.labelKey??e.slot,paths:n?.paths,children:jsx(Ta,{slot:e.slot})}):jsx(gt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function no({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Yn({entry:e}){return e.kind==="separator"?jsx(no,{}):e.kind==="submenu"?jsx(oo,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,n)=>jsx(Yn,{entry:t},n))}):e.slot==="file.open"?jsx(Yl,{}):e.slot==="file.save"?jsx(Xl,{}):e.slot==="file.pageSetup"?jsx(jl,{}):e.slot==="image.insert"?jsx(jv,{}):e.picker==="tableGrid"?jsx(Qv,{entry:e}):jsx(gt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function tp(e){if(!isValidElement(e))return null;let t=No(e,tp);if(t!==null)return t;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxMenuRow===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function Jv(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function ey(e,t,n){return Ur({entries:e??[],children:t,preset:n,keyOfEntry:Jv,keyOfChild:tp,renderEntry:o=>jsx(Yn,{entry:o})})}function Zo({id:e,labelKey:t,label:n,icon:o,className:r,hidden:a,preset:i=true,children:s}){let{openMenu:c,setOpenMenu:l,activeMenu:d}=ft(),p=Oe(),f=useId(),m=useRef(null),g=useRef(null),u=useRef(false),h=useRef(false),b=CHROME_MENUS.find(y=>y.id===e),v=c===e;if(a)return null;let C=n??p(t??b?.labelKey??e),P=ey(b?.entries,s,i),S=()=>{l(null),m.current?.focus();};return jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,children:[jsxs("button",{ref:m,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":v,"aria-controls":v?f:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...v?{"data-open":""}:{},onMouseDown:O,onKeyDown:y=>{y.key==="ArrowDown"||y.key==="Enter"||y.key===" "||y.key==="ArrowUp"?(y.preventDefault(),u.current=true,l(e)):y.key==="Escape"&&v&&(y.preventDefault(),S());},onClick:()=>{if(h.current){h.current=false;return}l(v?null:e);},onMouseEnter:()=>{c!==null&&c!==e&&(h.current=true,l(e));},onMouseLeave:()=>{h.current=false;},children:[o?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:o}):null,C]}),v?jsx("div",{ref:y=>{g.current=y,y&&u.current&&(u.current=false,it(Jt(y),"first"));},id:f,role:"menu","aria-label":C,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:y=>{let x=g.current;if(!x)return;let M=Jt(x),E=document.activeElement;y.key==="ArrowDown"?(y.preventDefault(),at(M,E,1)):y.key==="ArrowUp"?(y.preventDefault(),at(M,E,-1)):y.key==="Home"?(y.preventDefault(),it(M,"first")):y.key==="End"?(y.preventDefault(),it(M,"last")):y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),S()):y.key==="Tab"&&l(null);},children:P}):null]})}function Ql(e){return Object.assign(n=>jsx(Zo,{id:e,...n}),{docxMenu:e})}var Jl=Ql("file"),es=Ql("format"),ts=Ql("insert");function ty({className:e,hidden:t,onSelect:n}){let{setOpenMenu:o,onReportIssue:r,reportIssue:a}=ft(),i=Oe();if(t||a===false)return null;let s=n??r??Wn;return jsx(Le,{slot:"help.reportIssue",onSelect:()=>{s(),o(null);},...e?{className:e}:{},children:i("toolbar.reportIssue")})}var Sa=Object.assign(ty,{docxSlot:"help.reportIssue"});function oy({children:e,...t}){let{reportIssue:n}=ft();return e===void 0&&n===false?null:jsxs(Zo,{id:"help",...t,children:[jsx(Sa,{}),e]})}var os=Object.assign(oy,{docxMenu:"help"});var ay={file:Jl,format:es,insert:ts,help:os},iy=new Set(CHROME_MENUS.map(e=>e.id));function sp(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let o=Children.toArray(e.props.children).map(sp).filter(r=>r!==null);return o.length===1?o[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===Zo){let n=e.props.id;if(typeof n=="string"&&iy.has(n))return n}return null}function ly(e){let t=Xe(),{className:n,t:o,fileName:r,onOpen:a,onOpenFile:i,onSave:s,onPageSetup:c,onReportIssue:l,reportIssue:d,preset:p=true,children:f}=e,m=A(),{t:g}=_(),[u,h]=useState(null),[b,v]=useState(null),[C,P]=useState(null),[S,y]=useState(false),x=useRef(null),M=useRef(null);useEffect(()=>{if(u===null)return;let z=$=>{let Q=x.current;Q&&$.target instanceof Node&&Q.contains($.target)||h(null);},Z=$=>{$.key==="Escape"&&h(null);};return document.addEventListener("mousedown",z),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",Z);}},[u]);let E=useCallback(z=>{h(z),z!==null&&P(z);},[]),w=useCallback(()=>M.current?.click(),[]),N=useCallback(()=>{m&&m.save().then(z=>ju(z,Xu(r??b??void 0))).catch(z=>{console.error("[docx-editor] save failed",z);});},[m,r,b]),F=useCallback(()=>y(true),[]),H=m?a??w:void 0,k=m?s??N:void 0,D=m?c??F:void 0;useEffect(()=>{let z=Z=>{if(!(Z.metaKey||Z.ctrlKey)||Z.altKey||Z.shiftKey)return;let $=Z.key.toLowerCase();if($!=="s"&&$!=="o")return;let Q=Z.target,Me=Fo(x.current)??x.current;!Q||!Me?.contains(Q)||($==="s"&&k?(Z.preventDefault(),k()):$==="o"&&H&&(Z.preventDefault(),H()));};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[H,k]);let I=useMemo(()=>({t:o,openMenu:u,setOpenMenu:E,activeMenu:C,onOpen:H,onSave:k,onPageSetup:D,onReportIssue:l,reportIssue:d}),[o,u,E,C,H,k,D,l,d]),R;if(!p)R=f;else {let z=new Map,Z=[];for(let $ of Children.toArray(f)){let Q=sp($);Q?z.set(Q,$):Z.push($);}R=jsxs(Fragment,{children:[CHROME_MENUS.map($=>{let Q=z.get($.id);if(Q)return jsx(Fragment$1,{children:Q},$.id);let Me=ay[$.id];return jsx(Me,{},$.id)}),Z]});}return jsxs($n.Provider,{value:I,children:[jsx("div",{ref:z=>{if(x.current=z,z&&C===null){let Z=Al(z)[0]?.closest("[data-menu]")?.getAttribute("data-menu");Z&&P(Z);}},role:"menubar","aria-label":o?.("titleBar.menuBarAriaLabel")??g("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${t}docx-menubar${n?` ${n}`:""}`,onMouseDown:O,onKeyDown:z=>{if(z.key!=="ArrowLeft"&&z.key!=="ArrowRight")return;let Z=x.current;if(!Z)return;let $=Al(Z),Q=$.indexOf(document.activeElement);if(Q===-1)return;z.preventDefault();let Me=z.key==="ArrowRight"?1:-1,se=$[(Q+Me+$.length)%$.length],Te=se?.closest("[data-menu]")?.getAttribute("data-menu");Te&&(P(Te),se?.focus(),u!==null&&h(Te));},children:R}),jsx("input",{ref:M,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:z=>{let Z=z.target.files?.[0];z.target.value="",!(!Z||!m)&&(v(Z.name),i?.(Z),Z.arrayBuffer().then($=>m.load(new Uint8Array($))).catch($=>{console.error("[docx-editor] could not open the file",$);}));}}),jsx(Vn,{open:S,onClose:()=>y(false)})]})}var jn=Object.assign(ly,{Menu:Zo,File:Jl,Format:es,Insert:ts,Help:os,Item:gt,Row:Le,Group:Gn,Separator:no,Submenu:oo,TableGrid:Ta,Entry:Yn,Open:Yl,Save:Xl,PageSetup:jl,ReportIssue:Sa});function _e(e){return e/1440*96}function Ea(e){return e/96*1440}function ze(e){return `${Math.round(e*100)/100}px`}function ns(e){return e/2}var py=12240,up=1440,fp=1440,gp=567,ro=20,as=6,my=ro+as+2,fy="var(--doc-text-muted)",gy="var(--doc-text-subtle)",pp="var(--doc-shadow-subtle)",by="var(--doc-primary)",hy="var(--doc-primary-hover)",vy="var(--doc-text-subtle)",Jn=5,Qn=7,yy={left:0,right:0,firstLine:0};function mp(e,t){return t==="inch"?(e/fp).toFixed(2)+'"':(e/gp).toFixed(1)+" cm"}function xy(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function ao({pageSetup:e,zoom:t=1,editable:n=false,onLeftMarginChange:o,onRightMarginChange:r,onMarginDragEnd:a,showIndentHandles:i=false,indent:s,indentEditable:c=false,onIndentChange:l,onIndentDragEnd:d,unit:p="inch",className:f="",style:m,tabMarks:g,onTabMarkRemove:u}){let{t:h}=_(),[b,v]=useState(null),[C,P]=useState(null),[S,y]=useState(null),[x,M]=useState(null),E=useRef(null),w=e?.pageWidthTwips??py,N=e?.marginsTwips.left??up,F=e?.marginsTwips.right??up,H=e?.gutterTwips??0,k={pageWidth:w,leftMargin:N,rightMargin:F},D=s??yy,I=_e(w)*t,R=_e(N)*t,z=_e(F)*t,Z=useCallback(B=>{let Pe=E.current?.getBoundingClientRect();return Pe?Ea((B-Pe.left)/t):null},[t]),$=useCallback((B,Pe,Ue)=>{let ce=Z(Pe);if(ce===null)return;if(M(_e(ce)*t),B==="leftMargin"||B==="rightMargin"){if(B==="leftMargin"){let rn=w-F-H-720,Eo=Math.round(Math.max(0,Math.min(ce,rn)));y(Eo),o?.(Eo);}else {let rn=w-ce,Eo=w-N-H-720,Mr=Math.round(Math.max(0,Math.min(rn,Eo)));y(Mr),r?.(Mr);}return}let Ge=dragIndent(B,ce,D,k,{unit:p,precise:Ue});y(B==="right"?Ge.right:B==="firstLine"?Ge.firstLine:Ge.left),l?.(Ge);},[Z,t,w,N,F,H,o,r,l,D,k,p]),Q=useCallback(B=>{B==="leftMargin"||B==="rightMargin"?a?.():d?.(),v(null),y(null),M(null);},[a,d]),Me=useCallback((B,Pe,Ue)=>{let ce=handlePosition(B,D,k),Ge=dragIndent(B,ce+Pe*xy(p,Ue),D,k,{unit:p,precise:true});l?.(Ge),d?.();},[D,k,p,l,d]),se=wy(w,t,p),Te=i&&c&&l!==void 0,Ce=B=>_e(handlePosition(B,D,k))*t,G=(B,Pe,Ue)=>({positionPx:Ce(B),editable:Te,isDragging:b===B,isHovered:C===B,onPointerEnter:()=>P(B),onPointerLeave:()=>P(null),onPointerDown:ce=>{Te&&(ce.preventDefault(),ce.stopPropagation(),ce.currentTarget.setPointerCapture(ce.pointerId),v(B));},onPointerMove:ce=>{b===B&&$(B,ce.clientX,ce.altKey);},onPointerUp:ce=>{b===B&&(ce.currentTarget.releasePointerCapture(ce.pointerId),Q(B));},onKeyDown:ce=>{Te&&(ce.key!=="ArrowLeft"&&ce.key!=="ArrowRight"||(ce.preventDefault(),Me(B,ce.key==="ArrowLeft"?-1:1,ce.shiftKey)));},label:h(Pe),valueNow:Ue,valueText:mp(Ue,p),pageWidthTwips:w});return jsxs("div",{ref:E,className:`docx-horizontal-ruler ${f}`,style:{position:"relative",width:ze(I),height:my,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:b?"ew-resize":"default",...m},role:"group","aria-label":h("ruler.horizontal"),children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:ze(R),height:ro,backgroundColor:pp,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&o?B=>{B.preventDefault(),B.currentTarget.setPointerCapture(B.pointerId),v("leftMargin");}:void 0,onPointerMove:B=>b==="leftMargin"&&$("leftMargin",B.clientX,B.altKey),onPointerUp:B=>{b==="leftMargin"&&(B.currentTarget.releasePointerCapture(B.pointerId),Q("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:ze(z),height:ro,backgroundColor:pp,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&r?B=>{B.preventDefault(),B.currentTarget.setPointerCapture(B.pointerId),v("rightMargin");}:void 0,onPointerMove:B=>b==="rightMargin"&&$("rightMargin",B.clientX,B.altKey),onPointerUp:B=>{b==="rightMargin"&&(B.currentTarget.releasePointerCapture(B.pointerId),Q("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:ro,pointerEvents:"none"},children:se.map((B,Pe)=>jsx(Ty,{tick:B},Pe))}),g?.map(B=>jsx(Ey,{tabMark:B,positionPx:_e(B.position)*t,onDoubleClick:()=>u?.(B.position)},B.position)),i&&jsxs(Fragment,{children:[jsx(rs,{direction:"down",anchor:"top",...G("firstLine","ruler.firstLineIndent",D.firstLine)}),jsx(rs,{direction:"up",anchor:"strip",...G("hanging","ruler.hangingIndent",D.left)}),jsx(Sy,{...G("left","ruler.leftIndent",D.left)}),jsx(rs,{direction:"up",anchor:"strip",...G("right","ruler.rightIndent",D.right)})]}),b&&S!==null&&x!==null&&jsx(Cy,{value:mp(S,p),positionPx:x})]})}function Ty({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:ze(e.position),bottom:0,width:1,height:e.height,backgroundColor:gy}}),e.label&&jsx("div",{style:{position:"absolute",left:ze(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:fy,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function bp(e){return e.editable?e.isDragging||e.isHovered?hy:by:vy}function hp(e,t,n){return {position:"absolute",left:ze(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...n}}function vp(e){return {role:"slider","aria-label":e.label,"aria-orientation":"horizontal","aria-valuenow":e.valueNow,"aria-valuemin":-e.pageWidthTwips,"aria-valuemax":e.pageWidthTwips,"aria-valuetext":e.valueText,"aria-disabled":e.editable?void 0:true,tabIndex:e.editable?0:-1}}function rs({direction:e,anchor:t,...n}){let o=bp(n),r=t==="top"?{top:0,height:Qn+1}:{top:ro-Qn,height:Qn};return jsx("div",{className:"docx-ruler-indent",style:hp(n,Jn*2,r),onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onKeyDown:n.onKeyDown,...vp(n),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Jn}px solid transparent`,borderRight:`${Jn}px solid transparent`,...e==="down"?{top:0,borderTop:`${Qn}px solid ${o}`}:{bottom:0,borderBottom:`${Qn}px solid ${o}`},transition:"border-color 0.1s"}})})}function Sy(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:hp(e,Jn*2,{top:ro+1,height:as}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...vp(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:Jn*2-2,height:as,backgroundColor:bp(e),borderRadius:1,transition:"background-color 0.1s"}})})}function Cy({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:ze(t),top:-22,transform:"translateX(-50%)",backgroundColor:"var(--doc-text)",color:"var(--doc-on-primary)",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var Py={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function Ey({tabMark:e,positionPx:t,onDoubleClick:n}){return jsx("div",{style:{position:"absolute",left:ze(t-5),top:ro-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:o=>{o.stopPropagation(),n();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:Py[e.alignment]||"L"})}function wy(e,t,n){let o=[];if(n==="inch"){let r=fp/8,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let s=i*r;if(s>e)break;let c=_e(s)*t;i%8===0?o.push({position:c,height:8,label:i/8>0?String(i/8):void 0}):i%4===0?o.push({position:c,height:5}):i%2===0?o.push({position:c,height:3}):o.push({position:c,height:2});}}else {let r=gp/10,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let s=i*r;if(s>e)break;let c=_e(s)*t;i%10===0?o.push({position:c,height:8,label:i/10>0?String(i/10):void 0}):i%5===0?o.push({position:c,height:5}):o.push({position:c,height:3});}}return o}var ky=15840,Tp=1440,Ry=1440,_y=567,Bo=20,Ny="var(--doc-text-muted)",Dy="var(--doc-text-subtle)",Ly="var(--doc-primary)",Hy="var(--doc-primary)",Fy="var(--doc-primary-hover)";function er({pageSetup:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,onMarginDragEnd:a,unit:i="inch",className:s="",style:c}){let{t:l}=_(),[d,p]=useState(null),[f,m]=useState(null),g=useRef(null),u=e?.pageHeightTwips??ky,h=e?.marginsTwips.top??Tp,b=e?.marginsTwips.bottom??Tp,v=_e(u)*t,C=_e(h)*t,P=_e(b)*t,S=useCallback((w,N)=>{n&&(w.preventDefault(),p(N));},[n]),y=useCallback(w=>{if(!d||!g.current)return;let N=g.current.getBoundingClientRect(),F=w.clientY-N.top,H=Ea(F/t);if(d==="topMargin"){let k=u-b-720,D=Math.max(0,Math.min(H,k));o?.(Math.round(D));}else if(d==="bottomMargin"){let k=u-H,D=u-h-720,I=Math.max(0,Math.min(k,D));r?.(Math.round(I));}},[d,t,u,h,b,o,r]),x=useCallback(()=>{d!==null&&a?.(),p(null);},[d,a]);useEffect(()=>{if(d)return document.addEventListener("mousemove",y),document.addEventListener("mouseup",x),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",x);}},[d,y,x]);let M=Oy(u,t,i),E={position:"relative",width:Bo,height:ze(v),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...c};return jsxs("div",{ref:g,className:`docx-vertical-ruler ${s}`,style:E,role:"slider","aria-label":l("ruler.vertical"),"aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:M.map((w,N)=>jsx(Ay,{tick:w},N))}),jsx(Sp,{type:"topMargin",position:C,editable:n,isDragging:d==="topMargin",isHovered:f==="topMargin",onMouseEnter:()=>m("topMargin"),onMouseLeave:()=>m(null),onMouseDown:w=>S(w,"topMargin")}),jsx(Sp,{type:"bottomMargin",position:v-P,editable:n,isDragging:d==="bottomMargin",isHovered:f==="bottomMargin",onMouseEnter:()=>m("bottomMargin"),onMouseLeave:()=>m(null),onMouseDown:w=>S(w,"bottomMargin")})]})}function Ay({tick:e}){let t={position:"absolute",top:ze(e.position),right:0,height:1,width:e.width,backgroundColor:Dy},n={position:"absolute",top:ze(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:Ny,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function Sp({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:a,onMouseLeave:i,onMouseDown:s}){let{t:c}=_(),l=o?Fy:r?Hy:Ly,d={position:"absolute",top:ze(t-5),right:0,width:Bo,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},p={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:d,onMouseEnter:a,onMouseLeave:i,onMouseDown:s,role:"slider","aria-label":c(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:p})})}function Oy(e,t,n){let o=[];if(n==="inch"){let r=Ry/8,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let s=i*r;if(s>e)break;let c=_e(s)*t;if(i%8===0){let l=i/8;o.push({position:c,width:10,label:l>0?String(l):void 0});}else i%4===0?o.push({position:c,width:6}):i%2===0?o.push({position:c,width:4}):o.push({position:c,width:2});}}else {let r=_y/10,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let s=i*r;if(s>e)break;let c=_e(s)*t;if(i%10===0){let l=i/10;o.push({position:c,width:10,label:l>0?String(l):void 0});}else i%5===0?o.push({position:c,width:6}):o.push({position:c,width:3});}}return o}var io=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var qy=e=>e.formatting?.indent??null,Ky=e=>e.editable;function ss(){let e=A(),t=q(qy),n=q(Ky),o=useMemo(()=>n&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,n]),r=useCallback(a=>e?e.exec({...a.left!==void 0?{left:a.left}:{},...a.right!==void 0?{right:a.right}:{},...a.firstLine!==void 0?{firstLine:a.firstLine}:{},type:"setIndent"}).ok:false,[e]);return useMemo(()=>({indent:t,isEnabled:o,apply:r}),[t,o,r])}var Mp=e=>e.zoom;function Ip(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function kp(){let{apply:e}=eo(),[t,n]=useState({}),o=useRef({}),r=useCallback(i=>s=>{o.current={...o.current,[i]:Math.round(s)},n(o.current);},[]),a=useCallback(()=>{let i=o.current;o.current={},n({}),Object.keys(i).length!==0&&e({...i.top!==void 0?{marginTopTwips:i.top}:{},...i.right!==void 0?{marginRightTwips:i.right}:{},...i.bottom!==void 0?{marginBottomTwips:i.bottom}:{},...i.left!==void 0?{marginLeftTwips:i.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:a}}function wp(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function $y(){let e=A(),{indent:t,isEnabled:n,apply:o}=ss(),[r,a]=useState(null),i=useRef(null),s=useRef(null),c=useCallback(p=>{s.current===null&&(s.current=wp(e)),i.current=p,a(p);},[e]),l=useCallback(()=>{let p=i.current,f=s.current;i.current=null,s.current=null,a(null),p&&(f!==null&&f!==wp(e)||o({left:p.left,right:p.right,firstLine:p.firstLine}));},[e,o]),d=useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine}:null),[r,t]);return useMemo(()=>({indent:d,isEnabled:n,preview:c,commit:l}),[d,n,c,l])}function Wy(){let e=_o(),[t,n]=useState(0);return useEffect(()=>{if(!e){n(0);return}let o=()=>n(e.scrollLeft);return o(),e.addEventListener("scroll",o,{passive:true}),()=>e.removeEventListener("scroll",o)},[e]),t}function ka(e){let t=q(io),{pageSetup:n,isEnabled:o}=eo(),r=q(Mp),{pending:a,preview:i,commit:s}=kp(),c=$y(),l=Ro(),d=Uy(),p=Wy();return t?null:jsx(ao,{pageSetup:Ip(n,a),zoom:r,editable:o,onLeftMarginChange:i("left"),onRightMarginChange:i("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{flexShrink:0,marginRight:d,...e.style,marginInlineStart:l,transition:"margin 0.2s ease",transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-p}px)`,clipPath:l>0&&p>0?`inset(0 0 0 ${p}px)`:e.style?.clipPath}})}function Uy(){let e=q(Gy);return (useContext(St)?.mounted??0)===0?0:e?Yy:Xy}var Gy=e=>e.reviewPaneOpen??true,Yy=316,Xy=44;function Ra(e){let t=q(io),{pageSetup:n,isEnabled:o}=eo(),r=q(Mp),{pending:a,preview:i,commit:s}=kp();return t?null:jsx(er,{pageSetup:Ip(n,a),zoom:r,editable:o,onTopMarginChange:i("top"),onBottomMarginChange:i("bottom"),onMarginDragEnd:s,unit:e.unit??"inch",className:e.className??"",style:e.style})}function L({size:e=20,className:t="",style:n,children:o}){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...n},"aria-hidden":"true",children:o})}function Qy(e){return jsx(L,{...e,children:jsx("path",{d:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"})})}function Jy(e){return jsx(L,{...e,children:jsx("path",{d:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"})})}function ex(e){return jsx(L,{...e,children:jsx("path",{d:"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"})})}function tx(e){return jsx(L,{...e,children:jsx("path",{d:"M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function ox(e){return jsx(L,{...e,children:jsx("path",{d:"M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function nx(e){return jsx(L,{...e,children:jsx("path",{d:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"})})}function rx(e){return jsx(L,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function ax(e){return jsx(L,{...e,children:jsx("path",{d:"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"})})}function ix(e){return jsx(L,{...e,children:jsx("path",{d:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"})})}function lx(e){return jsx(L,{...e,children:jsx("path",{d:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"})})}function sx(e){return jsx(L,{...e,children:jsx("path",{d:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"})})}function cx(e){return jsx(L,{...e,children:jsx("path",{d:"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"})})}function dx(e){return jsx(L,{...e,children:jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function ux(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function px(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function mx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function fx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function us(e){return jsx(L,{...e,children:jsx("path",{d:"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"})})}function gx(e){return jsx(L,{...e,children:jsx("path",{d:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"})})}function bx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"})})}function hx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function vx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function yx(e){return jsx(L,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function xx(e){return jsx(L,{...e,children:jsx("path",{d:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"})})}function Tx(e){return jsx(L,{...e,children:jsx("path",{d:"M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"})})}function Sx(e){return jsx(L,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function Cx(e){return jsx(L,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"})})}function Px(e){return jsx(L,{...e,children:jsx("path",{d:"M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"})})}function Ex(e){return jsx(L,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"})})}function wx(e){return jsx(L,{...e,children:jsx("path",{d:"M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"})})}function Mx(e){return jsx(L,{...e,children:jsx("path",{d:"M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"})})}function _p(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function Ix(e){return jsx(L,{...e,children:jsx("path",{d:"M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"})})}function kx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"})})}function Rx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function _x(e){return jsx(L,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function Nx(e){return jsx(L,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function Dx(e){return jsx(L,{...e,children:jsx("path",{d:"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"})})}function Lx(e){return jsx(L,{...e,children:jsx("path",{d:"M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"})})}function Hx(e){return jsx(L,{...e,children:jsx("path",{d:"m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"})})}function Fx(e){return jsx(L,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function Ax(e){return jsx(L,{...e,children:jsx("path",{d:"M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"})})}function Ox(e){return jsx(L,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"})})}function Zx(e){return jsx(L,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function Bx(e){return jsx(L,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function qx(e){return jsx(L,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function Kx(e){return jsx(L,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function zx(e){return jsx(L,{...e,children:jsx("path",{d:"M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function Vx(e){return jsx(L,{...e,children:jsx("path",{d:"M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"})})}function $x(e){return jsx(L,{...e,children:jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function Wx(e){return jsx(L,{...e,children:jsx("path",{d:"M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"})})}function Ux(e){return jsx(L,{...e,children:jsx("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})})}function Gx(e){return jsx(L,{...e,children:jsx("path",{d:"M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"})})}function Yx(e){return jsx(L,{...e,children:jsx("path",{d:"M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"})})}function Xx(e){return jsx(L,{...e,children:jsx("path",{d:"M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"})})}function jx(e){return jsx(L,{...e,children:jsx("path",{d:"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"})})}function Qx(e){return jsx(L,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function Jx(e){return jsx(L,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function eT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function tT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function oT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function nT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"})})}function rT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h720v60H120Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function aT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-720h60v720h-60Zm165 0v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function iT(e){return jsx(L,{...e,children:jsx("path",{d:"M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})})}function lT(e){return jsx(L,{...e,children:jsx("path",{d:"M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"})})}function sT(e){return jsx(L,{...e,children:jsx("path",{d:"M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"})})}function cT(e){return jsx(L,{...e,children:jsx("path",{d:"M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"})})}function dT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function uT(e){return jsx(L,{...e,children:jsx("path",{d:"m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"})})}function pT(e){return jsx(L,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"})})}function mT(e){return jsx(L,{...e,children:jsx("path",{d:"m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"})})}function fT(e){return jsx(L,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function gT(e){return jsx(L,{...e,children:jsx("path",{d:"M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"})})}function bT(e){return jsx(L,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function hT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function vT(e){return jsx(L,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function yT(e){return jsx(L,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function xT(e){return jsx(L,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function TT(e){return jsx(L,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function ST(e){return jsx(L,{...e,children:jsx("path",{d:"M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"})})}function CT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"})})}function PT(e){return jsx(L,{...e,children:jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm320-60q66 0 113-37t47-93q0-29-13-58t-34-55q-21-26-50-49t-50-31q-21 8-50 31t-50 49q-21 26-34 55t-13 58q0 56 47 93t140 37Z"})})}function ET(e){return jsx(L,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function wT(e){return jsx(L,{...e,children:jsx("path",{d:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"})})}function MT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function IT(e){return jsx(L,{...e,children:jsx("path",{d:"M268-240 42-466l57-56 170 170 56 56-57 56Zm226 0L268-466l56-57 170 170 368-368 57 57-425 424Zm0-226-57-56 198-198 57 56-198 198Z"})})}function kT(e){return jsx(L,{...e,children:jsx("path",{d:"m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"})})}function RT(e){return jsx(L,{...e,children:jsx("path",{d:"M80-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"})})}function _T(e){return jsxs(L,{...e,children:[jsx("path",{d:"M80-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"}),jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function NT(e){return jsx(L,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function DT(e){return jsx(L,{...e,children:jsx("path",{d:"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"})})}function LT(e){return jsx(L,{...e,children:jsx("path",{d:"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"})})}function HT(e){return jsx(L,{...e,children:jsx("path",{d:"M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-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"})})}function FT(e){return jsx(L,{...e,children:jsx("path",{d:"M160-400h280v-80H160v80Zm0-160h440v-80H160v80Zm0-160h440v-80H160v80Zm360 360v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"})})}function AT(e){return jsx(L,{...e,children:jsx("path",{d:"M240-400h122l200-200q9-9 13.5-20.5T580-643q0-11-5-21.5T562-684l-36-38q-9-9-20-13.5t-23-4.5q-11 0-22.5 4.5T440-722L240-522v122Zm280-243-37-37 37 37ZM300-460v-38l101-101 20 18 18 20-101 101h-38Zm121-121 18 20-38-38 20 18Zm26 181h273v-80H527l-80 80ZM80-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"})})}function OT(e){return jsx(L,{...e,children:jsx("path",{d:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Zm0-300Zm0 220q113 0 207.5-59.5T832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280Z"})})}function ZT(e){return jsx(L,{...e,children:jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"})})}function BT(e){return jsx(L,{...e,children:jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"})})}function qT(e){return jsx(L,{...e,children:jsx("path",{d:"m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z"})})}var KT={undo:Qy,redo:Jy,print:ex,file_download:tx,file_upload:ox,format_bold:nx,format_italic:rx,format_underlined:ax,strikethrough_s:ix,superscript:lx,subscript:sx,link:cx,format_clear:dx,format_align_left:ux,format_align_center:px,format_align_right:mx,format_align_justify:fx,format_line_spacing:us,format_list_bulleted:gx,format_list_numbered:bx,format_indent_increase:hx,format_indent_decrease:vx,format_color_text:yx,ink_highlighter:xx,format_color_reset:Tx,arrow_drop_down:Sx,table:Cx,table_chart:Px,grid_on:Ex,table_rows:wx,view_column:Mx,border_all:_p,select_all:_p,border_outer:Ix,border_inner:kx,border_clear:Rx,add:_x,remove:Nx,delete:Dx,delete_sweep:Lx,call_merge:Hx,call_split:Fx,drag_indicator:Ax,image:Ox,format_image_left:Zx,format_image_right:Bx,horizontal_rule:qx,flip_to_back:Kx,flip_to_front:zx,open_with:Vx,tune:$x,rotate_right:Wx,rotate_left:Ux,swap_horiz:Gx,swap_vert:Yx,shapes:Xx,format_paint:jx,expand_more:Qx,expand_less:Jx,border_top:eT,border_bottom:tT,border_left:oT,border_right:nT,border_horizontal:rT,border_vertical:aT,padding:iT,text_rotation_none:lT,wrap_text:sT,height:cT,fit_width:dT,settings:uT,border_color:pT,format_color_fill:mT,vertical_align_top:fT,vertical_align_center:gT,vertical_align_bottom:bT,line_weight:hT,keyboard_arrow_up:vT,keyboard_arrow_down:yT,keyboard_arrow_left:xT,keyboard_arrow_right:TT,more_vert:ST,page_break:CT,branding_watermark:PT,arrow_back:ET,search:wT,toc:MT,done_all:IT,check_circle:kT,chat_bubble_outline:RT,chat_bubble_check:_T,check:NT,close:DT,add_comment:LT,comment:HT,edit_note:FT,rate_review:AT,visibility:OT,format_textdirection_l_to_r:ZT,format_textdirection_r_to_l:BT,"agent-sparkle":qT};function K({name:e,size:t=20,className:n="",style:o}){let r=KT[e];return r?jsx(r,{size:t,className:n,style:o}):(console.warn(`Icon not found: ${e}`),jsx("span",{className:n,style:{fontSize:t,width:t,height:t,...o},children:e}))}var _a=12,ps=240,UT=24,tr=12,Na=Ye__default.memo(function({headings:t,onHeadingClick:n,onClose:o,topOffset:r=0,scrollLeft:a=0,leftOffset:i=_a}){let{t:s}=_(),[c,l]=useState(false),d=t.length?Math.min(...t.map(p=>p.level)):0;return useEffect(()=>{requestAnimationFrame(()=>l(true));},[]),jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":s("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:i-a,bottom:0,width:ps,paddingTop:UT,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:c?"translateX(0)":`translateX(-${i+ps}px)`,transition:"transform 0.15s ease-out"},onMouseDown:p=>p.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsx("button",{onClick:o,"aria-label":s("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:s("documentOutline.closeTitle"),children:jsx(K,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:s("documentOutline.title")})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:s("documentOutline.noHeadings")}):t.map((p,f)=>jsx("div",{style:{marginLeft:(p.level-d)*16},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>n(p.blockId),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:p.text,children:p.text})},`${p.blockId}-${f}`))})]})});var jT=e=>e,QT=Object.freeze([]),JT=()=>{};function ms(e){let t=A(),n=q(jT),o=useMemo(()=>t&&!n.isLoading?t.getOutline():QT,[t,n]),r=useCallback(a=>{if(!t)return;t.focus();let i={paragraphId:a,offset:0};t.exec({type:"setSelection",range:{anchor:i,head:i}}),t.scrollToBlock(a);},[t]);return io(n)?null:jsx(Na,{headings:o,onHeadingClick:r,onClose:e.onClose??JT,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var fs=createContext(null);function Ot(e){let t=useContext(fs);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var qo=280,Da=32,Lp=16;function Ko(e=280){return 32+e+16}function La({viewportWidth:e,pageWidthPx:t,reservation:n,inlineEndReservation:o=0,docked:r=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<0)return 0;let a=(e-o-t)/2;return a>=n?0:!r&&n<=2*a?Math.ceil(2*(n-a)):Math.ceil(n)}var aS=Object.freeze([]),iS=e=>e;function Ha(){let e=A(),t=q(iS),[n,o]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():aS,[e,t]),a=useMemo(()=>{if(r.length===0)return [];let s=r[0].level;for(let c of r)c.level<s&&(s=c.level);return r.map(c=>({heading:c,depth:c.level-s}))},[r]),i=useCallback(s=>{if(!e||typeof s!="string"||s.length===0)return;e.focus();let c={paragraphId:s,offset:0};e.exec({type:"setSelection",range:{anchor:c,head:c}}),e.scrollToBlock(s),o(s);},[e]);return {headings:r,items:a,selectedBlockId:n,goTo:i,isEmpty:r.length===0}}var hs=150,vs=2e3,bs=Object.freeze([]),cS=e=>e;function Fa(){let e=A(),t=q(cS),[n,o]=useState(""),[r,a]=useState(""),[i,s]=useState(false),[c,l]=useState(false),[d,p]=useState(bs),[f,m]=useState(-1);useEffect(()=>{if(n===r)return;let y=setTimeout(()=>a(n),hs);return ()=>clearTimeout(y)},[n,r]);let g=useMemo(()=>({matchCase:i,wholeWord:c}),[i,c]);useEffect(()=>{if(!e||r.length===0){p(bs),m(-1);return}let y=e.findMatches(r,g);p(x=>x===y?x:y);},[e,r,g,t]);let u=useRef(d);useEffect(()=>{u.current!==d&&(u.current=d,m(y=>y>=0&&y<d.length?y:-1));},[d]);let h=useCallback(y=>{if(!e)return;let x=d[y];if(!x)return;e.focus(),e.selectMatch(x).ok&&m(y);},[e,d]),b=useCallback(y=>{if(d.length===0)return;let M=((f<0?y>0?-1:0:f)+y+d.length)%d.length;h(M);},[f,h,d.length]),v=useCallback(()=>b(1),[b]),C=useCallback(()=>b(-1),[b]),P=useCallback(y=>o(y),[]),S=useCallback(()=>{o(""),a(""),p(bs),m(-1);},[]);return {query:n,setQuery:P,matchCase:i,setMatchCase:s,wholeWord:c,setWholeWord:l,matches:d,truncated:d.length>=vs,activeIndex:f,goTo:h,next:v,previous:C,clear:S,isPending:n!==r}}var gS=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,zoom:e.zoom,reviewPaneOpen:e.reviewPaneOpen??true,fitting:t?.type==="fit"&&e.zoom<(t.maxZoom??ZOOM_MAX)&&e.zoom>(t.minZoom??ZOOM_MIN)}},bS=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Oa(e={}){let{defaultOpen:t=false,defaultTab:n="headings",paneWidth:o=280}=e,[r,a]=useState(t),[i,s]=useState(n),c=e.open??r,l=e.tab??i,{onOpenChange:d,onTabChange:p}=e,f=e.open!==void 0,m=e.tab!==void 0,g=useCallback(D=>{f||a(D),d?.(D);},[f,d]),u=useCallback(()=>g(!c),[c,g]),h=useCallback(D=>{m||s(D),p?.(D);},[m,p]),b=ko(),v=_o(),C=useContext(St),{pageSetup:P,zoom:S,reviewPaneOpen:y,fitting:x}=q(gS,bS),[M,E]=useState(0),[w,N]=useState(0);useEffect(()=>{if(!v){E(0),N(0);return}let D=()=>{E(v.clientWidth);let R=Number.parseFloat(getComputedStyle(v).paddingInlineEnd);N(Number.isFinite(R)?R:0);};if(D(),typeof ResizeObserver>"u")return;let I=new ResizeObserver(D);return I.observe(v),()=>I.disconnect()},[v,c,y,C?.mounted]);let F=useRef(null);P&&(F.current=P.pageWidthTwips);let H=P?.pageWidthTwips??F.current,k=useMemo(()=>!c||H===null?0:La({viewportWidth:M,pageWidthPx:_e(H)*S,reservation:Ko(o),inlineEndReservation:w,docked:x}),[c,H,S,M,o,w,x]);return useEffect(()=>{if(b)return b.setShift(k),()=>b.setShift(0)},[b,k]),{open:c,setOpen:g,toggle:u,tab:l,setTab:h,paneWidth:o,shift:k}}var or=["headings","find"],ht=(...e)=>e.filter(Boolean).join(" ");function nr({className:e,style:t,children:n}){return jsx("div",{className:ht("docx-nav__header",e),style:t,children:n??jsxs(Fragment,{children:[jsx(rr,{}),jsx(ar,{})]})})}function rr({className:e,style:t,children:n}){let{pane:o,t:r}=Ot("Close");return jsx("button",{type:"button",className:ht("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>o.setOpen(false),children:n??jsx(K,{name:"arrow_back",size:20})})}function ar({className:e,style:t,children:n}){let{t:o}=Ot("Title");return jsx("h2",{className:ht("docx-nav__title",e),style:t,children:n??o("navigation.title")})}function ir({className:e,style:t,children:n}){let{pane:o,t:r}=Ot("Tabs"),a=useCallback(i=>{let s=i.key==="ArrowRight"?1:i.key==="ArrowLeft"?-1:0;if(s===0)return;i.preventDefault();let c=or.indexOf(o.tab);o.setTab(or[(c+s+or.length)%or.length]);},[o]);return jsx("div",{className:ht("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:a,children:n??or.map(i=>jsx(lr,{value:i},i))})}function lr({value:e,className:t,style:n,children:o}){let{pane:r,t:a}=Ot("Tab"),i=r.tab===e;return jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":i,"aria-controls":`docx-nav-panel-${e}`,tabIndex:i?0:-1,className:ht("docx-nav__tab",i&&"docx-nav__tab--selected",t),style:n,onClick:()=>r.setTab(e),children:o??a(`navigation.tabs.${e}`)})}function Ap({value:e,onChange:t,onClear:n,placeholder:o,label:r,clearLabel:a,autoFocus:i}){return jsxs("div",{className:"docx-nav__searchbox",children:[jsx(K,{name:"search",size:18,className:"docx-nav__search-icon"}),jsx("input",{type:"search",className:"docx-nav__search-input",value:e,placeholder:o,"aria-label":r,autoFocus:i,onChange:s=>t(s.target.value)}),e.length>0&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":a,onClick:n,children:jsx(K,{name:"close",size:16})})]})}function sr({className:e,style:t}){let{pane:n,outline:o,t:r}=Ot("Headings"),[a,i]=useState(""),s=q(io),c=useMemo(()=>{let d=a.trim().toLowerCase();return d.length===0?o.items:o.items.filter(p=>p.heading.text.toLowerCase().includes(d))},[o.items,a]),l=n.tab!=="headings";return jsxs("div",{className:ht("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:l,children:[jsx(Ap,{value:a,onChange:i,onClear:()=>i(""),placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),s?null:o.isEmpty?jsx("p",{className:"docx-nav__empty",children:r("navigation.headings.noHeadings")}):c.length===0?jsx("p",{className:"docx-nav__empty",children:r("navigation.find.noResults")}):jsx("ul",{className:"docx-nav__list",children:c.map((d,p)=>jsx("li",{children:jsx("button",{type:"button",className:ht("docx-nav__heading",o.selectedBlockId===d.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+d.depth*14}px`},title:d.heading.text,onClick:()=>o.goTo(d.heading.blockId),children:d.heading.text})},`${d.heading.blockId}-${p}`))})]})}function xS({match:e,active:t,onSelect:n}){return jsx("li",{children:jsx("button",{type:"button",className:ht("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:n,children:jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function cr({className:e,style:t}){let{pane:n,search:o,t:r}=Ot("Find"),a=n.tab!=="find",i=o.query.trim().length>0,s=o.matches.length===0?null:o.activeIndex<0?r(o.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:o.matches.length}):r(o.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:o.activeIndex+1,total:o.matches.length});return jsxs("div",{className:ht("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsx(Ap,{value:o.query,onChange:o.setQuery,onClear:o.clear,placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),jsxs("div",{className:"docx-nav__options",role:"group","aria-label":r("navigation.find.optionsAriaLabel"),children:[jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:o.matchCase,onChange:c=>o.setMatchCase(c.target.checked)}),r("navigation.find.matchCase")]}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:o.wholeWord,onChange:c=>o.setWholeWord(c.target.checked)}),r("navigation.find.wholeWord")]})]}),jsxs("div",{className:"docx-nav__resultbar",children:[jsx("span",{className:"docx-nav__count","aria-live":"polite",children:i?o.isPending?r("navigation.find.searching"):s??r("navigation.find.noResults"):""}),jsxs("span",{className:"docx-nav__steppers",children:[jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.previousAriaLabel"),disabled:o.matches.length===0,onClick:o.previous,children:jsx(K,{name:"keyboard_arrow_up",size:18})}),jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.nextAriaLabel"),disabled:o.matches.length===0,onClick:o.next,children:jsx(K,{name:"keyboard_arrow_down",size:18})})]})]}),o.matches.length>0&&jsx("ul",{className:"docx-nav__list","aria-label":r("navigation.find.resultsAriaLabel"),children:o.matches.map((c,l)=>jsx(xS,{match:c,active:l===o.activeIndex,onSelect:()=>o.goTo(l)},`${c.blockId}-${c.start}-${l}`))})]})}function dr({className:e,style:t,children:n}){let{pane:o,t:r}=Ot("Toggle");return jsx("button",{type:"button",className:ht("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":o.open,title:r("navigation.openTitle"),onMouseDown:a=>a.preventDefault(),onClick:o.toggle,children:n??jsx(K,{name:"toc",size:20})})}function xs(e){let t=Xe(),{t:n,toggle:o=true,className:r,style:a,children:i,...s}=e,c=Oa(s),l=Ha(),d=Fa(),{t:p}=_(),f=useMemo(()=>({pane:c,outline:l,search:d,t:n??((g,u)=>p(g,u))}),[c,l,d,n,p]),m=e.paneWidth??280;return jsx(fs.Provider,{value:f,children:jsxs("div",{className:`${t}docx-nav${c.open?" docx-nav--open":""}${r?` ${r}`:""}`,"data-open":c.open?"true":"false",style:{"--docx-nav-width":`${m}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Ko(m)}px`,...a},children:[o!==false&&!c.open&&jsx(dr,{...typeof o=="object"?o:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":f.t("navigation.ariaLabel"),inert:!c.open,children:i??jsxs(Fragment,{children:[jsx(nr,{}),jsx(ir,{}),jsx(sr,{}),jsx(cr,{})]})})]})})}var Za=Object.assign(xs,{Header:nr,Close:rr,Title:ar,Tabs:ir,Tab:lr,Headings:sr,Find:cr,Toggle:dr});var MS=600,IS=e=>e.page.total,Ts=createContext(null);function Ss({className:e,style:t}){let n=Xe(),o=A(),r=_o(),a=q(IS),{t:i}=_(),s=useContext(Ts),[c,l]=useState(1),[d,p]=useState(false);if(useEffect(()=>{if(p(false),!o||!r||a<=1)return;l(o.getCurrentPage("viewport"));let m=null,g=()=>{l(o.getCurrentPage("viewport")),p(true),m&&clearTimeout(m),m=setTimeout(()=>p(false),MS);};return r.addEventListener("scroll",g,{passive:true}),()=>{r.removeEventListener("scroll",g),m&&clearTimeout(m);}},[o,a,r]),a<=1)return null;let f=s?s("viewer.pageIndicator").replace(/\{current\}/g,String(c)).replace(/\{total\}/g,String(a)):i("viewer.pageIndicator",{current:c,total:a});return jsx("div",{className:`${n}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":d?"true":"false",role:"status","aria-live":"polite",children:f})}var _S=[],NS=e=>e.fontSubstitutions??_S;function Ba({className:e,style:t,t:n}){let o=q(NS),{t:r}=_(),a=n??r,[i,s]=useState(null);if(o.length===0)return null;let c=o.join("\0");return i===c?null:jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsx("span",{className:"docx-font-notice__text",children:a("editor.fontSubstitutionNotice",{fonts:o.join(", ")}).replace("{fonts}",o.join(", "))}),jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>s(c),children:a("common.dismiss")})]})}var Ve={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Cs(e){return Math.round(e/1440*100)/100}function qp(e){return Math.round(e*1440)}function HS(e,t){return e===t?true:!e||!t?false:e.editing===t.editing&&e.sectionIndex===t.sectionIndex&&e.variant===t.variant&&e.rId===t.rId&&e.partName===t.partName&&e.inherited===t.inherited&&e.titlePage===t.titlePage&&e.evenAndOddHeaders===t.evenAndOddHeaders&&e.headerDistanceTwips===t.headerDistanceTwips&&e.footerDistanceTwips===t.footerDistanceTwips}function Ps(){let e=A(),t=useCallback(n=>e?.getHeaderFooterState()??null,[e]);return q(t,HS)}function qa(e,t,n){let o=e.getBoundingClientRect();return {left:t-o.left-e.clientLeft+e.scrollLeft,top:n-o.top-e.clientTop+e.scrollTop}}function Ka(e,t){let[n,o]=useState(null),r=useCallback(s=>o(s),[]),[a,i]=useState({visibility:"hidden"});return useLayoutEffect(()=>{let s=n?.closest(".docx-editor__scroll-container"),c=s??n?.parentElement?.querySelector(".docx-editor__scroll-container");if(!n||!c)return;let l=0,d=null,p=new ResizeObserver(()=>m()),f=()=>{l=0;let u=e(c);if(u!==d&&(p.disconnect(),p.observe(c),p.observe(n),u&&p.observe(u),d=u),!u||!u.isConnected){i({visibility:"hidden"});return}let h=u.getBoundingClientRect(),b=Math.max(n.offsetHeight,28),v=6,C=s===c,P=h.top-b-v,S=C?qa(c,h.left,P):{left:h.left,top:P},y=S.left,x=S.top;C?c.scrollLeft+8:8;i({position:C?"absolute":"fixed",left:y,top:x,...{width:Math.max(240,Math.min(h.width,c.clientWidth-16))},visibility:"visible"});},m=()=>{l||(l=requestAnimationFrame(f));};p.observe(c),p.observe(n);let g=new MutationObserver(m);return g.observe(c,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),c.addEventListener("scroll",m,{passive:true}),window.addEventListener("resize",m),f(),()=>{l&&cancelAnimationFrame(l),p.disconnect(),g.disconnect(),c.removeEventListener("scroll",m),window.removeEventListener("resize",m);}},[n,e,t]),{ref:r,style:a}}function BS(e,t){return t==="first"?e==="header"?"headerFooter.firstPageHeader":"headerFooter.firstPageFooter":t==="even"?e==="header"?"headerFooter.evenPageHeader":"headerFooter.evenPageFooter":e==="header"?"headerFooter.header":"headerFooter.footer"}var qS=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function ur(e){let t=A();return useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let n=t.can(e);return n.ok?{enabled:true,reason:null}:{enabled:false,reason:n.reason}},[t,e])}function KS(e){let{state:t,onMouseDown:n}=e,{t:o}=_(),r=A(),[a,i]=useState(false),s=useRef(null),[c,l]=useState(""),[d,p]=useState("");useEffect(()=>{a&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(l(String(Cs(t.headerDistanceTwips))),p(String(Cs(t.footerDistanceTwips)))));},[a,t.headerDistanceTwips,t.footerDistanceTwips]),useEffect(()=>{if(!a)return;let x=M=>{s.current?.contains(M.target)||i(false);};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[a]);let f=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),m=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),g=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),u=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),b=ur(f),v=ur(m),C=ur(g),P=ur(u),S=ur(h),y=(x,M)=>{if(!r)return;let E=Number.parseFloat(M);Number.isFinite(E)&&r.exec({type:"setHeaderFooterOptions",[x]:qp(E)});};return jsxs("div",{ref:s,className:"docx-hf-chrome__options",onMouseDown:n,children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":a,"aria-haspopup":"menu",onClick:()=>i(x=>!x),onMouseDown:n,children:o("headerFooter.options")}),a?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:n,children:[qS.map(x=>{let M={type:"insertPageField",field:x.field},E=r?.can(M);return jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!E?.ok,title:E&&!E.ok?E.reason:void 0,onClick:()=>{r?.exec(M),i(false);},onMouseDown:n,children:o(x.labelKey)},x.field)}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!b.enabled,title:b.reason??void 0,onChange:()=>r?.exec(f)}),jsx("span",{children:o("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!v.enabled,title:v.reason??void 0,onChange:()=>r?.exec(m)}),jsxs("span",{children:[o("headerFooter.differentOddEven"),jsx("span",{className:"docx-hf-chrome__menu-hint",children:o("headerFooter.differentOddEvenHint")})]})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!P.enabled,title:P.reason??void 0,onClick:()=>r?.exec(u),onMouseDown:n,children:o("headerFooter.unlinkFromPrevious")}):jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>r?.exec(g),onMouseDown:n,children:o("headerFooter.linkToPrevious")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:o("headerFooter.headerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":o("headerFooter.headerDistance"),value:c,onChange:x=>l(x.target.value),onBlur:()=>y("headerDistanceTwips",c)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:o("headerFooter.footerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":o("headerFooter.footerDistance"),value:d,onChange:x=>p(x.target.value),onBlur:()=>y("footerDistanceTwips",d)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!S.enabled,title:S.reason??void 0,onClick:()=>r?.exec(h),onMouseDown:n,children:t.editing==="header"?o("headerFooter.removeHeader"):o("headerFooter.removeFooter")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-hf-close",onClick:()=>{r?.exec({type:"exitHeaderFooter"}),i(false);},onMouseDown:n,children:o("common.close")})]}):null]})}function za({className:e}){let{t}=_(),n=Ps(),o=useCallback(s=>s.querySelector("[data-docx-hf-active]"),[]),r=Ka(o,"story-label"),a=O;if(!n?.editing)return null;let i=BS(n.editing,n.variant);return jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:a,style:{...r.style,zIndex:Ve.hfInlineEditor},children:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(i)}),n.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsx(KS,{state:n,onMouseDown:a})]})}function uo(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Va=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),YS="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",XS="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",jS="M770-302 656-416l57-57 114 114-57 57ZM603-469 469-603l57-57 134 134-57 57ZM280-280h133v80H280q-83 0-141.5-58.5T80-400q0-83 58.5-141.5T280-600h133v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35Zm40-80v-80h101l80 80H320Zm493-15-57-57q23-11 33.5-32t10.5-36q0-50-35-85t-85-35H547v-80h133q83 0 141.5 58.5T880-400q0 32-11 61.5T813-375ZM792-56 56-792l56-56 736 736-56 56Z",QS="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z";function JS({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let a=vt(),i=useRef(null),{state:s,close:c}=a;useEffect(()=>{if(s.mode==="closed")return;let u=b=>{b.key==="Escape"&&(b.preventDefault(),c());},h=b=>{let v=i.current;v&&b.target instanceof Node&&v.contains(b.target)||c();};return document.addEventListener("keydown",u),document.addEventListener("mousedown",h,true),()=>{document.removeEventListener("keydown",u),document.removeEventListener("mousedown",h,true);}},[s.mode,c]);let[l,d]=useState(null);useLayoutEffect(()=>{let u=s.anchor,h=i.current;if(!u||!h){d(null);return}let b=h.offsetParent;if(!b){d(null);return}let{left:v,top:C}=qa(b,u.left,u.top),P=Math.max(0,b.scrollWidth-h.offsetWidth);d({left:Math.max(0,Math.min(v,P)),top:C});},[s.anchor]);let{t:p}=_(),f=s.mode==="editing"?p(s.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):p("hyperlinkPopup.editLink"),m=r?jsx(eC,{children:o}):o;if(n)return s.mode==="closed"?null:jsx(Fragment,{children:o});let g={ref:i,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":s.mode,role:"dialog","aria-modal":false,onMouseDown:uo,style:l??void 0,"aria-label":f};return s.mode==="closed"?null:t?jsx(W,{...g,children:o}):jsx("div",{...g,children:m})}function eC({children:e}){let{state:t}=vt(),n=useMemo(()=>tC(e),[e]),o=(r,a)=>r in n?n[r]:a;return t.mode==="editing"?jsxs(Fragment,{children:[o("Fields",jsx(_s,{})),o("Error",jsx(Ds,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Apply",jsx(Ns,{})),o("Cancel",jsx(Ls,{}))]}),n.__extra]}):jsxs(Fragment,{children:[o("Url",jsx(Ms,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Copy",jsx(Is,{})),t.canEdit?o("Edit",jsx(ks,{})):null,t.canEdit?o("Unlink",jsx(Rs,{})):null]}),n.__extra]})}function tC(e){let t={},n=[],o=r=>{if(Array.isArray(r)){r.forEach(o);return}if(!r||typeof r!="object"||!("type"in r)){r&&n.push(r);return}if(r.type===Fragment$1){o(r.props.children);return}let a=r.type.docxHyperLinkPart;a?t[a]=r:n.push(r);};return o(e),n.length>0&&(t.__extra=n),t}function vt(){return useContext(mn)??oC}var oC={state:{mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:false},open:()=>{},openAtCaret:()=>{},close:()=>{},copy:async()=>false,beginEdit:()=>{},setText:()=>{},setUrl:()=>{},commitEdit:()=>false,unlink:()=>false,openTarget:()=>false};function Ms({className:e,asChild:t,hidden:n,children:o}){let{state:r,openTarget:a}=vt(),{t:i}=_();if(n||!r.link)return null;let s=!r.link.href,c=r.link.kind==="internal",l=c?`#${r.link.anchor??""}`:r.link.authored,d=i(s?"hyperlinkPopup.inertTarget":c?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),p={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...s?{"data-inert":""}:{},title:d,onMouseDown:uo,...s?{}:{onClick:()=>a(),type:"button"}};return t?jsx(W,{...p,children:o}):s?jsxs("span",{...p,children:[o??l,jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxs("button",{...p,children:[o??l,Va(QS)]})}Ms.docxHyperLinkPart="Url";function Is({className:e,asChild:t,hidden:n,children:o,icon:r}){let{state:a,copy:i}=vt(),{t:s}=_();if(n||!a.link?.href)return null;let c=a.copied?s("editor.linkCopied"):s("hyperlinkPopup.copyLink"),l={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...a.copied?{"data-copied":""}:{},"aria-label":c,title:c,onMouseDown:uo,onClick:()=>{i();}};return t?jsx(W,{...l,children:o}):jsx("button",{...l,children:r??o??Va(YS)})}Is.docxHyperLinkPart="Copy";function ks({className:e,asChild:t,hidden:n,children:o,icon:r}){let{beginEdit:a}=vt(),{t:i}=_();if(n)return null;let s=i("hyperlinkPopup.editLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":s,title:s,onMouseDown:uo,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:r??o??Va(XS)})}ks.docxHyperLinkPart="Edit";function Rs({className:e,asChild:t,hidden:n,children:o,icon:r}){let{unlink:a}=vt(),{t:i}=_();if(n)return null;let s=i("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":s,title:s,onMouseDown:uo,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:r??o??Va(jS)})}Rs.docxHyperLinkPart="Unlink";function _s({className:e,hidden:t}){let{state:n,setText:o,setUrl:r,commitEdit:a,close:i}=vt(),{t:s}=_(),c=useRef(null),l=useId(),d=useId();useEffect(()=>{n.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[n.mode]);let p=useCallback(f=>{if(f.key==="Enter"){f.preventDefault(),a();return}f.key==="Escape"&&(f.preventDefault(),i());},[a,i]);return t?null:jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:l,children:s("hyperlinkPopup.displayTextPlaceholder")}),jsx("input",{id:l,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:n.text,placeholder:s("hyperlinkPopup.displayTextPlaceholder"),onChange:f=>o(f.target.value),onKeyDown:p}),jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:s("hyperlinkPopup.urlPlaceholder")}),jsx("input",{id:d,ref:c,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:n.url,placeholder:s("hyperlinkPopup.urlPlaceholder"),onChange:f=>r(f.target.value),onKeyDown:p})]})}_s.docxHyperLinkPart="Fields";function Ns({className:e,asChild:t,hidden:n,children:o}){let{state:r,commitEdit:a}=vt(),{t:i}=_();if(n)return null;let s=i("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:uo,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:o??s})}function Ds({className:e,hidden:t}){let{state:n}=vt(),{t:o}=_();return t||!n.error?null:jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:o("hyperlinkPopup.refused")})}Ds.docxHyperLinkPart="Error";Ns.docxHyperLinkPart="Apply";function Ls({className:e,asChild:t,hidden:n,children:o}){let{close:r}=vt(),{t:a}=_();if(n)return null;let i=a("hyperlinkPopup.cancel"),s={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:uo,onClick:()=>r()};return t?jsx(W,{...s,children:o}):jsx("button",{...s,children:o??i})}Ls.docxHyperLinkPart="Cancel";var $a=Object.assign(JS,{Url:Ms,Copy:Is,Edit:ks,Unlink:Rs,Fields:_s,Error:Ds,Apply:Ns,Cancel:Ls});function nC(e,t){return e===t?true:!e||!t||e.kind!==t.kind?false:e.kind==="note"&&t.kind==="note"?e.id===t.id:e.kind==="headerFooter"&&t.kind==="headerFooter"?e.rId===t.rId:true}function Hs(){let e=A(),t=useCallback(o=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),n=q(t,nC);return n?.kind==="note"?n:null}function Up(e,t){return e===t?true:!e||!t?false:e.pos===t.pos&&e.numFmt===t.numFmt&&e.numStart===t.numStart&&e.numRestart===t.numRestart}function Gp(e,t){return e.resolved.pos===t.resolved.pos&&e.resolved.numFmt===t.resolved.numFmt&&e.resolved.numStart===t.resolved.numStart&&e.resolved.numRestart===t.resolved.numRestart&&Up(e.documentAuthored,t.documentAuthored)&&Up(e.sectionAuthored,t.sectionAuthored)}function rC(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Gp(e.footnote,t.footnote)&&Gp(e.endnote,t.endnote)}function Fs(){let e=A(),t=useCallback(n=>e?.getNotePropertiesState()??null,[e]);return q(t,rC)}var aC=/^(footnote|endnote):(-?\d{1,10})$/;function Xp(e){let t=aC.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isInteger(n)?{noteKind:t[1],noteId:n}:null}function iC(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function Os(e){let t=A();return useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let n=t.can(e);return n.ok?{enabled:true,reason:null}:{enabled:false,reason:n.reason}},[t,e])}function lC(e){let{t}=_(),[n,o]=useState(false),r=useRef(null);return useEffect(()=>{if(!n)return;let a=i=>{r.current?.contains(i.target)||o(false);};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]),jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":n,"aria-haspopup":"menu",onMouseDown:O,onClick:()=>o(a=>!a),children:t("headerFooter.options")}),n?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:O,children:[jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),o(false);},children:t("dialogs.footnoteProperties.title")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),o(false);},children:t("common.close")})]}):null]})}function Wa({className:e}){let{t}=_(),n=A(),o=Hs(),[r,a]=useState(null),[i,s]=useState(null),[c,l]=useState(false),d=useRef(null),p=useCallback(E=>{if(!o)return null;let N=[...E.querySelectorAll("[data-docx-note-scope]")].find(F=>F.matches("[data-docx-note]")&&F.dataset.docxNoteScope===o.id)??null;return N?.closest("[data-docx-notes]")??N},[o]),f=Ka(p,"story-label"),m=useCallback(()=>{d.current&&clearTimeout(d.current),d.current=null,a(null);},[]);useEffect(()=>{if(!n)return;let E=document.querySelector(".docx-pages");if(!E)return;let w=H=>{let k=H.target;if(!k)return;let D=k.closest("[data-docx-note-ref]");if(D?.dataset.docxNoteScope){H.preventDefault(),m(),s(null),n.setActiveScope({kind:"note",id:D.dataset.docxNoteScope});return}k.closest("[data-docx-note-mark-back]")&&(H.preventDefault(),m(),s(null),n.setActiveScope({kind:"body"}));},N=H=>{let k=H,I=k.target?.closest("[data-docx-note-scope]");I?.dataset.docxNoteScope&&(k.preventDefault(),s({scopeId:I.dataset.docxNoteScope,x:k.clientX,y:k.clientY}));},F=H=>{if(iC())return;let D=H.target?.closest("[data-docx-note-ref]");if(!D?.dataset.docxNoteScope){m();return}let I=D.dataset.docxNoteScope,z=n.getNotePreviewText(I)??D.getAttribute("aria-description")??t("notes.previewFallback"),Z=D.getBoundingClientRect();d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{a({scopeId:I,text:z,x:Z.left,y:Z.bottom+4});},400);};return E.addEventListener("click",w),E.addEventListener("contextmenu",N),E.addEventListener("pointerover",F),E.addEventListener("scroll",m,true),()=>{E.removeEventListener("click",w),E.removeEventListener("contextmenu",N),E.removeEventListener("pointerover",F),E.removeEventListener("scroll",m,true),m();}},[n,m,t]);let g=useCallback(E=>{n&&(n.exec(E),s(null));},[n]),u=i?Xp(i.scopeId):null,h=useMemo(()=>u?{type:"deleteNote",noteKind:u.noteKind,noteId:u.noteId}:null,[u]),b=useMemo(()=>u?{type:"convertNote",fromKind:u.noteKind,noteId:u.noteId}:null,[u]),v=useMemo(()=>u?{type:"convertAllNotes",fromKind:u.noteKind}:null,[u]),C=Os(h??{type:"deleteNote",noteKind:"footnote",noteId:0}),P=Os(b??{type:"convertNote",fromKind:"footnote",noteId:0}),S=Os(v??{type:"convertAllNotes",fromKind:"footnote"}),y=useMemo(()=>({position:"fixed",left:r?.x??0,top:r?.y??0,zIndex:Ve.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg, #fff)",color:"var(--doc-popover-fg, #111)",border:"1px solid var(--doc-border, #ddd)",boxShadow:"var(--doc-shadow, 0 4px 16px rgba(0,0,0,.12))",fontSize:12,lineHeight:1.4,pointerEvents:"none"}),[r]),x=o?Xp(o.id):null,M=x?t("notes.editingRegion",{kind:x.noteKind==="footnote"?t("notes.footnoteKind"):t("notes.endnoteKind"),number:x.noteId}):null;return n?jsxs("div",{className:e,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":o?void 0:true,children:[o&&x?jsxs("div",{ref:f.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":t("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":o.id,style:{...f.style,zIndex:Ve.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:M}),jsx(lC,{onOpenProperties:()=>l(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,r?jsx("div",{role:"tooltip","data-testid":"docx-notes-preview",style:y,onMouseDown:E=>{E.preventDefault(),E.stopPropagation();},children:r.text}):null,i&&u?jsxs("div",{role:"menu","data-testid":"docx-notes-menu",style:{position:"fixed",left:i.x,top:i.y,zIndex:Ve.popover,minWidth:160,background:"var(--doc-popover-bg, #fff)",border:"1px solid var(--doc-border, #ddd)",boxShadow:"var(--doc-shadow, 0 4px 16px rgba(0,0,0,.12))",padding:4},onMouseDown:O,children:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>h&&g(h),children:t("notes.delete")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!P.enabled,title:P.reason??void 0,onClick:()=>b&&g(b),children:u.noteKind==="footnote"?t("notes.convertToEndnote"):t("notes.convertToFootnote")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!S.enabled,title:S.reason??void 0,onClick:()=>v&&g(v),children:u.noteKind==="footnote"?t("notes.convertAllFootnotes"):t("notes.convertAllEndnotes")}),jsx("button",{type:"button",role:"menuitem",onClick:()=>l(true),children:t("dialogs.footnoteProperties.title")})]}):null,c?jsx(sC,{onClose:()=>l(false),onApply:E=>{g(E),l(false);}}):null]}):null}function sC(e){let{t}=_(),n=A(),o=Fs(),[r,a]=useState("document"),[i,s]=useState("decimal"),[c,l]=useState("continuous"),[d,p]=useState("pageBottom"),[f,m]=useState("decimal"),[g,u]=useState("continuous"),[h,b]=useState("docEnd");useEffect(()=>{o&&(s(o.footnote.resolved.numFmt),l(o.footnote.resolved.numRestart),p(o.footnote.resolved.pos),m(o.endnote.resolved.numFmt),u(o.endnote.resolved.numRestart),b(o.endnote.resolved.pos));},[o]);let v=!o?.footnote.documentAuthored&&!o?.footnote.sectionAuthored,C=!o?.endnote.documentAuthored&&!o?.endnote.sectionAuthored;return jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:Ve.modal},onClick:e.onClose,onKeyDown:P=>{P.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),children:[jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxs("div",{className:"docx-note-properties__body",children:[jsxs("label",{className:"docx-note-properties__scope",children:[jsx("span",{children:t("notes.scope")}),jsxs("select",{className:"docx-note-properties__select",value:r,onChange:P=>a(P.target.value),children:[jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),v?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:i,onChange:P=>s(P.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:c,onChange:P=>l(P.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:d,onChange:P=>p(P.target.value),children:[jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),C?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:f,onChange:P=>m(P.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:g,onChange:P=>u(P.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:h,"data-testid":"docx-notes-endnote-position",onChange:P=>b(P.target.value),children:[jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxs("div",{className:"docx-note-properties__footer",children:[jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!n)return;let P={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?o?.sectionIndex:void 0,footnote:{numFmt:i,numRestart:c,position:d},endnote:{numFmt:f,numRestart:g,position:h}};n.can(P).ok&&e.onApply(P);},children:t("common.apply")})]})]})})}var Ua=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function po(){return useContext(Ua)}function Jp(){return useContext(Ua).target}var em=["M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-560l-80-80 240-240h120v40L600-560ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6Zm-240 300q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z"],tm=["M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"],om=["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"],nm=["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"],rm=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],am=["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],im=["M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-120q-33 0-56.5-23.5T120-200h80v80Zm-80-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160q0-33 23.5-56.5T200-840v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"];function Ga(e,t,n){return Object.assign(({icon:r,labelKey:a,shortcutKey:i,className:s,hidden:c})=>{let l=A(),{close:d}=po(),p=Oe(),{isEnabled:f,disabledReason:m}=ne(t);return c?null:jsx(Le,{slot:e,icon:r??te(n.paths),shortcut:p(i??n.shortcutKey),disabled:!f,...m?{title:m}:{},onSelect:()=>{l?.exec(t),d(true);},...s?{className:s}:{},children:p(a??n.labelKey)})},{docxRow:e})}var mr=Ga("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:em}),fr=Ga("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:tm}),gr=Ga("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:nm}),br=Ga("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:im});function Wo({icon:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let a=A(),{close:i,clipboardRefusal:s,reportClipboardRefusal:c}=po(),l=Oe(),d=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:p,disabledReason:f}=ne(d);if(r)return null;let m=s!==null;return jsx(Le,{slot:"edit.paste",icon:e??te(om),shortcut:l(n??"contextMenu.pasteShortcut"),disabled:!p||m,...s??f?{title:s??f??""}:{},onSelect:()=>{(async()=>{try{let g=await navigator.clipboard.readText();g&&a?.exec({type:"paste",text:g});}catch(g){c(g instanceof Error?g.message:"the clipboard is not readable");}finally{i(true);}})();},...o?{className:o}:{},children:l(t??"contextMenu.paste")})}Wo.docxRow="edit.paste";function mo(e,t,n){return Object.assign(({icon:r,labelKey:a,className:i,hidden:s,destructive:c})=>{let{close:l}=po(),d=Oe(),p=ja(),{isEnabled:f,disabledReason:m,execute:g}=ne(t);return s||!p?null:jsx(Le,{slot:e,icon:r??te(n.paths),disabled:!f,...m?{title:m}:{},className:`${c??n.destructive?"docx-table-chrome__destructive-row":""}${i?` ${i}`:""}`,onSelect:()=>{g()&&l(true);},children:d(a??n.labelKey)})},{docxRow:e})}var Uo=mo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),Go=mo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),Yo=mo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),Xo=mo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),jo=mo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),Qo=mo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),Jo=mo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),uC=[{alignment:"top",labelKey:"tableAdvanced.top",icon:"vertical_align_top"},{alignment:"center",labelKey:"tableAdvanced.middle",icon:"vertical_align_center"},{alignment:"bottom",labelKey:"tableAdvanced.bottom",icon:"vertical_align_bottom"}];function fo({hidden:e}){let{close:t}=po(),n=Oe(),o=ja(),r=ne({type:"setTableCellVerticalAlignment",alignment:"top"}),a=ne({type:"setTableCellVerticalAlignment",alignment:"center"}),i=ne({type:"setTableCellVerticalAlignment",alignment:"bottom"}),s=[r,a,i];return e||!o?null:jsxs("div",{className:"docx-contextmenu__table-align",children:[jsx("span",{className:"docx-contextmenu__table-align-label",children:n("tableAdvanced.verticalAlignment")}),jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":n("tableAdvanced.verticalAlignment"),children:uC.map((c,l)=>{let d=s[l];return jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":n(c.labelKey),title:d.disabledReason??n(c.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:p=>{p.preventDefault(),p.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:te(tableChromeIconPaths(c.icon))},c.alignment)})})]})}fo.docxRow="table.cellVerticalAlignment";function sm(e,t,n){return Object.assign(({icon:r,labelKey:a,className:i,hidden:s})=>{let c=A(),{close:l,tocId:d}=po(),p=Oe(),f=useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:m,disabledReason:g}=ne(f);return s||d===null?null:jsx(Le,{slot:e,icon:r??te(n.paths),disabled:!m,...g?{title:g}:{},onSelect:()=>{c?.exec(f),l(true);},...i?{className:i}:{},children:p(a??n.labelKey)})},{docxRow:e})}var Ya=sm("toc.refresh","entire",{labelKey:"toc.refresh",paths:rm}),Xa=sm("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:am});function ja(){return q(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function Qa({label:e,icon:t,shortcut:n,disabled:o,disabledReason:r,active:a,onSelect:i,className:s}){let{close:c}=po();return jsx(Le,{...t?{icon:t}:{},...n?{shortcut:n}:{},...o?{disabled:o}:{},...o&&r?{title:r}:{},...a!==void 0?{active:a}:{},onSelect:()=>{i?.(),c(true);},...s?{className:s}:{},children:e})}var ti=8,fC=[{kind:"row",id:"edit.cut",render:()=>jsx(mr,{})},{kind:"row",id:"edit.copy",render:()=>jsx(fr,{})},{kind:"row",id:"edit.paste",render:()=>jsx(Wo,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(gr,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(br,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(gt,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsx(gt,{slot:"review.comments",labelKey:"comments.addComment"})}];function gC(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Uo.docxRow,render:()=>jsx(Uo,{})},{kind:"row",id:Go.docxRow,render:()=>jsx(Go,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Yo.docxRow,render:()=>jsx(Yo,{})},{kind:"row",id:Xo.docxRow,render:()=>jsx(Xo,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:jo.docxRow,render:()=>jsx(jo,{})},{kind:"row",id:Qo.docxRow,render:()=>jsx(Qo,{})},{kind:"row",id:Jo.docxRow,render:()=>jsx(Jo,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:fo.docxRow,render:()=>jsx(fo,{})}]}function bC(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Ya.docxRow,render:()=>jsx(Ya,{})},{kind:"row",id:Xa.docxRow,render:()=>jsx(Xa,{})}]}function hC(e,t=false){return [...fC,...e?gC():[],...t?bC():[]]}function mm(e){if(!isValidElement(e))return null;let t=No(e,mm);if(t!==null)return t;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxRow=="string")return n.docxRow;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxMenuRow===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function um(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function vC(e){return e?.closest(".docx-editor__scroll-container")??null}function vr({className:e,t,preset:n=true,disabled:o,onOpenChange:r,children:a}){let i=Xe(),s=A(),{t:c}=_(),l=ja(),d=useRef(null),p=useRef(null),[f,m]=useState(null),[g,u]=useState(null),[h,b]=useState(null),v=useMemo(()=>hC(l,g!==null),[l,g]),[C,P]=useState(null),S=useCallback((H=false)=>{m(null),P(null),u(null),b(null),H&&s?.focus();},[s]);useEffect(()=>{if(o)return;let H=vC(d.current);if(!H)return;let k=D=>{D.preventDefault();let I=D.button===-1||D.clientX===0&&D.clientY===0,R=H.getBoundingClientRect();u(s?.snapshot().tocContext?.id??null),b(I||!(D.target instanceof HTMLElement)?null:D.target),m(I?{x:R.left+16,y:R.top+16}:{x:D.clientX,y:D.clientY});};return H.addEventListener("contextmenu",k),()=>H.removeEventListener("contextmenu",k)},[o,s]),useEffect(()=>{o&&S();},[o,S]),useEffect(()=>{if(!f)return;let H=I=>{p.current?.contains(I.target)||S();},k=I=>{I.key==="Escape"?(I.preventDefault(),S(true)):I.key==="Tab"&&S();},D=()=>S();return document.addEventListener("pointerdown",H,true),document.addEventListener("keydown",k),document.addEventListener("scroll",D,{capture:true,passive:true}),window.addEventListener("blur",D),window.addEventListener("resize",D),()=>{document.removeEventListener("pointerdown",H,true),document.removeEventListener("keydown",k),document.removeEventListener("scroll",D,true),window.removeEventListener("blur",D),window.removeEventListener("resize",D);}},[f,S]),useLayoutEffect(()=>{let H=p.current;if(!f||!H)return;let{width:k,height:D}=H.getBoundingClientRect(),I=window.innerWidth-k-ti,R=window.innerHeight-D-ti,z=Math.max(ti,f.x>I?f.x-k:f.x),Z=Math.max(ti,f.y>R?f.y-D:f.y);P({x:z,y:Z});},[f]),useLayoutEffect(()=>{C&&p.current?.focus({preventScroll:true});},[C]);let y=useRef(r);y.current=r;let x=useRef(false);useEffect(()=>{let H=f!==null;H!==x.current&&(x.current=H,y.current?.(H));},[f]);let M=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>S(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,S]),[E,w]=useState(null),N=useMemo(()=>({close:S,anchor:f,tocId:g,target:h,clipboardRefusal:E,reportClipboardRefusal:w}),[S,f,g,h,E]),F={position:"fixed",left:(C??f)?.x??0,top:(C??f)?.y??0,visibility:C?"visible":"hidden"};return jsx("div",{ref:d,style:{display:"contents"},children:f?jsx($n.Provider,{value:M,children:jsx(Ua.Provider,{value:N,children:jsxs("div",{ref:p,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${i}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:F,onKeyDown:H=>{let k=p.current;if(!k)return;let D=Jt(k);H.key==="ArrowDown"?(H.preventDefault(),at(D,document.activeElement,1)):H.key==="ArrowUp"?(H.preventDefault(),at(D,document.activeElement,-1)):H.key==="Home"?(H.preventDefault(),it(D,"first")):H.key==="End"&&(H.preventDefault(),it(D,"last"));},children:[Children.toArray(a).filter(um),Ur({entries:v,children:Children.toArray(a).filter(H=>!um(H)),preset:n,keyOfEntry:H=>H.id,keyOfChild:mm,renderEntry:H=>H.kind==="separator"?jsx(no,{}):H.render()})]})})}):null})}var qs=Object.assign(vr,{Cut:mr,Copy:fr,Paste:Wo,Delete:gr,SelectAll:br,InsertRowAbove:Uo,InsertRowBelow:Go,InsertColumnLeft:Yo,InsertColumnRight:Xo,DeleteTableRow:jo,DeleteTableColumn:Qo,DeleteTable:Jo,CellVerticalAlignment:fo,RefreshToc:Ya,RefreshTocPageNumbers:Xa,Item:Qa,Slot:gt,Row:Le,Group:Gn,Separator:no,Submenu:oo});function Ks(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var gm=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),SC="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",CC="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",PC={position:"absolute",zIndex:20,minWidth:240,maxWidth:320,top:12,right:12,padding:12,borderRadius:8,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-surface)",boxShadow:"0 4px 16px var(--doc-shadow)",color:"var(--doc-text)",fontSize:13,display:"flex",flexDirection:"column",gap:10},EC={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},wC={color:"var(--doc-text-muted)",flexShrink:0},MC={textAlign:"right",wordBreak:"break-word"},IC={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},kC={display:"flex",gap:8,marginTop:4},bm={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:4,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text)",font:"inherit",cursor:"pointer"};function RC(e){switch(e){case "plainText":return "contentControl.types.plainText";case "checkbox":return "contentControl.types.checkbox";case "dropdown":return "contentControl.types.dropdown";case "comboBox":return "contentControl.types.comboBox";case "date":return "contentControl.types.date";case "picture":return "contentControl.types.picture";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function _C(e){return e.effectiveLock==="sdtContentLocked"?"contentControl.lock.sdtContentLocked":e.effectiveLock==="contentLocked"||e.locked?"contentControl.lock.contentLocked":e.effectiveLock==="sdtLocked"||e.removalLocked?"contentControl.lock.sdtLocked":"contentControl.lock.unlocked"}function en({label:e,value:t,testId:n}){return jsxs("div",{style:EC,"data-testid":n,children:[jsx("span",{style:wC,children:e}),jsx("span",{style:MC,children:t})]})}function NC({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let a=pt(),i=useRef(null),s=useId(),{t:c}=_(),{control:l,inspectorOpen:d,closeInspector:p}=a;if(useEffect(()=>{if(!d)return;let u=b=>{b.key==="Escape"&&(b.preventDefault(),p());},h=b=>{let v=i.current;v&&b.target instanceof Node&&v.contains(b.target)||p();};return document.addEventListener("keydown",u),document.addEventListener("mousedown",h,true),()=>{document.removeEventListener("keydown",u),document.removeEventListener("mousedown",h,true);}},[d,p]),useEffect(()=>{d&&!l&&p();},[d,l,p]),n||!d||!l)return null;let f=r?jsxs(Fragment,{children:[jsx(hm,{}),jsx(vm,{}),jsx("div",{style:kC,children:jsx(ym,{})}),o]}):o,m={ref:i,role:"dialog","aria-modal":false,"aria-labelledby":s,"data-testid":"content-control-inspector","data-control-id":l.id,"data-control-type":l.controlType,...l.locked?{"data-locked":""}:{},...l.bound?{"data-bound":""}:{},...l.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:PC,onMouseDown:u=>{Ks(u),u.stopPropagation();}},g=jsxs(Fragment,{children:[jsx("span",{id:s,className:"docx-editor-sr-only",children:c("contentControl.inspectorPanel.title")}),f]});return t?jsx(W,{...m,children:g}):jsx("div",{...m,children:g})}function hm({className:e,asChild:t,hidden:n,children:o}){let{closeInspector:r}=pt(),{t:a}=_();if(n)return null;let i={style:IC,className:e??void 0,"data-testid":"content-control-inspector-header"},s=jsxs(Fragment,{children:[jsx("span",{children:o??a("contentControl.inspectorPanel.title")}),jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":a("common.close"),title:a("common.close"),style:{...bm,padding:4,border:"none",background:"transparent"},onMouseDown:Ks,onClick:()=>r(),children:gm(SC)})]});return t?jsx(W,{...i,children:s}):jsx("div",{...i,children:s})}function vm({className:e,asChild:t,hidden:n,children:o}){let{control:r}=pt(),{t:a}=_();if(n||!r)return null;let i=a("contentControl.inspectorPanel.empty"),s=a("contentControl.inspectorPanel.yes"),c=a("contentControl.inspectorPanel.no"),l=o??jsxs(Fragment,{children:[jsx(en,{label:a("contentControl.inspectorPanel.alias"),value:r.alias??i,testId:"content-control-inspector-alias"}),jsx(en,{label:a("contentControl.inspectorPanel.tag"),value:r.tag??i,testId:"content-control-inspector-tag"}),jsx(en,{label:a("contentControl.inspectorPanel.type"),value:a(RC(r.controlType)),testId:"content-control-inspector-type"}),jsx(en,{label:a("contentControl.inspectorPanel.lock"),value:a(_C(r)),testId:"content-control-inspector-lock"}),jsx(en,{label:a("contentControl.inspectorPanel.placeholder"),value:r.placeholder?s:c,testId:"content-control-inspector-placeholder"}),jsx(en,{label:a("contentControl.inspectorPanel.bound"),value:r.bound?s:c,testId:"content-control-inspector-bound"}),r.bound?jsx("p",{"data-testid":"content-control-inspector-bound-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},children:a("contentControl.inspectorPanel.boundNote")}):null,r.locked?jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:a("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsx(W,{...d,children:l}):jsx("div",{...d,children:l})}function ym({className:e,asChild:t,hidden:n,icon:o,children:r}){let{canRemove:a,removeDisabledReason:i,remove:s,closeInspector:c}=pt(),{t:l}=_();if(n)return null;let d=l("contentControl.remove"),p={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":d,title:i??d,style:bm,onMouseDown:Ks,onClick:()=>{s().ok&&c();}},f=jsxs(Fragment,{children:[o??r??gm(CC),jsx("span",{children:d})]});return t?jsx(W,{...p,children:f}):jsx("button",{...p,children:f})}var oi=Object.assign(NC,{Header:hm,Fields:vm,Remove:ym});var FC={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},AC={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},OC={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},ZC={display:"flex",justifyContent:"center",flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",backgroundColor:"var(--doc-bg)"},BC={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},qC={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:30,backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},KC={padding:"8px 12px"},zC={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},VC={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},$C={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function WC({forwardedRef:e}){let t=A(),n=useRef(null);return n.current=t,Uc({ref:e,editorRef:n}),null}var UC=forwardRef(function(t,n){let{document:o,fonts:r,className:a,t:i,chrome:s=true,title:c,onTitleChange:l,renderTitleBarLeft:d,renderTitleBarRight:p,colorMode:f="light",author:m,locale:g,mode:u,modules:h,zoom:b,zoomMode:v,onReady:C,onChange:P,onFontError:S,onOpen:y,onSave:x,hyperlinkPopup:M,contextMenu:E=true,menu:w=true,navigation:N=true,rulers:F=true}=t,[H,k]=useState(fc);useEffect(()=>{if(f==="system")return bc(k)},[f]);let D=gc(f,H),{t:I}=_(),R=useCallback((Q,Me)=>i?i(Q,Me):I(Q,Me),[i,I]),z=jsxs(zr,{className:s?D?"dark":void 0:a,style:s?AC:void 0,children:[s?jsx(za,{}):null,s?jsx(Wa,{}):null,jsx(Fr,{}),jsx($a,{hidden:M===false}),E===false?null:jsx(vr,{t:R,...typeof E=="object"?E:{}}),jsx(oi,{}),F&&s?jsx("div",{style:BC,"aria-hidden":"true",children:jsx(Ra,{})}):null,t.children]}),Z=s?jsxs("div",{className:`docx-editor${D?" dark":""}${a?` ${a}`:""}`,style:FC,children:[jsxs("div",{style:qC,children:[jsxs("div",{style:zC,children:[d?.(),jsxs("div",{style:VC,children:[l?jsx("input",{"aria-label":R("titleBar.documentNameAriaLabel"),value:c??"",placeholder:R("titleBar.untitled"),onChange:Q=>l(Q.target.value),style:$C}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:c??R("titleBar.untitled")}),w!==false?jsx(jn,{t:R,...c!==void 0?{fileName:c}:{},...y?{onOpen:y}:{},...x?{onSave:x}:{},...typeof w=="object"?w:{}}):null]}),p?.()]}),jsx("div",{style:KC,children:jsx(zn,{t:R})})]}),F?jsx("div",{style:ZC,children:jsx(ka,{})}):null,jsx(Ba,{t:R}),jsxs("div",{style:OC,children:[N?jsx(Za,{t:R}):null,z,jsx(Ts.Provider,{value:R,children:jsx(Ss,{})})]})]}):z,$=useCallback(Q=>R(Q),[R]);return jsxs(qr,{...o!==void 0?{document:o}:{},...r?{fonts:r}:{},...m!==void 0?{author:m}:{},...g!==void 0?{locale:g}:{},translate:R,...u!==void 0?{mode:u}:{},...h!==void 0?{modules:h}:{},...b!==void 0?{zoom:b}:{},...v!==void 0?{zoomMode:v}:{},tableInteractionLabel:$,...C?{onReady:C}:{},...P?{onChange:P}:{},...S?{onFontError:S}:{},children:[jsx(WC,{forwardedRef:n}),jsx(Qt.Provider,{value:s,children:Z})]})}),GC=forwardRef(function(t,n){return jsx(wo,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(UC,{...t,ref:n})})}),YC=Object.assign(GC,{Root:qr,Viewport:zr,Content:Fr,Toolbar:zn,Menu:jn,Loading:Ai,HorizontalRuler:ka,VerticalRuler:Ra,DocumentOutline:ms,Navigation:Za,PageSetupDialog:Vn,PageNumber:Ss,FontNotice:Ba,HeaderFooterChrome:za,NotesChrome:Wa,HyperLink:$a,ContextMenu:qs,ContentControl:oi});function QC(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}async function JC(e){return typeof e=="function"?e():e}function eP(e,t={}){let[n,o]=useState(void 0),[r,a]=useState(void 0),[i,s]=useState(null),[c,l]=useState(e!=null),[d,p]=useState(t.fonts===void 0),f=useRef(t);return f.current=t,useEffect(()=>{let m=f.current.fonts;if(m===void 0)return;let g=true;return (async()=>{try{let u=await JC(m);g&&a(composeFontConfiguration(u));}catch{}finally{g&&p(true);}})(),()=>{g=false;}},[]),useEffect(()=>{if(e==null){o(void 0),s(null),l(false);return}let m=QC(e);if(m){o(m),s(null),l(false);return}let g=true,u=new AbortController;return l(true),s(null),(async()=>{try{let h=await fetch(String(e),{...f.current.fetchOptions,signal:u.signal});if(!h.ok)throw new Error(`could not open the document: ${h.status} ${h.statusText}`);let b=new Uint8Array(await h.arrayBuffer());if(!g)return;o(b),l(!1);}catch(h){if(!g||h instanceof Error&&h.name==="AbortError")return;s(h instanceof Error?h:new Error("could not open the document")),l(false);}})(),()=>{g=false,u.abort();}},[e]),{document:d?n:void 0,fonts:r,error:i,isLoading:c||!d}}function rP(e,...t){let n=useRef({source:e,fragments:t});return n.current={source:e,fragments:t},useMemo(()=>async o=>{let r=n.current,i=[typeof r.source=="function"?await r.source(o):await r.source,...r.fragments].filter(l=>l!==void 0);if(i.length===0)return;let{epoch:s,...c}=composeFontConfiguration(i[0],...i.slice(1));return c},[])}function lP(e){let n=e?.surface?.state?.().selection?.head;return n&&typeof n.paragraphId=="string"&&Number.isFinite(n.offset)?n:null}function sP(){let e=A(),t=useRef(null),n=useCallback(r=>{if(!e)return ()=>{};let a=e.on("selectionChange",r),i=e.on("change",r);return ()=>{a(),i();}},[e]),o=useCallback(()=>{let r=lP(e),a=t.current;return (r===null?a===null:a!==null&&cP(a,r))?a:(t.current=r,r)},[e]);return useSyncExternalStore(n,o,()=>null)}function cP(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function zs({source:e,scale:t,measurer:n,onStateChange:o,onError:r,className:a,documentFontFamily:i,ref:s}){let c=useRef(null),l=useRef(null),[d,p]=useState(null),f=useRef(o);f.current=o;let m=useRef(r);return m.current=r,useEffect(()=>{let g=c.current;if(!g)return;let u=mountPaginatedSurface(g,e,{...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onChange:b=>{p(b),f.current?.(b);}});if(!u.ok){m.current?.(u.reason,u.detail);return}l.current=u.surface;let h=u.surface.state();return p(h),f.current?.(h),()=>{u.surface.destroy(),l.current=null;}},[e,n]),useImperativeHandle(s,()=>({focus:()=>l.current?.focus(),type:g=>l.current?.type(g),undo:()=>l.current?.undo(),redo:()=>l.current?.redo(),selectAll:()=>l.current?.selectAll(),navigate:(g,u)=>l.current?.navigate(g,u),toggleRunProperty:(g,u)=>l.current?.toggleRunProperty(g,u),setRunProperty:(g,u)=>l.current?.setRunProperty(g,u),setParagraphProperty:(g,u)=>l.current?.setParagraphProperty(g,u),formatting:()=>l.current?.formatting()??null,sectionProperties:()=>l.current?.sectionProperties()??null,save:()=>l.current?.session.save()??null}),[]),jsx("div",{ref:c,style:{margin:"24px auto",...i?{fontFamily:i}:{}},className:a?`docx-paginated-surface ${a}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var Tr=createContext(null);function Pm(){let e=useContext(Tr);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function vP(e){return "type"in e&&e.type==="separator"}var Mm={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},yP={...Mm,background:"var(--doc-bg-hover)"},Im={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},xP={...Im,opacity:.4,cursor:"default"},TP={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},SP={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},CP={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:8,zIndex:1001};function Sr({label:e,items:t,disabled:n,showChevron:o=false}){let[r,a]=useState(false),[i,s]=useState(null),c=useRef(null),l=useRef(null),[d,p]=useState({top:0,left:0}),f=useCallback(()=>{a(false),s(null);},[]);useEffect(()=>{if(!r||!c.current)return;let g=c.current.getBoundingClientRect();p({top:g.bottom+2,left:g.left});},[r]),useEffect(()=>{if(!r)return;function g(b){let v=b.target;c.current&&!c.current.contains(v)&&l.current&&!l.current.contains(v)&&f();}function u(b){b.key==="Escape"&&f();}function h(){f();}return document.addEventListener("mousedown",g),document.addEventListener("keydown",u),window.addEventListener("scroll",h,true),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",u),window.removeEventListener("scroll",h,true);}},[r,f]);let m=g=>{g.disabled||g.submenuContent||g.onClick&&(g.onClick(),f());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:c,type:"button",onClick:()=>!n&&a(!r),onMouseDown:g=>g.preventDefault(),disabled:n,style:r?yP:Mm,children:[e,o&&jsx(K,{name:"arrow_drop_down",size:16})]}),r&&jsx("div",{ref:l,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:g=>g.preventDefault(),children:t.map((g,u)=>{if(vP(g))return jsx("div",{style:TP},`sep-${u}`);let h=g;if(h.customContent)return jsx("div",{onMouseDown:C=>C.preventDefault(),children:h.customContent},h.label);let b=!!h.submenuContent,v=i===h.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>b&&s(h.label),onMouseLeave:()=>b&&s(null),children:[jsxs("button",{type:"button",style:h.disabled?xP:Im,onClick:()=>m(h),onMouseDown:C=>C.preventDefault(),onMouseOver:C=>{h.disabled||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:C=>{C.currentTarget.style.backgroundColor="transparent";},disabled:h.disabled,children:[h.icon&&jsx(K,{name:h.icon,size:18}),jsx("span",{children:h.label}),h.shortcut&&jsx("span",{style:SP,children:h.shortcut}),b&&jsx("span",{style:{marginLeft:"auto"},children:jsx(K,{name:"keyboard_arrow_right",size:16})})]}),b&&v&&jsx("div",{style:CP,onMouseDown:C=>C.preventDefault(),children:h.submenuContent(f)})]},h.label)})})]})}var Ws=18,EP=2,Rm={width:Ws,height:Ws,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},wP={...Rm,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},MP={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function _m({onInsert:e,gridRows:t=6,gridColumns:n=6}){let[o,r]=useState(0),[a,i]=useState(0),s=useCallback(()=>{o>0&&a>0&&e(o,a);},[o,a,e]),c=[];for(let d=1;d<=t;d++)for(let p=1;p<=n;p++){let f=d<=o&&p<=a;c.push(jsx("div",{style:f?wP:Rm,onMouseEnter:()=>{r(d),i(p);},onClick:s,role:"gridcell","aria-selected":f},`${d}-${p}`));}let l=o>0&&a>0?`${a} \xD7 ${o}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:EP,gridTemplateColumns:`repeat(${n}, ${Ws}px)`},onMouseLeave:()=>{r(0),i(0);},role:"grid","aria-label":"Table size selector",children:c}),jsx("div",{style:MP,children:l})]})}function _P({items:e,closeMenu:t}){return jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(n=>{let o=!n.onClick;return jsxs("button",{type:"button",disabled:o,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:o?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:o?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{o||(n.onClick?.(),t());},onMouseOver:r=>{o||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsx(K,{name:n.icon,size:18}),jsx("span",{children:n.label})]},n.label)})})}function NP(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function ai({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function DP(e){return e.replace(/\.docx$/i,"")}function Gs({value:e,onChange:t,placeholder:n,editable:o=true}){let{t:r}=_(),a=n??r("titleBar.untitled"),i=DP(e)??"";return o?jsx("input",{type:"text",value:i,onChange:s=>{let c=s.target.value;t?.(c.endsWith(".docx")?c:c+".docx");},placeholder:a,className:"text-base font-normal text-foreground bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-muted focus:bg-doc-bg-input focus:ring-1 focus:ring-ring min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":r("titleBar.documentNameAriaLabel")}):jsx("span",{className:"text-base font-normal text-foreground px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:i||a})}function ii({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function li(){let{t:e}=_(),t=Pm(),{disabled:n=false,onFormat:o,onPrint:r,onOpen:a,onSave:i,onPageSetup:s,onInsertImage:c,onInsertTable:l,showTableInsert:d=true,showHelpMenu:p=true,onInsertPageBreak:f,onInsertSectionBreakNextPage:m,onInsertSectionBreakContinuous:g,onInsertTOC:u,onWatermark:h,onRefocusEditor:b}=t,v=useCallback(y=>{!n&&o&&o(y);},[n,o]),C=useCallback((y,x)=>{!n&&l&&(l(y,x),requestAnimationFrame(()=>b?.()));},[n,l,b]),P=!!r||!!s,S=P||a||i;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[S&&jsx(Sr,{label:e("toolbar.file"),disabled:n,items:[...a?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:a}]:[],...i?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:i}]:[],...(a||i)&&P?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...s?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:s}]:[]]}),jsx(Sr,{label:e("toolbar.format"),disabled:n,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>v("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>v("setRtl")}]}),jsx(Sr,{label:e("toolbar.insert"),disabled:n,items:[...c?[{icon:"image",label:e("toolbar.image"),onClick:c}]:[],...d&&l?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:y=>jsx(_m,{onInsert:(x,M)=>{C(x,M),y();}})}]:[],...c||d&&l?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:y=>jsx(_P,{closeMenu:y,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:f},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:m},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:g}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:u,disabled:!u},...h?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:h}]:[]]}),p&&jsx(Sr,{label:e("toolbar.help"),disabled:n,items:[{label:e("toolbar.reportIssue"),onClick:()=>Wn()}]})]})}function Ys({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,i=>{isValidElement(i)&&(i.type===ai?t=i:i.type===ii?n=i:i.type===li?r.push(i):o.push(i));});let a=useCallback(i=>{let s=i.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||i.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:a,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(NP,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}var si={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},AP={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},Nm={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function OP(e,t){let n=Nm[t]??Nm[t.toLowerCase()]??t,r=e?.colorScheme?.[n];return typeof r=="string"&&r?r:si[n]??"000000"}function Dm(e){let t=e.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/.test(t))return t;if(/^[0-9A-F]{3}$/.test(t))return t.split("").map(n=>n+n).join("")}function Xs(e,t,n="000000"){if(!e||e.kind==="auto")return `#${n}`;if(e.kind==="hex")return `#${Dm(e.value)??n}`;let o=Object.entries(t?.colorScheme??si).map(([a,i])=>({slot:a,hex:String(i)})),r=resolveThemeColorHex(e,o);return `#${r.ok?r.hex:OP(t,e.slot)}`}function wt(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?Dm(e.value):Xs(e,t).slice(1)}function Lm(e){if(!e||e==="none")return "";let t=AP[e];return t?`#${t}`:""}var ZP=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],BP=[{type:"base",keep:1,labelSuffix:""},{type:"tint",keep:.2,labelSuffix:", Lighter 80%"},{type:"tint",keep:.4,labelSuffix:", Lighter 60%"},{type:"tint",keep:.6,labelSuffix:", Lighter 40%"},{type:"shade",keep:.75,labelSuffix:", Darker 25%"},{type:"shade",keep:.5,labelSuffix:", Darker 50%"}];function Hm(e){let t=e??si;return BP.map(n=>ZP.map(o=>{let r=t[o.slot]??si[o.slot]??"000000",i={hex:n.type==="base"?r.toUpperCase():n.type==="tint"?applyThemeTint(r,n.keep):applyThemeShade(r,n.keep),themeSlot:o.slot,label:`${o.name}${n.labelSuffix}`};return n.type==="tint"?i.tint=n.keep:n.type==="shade"&&(i.shade=n.keep),i}))}function j(...e){return clsx(e)}var zP=cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-7 w-7"}},defaultVariants:{variant:"default",size:"default"}}),we=Ye.forwardRef(({className:e,variant:t,size:n,...o},r)=>jsx("button",{className:j(zP({variant:t,size:n,className:e})),ref:r,...o}));we.displayName="Button";function Je({content:e,children:t,side:n="bottom",delayMs:o=400}){let[r,a]=Ye.useState(false),[i,s]=Ye.useState({x:0,y:0}),c=Ye.useRef(null),l=Ye.useRef(null),d=Ye.useCallback(()=>{l.current=setTimeout(()=>{if(c.current){let g=c.current.getBoundingClientRect(),u=g.left+g.width/2,h=n==="top"?g.top-8:g.bottom+8;s({x:u,y:h});}a(true);},o);},[o,n]),p=Ye.useCallback(()=>{l.current&&(clearTimeout(l.current),l.current=null),a(false);},[]);Ye.useEffect(()=>()=>{l.current&&clearTimeout(l.current);},[]);let f=t.props,m=Ye.cloneElement(t,{ref:c,onMouseEnter:g=>{d(),f.onMouseEnter?.(g);},onMouseLeave:g=>{p(),f.onMouseLeave?.(g);}});return jsxs(Fragment,{children:[m,r&&jsx("div",{className:"fixed z-50 px-2 py-1 text-xs font-medium text-white bg-foreground dark:bg-muted dark:text-foreground rounded-md shadow-lg",style:{left:i.x,top:i.y,transform:n==="top"?"translate(-50%, -100%)":n==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var qt=pe.Root,Kt=pe.Group,ci=pe.Value;function zt({className:e,children:t,onMouseDown:n,...o}){return jsxs(pe.Trigger,{className:j("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-foreground bg-transparent","hover:bg-muted/80 focus:outline-none focus:bg-muted/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[t,jsx(pe.Icon,{asChild:true,children:jsx(GP,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Vt({className:e,children:t,position:n="popper",onCloseAutoFocus:o,...r}){let a=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsx(pe.Portal,{children:jsx("div",{className:j("docx-editor",a&&"dark"),children:jsx(pe.Content,{className:j("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-border bg-popover text-popover-foreground shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:n,onCloseAutoFocus:i=>{i.preventDefault(),o?.(i);},...r,children:jsx(pe.Viewport,{className:j("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:i=>i.preventDefault(),children:t})})})})}function bo({className:e,...t}){return jsx(pe.Label,{className:j("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function et({className:e,children:t,onMouseDown:n,...o}){return jsxs(pe.Item,{className:j("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-foreground outline-none","hover:bg-muted focus:bg-muted","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[jsx(pe.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(pe.ItemIndicator,{children:jsx(YP,{className:"h-4 w-4"})})})]})}function ho({className:e,...t}){return jsx(pe.Separator,{className:j("-mx-1 my-1 h-px bg-muted",e),...t})}function GP({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})}function YP({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})}function js(e){let t=e.trim();if(!t)return "";let n=null,o="";for(let r of t){if((r==='"'||r==="'")&&n===null){n=r,o+=r;continue}if(r===n){n=null,o+=r;continue}if(r===","&&n===null)break;o+=r;}return o.trim().replace(/^['"]|['"]$/g,"")}var XP=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function Om({value:e,onChange:t,fonts:n=XP,documentFonts:o,disabled:r=false,className:a,placeholder:i="Arial",width:s=120,showPreview:c=true}){let{t:l}=_(),d=Ye.useMemo(()=>{if(!o)return [];let u=new Set(n.map(h=>h.name.toLowerCase()));return o.filter(h=>!u.has(h.name.toLowerCase()))},[o,n]),p=Ye.useMemo(()=>[...d,...n],[d,n]),f=Ye.useMemo(()=>e?p.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||js(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:i,[e,p,i]),m=Ye.useCallback(u=>{let h=p.find(b=>b.name===u);h&&t?.(js(h.fontFamily)||h.name);},[t,p]),g=Ye.useMemo(()=>{let u={"sans-serif":[],serif:[],monospace:[],other:[]};return n.forEach(h=>{let b=h.category||"other";u[b].push(h);}),u},[n]);return jsxs(qt,{value:f,onValueChange:m,disabled:r,children:[jsx(zt,{className:j("h-8 text-sm",a),style:{minWidth:typeof s=="number"?`${s}px`:s},"aria-label":l("font.selectAriaLabel"),children:jsx(ci,{placeholder:i,children:f})}),jsxs(Vt,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(Kt,{children:[jsx(bo,{children:l("font.documentFonts")}),d.map(u=>jsx(et,{value:u.name,style:c?{fontFamily:u.fontFamily}:void 0,children:u.name},`doc-${u.name}`))]}),jsx(ho,{})]}),g["sans-serif"].length>0&&jsxs(Kt,{children:[jsx(bo,{children:l("font.sansSerif")}),g["sans-serif"].map(u=>jsx(et,{value:u.name,style:c?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]}),g.serif.length>0&&jsxs(Fragment,{children:[jsx(ho,{}),jsxs(Kt,{children:[jsx(bo,{children:l("font.serif")}),g.serif.map(u=>jsx(et,{value:u.name,style:c?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]})]}),g.monospace.length>0&&jsxs(Fragment,{children:[jsx(ho,{}),jsxs(Kt,{children:[jsx(bo,{children:l("font.monospace")}),g.monospace.map(u=>jsx(et,{value:u.name,style:c?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]})]}),g.other.length>0&&jsxs(Fragment,{children:[jsx(ho,{}),jsx(Kt,{children:g.other.map(u=>jsx(et,{value:u.name,style:c?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))})]})]})]})}function Qs(e){if(e===void 0)return;let t=e.map(n=>typeof n=="string"?{name:n,fontFamily:n,category:"other"}:n);return t}function e1(e,t,n,o){let a=Math.max(8,window.innerWidth-n-8),i=Math.max(8,window.innerHeight-o-8);return {top:Math.min(Math.max(8,e),i),left:Math.min(Math.max(8,t),a)}}function $e({isOpen:e,onClose:t,align:n="left"}){let o=useRef(null),r=useRef(null),[a,i]=useState({top:0,left:0});useEffect(()=>{if(!e||!o.current)return;let l=o.current.getBoundingClientRect();n==="right"?requestAnimationFrame(()=>{if(r.current){let d=r.current.getBoundingClientRect(),p=e1(l.bottom+4,l.right-d.width,d.width,d.height);i(p);}else i({top:l.bottom+4,left:l.left});}):i({top:l.bottom+4,left:l.left});},[e,n]),useEffect(()=>{if(!e)return;let l=performance.now()+150,d=m=>{let g=m.target;o.current&&!o.current.contains(g)&&r.current&&!r.current.contains(g)&&t();},p=m=>{m.key==="Escape"&&t();},f=m=>{if(performance.now()<l)return;let g=m.target;g&&r.current&&r.current.contains(g)||g instanceof Element&&g!==document.documentElement&&g!==document.body&&o.current&&g.contains(o.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),window.addEventListener("scroll",f,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,true);}},[e,t]);let s=useCallback(l=>{l.preventDefault(),l.stopPropagation();},[]),c={position:"fixed",top:a.top,left:a.left,zIndex:1e4};return {containerRef:o,dropdownRef:r,dropdownStyle:c,handleMouseDown:s}}var n1=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],r1=1,a1=400;function qm(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function Km(e,t,n){for(let o=t.length-1;o>=0;o--)if(t[o]<e)return t[o];return Math.max(e-1,n)}function zm({value:e,onChange:t,sizes:n=n1,disabled:o=false,className:r,placeholder:a="11",minSize:i=r1,maxSize:s=a1}){let{t:c}=_(),[l,d]=useState(false),[p,f]=useState(""),[m,g]=useState(false),u=useRef(null),h=useCallback(()=>{g(false),d(false);},[]),{containerRef:b,dropdownRef:v,dropdownStyle:C}=$e({isOpen:m,onClose:h}),P=e??(parseInt(a,10)||11),S=e!==void 0?e.toString():a,y=useCallback(k=>{if(k.preventDefault(),o)return;let D=Km(P,n,i);t?.(D);},[P,n,i,o,t]),x=useCallback(k=>{if(k.preventDefault(),o)return;let D=qm(P,n,s);t?.(D);},[P,n,s,o,t]),M=useCallback(k=>{k.preventDefault(),!o&&(d(true),f(S),g(true),requestAnimationFrame(()=>{u.current?.focus(),u.current?.select();}));},[o,S]),E=useCallback(k=>{f(k.target.value);},[]),w=useCallback(()=>{d(false);let k=parseFloat(p);if(!isNaN(k)&&k>=i&&k<=s){let D=Math.round(k*2)/2;t?.(D);}},[p,i,s,t]),N=useCallback(k=>{if(k.key==="Enter")k.preventDefault(),w(),g(false);else if(k.key==="Escape")d(false),g(false);else if(k.key==="ArrowUp"){k.preventDefault();let D=qm(P,n,s);f(D.toString()),t?.(D);}else if(k.key==="ArrowDown"){k.preventDefault();let D=Km(P,n,i);f(D.toString()),t?.(D);}},[w,P,n,s,i,t]),F=useCallback(k=>{t?.(k),g(false),d(false);},[t]),H=useCallback(k=>{k.target.tagName!=="INPUT"&&k.preventDefault();},[]);return jsxs("div",{ref:b,className:j("flex items-center",r),onMouseDown:H,children:[jsx(we,{variant:"ghost",size:"icon-sm",className:j("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:y,disabled:o||P<=i,"aria-label":c("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(K,{name:"remove",size:18})}),jsx("div",{className:"relative",children:l?jsx("input",{ref:u,type:"text",value:p,onChange:E,onBlur:w,onKeyDown:N,className:j("h-7 w-10 text-center text-sm border border-input bg-doc-bg-input text-doc-text","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none"),"aria-label":c("fontSize.label"),"data-testid":"font-size-input"}):jsx("button",{type:"button",onClick:M,className:j("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",o&&"opacity-50 cursor-not-allowed"),disabled:o,"aria-label":c("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":m,"data-testid":"font-size-display",children:S})}),m&&jsx("div",{ref:v,style:{...C,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":c("fontSize.listLabel"),children:n.map(k=>jsx("button",{type:"button",onClick:()=>F(k),className:j("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",k===P&&"bg-muted font-medium"),role:"option","aria-selected":k===P,children:k},k))}),jsx(we,{variant:"ghost",size:"icon-sm",className:j("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:x,disabled:o||P>=s,"aria-label":c("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(K,{name:"add",size:18})})]})}var s1=[{name:"Dark Red",nameKey:"colorPicker.colors.darkRed",hex:"C00000"},{name:"Red",nameKey:"colorPicker.colors.red",hex:"FF0000"},{name:"Orange",nameKey:"colorPicker.colors.orange",hex:"FFC000"},{name:"Yellow",nameKey:"colorPicker.colors.yellow",hex:"FFFF00"},{name:"Light Green",nameKey:"colorPicker.colors.lightGreen",hex:"92D050"},{name:"Green",nameKey:"colorPicker.colors.green",hex:"00B050"},{name:"Light Blue",nameKey:"colorPicker.colors.lightBlue",hex:"00B0F0"},{name:"Blue",nameKey:"colorPicker.colors.blue",hex:"0070C0"},{name:"Dark Blue",nameKey:"colorPicker.colors.darkBlue",hex:"002060"},{name:"Purple",nameKey:"colorPicker.colors.purple",hex:"7030A0"}],ui=18,c1=2,d1={position:"relative",display:"inline-block"},u1={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},p1={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},tc={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},oc={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},Wm={display:"grid",gap:`${c1}px`},pi={width:`${ui}px`,height:`${ui}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},Um={...pi,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},Gm={...pi,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},m1={display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"5px 8px",border:"1px solid var(--doc-border-dark)",borderRadius:"4px",backgroundColor:"var(--doc-surface)",cursor:"pointer",fontSize:"12px",color:"var(--doc-text)"},f1={display:"flex",alignItems:"center",gap:"6px"},g1={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},b1={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},Vm={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},h1={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},v1={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0,width:"28px",padding:"2px 4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},y1={display:"flex",alignItems:"center",justifyContent:"center",width:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"};function nc(e,t,n){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let o=Lm(e);return o||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Xs(e,n)}function $m(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let n=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (n*299+o*587+r*114)/1e3>230}function Ym(e,t,n){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():wt(e,n))===t.toUpperCase():false}function x1({matrix:e,selectedColor:t,theme:n,onSelect:o}){let[r,a]=useState(null);return jsx("div",{style:{...Wm,gridTemplateColumns:`repeat(10, ${ui}px)`},children:e.flatMap((i,s)=>i.map((c,l)=>{let d=`${s}-${l}`,p=r===d,f=Ym(t,c.hex,n);return jsx("button",{type:"button",style:{...f?Gm:p?Um:pi,backgroundColor:`#${c.hex}`},title:c.label,"aria-label":c.label,"aria-selected":f,onClick:()=>o(c),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>a(d),onMouseLeave:()=>a(null)},d)}))})}function T1({selectedColor:e,theme:t,onSelect:n}){let[o,r]=useState(null),{t:a}=_();return jsx("div",{style:{...Wm,gridTemplateColumns:`repeat(10, ${ui}px)`},children:s1.map((i,s)=>{let c=o===s,l=Ym(e,i.hex,t),d=a(i.nameKey);return jsx("button",{type:"button",style:{...l?Gm:c?Um:pi,backgroundColor:`#${i.hex}`},title:d,"aria-label":d,"aria-selected":l,onClick:()=>n(i.hex),onMouseDown:p=>p.preventDefault(),onMouseEnter:()=>r(s),onMouseLeave:()=>r(null)},i.hex)})})}function xo({mode:e,value:t,onChange:n,theme:o,disabled:r=false,className:a,style:i,title:s,icon:c,autoLabel:l,splitButton:d=true,defaultColor:p}){let[f,m]=useState(false),[g,u]=useState(false),[h,b]=useState(false),[v,C]=useState(false),[P,S]=useState(""),[y,x]=useState(()=>p??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:M}=_();useEffect(()=>{let G=nc(t,e,o).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(G)&&S(G.toUpperCase());},[t,e,o]);let E=useCallback(()=>m(false),[]),{containerRef:w,dropdownRef:N,dropdownStyle:F}=$e({isOpen:f,onClose:E}),H=o?.colorScheme??null,k=useMemo(()=>Hm(H),[H]),D=useMemo(()=>nc(t,e,o),[t,e,o]),I=useMemo(()=>nc(y,e,o),[y,e,o]),R=useCallback(()=>{r||m(G=>!G);},[r]),z=useCallback(G=>{let B;e==="highlight"?B=G.hex:B={kind:"theme",slot:G.themeSlot,...G.tint!==void 0?{tint:G.tint}:{},...G.shade!==void 0?{shade:G.shade}:{}},x(B),n?.(B),m(false);},[e,n]),Z=useCallback(G=>{let B=e==="highlight"?G:{kind:"hex",value:G};x(B),n?.(B),m(false);},[e,n]),$=useCallback(()=>{n?.(e==="highlight"?"none":{kind:"auto"}),m(false);},[e,n]),Q=useCallback(()=>{let G=P.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(G)){let B=e==="highlight"?G:{kind:"hex",value:G};x(B),n?.(B),m(false),S("");}},[e,P,n]),Me=useCallback(()=>{r||n?.(y);},[r,y,n]),se={...u1,...r?{cursor:"default",opacity:.38}:f?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:g?{backgroundColor:"var(--doc-bg-hover)"}:{}},Te=M(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),Ce=c??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:w,className:`docx-color-picker ${a||""}`,style:{...d1,...i},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...h1,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...v1,...r?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:Me,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),disabled:r,title:s||Te,"aria-label":s||Te,children:[jsx(K,{name:Ce,size:18}),jsx("div",{style:{...Vm,backgroundColor:I==="transparent"?"#fff":I,outline:I==="transparent"||$m(I)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...y1,...r?{cursor:"default"}:f?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:v?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:R,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>C(true),onMouseLeave:()=>C(false),disabled:r,title:s||Te,"aria-label":s||Te,"aria-haspopup":"true","aria-expanded":f,children:jsx(K,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:se,onClick:R,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),disabled:r,title:s||Te,"aria-label":s||Te,"aria-haspopup":"true","aria-expanded":f,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(K,{name:Ce,size:18}),jsx("div",{style:{...Vm,backgroundColor:D==="transparent"?"#fff":D,outline:D==="transparent"||$m(D)?"1px solid #bbb":"none"}})]}),jsx(K,{name:"arrow_drop_down",size:14})]}),f&&jsx("div",{ref:N,className:"docx-color-picker-dropdown",style:{...F,...p1},role:"dialog","aria-label":`${Te} picker`,onMouseDown:G=>{G.target.tagName!=="INPUT"&&G.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:m1,onClick:$,onMouseDown:G=>G.preventDefault(),children:[e==="highlight"?jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),l??M(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:oc}),jsx("div",{style:tc,children:M("colorPicker.themeColors")}),jsx(x1,{matrix:k,selectedColor:t,theme:o,onSelect:z}),jsx("div",{style:oc}),jsx("div",{style:tc,children:M("colorPicker.standardColors")}),jsx(T1,{selectedColor:t,theme:o,onSelect:Z}),jsx("div",{style:oc}),jsx("div",{style:tc,children:M("colorPicker.customColor")}),jsxs("div",{style:f1,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:g1,value:P,onChange:G=>S(G.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:G=>{G.key==="Enter"&&Q();},onMouseDown:G=>{G.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...b1,opacity:/^[0-9A-Fa-f]{6}$/.test(P)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(P)?"pointer":"default"},onClick:Q,onMouseDown:G=>G.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(P),children:M("common.apply")})]})]})})]})}var Pr=20,rc=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(K,{name:"format_align_left",size:Pr}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(K,{name:"format_align_center",size:Pr}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(K,{name:"format_align_right",size:Pr}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(K,{name:"format_align_justify",size:Pr}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function Qm({value:e="left",onChange:t,disabled:n=false}){let{t:o}=_(),[r,a]=useState(false),i=useCallback(()=>a(false),[]),{containerRef:s,dropdownRef:c,dropdownStyle:l,handleMouseDown:d}=$e({isOpen:r,onClose:i}),p=useCallback(b=>{n||t?.(b),a(false);},[n,t]),f=rc.find(b=>b.value===e)||rc[0],m=o(f.labelKey),g=f.shortcutKey?o(f.shortcutKey):void 0,u=`${m}${g?` (${g})`:""}`,h=jsxs(we,{variant:"ghost",size:"icon-sm",className:j("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",n&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!n&&a(b=>!b),disabled:n,"aria-label":u,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(K,{name:f.iconName,size:Pr}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(Je,{content:u,children:h}),r&&!n&&jsx("div",{ref:c,style:{...l,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:b=>b.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:rc.map(b=>{let v=e===b.value,C=o(b.labelKey),P=b.shortcutKey?o(b.shortcutKey):void 0;return jsx("button",{type:"button",title:`${C}${P?` (${P})`:""}`,"data-testid":`alignment-${b.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:v?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:S=>S.preventDefault(),onMouseEnter:S=>{v||(S.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:S=>{S.currentTarget.style.backgroundColor=v?"var(--doc-primary-light)":"transparent";},onClick:()=>p(b.value),children:jsx(K,{name:b.iconName,size:18})},b.value)})})})]})}function mi(){return {type:"none",level:0,isInList:false}}var w1={display:"inline-flex",alignItems:"center",gap:"4px"},Jm={display:"inline-flex",alignItems:"center",gap:"4px"},hi={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},M1={...hi,backgroundColor:"var(--doc-bg-hover)"},I1={...hi,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},k1={...hi,cursor:"default",opacity:.38},R1={width:"28px",height:"28px",padding:"2px"},_1={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},fi=20;function gi({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:a,style:i}){let[s,c]=useState(false),l={...t?k1:e?I1:s?M1:hi,...i},d=p=>{p.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${a||""}`,style:l,onMouseDown:d,onClick:t?void 0:o,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:n,"aria-label":n,"aria-pressed":e,role:"button",children:r})}function ef({listState:e,onBulletList:t,onNumberedList:n,onIndent:o,onOutdent:r,disabled:a=false,className:i,style:s,showIndentButtons:c=true,compact:l=false,hasIndent:d=false}){let{t:p}=_(),f=useCallback(()=>l?{...R1}:{},[l]),m=e?.type==="bullet",g=e?.type==="numbered",h=(e?.isInList||m||g)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${i||""}`,style:{...w1,...s},role:"group","aria-label":p("lists.ariaLabel"),children:[jsxs("div",{style:Jm,role:"group","aria-label":p("lists.typeAriaLabel"),children:[jsx(gi,{active:m,disabled:a,title:p("lists.bulletList"),onClick:t,style:f(),children:jsx(K,{name:"format_list_bulleted",size:fi})}),jsx(gi,{active:g,disabled:a,title:p("lists.numberedList"),onClick:n,style:f(),children:jsx(K,{name:"format_list_numbered",size:fi})})]}),c&&jsxs(Fragment,{children:[jsx("div",{style:_1,role:"separator"}),jsxs("div",{style:Jm,role:"group","aria-label":p("lists.indentationAriaLabel"),children:[jsx(gi,{active:false,disabled:a||!h,title:p("lists.decreaseIndent"),onClick:r,style:f(),children:jsx(K,{name:"format_indent_decrease",size:fi})}),jsx(gi,{active:false,disabled:a,title:p("lists.increaseIndent"),onClick:o,style:f(),children:jsx(K,{name:"format_indent_increase",size:fi})})]})]})]})}var D1=[{label:"Single",labelKey:"lineSpacing.single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",labelKey:"lineSpacing.double",value:2,twipsValue:480}];function of({value:e,onChange:t,options:n=D1,disabled:o=false,className:r}){let{t:a}=_(),i=Ye.useMemo(()=>e===void 0?n[0]:n.find(l=>l.twipsValue===e)||n[0],[e,n]),s=Ye.useCallback(l=>{let d=parseInt(l,10);isNaN(d)||t?.(d);},[t]),c=l=>l.labelKey?a(l.labelKey):l.label;return jsxs(qt,{value:i.twipsValue.toString(),onValueChange:s,disabled:o,children:[jsx(zt,{className:j("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":a("lineSpacing.label"),title:a("lineSpacing.lineSpacingTitle",{label:c(i)}),children:jsx(us,{className:"h-5 w-5 shrink-0"})}),jsxs(Vt,{children:[n.map(l=>jsx(et,{value:l.twipsValue.toString(),children:c(l)},l.twipsValue)),jsx(ho,{}),jsx(Kt,{children:jsx(bo,{children:a("lineSpacing.blockSpacingRules")})})]})]})}var L1={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},H1=new Set(["Title","Heading1","Heading2","Heading3"]),F1={Subtitle:"666666"},A1="#4a6c8c";function nf(e){let t=L1[e.styleId],o={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??H1.has(e.styleId))&&(o.fontWeight="bold"),e.italic&&(o.fontStyle="italic");let r=e.color??F1[e.styleId];return r?o.color=`#${r}`:e.styleId.startsWith("Heading")&&(o.color=A1),o}function rf(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:t.name||t.styleId,priority:99}))}var af=[{styleId:"Normal",name:"Normal text",nameKey:"styles.normalText",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",nameKey:"styles.title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",nameKey:"styles.subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",nameKey:"styles.heading1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",nameKey:"styles.heading2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",nameKey:"styles.heading3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}];function lf({value:e,onChange:t,styles:n,disabled:o=false,className:r,width:a=120}){let{t:i}=_(),s=Ye.useMemo(()=>{let m=rf(n);return m.length===0?af:m.map(g=>({...g,type:"paragraph",nameKey:af.find(u=>u.styleId===g.styleId)?.nameKey}))},[n]),c=Ye.useCallback(m=>{t?.(m);},[t]),l=m=>m.nameKey?i(m.nameKey):m.name,d=e||"Normal",p=s.find(m=>m.styleId===d),f=p?l(p):d;return jsxs(qt,{value:d,onValueChange:c,disabled:o,children:[jsx(zt,{className:j("h-8 text-sm",r),style:{width:typeof a=="number"?`${a}px`:a},"aria-label":i("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:f})}),jsx(Vt,{className:"min-w-[260px] max-h-[400px]",children:s.map(m=>jsx(et,{value:m.styleId,className:"py-2.5 px-3",children:jsx("span",{style:nf(m),children:l(m)})},m.styleId))})]})}var Z1=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function cf({value:e=1,onChange:t,levels:n=Z1,disabled:o=false,className:r,compact:a=false}){let{t:i}=_(),s=Ye.useMemo(()=>{let m=n.find(g=>Math.abs(g.value-e)<.001);return m?m.label:`${Math.round(e*100)}%`},[n,e]),c=Ye.useCallback(m=>{let g=parseFloat(m);isNaN(g)||t?.(g);},[t]),l=Ye.useMemo(()=>[...n].sort((m,g)=>m.value-g.value),[n]),d=Ye.useMemo(()=>[...l].reverse().find(m=>m.value<e-.001),[l,e]),p=Ye.useMemo(()=>l.find(m=>m.value>e+.001),[l,e]),f=a?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[jsx(we,{variant:"ghost",size:"icon-sm",className:j(f,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(o||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:o||!d,"aria-label":i("zoom.zoomOut"),children:jsx(K,{name:"remove",size:18})}),jsxs(qt,{value:e.toString(),onValueChange:c,disabled:o,children:[jsx(zt,{className:j(a?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":i("zoom.ariaLabel",{label:s}),children:jsx(ci,{placeholder:"100%",children:s})}),jsx(Vt,{children:n.map(m=>jsx(et,{value:m.value.toString(),children:m.label},m.value))})]}),jsx(we,{variant:"ghost",size:"icon-sm",className:j(f,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(o||!p)&&"opacity-30 cursor-not-allowed"),onClick:()=>p&&t?.(p.value),disabled:o||!p,"aria-label":i("zoom.zoomIn"),children:jsx(K,{name:"add",size:18})})]})}var q1=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function pf({onAction:e,disabled:t=false}){let{t:n}=_(),[o,r]=useState(false),a=useCallback(()=>r(false),[]),{containerRef:i,dropdownRef:s,dropdownStyle:c,handleMouseDown:l}=$e({isOpen:o,onClose:a}),d=useCallback(f=>{e(f),r(false);},[e]),p=jsxs(we,{variant:"ghost",size:"icon-sm",className:j("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:l,onClick:()=>!t&&r(f=>!f),disabled:t,"aria-label":n("table.borders.styleAriaLabel"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(K,{name:"border_all",size:20}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[o?p:jsx(Je,{content:n("table.borders.tooltip"),children:p}),o&&!t&&jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:f=>f.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:q1.map(({action:f,icon:m,labelKey:g})=>jsx("button",{type:"button",title:n(g),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:u=>u.preventDefault(),onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(f),children:jsx(K,{name:m,size:18})},typeof f=="string"?f:f.type))})})]})}function mf({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),a=useCallback(i=>{if(typeof i=="string"){e({type:"borderColor",color:i.replace(/^#/,"")});return}let s=i.kind==="auto"?"000000":wt(i,n);s&&e({type:"borderColor",color:s});},[e,n]);return jsx(xo,{mode:"border",value:o,onChange:a,theme:n,disabled:t,title:r("table.borderColor")})}var $1=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function gf({onAction:e,disabled:t=false}){let[n,o]=useState(false),{t:r}=_(),a=useCallback(()=>o(false),[]),{containerRef:i,dropdownRef:s,dropdownStyle:c,handleMouseDown:l}=$e({isOpen:n,onClose:a}),d=useCallback(f=>{e({type:"borderWidth",size:f}),o(false);},[e]),p=jsxs(we,{variant:"ghost",size:"icon-sm",className:j("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:l,onClick:()=>!t&&o(f=>!f),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(K,{name:"line_weight",size:20}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[n?p:jsx(Je,{content:r("table.borderWidth"),children:p}),n&&!t&&jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:120},onMouseDown:f=>f.stopPropagation(),children:$1.map(({size:f,label:m,thickness:g})=>jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},onMouseDown:u=>u.preventDefault(),onMouseEnter:u=>{u.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(f),children:[jsx("div",{style:{width:50,height:Math.max(g,1),backgroundColor:"#000",borderRadius:g>2?1:0}}),jsx("span",{children:m})]},f))})]})}function hf({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),a=useCallback(i=>{typeof i=="string"&&e(i==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:i.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsx(xo,{mode:"highlight",value:o,onChange:a,theme:n,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var U1={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},Co={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},xf={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function Tf({onAction:e,disabled:t=false,tableContext:n}){let{t:o}=_(),[r,a]=useState(false),[i,s]=useState(null),c=useCallback(()=>a(false),[]),{containerRef:l,dropdownRef:d,dropdownStyle:p,handleMouseDown:f}=$e({isOpen:r,onClose:c,align:"right"}),m=n?.table?.attrs?.justification??"left",g=useCallback(b=>{e(b),a(false);},[e]),u=(b,v,C,P,S)=>{let y=t||S?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...U1,backgroundColor:i===b&&!y?"var(--doc-bg-hover)":"transparent",color:y?"var(--doc-text-muted)":S?.danger?"var(--doc-error)":"var(--doc-text)",cursor:y?"not-allowed":"pointer"},onClick:()=>!y&&g(P),onMouseEnter:()=>s(b),onMouseLeave:()=>s(null),disabled:y,children:[jsx(K,{name:v,size:16,className:S?.danger&&!y?"text-destructive":""}),jsx("span",{style:{flex:1},children:C})]},b)},h=jsx(we,{variant:"ghost",size:"icon-sm",className:j("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!t&&a(b=>!b),disabled:t,"aria-label":o("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(K,{name:"more_vert",size:20})});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(Je,{content:o("table.moreOptions"),children:h}),r&&!t&&jsxs("div",{ref:d,style:{...p,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:200,maxHeight:"70vh",overflowY:"auto"},role:"menu",onMouseDown:b=>b.stopPropagation(),children:[u("addRowAbove","add",o("table.insertRowAbove"),"addRowAbove"),u("addRowBelow","add",o("table.insertRowBelow"),"addRowBelow"),u("addColumnLeft","add",o("table.insertColumnLeft"),"addColumnLeft"),u("addColumnRight","add",o("table.insertColumnRight"),"addColumnRight"),jsx("div",{style:Co,role:"separator"}),u("mergeCells","call_merge",o("table.mergeCells"),"mergeCells",{itemDisabled:!n?.hasMultiCellSelection}),u("splitCell","call_split",o("table.splitCell"),"splitCell",{itemDisabled:!n?.canSplitCell}),jsx("div",{style:Co,role:"separator"}),u("selectTable","select_all",o("table.selectTable"),"selectTable"),jsx("div",{style:Co,role:"separator"}),u("deleteRow","delete",o("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(n?.rowCount??0)<=1}),u("deleteColumn","delete",o("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(n?.columnCount??0)<=1}),u("deleteTable","delete",o("table.deleteTable"),"deleteTable",{danger:true}),jsx("div",{style:Co,role:"separator"}),jsx("div",{style:xf,children:o("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(b=>{let v={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsx("button",{type:"button",title:o({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[b]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:P=>P.preventDefault(),onMouseEnter:P=>{P.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent";},onClick:()=>g({type:"cellVerticalAlign",align:b}),children:jsx(K,{name:v[b],size:16})},b)})}),jsx("div",{style:Co,role:"separator"}),jsx("div",{style:xf,children:o("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(b=>{let v={left:"format_align_left",center:"format_align_center",right:"format_align_right"},C=m===b;return jsx("button",{type:"button",title:o({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[b]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:C?"var(--doc-primary-light)":"transparent",borderColor:C?"var(--doc-primary)":"var(--doc-border)",color:C?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:P=>P.preventDefault(),onClick:()=>g({type:"tableProperties",props:{justification:b}}),children:jsx(K,{name:v[b],size:16})},b)})}),jsx("div",{style:Co,role:"separator"}),u("headerRow","table_rows",o("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),u("distribute","view_column",o("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),u("autoFit","fit_width",o("tableAdvanced.autoFit"),{type:"autoFitContents"}),u("noWrap","wrap_text",o("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsx("div",{style:Co,role:"separator"}),u("properties","settings",o("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var Y1=20;function xi({options:e,activeValue:t,triggerIcon:n,tooltipContent:o,onSelect:r,disabled:a=false,ariaLabel:i,testId:s,showLabels:c=false}){let[l,d]=useState(false),p=useCallback(()=>d(false),[]),{containerRef:f,dropdownRef:m,dropdownStyle:g,handleMouseDown:u}=$e({isOpen:l,onClose:p}),h=useCallback(v=>{a||r(v),d(false);},[a,r]),b=jsxs(we,{variant:"ghost",size:"icon-sm",className:j("text-muted-foreground hover:text-foreground hover:bg-muted/80",l&&"bg-muted",a&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!a&&d(v=>!v),disabled:a,"aria-label":i??o,"aria-expanded":l,"aria-haspopup":"true","data-testid":s,children:[jsx(K,{name:n,size:Y1}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:f,style:{position:"relative",display:"inline-block"},children:[l?b:jsx(Je,{content:o,children:b}),l&&!a&&jsx("div",{ref:m,style:{...g,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:v=>v.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",gap:c?1:2,minWidth:c?200:void 0},children:e.map(v=>{let C=t===v.value;return jsxs("button",{type:"button",title:v.label,"data-testid":s?`${s}-${v.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:C?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:C?"var(--doc-primary)":"var(--doc-text)",...c?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:P=>P.preventDefault(),onMouseEnter:P=>{C||(P.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:P=>{P.currentTarget.style.backgroundColor=C?"var(--doc-primary-light)":"transparent";},onClick:()=>h(v.value),children:[jsx(K,{name:v.iconName,size:18}),c&&jsx("span",{style:{flex:1},children:v.label})]},v.value)})})})]})}var X1=[{value:"inline",labelKey:"imageWrap.inline",iconName:"wrap_text"},{value:"wrapRight",labelKey:"imageWrap.floatLeft",iconName:"format_image_left"},{value:"wrapLeft",labelKey:"imageWrap.floatRight",iconName:"format_image_right"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function j1(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function Cf({imageContext:e,onChange:t,disabled:n=false}){let{t:o}=_(),r=X1.map(s=>({...s,label:o(s.labelKey)})),a=j1(e),i=r.find(s=>s.value===a)||r[0];return jsx(xi,{options:r,activeValue:a,triggerIcon:i.iconName,tooltipContent:`Wrap: ${i.label}`,onSelect:t,disabled:n,testId:"toolbar-image-wrap",showLabels:true})}var J1=[{value:"rotateCW",labelKey:"imageTransform.rotateClockwise",iconName:"rotate_right"},{value:"rotateCCW",labelKey:"imageTransform.rotateCounterClockwise",iconName:"rotate_left"},{value:"flipH",labelKey:"imageTransform.flipHorizontal",iconName:"swap_horiz"},{value:"flipV",labelKey:"imageTransform.flipVertical",iconName:"swap_vert"}];function Pf({onTransform:e,disabled:t=false}){let{t:n}=_(),o=J1.map(r=>({...r,label:n(r.labelKey)}));return jsx(xi,{options:o,triggerIcon:"rotate_right",tooltipContent:n("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var ct=18;function tt({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:a,ariaLabel:i}){let s=i?.toLowerCase().replace(/\s+/g,"-")||n?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),c=d=>{d.preventDefault();},l=jsx(we,{variant:"ghost",size:"icon-sm",className:j("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",a),"data-active":e?"true":void 0,onMouseDown:c,onClick:t?void 0:o,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":i||n,"data-testid":s?`toolbar-${s}`:void 0,children:r});return n?jsx(Je,{content:n,children:l}):l}function dt({label:e,children:t,className:n}){return jsx("div",{className:j("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",n),role:"group","aria-label":e,children:t})}function r2(e){let t=Ye__default.useContext(Tr);return t?{...t,...a2(e)}:e}function a2(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function sc(e){let{t}=_(),n=r2(e),{currentFormatting:o={},onFormat:r,onUndo:a,onRedo:i,canUndo:s=false,canRedo:c=false,disabled:l=false,className:d,style:p,enableShortcuts:f=true,editorRef:m,children:g,showFontPicker:u=true,fontFamilies:h,documentFonts:b,showFontSizePicker:v=true,showTextColorPicker:C=true,showHighlightColorPicker:P=true,showAlignmentButtons:S=true,showListButtons:y=true,showLineSpacingPicker:x=true,showStylePicker:M=true,documentStyles:E,theme:w,showZoomControl:N=true,zoom:F,onZoomChange:H,onRefocusEditor:k,imageContext:D,onImageWrapType:I,onImageTransform:R,onOpenImageProperties:z,tableContext:Z,onTableAction:$,inline:Q=false}=n,Me=useRef(null),se=useCallback(de=>{!l&&r&&r(de);},[l,r]),Te=useCallback(()=>{!l&&s&&a&&a();},[l,s,a]),Ce=useCallback(()=>{!l&&c&&i&&i();},[l,c,i]),G=useCallback(de=>{!l&&r&&r({type:"fontFamily",value:de});},[l,r]),B=Ye__default.useMemo(()=>Qs(h),[h]),Pe=useCallback(de=>{!l&&r&&r({type:"fontSize",value:de});},[l,r]),Ue=useCallback(de=>{!l&&r&&r({type:"textColor",value:de});},[l,r]),ce=useCallback(de=>{!l&&r&&r({type:"highlightColor",value:typeof de=="string"?de:""});},[l,r]),Ge=useCallback(de=>{!l&&r&&r({type:"alignment",value:de});},[l,r]),rn=useCallback(()=>{!l&&r&&r("bulletList");},[l,r]),Eo=useCallback(()=>{!l&&r&&r("numberedList");},[l,r]),Mr=useCallback(()=>{!l&&r&&r("indent");},[l,r]),Lf=useCallback(()=>{!l&&r&&r("outdent");},[l,r]),Hf=useCallback(de=>{!l&&r&&(r({type:"lineSpacing",value:de}),requestAnimationFrame(()=>k?.()));},[l,r,k]),Ff=useCallback(de=>{!l&&r&&r({type:"applyStyle",value:de});},[l,r]),an=useCallback(de=>{!l&&$&&($(de),requestAnimationFrame(()=>k?.()));},[l,$,k]);useEffect(()=>{if(!f)return;let de=ue=>{if(ue.defaultPrevented)return;let ln=ue.target,uc=m?.current,Zf=Me.current,Bf=uc?.contains(ln),qf=Zf?.contains(ln);if(!Bf&&!qf)return;if((ue.ctrlKey||ue.metaKey)&&!ue.altKey)switch(ue.key.toLowerCase()){case "b":ue.preventDefault(),se("bold");break;case "i":ue.preventDefault(),se("italic");break;case "u":ue.preventDefault(),se("underline");break;case "=":ue.shiftKey?(ue.preventDefault(),se("superscript")):(ue.preventDefault(),se("subscript"));break;case "l":ue.preventDefault(),Ge("left");break;case "e":ue.preventDefault(),Ge("center");break;case "r":ue.preventDefault(),Ge("right");break;case "j":ue.preventDefault(),Ge("both");break;case "k":ue.preventDefault(),se("insertLink");break}};return document.addEventListener("keydown",de),()=>{document.removeEventListener("keydown",de);}},[f,se,Ge,m]);let Af=useCallback(de=>{let ue=de.target;ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.tagName==="SELECT"||ue.tagName==="OPTION"||de.preventDefault();},[]),Of=useCallback(de=>{let ue=de.target,ln=document.activeElement;ue.tagName==="SELECT"||ue.tagName==="OPTION"||ln?.tagName==="SELECT"||requestAnimationFrame(()=>{k?.();});},[k]);return jsxs("div",{ref:Me,className:j(!Q&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:Q?{display:"contents",...p}:p,role:Q?void 0:"toolbar","aria-label":Q?void 0:t("toolbar.ariaLabel"),"data-testid":Q?void 0:"formatting-bar",onMouseDown:Q?void 0:Af,onMouseUp:Q?void 0:Of,children:[jsxs(dt,{label:t("formattingBar.groups.history"),children:[jsx(tt,{onClick:Te,disabled:l||!s,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(K,{name:"undo",size:ct})}),jsx(tt,{onClick:Ce,disabled:l||!c,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(K,{name:"redo",size:ct})})]}),N&&jsx(dt,{label:t("formattingBar.groups.zoom"),children:jsx(cf,{value:F,onChange:H,disabled:l,compact:true})}),M&&jsx(dt,{label:t("formattingBar.groups.styles"),children:jsx(lf,{value:o.styleId||"Normal",onChange:Ff,styles:E,theme:w,disabled:l,width:120})}),(u||v)&&jsxs(dt,{label:t("formattingBar.groups.font"),children:[u&&jsx(Om,{value:o.fontFamily||"Arial",onChange:G,fonts:B,documentFonts:b,disabled:l,width:60,placeholder:"Arial"}),v&&jsx(zm,{value:o.fontSize!==void 0?ns(o.fontSize):11,onChange:Pe,disabled:l,width:42,placeholder:"11"})]}),jsxs(dt,{label:t("formattingBar.groups.textFormatting"),children:[jsx(tt,{onClick:()=>se("bold"),active:o.bold,disabled:l,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(K,{name:"format_bold",size:ct})}),jsx(tt,{onClick:()=>se("italic"),active:o.italic,disabled:l,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(K,{name:"format_italic",size:ct})}),jsx(tt,{onClick:()=>se("underline"),active:o.underline,disabled:l,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(K,{name:"format_underlined",size:ct})}),jsx(tt,{onClick:()=>se("strikethrough"),active:o.strike,disabled:l,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(K,{name:"strikethrough_s",size:ct})}),C&&jsx(xo,{mode:"text",value:o.color?.replace(/^#/,""),onChange:Ue,theme:w,disabled:l,title:t("formattingBar.fontColor")}),P&&jsx(xo,{mode:"highlight",value:o.highlight,onChange:ce,theme:w,disabled:l,title:t("formattingBar.highlightColor")}),jsx(tt,{onClick:()=>se("insertLink"),disabled:l,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(K,{name:"link",size:ct})})]}),jsxs(dt,{label:t("formattingBar.groups.script"),children:[jsx(tt,{onClick:()=>se("superscript"),active:o.superscript,disabled:l,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(K,{name:"superscript",size:ct})}),jsx(tt,{onClick:()=>se("subscript"),active:o.subscript,disabled:l,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(K,{name:"subscript",size:ct})})]}),S&&jsx(dt,{label:t("formattingBar.groups.alignment"),children:jsx(Qm,{value:o.alignment||"left",onChange:Ge,disabled:l})}),(y||x)&&jsxs(dt,{label:t("formattingBar.groups.listFormatting"),children:[y&&jsx(ef,{listState:o.listState||mi(),onBulletList:rn,onNumberedList:Eo,onIndent:Mr,onOutdent:Lf,disabled:l,showIndentButtons:true,compact:true,hasIndent:(o.indentLeft??0)>0}),x&&jsx(of,{value:o.lineSpacing,onChange:Hf,disabled:l})]}),D&&I&&jsxs(dt,{label:t("formattingBar.groups.image"),children:[jsx(Cf,{imageContext:D,onChange:I,disabled:l}),R&&jsx(Pf,{onTransform:R,disabled:l}),z&&jsx(tt,{onClick:z,disabled:l,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(K,{name:"tune",size:ct})})]}),Z?.isInTable&&$&&jsxs(dt,{label:t("formattingBar.groups.table"),children:[jsx(pf,{onAction:an,disabled:l}),jsx(mf,{onAction:an,disabled:l,theme:w,value:wt(Z?.cellBorderColor,w)}),jsx(gf,{onAction:an,disabled:l}),jsx(hf,{onAction:an,disabled:l,theme:w,value:Z?.cellBackgroundColor}),jsx(Tf,{onAction:an,disabled:l,tableContext:Z})]}),jsx(tt,{onClick:()=>se("clearFormatting"),disabled:l,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(K,{name:"format_clear",size:ct})}),g]})}function i2({children:e,className:t,style:n,...o}){return jsx(Tr.Provider,{value:o,children:jsx("div",{className:j("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:Ve.toolbar,...n},"data-testid":"editor-toolbar",children:e})})}var We=i2;We.TitleBar=Ys;We.Logo=ai;We.DocumentName=Gs;We.MenuBar=li;We.TitleBarRight=ii;We.Toolbar=sc;var c2=new Map([["#ffff00","yellow"],["#00ff00","green"],["#00ffff","cyan"],["#ff00ff","magenta"],["#0000ff","blue"],["#ff0000","red"],["#000080","darkBlue"],["#008080","darkCyan"],["#008000","darkGreen"],["#800080","darkMagenta"],["#800000","darkRed"],["#808000","darkYellow"],["#808080","darkGray"],["#c0c0c0","lightGray"],["#ffffff","white"]]),d2=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function u2({source:e,scale:t,measurer:n,documentName:o,onStateChange:r,onError:a,onSave:i,renderTitleBarLeft:s,renderTitleBarRight:c,ref:l,colorMode:d,onZoomChange:p,documentFontFamily:f,className:m}){let g=useRef(null),[u,h]=useState(null),[b,v]=useState({}),[C,P]=useState(null),S=useCallback(E=>{h(E);let w=g.current?.formatting();w&&v({bold:w.bold,italic:w.italic,underline:w.underline,strike:w.strikethrough,superscript:w.superscript,subscript:w.subscript,...w.fontFamily?{fontFamily:w.fontFamily}:{},...w.fontSizeHalfPoints?{fontSize:w.fontSizeHalfPoints}:{},...w.alignment?{alignment:w.alignment}:{},...w.styleId?{styleId:w.styleId}:{},...w.color?{color:`#${w.color}`}:{},...w.highlight?{highlight:w.highlight}:{}}),P(g.current?.sectionProperties()??null),r?.(E);},[r]),y=useCallback(E=>{let w=g.current;if(w){if(typeof E=="string")switch(E){case "bold":return w.toggleRunProperty("b");case "italic":return w.toggleRunProperty("i");case "underline":return w.toggleRunProperty("u",{val:"single"});case "strikethrough":return w.toggleRunProperty("strike");case "superscript":return w.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return w.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":w.setRunProperty("b",{val:"0"}),w.setRunProperty("i",{val:"0"}),w.setRunProperty("u",{val:"none"}),w.setRunProperty("strike",{val:"0"}),w.setRunProperty("vertAlign",{val:"baseline"});return;default:return}switch(E.type){case "fontFamily":return w.setRunProperty("rFonts",{ascii:E.value,hAnsi:E.value});case "fontSize":return w.setRunProperty("sz",{val:String(Math.round(E.value*2))});case "textColor":{let N=E.value,F=typeof N=="string"?d2(N):wt(N,null)??null;return F?w.setRunProperty("color",{val:F}):void 0}case "highlightColor":{let N=E.value.trim().toLowerCase();if(N==="none"||N==="")return w.setRunProperty("highlight",{val:"none"});let F=c2.get(N.startsWith("#")?N:`#${N}`);return F?w.setRunProperty("highlight",{val:F}):void 0}case "alignment":return w.setParagraphProperty("jc",{val:String(E.value)});case "lineSpacing":return w.setParagraphProperty("spacing",{line:String(Math.round(E.value)),lineRule:"auto"});case "applyStyle":return w.setParagraphProperty("pStyle",{val:E.value});default:return}}},[]);useImperativeHandle(l,()=>g.current,[]);let x=t===void 0?1:t/(96/72),M=C?{pageWidthTwips:C.pageSize.widthTwips,pageHeightTwips:C.pageSize.heightTwips,orientation:C.landscape?"landscape":"portrait",marginsTwips:{top:C.margins.topTwips,right:C.margins.rightTwips,bottom:C.margins.bottomTwips,left:C.margins.leftTwips}}:null;return jsxs("div",{className:["docx-editor docx-paginated-shell",d==="dark"?"dark":"",m??""].filter(Boolean).join(" "),style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:"var(--doc-bg)",color:"var(--doc-text)"},"data-testid":"paginated-shell",children:[jsxs(We,{currentFormatting:b,onFormat:y,onUndo:()=>g.current?.undo(),onRedo:()=>g.current?.redo(),canUndo:u?.canUndo??false,canRedo:u?.canRedo??false,zoom:x,onZoomChange:p,onSave:()=>{let E=g.current?.save();E&&i?.(E);},children:[jsxs(We.TitleBar,{children:[s&&jsx(We.Logo,{children:s()}),jsx(We.DocumentName,{value:o??"Document",editable:false}),c&&jsx(We.TitleBarRight,{children:c()}),jsx(We.MenuBar,{})]}),jsx(We.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[M?jsx("div",{style:{display:"flex",justifyContent:"center",padding:"4px 0"},children:jsx(ao,{pageSetup:M,zoom:x})}):null,jsx(zs,{ref:g,source:e,...f?{documentFontFamily:f}:{},...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onStateChange:S,...a?{onError:a}:{}})]})]})}var Si=class{constructor(t){nt(this,"listeners",new Set);nt(this,"snapshot");nt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t);}));nt(this,"getSnapshot",()=>this.snapshot);this.snapshot=t;}setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var Ci=class extends Si{constructor(){super({notifications:[]});nt(this,"notifications",[]);nt(this,"idCounter",0);nt(this,"timers",new Set);}showError(n,o){return this.addNotification(n,"error",o)}showWarning(n,o){return this.addNotification(n,"warning",o)}showInfo(n,o){return this.addNotification(n,"info",o)}dismiss(n){this.notifications=this.notifications.map(r=>r.id===n?{...r,dismissed:true}:r),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(r=>r.id!==n),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let n of this.timers)clearTimeout(n);this.timers.clear(),this.emitSnapshot();}destroy(){for(let n of this.timers)clearTimeout(n);this.timers.clear(),this.notifications=[];}addNotification(n,o,r){let a=`error-${++this.idCounter}-${Date.now()}`,i={id:a,message:n,severity:o,details:r,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let s=setTimeout(()=>{this.timers.delete(s),this.dismiss(a);},5e3);this.timers.add(s);}return a}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var h2=createContext(null);function kf({children:e}){let t=useMemo(()=>new Ci,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((l,d)=>{t.showError(l,d);},[t]),r=useCallback((l,d)=>{t.showWarning(l,d);},[t]),a=useCallback((l,d)=>{t.showInfo(l,d);},[t]),i=useCallback(l=>{t.dismiss(l);},[t]),s=useCallback(()=>{t.clearAll();},[t]),c=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:a,dismissNotification:i,clearNotifications:s}),[n.notifications,o,r,a,i,s]);return jsxs(h2.Provider,{value:c,children:[e,jsx(v2,{notifications:n.notifications,onDismiss:i})]})}function v2({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:n.map(r=>jsx(y2,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function y2({notification:e,onDismiss:t}){let{t:n}=_(),[o,r]=useState(false),i=(u=>{switch(u){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),s={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"slideIn 0.3s ease-out"},c={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},d={flex:1,minWidth:0},p={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},f={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},m={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},g=u=>{switch(u){case "error":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:s,children:[jsx("style",{children:`
1
+ import*as Ye from'react';import Ye__default,{createContext,useState,useEffect,forwardRef,useCallback,useRef,useId,useMemo,useContext,Children,Fragment as Fragment$1,useLayoutEffect,isValidElement,cloneElement,useSyncExternalStore,useImperativeHandle,Component}from'react';import {CHROME_MENUS,tableChromeIconPaths,chromeProbeForSlot,commandForSlotValue,FIT_WIDTH_ZOOM_MODE,sameZoomMode,AUTO_ZOOM_MODE,TABLE_BORDER_TARGET_OPTIONS,TABLE_BORDER_STYLE_OPTIONS,TABLE_BORDER_WIDTH_OPTIONS,runToolbarCommand,toolbarCommandState,commandForSlot,createDocxEditor,resolveZoomMode,defaultTableLabel,CHROME_GROUPS,chromeSlotId,LOADING_SNAPSHOT,IMAGE_WRAP_TARGETS,validateDrawingPositionInput,positionInputFromPropertiesCommand,DRAWING_REL_FROM_H,DRAWING_REL_FROM_V,editorCommandKey,formattingBarChromeGroups,DEFAULT_TABLE_CHROME_DRAFT,runTableChromeCommand,createImageOverlayScrollPort,captureImageMutationPreconditions,isStaleImageInteractionCommit,selectedDrawingOverlayTargetOf,IMAGE_OVERLAY_NUDGE_SHIFT_PT,IMAGE_OVERLAY_NUDGE_PT,computeImageResizeResult,resizePreservesAspect,computeMovedImagePosition,overlayFrameToSheetCssPixels,dragIndent,handlePosition,executeImageCommand,tableChromeToolbarState,ZOOM_MAX,ZOOM_MIN,cssPixelsToLayoutPoints,finalizeImageOverlayInteraction,SNAP_TWIPS_CM,SNAP_TWIPS_INCH,DEFAULT_IMAGE_RESOURCE_LIMITS,sniffImageMime,validateRasterHeader,tableChromeLabelKeyForTarget,composeFontConfiguration,mountPaginatedSurface,applyThemeTint,applyThemeShade,resolveThemeColorHex}from'@docx-editor.dev/core/editor';export{CHROME_GROUPS,CHROME_MENUS,LOADING_SNAPSHOT,MAX_RESOLVER_FAMILIES,PX_PER_CM,PX_PER_INCH,WORD_DEFAULT_FONT,chromeMenuSlots,commandForSlot,composeFontConfiguration,createFontSource,generateRulerTicks,loadFonts,rulerPageBox,runToolbarCommand,toolbarCommandState}from'@docx-editor.dev/core/editor';import {en as en$1,localizeDisabledReason,createT,deepMerge}from'@docx-editor.dev/i18n';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {cva}from'class-variance-authority';import {clsx}from'clsx';import*as pe from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var f0=Object.defineProperty;var g0=(e,t,n)=>t in e?f0(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var rt=(e,t,n)=>g0(e,typeof t!="symbol"?t+"":t,n);var kc={version:"2.6.0"};var h0=kc.version;var _c="(prefers-color-scheme: dark)";function Dc(){return typeof window<"u"&&typeof window.matchMedia=="function"}function Nc(){return Dc()?window.matchMedia(_c).matches:false}function Lc(e,t){return e==="dark"||e==="system"&&t}function Hc(e){if(!Dc())return ()=>{};let t=window.matchMedia(_c);e(t.matches);let n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}var Hi=createContext(null);function A(){return useContext(Hi)}var at=createContext(null);var Fi=createContext(en$1),Ai=createContext("en");function Do({i18n:e,children:t}){let n=useContext(Fi),o=useContext(Ai),r=typeof e?._lang=="string"?e._lang:o,a=useMemo(()=>deepMerge(n,e),[n,e]);return jsx(Ai.Provider,{value:r,children:jsx(Fi.Provider,{value:a,children:t})})}function _(){let e=useContext(Fi),t=useContext(Ai);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e}}function Bc(e){let{t}=_();return useCallback((n,o)=>e?.get(n)??t(n,o),[e,t])}var E0=()=>{},Zi=0;function w0(){return Zi}function Bi(e){let t=false;return ()=>{if(t)return;t=true;let n=globalThis.navigator?.scheduling,o=()=>{t=false,e();};n?.isInputPending?.({includeContinuous:true})?setTimeout(o,0):queueMicrotask(o);}}function B(e,t=Object.is,n){let o=A(),r=n?.onSubscribe,a=n?.onUnsubscribe,i=useCallback(d=>{if(!o)return E0;let u=false;Zi++,r?.();let m=Bi(()=>{u||d();}),g=[o.on("change",m),o.on("selectionChange",m),o.on("error",m)];return ()=>{u=true,Zi--,a?.();for(let p of g)p();}},[o,r,a]),l=useMemo(()=>{let d=false,u,m;return g=>{if(d&&g===u)return m;let p=e(g);return d&&t(m,p)?(u=g,m):(d=true,u=g,m=p,p)}},[o,e,t]),c=useCallback(()=>l(o?o.snapshot():LOADING_SNAPSHOT),[o,l]),s=useCallback(()=>l(LOADING_SNAPSHOT),[l]);return useSyncExternalStore(i,c,s)}var Kc=12700,qc=96;function k0(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function _0(e,t,n,o){let r=e*72/n,a=t*72/o;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(a*100)/100)}}function qr(e){let t=DEFAULT_IMAGE_RESOURCE_LIMITS;if(e.byteLength===0)return {ok:false,reasonKey:"imageInsert.errors.emptyFile"};if(e.byteLength>t.maxEncodedBytes)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let n=sniffImageMime(e);if(!k0(n))return n==="image/svg+xml"||n==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let o=validateRasterHeader(e,n);if(!o)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(o.pixelWidth*o.pixelHeight>t.maxPixels||o.pixelWidth>t.maxDimension||o.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:a,heightPoints:i}=_0(o.pixelWidth,o.pixelHeight,qc,qc);return Object.freeze({ok:true,bytes:e,mime:n,widthPoints:a,heightPoints:i})}function _t(e){return Math.round(e/Kc*100)/100}function bn(e){return Math.round(e*Kc)}var Xt=createContext({t:void 0,onSave:void 0});function N0(){return useContext(Xt)}function Kr(e){let{t}=_();return n=>e?.(n)??t(n)}function Y(){let{t:e}=useContext(Xt);return Kr(e)}function Z0(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function qi(e){return typeof e=="string"}function ne(e){let t=A(),{t:n}=_(),o=qi(e)?e:editorCommandKey(e),r=useRef(e);r.current=e;let a=useCallback(c=>{let s=r.current;if(qi(s)){let u=toolbarCommandState(t,s);return {active:u.active,enabled:u.enabled,disabledReason:localizeDisabledReason(u.disabledReason,n)}}if(!t)return {active:false,enabled:false,disabledReason:null};let d=t.can(s);return {active:t.isActive(s),enabled:d.ok,disabledReason:d.ok?null:localizeDisabledReason(d.reason??null,n)}},[t,o,n]),i=B(a,Z0),l=useCallback(()=>{let c=r.current;return qi(c)?runToolbarCommand(t,c).ok:t?t.exec(c).ok:false},[t,o]);return useMemo(()=>({execute:l,isActive:i.active,isEnabled:i.enabled,disabledReason:i.disabledReason}),[l,i])}function z0(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function V0(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=z0(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 W({children:e,...t}){let n=Children.only(e);if(!isValidElement(n))return null;let o=n.props,r=V0(t,o),a=n.ref,i=t.ref;return (a||i)&&(r.ref=l=>{for(let c of [a,i])typeof c=="function"?c(l):c&&typeof c=="object"&&(c.current=l);}),cloneElement(n,r)}function X(e){for(let t of CHROME_GROUPS)for(let n of t.controls)if(chromeSlotId(t,n)===e)return n;return null}function te(e){return e?jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsx("path",{d:t,fill:"currentColor"},t))}):null}function O(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Qt(e){let{slot:t,icon:n,asChild:o,className:r,children:a,hidden:i}=e,{execute:l,isActive:c,isEnabled:s,disabledReason:d}=ne(t),u=Y();if(i)return null;let m=X(t),g=u(m?.labelKey??t),p=commandForSlot(t),f=p?.type==="toggleMark"||p?.type==="setAlignment",b={onClick:()=>l(),onMouseDown:O,disabled:!s,"data-slot":t,className:`docx-toolbar__button${r?` ${r}`:""}`,...c?{"data-active":""}:{},...s?{}:{"data-disabled":""},...f?{"aria-pressed":c}:{},"aria-label":g,title:d??g};return o?jsx(W,{...b,children:a}):jsx("button",{type:"button",...b,children:n??a??te(m?.paths)})}Qt.docxToolbarPart=true;var J0="image/png,image/jpeg,image/gif",zi=createContext(null);function Vr(){let e=useContext(zi);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Vi(){return useContext(zi)}function $r({children:e}){let t=A(),{t:n}=_(),o=useRef(null),r=useRef(false),a=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),i=B(a,(f,b)=>f.enabled===b.enabled&&f.disabledReason===b.disabledReason),l=i.enabled,c=localizeDisabledReason(i.disabledReason,n),s=useCallback(async f=>{if(!t||r.current)return;let b=qr(f);if(!b.ok){window.alert(n(b.reasonKey));return}let h={type:"insertImage",data:b.bytes,mime:b.mime,widthPoints:b.widthPoints,heightPoints:b.heightPoints},P=t.canExecuteImageCommand?.(h);if(P&&!P.ok){window.alert(P.reason??n("imageInsert.errors.refused"));return}r.current=true;try{let x=await executeImageCommand(t,h);x.ok?t.focus():window.alert(x.reason??n("imageInsert.errors.refused"));}finally{r.current=false;}},[t,n]),d=useCallback(async f=>{let b=f?.[0];if(!b)return;let h=await b.arrayBuffer();await s(new Uint8Array(h));},[s]),u=useCallback(async f=>{if(!f)return;let b=[...f.files].find(h=>h.type.startsWith("image/"));if(b){await d([b]);return}for(let h of f.items){if(h.kind!=="file"||!h.type.startsWith("image/"))continue;let P=h.getAsFile();if(!P)continue;let x=await P.arrayBuffer();await s(new Uint8Array(x));return}},[s,d]),m=useCallback(()=>{l&&o.current?.click();},[l]),g=useCallback(async f=>{let b=f.currentTarget;await d(b.files),b.value="";},[d]),p=useMemo(()=>({openFilePicker:m,insertFromFileList:d,insertFromDataTransfer:u,isEnabled:l,disabledReason:c,inputRef:o,onInputChange:g}),[m,d,u,l,c,g]);return jsxs(zi.Provider,{value:p,children:[jsx("input",{ref:o,type:"file",accept:J0,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:f=>f.stopPropagation()}),e]})}function Wr({className:e,hidden:t,asChild:n,children:o}){let{openFilePicker:r,isEnabled:a,disabledReason:i}=Vr(),l=Y();if(t)return null;let c=X("image.insert"),s=l(c?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":s,title:i??s,onMouseDown:O,onClick:r};return n?jsx(W,{...d,children:o}):jsx("button",{...d,children:o??te(c?.paths)})}Wr.docxSlot="image.insert";var hn=Object.assign(Wr,{docxSlot:"image.insert"});var ug=["nw","n","ne","e","se","s","sw","w"],Qc=40,Jc=12;function pg(e){return `imageOverlay.handle.${e}`}function mg(e){switch(e){case "nw":case "se":return "nwse-resize";case "ne":case "sw":return "nesw-resize";case "n":case "s":return "ns-resize";default:return "ew-resize"}}function fg(e){return {nw:{x:"0%",y:"0%"},n:{x:"50%",y:"0%"},ne:{x:"100%",y:"0%"},e:{x:"100%",y:"50%"},se:{x:"100%",y:"100%"},s:{x:"50%",y:"100%"},sw:{x:"0%",y:"100%"},w:{x:"0%",y:"50%"}}[e]}function gg(e,t){return e>0&&t>0?"se":e>0&&t<0?"ne":e<0&&t>0?"sw":e<0&&t<0?"nw":e>0?"e":e<0?"w":t>0?"s":"n"}function $i({containerRef:e,portalRef:t,scrollPort:n}){let o=A(),{t:r}=_(),[a,i]=useState(null),[l,c]=useState(null),s=useRef(null);s.current=l;let d=useRef(null),u=useRef(null),m=useRef(null),g=useRef(null),p=useRef(null);useEffect(()=>{let v=e.current;if(!v)return;let y=T=>{let w=(T.target instanceof Element?T.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");g.current=w??null,w&&w===a?.id&&queueMicrotask(()=>m.current?.focus({preventScroll:true}));};return v.addEventListener("pointerdown",y,{capture:true}),()=>v.removeEventListener("pointerdown",y,{capture:true})},[e,a?.id]),useEffect(()=>{if(!o){i(null);return}let v=()=>{i(selectedDrawingOverlayTargetOf(o.surface));},y=()=>{queueMicrotask(v);};v();let T=[o.on("change",y),o.on("selectionChange",v)];return ()=>{for(let M of T)M();}},[o]),useEffect(()=>{if(n){p.current=n;return}let v=e.current;if(!v||!o?.surface)return;let y=v.closest(".docx-editor__scroll-container");if(!y)return;let T=o.surface.overlayCoordinates();return p.current=createImageOverlayScrollPort(y,T.paintScale),()=>{p.current=null;}},[e,o,n]);let f=useCallback(()=>{c(null),d.current=null;let v=u.current;if(u.current=null,v)try{v.releasePointerCapture(v._lastPointerId??0);}catch{}},[]),b=useCallback((v,y,T,M,w,E,D)=>{if(!o?.surface)return;let F=captureImageMutationPreconditions(o);if(!F)return;let H=o.surface.publishedLayout();d.current=Object.freeze({x:M,y:w}),u.current=E,E._lastPointerId=D;try{E.setPointerCapture(D);}catch{}c({session:Object.freeze({drawingNodeId:T.id,startBounds:Object.freeze({x:T.x,y:T.y,width:T.width,height:T.height}),startWidthEmu:T.widthEmu,startHeightEmu:T.heightEmu,startPosition:T.position,anchorFrameOrigin:T.anchorFrameOrigin,transform:T.transform,mode:v,handle:y,preconditions:F,layoutRevision:H.revision,packageRevision:o.surface.session.packageRevision(),kind:T.kind}),bounds:T,accumulatedScrollPt:0}),m.current?.focus({preventScroll:true});},[o]),h=useCallback((v,y,T,M,w)=>{if(!o)return;if(isStaleImageInteractionCommit(o,v)){f();return}v.mode==="resize"?o.exec({type:"setImageProperties",widthEmu:y,heightEmu:T,...w?.mode==="simple"?{horizontalEmu:w.horizontalEmu,verticalEmu:w.verticalEmu}:{},...w?.mode==="frame"?{...w.horizontalEmu!==void 0?{horizontalEmu:w.horizontalEmu}:{},...w.verticalEmu!==void 0?{verticalEmu:w.verticalEmu}:{}}:{}}):v.mode==="move"&&w&&o.exec({type:"setImagePosition",...w}),f();},[f,o]),P=useCallback(v=>{if(!o)return;let y=s.current?.bounds??selectedDrawingOverlayTargetOf(o.surface);if(!y)return;if(s.current&&v.key==="Escape"){v.preventDefault(),v.stopPropagation(),f();return}if(s.current)return;let T=v.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(v.key==="Delete"||v.key==="Backspace"){v.preventDefault(),v.stopPropagation(),o.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(v.key))return;v.preventDefault(),v.stopPropagation();let M=v.key==="ArrowLeft"?-T:v.key==="ArrowRight"?T:0,w=v.key==="ArrowUp"?-T:v.key==="ArrowDown"?T:0;if(v.altKey){if(!y.canResize)return;let D=gg(M,w),F=computeImageResizeResult({handle:D,startWidthEmu:y.widthEmu,startHeightEmu:y.heightEmu,startBounds:{x:y.x,y:y.y,width:y.width,height:y.height},startPosition:y.position,anchorFrameOrigin:y.anchorFrameOrigin,deltaXPt:M,deltaYPt:w,transform:y.transform,preserveAspect:resizePreservesAspect(D,y.aspectLocked,v.shiftKey),kind:y.kind});o.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(y.kind!=="anchored"||!y.canMove||!y.position)return;let E=computeMovedImagePosition(y.position,M,w);o.exec({type:"setImagePosition",...E});},[f,o]);useEffect(()=>{if(!l||!o?.surface)return;let v=o.surface.overlayCoordinates(),y=M=>{let w=s.current,E=d.current;if(!w||!E)return;let D=cssPixelsToLayoutPoints(M.clientX-E.x,v.paintScale),F=cssPixelsToLayoutPoints(M.clientY-E.y,v.paintScale);if(w.session.mode==="move"){let k=0,L=p.current,R=e.current?.closest(".docx-editor__scroll-container");if(L&&R){let z=R.getBoundingClientRect();M.clientY>z.bottom-Qc?k=Jc:M.clientY<z.top+Qc&&(k=-Jc),k!==0&&(k=L.scrollBy(k));}let I=w.accumulatedScrollPt+k;c({...w,accumulatedScrollPt:I,bounds:Object.freeze({...w.bounds,x:w.session.startBounds.x+D,y:w.session.startBounds.y+F+I})});return}if(!w.session.handle)return;let H=computeImageResizeResult({handle:w.session.handle,startWidthEmu:w.session.startWidthEmu,startHeightEmu:w.session.startHeightEmu,startBounds:w.session.startBounds,startPosition:w.session.startPosition,anchorFrameOrigin:w.session.anchorFrameOrigin,deltaXPt:D,deltaYPt:F,transform:w.session.transform,preserveAspect:resizePreservesAspect(w.session.handle,w.bounds.aspectLocked,M.shiftKey),kind:w.session.kind});c({...w,bounds:Object.freeze({...w.bounds,x:H.previewBounds.x,y:H.previewBounds.y,width:H.previewBounds.width,height:H.previewBounds.height,widthEmu:H.widthEmu,heightEmu:H.heightEmu})});},T=M=>{let w=s.current;if(w)if(M.type==="pointerup"){let E=cssPixelsToLayoutPoints(M.clientX-(d.current?.x??M.clientX),v.paintScale),D=cssPixelsToLayoutPoints(M.clientY-(d.current?.y??M.clientY),v.paintScale),F=finalizeImageOverlayInteraction({session:w.session,deltaXPt:E,deltaYPt:D,accumulatedScrollPt:w.accumulatedScrollPt,aspectLocked:w.bounds.aspectLocked,shiftKey:M.shiftKey,anchorFrameOrigin:w.session.anchorFrameOrigin});h(w.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else f();};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",T),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",T);}},[f,h,e,o,l]),useEffect(()=>{!a||g.current!==a.id||(g.current=null,m.current?.focus({preventScroll:true}));},[a]);let x=l?.bounds??a,C=useMemo(()=>{if(!o?.surface||!x)return null;let v=o.surface.publishedLayout(),y=o.surface.overlayCoordinates(),T=overlayFrameToSheetCssPixels(v,{pageIndex:x.pageIndex,x:x.x,y:x.y,width:x.width,height:x.height},y),M=x.canResize,w=x.kind==="anchored"&&x.canMove;return jsxs("div",{ref:m,className:"docx-image-selection-overlay","data-drawing-node-id":x.id,tabIndex:0,onKeyDown:P,children:[jsx("div",{className:`docx-image-selection-overlay__frame${w?" docx-editor-one-surface__overlay-control":""}`,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${T.left}px`,top:`${T.top}px`,width:`${T.width}px`,height:`${T.height}px`,cursor:w?"move":"default"},onPointerDown:E=>{O(E),!(!w||!x.position)&&E.button===0&&(E.preventDefault(),E.stopPropagation(),b("move",null,x,E.clientX,E.clientY,E.currentTarget,E.pointerId));}}),M?ug.map(E=>{let D=fg(E);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(pg(E)),tabIndex:0,style:{left:`calc(${T.left}px + ${T.width}px * ${parseFloat(D.x)/100} - 5px)`,top:`calc(${T.top}px + ${T.height}px * ${parseFloat(D.y)/100} - 5px)`,cursor:mg(E)},onPointerDown:F=>{O(F),F.button===0&&(F.preventDefault(),F.stopPropagation(),b("resize",E,x,F.clientX,F.clientY,F.currentTarget,F.pointerId));}},E)}):null]})},[x,b,o,P,r]);return !C||!t.current?null:createPortal(C,t.current)}function Ui(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function jr({className:e}){let t=A(),n=Vi(),o=useRef(null),r=useRef(null);useLayoutEffect(()=>{let c=o.current;if(!(!t||!c))return t.attach(c),()=>{t.detach();}},[t]);let a=useCallback(c=>{if(!n?.isEnabled)return;let s=c.clipboardData;s&&Ui(s)&&(c.preventDefault(),n.insertFromDataTransfer(s));},[n]),i=useCallback(c=>{!n?.isEnabled||!Ui(c.dataTransfer)||c.preventDefault();},[n]),l=useCallback(c=>{n?.isEnabled&&Ui(c.dataTransfer)&&(c.preventDefault(),n.insertFromDataTransfer(c.dataTransfer));},[n]);return jsxs("div",{ref:r,className:"docx-content-mount",children:[jsx("div",{ref:o,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:a,onDragOver:i,onDrop:l}),t?jsx($i,{containerRef:o,portalRef:r}):null]})}var yg=e=>e.isLoading||e.isOpening===true;function Gi({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function xg({when:e=false,overlay:t=false,className:n,style:o,children:r}){let a=B(yg),{t:i}=_();if(!e&&!a)return null;let l=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${n?` ${n}`:""}`;return jsx("div",{className:l,style:o,role:"status","aria-live":"polite",children:r??jsxs(Fragment,{children:[jsx(Gi,{}),jsx("span",{className:"docx-editor-sr-only",children:i("loading.label")})]})})}var Xr=Object.assign(xg,{Spinner:Gi});function nd(){let e=new Set,t=new Map,n=new Map,o=0,r=null,a=false;function i(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let m=Object.create(null),g=[...t].sort((p,f)=>(n.get(p[0])??0)-(n.get(f[0])??0));for(let[,{author:p,style:f}]of g)m[p]=f;return {authors:m,others:e.size>0?"kind":"author"}}let l=null,c=false;function s(m){if(m===void 0)return "none";if(typeof m=="string")return m;let g=Object.entries(m.authors).map(([p,f])=>`${p}\0${JSON.stringify(f)}`).sort();return `${m.others??"kind"}${g.join("")}`}function d(){if(!r)return;let m=i(),g=s(m);if(g!==l){if(m===void 0){a&&(r.setRevisionStyles("author"),a=false,l=g);return}r.setRevisionStyles(m),a=true,l=g;}}function u(){!r||c||(c=true,queueMicrotask(()=>{c=false,d();}));}return {registerScheme(m){e.add(m),u();},register(m,g,p){n.has(m)||n.set(m,o++),t.set(m,{author:g,style:p}),u();},unregister(m){(e.delete(m)||t.delete(m))&&u();},connect(m){r=m;let g=i();a=m!==null&&g!==void 0,l=m===null?null:s(g),u();},current:i}}var yn=createContext(null);function id(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function ji(){let e=useContext(yn),t=id();return useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function Yi(e){let{author:t,color:n,background:o,spanClassName:r,avatarUrl:a}=e,i=useContext(yn),l=id();return useEffect(()=>{if(i)return i.register(l,t,{...n!==void 0?{color:n}:{},...o!==void 0?{background:o}:{},...r!==void 0?{spanClassName:r}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>i.unregister(l)},[i,l,t,n,o,r,a]),null}function xn(e){return e.paragraphId===""}var Jt=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),Ig=e=>e;function kg(){let e=n=>!!n&&(n.width>0||n.height>0);if(typeof document<"u"){let o=document.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(e(o))return {left:o.left,top:o.bottom}}let t=typeof window>"u"?null:window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0),o=n.getBoundingClientRect();if(e(o))return {left:o.left,top:o.bottom};let r=n.startContainer,i=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(i))return {left:i.left,top:i.bottom}}return null}var Tn=createContext(null);function Xi(){let e=useContext(Tn),t=Jr(e===null);return e??t}function Jr(e=true){let t=A(),[n,o]=useState(Jt),r=useRef(null),a=useRef(n);a.current=n;let i=B(Ig),l=t?t.can({type:"insertText",text:""}).ok:false,c=useCallback(()=>{let x=r.current;x&&(x.editor.releaseSelection(x.pin),r.current=null);},[]),s=useCallback((x,C)=>{c(),o({mode:x?"reading":"editing",link:x??null,anchor:C??null,text:x?.text??"",url:x?x.kind==="internal"?`#${x.anchor??""}`:x.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c]),d=useCallback(()=>{c(),o(Jt);},[c]);useEffect(()=>c,[c]);let u=useCallback(()=>{let x=kg();c();let C=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(C&&xn(C)){s(C,x);return}if(C){o({mode:"editing",link:C,anchor:x,text:C.text,url:C.kind==="internal"?`#${C.anchor??""}`:C.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let v=t?.query({type:"selectedText"})??"",y=t?.retainSelection()??null;t&&y&&(r.current={editor:t,pin:y}),o({mode:"editing",link:null,anchor:x,text:v,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,s,c]);useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:x=>s(x.link,{left:x.rect.left,top:x.rect.bottom}),onRequest:u})},[t,e,s,u]),useEffect(()=>{let x=a.current;if(x.mode!=="reading"||!x.link)return;let C=xn(x.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;C&&C.id===x.link.id||o(Jt);},[i,t]),useEffect(()=>{let x=a.current;if(x.mode!=="editing"||x.link)return;let C=t?.surface;!C||C.retainedSelection()||o(Jt);},[i,t]);let m=useCallback(async()=>{let x=a.current.link?.href;if(!x)return false;try{await navigator.clipboard.writeText(x);}catch{return false}return o(C=>({...C,copied:true})),true},[]),g=useCallback(()=>{o(x=>({...x,mode:"editing",copied:false,error:false}));},[]),p=useCallback(x=>{o(C=>({...C,text:x,copied:false,error:false}));},[]),f=useCallback(x=>{o(C=>({...C,url:x,copied:false,error:false}));},[]),b=useCallback(()=>{let x=a.current,C=t?.surface?.hyperlinks;if(!C)return false;let v=x.url.trim();if(v.length===0)return o(M=>({...M,error:true})),false;let y=v.startsWith("#");return C.applyHyperlink({...y?{anchor:v.slice(1)}:{url:v},...x.text.trim().length>0?{text:x.text}:{}})?(d(),true):(o(M=>({...M,error:true})),false)},[t,d]),h=useCallback(()=>{let x=t?.surface?.hyperlinks,C=a.current.link;if(!x)return false;let v=x.removeHyperlink(C?.id);return v&&d(),v},[t,d]),P=useCallback(()=>{let x=t?.surface?.navigation,C=a.current.link;if(!x||!C)return false;if(C.kind==="internal"){let y=C.anchor?x.goToBookmark(C.anchor):false;return y&&o(Jt),y}let v=x.openExternal(C.href);return v&&o(Jt),v},[t]);return useMemo(()=>({state:n.mode==="closed"?Jt:{...n,canEdit:l},open:s,openAtCaret:u,close:d,copy:m,beginEdit:g,setText:p,setUrl:f,commitEdit:b,unlink:h,openTarget:P}),[n,l,s,u,d,m,g,p,f,b,h,P])}var Be={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function Lg(e){return e==="sdtLocked"||e==="sdtContentLocked"}function Hg(e){return e==="contentLocked"||e==="sdtContentLocked"}function Ji(e,t){return !e.ok&&e.code===t}function ft(){let e=useContext(el),t=ea();return e??t}function ea(){let e=A(),[t,n]=useState(false),[o,r]=useState(false),[a,i]=useState(false),l=B(T=>T),c=e?.surface??null,s=c?.contentControls;useEffect(()=>{r(s?.showAll()??c?.state().contentControls.showAll??false),i(s?.formFill()??c?.state().contentControls.formFill??false);},[l,s,c]);let d=useMemo(()=>{if(!e)return null;let T=s?.atCaret()??null;if(T){let R=s?.disabledReason(T.id,"edit")??null,I=s?.disabledReason(T.id,"remove")??null;return {id:T.id,tag:T.tag??null,alias:T.alias??null,controlType:T.controlType,locked:Hg(T.effectiveLock)||R==="locked",removalLocked:Lg(T.effectiveLock)||I==="locked",placeholder:T.placeholder,bound:T.bound||R==="bound",effectiveLock:T.effectiveLock}}let M=e.query({type:"contentControlAt"});if(!M)return null;let w=s?.disabledReason(M.id,"edit")??null,E=s?.disabledReason(M.id,"remove")??null,D=e.can({type:"setContentControlValue",value:""}),F=e.can({type:"removeContentControl"}),H=M.locked===true||w==="locked"||Ji(D,"locked"),k=w==="bound"||Ji(D,"bound"),L=E==="locked"||Ji(F,"locked");return {id:M.id,tag:M.tag??null,alias:M.alias??null,controlType:M.controlType,locked:H,removalLocked:L,placeholder:false,bound:k,effectiveLock:null}},[e,l,s]),u=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),m=useCallback(T=>{s?.setShowAll(T),r(T);},[s]),g=useCallback(T=>{s?.setFormFill(T),i(T);},[s]),p=useCallback(()=>m(!o),[m,o]),f=useCallback(()=>g(!a),[g,a]),b=useCallback(()=>n(true),[]),h=useCallback(()=>n(false),[]),P=useCallback(()=>n(T=>!T),[]),x=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let M=s.disabledReason(d.id,"edit");return M==="locked"?"the content control is locked":M==="bound"?"the content control is bound to external data":M==="notFound"?"the content control was not found":M}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let T=e.can({type:"setContentControlValue",value:""});return T.ok?null:T.reason},[d,s,e]),C=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let M=s.disabledReason(d.id,"remove");return M==="locked"?"the content control is locked":M==="notFound"?"the content control was not found":M}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let T=e.can({type:"removeContentControl"});return T.ok?null:T.reason},[d,s,e]),v=useCallback(T=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(s&&d){let M=s.disabledReason(d.id,"edit");if(M)return {ok:false,code:M==="bound"?"bound":M==="locked"?"locked":"notFound",reason:M==="bound"?"the content control is bound to external data":M==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:T})},[e,s,d]),y=useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(s){let T=d?.id;if(!T)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let M=s.disabledReason(T,"remove");return M?{ok:false,code:M==="locked"?"locked":"notFound",reason:M==="locked"?"the content control is locked":"the content control was not found"}:s.remove(T)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,s,d]);return useMemo(()=>({control:d,controls:u,showAll:o,formFill:a,inspectorOpen:t,canSetValue:x===null&&d!==null,canRemove:C===null&&d!==null,setValueDisabledReason:x,removeDisabledReason:C,setShowAll:m,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:b,closeInspector:h,toggleInspector:P,remove:y,setValue:v}),[d,u,o,a,t,x,C,m,p,g,f,b,h,P,y,v])}var el=createContext(null);function sd(){let e=0,t=0,n=null,o=new Set,r=new Set,a=new Set,i=l=>{for(let c of [...l])c();};return {getShift:()=>e,setShift(l){let c=Math.max(0,Math.round(l));c!==e&&(e=c,i(o));},subscribeShift(l){return o.add(l),()=>o.delete(l)},getReservation:()=>t,setReservation(l){let c=Math.max(0,Math.round(l));c!==t&&(t=c,i(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>n,setViewport(l){l!==n&&(n=l,i(a));},subscribeViewport(l){return a.add(l),()=>a.delete(l)}}}var ol=createContext(null);function to(){return useContext(ol)}var cd=()=>0,nl=()=>()=>{};function oo(){let e=to(),t=useCallback(o=>e?e.subscribeShift(o):nl(),[e]),n=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,n,cd)}function dd(){let e=to(),t=useCallback(o=>e?e.subscribeReservation(o):nl(),[e]),n=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,n,cd)}function Ct(){let e=to(),t=useCallback(r=>e?e.subscribeViewport(r):nl(),[e]),n=useCallback(()=>e?e.getViewport():null,[e]),o=useCallback(()=>null,[]);return useSyncExternalStore(t,n,o)}function Kg(e,t){if(e===t)return true;let n=resolveZoomMode(e),o=resolveZoomMode(t);return n!==null&&o!==null&&sameZoomMode(n,o)}function zg(e){let t=useRef(e);t.current=e;let[n,o]=useState(null),{onReady:r,onChange:a,onFontError:i,...l}=e,c=useMemo(()=>({onReady:s=>{o(s),t.current.onReady?.(s);},onChange:s=>t.current.onChange?.(s),onFontError:s=>t.current.onFontError?.(s)}),[]);return {DocxEditorRoot:En,rootProps:l,rootListeners:c,editorRef:n}}function En(e){let{document:t,fonts:n,zoom:o,zoomMode:r,tableInteractionLabel:a,imageDecodePort:i,children:l}=e,{t:c}=_(),s=useCallback((v,y)=>c(v,y),[c]),d=useRef(e);d.current=e;let[u,m]=useState(null),g=useRef(null);g.current??(g.current=nd());let p=g.current;useEffect(()=>{let v=d.current,y=v.translate??s,T=p.current(),M=createDocxEditor({...v.document!==void 0?{document:v.document}:{},...v.fonts?{fonts:v.fonts}:{},...v.author!==void 0?{author:v.author}:{},...v.locale!==void 0?{locale:v.locale}:{},translate:y,...v.mode!==void 0?{mode:v.mode}:{},...T!==void 0?{revisionStyles:T}:{},...v.modules!==void 0?{modules:v.modules}:{},...v.zoom!==void 0?{zoom:v.zoom}:{},...v.zoomMode!==void 0?{zoomMode:v.zoomMode}:{},...v.tableInteractionLabel?{tableInteractionLabel:v.tableInteractionLabel}:{},...v.imageDecodePort?{imageDecodePort:v.imageDecodePort}:{},onFontError:E=>d.current.onFontError?.(E)}),w=M.on("change",E=>d.current.onChange?.(E));return m(M),()=>{w(),M.destroy(),m(E=>E===M?null:E);}},[t,n,s,i,p]),useEffect(()=>{if(!u)return;if(!u.snapshot().isOpening){d.current.onReady?.(u);return}let v=u.on("change",()=>{v(),d.current.onReady?.(u);});return v},[u]);let f=useRef({editor:null,zoom:void 0,mode:void 0});useEffect(()=>{if(!u)return;f.current.editor!==u&&(f.current={editor:u,zoom:void 0,mode:void 0});let y=false;o!==void 0&&o!==f.current.zoom&&(f.current.zoom=o,u.setZoom(o),y=true);let T=f.current.mode,M=r!==void 0&&(T===void 0||!Kg(T,r)),w=r===void 0?null:resolveZoomMode(r),E=y&&r!==void 0&&w!==null&&w.type==="fit";(M||E)&&(f.current.mode=r,u.setZoomMode(r));},[u,o,r]),useEffect(()=>{u&&u.setTableInteractionLabel(a??defaultTableLabel);},[u,a]);let[b,h]=useState(0),P=useRef([]),x=useMemo(()=>({mounted:b,register:()=>(h(v=>v+1),()=>h(v=>Math.max(0,v-1))),registerCommentDraft:v=>(P.current.push(v),()=>{let y=P.current.indexOf(v);y!==-1&&P.current.splice(y,1);}),requestCommentDraft:()=>{let v=P.current.at(-1);return v?(v(),true):false}}),[b]),C=useMemo(sd,[]);return useEffect(()=>(p.connect(u),()=>p.connect(null)),[p,u]),jsx(at.Provider,{value:x,children:jsx(Hi.Provider,{value:u,children:jsx(ol.Provider,{value:C,children:jsx(yn.Provider,{value:p,children:jsx(Vg,{children:jsx($g,{children:jsx($r,{children:l})})})})})})})}function Vg({children:e}){let t=Jr(true);return jsx(Tn.Provider,{value:t,children:e})}function $g({children:e}){let t=ea();return jsx(el.Provider,{value:t,children:e})}function xe(e){return e/1440*96}function ta(e){return e/96*1440}function qe(e){return `${Math.round(e*100)/100}px`}function ll(e){return e/2}var cl=316,sl=44,Yg=24,oa={inlineStart:0,inlineEnd:cl},ud={inlineStart:sl,inlineEnd:sl},Xg={inlineStart:0,inlineEnd:0};function fd({open:e,viewportWidth:t,pageWidthPx:n,inlineStartReservation:o=0,docked:r=false}){if(!e)return ud;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)return oa;let a=Number.isFinite(o)&&o>0?o:0;return t-a-n-2*Yg>=cl?oa:ud}var Qg=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:t?.type==="fit"?t.maxZoom!==void 0&&t.maxZoom<ZOOM_MAX?t.maxZoom:null:e.zoom}},Jg=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function gd(){let e=Ct(),[t,n]=useState(null);return useEffect(()=>{if(!e){n(null);return}let o=()=>n(e.clientWidth);if(o(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(o);return r.observe(e),()=>r.disconnect()},[e]),t}function Fo(){let e=useContext(at),{pageSetup:t,reviewPaneOpen:n,entitledZoom:o}=B(Qg,Jg),r=Ct(),a=dd(),i=useRef(null);t&&(i.current=t.pageWidthTwips);let l=t?.pageWidthTwips??i.current,c=(e?.mounted??0)>0,s=useCallback(m=>c?fd({open:n,viewportWidth:m??0,pageWidthPx:l===null||o===null?0:xe(l)*o,inlineStartReservation:a,docked:o===null}):Xg,[c,n,l,o,a]),[d,u]=useState(()=>s(r?r.clientWidth:null));return useEffect(()=>{let m=()=>u(s(r?r.clientWidth:null));if(m(),!r||typeof ResizeObserver>"u")return;let g=new ResizeObserver(m);return g.observe(r),()=>g.disconnect()},[r,s]),d}var na=[.25,.5,.75,1,1.25,1.5,2];function wn(e,t){return t==="in"?na.find(o=>o>e+.001)??null:[...na].reverse().find(o=>o<e-.001)??null}function bd(e,t){return e==="0"?1:e==="+"||e==="="?wn(t,"in")??t:e==="-"?wn(t,"out")??t:null}var no=createContext(false);function je(){return useContext(no)?"":"docx-editor "}var nb=e=>e.reviewPaneOpen??true,rb=e=>e.zoomMode?.type==="fit";function ra({className:e,style:t,children:n}){let o=je(),r=A(),a=B(nb),i=Fo(),l=B(rb),s=(useContext(at)?.mounted??0)>0,d=to(),u=oo(),m=useCallback(p=>d?.setViewport(p),[d]),g=useCallback(p=>{if(!r||!(p.metaKey||p.ctrlKey)||p.altKey)return;let f=p.target;if(f instanceof Element&&f.closest('input, textarea, select, [role="dialog"]'))return;let b=bd(p.key,r.getZoom());b!==null&&(p.preventDefault(),r.setZoom(b));},[r]);return jsx("div",{ref:m,"data-testid":"docx-editor-scroll",onKeyDownCapture:g,...s?{"data-review-pane":a?"open":"closed"}:{},...l?{"data-zoom-fit":""}:{},className:`${o}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${u}px`,...s?{"--docx-review-gutter":`${i.inlineEnd}px`,"--docx-review-gutter-start":`${i.inlineStart}px`}:{}},children:jsx(no.Provider,{value:true,children:n})})}var ib=LOADING_SNAPSHOT;function yd({ref:e,editorRef:t}){useImperativeHandle(e,()=>({load:n=>t.current?.load(n),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(n,o)=>t.current?.exec(n,o)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:n=>t.current?.snapshot(n)??ib}),[t]);}var pb=e=>e.editingMode??"editing",ul=[{mode:"editing",labelKey:"editingMode.editing",hintKey:"editingMode.editingHint",path:"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"},{mode:"suggesting",labelKey:"editingMode.suggesting",hintKey:"editingMode.suggestingHint",path:"M240-400h122l40-40H240v40Zm0-100h222l40-40H240v40Zm0-100h322l40-40H240v40ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v320h-80v-320H160v525l46-45h274v80H240L80-80Zm520-80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T943-380L723-160H600Zm300-263-37-37 37 37ZM660-220h38l121-122-19-18-18-19-122 121v38Zm140-141-18-19 37 37-19-18Z"},{mode:"viewing",labelKey:"editingMode.viewing",hintKey:"editingMode.viewingHint",path:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Z"}],mb="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function ia({className:e,hidden:t}){let n=A(),o=B(pb),r=Y(),{t:a}=_(),[i,l]=useState(false),c=useRef(null),s=useRef(null),d=useRef(null);useEffect(()=>{if(!i)return;let h=d.current?.querySelectorAll('[role="menuitemradio"]');(d.current?.querySelector('[aria-checked="true"]')??h?.[0]??void 0)?.focus();},[i]);let u=useCallback(h=>{let P=[...d.current?.querySelectorAll('[role="menuitemradio"]')??[]],x=P.indexOf(document.activeElement),C=v=>{h.preventDefault(),P[(v+P.length)%P.length]?.focus();};h.key==="ArrowDown"?C(x+1):h.key==="ArrowUp"?C(x-1):h.key==="Home"?C(0):h.key==="End"&&C(P.length-1);},[]);useEffect(()=>{if(!i)return;let h=x=>{let C=c.current;C&&x.target instanceof Node&&C.contains(x.target)||l(false);},P=x=>{x.key==="Escape"&&(x.preventDefault(),l(false));};return document.addEventListener("mousedown",h,true),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",h,true),document.removeEventListener("keydown",P);}},[i]);let m=useCallback(h=>{l(false),runToolbarCommand(n,"review.editingMode",h),n?.focus();},[n]),g=toolbarCommandState(n,"review.editingMode"),p=localizeDisabledReason(g.disabledReason,a),f=useMemo(()=>ul.find(h=>h.mode===o)??ul[0],[o]);if(t)return null;let b=X("review.editingMode");return jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxs("button",{ref:s,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":o,"aria-haspopup":"menu","aria-expanded":i,"aria-label":r(b?.labelKey??"editingMode.label"),disabled:!g.enabled,...p?{title:p}:{},onMouseDown:O,onClick:()=>l(h=>!h),children:[pl(f.path),jsx("span",{className:"docx-toolbar__picker-value",children:r(f.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),i?jsx("div",{ref:d,className:"docx-toolbar__mode-menu",role:"menu","aria-label":r(b?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:ul.map(h=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h.mode===o,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${h.mode}`,onMouseDown:O,onClick:()=>m(h.mode),children:[pl(h.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:r(h.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:r(h.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:h.mode===o?pl(mb):null})]},h.mode))}):null]})}ia.docxSlot="review.editingMode";function pl(e){return jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})})}function Ao(e,t){if(!isValidElement(e)||e.type!==Fragment$1)return null;let o=Children.toArray(e.props.children).map(t).filter(r=>r!==null);return o.length===1?o[0]:null}function sa({entries:e,children:t,preset:n,keyOfEntry:o,keyOfChild:r,renderEntry:a}){if(!n)return t;let i=new Map,l=[];for(let u of Children.toArray(t)){let m=r(u);m?i.set(m,u):l.push(u);}let c=e.map((u,m)=>{let g=o(u,m),p=i.get(g);return p?jsx(Fragment$1,{children:p},g):jsx(Fragment$1,{children:a(u,m)},g)}),s=new Set(e.map(o)),d=[...i.entries()].filter(([u])=>!s.has(u)).map(([u,m])=>jsx(Fragment$1,{children:m},u));return jsxs(Fragment,{children:[c,d,l]})}var hb=["zoom","script","format","list","alignment","styles","font","text","history"],fl=new Set(["review"]),gl=24,Pd=new Set;function Ed(e,t=hb){let n=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...n]}function Cd(e,t){let{widths:n,groups:o,order:r,fixed:a,more:i}=e,l=a;for(let s of o)l+=n.get(s)??0;if(l<=t)return Pd;l+=i;let c=new Set;for(let s of r){if(l<=t)break;let d=n.get(s);d===void 0||c.has(s)||(c.add(s),l-=d);}return c}function wd(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let n of e)if(!t.has(n))return false;return true}var Md=wd;function Rd(e){if(!(e.available>0))return Pd;let t=Cd(e,e.available),n=e.previous;if(!n||n.size===0||t.size>=n.size)return t;let o=Cd(e,e.available-(e.hysteresis));return wd(o,n)?n:o}function Id(e,t,n,o){return e+t+n+o*2}function kd(e,t){return e+t}function hl(e,t){return e+t}function _d(e){let t=Number.parseFloat(e.marginInlineStart||e.marginLeft),n=Number.parseFloat(e.marginInlineEnd||e.marginRight);return {start:Number.isFinite(t)?t:0,end:Number.isFinite(n)?n:0}}function bl(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Dd(e){return bl(e.columnGap)}function Nd(e,t){return e.clientWidth-bl(t.paddingLeft)-bl(t.paddingRight)}var Rn="data-toolbar-group",In="data-toolbar-fixed",yl="data-toolbar-more",Tb=34,vl=new Set;function Hd(e,t,n){let o=useRef(null),r=useRef(new Map),a=useRef(Tb),[i,l]=useState(vl),c=useRef(i);c.current=i;let s=useRef({groups:t,order:n});s.current={groups:t,order:n};let d=useCallback(()=>{let m=o.current;if(!m||!e)return;let g=getComputedStyle(m),p=Dd(g),f=Nd(m,g),b=m.querySelector(".docx-toolbar__separator"),h=p*2;if(b){let y=getComputedStyle(b),T=_d(y);h=Id(b.offsetWidth,T.start,T.end,p);}for(let y of m.querySelectorAll(`[${Rn}]`)){let T=y.getAttribute(Rn);T&&y.offsetWidth>0&&r.current.set(T,kd(y.offsetWidth,h));}let P=0;for(let y of m.querySelectorAll(`[${In}]`))y.offsetWidth>0&&(P+=hl(y.offsetWidth,p));let x=m.querySelector(`[${yl}]`);x&&x.offsetWidth>0&&(a.current=hl(x.offsetWidth,p));let C={available:f,widths:r.current,groups:s.current.groups,order:s.current.order,fixed:P,more:a.current,previous:c.current,hysteresis:gl},v=Rd(C);Md(v,c.current)||(c.current=v,l(v));},[e]),u=useCallback(m=>{o.current=m;},[]);return useLayoutEffect(()=>{if(!e){c.current.size>0&&(c.current=vl,l(vl));return}d();},[e,d]),useEffect(()=>{let m=o.current;if(!e||!m||typeof ResizeObserver>"u")return;let g=0,p=new ResizeObserver(()=>{g===0&&(g=requestAnimationFrame(()=>{g=0,d();}));});p.observe(m);for(let f of m.querySelectorAll(`[${Rn}], [${In}]`))p.observe(f);return ()=>{g!==0&&cancelAnimationFrame(g),p.disconnect();}},[e,d,i]),{attach:u,overflow:i}}var Ib=["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"],Ad=createContext({close:()=>{}});function kb(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function Od({label:e,children:t}){return jsxs("div",{className:"docx-toolbar__more-control",children:[jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function Zd({slot:e}){let t=Y(),{close:n}=useContext(Ad),{execute:o,isActive:r,isEnabled:a,disabledReason:i}=ne(e),l=X(e),c=commandForSlot(e),s=c?.type==="toggleMark"||c?.type==="setAlignment",d=t(l?.labelKey??e);return jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...i?{title:i}:{},...s?{"aria-pressed":r}:{},...r?{"data-active":""}:{},onMouseDown:O,onClick:u=>{o(),n(u.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:te(l?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:d})]})}function Bd({sections:e,className:t}){let n=Y(),[o,r]=useState(false),a=useRef(null),i=useRef(null),l=useRef(null),c=useRef(false),s=useId(),d=n("formattingBar.more"),u=useCallback(p=>{r(false),p&&i.current?.focus();},[]),m=useMemo(()=>({close:u}),[u]);useEffect(()=>{if(!o)return;let p=f=>{let b=f.target;b instanceof Node&&a.current?.contains(b)||r(false);};return document.addEventListener("mousedown",p,true),()=>document.removeEventListener("mousedown",p,true)},[o]),useEffect(()=>{if(!o||!c.current)return;c.current=false;let p=l.current;p&&kb(p);},[o]);let g=p=>{p.key!=="Escape"||p.defaultPrevented||(p.preventDefault(),u(true));};return jsxs("div",{ref:a,className:`docx-toolbar__more${t?` ${t}`:""}`,[yl]:"",children:[jsx("button",{ref:i,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":o,"aria-controls":o?s:void 0,"aria-label":d,title:d,...o?{"data-active":""}:{},onMouseDown:O,onClick:()=>r(p=>!p),onKeyDown:p=>{p.key==="ArrowDown"&&(p.preventDefault(),c.current=true,r(true));},children:te(Ib)}),o?jsx(Ad.Provider,{value:m,children:jsx("div",{ref:l,id:s,role:"dialog","aria-label":d,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",onKeyDown:g,children:e.map(p=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":n(p.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:n(p.labelKey)}),p.children]},p.id))})}):null]})}function Hb(e,t){return e.value===t.value&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function kn(e){let t=A(),n=useRef(e);n.current=e;let o=useCallback(l=>{let c=n.current,s=toolbarCommandState(t,c);return {value:s.value??null,enabled:s.enabled,disabledReason:s.disabledReason}},[t,e]),r=B(o,Hb),a=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.wrap",l),value:r.value??null,options:IMAGE_WRAP_TARGETS,isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]),i=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.altText",l),value:r.value,options:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]);return e==="image.wrap"?a:i}var Tl=[{value:"inline",labelKey:"imageWrap.menu.inLineWithText",iconName:"wrap_text"},{value:"square",labelKey:"imageWrap.square",iconName:"crop_square"},{value:"squareLeft",labelKey:"imageWrap.menu.squareLeft",iconName:"format_image_left"},{value:"squareRight",labelKey:"imageWrap.menu.squareRight",iconName:"format_image_right"},{value:"tight",labelKey:"imageWrap.tight",iconName:"wrap_text"},{value:"through",labelKey:"imageWrap.through",iconName:"wrap_text"},{value:"topAndBottom",labelKey:"imageWrap.topAndBottom",iconName:"vertical_align_center"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function pa({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),a=Y(),{execute:i,value:l,isEnabled:c,disabledReason:s}=kn("image.wrap"),[d,u]=useState(false),m=useRef(null),g=useRef(null),p=useRef(null),f=useId(),b=useMemo(()=>Tl.find(y=>y.value===l)??Tl[0],[l]),h=X("image.wrap"),P=a(h?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let y=M=>{let w=m.current;w&&M.target instanceof Node&&w.contains(M.target)||u(false);},T=M=>{M.key==="Escape"&&(M.preventDefault(),u(false),g.current?.focus());};return document.addEventListener("mousedown",y,true),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",y,true),document.removeEventListener("keydown",T);}},[d]);let x=useCallback(y=>{u(false),i(y);},[i]);if(t)return null;let C=r("imageWrap.tooltipPrefix",{label:r(b.labelKey)}),v={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!c,...c?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":P,title:s??C,onMouseDown:O,onClick:()=>u(y=>!y)};return jsxs("div",{ref:m,className:"docx-toolbar__image-wrap",children:[n?jsx(W,{...v,children:o}):jsx("button",{...v,children:o??te(h?.paths)}),d?jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:y=>y.stopPropagation(),children:Tl.map(y=>jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===y.value,...l===y.value?{"data-active":""}:{},onMouseDown:O,onClick:()=>x(y.value),children:r(y.labelKey)},y.value))}):null]})}pa.docxSlot="image.wrap";var _n=Object.assign(pa,{docxSlot:"image.wrap"});function ma({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),a=Y(),{execute:i,value:l,isEnabled:c,disabledReason:s}=kn("image.altText"),[d,u]=useState(false),[m,g]=useState(""),p=useRef(null),f=useRef(null),b=useId();useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let v=T=>{let M=p.current;M&&T.target instanceof Node&&M.contains(T.target)||u(false);},y=T=>{T.key==="Escape"&&(T.preventDefault(),u(false),f.current?.focus());};return document.addEventListener("mousedown",v,true),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v,true),document.removeEventListener("keydown",y);}},[d]);let h=useCallback(()=>{i(m),u(false);},[m,i]);if(t)return null;let P=X("image.altText"),x=a(P?.labelKey??"formattingBar.altText"),C={type:"button",ref:f,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!c,...c?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?b:void 0,"aria-label":x,title:s??x,onMouseDown:O,onClick:()=>u(v=>!v)};return jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[n?jsx(W,{...C,children:o}):jsx("button",{...C,children:o??x}),d?jsxs("div",{id:b,role:"dialog","aria-label":r("imageAltText.panelTitle"),className:"docx-toolbar__alt-text-panel",onMouseDown:v=>v.stopPropagation(),children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${b}-description`,children:r("imageAltText.description")}),jsx("textarea",{id:`${b}-description`,className:"docx-dialog__textarea",value:m,onChange:v=>g(v.target.value),placeholder:r("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>u(false),children:r("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:h,children:r("common.apply")})]})]}):null]})}ma.docxSlot="image.altText";var Dn=Object.assign(ma,{docxSlot:"image.altText"});var Gd=e=>e.image;function Ud(e){return Array.from(e.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null||t===document.activeElement)}function Yb(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function wl(e){let t=e.position;return !t||e.kind!=="anchored"?{positionMode:"frame",horizontalPoints:"",verticalPoints:"",relativeToH:"page",relativeToV:"line"}:t.mode==="simple"?{positionMode:"simple",horizontalPoints:t.horizontalEmu!==void 0?String(_t(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(_t(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(_t(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(_t(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function Xb(e,t){let n=wl(t);return e.horizontalPoints!==n.horizontalPoints||e.verticalPoints!==n.verticalPoints||e.relativeToH!==n.relativeToH||e.relativeToV!==n.relativeToV}function fa(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let n=bn(t);return Number.isInteger(n)?n:null}function Qb(e,t){let n=wl(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let s=e.horizontalPoints!==n.horizontalPoints,d=e.verticalPoints!==n.verticalPoints,u=s?fa(e.horizontalPoints):t.position?.horizontalEmu,m=d?fa(e.verticalPoints):t.position?.verticalEmu;return s&&u===null?{ok:false}:d&&m===null?{ok:false}:u===void 0||m===void 0?{ok:false}:{ok:true,value:{horizontalEmu:u,verticalEmu:m}}}let o=e.horizontalPoints!==n.horizontalPoints,r=e.verticalPoints!==n.verticalPoints,a=e.relativeToH!==n.relativeToH,i=e.relativeToV!==n.relativeToV,l=o?fa(e.horizontalPoints):t.position?.horizontalEmu,c=r?fa(e.verticalPoints):t.position?.verticalEmu;return o&&l===null?{ok:false}:r&&c===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof c=="number"?{verticalEmu:c}:{},...a||o||r?{relativeToH:e.relativeToH}:{},...i||o||r?{relativeToV:e.relativeToV}:{}}}}function ga(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function ba(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Ml({open:e,onClose:t,className:n,triggerRef:o}){let r=A(),{t:a}=_(),i=B(Gd),l=useId(),c=useId(),s=useId(),d=useRef(null),u=useRef(null),m=useRef(null),g=useRef(null),[p,f]=useState(null),[b,h]=useState(null),P=u.current,x=P?.canCrop===false,C=P?.canResize===false,v=P?.locks.changeAspect===true,y=P?.kind==="anchored"&&P.canMove===true,T=P?.kind==="inline",M=P?.kind==="anchored"&&P.canMove===false;useEffect(()=>{if(!e){u.current=null,m.current=null,g.current=null;return}if(!i)return;if(u.current=i,r?.surface){let{anchor:z}=r.surface.state().selection;m.current={paragraphId:z.paragraphId,offset:z.offset},g.current=r.surface.session.packageRevision();}h(null);let R=wl(i),I=i.crop;f({widthPoints:String(_t(i.widthEmu)),heightPoints:String(_t(i.heightEmu)),cropLeft:String(I.left),cropTop:String(I.top),cropRight:String(I.right),cropBottom:String(I.bottom),title:i.title,description:i.description,hyperlink:i.hyperlink??"",wrap:i.wrap,lockAspect:i.locks.changeAspect,...R});},[e,i?.id,i?.widthEmu,i?.heightEmu,r]);let w=useCallback(()=>{o?.current?.focus(),r?.focus();},[r,o]),E=useCallback(()=>{t(),w();},[t,w]);useEffect(()=>{if(!e)return;let R=d.current;if(!R)return;let I=Ud(R);(I.find(V=>V.id==="image-prop-width"&&!V.hasAttribute("disabled"))??I.find(V=>!V.hasAttribute("disabled"))??R).focus();let Z=V=>{if(V.key==="Escape"){V.preventDefault(),E();return}if(V.key!=="Tab")return;let j=Ud(R);if(j.length===0)return;let Re=document.activeElement,se=j.findIndex(Pe=>Pe===Re);if(se===-1)return;V.preventDefault();let Se=V.shiftKey?(se-1+j.length)%j.length:(se+1)%j.length;j[Se]?.focus();};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[e,E]);let D=useMemo(()=>{let R=P??i;return !R||R.widthEmu<=0?1:R.widthEmu/R.heightEmu},[i,P]),F=useCallback(R=>{f(I=>{if(!I)return I;if(!I.lockAspect)return {...I,widthPoints:R};let z=ba(R);if(z===null)return {...I,widthPoints:R};let Z=Math.round(z/D*100)/100;return {...I,widthPoints:R,heightPoints:String(Z)}});},[D]),H=useCallback(R=>{f(I=>{if(!I)return I;if(!I.lockAspect)return {...I,heightPoints:R};let z=ba(R);if(z===null)return {...I,heightPoints:R};let Z=Math.round(z*D*100)/100;return {...I,widthPoints:String(Z),heightPoints:R}});},[D]),k=useCallback(()=>{let R=u.current;if(!R?.intrinsic)return;let I=R.intrinsic.pixelWidth*72/R.intrinsic.dpiX,z=R.intrinsic.pixelHeight*72/R.intrinsic.dpiY;f(Z=>Z&&{...Z,widthPoints:String(Math.round(I*100)/100),heightPoints:String(Math.round(z*100)/100)});},[i]),L=useCallback(()=>{let R=u.current,I=m.current,z=g.current;if(!r||!R||!p||!I||z===null)return;let Z={type:"setImageProperties",drawingNodeId:R.id,expectedPackageRevision:z,selectionParagraphId:I.paragraphId,selectionOffset:I.offset};if(!C){let Pe=ba(p.widthPoints),G=ba(p.heightPoints);if(Pe===null||G===null){h("imageProperties.errors.invalidDimensions");return}let q=bn(Pe),Ee=bn(G);q!==R.widthEmu&&(Z.widthEmu=q),Ee!==R.heightEmu&&(Z.heightEmu=Ee);}if(R.canCrop&&!x){let Pe=ga(p.cropLeft),G=ga(p.cropTop),q=ga(p.cropRight),Ee=ga(p.cropBottom);if(Pe===null||G===null||q===null||Ee===null){h("imageProperties.errors.invalidCrop");return}let Ue=R.crop;(Pe!==Ue.left||G!==Ue.top||q!==Ue.right||Ee!==Ue.bottom)&&(Z.crop={left:Pe,top:G,right:q,bottom:Ee});}p.title!==R.title&&(Z.title=p.title),p.description!==R.description&&(Z.description=p.description);let V=p.hyperlink.trim();if(V!==(R.hyperlink??"")&&(Z.hyperlink=V===""?null:V),R.canChangeWrap&&p.wrap!==R.wrap&&(Z.wrap=p.wrap),R.kind==="anchored"&&R.canMove&&Xb(p,R)){let Pe=Qb(p,R);if(!Pe.ok){h("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(Pe.value,R))){h("imageProperties.errors.invalidPosition");return}Object.assign(Z,Pe.value);}if(!(Z.widthEmu!==void 0||Z.heightEmu!==void 0||Z.title!==void 0||Z.description!==void 0||Z.hyperlink!==void 0||Z.crop!==void 0||Z.wrap!==void 0||Z.horizontalEmu!==void 0||Z.verticalEmu!==void 0||Z.relativeToH!==void 0||Z.relativeToV!==void 0)){E();return}if(!r.can(Z).ok){h("imageProperties.errors.refused");return}if(!r.exec(Z).ok){h("imageProperties.errors.refused");return}E();},[r,p,x,C,E]);return !e||!p?null:jsx("div",{className:`docx-dialog-overlay${n?` ${n}`:""}`,onClick:E,onMouseDown:R=>{R.stopPropagation(),Yb(R);},children:jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:R=>R.stopPropagation(),onMouseDown:R=>R.stopPropagation(),children:[jsx("div",{id:l,className:"docx-dialog__header",children:a("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[b?jsx("p",{className:"docx-dialog__error",children:a(b)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:a("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:C,onChange:R=>F(R.target.value)}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:a("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:C,onChange:R=>H(R.target.value)}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:v,onChange:R=>f(I=>I&&{...I,lockAspect:R.target.checked})}),a("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:x||!P?.intrinsic,onClick:k,children:a("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.position")}),T?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.positionUnavailable")}):null,M?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.positionLocked")}):null,y?jsxs(Fragment,{children:[p.positionMode==="frame"?jsxs(Fragment,{children:[jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:a("imageProperties.relativeToHorizontal")}),jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange:R=>f(I=>I&&{...I,relativeToH:R.target.value}),children:DRAWING_REL_FROM_H.map(R=>jsx("option",{value:R,children:a(`dialogs.imagePosition.relativeOptions.${R}`)},R))})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:a("imageProperties.relativeToVertical")}),jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:p.relativeToV??"line",onChange:R=>f(I=>I&&{...I,relativeToV:R.target.value}),children:DRAWING_REL_FROM_V.map(R=>jsx("option",{value:R,children:a(`dialogs.imagePosition.relativeOptions.${R}`)},R))})]})]}):null,jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:a("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:R=>f(I=>I&&{...I,horizontalPoints:R.target.value})}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:a("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:R=>f(I=>I&&{...I,verticalPoints:R.target.value})}),jsx("span",{className:"docx-dialog__unit",children:a("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:a("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:R=>f(I=>I&&{...I,title:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:a("imageAltText.description")}),jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:p.description,onChange:R=>f(I=>I&&{...I,description:R.target.value}),placeholder:a("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:a("hyperlinkPopup.urlLabel")}),jsx("input",{id:s,className:"docx-dialog__input docx-dialog__input--full",value:p.hyperlink,onChange:R=>f(I=>I&&{...I,hyperlink:R.target.value}),placeholder:a("hyperlinkPopup.urlPlaceholder")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:a("formattingBar.imageWrap")}),jsx("select",{id:c,className:"docx-dialog__select docx-dialog__input--full",value:p.wrap,disabled:P?.canChangeWrap===false,onChange:R=>f(I=>I&&{...I,wrap:R.target.value}),children:IMAGE_WRAP_TARGETS.map(R=>jsx("option",{value:R,children:a(`imageWrap.targets.${R}`)},R))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:a("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:a("imageProperties.cropLeft")}),jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:x,value:p.cropLeft,onChange:R=>f(I=>I&&{...I,cropLeft:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:a("imageProperties.cropTop")}),jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:x,value:p.cropTop,onChange:R=>f(I=>I&&{...I,cropTop:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:a("imageProperties.cropRight")}),jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:x,value:p.cropRight,onChange:R=>f(I=>I&&{...I,cropRight:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:a("imageProperties.cropBottom")}),jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:x,value:p.cropBottom,onChange:R=>f(I=>I&&{...I,cropBottom:R.target.value})})]}),x?jsx("p",{className:"docx-dialog__hint",children:a("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:E,children:a("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:L,children:a("common.apply")})]})]})})}function ha({className:e,hidden:t,asChild:n,children:o}){let r=A(),{t:a}=_(),i=B(Gd),[l,c]=useState(false),s=useRef(null),d={type:"setImageProperties",description:"probe"},u=r&&i?r.can(d):null,m=u?.ok===true,g=u&&!u.ok?u.reason:null;if(t)return null;let p=X("image.properties"),f={type:"button",ref:s,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!m,...m?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:g??a("formattingBar.imagePropertiesShortcut"),onMouseDown:O,onClick:()=>c(true)};return jsxs(Fragment,{children:[n?jsx(W,{...f,children:o}):jsx("button",{...f,children:o??te(p?.paths)}),jsx(Ml,{open:l,onClose:()=>c(false),triggerRef:s})]})}ha.docxSlot="image.properties";var Bo=Object.assign(ha,{docxSlot:"image.properties"});function we(e){return Object.assign(n=>jsx(Qt,{slot:e,...n}),{docxSlot:e})}var jd=we("history.undo"),Yd=we("history.redo"),Xd=we("text.bold"),Qd=we("text.italic"),Jd=we("text.underline"),eu=we("text.strike"),tu=we("format.clear"),ou=we("script.super"),nu=we("script.sub"),ru=we("alignment.left"),au=we("alignment.center"),iu=we("alignment.right"),lu=we("alignment.justify"),su=we("list.bullet"),cu=we("list.numbered"),du=we("list.outdent"),uu=we("list.indent");var pu=we("table.insert"),mu=we("review.comments");function oh({className:e,hidden:t,icon:n,asChild:o,children:r}){let a=A(),{openAtCaret:i}=Xi(),l=chromeProbeForSlot("text.link"),c=a&&l?a.can(l):null,s=c?.ok===true,{t:d}=_(),u=localizeDisabledReason(c&&!c.ok?c.reason:null,d),m=Y();if(t)return null;let g=X("text.link"),p=m(g?.labelKey??"text.link"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!s,...s?{}:{"data-disabled":""},"aria-label":p,title:u??p,onMouseDown:O,onClick:()=>i()};return o?jsx(W,{...f,children:r}):jsx("button",{...f,children:n??r??te(g?.paths)})}var Rl=Object.assign(oh,{docxSlot:"text.link"});function nh({className:e,hidden:t}){let n=A(),{onSave:o}=useContext(Xt),r=Y();if(t)return null;let a=X("file.save"),i=r(a?.labelKey??"file.save"),l=!n||!o;return jsx("button",{type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"file.save",disabled:l,...l?{"data-disabled":""}:{},"aria-label":i,title:i,onMouseDown:O,onClick:()=>o?.(),children:te(a?.paths)})}var Il=Object.assign(nh,{docxSlot:"file.save"});function qo({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}function Ko(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}var ih=e=>({zoom:e.zoom,mode:e.zoomMode}),lh=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,gu={type:"fixed"};function kl(){let e=A(),{zoom:t,mode:n}=B(ih,lh),o=useCallback(a=>{e?.setZoom(a);},[e]),r=useCallback(a=>{e?.setZoomMode(a);},[e]);return useMemo(()=>{let a=n??gu,i=wn(t,"out"),l=wn(t,"in");return {zoom:t,mode:a,isFit:a.type==="fit",setZoom:o,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(gu),o(1);},zoomIn:()=>l!==null&&o(l),zoomOut:()=>i!==null&&o(i),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&i!==null,levels:na}},[e,t,n,o,r])}var Fn=2,An=3276,Hn=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],dh=e=>e.formatting?.fontSizePt??null;function vu(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function yu(e,t,n){for(let o=t.length-1;o>=0;o-=1)if(t[o]<e)return t[o];return Math.max(e-1,n)}function Tu(e){return jsxs("span",{className:`docx-toolbar__stepper${e.className?` ${e.className}`:""}`,...e.slot!==void 0?{"data-slot":e.slot}:{},role:"group","aria-label":e.groupLabel,title:e.title??e.groupLabel,children:[jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:O,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:O,onClick:e.onIncrease,children:"+"})]})}function uh(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let n=Number(t);if(!Number.isFinite(n))return null;let o=Math.round(n*2);return o<Fn||o>An?null:o}function ph({className:e,hidden:t}){let n=A(),o=B(dh),{isEnabled:r,disabledReason:a}=ne("font.size"),i=Y(),[l,c]=useState(false),[s,d]=useState(null),u=useRef(null),m=useRef(null),g=useCallback(v=>{if(!n)return;let y=commandForSlotValue("font.size",v);y&&n.can(y).ok&&n.exec(y);},[n]),p=useCallback(v=>{g(Math.min(An,Math.max(Fn,Math.round(v*2))));},[g]),f=useCallback(v=>{c(false),d(null),m.current?.blur(),v&&mh(u.current);},[]);if(useEffect(()=>{if(!l)return;let v=y=>{let T=u.current;T&&y.target instanceof Node&&T.contains(y.target)||(c(false),d(null));};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]),t)return null;let b=r&&o!==null,h=o===null?"\u2014":String(Math.round(o*2)/2),P=s??h,x=o===null?null:Math.round(o*2)/2,C=()=>{if(s===null)return;let v=uh(s);v!==null&&g(v);};return jsxs("span",{ref:u,className:"docx-toolbar__font-size","data-slot":"font.size",title:a??void 0,children:[jsx(Tu,{className:e,groupLabel:i("fontSize.label"),decreaseLabel:i("fontSize.decrease"),increaseLabel:i("fontSize.increase"),middle:jsx("input",{ref:m,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:P,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":i("fontSize.label"),autoComplete:"off",onChange:v=>{d(v.target.value),c(true);},onFocus:v=>{v.target.select(),c(true);},onClick:()=>c(true),onKeyDown:v=>{v.key==="Enter"?(v.preventDefault(),C(),f(true)):v.key==="Escape"?(v.preventDefault(),f(true)):(v.key==="ArrowDown"||v.key==="ArrowUp")&&(v.preventDefault(),c(true),o!==null&&p(v.key==="ArrowDown"?yu(o,Hn,Fn/2):vu(o,Hn,An/2)));},onBlur:()=>{C(),d(null);}}),canDecrease:b&&Math.round(o*2)>Fn,canIncrease:b&&Math.round(o*2)<An,onDecrease:()=>p(yu(o??0,Hn,Fn/2)),onIncrease:()=>p(vu(o??0,Hn,An/2))}),l&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":i("fontSize.listLabel"),children:Hn.map(v=>{let y=x===v;return jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>{p(v),f(true);},children:v},v)})}):null]})}function mh(e){(Ko(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}var Nl=Object.assign(ph,{docxSlot:"font.size"});function fh({className:e,hidden:t}){let n=A(),{zoom:o,isFit:r,mode:a,setZoom:i,setMode:l,zoomIn:c,zoomOut:s,canZoomIn:d,canZoomOut:u,levels:m}=kl(),g=Y(),[p,f]=useState(false),b=useRef(null);useEffect(()=>{if(!p)return;let y=T=>{let M=b.current;M&&T.target instanceof Node&&M.contains(T.target)||f(false);};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[p]);let h=useCallback(y=>{f(false),i(y);},[i]),P=useCallback(y=>{f(false),l(y==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let x=`${Math.round(o*100)}%`,C=sameZoomMode(a,AUTO_ZOOM_MODE),v=sameZoomMode(a,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:b,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(Tu,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle:jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!n,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":g("zoom.zoomLevel"),onMouseDown:O,onClick:()=>f(y=>!y),children:[x,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:u,canIncrease:d,onDecrease:s,onIncrease:c}),p?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox","aria-label":g("zoom.zoomLevel"),children:[jsx("button",{type:"button",role:"option","aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>P("auto"),children:g("zoom.automatic")}),jsx("button",{type:"button",role:"option","aria-selected":v,...v?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>P("fit-width"),children:g("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),m.map(y=>{let T=!r&&Math.abs(y-o)<.001;return jsx("button",{type:"button",role:"option","aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>h(y),children:`${Math.round(y*100)}%`},y)})]}):null]})}var Ll=Object.assign(fh,{docxSlot:"zoom.level"});var yh=[1,1.15,1.5,2,2.5,3],Cu=10,xh=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),Th=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function Sh({className:e,hidden:t}){let n=A(),o=B(xh,Th),{isEnabled:r,disabledReason:a}=ne("list.lineSpacing"),i=Y(),[l,c]=useState(false),s=useRef(null);useEffect(()=>{if(!l)return;let b=h=>{let P=s.current;P&&h.target instanceof Node&&P.contains(h.target)||c(false);};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);let d=useCallback(b=>{if(c(false),!n)return;let h=commandForSlotValue("list.lineSpacing",b);h&&n.can(h).ok&&n.exec(h);},[n]),u=useCallback((b,h)=>{if(c(false),!n)return;let P={type:"setParagraphSpacing",[b]:h};n.can(P).ok&&n.exec(P);},[n]);if(t)return null;let m=X("list.lineSpacing"),g=(o.spaceBeforePt??0)>0,p=(o.spaceAfterPt??0)>0,f=o.lineSpacing?.rule==="multiple"?o.lineSpacing?.value??null:null;return jsxs("span",{ref:s,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxs("button",{type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":l,"aria-label":i("lineSpacing.label"),title:a??i("lineSpacing.label"),onMouseDown:O,onClick:()=>c(b=>!b),children:[te(m?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l&&r?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[yh.map(b=>{let h=f===b;return jsx("button",{type:"button",role:"menuitemradio","aria-checked":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>d(b),children:Number.isInteger(b*10)?b.toFixed(1):b.toFixed(2)},b)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>u("beforePt",g?null:Cu),children:i(g?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:O,onClick:()=>u("afterPt",p?null:Cu),children:i(p?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Fl=Object.assign(Sh,{docxSlot:"list.lineSpacing"});var Rh=[{value:"C00000",labelKey:"colorPicker.colors.darkRed",css:"#c00000"},{value:"FF0000",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"FFC000",labelKey:"colorPicker.colors.orange",css:"#ffc000"},{value:"FFFF00",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"92D050",labelKey:"colorPicker.colors.lightGreen",css:"#92d050"},{value:"00B050",labelKey:"colorPicker.colors.green",css:"#00b050"},{value:"00B0F0",labelKey:"colorPicker.colors.lightBlue",css:"#00b0f0"},{value:"0070C0",labelKey:"colorPicker.colors.blue",css:"#0070c0"},{value:"002060",labelKey:"colorPicker.colors.darkBlue",css:"#002060"},{value:"7030A0",labelKey:"colorPicker.colors.purple",css:"#7030a0"}],Pu=[{value:"yellow",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"green",labelKey:"colorPicker.colors.brightGreen",css:"#00ff00"},{value:"cyan",labelKey:"colorPicker.colors.cyan",css:"#00ffff"},{value:"magenta",labelKey:"colorPicker.colors.magenta",css:"#ff00ff"},{value:"blue",labelKey:"colorPicker.colors.blue",css:"#0000ff"},{value:"red",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"darkBlue",labelKey:"colorPicker.colors.darkBlue",css:"#000080"},{value:"darkCyan",labelKey:"colorPicker.colors.darkCyan",css:"#008080"},{value:"darkGreen",labelKey:"colorPicker.colors.darkGreen",css:"#008000"},{value:"darkMagenta",labelKey:"colorPicker.colors.darkMagenta",css:"#800080"},{value:"darkRed",labelKey:"colorPicker.colors.darkRed",css:"#800000"},{value:"darkYellow",labelKey:"colorPicker.colors.darkYellow",css:"#808000"},{value:"darkGray",labelKey:"colorPicker.colors.darkGray",css:"#808080"},{value:"lightGray",labelKey:"colorPicker.colors.lightGray",css:"#c0c0c0"},{value:"black",labelKey:"colorPicker.colors.black",css:"#000000"},{value:"white",labelKey:"colorPicker.colors.white",css:"#ffffff"}],Eu=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],va=["colorPicker.theme.background1","colorPicker.theme.text1","colorPicker.theme.background2","colorPicker.theme.text2","colorPicker.theme.accent1","colorPicker.theme.accent2","colorPicker.theme.accent3","colorPicker.theme.accent4","colorPicker.theme.accent5","colorPicker.theme.accent6"],Lt=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Qe=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function Ih(e){let t=[0,2,4].map(o=>parseInt(e.slice(o,o+2),16)),n=(Math.max(...t)+Math.min(...t))/2/255;return n===1?[Qe(5),Qe(15),Qe(25),Qe(35),Qe(50)]:n===0?[Lt(50),Lt(35),Lt(25),Lt(15),Lt(5)]:n>=.8?[Qe(10),Qe(25),Qe(50),Qe(75),Qe(90)]:[Lt(80),Lt(60),Lt(40),Qe(25),Qe(50)]}var kh=/^[0-9A-Fa-f]{6}$/;function _h(e,t){let n="";for(let o=0;o<6;o+=2){let r=Math.round(t(parseInt(e.slice(o,o+2),16)));n+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return n.toUpperCase()}function Dh(e){let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return .299*t+.587*n+.114*o>230}function ya({value:e,css:t,title:n,selected:o,apply:r}){return jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":n,title:n,"data-value":e,...o?{"data-selected":""}:{},...Dh(t.replace("#",""))?{"data-light":""}:{},onMouseDown:O,onClick:()=>r(e)})}function Nh({apply:e,label:t,current:n,themeHexes:o}){let r=o.map(Ih),a=[0,1,2,3,4];return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[o.map((i,l)=>jsx(ya,{value:i,css:`#${i.toLowerCase()}`,title:t(va[l]),selected:n===i,apply:e},`base-${l}`)),a.map(i=>o.map((l,c)=>{let s=r[c][i],d=_h(l,s.apply);return jsx(ya,{value:d,css:`#${d.toLowerCase()}`,title:`${t(va[c])}, ${t(s.labelKey)}`,selected:n===d,apply:e},`${i}-${c}`)}))]})]})}function Lh(e){let{apply:t,label:n,current:o}=e,[r,a]=useState(""),i=kh.test(r);return jsxs(Fragment,{children:[jsx(Nh,{...e}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:n("colorPicker.standardColors")}),jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:Rh.map(l=>jsx(ya,{value:l.value,css:l.css,title:n(l.labelKey),selected:o===l.value,apply:t},l.value))})]}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:n("colorPicker.customColor")}),jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":n("colorPicker.customColor"),onChange:l=>a(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&i&&t(r.toUpperCase());}}),jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!i,onMouseDown:O,onClick:()=>t(r.toUpperCase()),children:n("colorPicker.apply")})]})]})]})}function Ol({apply:e,current:t}){let n=A(),o=Y(),r=n?.getDocumentThemeColors()??[],a=r.length===va.length?r.map(l=>l.hex):Eu,i=t?.toUpperCase()??null;return jsx(Lh,{apply:e,label:o,current:i,themeHexes:a})}var Hh=Pu.filter(e=>e.value!=="white");function Fh({apply:e,label:t,current:n}){return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:Hh.map(o=>jsx(ya,{value:o.value,css:o.css,title:t(o.labelKey),selected:n===o.value,apply:e},o.value))})]})}function wu(e){let{slot:t,defaultValue:n,cssOf:o,clear:r,body:a}=e,i=t==="text.color";return Object.assign(({className:c,hidden:s,icon:d})=>{let u=A(),{isEnabled:m,disabledReason:g}=ne(t),p=Y(),[f,b]=useState(false),[h,P]=useState(n),x=useRef(null),C=B(E=>{if(i){let D=E.formatting?.color;return D&&D.kind==="hex"?D.value.toUpperCase():null}return E.formatting?.highlight??null}),v=u?.getDocumentThemeColors()??[],y=v.length===va.length?v.map(E=>E.hex):Eu;useEffect(()=>{if(!f)return;let E=D=>{let F=x.current;F&&D.target instanceof Node&&F.contains(D.target)||b(false);};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[f]);let T=useCallback(E=>{if(b(false),!u)return;let D=commandForSlotValue(t,E);D&&u.can(D).ok&&(u.exec(D),E!==r.value&&P(E));},[u]),M=useMemo(()=>X(t),[]);if(s)return null;let w=p(M?.labelKey??t);return jsxs("div",{ref:x,className:`docx-toolbar__colorsplit${c?` ${c}`:""}`,"data-slot":t,children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!m,...m?{}:{"data-disabled":""},"aria-label":w,title:g??w,onMouseDown:O,onClick:()=>T(h),children:[d??te(M?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:o(h)},"aria-hidden":"true"})]}),jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!m,...m?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":f,"aria-label":w,title:g??w,onMouseDown:O,onClick:()=>b(E=>!E),children:"\u25BE"}),f?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":w,onMouseDown:O,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:O,onClick:()=>T(r.value),children:[jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(r.labelKey)]}),a({apply:T,label:p,current:C,themeHexes:y})]}):null]})},{docxSlot:t})}var Ah=new Map(Pu.map(e=>[e.value,e.css])),Zl=wu({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(Ol,{apply:e.apply,current:e.current})}),Bl=wu({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>Ah.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(Fh,{...e})});var Kh=["alignment.left","alignment.center","alignment.right","alignment.justify"];function zh({className:e,hidden:t}){let n=ne("alignment.left"),o=ne("alignment.center"),r=ne("alignment.right"),a=ne("alignment.justify"),i=Y(),[l,c]=useState(false),s=useRef(null);if(useEffect(()=>{if(!l)return;let f=b=>{let h=s.current;h&&b.target instanceof Node&&h.contains(b.target)||c(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]),t)return null;let d=[n,o,r,a],u=Kh.map((f,b)=>({slot:f,control:X(f),state:d[b]})),m=u.find(f=>f.state.isActive)??u[0],g=u.some(f=>f.state.isEnabled),p=i(m.control?.labelKey??m.slot);return jsxs("div",{ref:s,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!g,...g?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":l,"aria-label":p,title:g?p:m.state.disabledReason??p,onMouseDown:O,onClick:()=>c(f=>!f),children:[te(m.control?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:u.map(f=>{let b=i(f.control?.labelKey??f.slot);return jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":f.slot,disabled:!f.state.isEnabled,...f.state.isActive?{"data-active":""}:{},"aria-pressed":f.state.isActive,"aria-label":b,title:f.state.disabledReason??b,onMouseDown:O,onClick:()=>{f.state.execute(),c(false);},children:te(f.control?.paths)},f.slot)})}):null]})}var xa=Object.assign(zh,{docxSlot:"alignment"});function Kl(e){let{label:t,icon:n,active:o,disabled:r,disabledReason:a,onSelect:i,asChild:l,className:c,children:s}=e,d={type:"button",className:`docx-toolbar__button${c?` ${c}`:""}`,disabled:r,...o?{"data-active":""}:{},...r?{"data-disabled":""}:{},...o!==void 0?{"aria-pressed":o}:{},"aria-label":t,title:r?a??t:t,onMouseDown:u=>O(u),onClick:r?void 0:i};return l?jsx(W,{...d,children:s}):jsx("button",{...d,children:n??s})}var Xh=Object.freeze([]),Qh=e=>e.formatting?.fontFamily??null,Jh=e=>e;function Ta(){let e=A(),t=B(Qh),n=B(Jh),o=useMemo(()=>e&&!n.isLoading?e.getAvailableFonts():Xh,[e,n]),{isEnabled:r}=ne("font.family"),a=useCallback(i=>{if(!e)return;let l=commandForSlotValue("font.family",i);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:a,options:o,isEnabled:r}),[t,a,o,r])}var Iu=createContext(null);function Vl(){return useContext(Iu)}function $l({asChild:e,className:t,children:n}){let o=Vl(),r=Y();if(!o)return null;let a=r(X("font.family")?.labelKey??"font.family"),i={onClick:()=>o.setOpen(!o.open),onMouseDown:O,disabled:!o.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":a,title:a},l=n??jsx("span",{children:o.value??"\u2014"});return e?jsx(W,{...i,children:l}):jsx("button",{type:"button",...i,children:l})}$l.docxToolbarPart=true;var ev=new Map([["arial","sansSerif"],["calibri","sansSerif"],["helvetica","sansSerif"],["verdana","sansSerif"],["open sans","sansSerif"],["roboto","sansSerif"],["times new roman","serif"],["georgia","serif"],["cambria","serif"],["garamond","serif"],["courier new","monospace"],["consolas","monospace"]]),tv=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function ku({asChild:e,className:t,children:n}){let o=Vl(),r=Y();if(!o||!o.open)return null;let a={role:"listbox",className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`,style:{position:"absolute",top:"100%",left:0,zIndex:30,minWidth:"100%",maxHeight:300,overflowY:"auto"}},i;return n!==void 0?i=n:i=tv.map(c=>({...c,fonts:o.options.filter(s=>(ev.get(s.toLowerCase())??"other")===c.category)})).filter(c=>c.fonts.length>0).map((c,s)=>jsxs("div",{role:"group",children:[s>0?jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}):null,c.labelKey?jsx("div",{className:"docx-toolbar__menu-label",children:r(c.labelKey)}):null,c.fonts.map(d=>jsx(_u,{value:d},d))]},c.category)),e?jsx(W,{...a,children:i}):jsx("div",{...a,children:i})}function _u({value:e,asChild:t,className:n,children:o}){let r=Vl();if(!r)return null;let a=r.value===e,i={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:O,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__font-family-item${n?` ${n}`:""}`},l=o??jsx("span",{style:{fontFamily:e},children:e});return t?jsx(W,{...i,children:l}):jsxs("button",{type:"button",...i,children:[l,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function ov({hidden:e,asChild:t,className:n,children:o}){let r=Ta(),[a,i]=useState(false),l=useRef(null);useEffect(()=>{if(!a)return;let u=m=>{let g=l.current;g&&m.target instanceof Node&&g.contains(m.target)||i(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[a]);let c=useMemo(()=>({...r,open:a,setOpen:i}),[r,a]);if(e)return null;let s={className:`docx-toolbar__font-family${n?` ${n}`:""}`,"data-slot":"font.family",style:{position:"relative",display:"inline-block"}},d=o??jsxs(Fragment,{children:[jsx($l,{}),jsx(ku,{})]});return jsx(Iu.Provider,{value:c,children:t?jsx(W,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var Wl=Object.assign(ov,{docxSlot:"font.family",Trigger:$l,Content:ku,Item:_u});function uv(e){let t=e.fontSizePt;return {...e.fontFamily?{fontFamily:e.fontFamily}:{},...t?{fontSize:`${Math.min(Math.max(t,9),20)}px`}:{},...e.bold?{fontWeight:700}:{},...e.italic?{fontStyle:"italic"}:{},...e.color?{color:`#${e.color}`}:{}}}var pv=Object.freeze([]),mv=e=>e.formatting?.styleId??null,fv=e=>e;function Sa(){let e=A(),t=B(mv),n=B(fv),o=useMemo(()=>e&&!n.isLoading?e.getDocumentStyles().filter(i=>i.type==="paragraph").map(i=>({styleId:i.styleId,name:i.name,preview:i.preview})):pv,[e,n]),{isEnabled:r}=ne("styles.style"),a=useCallback(i=>{if(!e)return;let l=commandForSlotValue("styles.style",i);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:a,options:o,isEnabled:r}),[t,a,o,r])}var Du=createContext(null);function jl(){return useContext(Du)}function Yl({asChild:e,className:t,children:n}){let o=jl(),r=Y();if(!o)return null;let a=X("styles.style"),i=r(a?.labelKey??"styles.style"),l={onClick:()=>o.setOpen(!o.open),onMouseDown:O,disabled:!o.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":i,title:i},c=o.options.find(d=>d.styleId===o.value),s=n??(o.value===null?jsx("span",{children:a?.valueKey?r(a.valueKey):"\u2014"}):jsx("span",{children:c?.name??o.value}));return e?jsx(W,{...l,children:s}):jsx("button",{type:"button",...l,children:s})}Yl.docxToolbarPart=true;function Nu({asChild:e,className:t,children:n}){let o=jl();if(!o||!o.open)return null;let r={role:"listbox",className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`,style:{position:"absolute",top:"100%",left:0,zIndex:30,minWidth:"100%",maxHeight:300,overflowY:"auto"}},a=n??o.options.map(i=>jsx(Lu,{value:i.styleId},i.styleId));return e?jsx(W,{...r,children:a}):jsx("div",{...r,children:a})}function Lu({value:e,asChild:t,className:n,children:o}){let r=jl();if(!r)return null;let a=r.value===e,i=r.options.find(s=>s.styleId===e),l={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:O,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${n?` ${n}`:""}`},c=o??jsx("span",{style:i?uv(i.preview):void 0,children:i?.name??e});return t?jsx(W,{...l,children:c}):jsxs("button",{type:"button",...l,children:[c,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function gv({hidden:e,asChild:t,className:n,children:o}){let r=Sa(),[a,i]=useState(false),l=useRef(null);useEffect(()=>{if(!a)return;let u=m=>{let g=l.current;g&&m.target instanceof Node&&g.contains(m.target)||i(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[a]);let c=useMemo(()=>({...r,open:a,setOpen:i}),[r,a]);if(e)return null;let s={className:`docx-toolbar__style${n?` ${n}`:""}`,"data-slot":"styles.style",style:{position:"relative",display:"inline-block"}},d=o??jsxs(Fragment,{children:[jsx(Yl,{}),jsx(Nu,{})]});return jsx(Du.Provider,{value:c,children:t?jsx(W,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var Xl=Object.assign(gv,{docxSlot:"styles.style",Trigger:Yl,Content:Nu,Item:Lu});function Fu(e,t){let n=e;return Object.assign(({className:r,hidden:a,icon:i,asChild:l,children:c})=>{let{isEnabled:s,disabledReason:d}=ne(n),u=ft(),m=t==="showAll"?u.showAll:u.formFill,g=Y();if(a)return null;let p=X(n),f=g(p?.labelKey??e),b={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!s,...s?{}:{"data-disabled":""},...m?{"data-active":""}:{},"aria-pressed":m,"aria-label":f,title:d??f,onMouseDown:O,onClick:()=>{t==="showAll"?u.toggleShowAll():u.toggleFormFill();}};return l?jsx(W,{...b,children:c}):jsx("button",{...b,children:i??c??te(p?.paths)})},{docxSlot:n})}function hv({className:e,hidden:t,icon:n,asChild:o,children:r}){let a=Be.inspector,{isEnabled:i,disabledReason:l}=ne(a),{inspectorOpen:c,openInspector:s}=ft(),d=Y();if(t)return null;let u=X(a),m=d(u?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Be.inspector,disabled:!i,...i?{}:{"data-disabled":""},...c?{"data-active":""}:{},"aria-pressed":c,"aria-label":m,title:l??m,onMouseDown:O,onClick:()=>s()};return o?jsx(W,{...g,children:r}):jsx("button",{...g,children:n??r??te(u?.paths)})}function vv({className:e,hidden:t,icon:n,asChild:o,children:r}){let{canRemove:a,removeDisabledReason:i,remove:l}=ft(),c=Y();if(t)return null;let s=Be.remove,d=X(s),u=c(d?.labelKey??"contentControl.remove"),m={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Be.remove,disabled:!a,...a?{}:{"data-disabled":""},"aria-label":u,title:i??u,onMouseDown:O,onClick:()=>{l();}};return o?jsx(W,{...m,children:r}):jsx("button",{...m,children:n??r??te(d?.paths)})}var Ca=Fu(Be.showAll,"showAll"),Pa=Fu(Be.formFill,"formFill"),Ea=Object.assign(vv,{docxSlot:Be.remove}),wa=Object.assign(hv,{docxSlot:Be.inspector}),Au={[Be.showAll]:Ca,[Be.formFill]:Pa,[Be.inspector]:wa,[Be.remove]:Ea};function Ql(e,t){let n=A(),o=useRef(t);o.current=t,useEffect(()=>{if(!n)return;let r=((...a)=>{o.current(...a);});return n.on(e,r)},[n,e]);}var Ev=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],es=createContext(null);function Vu(){let e=useContext(es);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function Mv(e,t){let n=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",a=n?`${r}|${n.rows}|${n.columns}|${n.rowIndex}|${n.columnIndex}`:"",i=t.selection,l=i?`${i.from&&"paraId"in i.from?i.from.paraId:""}|${i.to&&"paraId"in i.to?i.to.paraId:""}|${t.selectionCollapsed}`:"",c=e?.getTableCellSelection()??null,s=c?`${c.tableId}|${c.rows.from}-${c.rows.to}|${c.columns.from}-${c.columns.to}|${c.cellIds.join(",")}`:"";return {tableKey:a,selectionKey:l,cellSelectionKey:s,editable:t.editable,editingMode:t.editingMode??"editing"}}function Rv(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function Iv(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Ku={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function kv(e,t){let n={};for(let o of Ev){let r=tableChromeToolbarState(e,o,t);n[o]={enabled:r.enabled,disabledReason:r.disabledReason};}return n}function ts({children:e}){let t=A(),[n,o]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,a]=useState(Ku);useEffect(()=>(()=>{}),[]);let i=B(useCallback(m=>({table:m.table,editable:m.editable,editingMode:m.editingMode??"editing",headParagraphId:m.selection?.to&&"paraId"in m.selection.to?m.selection.to.paraId:m.selection?.from&&"paraId"in m.selection.from?m.selection.from.paraId:""}),[]),Rv,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=useCallback(()=>{if(!t){a(Ku);return}let m=Mv(t,t.snapshot());a(g=>Iv(g,m)?g:m);},[t]);useEffect(()=>{l();},[l,i]),Ql("selectionChange",useCallback(()=>{l();},[l]));let c=r.tableKey!=="",s=useMemo(()=>t?kv(t,n):{},[t,n,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=useCallback((m,g)=>{if(!t)return;let{result:p,nextDraft:f}=runTableChromeCommand(t,m,g,n);p.ok&&f&&o(f);},[t,n]),u=useMemo(()=>({visible:c,draft:n,setDraft:o,slotState:m=>s[m]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[c,n,s,d]);return jsx(es.Provider,{value:u,children:e})}function _v(){let e=useContext(es);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function Ra(e){let t=_v(),n=t.slotState(e);return useMemo(()=>({visible:t.visible,enabled:n.enabled,disabledReason:n.disabledReason,draft:t.draft,apply:o=>t.apply(e,o)}),[t,e,n])}var Nv='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function ro(e){return [...e.querySelectorAll(Nv)].filter(t=>t.closest('[role="menu"]')===e)}function os(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function st(e,t,n){if(e.length===0)return false;let o=t?e.indexOf(t):-1,r=o===-1?n>0?0:e.length-1:(o+n+e.length)%e.length;return e[r]?.focus(),true}function ct(e,t){let n=t==="first"?e[0]:e[e.length-1];return n?(n.focus(),true):false}function Ia(e){(Ko(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function rs(e,t,n){useEffect(()=>{if(!e)return;let o=r=>{let a=n.current;a&&r.target instanceof Node&&a.contains(r.target)||t(false);};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t,n]);}function ka({enabled:e,disabledReason:t,ariaLabel:n}){let{t:o}=_(),r=localizeDisabledReason(t,o),a=useId(),i=!e&&r?a:void 0;return {reasonId:a,shared:{type:"button",onMouseDown:O,"aria-label":n,...i?{"aria-describedby":i}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:i&&r?jsx("span",{id:a,className:"docx-editor-sr-only",children:r}):null}}var Fv='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function $u(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,a=o.current;if(!r)return;let i=()=>[...r.querySelectorAll(Fv)].filter(s=>s.closest('[role="menu"]')===r);queueMicrotask(()=>{let s=i();(s.find(u=>u.hasAttribute("data-selected")||u.hasAttribute("data-active"))??s[0])?.focus();});let c=s=>{let d=i();if(s.key==="Escape"){s.preventDefault(),t(false),a?.focus();return}if(s.key==="ArrowDown"){s.preventDefault(),st(d,document.activeElement,1);return}if(s.key==="ArrowUp"){s.preventDefault(),st(d,document.activeElement,-1);return}if(s.key==="Home"){s.preventDefault(),ct(d,"first");return}if(s.key==="End"){s.preventDefault(),ct(d,"last");return}if(s.key==="Enter"||s.key===" "){let u=document.activeElement;u instanceof HTMLElement&&d.includes(u)&&(s.preventDefault(),u.click());}};return r.addEventListener("keydown",c),()=>r.removeEventListener("keydown",c)},[e,t,n,o]);}function Wu(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,a=o.current;if(!r)return;let i=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(c=>c.closest('[role="dialog"]')===r);queueMicrotask(()=>{i()[0]?.focus();});let l=c=>{if(c.key==="Escape"){c.preventDefault(),t(false),a?.focus();return}if(c.key==="Enter"||c.key===" "){let s=document.activeElement,d=i();s instanceof HTMLElement&&d.includes(s)&&(c.preventDefault(),s.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,n,o]);}function Xu(e,t,n){if(e)return o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(!t));}}function zv(e){return te(tableChromeIconPaths(e))}function Qu(){return createContext(null)}function Et(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function is(e,t,n){let o=Qu();function r({hidden:l,asChild:c,className:s,children:d}){let{visible:u,enabled:m,disabledReason:g,draft:p,apply:f}=Ra(e),[b,h]=useState(false),P=useRef(null),x=useRef(null);rs(b,h,P);let C=useMemo(()=>({open:b,setOpen:h,enabled:m,disabledReason:g,apply:f,draft:p,triggerRef:x}),[b,m,g,f,p]);if(l||!u)return null;let v={className:`${t}${s?` ${s}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},y=d??jsxs(Fragment,{children:[jsx(a,{}),jsx(i,{})]});return jsx(o.Provider,{value:C,children:c?jsx(W,{...v,ref:P,children:y}):jsx("div",{ref:P,...v,children:y})})}function a({asChild:l,className:c,children:s}){let{open:d,setOpen:u,enabled:m,disabledReason:g,triggerRef:p}=Et(o),f=Y(),b=X(e),h=f(b?.labelKey??n),{shared:P,reasonNode:x}=ka({enabled:m,disabledReason:g,ariaLabel:h}),C={...P,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${c?` ${c}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:m?()=>u(!d):void 0,...l?{tabIndex:m?0:-1,role:"button",onKeyDown:Xu(m,d,u)}:{}},v=s??jsxs(Fragment,{children:[te(b?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(W,{...C,children:v}),x]}):jsxs("button",{...C,children:[v,x]})}a.docxToolbarPart=true;function i({asChild:l,className:c,children:s}){let{open:d,setOpen:u,enabled:m,triggerRef:g}=Et(o),p=Y(),f=useRef(null);if($u(d&&m,u,f,g),!d||!m)return null;let b=X(e),h=p(b?.labelKey??n),P={ref:f,role:"menu","aria-label":h,className:`docx-table-chrome__panel${c?` ${c}`:""}`,onMouseDown:O};return l?jsx(W,{...P,children:s}):jsx("div",{...P,children:s})}return {Root:r,Trigger:a,Content:i,Ctx:o}}var qn=is("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Ju({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Et(qn.Ctx),l=Y(),c=TABLE_BORDER_TARGET_OPTIONS.find(m=>m.value===e);if(!c)return null;let s=c.value==="none"?false:c.value===i.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":s,"data-value":c.value,className:`docx-table-chrome__target-btn${n?` ${n}`:""}`,...s?{"data-active":""}:{},"aria-label":l(c.labelKey),title:l(c.labelKey),onMouseDown:O,onClick:()=>{a(false),r(c.value);}},u=o??zv(c.icon);return t?jsx(W,{...d,children:u}):jsx("button",{...d,children:u})}function ep(e){let{children:t}=e;return jsx(qn.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(n=>jsx(Ju,{value:n.value},n.value))})})}function Vv(e){let{children:t}=e,n=t??jsxs(Fragment,{children:[jsx(qn.Trigger,{}),jsx(ep,{})]});return jsx(qn.Root,{...e,children:n})}var Wn=Object.assign(Vv,{docxSlot:"table.borderTarget",Trigger:qn.Trigger,Content:ep,Item:Ju}),Kn=is("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function tp({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Et(Kn.Ctx),l=Y(),c=TABLE_BORDER_STYLE_OPTIONS.find(m=>m.value===e);if(!c)return null;let s=c.value===i.spec.style,d={type:"button",role:"menuitemradio","aria-checked":s,...s?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:O,onClick:()=>{a(false),r(c.value);}},u=o??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${c.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(c.labelKey)})]});return t?jsx(W,{...d,children:u}):jsx("button",{...d,children:u})}function op(e){let{children:t}=e;return jsx(Kn.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(n=>jsx(tp,{value:n.value},n.value))})}function $v(e){let t=e.children??jsxs(Fragment,{children:[jsx(Kn.Trigger,{}),jsx(op,{})]});return jsx(Kn.Root,{...e,children:t})}var Un=Object.assign($v,{docxSlot:"table.borderStyle",Trigger:Kn.Trigger,Content:op,Item:tp}),zn=is("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function np({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:a,draft:i}=Et(zn.Ctx),l=Y(),c=Number(e),s=TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===c);if(!s)return null;let d=s.size===i.spec.size,u={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:O,onClick:()=>{a(false),r(s.size);}},m=o??jsxs(Fragment,{children:[jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${s.previewThickness}px`},"aria-hidden":"true"}),jsx("span",{children:l(s.labelKey)})]});return t?jsx(W,{...u,children:m}):jsx("button",{...u,children:m})}function rp(e){let{children:t}=e;return jsx(zn.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(n=>jsx(np,{value:String(n.size)},n.size))})}function Wv(e){let t=e.children??jsxs(Fragment,{children:[jsx(zn.Trigger,{}),jsx(rp,{})]});return jsx(zn.Root,{...e,children:t})}var Gn=Object.assign(Wv,{docxSlot:"table.borderWidth",Trigger:zn.Trigger,Content:rp,Item:np});function ap(e,t,n){let o=n?.defaultHex??"FF0000",r=Qu();function a({hidden:d,asChild:u,className:m,children:g}){let{visible:p,enabled:f,disabledReason:b,draft:h,apply:P}=Ra(e),[x,C]=useState(false),[v,y]=useState(o),T=useRef(null),M=useRef(null);rs(x,C,T);let w=useMemo(()=>({open:x,setOpen:C,enabled:f,disabledReason:b,apply:P,draft:h,triggerRef:M,lastHex:v,setLastHex:y}),[x,f,b,P,h,v]);if(d||!p)return null;let E={className:`docx-toolbar__colorsplit docx-table-chrome${m?` ${m}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},D=g??jsxs(Fragment,{children:[jsx(i,{}),jsx(l,{}),jsx(c,{clearFill:n?.clearFill??false})]});return jsx(r.Provider,{value:w,children:u?jsx(W,{...E,ref:T,children:D}):jsx("div",{ref:T,...E,children:D})})}function i({asChild:d,className:u,children:m}){let{enabled:g,disabledReason:p,apply:f,draft:b,lastHex:h}=Et(r),P=Y(),x=X(e),C=P(x?.labelKey??t),{shared:v,reasonNode:y}=ka({enabled:g,disabledReason:p,ariaLabel:C}),T=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:h??o,M={...v,className:`docx-toolbar__button docx-toolbar__colorsplit-main${u?` ${u}`:""}`,onClick:g?()=>f({kind:"hex",value:T}):void 0},w=m??jsxs(Fragment,{children:[te(x?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${T.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(W,{...M,children:w}),y]}):jsxs("button",{...M,children:[w,y]})}i.docxToolbarPart=true;function l({asChild:d,className:u,children:m}){let{open:g,setOpen:p,enabled:f,disabledReason:b,triggerRef:h}=Et(r),P=Y(),x=X(e),C=P(x?.labelKey??t),{shared:v,reasonNode:y}=ka({enabled:f,disabledReason:b,ariaLabel:C}),T={...v,ref:h,className:`docx-toolbar__colorsplit-caret${u?` ${u}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>p(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:Xu(f,g,p)}:{}},M=m??"\u25BE";return d?jsxs(Fragment,{children:[jsx(W,{...T,children:M}),y]}):jsxs("button",{...T,children:[M,y]})}l.docxToolbarPart=true;function c({asChild:d,className:u,children:m,clearFill:g}){let{open:p,setOpen:f,enabled:b,apply:h,draft:P,triggerRef:x,lastHex:C,setLastHex:v}=Et(r),y=Y(),T=useRef(null);if(Wu(p&&b,f,T,x),!p||!b)return null;let M=y(t),w=e==="table.borderColor"&&P.spec.color.kind==="hex"?P.spec.color.value:C??o,E={ref:T,role:"dialog","aria-label":M,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${u?` ${u}`:""}`,onMouseDown:O},D=m??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:O,onClick:()=>{f(false),h(null),Ia(x.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),y("table.clearCellFill")]}):null,jsx(Ol,{apply:F=>{f(false),v?.(F),h({kind:"hex",value:F}),Ia(x.current);},current:w})]});return d?jsx(W,{...E,children:D}):jsx("div",{...E,children:D})}function s({value:d,css:u,labelKey:m,asChild:g,className:p,children:f}){let{apply:b,setOpen:h,setLastHex:P,triggerRef:x}=Et(r),C=Y(),v=u??`#${d.toLowerCase()}`,y=m?C(m):d,T={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:v},"data-value":d,"aria-label":y,title:y,onMouseDown:O,onClick:()=>{h(false),P?.(d),b({kind:"hex",value:d}),Ia(x.current);}};return g?jsx(W,{...T,children:f}):jsx("button",{...T,children:f})}return {Root:a,Main:i,Trigger:l,Content:c,Item:s,Ctx:r}}var Vn=ap("table.borderColor","table.borderColor",{defaultHex:"000000"});function Uv(e){return jsx(Vn.Content,{...e,clearFill:false})}function Gv(e){return jsx(Vn.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function jv(e){return jsx(Vn.Root,{...e})}var jn=Object.assign(jv,{docxSlot:"table.borderColor",Trigger:Vn.Trigger,Content:Uv,Item:Gv,Main:Vn.Main}),$n=ap("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function Yv(e){return jsx($n.Content,{...e,clearFill:true})}function Xv(e){return jsx($n.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function Qv(e){return jsx($n.Root,{...e})}var Yn=Object.assign(Qv,{docxSlot:"table.cellFill",Trigger:$n.Trigger,Content:Yv,Item:Xv,Main:$n.Main});function ip({overrides:e=new Map}){return Vu()?jsxs(Fragment,{children:[jsx(qo,{}),[Wn,jn,Un,Gn,Yn].map(o=>{let r=e.get(o.docxSlot);return r?jsx(Fragment$1,{children:r},o.docxSlot):jsx(o,{},o.docxSlot)})]}):null}function lp(){let e=Y(),{draft:t}=Ra("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var up=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],pp={"zoom.level":Ll,"styles.style":Xl,"font.family":Wl,"font.size":Nl,"text.color":Zl,"text.highlight":Bl,"text.link":Rl,"list.lineSpacing":Fl,"review.editingMode":ia,"file.save":Il,...Au,"table.borderTarget":Wn,"table.borderColor":jn,"table.borderStyle":Un,"table.borderWidth":Gn,"table.cellFill":Yn,"image.insert":hn,"image.properties":Bo,"image.wrap":_n,"image.altText":Dn},cp=new Map;function ty(e){let t=cp.get(e);return t||(t=n=>jsx(Qt,{slot:e,...n}),cp.set(e,t)),t}function oy(e){return formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:xa}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(n=>{let o=chromeSlotId(t,n);return {slot:o,Part:pp[o]??ty(o)}})})}var ny=e=>e.image;function ry(e){return e==="alignment"||e in pp}function cs(e){let t=Ao(e,cs);if(t!==null)return t;if(!isValidElement(e))return null;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxToolbarPart===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function ls(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(ls);let t=cs(e);return t!=null&&up.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(ls):false}function ay(e,t){return t?true:Children.toArray(e).some(ls)}function iy(e){let t=je(),{className:n,t:o,onSave:r,preset:a=true,overflow:i=true,children:l}=e,c=useMemo(()=>({t:o,onSave:r}),[o,r]),s=Kr(o),d=B(ny),u=useMemo(()=>oy(d),[d]),m=useMemo(()=>new Set(u.flatMap(x=>x.entries.map(C=>C.slot))),[u]),g=useMemo(()=>u.map(x=>x.id).filter(x=>!fl.has(x)),[u]),p=useMemo(()=>Ed(g),[g]),f=a&&i,{attach:b,overflow:h}=Hd(f,g,p),P;if(!a)P=l;else {let x=Children.toArray(l),C=new Map,v=new Map,y=[];for(let D of x){let F=cs(D);F&&m.has(F)?C.set(F,D):F&&up.includes(F)?v.set(F,D):y.push(D);}let T=D=>{let F=C.get(D.slot);if(F)return F;let H=D.Part;return jsx(H,{})},M=[],w=[],E=0;for(let D of u){if(h.has(D.id)){let H=D.entries.flatMap(k=>{let L=sy(k,C,s,D.labelKey,T);return L===null?[]:[jsx(Fragment$1,{children:L},k.slot)]});if(H.length===0)continue;w.push({id:D.id,labelKey:D.labelKey,children:H});continue}E>0&&M.push(jsx(qo,{},`separator-${D.id}`)),E+=1;let F=fl.has(D.id);M.push(jsx("div",{className:"docx-toolbar__group",...F?{[In]:""}:{[Rn]:D.id},children:D.entries.map(H=>jsx(Fragment$1,{children:T(H)},H.slot))},D.id));}P=jsxs(Fragment,{children:[M,jsx(ip,{overrides:v}),y.length>0?jsx("div",{className:"docx-toolbar__group",[In]:"",children:y}):null,w.length>0?jsx(Bd,{sections:w}):null]});}return jsx(Xt.Provider,{value:c,children:jsx("div",{ref:b,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${n?` ${n}`:""}`,...f?{"data-overflow":""}:{},onMouseDown:O,children:ay(l,a)?jsx(ts,{children:P}):P})})}function ly(e){return e?!!e.props.hidden:false}function sy(e,t,n,o,r){let a=t.get(e.slot);return ly(a)?null:a||ry(e.slot)?jsx(Od,{label:cy(n,e,o),children:r(e)}):jsx(Zd,{slot:e.slot})}function cy(e,t,n){let o=t.slot==="alignment"?null:X(t.slot);return e(o?.labelKey??n)}var Qn=Object.assign(iy,{Button:Qt,Action:Kl,Separator:qo,Undo:jd,Redo:Yd,Bold:Xd,Italic:Qd,Underline:Jd,Strike:eu,Link:Rl,ClearFormatting:tu,Superscript:ou,Subscript:nu,Alignment:xa,AlignLeft:ru,AlignCenter:au,AlignRight:iu,AlignJustify:lu,LineSpacing:Fl,BulletList:su,NumberedList:cu,Outdent:du,Indent:uu,ImageInsert:hn,ImageProperties:Bo,ImageWrap:_n,ImageAltText:Dn,TableInsert:pu,TableBorderTarget:Wn,TableBorderColor:jn,TableBorderStyle:Un,TableBorderWidth:Gn,TableCellFill:Yn,Comments:mu,FontFamily:Wl,FontSize:Nl,FontColor:Zl,Highlight:Bl,Zoom:Ll,StylePicker:Xl,EditingMode:ia,Save:Il,ContentControlShowAll:Ca,ContentControlFormFill:Pa,ContentControlInspector:wa,ContentControlRemove:Ea});var my=e=>e.pageSetup??null,fy=e=>e.editable;function ao(){let e=A(),t=B(my),n=B(fy),o=useMemo(()=>n&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,n]),r=useCallback(a=>e?e.exec({...a.pageWidthTwips!==void 0?{pageWidth:a.pageWidthTwips}:{},...a.pageHeightTwips!==void 0?{pageHeight:a.pageHeightTwips}:{},...a.orientation!==void 0?{orientation:a.orientation}:{},...a.marginTopTwips!==void 0?{marginTop:a.marginTopTwips}:{},...a.marginRightTwips!==void 0?{marginRight:a.marginRightTwips}:{},...a.marginBottomTwips!==void 0?{marginBottom:a.marginBottomTwips}:{},...a.marginLeftTwips!==void 0?{marginLeft:a.marginLeftTwips}:{},...a.scope!==void 0?{scope:a.scope}:{},type:"setPageSetup"}).ok:false,[e]);return useMemo(()=>({pageSetup:t,isEnabled:o,apply:r}),[t,o,r])}var us=[{labelKey:"dialogs.pageSetup.pageSizes.letter",width:12240,height:15840},{labelKey:"dialogs.pageSetup.pageSizes.a4",width:11906,height:16838},{labelKey:"dialogs.pageSetup.pageSizes.legal",width:12240,height:20160},{labelKey:"dialogs.pageSetup.pageSizes.a3",width:16838,height:23811},{labelKey:"dialogs.pageSetup.pageSizes.a5",width:8391,height:11906},{labelKey:"dialogs.pageSetup.pageSizes.b5",width:9979,height:14175},{labelKey:"dialogs.pageSetup.pageSizes.executive",width:10440,height:15120}],xp=1440,gy=e=>Math.round(e/xp*100)/100,by=e=>Math.round(e*xp);function hy(e,t){let n=Math.min(e,t),o=Math.max(e,t);return us.findIndex(r=>Math.abs(r.width-n)<20&&Math.abs(r.height-o)<20)}var vy={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},yy={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:400,maxWidth:480,width:"100%",margin:20},xy={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600,color:"var(--doc-text)"},Ty={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},bp={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},_a={display:"flex",alignItems:"center",gap:12},Da={width:80,fontSize:13,color:"var(--doc-text-muted)"},Na={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Sy={fontSize:11,color:"var(--doc-text-muted)",width:16},Cy={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},hp={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},vp=12240,yp=15840,Ft=1440;function Jn({open:e,onClose:t,className:n}){let{t:o}=_(),{pageSetup:r,isEnabled:a,apply:i}=ao(),[l,c]=useState(vp),[s,d]=useState(yp),[u,m]=useState("portrait"),[g,p]=useState(Ft),[f,b]=useState(Ft),[h,P]=useState(Ft),[x,C]=useState(Ft),[v,y]=useState("document"),T=useRef(null),M=useRef("no");useEffect(()=>{if(!e){M.current="no";return}if(M.current==="yes"&&r===null){M.current="no";return}M.current==="yes"||M.current==="loading"&&r===null||(c(r?.pageWidthTwips??vp),d(r?.pageHeightTwips??yp),m(r?.orientation??"portrait"),p(r?.marginsTwips.top??Ft),b(r?.marginsTwips.bottom??Ft),P(r?.marginsTwips.left??Ft),C(r?.marginsTwips.right??Ft),y("document"),M.current=r===null?"loading":"yes");},[e,r]),useEffect(()=>{e&&T.current?.focus();},[e]);let w=useCallback(k=>{let L=us[k];L&&(c(u==="landscape"?L.height:L.width),d(u==="landscape"?L.width:L.height));},[u]),E=useCallback(k=>{k!==u&&(m(k),c(s),d(l));},[u,l,s]),D=useCallback(()=>{i({pageWidthTwips:l,pageHeightTwips:s,orientation:u,marginTopTwips:g,marginRightTwips:x,marginBottomTwips:f,marginLeftTwips:h,scope:v})&&t();},[i,l,s,u,g,x,f,h,v,t]);if(!e)return null;let F=hy(l,s),H=(k,L,R)=>jsxs("div",{style:_a,children:[jsx("label",{style:Da,children:o(`dialogs.pageSetup.${k}`)}),jsx("input",{type:"number",style:Na,min:0,max:22,step:.1,value:gy(L),onChange:I=>R(Math.max(0,by(Number(I.target.value)||0))),"aria-label":o(`dialogs.pageSetup.${k}`)}),jsx("span",{style:Sy,children:"in"})]});return jsx("div",{className:n,style:vy,onClick:t,onKeyDown:k=>{k.key==="Escape"&&t(),k.key==="Enter"&&D();},children:jsxs("div",{ref:T,tabIndex:-1,style:yy,onClick:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o("dialogs.pageSetup.title"),children:[jsx("div",{style:xy,children:o("dialogs.pageSetup.title")}),jsxs("div",{style:Ty,children:[jsx("div",{style:bp,children:o("dialogs.pageSetup.pageSize")}),jsxs("div",{style:_a,children:[jsx("label",{style:Da,children:o("dialogs.pageSetup.sizeLabel")}),jsxs("select",{style:Na,value:F,onChange:k=>w(Number(k.target.value)),"aria-label":o("dialogs.pageSetup.sizeLabel"),children:[us.map((k,L)=>jsx("option",{value:L,children:o(k.labelKey)},k.labelKey)),F<0&&jsx("option",{value:-1,children:o("dialogs.pageSetup.custom")})]})]}),jsxs("div",{style:_a,children:[jsx("label",{style:Da,children:o("dialogs.pageSetup.orientation")}),jsxs("select",{style:Na,value:u,onChange:k=>E(k.target.value),"aria-label":o("dialogs.pageSetup.orientation"),children:[jsx("option",{value:"portrait",children:o("dialogs.pageSetup.portrait")}),jsx("option",{value:"landscape",children:o("dialogs.pageSetup.landscape")})]})]}),jsx("div",{style:{...bp,marginTop:4},children:o("dialogs.pageSetup.margins")}),H("top",g,p),H("bottom",f,b),H("left",h,P),H("right",x,C),jsxs("div",{style:_a,children:[jsx("label",{style:Da,children:o("dialogs.pageSetup.applyTo")}),jsxs("select",{style:Na,value:v,onChange:k=>y(k.target.value),"aria-label":o("dialogs.pageSetup.applyTo"),children:[jsx("option",{value:"document",children:o("dialogs.pageSetup.applyToDocument")}),jsx("option",{value:"section",children:o("dialogs.pageSetup.applyToSection")})]})]})]}),jsxs("div",{style:Cy,children:[jsx("button",{type:"button",style:hp,onClick:t,children:o("common.cancel")}),jsx("button",{type:"button",style:{...hp,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:a?1:.5},disabled:!a,onClick:D,children:o("common.apply")})]})]})})}var er=createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onReportIssue:void 0,reportIssue:void 0});function Je(){return useContext(er)}function _e(){let{t:e}=Je(),{t}=_();return n=>e?.(n)??t(n)}var wy=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,My=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var Tp=new TextEncoder;function Ry(e,t){if(Tp.encode(e).length<=t)return e;let n=0,o="";for(let r of e){let a=Tp.encode(r).length;if(n+a>t)break;n+=a,o+=r;}return o}function Sp(e){let t=Ry((e??"").replace(/\.docx$/i,"").replace(My," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||wy.test(t)?"document.docx":`${t}.docx`}function Cp(e,t){let n=URL.createObjectURL(new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})),o=document.createElement("a");o.href=n,o.download=t,o.click(),setTimeout(()=>URL.revokeObjectURL(n),0);}var Iy="https://github.com/eigenpal/docx-editor/issues/new";function ky(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Pp(e={}){let t=e.userAgent??(typeof navigator<"u"?navigator.userAgent:"unknown"),n=e.viewport??(typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??ky()}`,`- Viewport: ${n.width} x ${n.height}`,`- User agent: ${t}`,""].join(`
2
+ `),a=new URLSearchParams({title:"[Bug] ",body:r});return `${Iy}?${a.toString()}`}function tr(e){typeof window>"u"||window.open(Pp(e),"_blank","noopener,noreferrer");}var ps=6,wp=6;function Ne(e){let{icon:t,shortcut:n,disabled:o,title:r,active:a,selected:i,slot:l,onSelect:c,className:s,children:d}=e,u=useId(),m=o&&r?u:void 0;return jsxs("button",{type:"button",role:a===void 0?"menuitem":i===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${s?` ${s}`:""}`,tabIndex:-1,...l?{"data-slot":l}:{},...a?{"data-active":""}:{},...o?{"data-disabled":"","aria-disabled":true}:{},...a!==void 0?{"aria-checked":a}:{},...m?{"aria-describedby":m}:{},...r?{title:r}:{},onMouseDown:O,onClick:o?void 0:c,children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsx("span",{className:"docx-menubar__item-label",children:d}),n?jsx("span",{className:"docx-menubar__item-shortcut",children:n}):null,m?jsx("span",{id:u,className:"docx-editor-sr-only",children:r}):null]})}function nr({label:e,labelKey:t,className:n,hidden:o,children:r}){let a=_e();if(o)return null;let i=e??(t===void 0?void 0:a(t));return jsxs("div",{role:"group",className:`docx-menubar__group${n?` ${n}`:""}`,...i?{"aria-label":i}:{},children:[i?jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:i}):null,r]})}function wt({slot:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let{execute:a,isActive:i,isEnabled:l,disabledReason:c}=ne(e),{setOpenMenu:s}=Je(),d=_e();if(r)return null;let u=X(e),m=d(t??u?.labelKey??e),g=commandForSlot(e),p=g?.type==="toggleMark"||g?.type==="setAlignment",f=g?.type==="setAlignment";return jsx(Ne,{slot:e,icon:te(u?.paths),...n?{shortcut:d(n)}:{},disabled:!l,...c?{title:c}:{},...p?{active:i}:{},...f?{selected:true}:{},onSelect:()=>{a(),s(null);},...o?{className:o}:{},children:m})}wt.docxMenuRow=true;function Mp(e,t,n,o){return Object.assign(({className:a,hidden:i})=>{let l=Je(),c=_e(),s=o(l);if(i)return null;let d=X(e),u=c(t??d?.labelKey??e);return jsx(Ne,{slot:e,icon:te(d?.paths),...n?{shortcut:c(n)}:{},disabled:!s,onSelect:()=>{s?.(),l.setOpenMenu(null);},...a?{className:a}:{},children:u})},{docxSlot:e})}var fs=Mp("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),gs=Mp("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function Fy({className:e,hidden:t}){let n=A(),o=Je(),r=_e(),a=chromeProbeForSlot("file.pageSetup"),i=n&&a?n.can(a):null,l=i?.ok===true,c=i&&!i.ok?i.reason:null;if(t)return null;let s=X("file.pageSetup"),d=r(s?.labelKey??"file.pageSetup"),u=l&&!!o.onPageSetup;return jsx(Ne,{slot:"file.pageSetup",icon:te(s?.paths),disabled:!u,...c?{title:c}:{},onSelect:()=>{o.onPageSetup?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}var bs=Object.assign(Fy,{docxSlot:"file.pageSetup"});function Ay({className:e,hidden:t}){let{openFilePicker:n,isEnabled:o,disabledReason:r}=Vr(),a=Je(),i=_e();if(t)return null;let l=X("image.insert"),c=i(l?.labelKey??"toolbar.image");return jsx(Ne,{slot:"image.insert",icon:te(l?.paths),disabled:!o,...r?{title:r}:{},onSelect:()=>{n(),a.setOpenMenu(null);},...e?{className:e}:{},children:c})}var Oy=Object.assign(Ay,{docxSlot:"image.insert"}),or=8;function lo({labelKey:e,paths:t,className:n,children:o}){let r=_e(),[a,i]=useState(false),l=useRef(null),c=useRef(null),s=useId(),d=r(e),[u,m]=useState(null);return useLayoutEffect(()=>{if(!a){m(null);return}let g=l.current,p=c.current,f=g?.ownerDocument.defaultView;if(!g||!p||!f)return;let b=g.getBoundingClientRect(),h=p.offsetWidth,P=p.offsetHeight,x=b.right+h>f.innerWidth-or;m({left:x?Math.max(or,b.left-h):Math.min(b.right,f.innerWidth-h-or),top:Math.max(or,Math.min(b.top-4,f.innerHeight-P-or))});},[a]),jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),onKeyDown:g=>{g.key==="ArrowRight"&&document.activeElement===l.current?(g.preventDefault(),i(true),queueMicrotask(()=>{c.current&&ct(ro(c.current),"first");})):(g.key==="ArrowLeft"||g.key==="Escape")&&a&&(g.preventDefault(),g.stopPropagation(),i(false),l.current?.focus());},onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||i(false);},children:[jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?s:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:O,onFocus:()=>i(true),onClick:()=>i(true),children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:te(t)}),jsx("span",{className:"docx-menubar__item-label",children:d}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsx("div",{ref:c,id:s,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:u?{position:"fixed",left:u.left,top:u.top}:{position:"fixed",visibility:"hidden"},onKeyDown:g=>{let p=c.current;if(!p)return;let f=ro(p);g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),st(f,document.activeElement,1)):g.key==="ArrowUp"&&(g.preventDefault(),g.stopPropagation(),st(f,document.activeElement,-1));},children:o}):null]})}function Ha({slot:e="table.insert",className:t}){let n=A(),{isEnabled:o}=ne(e),{setOpenMenu:r}=Je(),a=_e(),[i,l]=useState(null),[c,s]=useState({rows:1,cols:1}),d=useRef(null),u=useCallback((p,f)=>{if(!n||!o)return;let b={type:"insertTable",rows:p,cols:f};n.can(b).ok&&(n.exec(b),r(null),n.focus());},[n,o,r]),m=useCallback(p=>{s(f=>{let b={rows:Math.min(wp,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(ps,Math.max(1,p.toCol??f.cols+(p.cols??0)))};return l(b),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${b.rows}x${b.cols}"]`)?.focus()),b});},[]),g=[];for(let p=1;p<=wp;p+=1){let f=[];for(let b=1;b<=ps;b+=1){let h=!!i&&p<=i.rows&&b<=i.cols;f.push(jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${b}`,className:"docx-menubar__grid-cell",tabIndex:c.rows===p&&c.cols===b?0:-1,...h?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:O,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>u(p,b)},b));}g.push(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return jsxs("div",{ref:d,role:"grid","aria-label":a("toolbar.insertTable"),className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>l(null),onKeyDown:p=>{if(p.key==="ArrowRight")m({cols:1});else if(p.key==="ArrowLeft")m({cols:-1});else if(p.key==="ArrowDown")m({rows:1});else if(p.key==="ArrowUp")m({rows:-1});else if(p.key==="Home")m({toCol:1});else if(p.key==="End")m({toCol:ps});else return;p.preventDefault(),p.stopPropagation();},children:[jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:i?`${i.cols} \xD7 ${i.rows}`:""})]})}function Zy({entry:e}){let{isEnabled:t}=ne(e.slot),n=X(e.slot);return t?jsx(lo,{labelKey:e.labelKey??n?.labelKey??e.slot,paths:n?.paths,children:jsx(Ha,{slot:e.slot})}):jsx(wt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function so({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function rr({entry:e}){return e.kind==="separator"?jsx(so,{}):e.kind==="submenu"?jsx(lo,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,n)=>jsx(rr,{entry:t},n))}):e.slot==="file.open"?jsx(fs,{}):e.slot==="file.save"?jsx(gs,{}):e.slot==="file.pageSetup"?jsx(bs,{}):e.slot==="image.insert"?jsx(Oy,{}):e.picker==="tableGrid"?jsx(Zy,{entry:e}):jsx(wt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Rp(e){if(!isValidElement(e))return null;let t=Ao(e,Rp);if(t!==null)return t;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxMenuRow===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function By(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function qy(e,t,n){return sa({entries:e??[],children:t,preset:n,keyOfEntry:By,keyOfChild:Rp,renderEntry:o=>jsx(rr,{entry:o})})}function $o({id:e,labelKey:t,label:n,icon:o,className:r,hidden:a,preset:i=true,children:l}){let{openMenu:c,setOpenMenu:s,activeMenu:d}=Je(),u=_e(),m=useId(),g=useRef(null),p=useRef(null),f=useRef(false),b=useRef(false),h=CHROME_MENUS.find(y=>y.id===e),P=c===e;if(a)return null;let x=n??u(t??h?.labelKey??e),C=qy(h?.entries,l,i),v=()=>{s(null),g.current?.focus();};return jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,children:[jsxs("button",{ref:g,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":P,"aria-controls":P?m:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...P?{"data-open":""}:{},onMouseDown:O,onKeyDown:y=>{y.key==="ArrowDown"||y.key==="Enter"||y.key===" "||y.key==="ArrowUp"?(y.preventDefault(),f.current=true,s(e)):y.key==="Escape"&&P&&(y.preventDefault(),v());},onClick:()=>{if(b.current){b.current=false;return}s(P?null:e);},onMouseEnter:()=>{c!==null&&c!==e&&(b.current=true,s(e));},onMouseLeave:()=>{b.current=false;},children:[o?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:o}):null,x]}),P?jsx("div",{ref:y=>{p.current=y,y&&f.current&&(f.current=false,ct(ro(y),"first"));},id:m,role:"menu","aria-label":x,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:y=>{let T=p.current;if(!T)return;let M=ro(T),w=document.activeElement;y.key==="ArrowDown"?(y.preventDefault(),st(M,w,1)):y.key==="ArrowUp"?(y.preventDefault(),st(M,w,-1)):y.key==="Home"?(y.preventDefault(),ct(M,"first")):y.key==="End"?(y.preventDefault(),ct(M,"last")):y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),v()):y.key==="Tab"&&s(null);},children:C}):null]})}function hs(e){return Object.assign(n=>jsx($o,{id:e,...n}),{docxMenu:e})}var vs=hs("file"),ys=hs("format"),xs=hs("insert");function Ky({className:e,hidden:t,onSelect:n}){let{setOpenMenu:o,onReportIssue:r,reportIssue:a}=Je(),i=_e();if(t||a===false)return null;let l=n??r??tr;return jsx(Ne,{slot:"help.reportIssue",onSelect:()=>{l(),o(null);},...e?{className:e}:{},children:i("toolbar.reportIssue")})}var Fa=Object.assign(Ky,{docxSlot:"help.reportIssue"});function zy({children:e,...t}){let{reportIssue:n}=Je();return e===void 0&&n===false?null:jsxs($o,{id:"help",...t,children:[jsx(Fa,{}),e]})}var Ts=Object.assign(zy,{docxMenu:"help"});var Wy={file:vs,format:ys,insert:xs,help:Ts},Uy=new Set(CHROME_MENUS.map(e=>e.id));function Hp(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let o=Children.toArray(e.props.children).map(Hp).filter(r=>r!==null);return o.length===1?o[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===$o){let n=e.props.id;if(typeof n=="string"&&Uy.has(n))return n}return null}function Gy(e){let t=je(),{className:n,t:o,fileName:r,onOpen:a,onOpenFile:i,onSave:l,onPageSetup:c,onReportIssue:s,reportIssue:d,preset:u=true,children:m}=e,g=A(),{t:p}=_(),[f,b]=useState(null),[h,P]=useState(null),[x,C]=useState(null),[v,y]=useState(false),T=useRef(null),M=useRef(null);useEffect(()=>{if(f===null)return;let z=V=>{let j=T.current;j&&V.target instanceof Node&&j.contains(V.target)||b(null);},Z=V=>{V.key==="Escape"&&b(null);};return document.addEventListener("mousedown",z),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",Z);}},[f]);let w=useCallback(z=>{b(z),z!==null&&C(z);},[]),E=useCallback(()=>M.current?.click(),[]),D=useCallback(()=>{g&&g.save().then(z=>Cp(z,Sp(r??h??void 0))).catch(z=>{console.error("[docx-editor] save failed",z);});},[g,r,h]),F=useCallback(()=>y(true),[]),H=g?a??E:void 0,k=g?l??D:void 0,L=g?c??F:void 0;useEffect(()=>{let z=Z=>{if(!(Z.metaKey||Z.ctrlKey)||Z.altKey||Z.shiftKey)return;let V=Z.key.toLowerCase();if(V!=="s"&&V!=="o")return;let j=Z.target,Re=Ko(T.current)??T.current;!j||!Re?.contains(j)||(V==="s"&&k?(Z.preventDefault(),k()):V==="o"&&H&&(Z.preventDefault(),H()));};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[H,k]);let R=useMemo(()=>({t:o,openMenu:f,setOpenMenu:w,activeMenu:x,onOpen:H,onSave:k,onPageSetup:L,onReportIssue:s,reportIssue:d}),[o,f,w,x,H,k,L,s,d]),I;if(!u)I=m;else {let z=new Map,Z=[];for(let V of Children.toArray(m)){let j=Hp(V);j?z.set(j,V):Z.push(V);}I=jsxs(Fragment,{children:[CHROME_MENUS.map(V=>{let j=z.get(V.id);if(j)return jsx(Fragment$1,{children:j},V.id);let Re=Wy[V.id];return jsx(Re,{},V.id)}),Z]});}return jsxs(er.Provider,{value:R,children:[jsx("div",{ref:z=>{if(T.current=z,z&&x===null){let Z=os(z)[0]?.closest("[data-menu]")?.getAttribute("data-menu");Z&&C(Z);}},role:"menubar","aria-label":o?.("titleBar.menuBarAriaLabel")??p("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${t}docx-menubar${n?` ${n}`:""}`,onMouseDown:O,onKeyDown:z=>{if(z.key!=="ArrowLeft"&&z.key!=="ArrowRight")return;let Z=T.current;if(!Z)return;let V=os(Z),j=V.indexOf(document.activeElement);if(j===-1)return;z.preventDefault();let Re=z.key==="ArrowRight"?1:-1,se=V[(j+Re+V.length)%V.length],Se=se?.closest("[data-menu]")?.getAttribute("data-menu");Se&&(C(Se),se?.focus(),f!==null&&b(Se));},children:I}),jsx("input",{ref:M,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:z=>{let Z=z.target.files?.[0];z.target.value="",!(!Z||!g)&&(P(Z.name),i?.(Z),Z.arrayBuffer().then(V=>g.load(new Uint8Array(V))).catch(V=>{console.error("[docx-editor] could not open the file",V);}));}}),jsx(Jn,{open:v,onClose:()=>y(false)})]})}var ir=Object.assign(Gy,{Menu:$o,File:vs,Format:ys,Insert:xs,Help:Ts,Item:wt,Row:Ne,Group:nr,Separator:so,Submenu:lo,TableGrid:Ha,Entry:rr,Open:fs,Save:gs,PageSetup:bs,ReportIssue:Fa});var Jy=12240,Op=1440,qp=1440,Kp=567,co=20,Cs=6,ex=co+Cs+2,tx="var(--doc-text-muted)",ox="var(--doc-text-subtle)",Zp="var(--doc-shadow-subtle)",nx="var(--doc-primary)",rx="var(--doc-primary-hover)",ax="var(--doc-text-subtle)",sr=5,lr=7,ix={left:0,right:0,firstLine:0};function Bp(e,t){return t==="inch"?(e/qp).toFixed(2)+'"':(e/Kp).toFixed(1)+" cm"}function lx(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function uo({pageSetup:e,zoom:t=1,editable:n=false,onLeftMarginChange:o,onRightMarginChange:r,onMarginDragEnd:a,showIndentHandles:i=false,indent:l,indentEditable:c=false,onIndentChange:s,onIndentDragEnd:d,unit:u="inch",className:m="",style:g,tabMarks:p,onTabMarkRemove:f}){let{t:b}=_(),[h,P]=useState(null),[x,C]=useState(null),[v,y]=useState(null),[T,M]=useState(null),w=useRef(null),E=e?.pageWidthTwips??Jy,D=e?.marginsTwips.left??Op,F=e?.marginsTwips.right??Op,H=e?.gutterTwips??0,k={pageWidth:E,leftMargin:D,rightMargin:F},L=l??ix,R=xe(E)*t,I=xe(D)*t,z=xe(F)*t,Z=useCallback(q=>{let Ee=w.current?.getBoundingClientRect();return Ee?ta((q-Ee.left)/t):null},[t]),V=useCallback((q,Ee,Ue)=>{let ce=Z(Ee);if(ce===null)return;if(M(xe(ce)*t),q==="leftMargin"||q==="rightMargin"){if(q==="leftMargin"){let mn=E-F-H-720,_o=Math.round(Math.max(0,Math.min(ce,mn)));y(_o),o?.(_o);}else {let mn=E-ce,_o=E-D-H-720,Zr=Math.round(Math.max(0,Math.min(mn,_o)));y(Zr),r?.(Zr);}return}let Ge=dragIndent(q,ce,L,k,{unit:u,precise:Ue});y(q==="right"?Ge.right:q==="firstLine"?Ge.firstLine:Ge.left),s?.(Ge);},[Z,t,E,D,F,H,o,r,s,L,k,u]),j=useCallback(q=>{q==="leftMargin"||q==="rightMargin"?a?.():d?.(),P(null),y(null),M(null);},[a,d]),Re=useCallback((q,Ee,Ue)=>{let ce=handlePosition(q,L,k),Ge=dragIndent(q,ce+Ee*lx(u,Ue),L,k,{unit:u,precise:true});s?.(Ge),d?.();},[L,k,u,s,d]),se=mx(E,t,u),Se=i&&c&&s!==void 0,Pe=q=>xe(handlePosition(q,L,k))*t,G=(q,Ee,Ue)=>({positionPx:Pe(q),editable:Se,isDragging:h===q,isHovered:x===q,onPointerEnter:()=>C(q),onPointerLeave:()=>C(null),onPointerDown:ce=>{Se&&(ce.preventDefault(),ce.stopPropagation(),ce.currentTarget.setPointerCapture(ce.pointerId),P(q));},onPointerMove:ce=>{h===q&&V(q,ce.clientX,ce.altKey);},onPointerUp:ce=>{h===q&&(ce.currentTarget.releasePointerCapture(ce.pointerId),j(q));},onKeyDown:ce=>{Se&&(ce.key!=="ArrowLeft"&&ce.key!=="ArrowRight"||(ce.preventDefault(),Re(q,ce.key==="ArrowLeft"?-1:1,ce.shiftKey)));},label:b(Ee),valueNow:Ue,valueText:Bp(Ue,u),pageWidthTwips:E});return jsxs("div",{ref:w,className:`docx-horizontal-ruler ${m}`,style:{position:"relative",width:qe(R),height:ex,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:h?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":b("ruler.horizontal"),children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:qe(I),height:co,backgroundColor:Zp,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&o?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),P("leftMargin");}:void 0,onPointerMove:q=>h==="leftMargin"&&V("leftMargin",q.clientX,q.altKey),onPointerUp:q=>{h==="leftMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),j("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:qe(z),height:co,backgroundColor:Zp,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&r?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),P("rightMargin");}:void 0,onPointerMove:q=>h==="rightMargin"&&V("rightMargin",q.clientX,q.altKey),onPointerUp:q=>{h==="rightMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),j("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:co,pointerEvents:"none"},children:se.map((q,Ee)=>jsx(sx,{tick:q},Ee))}),p?.map(q=>jsx(px,{tabMark:q,positionPx:xe(q.position)*t,onDoubleClick:()=>f?.(q.position)},q.position)),i&&jsxs(Fragment,{children:[jsx(Ss,{direction:"down",anchor:"top",...G("firstLine","ruler.firstLineIndent",L.firstLine)}),jsx(Ss,{direction:"up",anchor:"strip",...G("hanging","ruler.hangingIndent",L.left)}),jsx(cx,{...G("left","ruler.leftIndent",L.left)}),jsx(Ss,{direction:"up",anchor:"strip",...G("right","ruler.rightIndent",L.right)})]}),h&&v!==null&&T!==null&&jsx(dx,{value:Bp(v,u),positionPx:T})]})}function sx({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:qe(e.position),bottom:0,width:1,height:e.height,backgroundColor:ox}}),e.label&&jsx("div",{style:{position:"absolute",left:qe(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:tx,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function zp(e){return e.editable?e.isDragging||e.isHovered?rx:nx:ax}function Vp(e,t,n){return {position:"absolute",left:qe(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...n}}function $p(e){return {role:"slider","aria-label":e.label,"aria-orientation":"horizontal","aria-valuenow":e.valueNow,"aria-valuemin":-e.pageWidthTwips,"aria-valuemax":e.pageWidthTwips,"aria-valuetext":e.valueText,"aria-disabled":e.editable?void 0:true,tabIndex:e.editable?0:-1}}function Ss({direction:e,anchor:t,...n}){let o=zp(n),r=t==="top"?{top:0,height:lr+1}:{top:co-lr,height:lr};return jsx("div",{className:"docx-ruler-indent",style:Vp(n,sr*2,r),onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onKeyDown:n.onKeyDown,...$p(n),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${sr}px solid transparent`,borderRight:`${sr}px solid transparent`,...e==="down"?{top:0,borderTop:`${lr}px solid ${o}`}:{bottom:0,borderBottom:`${lr}px solid ${o}`},transition:"border-color 0.1s"}})})}function cx(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Vp(e,sr*2,{top:co+1,height:Cs}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...$p(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:sr*2-2,height:Cs,backgroundColor:zp(e),borderRadius:1,transition:"background-color 0.1s"}})})}function dx({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:qe(t),top:-22,transform:"translateX(-50%)",backgroundColor:"var(--doc-text)",color:"var(--doc-on-primary)",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var ux={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function px({tabMark:e,positionPx:t,onDoubleClick:n}){return jsx("div",{style:{position:"absolute",left:qe(t-5),top:co-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:o=>{o.stopPropagation(),n();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:ux[e.alignment]||"L"})}function mx(e,t,n){let o=[];if(n==="inch"){let r=qp/8,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let l=i*r;if(l>e)break;let c=xe(l)*t;i%8===0?o.push({position:c,height:8,label:i/8>0?String(i/8):void 0}):i%4===0?o.push({position:c,height:5}):i%2===0?o.push({position:c,height:3}):o.push({position:c,height:2});}}else {let r=Kp/10,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let l=i*r;if(l>e)break;let c=xe(l)*t;i%10===0?o.push({position:c,height:8,label:i/10>0?String(i/10):void 0}):i%5===0?o.push({position:c,height:5}):o.push({position:c,height:3});}}return o}var bx=15840,Gp=1440,hx=1440,vx=567,Wo=20,yx="var(--doc-text-muted)",xx="var(--doc-text-subtle)",Tx="var(--doc-primary)",Sx="var(--doc-primary)",Cx="var(--doc-primary-hover)";function cr({pageSetup:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,onMarginDragEnd:a,unit:i="inch",className:l="",style:c}){let{t:s}=_(),[d,u]=useState(null),[m,g]=useState(null),p=useRef(null),f=e?.pageHeightTwips??bx,b=e?.marginsTwips.top??Gp,h=e?.marginsTwips.bottom??Gp,P=xe(f)*t,x=xe(b)*t,C=xe(h)*t,v=useCallback((E,D)=>{n&&(E.preventDefault(),u(D));},[n]),y=useCallback(E=>{if(!d||!p.current)return;let D=p.current.getBoundingClientRect(),F=E.clientY-D.top,H=ta(F/t);if(d==="topMargin"){let k=f-h-720,L=Math.max(0,Math.min(H,k));o?.(Math.round(L));}else if(d==="bottomMargin"){let k=f-H,L=f-b-720,R=Math.max(0,Math.min(k,L));r?.(Math.round(R));}},[d,t,f,b,h,o,r]),T=useCallback(()=>{d!==null&&a?.(),u(null);},[d,a]);useEffect(()=>{if(d)return document.addEventListener("mousemove",y),document.addEventListener("mouseup",T),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",T);}},[d,y,T]);let M=Ex(f,t,i),w={position:"relative",width:Wo,height:qe(P),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...c};return jsxs("div",{ref:p,className:`docx-vertical-ruler ${l}`,style:w,role:"slider","aria-label":s("ruler.vertical"),"aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:M.map((E,D)=>jsx(Px,{tick:E},D))}),jsx(jp,{type:"topMargin",position:x,editable:n,isDragging:d==="topMargin",isHovered:m==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>v(E,"topMargin")}),jsx(jp,{type:"bottomMargin",position:P-C,editable:n,isDragging:d==="bottomMargin",isHovered:m==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>v(E,"bottomMargin")})]})}function Px({tick:e}){let t={position:"absolute",top:qe(e.position),right:0,height:1,width:e.width,backgroundColor:xx},n={position:"absolute",top:qe(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:yx,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function jp({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:a,onMouseLeave:i,onMouseDown:l}){let{t:c}=_(),s=o?Cx:r?Sx:Tx,d={position:"absolute",top:qe(t-5),right:0,width:Wo,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},u={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${s}`,transition:"border-right-color 0.1s"};return jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:d,onMouseEnter:a,onMouseLeave:i,onMouseDown:l,role:"slider","aria-label":c(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:u})})}function Ex(e,t,n){let o=[];if(n==="inch"){let r=hx/8,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let l=i*r;if(l>e)break;let c=xe(l)*t;if(i%8===0){let s=i/8;o.push({position:c,width:10,label:s>0?String(s):void 0});}else i%4===0?o.push({position:c,width:6}):i%2===0?o.push({position:c,width:4}):o.push({position:c,width:2});}}else {let r=vx/10,a=Math.ceil(e/r);for(let i=0;i<=a;i++){let l=i*r;if(l>e)break;let c=xe(l)*t;if(i%10===0){let s=i/10;o.push({position:c,width:10,label:s>0?String(s):void 0});}else i%5===0?o.push({position:c,width:6}):o.push({position:c,width:3});}}return o}var po=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var Rx=e=>e.formatting?.indent??null,Ix=e=>e.editable;function ws(){let e=A(),t=B(Rx),n=B(Ix),o=useMemo(()=>n&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,n]),r=useCallback(a=>e?e.exec({...a.left!==void 0?{left:a.left}:{},...a.right!==void 0?{right:a.right}:{},...a.firstLine!==void 0?{firstLine:a.firstLine}:{},type:"setIndent"}).ok:false,[e]);return useMemo(()=>({indent:t,isEnabled:o,apply:r}),[t,o,r])}var em=e=>e.zoom;function tm(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function om(){let{apply:e}=ao(),[t,n]=useState({}),o=useRef({}),r=useCallback(i=>l=>{o.current={...o.current,[i]:Math.round(l)},n(o.current);},[]),a=useCallback(()=>{let i=o.current;o.current={},n({}),Object.keys(i).length!==0&&e({...i.top!==void 0?{marginTopTwips:i.top}:{},...i.right!==void 0?{marginRightTwips:i.right}:{},...i.bottom!==void 0?{marginBottomTwips:i.bottom}:{},...i.left!==void 0?{marginLeftTwips:i.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:a}}function Jp(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function _x(){let e=A(),{indent:t,isEnabled:n,apply:o}=ws(),[r,a]=useState(null),i=useRef(null),l=useRef(null),c=useCallback(u=>{l.current===null&&(l.current=Jp(e)),i.current=u,a(u);},[e]),s=useCallback(()=>{let u=i.current,m=l.current;i.current=null,l.current=null,a(null),u&&(m!==null&&m!==Jp(e)||o({left:u.left,right:u.right,firstLine:u.firstLine}));},[e,o]),d=useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine}:null),[r,t]);return useMemo(()=>({indent:d,isEnabled:n,preview:c,commit:s}),[d,n,c,s])}function Dx(){let e=Ct(),[t,n]=useState(0);return useEffect(()=>{if(!e){n(0);return}let o=()=>n(e.scrollLeft);return o(),e.addEventListener("scroll",o,{passive:true}),()=>e.removeEventListener("scroll",o)},[e]),t}function Ka(e){let t=B(po),{pageSetup:n,isEnabled:o}=ao(),r=B(em),{pending:a,preview:i,commit:l}=om(),c=_x(),s=oo(),d=Fo(),u=Dx();return t?null:jsx("div",{className:"docx-ruler-frame",style:{paddingInlineStart:s+d.inlineStart,paddingRight:d.inlineEnd},children:jsx(uo,{pageSetup:tm(n,a),zoom:r,editable:o,onLeftMarginChange:i("left"),onRightMarginChange:i("right"),onMarginDragEnd:l,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-u}px)`,clipPath:s>0&&u>0?`inset(0 0 0 ${u}px)`:e.style?.clipPath}})})}function za(e){let t=B(po),{pageSetup:n,isEnabled:o}=ao(),r=B(em),{pending:a,preview:i,commit:l}=om(),c=oo(),s=Fo(),d=gd();return t||d!==null&&d>0&&n&&xe(n.pageWidthTwips)*r>d-c-s.inlineStart-s.inlineEnd?null:jsx(cr,{pageSetup:tm(n,a),zoom:r,editable:o,onTopMarginChange:i("top"),onBottomMarginChange:i("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function N({size:e=20,className:t="",style:n,children:o}){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...n},"aria-hidden":"true",children:o})}function Lx(e){return jsx(N,{...e,children:jsx("path",{d:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"})})}function Hx(e){return jsx(N,{...e,children:jsx("path",{d:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"})})}function Fx(e){return jsx(N,{...e,children:jsx("path",{d:"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"})})}function Ax(e){return jsx(N,{...e,children:jsx("path",{d:"M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function Ox(e){return jsx(N,{...e,children:jsx("path",{d:"M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function Zx(e){return jsx(N,{...e,children:jsx("path",{d:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"})})}function Bx(e){return jsx(N,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function qx(e){return jsx(N,{...e,children:jsx("path",{d:"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"})})}function Kx(e){return jsx(N,{...e,children:jsx("path",{d:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"})})}function zx(e){return jsx(N,{...e,children:jsx("path",{d:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"})})}function Vx(e){return jsx(N,{...e,children:jsx("path",{d:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"})})}function $x(e){return jsx(N,{...e,children:jsx("path",{d:"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"})})}function Wx(e){return jsx(N,{...e,children:jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function Ux(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function Gx(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function jx(e){return jsx(N,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function Yx(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function ks(e){return jsx(N,{...e,children:jsx("path",{d:"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"})})}function Xx(e){return jsx(N,{...e,children:jsx("path",{d:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"})})}function Qx(e){return jsx(N,{...e,children:jsx("path",{d:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"})})}function Jx(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function eT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function tT(e){return jsx(N,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function oT(e){return jsx(N,{...e,children:jsx("path",{d:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"})})}function nT(e){return jsx(N,{...e,children:jsx("path",{d:"M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"})})}function rT(e){return jsx(N,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function aT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"})})}function iT(e){return jsx(N,{...e,children:jsx("path",{d:"M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"})})}function lT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"})})}function sT(e){return jsx(N,{...e,children:jsx("path",{d:"M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"})})}function cT(e){return jsx(N,{...e,children:jsx("path",{d:"M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"})})}function nm(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function dT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"})})}function uT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"})})}function pT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function mT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function fT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function gT(e){return jsx(N,{...e,children:jsx("path",{d:"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"})})}function bT(e){return jsx(N,{...e,children:jsx("path",{d:"M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"})})}function hT(e){return jsx(N,{...e,children:jsx("path",{d:"m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"})})}function vT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function yT(e){return jsx(N,{...e,children:jsx("path",{d:"M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"})})}function xT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"})})}function TT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function ST(e){return jsx(N,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function CT(e){return jsx(N,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function PT(e){return jsx(N,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function ET(e){return jsx(N,{...e,children:jsx("path",{d:"M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function wT(e){return jsx(N,{...e,children:jsx("path",{d:"M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"})})}function MT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function RT(e){return jsx(N,{...e,children:jsx("path",{d:"M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"})})}function IT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})})}function kT(e){return jsx(N,{...e,children:jsx("path",{d:"M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"})})}function _T(e){return jsx(N,{...e,children:jsx("path",{d:"M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"})})}function DT(e){return jsx(N,{...e,children:jsx("path",{d:"M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"})})}function NT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"})})}function LT(e){return jsx(N,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function HT(e){return jsx(N,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function FT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function AT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function OT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function ZT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"})})}function BT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h720v60H120Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function qT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-720h60v720h-60Zm165 0v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function KT(e){return jsx(N,{...e,children:jsx("path",{d:"M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})})}function zT(e){return jsx(N,{...e,children:jsx("path",{d:"M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"})})}function VT(e){return jsx(N,{...e,children:jsx("path",{d:"M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"})})}function $T(e){return jsx(N,{...e,children:jsx("path",{d:"M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"})})}function WT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function UT(e){return jsx(N,{...e,children:jsx("path",{d:"m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"})})}function GT(e){return jsx(N,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"})})}function jT(e){return jsx(N,{...e,children:jsx("path",{d:"m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"})})}function YT(e){return jsx(N,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function XT(e){return jsx(N,{...e,children:jsx("path",{d:"M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"})})}function QT(e){return jsx(N,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function JT(e){return jsx(N,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function eS(e){return jsx(N,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function tS(e){return jsx(N,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function oS(e){return jsx(N,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function nS(e){return jsx(N,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function rS(e){return jsx(N,{...e,children:jsx("path",{d:"M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"})})}function aS(e){return jsx(N,{...e,children:jsx("path",{d:"M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"})})}function iS(e){return jsx(N,{...e,children:jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm320-60q66 0 113-37t47-93q0-29-13-58t-34-55q-21-26-50-49t-50-31q-21 8-50 31t-50 49q-21 26-34 55t-13 58q0 56 47 93t140 37Z"})})}function lS(e){return jsx(N,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function sS(e){return jsx(N,{...e,children:jsx("path",{d:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"})})}function cS(e){return jsx(N,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function dS(e){return jsx(N,{...e,children:jsx("path",{d:"M268-240 42-466l57-56 170 170 56 56-57 56Zm226 0L268-466l56-57 170 170 368-368 57 57-425 424Zm0-226-57-56 198-198 57 56-198 198Z"})})}function uS(e){return jsx(N,{...e,children:jsx("path",{d:"m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"})})}function pS(e){return jsx(N,{...e,children:jsx("path",{d:"M80-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"})})}function mS(e){return jsxs(N,{...e,children:[jsx("path",{d:"M80-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"}),jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function fS(e){return jsx(N,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function gS(e){return jsx(N,{...e,children:jsx("path",{d:"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"})})}function bS(e){return jsx(N,{...e,children:jsx("path",{d:"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"})})}function hS(e){return jsx(N,{...e,children:jsx("path",{d:"M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-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"})})}function vS(e){return jsx(N,{...e,children:jsx("path",{d:"M160-400h280v-80H160v80Zm0-160h440v-80H160v80Zm0-160h440v-80H160v80Zm360 360v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"})})}function yS(e){return jsx(N,{...e,children:jsx("path",{d:"M240-400h122l200-200q9-9 13.5-20.5T580-643q0-11-5-21.5T562-684l-36-38q-9-9-20-13.5t-23-4.5q-11 0-22.5 4.5T440-722L240-522v122Zm280-243-37-37 37 37ZM300-460v-38l101-101 20 18 18 20-101 101h-38Zm121-121 18 20-38-38 20 18Zm26 181h273v-80H527l-80 80ZM80-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"})})}function xS(e){return jsx(N,{...e,children:jsx("path",{d:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Zm0-300Zm0 220q113 0 207.5-59.5T832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280Z"})})}function TS(e){return jsx(N,{...e,children:jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"})})}function SS(e){return jsx(N,{...e,children:jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"})})}function CS(e){return jsx(N,{...e,children:jsx("path",{d:"m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z"})})}var PS={undo:Lx,redo:Hx,print:Fx,file_download:Ax,file_upload:Ox,format_bold:Zx,format_italic:Bx,format_underlined:qx,strikethrough_s:Kx,superscript:zx,subscript:Vx,link:$x,format_clear:Wx,format_align_left:Ux,format_align_center:Gx,format_align_right:jx,format_align_justify:Yx,format_line_spacing:ks,format_list_bulleted:Xx,format_list_numbered:Qx,format_indent_increase:Jx,format_indent_decrease:eT,format_color_text:tT,ink_highlighter:oT,format_color_reset:nT,arrow_drop_down:rT,table:aT,table_chart:iT,grid_on:lT,table_rows:sT,view_column:cT,border_all:nm,select_all:nm,border_outer:dT,border_inner:uT,border_clear:pT,add:mT,remove:fT,delete:gT,delete_sweep:bT,call_merge:hT,call_split:vT,drag_indicator:yT,image:xT,format_image_left:TT,format_image_right:ST,horizontal_rule:CT,flip_to_back:PT,flip_to_front:ET,open_with:wT,tune:MT,rotate_right:RT,rotate_left:IT,swap_horiz:kT,swap_vert:_T,shapes:DT,format_paint:NT,expand_more:LT,expand_less:HT,border_top:FT,border_bottom:AT,border_left:OT,border_right:ZT,border_horizontal:BT,border_vertical:qT,padding:KT,text_rotation_none:zT,wrap_text:VT,height:$T,fit_width:WT,settings:UT,border_color:GT,format_color_fill:jT,vertical_align_top:YT,vertical_align_center:XT,vertical_align_bottom:QT,line_weight:JT,keyboard_arrow_up:eS,keyboard_arrow_down:tS,keyboard_arrow_left:oS,keyboard_arrow_right:nS,more_vert:rS,page_break:aS,branding_watermark:iS,arrow_back:lS,search:sS,toc:cS,done_all:dS,check_circle:uS,chat_bubble_outline:pS,chat_bubble_check:mS,check:fS,close:gS,add_comment:bS,comment:hS,edit_note:vS,rate_review:yS,visibility:xS,format_textdirection_l_to_r:TS,format_textdirection_r_to_l:SS,"agent-sparkle":CS};function K({name:e,size:t=20,className:n="",style:o}){let r=PS[e];return r?jsx(r,{size:t,className:n,style:o}):(console.warn(`Icon not found: ${e}`),jsx("span",{className:n,style:{fontSize:t,width:t,height:t,...o},children:e}))}var dr=12,_s=240,am=16,IS=24,kS=dr+_s+am,Uo=12,_S=36,DS=Uo+_S+am,ur=Ye__default.memo(function({headings:t,onHeadingClick:n,onClose:o,topOffset:r=0,scrollLeft:a=0,leftOffset:i=dr}){let{t:l}=_(),[c,s]=useState(false),d=t.length?Math.min(...t.map(u=>u.level)):0;return useEffect(()=>{requestAnimationFrame(()=>s(true));},[]),jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:i-a,bottom:0,width:_s,paddingTop:IS,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:c?"translateX(0)":`translateX(-${i+_s}px)`,transition:"transform 0.15s ease-out"},onMouseDown:u=>u.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsx("button",{onClick:o,"aria-label":l("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:l("documentOutline.closeTitle"),children:jsx(K,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((u,m)=>jsx("div",{style:{marginLeft:(u.level-d)*16},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>n(u.blockId),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:u.text,children:u.text})},`${u.blockId}-${m}`))})]})});var HS=e=>e,FS=Object.freeze([]),AS=()=>{};function Ds(e){let t=A(),n=B(HS),o=useMemo(()=>t&&!n.isLoading?t.getOutline():FS,[t,n]),r=useCallback(a=>{if(!t)return;t.focus();let i={paragraphId:a,offset:0};t.exec({type:"setSelection",range:{anchor:i,head:i}}),t.scrollToBlock(a);},[t]);return po(n)?null:jsx(ur,{headings:o,onHeadingClick:r,onClose:e.onClose??AS,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Ns=createContext(null);function Zt(e){let t=useContext(Ns);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var Go=280,Va=32,im=16;function fo(e=280){return 32+e+16}function $a({viewportWidth:e,pageWidthPx:t,reservation:n,inlineEndReservation:o=0,inlineStartReservation:r=0,docked:a=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<0||!Number.isFinite(r)||r<0)return 0;let i=(e-o-t)/2,l=i>=n?0:!a&&n<=2*i?2*(n-i):n;return Math.ceil(Math.max(0,l-r))}var zS=Object.freeze([]),VS=e=>e;function Wa(){let e=A(),t=B(VS),[n,o]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():zS,[e,t]),a=useMemo(()=>{if(r.length===0)return [];let l=r[0].level;for(let c of r)c.level<l&&(l=c.level);return r.map(c=>({heading:c,depth:c.level-l}))},[r]),i=useCallback(l=>{if(!e||typeof l!="string"||l.length===0)return;e.focus();let c={paragraphId:l,offset:0};e.exec({type:"setSelection",range:{anchor:c,head:c}}),e.scrollToBlock(l),o(l);},[e]);return {headings:r,items:a,selectedBlockId:n,goTo:i,isEmpty:r.length===0}}var Fs=150,As=2e3,Hs=Object.freeze([]),US=e=>e;function Ua(){let e=A(),t=B(US),[n,o]=useState(""),[r,a]=useState(""),[i,l]=useState(false),[c,s]=useState(false),[d,u]=useState(Hs),[m,g]=useState(-1);useEffect(()=>{if(n===r)return;let y=setTimeout(()=>a(n),Fs);return ()=>clearTimeout(y)},[n,r]);let p=useMemo(()=>({matchCase:i,wholeWord:c}),[i,c]);useEffect(()=>{if(!e||r.length===0){u(Hs),g(-1);return}let y=e.findMatches(r,p);u(T=>T===y?T:y);},[e,r,p,t]);let f=useRef(d);useEffect(()=>{f.current!==d&&(f.current=d,g(y=>y>=0&&y<d.length?y:-1));},[d]);let b=useCallback(y=>{if(!e)return;let T=d[y];if(!T)return;e.focus(),e.selectMatch(T).ok&&g(y);},[e,d]),h=useCallback(y=>{if(d.length===0)return;let M=((m<0?y>0?-1:0:m)+y+d.length)%d.length;b(M);},[m,b,d.length]),P=useCallback(()=>h(1),[h]),x=useCallback(()=>h(-1),[h]),C=useCallback(y=>o(y),[]),v=useCallback(()=>{o(""),a(""),u(Hs),g(-1);},[]);return {query:n,setQuery:C,matchCase:i,setMatchCase:l,wholeWord:c,setWholeWord:s,matches:d,truncated:d.length>=As,activeIndex:m,goTo:b,next:P,previous:x,clear:v,isPending:n!==r}}var JS=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,zoom:e.zoom,reviewPaneOpen:e.reviewPaneOpen??true,fitting:t?.type==="fit"&&e.zoom<(t.maxZoom??ZOOM_MAX)&&e.zoom>(t.minZoom??ZOOM_MIN)}},eC=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Ga(e={}){let{defaultOpen:t=false,defaultTab:n="headings",paneWidth:o=280}=e,[r,a]=useState(t),[i,l]=useState(n),c=e.open??r,s=e.tab??i,{onOpenChange:d,onTabChange:u}=e,m=e.open!==void 0,g=e.tab!==void 0,p=useCallback(I=>{m||a(I),d?.(I);},[m,d]),f=useCallback(()=>p(!c),[c,p]),b=useCallback(I=>{g||l(I),u?.(I);},[g,u]),h=to(),P=Ct(),x=useContext(at),{pageSetup:C,zoom:v,reviewPaneOpen:y,fitting:T}=B(JS,eC),[M,w]=useState(0),[E,D]=useState(0),[F,H]=useState(0);useEffect(()=>{if(!P){w(0),D(0),H(0);return}let I=()=>{w(P.clientWidth);let Z=getComputedStyle(P),V=Number.parseFloat(Z.paddingInlineEnd);D(Number.isFinite(V)?V:0);let j=Number.parseFloat(Z.getPropertyValue("--docx-review-gutter-start"));H(Number.isFinite(j)?j:0);};if(I(),typeof ResizeObserver>"u")return;let z=new ResizeObserver(I);return z.observe(P),()=>z.disconnect()},[P,c,y,x?.mounted]);let k=useRef(null);C&&(k.current=C.pageWidthTwips);let L=C?.pageWidthTwips??k.current,R=useMemo(()=>!c||L===null?0:$a({viewportWidth:M,pageWidthPx:xe(L)*v,reservation:fo(o),inlineEndReservation:E,inlineStartReservation:F,docked:T}),[c,L,v,M,o,E,F,T]);return useEffect(()=>{if(h)return h.setShift(R),()=>h.setShift(0)},[h,R]),useEffect(()=>{if(h)return h.setReservation(c?fo(o):0),()=>h.setReservation(0)},[h,c,o]),{open:c,setOpen:p,toggle:f,tab:s,setTab:b,paneWidth:o,shift:R}}var mr=["headings","find"],ht=(...e)=>e.filter(Boolean).join(" ");function fr({className:e,style:t,children:n}){return jsx("div",{className:ht("docx-nav__header",e),style:t,children:n??jsxs(Fragment,{children:[jsx(gr,{}),jsx(br,{})]})})}function gr({className:e,style:t,children:n}){let{pane:o,t:r}=Zt("Close");return jsx("button",{type:"button",className:ht("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>o.setOpen(false),children:n??jsx(K,{name:"arrow_back",size:20})})}function br({className:e,style:t,children:n}){let{t:o}=Zt("Title");return jsx("h2",{className:ht("docx-nav__title",e),style:t,children:n??o("navigation.title")})}function hr({className:e,style:t,children:n}){let{pane:o,t:r}=Zt("Tabs"),a=useCallback(i=>{let l=i.key==="ArrowRight"?1:i.key==="ArrowLeft"?-1:0;if(l===0)return;i.preventDefault();let c=mr.indexOf(o.tab);o.setTab(mr[(c+l+mr.length)%mr.length]);},[o]);return jsx("div",{className:ht("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:a,children:n??mr.map(i=>jsx(vr,{value:i},i))})}function vr({value:e,className:t,style:n,children:o}){let{pane:r,t:a}=Zt("Tab"),i=r.tab===e;return jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":i,"aria-controls":`docx-nav-panel-${e}`,tabIndex:i?0:-1,className:ht("docx-nav__tab",i&&"docx-nav__tab--selected",t),style:n,onClick:()=>r.setTab(e),children:o??a(`navigation.tabs.${e}`)})}function sm({value:e,onChange:t,onClear:n,placeholder:o,label:r,clearLabel:a,autoFocus:i}){return jsxs("div",{className:"docx-nav__searchbox",children:[jsx(K,{name:"search",size:18,className:"docx-nav__search-icon"}),jsx("input",{type:"search",className:"docx-nav__search-input",value:e,placeholder:o,"aria-label":r,autoFocus:i,onChange:l=>t(l.target.value)}),e.length>0&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":a,onClick:n,children:jsx(K,{name:"close",size:16})})]})}function yr({className:e,style:t}){let{pane:n,outline:o,t:r}=Zt("Headings"),[a,i]=useState(""),l=B(po),c=useMemo(()=>{let d=a.trim().toLowerCase();return d.length===0?o.items:o.items.filter(u=>u.heading.text.toLowerCase().includes(d))},[o.items,a]),s=n.tab!=="headings";return jsxs("div",{className:ht("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:s,children:[jsx(sm,{value:a,onChange:i,onClear:()=>i(""),placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),l?null:o.isEmpty?jsx("p",{className:"docx-nav__empty",children:r("navigation.headings.noHeadings")}):c.length===0?jsx("p",{className:"docx-nav__empty",children:r("navigation.find.noResults")}):jsx("ul",{className:"docx-nav__list",children:c.map((d,u)=>jsx("li",{children:jsx("button",{type:"button",className:ht("docx-nav__heading",o.selectedBlockId===d.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+d.depth*14}px`},title:d.heading.text,onClick:()=>o.goTo(d.heading.blockId),children:d.heading.text})},`${d.heading.blockId}-${u}`))})]})}function rC({match:e,active:t,onSelect:n}){return jsx("li",{children:jsx("button",{type:"button",className:ht("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:n,children:jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function xr({className:e,style:t}){let{pane:n,search:o,t:r}=Zt("Find"),a=n.tab!=="find",i=o.query.trim().length>0,l=o.matches.length===0?null:o.activeIndex<0?r(o.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:o.matches.length}):r(o.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:o.activeIndex+1,total:o.matches.length});return jsxs("div",{className:ht("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsx(sm,{value:o.query,onChange:o.setQuery,onClear:o.clear,placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),jsxs("div",{className:"docx-nav__options",role:"group","aria-label":r("navigation.find.optionsAriaLabel"),children:[jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:o.matchCase,onChange:c=>o.setMatchCase(c.target.checked)}),r("navigation.find.matchCase")]}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:o.wholeWord,onChange:c=>o.setWholeWord(c.target.checked)}),r("navigation.find.wholeWord")]})]}),jsxs("div",{className:"docx-nav__resultbar",children:[jsx("span",{className:"docx-nav__count","aria-live":"polite",children:i?o.isPending?r("navigation.find.searching"):l??r("navigation.find.noResults"):""}),jsxs("span",{className:"docx-nav__steppers",children:[jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.previousAriaLabel"),disabled:o.matches.length===0,onClick:o.previous,children:jsx(K,{name:"keyboard_arrow_up",size:18})}),jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.nextAriaLabel"),disabled:o.matches.length===0,onClick:o.next,children:jsx(K,{name:"keyboard_arrow_down",size:18})})]})]}),o.matches.length>0&&jsx("ul",{className:"docx-nav__list","aria-label":r("navigation.find.resultsAriaLabel"),children:o.matches.map((c,s)=>jsx(rC,{match:c,active:s===o.activeIndex,onSelect:()=>o.goTo(s)},`${c.blockId}-${c.start}-${s}`))})]})}function Tr({className:e,style:t,children:n}){let{pane:o,t:r}=Zt("Toggle");return jsx("button",{type:"button",className:ht("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":o.open,title:r("navigation.openTitle"),onMouseDown:a=>a.preventDefault(),onClick:o.toggle,children:n??jsx(K,{name:"toc",size:20})})}function Bs(e){let t=je(),{t:n,toggle:o=true,className:r,style:a,children:i,...l}=e,c=Ga(l),s=Wa(),d=Ua(),{t:u}=_(),m=useMemo(()=>({pane:c,outline:s,search:d,t:n??((p,f)=>u(p,f))}),[c,s,d,n,u]),g=e.paneWidth??280;return jsx(Ns.Provider,{value:m,children:jsxs("div",{className:`${t}docx-nav${c.open?" docx-nav--open":""}${r?` ${r}`:""}`,"data-open":c.open?"true":"false",style:{"--docx-nav-width":`${g}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${fo(g)}px`,...a},children:[o!==false&&!c.open&&jsx(Tr,{...typeof o=="object"?o:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":m.t("navigation.ariaLabel"),inert:!c.open,children:i??jsxs(Fragment,{children:[jsx(fr,{}),jsx(hr,{}),jsx(yr,{}),jsx(xr,{})]})})]})})}var ja=Object.assign(Bs,{Header:fr,Close:gr,Title:br,Tabs:hr,Tab:vr,Headings:yr,Find:xr,Toggle:Tr});var uC=600,pC=e=>e.page.total,Ya=createContext(null);function Xa({className:e,style:t}){let n=je(),o=A(),r=Ct(),a=B(pC),{t:i}=_(),l=useContext(Ya),[c,s]=useState(1),[d,u]=useState(false);if(useEffect(()=>{if(u(false),!o||!r||a<=1)return;s(o.getCurrentPage("viewport"));let g=null,p=()=>{s(o.getCurrentPage("viewport")),u(true),g&&clearTimeout(g),g=setTimeout(()=>u(false),uC);};return r.addEventListener("scroll",p,{passive:true}),()=>{r.removeEventListener("scroll",p),g&&clearTimeout(g);}},[o,a,r]),a<=1)return null;let m=l?l("viewer.pageIndicator").replace(/\{current\}/g,String(c)).replace(/\{total\}/g,String(a)):i("viewer.pageIndicator",{current:c,total:a});return jsx("div",{className:`${n}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":d?"true":"false",role:"status","aria-live":"polite",children:m})}var gC=[],bC=e=>e.fontSubstitutions??gC;function Qa({className:e,style:t,t:n}){let o=B(bC),{t:r}=_(),a=n??r,[i,l]=useState(null);if(o.length===0)return null;let c=o.join("\0");return i===c?null:jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsx("span",{className:"docx-font-notice__text",children:a("editor.fontSubstitutionNotice",{fonts:o.join(", ")}).replace("{fonts}",o.join(", "))}),jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(c),children:a("common.dismiss")})]})}var Ve={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function qs(e){return Math.round(e/1440*100)/100}function pm(e){return Math.round(e*1440)}function yC(e,t){return e===t?true:!e||!t?false:e.editing===t.editing&&e.sectionIndex===t.sectionIndex&&e.variant===t.variant&&e.rId===t.rId&&e.partName===t.partName&&e.inherited===t.inherited&&e.titlePage===t.titlePage&&e.evenAndOddHeaders===t.evenAndOddHeaders&&e.headerDistanceTwips===t.headerDistanceTwips&&e.footerDistanceTwips===t.footerDistanceTwips}function Ks(){let e=A(),t=useCallback(n=>e?.getHeaderFooterState()??null,[e]);return B(t,yC)}function Ja(e,t,n){let o=e.getBoundingClientRect();return {left:t-o.left-e.clientLeft+e.scrollLeft,top:n-o.top-e.clientTop+e.scrollTop}}function Sr(e,t){let[n,o]=useState(null),r=useCallback(l=>o(l),[]),[a,i]=useState({visibility:"hidden"});return useLayoutEffect(()=>{let l=n?.closest(".docx-editor__scroll-container"),c=l??n?.parentElement?.querySelector(".docx-editor__scroll-container");if(!n||!c)return;let s=0,d=null,u=new ResizeObserver(()=>g()),m=()=>{s=0;let f=e(c);if(f!==d&&(u.disconnect(),u.observe(c),u.observe(n),f&&u.observe(f),d=f),!f||!f.isConnected){i({visibility:"hidden"});return}let b=f.getBoundingClientRect(),h=t==="story-label"?Math.max(n.offsetHeight,28):n.offsetHeight,P=t==="story-label"?6:4,x=l===c,C=t==="after"?b.bottom+6:b.top-h-P,v=x?Ja(c,b.left,C):{left:b.left,top:C},y=v.left,T=v.top,M=x?c.scrollLeft+8:8;i({position:x?"absolute":"fixed",left:t==="story-label"?y:Math.max(M,y+8),top:t==="story-label"?T:Math.max(x?c.scrollTop+8:8,T),...t==="story-label"?{width:Math.max(240,Math.min(b.width,c.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(b.width-16,c.clientWidth-16))},visibility:"visible"});},g=()=>{s||(s=requestAnimationFrame(m));};u.observe(c),u.observe(n);let p=new MutationObserver(g);return p.observe(c,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),c.addEventListener("scroll",g,{passive:true}),window.addEventListener("resize",g),m(),()=>{s&&cancelAnimationFrame(s),u.disconnect(),p.disconnect(),c.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[n,e,t]),{ref:r,style:a}}function PC(e,t){return t==="first"?e==="header"?"headerFooter.firstPageHeader":"headerFooter.firstPageFooter":t==="even"?e==="header"?"headerFooter.evenPageHeader":"headerFooter.evenPageFooter":e==="header"?"headerFooter.header":"headerFooter.footer"}var EC=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Cr(e){let t=A();return useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let n=t.can(e);return n.ok?{enabled:true,reason:null}:{enabled:false,reason:n.reason}},[t,e])}function wC(e){let{state:t,onMouseDown:n}=e,{t:o}=_(),r=A(),[a,i]=useState(false),l=useRef(null),[c,s]=useState(""),[d,u]=useState("");useEffect(()=>{a&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(s(String(qs(t.headerDistanceTwips))),u(String(qs(t.footerDistanceTwips)))));},[a,t.headerDistanceTwips,t.footerDistanceTwips]),useEffect(()=>{if(!a)return;let T=M=>{l.current?.contains(M.target)||i(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[a]);let m=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),b=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),h=Cr(m),P=Cr(g),x=Cr(p),C=Cr(f),v=Cr(b),y=(T,M)=>{if(!r)return;let w=Number.parseFloat(M);Number.isFinite(w)&&r.exec({type:"setHeaderFooterOptions",[T]:pm(w)});};return jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:n,children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":a,"aria-haspopup":"menu",onClick:()=>i(T=>!T),onMouseDown:n,children:o("headerFooter.options")}),a?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:n,children:[EC.map(T=>{let M={type:"insertPageField",field:T.field},w=r?.can(M);return jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!w?.ok,title:w&&!w.ok?w.reason:void 0,onClick:()=>{r?.exec(M),i(false);},onMouseDown:n,children:o(T.labelKey)},T.field)}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!h.enabled,title:h.reason??void 0,onChange:()=>r?.exec(m)}),jsx("span",{children:o("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!P.enabled,title:P.reason??void 0,onChange:()=>r?.exec(g)}),jsxs("span",{children:[o("headerFooter.differentOddEven"),jsx("span",{className:"docx-hf-chrome__menu-hint",children:o("headerFooter.differentOddEvenHint")})]})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>r?.exec(f),onMouseDown:n,children:o("headerFooter.unlinkFromPrevious")}):jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!x.enabled,title:x.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:n,children:o("headerFooter.linkToPrevious")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:o("headerFooter.headerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":o("headerFooter.headerDistance"),value:c,onChange:T=>s(T.target.value),onBlur:()=>y("headerDistanceTwips",c)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:o("headerFooter.footerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":o("headerFooter.footerDistance"),value:d,onChange:T=>u(T.target.value),onBlur:()=>y("footerDistanceTwips",d)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!v.enabled,title:v.reason??void 0,onClick:()=>r?.exec(b),onMouseDown:n,children:t.editing==="header"?o("headerFooter.removeHeader"):o("headerFooter.removeFooter")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-hf-close",onClick:()=>{r?.exec({type:"exitHeaderFooter"}),i(false);},onMouseDown:n,children:o("common.close")})]}):null]})}function ei({className:e}){let{t}=_(),n=Ks(),o=useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=Sr(o,"story-label"),a=O;if(!n?.editing)return null;let i=PC(n.editing,n.variant);return jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:a,style:{...r.style,zIndex:Ve.hfInlineEditor},children:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(i)}),n.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsx(wC,{state:n,onMouseDown:a})]})}function ho(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ti=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),NC="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",LC="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",HC="M770-302 656-416l57-57 114 114-57 57ZM603-469 469-603l57-57 134 134-57 57ZM280-280h133v80H280q-83 0-141.5-58.5T80-400q0-83 58.5-141.5T280-600h133v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35Zm40-80v-80h101l80 80H320Zm493-15-57-57q23-11 33.5-32t10.5-36q0-50-35-85t-85-35H547v-80h133q83 0 141.5 58.5T880-400q0 32-11 61.5T813-375ZM792-56 56-792l56-56 736 736-56 56Z",FC="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z";function AC({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let a=vt(),i=useRef(null),{state:l,close:c}=a;useEffect(()=>{if(l.mode==="closed")return;let f=h=>{h.key==="Escape"&&(h.preventDefault(),c());},b=h=>{let P=i.current;P&&h.target instanceof Node&&P.contains(h.target)||c();};return document.addEventListener("keydown",f),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",b,true);}},[l.mode,c]);let[s,d]=useState(null);useLayoutEffect(()=>{let f=l.anchor,b=i.current;if(!f||!b){d(null);return}let h=b.offsetParent;if(!h){d(null);return}let{left:P,top:x}=Ja(h,f.left,f.top),C=Math.max(0,h.scrollWidth-b.offsetWidth);d({left:Math.max(0,Math.min(P,C)),top:x});},[l.anchor]);let{t:u}=_(),m=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),g=r?jsx(OC,{children:o}):o;if(n)return l.mode==="closed"?null:jsx(Fragment,{children:o});let p={ref:i,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:ho,style:s??void 0,"aria-label":m};return l.mode==="closed"?null:t?jsx(W,{...p,children:o}):jsx("div",{...p,children:g})}function OC({children:e}){let{state:t}=vt(),n=useMemo(()=>ZC(e),[e]),o=(a,i)=>a in n?n[a]:i;if(t.mode==="editing")return jsxs(Fragment,{children:[o("Fields",jsx(js,{})),o("Error",jsx(Xs,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Apply",jsx(Ys,{})),o("Cancel",jsx(Qs,{}))]}),n.__extra]});let r=t.canEdit&&!(t.link&&xn(t.link));return jsxs(Fragment,{children:[o("Url",jsx($s,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Copy",jsx(Ws,{})),r?o("Edit",jsx(Us,{})):null,r?o("Unlink",jsx(Gs,{})):null]}),n.__extra]})}function ZC(e){let t={},n=[],o=r=>{if(Array.isArray(r)){r.forEach(o);return}if(!r||typeof r!="object"||!("type"in r)){r&&n.push(r);return}if(r.type===Fragment$1){o(r.props.children);return}let a=r.type.docxHyperLinkPart;a?t[a]=r:n.push(r);};return o(e),n.length>0&&(t.__extra=n),t}function vt(){return useContext(Tn)??BC}var BC={state:{mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:false},open:()=>{},openAtCaret:()=>{},close:()=>{},copy:async()=>false,beginEdit:()=>{},setText:()=>{},setUrl:()=>{},commitEdit:()=>false,unlink:()=>false,openTarget:()=>false};function $s({className:e,asChild:t,hidden:n,children:o}){let{state:r,openTarget:a}=vt(),{t:i}=_();if(n||!r.link)return null;let l=!r.link.href,c=r.link.kind==="internal",s=c?`#${r.link.anchor??""}`:r.link.authored,d=i(l?"hyperlinkPopup.inertTarget":c?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),u={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:ho,...l?{}:{onClick:()=>a(),type:"button"}};return t?jsx(W,{...u,children:o}):l?jsxs("span",{...u,children:[o??s,jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxs("button",{...u,children:[o??s,ti(FC)]})}$s.docxHyperLinkPart="Url";function Ws({className:e,asChild:t,hidden:n,children:o,icon:r}){let{state:a,copy:i}=vt(),{t:l}=_();if(n||!a.link?.href)return null;let c=a.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...a.copied?{"data-copied":""}:{},"aria-label":c,title:c,onMouseDown:ho,onClick:()=>{i();}};return t?jsx(W,{...s,children:o}):jsx("button",{...s,children:r??o??ti(NC)})}Ws.docxHyperLinkPart="Copy";function Us({className:e,asChild:t,hidden:n,children:o,icon:r}){let{beginEdit:a}=vt(),{t:i}=_();if(n)return null;let l=i("hyperlinkPopup.editLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:ho,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:r??o??ti(LC)})}Us.docxHyperLinkPart="Edit";function Gs({className:e,asChild:t,hidden:n,children:o,icon:r}){let{unlink:a}=vt(),{t:i}=_();if(n)return null;let l=i("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:ho,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:r??o??ti(HC)})}Gs.docxHyperLinkPart="Unlink";function js({className:e,hidden:t}){let{state:n,setText:o,setUrl:r,commitEdit:a,close:i}=vt(),{t:l}=_(),c=useRef(null),s=useId(),d=useId();useEffect(()=>{n.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[n.mode]);let u=useCallback(m=>{if(m.key==="Enter"){m.preventDefault(),a();return}m.key==="Escape"&&(m.preventDefault(),i());},[a,i]);return t?null:jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:s,children:l("hyperlinkPopup.displayTextPlaceholder")}),jsx("input",{id:s,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:n.text,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onChange:m=>o(m.target.value),onKeyDown:u}),jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:l("hyperlinkPopup.urlPlaceholder")}),jsx("input",{id:d,ref:c,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:n.url,placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:m=>r(m.target.value),onKeyDown:u})]})}js.docxHyperLinkPart="Fields";function Ys({className:e,asChild:t,hidden:n,children:o}){let{state:r,commitEdit:a}=vt(),{t:i}=_();if(n)return null;let l=i("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:ho,onClick:()=>a()};return t?jsx(W,{...c,children:o}):jsx("button",{...c,children:o??l})}function Xs({className:e,hidden:t}){let{state:n}=vt(),{t:o}=_();return t||!n.error?null:jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:o("hyperlinkPopup.refused")})}Xs.docxHyperLinkPart="Error";Ys.docxHyperLinkPart="Apply";function Qs({className:e,asChild:t,hidden:n,children:o}){let{close:r}=vt(),{t:a}=_();if(n)return null;let i=a("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:ho,onClick:()=>r()};return t?jsx(W,{...l,children:o}):jsx("button",{...l,children:o??i})}Qs.docxHyperLinkPart="Cancel";var oi=Object.assign(AC,{Url:$s,Copy:Ws,Edit:Us,Unlink:Gs,Fields:js,Error:Xs,Apply:Ys,Cancel:Qs});function qC(e,t){return e===t?true:!e||!t||e.kind!==t.kind?false:e.kind==="note"&&t.kind==="note"?e.id===t.id:e.kind==="headerFooter"&&t.kind==="headerFooter"?e.rId===t.rId:true}function Js(){let e=A(),t=useCallback(o=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),n=B(t,qC);return n?.kind==="note"?n:null}function vm(e,t){return e===t?true:!e||!t?false:e.pos===t.pos&&e.numFmt===t.numFmt&&e.numStart===t.numStart&&e.numRestart===t.numRestart}function ym(e,t){return e.resolved.pos===t.resolved.pos&&e.resolved.numFmt===t.resolved.numFmt&&e.resolved.numStart===t.resolved.numStart&&e.resolved.numRestart===t.resolved.numRestart&&vm(e.documentAuthored,t.documentAuthored)&&vm(e.sectionAuthored,t.sectionAuthored)}function KC(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&ym(e.footnote,t.footnote)&&ym(e.endnote,t.endnote)}function ec(){let e=A(),t=useCallback(n=>e?.getNotePropertiesState()??null,[e]);return B(t,KC)}var zC=/^(footnote|endnote):(-?\d{1,10})$/;function Tm(e){let t=zC.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isInteger(n)?{noteKind:t[1],noteId:n}:null}function VC(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function oc(e){let t=A();return useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let n=t.can(e);return n.ok?{enabled:true,reason:null}:{enabled:false,reason:n.reason}},[t,e])}function $C(e){let{t}=_(),[n,o]=useState(false),r=useRef(null);return useEffect(()=>{if(!n)return;let a=i=>{r.current?.contains(i.target)||o(false);};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]),jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":n,"aria-haspopup":"menu",onMouseDown:O,onClick:()=>o(a=>!a),children:t("headerFooter.options")}),n?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:O,children:[jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),o(false);},children:t("dialogs.footnoteProperties.title")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),o(false);},children:t("common.close")})]}):null]})}function ni({className:e}){let{t}=_(),n=A(),o=Js(),[r,a]=useState(null),[i,l]=useState(null),[c,s]=useState(false),d=useRef(null),u=useCallback(w=>{if(!o)return null;let D=[...w.querySelectorAll("[data-docx-note-scope]")].find(F=>F.matches("[data-docx-note]")&&F.dataset.docxNoteScope===o.id)??null;return D?.closest("[data-docx-notes]")??D},[o]),m=Sr(u,"story-label"),g=useCallback(()=>{d.current&&clearTimeout(d.current),d.current=null,a(null);},[]);useEffect(()=>{if(!n)return;let w=document.querySelector(".docx-pages");if(!w)return;let E=H=>{let k=H.target;if(!k)return;let L=k.closest("[data-docx-note-ref]");if(L?.dataset.docxNoteScope){H.preventDefault(),g(),l(null),n.setActiveScope({kind:"note",id:L.dataset.docxNoteScope});return}k.closest("[data-docx-note-mark-back]")&&(H.preventDefault(),g(),l(null),n.setActiveScope({kind:"body"}));},D=H=>{let k=H,R=k.target?.closest("[data-docx-note-scope]");R?.dataset.docxNoteScope&&(k.preventDefault(),l({scopeId:R.dataset.docxNoteScope,x:k.clientX,y:k.clientY}));},F=H=>{if(VC())return;let L=H.target?.closest("[data-docx-note-ref]");if(!L?.dataset.docxNoteScope){g();return}let R=L.dataset.docxNoteScope,z=n.getNotePreviewText(R)??L.getAttribute("aria-description")??t("notes.previewFallback"),Z=L.getBoundingClientRect();d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{a({scopeId:R,text:z,x:Z.left,y:Z.bottom+4});},400);};return w.addEventListener("click",E),w.addEventListener("contextmenu",D),w.addEventListener("pointerover",F),w.addEventListener("scroll",g,true),()=>{w.removeEventListener("click",E),w.removeEventListener("contextmenu",D),w.removeEventListener("pointerover",F),w.removeEventListener("scroll",g,true),g();}},[n,g,t]);let p=useCallback(w=>{n&&(n.exec(w),l(null));},[n]),f=i?Tm(i.scopeId):null,b=useMemo(()=>f?{type:"deleteNote",noteKind:f.noteKind,noteId:f.noteId}:null,[f]),h=useMemo(()=>f?{type:"convertNote",fromKind:f.noteKind,noteId:f.noteId}:null,[f]),P=useMemo(()=>f?{type:"convertAllNotes",fromKind:f.noteKind}:null,[f]),x=oc(b??{type:"deleteNote",noteKind:"footnote",noteId:0}),C=oc(h??{type:"convertNote",fromKind:"footnote",noteId:0}),v=oc(P??{type:"convertAllNotes",fromKind:"footnote"}),y=useMemo(()=>({position:"fixed",left:r?.x??0,top:r?.y??0,zIndex:Ve.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg, #fff)",color:"var(--doc-popover-fg, #111)",border:"1px solid var(--doc-border, #ddd)",boxShadow:"var(--doc-shadow, 0 4px 16px rgba(0,0,0,.12))",fontSize:12,lineHeight:1.4,pointerEvents:"none"}),[r]),T=o?Tm(o.id):null,M=T?t("notes.editingRegion",{kind:T.noteKind==="footnote"?t("notes.footnoteKind"):t("notes.endnoteKind"),number:T.noteId}):null;return n?jsxs("div",{className:e,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":o?void 0:true,children:[o&&T?jsxs("div",{ref:m.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":t("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":o.id,style:{...m.style,zIndex:Ve.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:M}),jsx($C,{onOpenProperties:()=>s(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,r?jsx("div",{role:"tooltip","data-testid":"docx-notes-preview",style:y,onMouseDown:w=>{w.preventDefault(),w.stopPropagation();},children:r.text}):null,i&&f?jsxs("div",{role:"menu","data-testid":"docx-notes-menu",style:{position:"fixed",left:i.x,top:i.y,zIndex:Ve.popover,minWidth:160,background:"var(--doc-popover-bg, #fff)",border:"1px solid var(--doc-border, #ddd)",boxShadow:"var(--doc-shadow, 0 4px 16px rgba(0,0,0,.12))",padding:4},onMouseDown:O,children:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!x.enabled,title:x.reason??void 0,onClick:()=>b&&p(b),children:t("notes.delete")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>h&&p(h),children:f.noteKind==="footnote"?t("notes.convertToEndnote"):t("notes.convertToFootnote")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!v.enabled,title:v.reason??void 0,onClick:()=>P&&p(P),children:f.noteKind==="footnote"?t("notes.convertAllFootnotes"):t("notes.convertAllEndnotes")}),jsx("button",{type:"button",role:"menuitem",onClick:()=>s(true),children:t("dialogs.footnoteProperties.title")})]}):null,c?jsx(WC,{onClose:()=>s(false),onApply:w=>{p(w),s(false);}}):null]}):null}function WC(e){let{t}=_(),n=A(),o=ec(),[r,a]=useState("document"),[i,l]=useState("decimal"),[c,s]=useState("continuous"),[d,u]=useState("pageBottom"),[m,g]=useState("decimal"),[p,f]=useState("continuous"),[b,h]=useState("docEnd");useEffect(()=>{o&&(l(o.footnote.resolved.numFmt),s(o.footnote.resolved.numRestart),u(o.footnote.resolved.pos),g(o.endnote.resolved.numFmt),f(o.endnote.resolved.numRestart),h(o.endnote.resolved.pos));},[o]);let P=!o?.footnote.documentAuthored&&!o?.footnote.sectionAuthored,x=!o?.endnote.documentAuthored&&!o?.endnote.sectionAuthored;return jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:Ve.modal},onClick:e.onClose,onKeyDown:C=>{C.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:C=>C.stopPropagation(),onMouseDown:C=>C.stopPropagation(),children:[jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxs("div",{className:"docx-note-properties__body",children:[jsxs("label",{className:"docx-note-properties__scope",children:[jsx("span",{children:t("notes.scope")}),jsxs("select",{className:"docx-note-properties__select",value:r,onChange:C=>a(C.target.value),children:[jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),P?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:i,onChange:C=>l(C.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:c,onChange:C=>s(C.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:d,onChange:C=>u(C.target.value),children:[jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),x?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:m,onChange:C=>g(C.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:p,onChange:C=>f(C.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:b,"data-testid":"docx-notes-endnote-position",onChange:C=>h(C.target.value),children:[jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxs("div",{className:"docx-note-properties__footer",children:[jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!n)return;let C={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?o?.sectionIndex:void 0,footnote:{numFmt:i,numRestart:c,position:d},endnote:{numFmt:m,numRestart:p,position:b}};n.can(C).ok&&e.onApply(C);},children:t("common.apply")})]})]})})}var ri=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function vo(){return useContext(ri)}function Pm(){return useContext(ri).target}var Em=["M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-560l-80-80 240-240h120v40L600-560ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6Zm-240 300q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z"],wm=["M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"],Mm=["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"],Rm=["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"],Im=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],km=["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],_m=["M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-120q-33 0-56.5-23.5T120-200h80v80Zm-80-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160q0-33 23.5-56.5T200-840v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"];function ai(e,t,n){return Object.assign(({icon:r,labelKey:a,shortcutKey:i,className:l,hidden:c})=>{let s=A(),{close:d}=vo(),u=_e(),{isEnabled:m,disabledReason:g}=ne(t);return c?null:jsx(Ne,{slot:e,icon:r??te(n.paths),shortcut:u(i??n.shortcutKey),disabled:!m,...g?{title:g}:{},onSelect:()=>{s?.exec(t),d(true);},...l?{className:l}:{},children:u(a??n.labelKey)})},{docxRow:e})}var Er=ai("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Em}),wr=ai("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:wm}),Mr=ai("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:Rm}),Rr=ai("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:_m});function Qo({icon:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let a=A(),{close:i,clipboardRefusal:l,reportClipboardRefusal:c}=vo(),s=_e(),d=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:m}=ne(d);if(r)return null;let g=l!==null;return jsx(Ne,{slot:"edit.paste",icon:e??te(Mm),shortcut:s(n??"contextMenu.pasteShortcut"),disabled:!u||g,...l??m?{title:l??m??""}:{},onSelect:()=>{(async()=>{try{let p=await navigator.clipboard.readText();p&&a?.exec({type:"paste",text:p});}catch(p){c(p instanceof Error?p.message:"the clipboard is not readable");}finally{i(true);}})();},...o?{className:o}:{},children:s(t??"contextMenu.paste")})}Qo.docxRow="edit.paste";function yo(e,t,n){return Object.assign(({icon:r,labelKey:a,className:i,hidden:l,destructive:c})=>{let{close:s}=vo(),d=_e(),u=ii(),{isEnabled:m,disabledReason:g,execute:p}=ne(t);return l||!u?null:jsx(Ne,{slot:e,icon:r??te(n.paths),disabled:!m,...g?{title:g}:{},className:`${c??n.destructive?"docx-table-chrome__destructive-row":""}${i?` ${i}`:""}`,onSelect:()=>{p()&&s(true);},children:d(a??n.labelKey)})},{docxRow:e})}var Jo=yo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),en=yo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),tn=yo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),on=yo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),nn=yo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),rn=yo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),an=yo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),jC=[{alignment:"top",labelKey:"tableAdvanced.top",icon:"vertical_align_top"},{alignment:"center",labelKey:"tableAdvanced.middle",icon:"vertical_align_center"},{alignment:"bottom",labelKey:"tableAdvanced.bottom",icon:"vertical_align_bottom"}];function xo({hidden:e}){let{close:t}=vo(),n=_e(),o=ii(),r=ne({type:"setTableCellVerticalAlignment",alignment:"top"}),a=ne({type:"setTableCellVerticalAlignment",alignment:"center"}),i=ne({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,a,i];return e||!o?null:jsxs("div",{className:"docx-contextmenu__table-align",children:[jsx("span",{className:"docx-contextmenu__table-align-label",children:n("tableAdvanced.verticalAlignment")}),jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":n("tableAdvanced.verticalAlignment"),children:jC.map((c,s)=>{let d=l[s];return jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":n(c.labelKey),title:d.disabledReason??n(c.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:u=>{u.preventDefault(),u.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:te(tableChromeIconPaths(c.icon))},c.alignment)})})]})}xo.docxRow="table.cellVerticalAlignment";function Nm(e,t,n){return Object.assign(({icon:r,labelKey:a,className:i,hidden:l})=>{let c=A(),{close:s,tocId:d}=vo(),u=_e(),m=useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=ne(m);return l||d===null?null:jsx(Ne,{slot:e,icon:r??te(n.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{c?.exec(m),s(true);},...i?{className:i}:{},children:u(a??n.labelKey)})},{docxRow:e})}var ln=Nm("toc.refresh","entire",{labelKey:"toc.refresh",paths:Im}),sn=Nm("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:km});function ii(){return B(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function li({label:e,icon:t,shortcut:n,disabled:o,disabledReason:r,active:a,onSelect:i,className:l}){let{close:c}=vo();return jsx(Ne,{...t?{icon:t}:{},...n?{shortcut:n}:{},...o?{disabled:o}:{},...o&&r?{title:r}:{},...a!==void 0?{active:a}:{},onSelect:()=>{i?.(),c(true);},...l?{className:l}:{},children:e})}var di=8,JC=e=>e.editingMode==="viewing";function eP(){let e=A(),t=useContext(at),n=Je(),o=_e(),r=e?.can({type:"toggleReviewPane"}),a=B(JC),i=!r?.ok||a||(t?.mounted??0)===0||e?.getSelectionPlacement()===null,l=X("review.comments");return jsx(Ne,{icon:te(l?.paths),slot:"review.comments",disabled:i,title:r&&!r.ok?r.reason:a?o("editingMode.viewingHint"):void 0,onSelect:()=>{t?.requestCommentDraft()&&n.setOpenMenu(null);},children:o("comments.addComment")})}var tP=[{kind:"row",id:"edit.cut",render:()=>jsx(Er,{})},{kind:"row",id:"edit.copy",render:()=>jsx(wr,{})},{kind:"row",id:"edit.paste",render:()=>jsx(Qo,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(Mr,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(Rr,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(wt,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsx(eP,{})}];function oP(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Jo.docxRow,render:()=>jsx(Jo,{})},{kind:"row",id:en.docxRow,render:()=>jsx(en,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:tn.docxRow,render:()=>jsx(tn,{})},{kind:"row",id:on.docxRow,render:()=>jsx(on,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:nn.docxRow,render:()=>jsx(nn,{})},{kind:"row",id:rn.docxRow,render:()=>jsx(rn,{})},{kind:"row",id:an.docxRow,render:()=>jsx(an,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:xo.docxRow,render:()=>jsx(xo,{})}]}function nP(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:ln.docxRow,render:()=>jsx(ln,{})},{kind:"row",id:sn.docxRow,render:()=>jsx(sn,{})}]}function rP(e,t=false){return [...tP,...e?oP():[],...t?nP():[]]}function Om(e){if(!isValidElement(e))return null;let t=Ao(e,Om);if(t!==null)return t;let n=e.type;if(typeof n!="function"&&typeof n!="object")return null;if(typeof n.docxRow=="string")return n.docxRow;if(typeof n.docxSlot=="string")return n.docxSlot;if(n.docxMenuRow===true){let o=e.props.slot;if(typeof o=="string")return o}return null}function Fm(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function aP(e){return e?.closest(".docx-editor__scroll-container")??null}function kr({className:e,t,preset:n=true,disabled:o,onOpenChange:r,children:a}){let i=je(),l=A(),{t:c}=_(),s=ii(),d=useRef(null),u=useRef(null),[m,g]=useState(null),[p,f]=useState(null),[b,h]=useState(null),P=useMemo(()=>rP(s,p!==null),[s,p]),[x,C]=useState(null),v=useCallback((H=false)=>{g(null),C(null),f(null),h(null),H&&l?.focus();},[l]);useEffect(()=>{if(o)return;let H=aP(d.current);if(!H)return;let k=L=>{L.preventDefault();let R=L.button===-1||L.clientX===0&&L.clientY===0,I=H.getBoundingClientRect();f(l?.snapshot().tocContext?.id??null),h(R||!(L.target instanceof HTMLElement)?null:L.target),g(R?{x:I.left+16,y:I.top+16}:{x:L.clientX,y:L.clientY});};return H.addEventListener("contextmenu",k),()=>H.removeEventListener("contextmenu",k)},[o,l]),useEffect(()=>{o&&v();},[o,v]),useEffect(()=>{if(!m)return;let H=R=>{u.current?.contains(R.target)||v();},k=R=>{R.key==="Escape"?(R.preventDefault(),v(true)):R.key==="Tab"&&v();},L=()=>v();return document.addEventListener("pointerdown",H,true),document.addEventListener("keydown",k),document.addEventListener("scroll",L,{capture:true,passive:true}),window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{document.removeEventListener("pointerdown",H,true),document.removeEventListener("keydown",k),document.removeEventListener("scroll",L,true),window.removeEventListener("blur",L),window.removeEventListener("resize",L);}},[m,v]),useLayoutEffect(()=>{let H=u.current;if(!m||!H)return;let{width:k,height:L}=H.getBoundingClientRect(),R=window.innerWidth-k-di,I=window.innerHeight-L-di,z=Math.max(di,m.x>R?m.x-k:m.x),Z=Math.max(di,m.y>I?m.y-L:m.y);C({x:z,y:Z});},[m]),useLayoutEffect(()=>{x&&u.current?.focus({preventScroll:true});},[x]);let y=useRef(r);y.current=r;let T=useRef(false);useEffect(()=>{let H=m!==null;H!==T.current&&(T.current=H,y.current?.(H));},[m]);let M=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>v(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,v]),[w,E]=useState(null),D=useMemo(()=>({close:v,anchor:m,tocId:p,target:b,clipboardRefusal:w,reportClipboardRefusal:E}),[v,m,p,b,w]),F={position:"fixed",left:(x??m)?.x??0,top:(x??m)?.y??0,visibility:x?"visible":"hidden"};return jsx("div",{ref:d,style:{display:"contents"},children:m?jsx(er.Provider,{value:M,children:jsx(ri.Provider,{value:D,children:jsxs("div",{ref:u,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${i}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:F,onKeyDown:H=>{let k=u.current;if(!k)return;let L=ro(k);H.key==="ArrowDown"?(H.preventDefault(),st(L,document.activeElement,1)):H.key==="ArrowUp"?(H.preventDefault(),st(L,document.activeElement,-1)):H.key==="Home"?(H.preventDefault(),ct(L,"first")):H.key==="End"&&(H.preventDefault(),ct(L,"last"));},children:[Children.toArray(a).filter(Fm),sa({entries:P,children:Children.toArray(a).filter(H=>!Fm(H)),preset:n,keyOfEntry:H=>H.id,keyOfChild:Om,renderEntry:H=>H.kind==="separator"?jsx(so,{}):H.render()})]})})}):null})}var ac=Object.assign(kr,{Cut:Er,Copy:wr,Paste:Qo,Delete:Mr,SelectAll:Rr,InsertRowAbove:Jo,InsertRowBelow:en,InsertColumnLeft:tn,InsertColumnRight:on,DeleteTableRow:nn,DeleteTableColumn:rn,DeleteTable:an,CellVerticalAlignment:xo,RefreshToc:ln,RefreshTocPageNumbers:sn,Item:li,Slot:wt,Row:Ne,Group:nr,Separator:so,Submenu:lo});function ic(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Bm=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),cP="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",dP="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",uP={position:"absolute",zIndex:20,minWidth:240,maxWidth:320,top:12,right:12,padding:12,borderRadius:8,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-surface)",boxShadow:"0 4px 16px var(--doc-shadow)",color:"var(--doc-text)",fontSize:13,display:"flex",flexDirection:"column",gap:10},pP={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},mP={color:"var(--doc-text-muted)",flexShrink:0},fP={textAlign:"right",wordBreak:"break-word"},gP={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},bP={display:"flex",gap:8,marginTop:4},qm={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:4,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text)",font:"inherit",cursor:"pointer"};function hP(e){switch(e){case "plainText":return "contentControl.types.plainText";case "checkbox":return "contentControl.types.checkbox";case "dropdown":return "contentControl.types.dropdown";case "comboBox":return "contentControl.types.comboBox";case "date":return "contentControl.types.date";case "picture":return "contentControl.types.picture";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function vP(e){return e.effectiveLock==="sdtContentLocked"?"contentControl.lock.sdtContentLocked":e.effectiveLock==="contentLocked"||e.locked?"contentControl.lock.contentLocked":e.effectiveLock==="sdtLocked"||e.removalLocked?"contentControl.lock.sdtLocked":"contentControl.lock.unlocked"}function cn({label:e,value:t,testId:n}){return jsxs("div",{style:pP,"data-testid":n,children:[jsx("span",{style:mP,children:e}),jsx("span",{style:fP,children:t})]})}function yP({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let a=ft(),i=useRef(null),l=useId(),{t:c}=_(),{control:s,inspectorOpen:d,closeInspector:u}=a;if(useEffect(()=>{if(!d)return;let f=h=>{h.key==="Escape"&&(h.preventDefault(),u());},b=h=>{let P=i.current;P&&h.target instanceof Node&&P.contains(h.target)||u();};return document.addEventListener("keydown",f),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",b,true);}},[d,u]),useEffect(()=>{d&&!s&&u();},[d,s,u]),n||!d||!s)return null;let m=r?jsxs(Fragment,{children:[jsx(Km,{}),jsx(zm,{}),jsx("div",{style:bP,children:jsx(Vm,{})}),o]}):o,g={ref:i,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":s.id,"data-control-type":s.controlType,...s.locked?{"data-locked":""}:{},...s.bound?{"data-bound":""}:{},...s.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:uP,onMouseDown:f=>{ic(f),f.stopPropagation();}},p=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:c("contentControl.inspectorPanel.title")}),m]});return t?jsx(W,{...g,children:p}):jsx("div",{...g,children:p})}function Km({className:e,asChild:t,hidden:n,children:o}){let{closeInspector:r}=ft(),{t:a}=_();if(n)return null;let i={style:gP,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxs(Fragment,{children:[jsx("span",{children:o??a("contentControl.inspectorPanel.title")}),jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":a("common.close"),title:a("common.close"),style:{...qm,padding:4,border:"none",background:"transparent"},onMouseDown:ic,onClick:()=>r(),children:Bm(cP)})]});return t?jsx(W,{...i,children:l}):jsx("div",{...i,children:l})}function zm({className:e,asChild:t,hidden:n,children:o}){let{control:r}=ft(),{t:a}=_();if(n||!r)return null;let i=a("contentControl.inspectorPanel.empty"),l=a("contentControl.inspectorPanel.yes"),c=a("contentControl.inspectorPanel.no"),s=o??jsxs(Fragment,{children:[jsx(cn,{label:a("contentControl.inspectorPanel.alias"),value:r.alias??i,testId:"content-control-inspector-alias"}),jsx(cn,{label:a("contentControl.inspectorPanel.tag"),value:r.tag??i,testId:"content-control-inspector-tag"}),jsx(cn,{label:a("contentControl.inspectorPanel.type"),value:a(hP(r.controlType)),testId:"content-control-inspector-type"}),jsx(cn,{label:a("contentControl.inspectorPanel.lock"),value:a(vP(r)),testId:"content-control-inspector-lock"}),jsx(cn,{label:a("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:c,testId:"content-control-inspector-placeholder"}),jsx(cn,{label:a("contentControl.inspectorPanel.bound"),value:r.bound?l:c,testId:"content-control-inspector-bound"}),r.bound?jsx("p",{"data-testid":"content-control-inspector-bound-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},children:a("contentControl.inspectorPanel.boundNote")}):null,r.locked?jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:a("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsx(W,{...d,children:s}):jsx("div",{...d,children:s})}function Vm({className:e,asChild:t,hidden:n,icon:o,children:r}){let{canRemove:a,removeDisabledReason:i,remove:l,closeInspector:c}=ft(),{t:s}=_();if(n)return null;let d=s("contentControl.remove"),u={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":d,title:i??d,style:qm,onMouseDown:ic,onClick:()=>{l().ok&&c();}},m=jsxs(Fragment,{children:[o??r??Bm(dP),jsx("span",{children:d})]});return t?jsx(W,{...u,children:m}):jsx("button",{...u,children:m})}var ui=Object.assign(yP,{Header:Km,Fields:zm,Remove:Vm});var CP={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},PP={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},EP={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},wP={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},MP={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},RP={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:30,backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},IP={padding:"8px 12px"},kP={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},_P={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},DP={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function NP({forwardedRef:e}){let t=A(),n=useRef(null);return n.current=t,yd({ref:e,editorRef:n}),null}var LP=forwardRef(function(t,n){let{document:o,fonts:r,className:a,t:i,chrome:l=true,title:c,onTitleChange:s,renderTitleBarLeft:d,renderTitleBarRight:u,colorMode:m="light",author:g,locale:p,mode:f="edit",modules:b,zoom:h,zoomMode:P,onReady:x,onChange:C,onFontError:v,onOpen:y,onSave:T,hyperlinkPopup:M,contextMenu:w=true,menu:E=true,navigation:D=true,rulers:F=true}=t,[H,k]=useState(Nc);useEffect(()=>{if(m==="system")return Hc(k)},[m]);let L=Lc(m,H),{t:R}=_(),I=useCallback((j,Re)=>i?i(j,Re):R(j,Re),[i,R]),z=jsxs(ra,{className:l?L?"dark":void 0:a,style:l?PP:void 0,children:[l?jsx(ei,{}):null,l?jsx(ni,{}):null,jsx(jr,{}),jsx(oi,{hidden:M===false}),w===false?null:jsx(kr,{t:I,...typeof w=="object"?w:{}}),jsx(ui,{}),F&&l?jsx("div",{style:MP,"aria-hidden":"true",children:jsx(za,{})}):null,t.children]}),Z=l?jsxs("div",{className:`docx-editor${L?" dark":""}${a?` ${a}`:""}`,style:CP,children:[jsxs("div",{style:RP,children:[jsxs("div",{style:kP,children:[d?.(),jsxs("div",{style:_P,children:[s?jsx("input",{"aria-label":I("titleBar.documentNameAriaLabel"),value:c??"",placeholder:I("titleBar.untitled"),onChange:j=>s(j.target.value),style:DP}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:c??I("titleBar.untitled")}),E!==false?jsx(ir,{t:I,...c!==void 0?{fileName:c}:{},...y?{onOpen:y}:{},...T?{onSave:T}:{},...typeof E=="object"?E:{}}):null]}),u?.()]}),jsx("div",{style:IP,children:jsx(Qn,{t:I})})]}),F?jsx("div",{style:wP,"data-testid":"docx-editor-ruler-row",children:jsx(Ka,{})}):null,jsx(Qa,{t:I}),jsxs("div",{style:EP,children:[D?jsx(ja,{t:I}):null,z,jsx(Ya.Provider,{value:I,children:jsx(Xa,{})}),jsx(Xr,{overlay:true})]})]}):z,V=useCallback(j=>I(j),[I]);return jsxs(En,{...o!==void 0?{document:o}:{},...r?{fonts:r}:{},...g!==void 0?{author:g}:{},...p!==void 0?{locale:p}:{},translate:I,mode:f,...b!==void 0?{modules:b}:{},...h!==void 0?{zoom:h}:{},...P!==void 0?{zoomMode:P}:{},tableInteractionLabel:V,...x?{onReady:x}:{},...C?{onChange:C}:{},...v?{onFontError:v}:{},children:[jsx(NP,{forwardedRef:n}),jsx(no.Provider,{value:l,children:Z})]})}),HP=forwardRef(function(t,n){return jsx(Do,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(LP,{...t,ref:n})})}),FP=Object.assign(HP,{Root:En,Viewport:ra,Content:jr,Toolbar:Qn,Menu:ir,Loading:Xr,ColorByChangeType:ji,AuthorStyle:Yi,HorizontalRuler:Ka,VerticalRuler:za,DocumentOutline:Ds,Navigation:ja,PageSetupDialog:Jn,PageNumber:Xa,FontNotice:Qa,HeaderFooterChrome:ei,NotesChrome:ni,HyperLink:oi,ContextMenu:ac,ContentControl:ui});function ZP(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}async function BP(e){return typeof e=="function"?e():e}function qP(e,t={}){let[n,o]=useState(void 0),[r,a]=useState(void 0),[i,l]=useState(null),[c,s]=useState(e!=null),[d,u]=useState(t.fonts===void 0),m=useRef(t);return m.current=t,useEffect(()=>{let g=m.current.fonts;if(g===void 0)return;let p=true;return (async()=>{try{let f=await BP(g);p&&a(composeFontConfiguration(f));}catch{}finally{p&&u(true);}})(),()=>{p=false;}},[]),useEffect(()=>{if(e==null){o(void 0),l(null),s(false);return}let g=ZP(e);if(g){o(g),l(null),s(false);return}let p=true,f=new AbortController;return s(true),l(null),(async()=>{try{let b=await fetch(String(e),{...m.current.fetchOptions,signal:f.signal});if(!b.ok)throw new Error(`could not open the document: ${b.status} ${b.statusText}`);let h=new Uint8Array(await b.arrayBuffer());if(!p)return;o(h),s(!1);}catch(b){if(!p||b instanceof Error&&b.name==="AbortError")return;l(b instanceof Error?b:new Error("could not open the document")),s(false);}})(),()=>{p=false,f.abort();}},[e]),{document:d?n:void 0,fonts:r,error:i,isLoading:c||!d}}function $P(e,...t){let n=useRef({source:e,fragments:t});return n.current={source:e,fragments:t},useMemo(()=>async o=>{let r=n.current,i=[typeof r.source=="function"?await r.source(o):await r.source,...r.fragments].filter(s=>s!==void 0);if(i.length===0)return;let{epoch:l,...c}=composeFontConfiguration(i[0],...i.slice(1));return c},[])}var Gm=[],GP=()=>{};function jP(){let e=A(),t=useCallback(n=>{if(!e)return GP;let o=Bi(n),r=e.on("change",o),a=e.on("selectionChange",o);return ()=>{r(),a();}},[e]);return useSyncExternalStore(t,()=>e?.getReviewAuthors()??Gm,()=>Gm)}function QP(e){let n=e?.surface?.state?.().selection?.head;return n&&typeof n.paragraphId=="string"&&Number.isFinite(n.offset)?n:null}function JP(){let e=A(),t=useRef(null),n=useCallback(r=>{if(!e)return ()=>{};let a=e.on("selectionChange",r),i=e.on("change",r);return ()=>{a(),i();}},[e]),o=useCallback(()=>{let r=QP(e),a=t.current;return (r===null?a===null:a!==null&&e1(a,r))?a:(t.current=r,r)},[e]);return useSyncExternalStore(n,o,()=>null)}function e1(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function lc({source:e,scale:t,measurer:n,onStateChange:o,onError:r,className:a,documentFontFamily:i,ref:l}){let c=useRef(null),s=useRef(null),[d,u]=useState(null),m=useRef(o);m.current=o;let g=useRef(r);return g.current=r,useEffect(()=>{let p=c.current;if(!p)return;let f=mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onChange:h=>{u(h),m.current?.(h);}});if(!f.ok){g.current?.(f.reason,f.detail);return}s.current=f.surface;let b=f.surface.state();return u(b),m.current?.(b),()=>{f.surface.destroy(),s.current=null;}},[e,n]),useImperativeHandle(l,()=>({focus:()=>s.current?.focus(),type:p=>s.current?.type(p),undo:()=>s.current?.undo(),redo:()=>s.current?.redo(),selectAll:()=>s.current?.selectAll(),navigate:(p,f)=>s.current?.navigate(p,f),toggleRunProperty:(p,f)=>s.current?.toggleRunProperty(p,f),setRunProperty:(p,f)=>s.current?.setRunProperty(p,f),setParagraphProperty:(p,f)=>s.current?.setParagraphProperty(p,f),formatting:()=>s.current?.formatting()??null,sectionProperties:()=>s.current?.sectionProperties()??null,save:()=>{let p=s.current;return p?(p.flushPendingInput(),p.session.save()):null}}),[]),jsx("div",{ref:c,style:{margin:"24px auto",...i?{fontFamily:i}:{}},className:a?`docx-paginated-surface ${a}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var Nr=createContext(null);function Ym(){let e=useContext(Nr);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function c1(e){return "type"in e&&e.type==="separator"}var Jm={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},d1={...Jm,background:"var(--doc-bg-hover)"},ef={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},u1={...ef,opacity:.4,cursor:"default"},p1={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},m1={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},f1={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:8,zIndex:1001};function Lr({label:e,items:t,disabled:n,showChevron:o=false}){let[r,a]=useState(false),[i,l]=useState(null),c=useRef(null),s=useRef(null),[d,u]=useState({top:0,left:0}),m=useCallback(()=>{a(false),l(null);},[]);useEffect(()=>{if(!r||!c.current)return;let p=c.current.getBoundingClientRect();u({top:p.bottom+2,left:p.left});},[r]),useEffect(()=>{if(!r)return;function p(h){let P=h.target;c.current&&!c.current.contains(P)&&s.current&&!s.current.contains(P)&&m();}function f(h){h.key==="Escape"&&m();}function b(){m();}return document.addEventListener("mousedown",p),document.addEventListener("keydown",f),window.addEventListener("scroll",b,true),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",f),window.removeEventListener("scroll",b,true);}},[r,m]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),m());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:c,type:"button",onClick:()=>!n&&a(!r),onMouseDown:p=>p.preventDefault(),disabled:n,style:r?d1:Jm,children:[e,o&&jsx(K,{name:"arrow_drop_down",size:16})]}),r&&jsx("div",{ref:s,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:p=>p.preventDefault(),children:t.map((p,f)=>{if(c1(p))return jsx("div",{style:p1},`sep-${f}`);let b=p;if(b.customContent)return jsx("div",{onMouseDown:x=>x.preventDefault(),children:b.customContent},b.label);let h=!!b.submenuContent,P=i===b.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>h&&l(b.label),onMouseLeave:()=>h&&l(null),children:[jsxs("button",{type:"button",style:b.disabled?u1:ef,onClick:()=>g(b),onMouseDown:x=>x.preventDefault(),onMouseOver:x=>{b.disabled||(x.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsx(K,{name:b.icon,size:18}),jsx("span",{children:b.label}),b.shortcut&&jsx("span",{style:m1,children:b.shortcut}),h&&jsx("span",{style:{marginLeft:"auto"},children:jsx(K,{name:"keyboard_arrow_right",size:16})})]}),h&&P&&jsx("div",{style:f1,onMouseDown:x=>x.preventDefault(),children:b.submenuContent(m)})]},b.label)})})]})}var dc=18,b1=2,of={width:dc,height:dc,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},h1={...of,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},v1={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function nf({onInsert:e,gridRows:t=6,gridColumns:n=6}){let[o,r]=useState(0),[a,i]=useState(0),l=useCallback(()=>{o>0&&a>0&&e(o,a);},[o,a,e]),c=[];for(let d=1;d<=t;d++)for(let u=1;u<=n;u++){let m=d<=o&&u<=a;c.push(jsx("div",{style:m?h1:of,onMouseEnter:()=>{r(d),i(u);},onClick:l,role:"gridcell","aria-selected":m},`${d}-${u}`));}let s=o>0&&a>0?`${a} \xD7 ${o}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:b1,gridTemplateColumns:`repeat(${n}, ${dc}px)`},onMouseLeave:()=>{r(0),i(0);},role:"grid","aria-label":"Table size selector",children:c}),jsx("div",{style:v1,children:s})]})}function S1({items:e,closeMenu:t}){return jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(n=>{let o=!n.onClick;return jsxs("button",{type:"button",disabled:o,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:o?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:o?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{o||(n.onClick?.(),t());},onMouseOver:r=>{o||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsx(K,{name:n.icon,size:18}),jsx("span",{children:n.label})]},n.label)})})}function C1(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function fi({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function P1(e){return e.replace(/\.docx$/i,"")}function pc({value:e,onChange:t,placeholder:n,editable:o=true}){let{t:r}=_(),a=n??r("titleBar.untitled"),i=P1(e)??"";return o?jsx("input",{type:"text",value:i,onChange:l=>{let c=l.target.value;t?.(c.endsWith(".docx")?c:c+".docx");},placeholder:a,className:"text-base font-normal text-foreground bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-muted focus:bg-doc-bg-input focus:ring-1 focus:ring-ring min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":r("titleBar.documentNameAriaLabel")}):jsx("span",{className:"text-base font-normal text-foreground px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:i||a})}function gi({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function bi(){let{t:e}=_(),t=Ym(),{disabled:n=false,onFormat:o,onPrint:r,onOpen:a,onSave:i,onPageSetup:l,onInsertImage:c,onInsertTable:s,showTableInsert:d=true,showHelpMenu:u=true,onInsertPageBreak:m,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:f,onWatermark:b,onRefocusEditor:h}=t,P=useCallback(y=>{!n&&o&&o(y);},[n,o]),x=useCallback((y,T)=>{!n&&s&&(s(y,T),requestAnimationFrame(()=>h?.()));},[n,s,h]),C=!!r||!!l,v=C||a||i;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[v&&jsx(Lr,{label:e("toolbar.file"),disabled:n,items:[...a?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:a}]:[],...i?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:i}]:[],...(a||i)&&C?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsx(Lr,{label:e("toolbar.format"),disabled:n,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>P("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>P("setRtl")}]}),jsx(Lr,{label:e("toolbar.insert"),disabled:n,items:[...c?[{icon:"image",label:e("toolbar.image"),onClick:c}]:[],...d&&s?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:y=>jsx(nf,{onInsert:(T,M)=>{x(T,M),y();}})}]:[],...c||d&&s?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:y=>jsx(S1,{closeMenu:y,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:m},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),u&&jsx(Lr,{label:e("toolbar.help"),disabled:n,items:[{label:e("toolbar.reportIssue"),onClick:()=>tr()}]})]})}function mc({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,i=>{isValidElement(i)&&(i.type===fi?t=i:i.type===gi?n=i:i.type===bi?r.push(i):o.push(i));});let a=useCallback(i=>{let l=i.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||i.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:a,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(C1,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}var hi={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},R1={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},rf={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function I1(e,t){let n=rf[t]??rf[t.toLowerCase()]??t,r=e?.colorScheme?.[n];return typeof r=="string"&&r?r:hi[n]??"000000"}function af(e){let t=e.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/.test(t))return t;if(/^[0-9A-F]{3}$/.test(t))return t.split("").map(n=>n+n).join("")}function fc(e,t,n="000000"){if(!e||e.kind==="auto")return `#${n}`;if(e.kind==="hex")return `#${af(e.value)??n}`;let o=Object.entries(t?.colorScheme??hi).map(([a,i])=>({slot:a,hex:String(i)})),r=resolveThemeColorHex(e,o);return `#${r.ok?r.hex:I1(t,e.slot)}`}function Rt(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?af(e.value):fc(e,t).slice(1)}function lf(e){if(!e||e==="none")return "";let t=R1[e];return t?`#${t}`:""}var k1=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],_1=[{type:"base",keep:1,labelSuffix:""},{type:"tint",keep:.2,labelSuffix:", Lighter 80%"},{type:"tint",keep:.4,labelSuffix:", Lighter 60%"},{type:"tint",keep:.6,labelSuffix:", Lighter 40%"},{type:"shade",keep:.75,labelSuffix:", Darker 25%"},{type:"shade",keep:.5,labelSuffix:", Darker 50%"}];function sf(e){let t=e??hi;return _1.map(n=>k1.map(o=>{let r=t[o.slot]??hi[o.slot]??"000000",i={hex:n.type==="base"?r.toUpperCase():n.type==="tint"?applyThemeTint(r,n.keep):applyThemeShade(r,n.keep),themeSlot:o.slot,label:`${o.name}${n.labelSuffix}`};return n.type==="tint"?i.tint=n.keep:n.type==="shade"&&(i.shade=n.keep),i}))}function J(...e){return clsx(e)}var L1=cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-7 w-7"}},defaultVariants:{variant:"default",size:"default"}}),Me=Ye.forwardRef(({className:e,variant:t,size:n,...o},r)=>jsx("button",{className:J(L1({variant:t,size:n,className:e})),ref:r,...o}));Me.displayName="Button";function et({content:e,children:t,side:n="bottom",delayMs:o=400}){let[r,a]=Ye.useState(false),[i,l]=Ye.useState({x:0,y:0}),c=Ye.useRef(null),s=Ye.useRef(null),d=Ye.useCallback(()=>{s.current=setTimeout(()=>{if(c.current){let p=c.current.getBoundingClientRect(),f=p.left+p.width/2,b=n==="top"?p.top-8:p.bottom+8;l({x:f,y:b});}a(true);},o);},[o,n]),u=Ye.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),a(false);},[]);Ye.useEffect(()=>()=>{s.current&&clearTimeout(s.current);},[]);let m=t.props,g=Ye.cloneElement(t,{ref:c,onMouseEnter:p=>{d(),m.onMouseEnter?.(p);},onMouseLeave:p=>{u(),m.onMouseLeave?.(p);}});return jsxs(Fragment,{children:[g,r&&jsx("div",{className:"fixed z-50 px-2 py-1 text-xs font-medium text-white bg-foreground dark:bg-muted dark:text-foreground rounded-md shadow-lg",style:{left:i.x,top:i.y,transform:n==="top"?"translate(-50%, -100%)":n==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var Kt=pe.Root,zt=pe.Group,vi=pe.Value;function Vt({className:e,children:t,onMouseDown:n,...o}){return jsxs(pe.Trigger,{className:J("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-foreground bg-transparent","hover:bg-muted/80 focus:outline-none focus:bg-muted/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[t,jsx(pe.Icon,{asChild:true,children:jsx(Z1,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function $t({className:e,children:t,position:n="popper",onCloseAutoFocus:o,...r}){let a=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsx(pe.Portal,{children:jsx("div",{className:J("docx-editor",a&&"dark"),children:jsx(pe.Content,{className:J("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-border bg-popover text-popover-foreground shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:n,onCloseAutoFocus:i=>{i.preventDefault(),o?.(i);},...r,children:jsx(pe.Viewport,{className:J("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:i=>i.preventDefault(),children:t})})})})}function So({className:e,...t}){return jsx(pe.Label,{className:J("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function tt({className:e,children:t,onMouseDown:n,...o}){return jsxs(pe.Item,{className:J("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-foreground outline-none","hover:bg-muted focus:bg-muted","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[jsx(pe.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(pe.ItemIndicator,{children:jsx(B1,{className:"h-4 w-4"})})})]})}function Co({className:e,...t}){return jsx(pe.Separator,{className:J("-mx-1 my-1 h-px bg-muted",e),...t})}function Z1({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})}function B1({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})}function gc(e){let t=e.trim();if(!t)return "";let n=null,o="";for(let r of t){if((r==='"'||r==="'")&&n===null){n=r,o+=r;continue}if(r===n){n=null,o+=r;continue}if(r===","&&n===null)break;o+=r;}return o.trim().replace(/^['"]|['"]$/g,"")}var q1=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function uf({value:e,onChange:t,fonts:n=q1,documentFonts:o,disabled:r=false,className:a,placeholder:i="Arial",width:l=120,showPreview:c=true}){let{t:s}=_(),d=Ye.useMemo(()=>{if(!o)return [];let f=new Set(n.map(b=>b.name.toLowerCase()));return o.filter(b=>!f.has(b.name.toLowerCase()))},[o,n]),u=Ye.useMemo(()=>[...d,...n],[d,n]),m=Ye.useMemo(()=>e?u.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||gc(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:i,[e,u,i]),g=Ye.useCallback(f=>{let b=u.find(h=>h.name===f);b&&t?.(gc(b.fontFamily)||b.name);},[t,u]),p=Ye.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return n.forEach(b=>{let h=b.category||"other";f[h].push(b);}),f},[n]);return jsxs(Kt,{value:m,onValueChange:g,disabled:r,children:[jsx(Vt,{className:J("h-8 text-sm",a),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":s("font.selectAriaLabel"),children:jsx(vi,{placeholder:i,children:m})}),jsxs($t,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(zt,{children:[jsx(So,{children:s("font.documentFonts")}),d.map(f=>jsx(tt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(Co,{})]}),p["sans-serif"].length>0&&jsxs(zt,{children:[jsx(So,{children:s("font.sansSerif")}),p["sans-serif"].map(f=>jsx(tt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxs(Fragment,{children:[jsx(Co,{}),jsxs(zt,{children:[jsx(So,{children:s("font.serif")}),p.serif.map(f=>jsx(tt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxs(Fragment,{children:[jsx(Co,{}),jsxs(zt,{children:[jsx(So,{children:s("font.monospace")}),p.monospace.map(f=>jsx(tt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxs(Fragment,{children:[jsx(Co,{}),jsx(zt,{children:p.other.map(f=>jsx(tt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function bc(e){if(e===void 0)return;let t=e.map(n=>typeof n=="string"?{name:n,fontFamily:n,category:"other"}:n);return t}function $1(e,t,n,o){let a=Math.max(8,window.innerWidth-n-8),i=Math.max(8,window.innerHeight-o-8);return {top:Math.min(Math.max(8,e),i),left:Math.min(Math.max(8,t),a)}}function $e({isOpen:e,onClose:t,align:n="left"}){let o=useRef(null),r=useRef(null),[a,i]=useState({top:0,left:0});useEffect(()=>{if(!e||!o.current)return;let s=o.current.getBoundingClientRect();n==="right"?requestAnimationFrame(()=>{if(r.current){let d=r.current.getBoundingClientRect(),u=$1(s.bottom+4,s.right-d.width,d.width,d.height);i(u);}else i({top:s.bottom+4,left:s.left});}):i({top:s.bottom+4,left:s.left});},[e,n]),useEffect(()=>{if(!e)return;let s=performance.now()+150,d=g=>{let p=g.target;o.current&&!o.current.contains(p)&&r.current&&!r.current.contains(p)&&t();},u=g=>{g.key==="Escape"&&t();},m=g=>{if(performance.now()<s)return;let p=g.target;p&&r.current&&r.current.contains(p)||p instanceof Element&&p!==document.documentElement&&p!==document.body&&o.current&&p.contains(o.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),window.addEventListener("scroll",m,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u),window.removeEventListener("scroll",m,true);}},[e,t]);let l=useCallback(s=>{s.preventDefault(),s.stopPropagation();},[]),c={position:"fixed",top:a.top,left:a.left,zIndex:1e4};return {containerRef:o,dropdownRef:r,dropdownStyle:c,handleMouseDown:l}}var G1=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],j1=1,Y1=400;function ff(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function gf(e,t,n){for(let o=t.length-1;o>=0;o--)if(t[o]<e)return t[o];return Math.max(e-1,n)}function bf({value:e,onChange:t,sizes:n=G1,disabled:o=false,className:r,placeholder:a="11",minSize:i=j1,maxSize:l=Y1}){let{t:c}=_(),[s,d]=useState(false),[u,m]=useState(""),[g,p]=useState(false),f=useRef(null),b=useCallback(()=>{p(false),d(false);},[]),{containerRef:h,dropdownRef:P,dropdownStyle:x}=$e({isOpen:g,onClose:b}),C=e??(parseInt(a,10)||11),v=e!==void 0?e.toString():a,y=useCallback(k=>{if(k.preventDefault(),o)return;let L=gf(C,n,i);t?.(L);},[C,n,i,o,t]),T=useCallback(k=>{if(k.preventDefault(),o)return;let L=ff(C,n,l);t?.(L);},[C,n,l,o,t]),M=useCallback(k=>{k.preventDefault(),!o&&(d(true),m(v),p(true),requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[o,v]),w=useCallback(k=>{m(k.target.value);},[]),E=useCallback(()=>{d(false);let k=parseFloat(u);if(!isNaN(k)&&k>=i&&k<=l){let L=Math.round(k*2)/2;t?.(L);}},[u,i,l,t]),D=useCallback(k=>{if(k.key==="Enter")k.preventDefault(),E(),p(false);else if(k.key==="Escape")d(false),p(false);else if(k.key==="ArrowUp"){k.preventDefault();let L=ff(C,n,l);m(L.toString()),t?.(L);}else if(k.key==="ArrowDown"){k.preventDefault();let L=gf(C,n,i);m(L.toString()),t?.(L);}},[E,C,n,l,i,t]),F=useCallback(k=>{t?.(k),p(false),d(false);},[t]),H=useCallback(k=>{k.target.tagName!=="INPUT"&&k.preventDefault();},[]);return jsxs("div",{ref:h,className:J("flex items-center",r),onMouseDown:H,children:[jsx(Me,{variant:"ghost",size:"icon-sm",className:J("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:y,disabled:o||C<=i,"aria-label":c("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(K,{name:"remove",size:18})}),jsx("div",{className:"relative",children:s?jsx("input",{ref:f,type:"text",value:u,onChange:w,onBlur:E,onKeyDown:D,className:J("h-7 w-10 text-center text-sm border border-input bg-doc-bg-input text-doc-text","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none"),"aria-label":c("fontSize.label"),"data-testid":"font-size-input"}):jsx("button",{type:"button",onClick:M,className:J("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",o&&"opacity-50 cursor-not-allowed"),disabled:o,"aria-label":c("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:v})}),g&&jsx("div",{ref:P,style:{...x,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":c("fontSize.listLabel"),children:n.map(k=>jsx("button",{type:"button",onClick:()=>F(k),className:J("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",k===C&&"bg-muted font-medium"),role:"option","aria-selected":k===C,children:k},k))}),jsx(Me,{variant:"ghost",size:"icon-sm",className:J("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:T,disabled:o||C>=l,"aria-label":c("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(K,{name:"add",size:18})})]})}var J1=[{name:"Dark Red",nameKey:"colorPicker.colors.darkRed",hex:"C00000"},{name:"Red",nameKey:"colorPicker.colors.red",hex:"FF0000"},{name:"Orange",nameKey:"colorPicker.colors.orange",hex:"FFC000"},{name:"Yellow",nameKey:"colorPicker.colors.yellow",hex:"FFFF00"},{name:"Light Green",nameKey:"colorPicker.colors.lightGreen",hex:"92D050"},{name:"Green",nameKey:"colorPicker.colors.green",hex:"00B050"},{name:"Light Blue",nameKey:"colorPicker.colors.lightBlue",hex:"00B0F0"},{name:"Blue",nameKey:"colorPicker.colors.blue",hex:"0070C0"},{name:"Dark Blue",nameKey:"colorPicker.colors.darkBlue",hex:"002060"},{name:"Purple",nameKey:"colorPicker.colors.purple",hex:"7030A0"}],xi=18,eE=2,tE={position:"relative",display:"inline-block"},oE={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},nE={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},yc={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},xc={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},yf={display:"grid",gap:`${eE}px`},Ti={width:`${xi}px`,height:`${xi}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},xf={...Ti,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},Tf={...Ti,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},rE={display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"5px 8px",border:"1px solid var(--doc-border-dark)",borderRadius:"4px",backgroundColor:"var(--doc-surface)",cursor:"pointer",fontSize:"12px",color:"var(--doc-text)"},aE={display:"flex",alignItems:"center",gap:"6px"},iE={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},lE={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},hf={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},sE={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},cE={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0,width:"28px",padding:"2px 4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},dE={display:"flex",alignItems:"center",justifyContent:"center",width:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"};function Tc(e,t,n){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let o=lf(e);return o||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return fc(e,n)}function vf(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let n=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (n*299+o*587+r*114)/1e3>230}function Sf(e,t,n){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Rt(e,n))===t.toUpperCase():false}function uE({matrix:e,selectedColor:t,theme:n,onSelect:o}){let[r,a]=useState(null);return jsx("div",{style:{...yf,gridTemplateColumns:`repeat(10, ${xi}px)`},children:e.flatMap((i,l)=>i.map((c,s)=>{let d=`${l}-${s}`,u=r===d,m=Sf(t,c.hex,n);return jsx("button",{type:"button",style:{...m?Tf:u?xf:Ti,backgroundColor:`#${c.hex}`},title:c.label,"aria-label":c.label,"aria-selected":m,onClick:()=>o(c),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>a(d),onMouseLeave:()=>a(null)},d)}))})}function pE({selectedColor:e,theme:t,onSelect:n}){let[o,r]=useState(null),{t:a}=_();return jsx("div",{style:{...yf,gridTemplateColumns:`repeat(10, ${xi}px)`},children:J1.map((i,l)=>{let c=o===l,s=Sf(e,i.hex,t),d=a(i.nameKey);return jsx("button",{type:"button",style:{...s?Tf:c?xf:Ti,backgroundColor:`#${i.hex}`},title:d,"aria-label":d,"aria-selected":s,onClick:()=>n(i.hex),onMouseDown:u=>u.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},i.hex)})})}function wo({mode:e,value:t,onChange:n,theme:o,disabled:r=false,className:a,style:i,title:l,icon:c,autoLabel:s,splitButton:d=true,defaultColor:u}){let[m,g]=useState(false),[p,f]=useState(false),[b,h]=useState(false),[P,x]=useState(false),[C,v]=useState(""),[y,T]=useState(()=>u??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:M}=_();useEffect(()=>{let G=Tc(t,e,o).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(G)&&v(G.toUpperCase());},[t,e,o]);let w=useCallback(()=>g(false),[]),{containerRef:E,dropdownRef:D,dropdownStyle:F}=$e({isOpen:m,onClose:w}),H=o?.colorScheme??null,k=useMemo(()=>sf(H),[H]),L=useMemo(()=>Tc(t,e,o),[t,e,o]),R=useMemo(()=>Tc(y,e,o),[y,e,o]),I=useCallback(()=>{r||g(G=>!G);},[r]),z=useCallback(G=>{let q;e==="highlight"?q=G.hex:q={kind:"theme",slot:G.themeSlot,...G.tint!==void 0?{tint:G.tint}:{},...G.shade!==void 0?{shade:G.shade}:{}},T(q),n?.(q),g(false);},[e,n]),Z=useCallback(G=>{let q=e==="highlight"?G:{kind:"hex",value:G};T(q),n?.(q),g(false);},[e,n]),V=useCallback(()=>{n?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,n]),j=useCallback(()=>{let G=C.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(G)){let q=e==="highlight"?G:{kind:"hex",value:G};T(q),n?.(q),g(false),v("");}},[e,C,n]),Re=useCallback(()=>{r||n?.(y);},[r,y,n]),se={...oE,...r?{cursor:"default",opacity:.38}:m?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},Se=M(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),Pe=c??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:E,className:`docx-color-picker ${a||""}`,style:{...tE,...i},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...sE,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...cE,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:Re,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),disabled:r,title:l||Se,"aria-label":l||Se,children:[jsx(K,{name:Pe,size:18}),jsx("div",{style:{...hf,backgroundColor:R==="transparent"?"#fff":R,outline:R==="transparent"||vf(R)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...dE,...r?{cursor:"default"}:m?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:P?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:I,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>x(true),onMouseLeave:()=>x(false),disabled:r,title:l||Se,"aria-label":l||Se,"aria-haspopup":"true","aria-expanded":m,children:jsx(K,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:se,onClick:I,onMouseDown:G=>G.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||Se,"aria-label":l||Se,"aria-haspopup":"true","aria-expanded":m,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(K,{name:Pe,size:18}),jsx("div",{style:{...hf,backgroundColor:L==="transparent"?"#fff":L,outline:L==="transparent"||vf(L)?"1px solid #bbb":"none"}})]}),jsx(K,{name:"arrow_drop_down",size:14})]}),m&&jsx("div",{ref:D,className:"docx-color-picker-dropdown",style:{...F,...nE},role:"dialog","aria-label":`${Se} picker`,onMouseDown:G=>{G.target.tagName!=="INPUT"&&G.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:rE,onClick:V,onMouseDown:G=>G.preventDefault(),children:[e==="highlight"?jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),s??M(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:xc}),jsx("div",{style:yc,children:M("colorPicker.themeColors")}),jsx(uE,{matrix:k,selectedColor:t,theme:o,onSelect:z}),jsx("div",{style:xc}),jsx("div",{style:yc,children:M("colorPicker.standardColors")}),jsx(pE,{selectedColor:t,theme:o,onSelect:Z}),jsx("div",{style:xc}),jsx("div",{style:yc,children:M("colorPicker.customColor")}),jsxs("div",{style:aE,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:iE,value:C,onChange:G=>v(G.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:G=>{G.key==="Enter"&&j();},onMouseDown:G=>{G.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...lE,opacity:/^[0-9A-Fa-f]{6}$/.test(C)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(C)?"pointer":"default"},onClick:j,onMouseDown:G=>G.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(C),children:M("common.apply")})]})]})})]})}var Fr=20,Sc=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(K,{name:"format_align_left",size:Fr}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(K,{name:"format_align_center",size:Fr}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(K,{name:"format_align_right",size:Fr}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(K,{name:"format_align_justify",size:Fr}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function Ef({value:e="left",onChange:t,disabled:n=false}){let{t:o}=_(),[r,a]=useState(false),i=useCallback(()=>a(false),[]),{containerRef:l,dropdownRef:c,dropdownStyle:s,handleMouseDown:d}=$e({isOpen:r,onClose:i}),u=useCallback(h=>{n||t?.(h),a(false);},[n,t]),m=Sc.find(h=>h.value===e)||Sc[0],g=o(m.labelKey),p=m.shortcutKey?o(m.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,b=jsxs(Me,{variant:"ghost",size:"icon-sm",className:J("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",n&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!n&&a(h=>!h),disabled:n,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(K,{name:m.iconName,size:Fr}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(et,{content:f,children:b}),r&&!n&&jsx("div",{ref:c,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:h=>h.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:Sc.map(h=>{let P=e===h.value,x=o(h.labelKey),C=h.shortcutKey?o(h.shortcutKey):void 0;return jsx("button",{type:"button",title:`${x}${C?` (${C})`:""}`,"data-testid":`alignment-${h.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:P?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:P?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:v=>v.preventDefault(),onMouseEnter:v=>{P||(v.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:v=>{v.currentTarget.style.backgroundColor=P?"var(--doc-primary-light)":"transparent";},onClick:()=>u(h.value),children:jsx(K,{name:h.iconName,size:18})},h.value)})})})]})}function Si(){return {type:"none",level:0,isInList:false}}var hE={display:"inline-flex",alignItems:"center",gap:"4px"},wf={display:"inline-flex",alignItems:"center",gap:"4px"},wi={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},vE={...wi,backgroundColor:"var(--doc-bg-hover)"},yE={...wi,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},xE={...wi,cursor:"default",opacity:.38},TE={width:"28px",height:"28px",padding:"2px"},SE={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Ci=20;function Pi({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:a,style:i}){let[l,c]=useState(false),s={...t?xE:e?yE:l?vE:wi,...i},d=u=>{u.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${a||""}`,style:s,onMouseDown:d,onClick:t?void 0:o,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:n,"aria-label":n,"aria-pressed":e,role:"button",children:r})}function Mf({listState:e,onBulletList:t,onNumberedList:n,onIndent:o,onOutdent:r,disabled:a=false,className:i,style:l,showIndentButtons:c=true,compact:s=false,hasIndent:d=false}){let{t:u}=_(),m=useCallback(()=>s?{...TE}:{},[s]),g=e?.type==="bullet",p=e?.type==="numbered",b=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${i||""}`,style:{...hE,...l},role:"group","aria-label":u("lists.ariaLabel"),children:[jsxs("div",{style:wf,role:"group","aria-label":u("lists.typeAriaLabel"),children:[jsx(Pi,{active:g,disabled:a,title:u("lists.bulletList"),onClick:t,style:m(),children:jsx(K,{name:"format_list_bulleted",size:Ci})}),jsx(Pi,{active:p,disabled:a,title:u("lists.numberedList"),onClick:n,style:m(),children:jsx(K,{name:"format_list_numbered",size:Ci})})]}),c&&jsxs(Fragment,{children:[jsx("div",{style:SE,role:"separator"}),jsxs("div",{style:wf,role:"group","aria-label":u("lists.indentationAriaLabel"),children:[jsx(Pi,{active:false,disabled:a||!b,title:u("lists.decreaseIndent"),onClick:r,style:m(),children:jsx(K,{name:"format_indent_decrease",size:Ci})}),jsx(Pi,{active:false,disabled:a,title:u("lists.increaseIndent"),onClick:o,style:m(),children:jsx(K,{name:"format_indent_increase",size:Ci})})]})]})]})}var PE=[{label:"Single",labelKey:"lineSpacing.single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",labelKey:"lineSpacing.double",value:2,twipsValue:480}];function If({value:e,onChange:t,options:n=PE,disabled:o=false,className:r}){let{t:a}=_(),i=Ye.useMemo(()=>e===void 0?n[0]:n.find(s=>s.twipsValue===e)||n[0],[e,n]),l=Ye.useCallback(s=>{let d=parseInt(s,10);isNaN(d)||t?.(d);},[t]),c=s=>s.labelKey?a(s.labelKey):s.label;return jsxs(Kt,{value:i.twipsValue.toString(),onValueChange:l,disabled:o,children:[jsx(Vt,{className:J("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":a("lineSpacing.label"),title:a("lineSpacing.lineSpacingTitle",{label:c(i)}),children:jsx(ks,{className:"h-5 w-5 shrink-0"})}),jsxs($t,{children:[n.map(s=>jsx(tt,{value:s.twipsValue.toString(),children:c(s)},s.twipsValue)),jsx(Co,{}),jsx(zt,{children:jsx(So,{children:a("lineSpacing.blockSpacingRules")})})]})]})}var EE={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},wE=new Set(["Title","Heading1","Heading2","Heading3"]),ME={Subtitle:"666666"},RE="#4a6c8c";function kf(e){let t=EE[e.styleId],o={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??wE.has(e.styleId))&&(o.fontWeight="bold"),e.italic&&(o.fontStyle="italic");let r=e.color??ME[e.styleId];return r?o.color=`#${r}`:e.styleId.startsWith("Heading")&&(o.color=RE),o}function _f(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:t.name||t.styleId,priority:99}))}var Df=[{styleId:"Normal",name:"Normal text",nameKey:"styles.normalText",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",nameKey:"styles.title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",nameKey:"styles.subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",nameKey:"styles.heading1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",nameKey:"styles.heading2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",nameKey:"styles.heading3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}];function Nf({value:e,onChange:t,styles:n,disabled:o=false,className:r,width:a=120}){let{t:i}=_(),l=Ye.useMemo(()=>{let g=_f(n);return g.length===0?Df:g.map(p=>({...p,type:"paragraph",nameKey:Df.find(f=>f.styleId===p.styleId)?.nameKey}))},[n]),c=Ye.useCallback(g=>{t?.(g);},[t]),s=g=>g.nameKey?i(g.nameKey):g.name,d=e||"Normal",u=l.find(g=>g.styleId===d),m=u?s(u):d;return jsxs(Kt,{value:d,onValueChange:c,disabled:o,children:[jsx(Vt,{className:J("h-8 text-sm",r),style:{width:typeof a=="number"?`${a}px`:a},"aria-label":i("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:m})}),jsx($t,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(tt,{value:g.styleId,className:"py-2.5 px-3",children:jsx("span",{style:kf(g),children:s(g)})},g.styleId))})]})}var kE=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function Hf({value:e=1,onChange:t,levels:n=kE,disabled:o=false,className:r,compact:a=false}){let{t:i}=_(),l=Ye.useMemo(()=>{let g=n.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[n,e]),c=Ye.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),s=Ye.useMemo(()=>[...n].sort((g,p)=>g.value-p.value),[n]),d=Ye.useMemo(()=>[...s].reverse().find(g=>g.value<e-.001),[s,e]),u=Ye.useMemo(()=>s.find(g=>g.value>e+.001),[s,e]),m=a?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[jsx(Me,{variant:"ghost",size:"icon-sm",className:J(m,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(o||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:o||!d,"aria-label":i("zoom.zoomOut"),children:jsx(K,{name:"remove",size:18})}),jsxs(Kt,{value:e.toString(),onValueChange:c,disabled:o,children:[jsx(Vt,{className:J(a?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":i("zoom.ariaLabel",{label:l}),children:jsx(vi,{placeholder:"100%",children:l})}),jsx($t,{children:n.map(g=>jsx(tt,{value:g.value.toString(),children:g.label},g.value))})]}),jsx(Me,{variant:"ghost",size:"icon-sm",className:J(m,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(o||!u)&&"opacity-30 cursor-not-allowed"),onClick:()=>u&&t?.(u.value),disabled:o||!u,"aria-label":i("zoom.zoomIn"),children:jsx(K,{name:"add",size:18})})]})}var DE=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function Of({onAction:e,disabled:t=false}){let{t:n}=_(),[o,r]=useState(false),a=useCallback(()=>r(false),[]),{containerRef:i,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=$e({isOpen:o,onClose:a}),d=useCallback(m=>{e(m),r(false);},[e]),u=jsxs(Me,{variant:"ghost",size:"icon-sm",className:J("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&r(m=>!m),disabled:t,"aria-label":n("table.borders.styleAriaLabel"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(K,{name:"border_all",size:20}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[o?u:jsx(et,{content:n("table.borders.tooltip"),children:u}),o&&!t&&jsx("div",{ref:l,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:m=>m.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:DE.map(({action:m,icon:g,labelKey:p})=>jsx("button",{type:"button",title:n(p),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:f=>f.preventDefault(),onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(m),children:jsx(K,{name:g,size:18})},typeof m=="string"?m:m.type))})})]})}function Zf({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),a=useCallback(i=>{if(typeof i=="string"){e({type:"borderColor",color:i.replace(/^#/,"")});return}let l=i.kind==="auto"?"000000":Rt(i,n);l&&e({type:"borderColor",color:l});},[e,n]);return jsx(wo,{mode:"border",value:o,onChange:a,theme:n,disabled:t,title:r("table.borderColor")})}var FE=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function qf({onAction:e,disabled:t=false}){let[n,o]=useState(false),{t:r}=_(),a=useCallback(()=>o(false),[]),{containerRef:i,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=$e({isOpen:n,onClose:a}),d=useCallback(m=>{e({type:"borderWidth",size:m}),o(false);},[e]),u=jsxs(Me,{variant:"ghost",size:"icon-sm",className:J("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&o(m=>!m),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(K,{name:"line_weight",size:20}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[n?u:jsx(et,{content:r("table.borderWidth"),children:u}),n&&!t&&jsx("div",{ref:l,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:120},onMouseDown:m=>m.stopPropagation(),children:FE.map(({size:m,label:g,thickness:p})=>jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},onMouseDown:f=>f.preventDefault(),onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(m),children:[jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsx("span",{children:g})]},m))})]})}function zf({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),a=useCallback(i=>{typeof i=="string"&&e(i==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:i.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsx(wo,{mode:"highlight",value:o,onChange:a,theme:n,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var OE={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},Io={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},Wf={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function Uf({onAction:e,disabled:t=false,tableContext:n}){let{t:o}=_(),[r,a]=useState(false),[i,l]=useState(null),c=useCallback(()=>a(false),[]),{containerRef:s,dropdownRef:d,dropdownStyle:u,handleMouseDown:m}=$e({isOpen:r,onClose:c,align:"right"}),g=n?.table?.attrs?.justification??"left",p=useCallback(h=>{e(h),a(false);},[e]),f=(h,P,x,C,v)=>{let y=t||v?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...OE,backgroundColor:i===h&&!y?"var(--doc-bg-hover)":"transparent",color:y?"var(--doc-text-muted)":v?.danger?"var(--doc-error)":"var(--doc-text)",cursor:y?"not-allowed":"pointer"},onClick:()=>!y&&p(C),onMouseEnter:()=>l(h),onMouseLeave:()=>l(null),disabled:y,children:[jsx(K,{name:P,size:16,className:v?.danger&&!y?"text-destructive":""}),jsx("span",{style:{flex:1},children:x})]},h)},b=jsx(Me,{variant:"ghost",size:"icon-sm",className:J("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:m,onClick:()=>!t&&a(h=>!h),disabled:t,"aria-label":o("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(K,{name:"more_vert",size:20})});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(et,{content:o("table.moreOptions"),children:b}),r&&!t&&jsxs("div",{ref:d,style:{...u,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:200,maxHeight:"70vh",overflowY:"auto"},role:"menu",onMouseDown:h=>h.stopPropagation(),children:[f("addRowAbove","add",o("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",o("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",o("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",o("table.insertColumnRight"),"addColumnRight"),jsx("div",{style:Io,role:"separator"}),f("mergeCells","call_merge",o("table.mergeCells"),"mergeCells",{itemDisabled:!n?.hasMultiCellSelection}),f("splitCell","call_split",o("table.splitCell"),"splitCell",{itemDisabled:!n?.canSplitCell}),jsx("div",{style:Io,role:"separator"}),f("selectTable","select_all",o("table.selectTable"),"selectTable"),jsx("div",{style:Io,role:"separator"}),f("deleteRow","delete",o("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(n?.rowCount??0)<=1}),f("deleteColumn","delete",o("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(n?.columnCount??0)<=1}),f("deleteTable","delete",o("table.deleteTable"),"deleteTable",{danger:true}),jsx("div",{style:Io,role:"separator"}),jsx("div",{style:Wf,children:o("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(h=>{let P={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsx("button",{type:"button",title:o({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[h]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:h}),children:jsx(K,{name:P[h],size:16})},h)})}),jsx("div",{style:Io,role:"separator"}),jsx("div",{style:Wf,children:o("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(h=>{let P={left:"format_align_left",center:"format_align_center",right:"format_align_right"},x=g===h;return jsx("button",{type:"button",title:o({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[h]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",borderColor:x?"var(--doc-primary)":"var(--doc-border)",color:x?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:C=>C.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:h}}),children:jsx(K,{name:P[h],size:16})},h)})}),jsx("div",{style:Io,role:"separator"}),f("headerRow","table_rows",o("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",o("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",o("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",o("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsx("div",{style:Io,role:"separator"}),f("properties","settings",o("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var BE=20;function Ii({options:e,activeValue:t,triggerIcon:n,tooltipContent:o,onSelect:r,disabled:a=false,ariaLabel:i,testId:l,showLabels:c=false}){let[s,d]=useState(false),u=useCallback(()=>d(false),[]),{containerRef:m,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=$e({isOpen:s,onClose:u}),b=useCallback(P=>{a||r(P),d(false);},[a,r]),h=jsxs(Me,{variant:"ghost",size:"icon-sm",className:J("text-muted-foreground hover:text-foreground hover:bg-muted/80",s&&"bg-muted",a&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!a&&d(P=>!P),disabled:a,"aria-label":i??o,"aria-expanded":s,"aria-haspopup":"true","data-testid":l,children:[jsx(K,{name:n,size:BE}),jsx(K,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:m,style:{position:"relative",display:"inline-block"},children:[s?h:jsx(et,{content:o,children:h}),s&&!a&&jsx("div",{ref:g,style:{...p,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:P=>P.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",gap:c?1:2,minWidth:c?200:void 0},children:e.map(P=>{let x=t===P.value;return jsxs("button",{type:"button",title:P.label,"data-testid":l?`${l}-${P.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)",...c?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{x||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:C=>{C.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>b(P.value),children:[jsx(K,{name:P.iconName,size:18}),c&&jsx("span",{style:{flex:1},children:P.label})]},P.value)})})})]})}var qE=[{value:"inline",labelKey:"imageWrap.inline",iconName:"wrap_text"},{value:"wrapRight",labelKey:"imageWrap.floatLeft",iconName:"format_image_left"},{value:"wrapLeft",labelKey:"imageWrap.floatRight",iconName:"format_image_right"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function KE(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function jf({imageContext:e,onChange:t,disabled:n=false}){let{t:o}=_(),r=qE.map(l=>({...l,label:o(l.labelKey)})),a=KE(e),i=r.find(l=>l.value===a)||r[0];return jsx(Ii,{options:r,activeValue:a,triggerIcon:i.iconName,tooltipContent:`Wrap: ${i.label}`,onSelect:t,disabled:n,testId:"toolbar-image-wrap",showLabels:true})}var VE=[{value:"rotateCW",labelKey:"imageTransform.rotateClockwise",iconName:"rotate_right"},{value:"rotateCCW",labelKey:"imageTransform.rotateCounterClockwise",iconName:"rotate_left"},{value:"flipH",labelKey:"imageTransform.flipHorizontal",iconName:"swap_horiz"},{value:"flipV",labelKey:"imageTransform.flipVertical",iconName:"swap_vert"}];function Yf({onTransform:e,disabled:t=false}){let{t:n}=_(),o=VE.map(r=>({...r,label:n(r.labelKey)}));return jsx(Ii,{options:o,triggerIcon:"rotate_right",tooltipContent:n("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var pt=18;function ot({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:a,ariaLabel:i}){let l=i?.toLowerCase().replace(/\s+/g,"-")||n?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),c=d=>{d.preventDefault();},s=jsx(Me,{variant:"ghost",size:"icon-sm",className:J("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",a),"data-active":e?"true":void 0,onMouseDown:c,onClick:t?void 0:o,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":i||n,"data-testid":l?`toolbar-${l}`:void 0,children:r});return n?jsx(et,{content:n,children:s}):s}function mt({label:e,children:t,className:n}){return jsx("div",{className:J("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",n),role:"group","aria-label":e,children:t})}function jE(e){let t=Ye__default.useContext(Nr);return t?{...t,...YE(e)}:e}function YE(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function wc(e){let{t}=_(),n=jE(e),{currentFormatting:o={},onFormat:r,onUndo:a,onRedo:i,canUndo:l=false,canRedo:c=false,disabled:s=false,className:d,style:u,enableShortcuts:m=true,editorRef:g,children:p,showFontPicker:f=true,fontFamilies:b,documentFonts:h,showFontSizePicker:P=true,showTextColorPicker:x=true,showHighlightColorPicker:C=true,showAlignmentButtons:v=true,showListButtons:y=true,showLineSpacingPicker:T=true,showStylePicker:M=true,documentStyles:w,theme:E,showZoomControl:D=true,zoom:F,onZoomChange:H,onRefocusEditor:k,imageContext:L,onImageWrapType:R,onImageTransform:I,onOpenImageProperties:z,tableContext:Z,onTableAction:V,inline:j=false}=n,Re=useRef(null),se=useCallback(de=>{!s&&r&&r(de);},[s,r]),Se=useCallback(()=>{!s&&l&&a&&a();},[s,l,a]),Pe=useCallback(()=>{!s&&c&&i&&i();},[s,c,i]),G=useCallback(de=>{!s&&r&&r({type:"fontFamily",value:de});},[s,r]),q=Ye__default.useMemo(()=>bc(b),[b]),Ee=useCallback(de=>{!s&&r&&r({type:"fontSize",value:de});},[s,r]),Ue=useCallback(de=>{!s&&r&&r({type:"textColor",value:de});},[s,r]),ce=useCallback(de=>{!s&&r&&r({type:"highlightColor",value:typeof de=="string"?de:""});},[s,r]),Ge=useCallback(de=>{!s&&r&&r({type:"alignment",value:de});},[s,r]),mn=useCallback(()=>{!s&&r&&r("bulletList");},[s,r]),_o=useCallback(()=>{!s&&r&&r("numberedList");},[s,r]),Zr=useCallback(()=>{!s&&r&&r("indent");},[s,r]),i0=useCallback(()=>{!s&&r&&r("outdent");},[s,r]),l0=useCallback(de=>{!s&&r&&(r({type:"lineSpacing",value:de}),requestAnimationFrame(()=>k?.()));},[s,r,k]),s0=useCallback(de=>{!s&&r&&r({type:"applyStyle",value:de});},[s,r]),fn=useCallback(de=>{!s&&V&&(V(de),requestAnimationFrame(()=>k?.()));},[s,V,k]);useEffect(()=>{if(!m)return;let de=ue=>{if(ue.defaultPrevented)return;let gn=ue.target,Ic=g?.current,u0=Re.current,p0=Ic?.contains(gn),m0=u0?.contains(gn);if(!p0&&!m0)return;if((ue.ctrlKey||ue.metaKey)&&!ue.altKey)switch(ue.key.toLowerCase()){case "b":ue.preventDefault(),se("bold");break;case "i":ue.preventDefault(),se("italic");break;case "u":ue.preventDefault(),se("underline");break;case "=":ue.shiftKey?(ue.preventDefault(),se("superscript")):(ue.preventDefault(),se("subscript"));break;case "l":ue.preventDefault(),Ge("left");break;case "e":ue.preventDefault(),Ge("center");break;case "r":ue.preventDefault(),Ge("right");break;case "j":ue.preventDefault(),Ge("both");break;case "k":ue.preventDefault(),se("insertLink");break}};return document.addEventListener("keydown",de),()=>{document.removeEventListener("keydown",de);}},[m,se,Ge,g]);let c0=useCallback(de=>{let ue=de.target;ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.tagName==="SELECT"||ue.tagName==="OPTION"||de.preventDefault();},[]),d0=useCallback(de=>{let ue=de.target,gn=document.activeElement;ue.tagName==="SELECT"||ue.tagName==="OPTION"||gn?.tagName==="SELECT"||requestAnimationFrame(()=>{k?.();});},[k]);return jsxs("div",{ref:Re,className:J(!j&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:j?{display:"contents",...u}:u,role:j?void 0:"toolbar","aria-label":j?void 0:t("toolbar.ariaLabel"),"data-testid":j?void 0:"formatting-bar",onMouseDown:j?void 0:c0,onMouseUp:j?void 0:d0,children:[jsxs(mt,{label:t("formattingBar.groups.history"),children:[jsx(ot,{onClick:Se,disabled:s||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(K,{name:"undo",size:pt})}),jsx(ot,{onClick:Pe,disabled:s||!c,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(K,{name:"redo",size:pt})})]}),D&&jsx(mt,{label:t("formattingBar.groups.zoom"),children:jsx(Hf,{value:F,onChange:H,disabled:s,compact:true})}),M&&jsx(mt,{label:t("formattingBar.groups.styles"),children:jsx(Nf,{value:o.styleId||"Normal",onChange:s0,styles:w,theme:E,disabled:s,width:120})}),(f||P)&&jsxs(mt,{label:t("formattingBar.groups.font"),children:[f&&jsx(uf,{value:o.fontFamily||"Arial",onChange:G,fonts:q,documentFonts:h,disabled:s,width:60,placeholder:"Arial"}),P&&jsx(bf,{value:o.fontSize!==void 0?ll(o.fontSize):11,onChange:Ee,disabled:s,width:42,placeholder:"11"})]}),jsxs(mt,{label:t("formattingBar.groups.textFormatting"),children:[jsx(ot,{onClick:()=>se("bold"),active:o.bold,disabled:s,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(K,{name:"format_bold",size:pt})}),jsx(ot,{onClick:()=>se("italic"),active:o.italic,disabled:s,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(K,{name:"format_italic",size:pt})}),jsx(ot,{onClick:()=>se("underline"),active:o.underline,disabled:s,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(K,{name:"format_underlined",size:pt})}),jsx(ot,{onClick:()=>se("strikethrough"),active:o.strike,disabled:s,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(K,{name:"strikethrough_s",size:pt})}),x&&jsx(wo,{mode:"text",value:o.color?.replace(/^#/,""),onChange:Ue,theme:E,disabled:s,title:t("formattingBar.fontColor")}),C&&jsx(wo,{mode:"highlight",value:o.highlight,onChange:ce,theme:E,disabled:s,title:t("formattingBar.highlightColor")}),jsx(ot,{onClick:()=>se("insertLink"),disabled:s,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(K,{name:"link",size:pt})})]}),jsxs(mt,{label:t("formattingBar.groups.script"),children:[jsx(ot,{onClick:()=>se("superscript"),active:o.superscript,disabled:s,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(K,{name:"superscript",size:pt})}),jsx(ot,{onClick:()=>se("subscript"),active:o.subscript,disabled:s,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(K,{name:"subscript",size:pt})})]}),v&&jsx(mt,{label:t("formattingBar.groups.alignment"),children:jsx(Ef,{value:o.alignment||"left",onChange:Ge,disabled:s})}),(y||T)&&jsxs(mt,{label:t("formattingBar.groups.listFormatting"),children:[y&&jsx(Mf,{listState:o.listState||Si(),onBulletList:mn,onNumberedList:_o,onIndent:Zr,onOutdent:i0,disabled:s,showIndentButtons:true,compact:true,hasIndent:(o.indentLeft??0)>0}),T&&jsx(If,{value:o.lineSpacing,onChange:l0,disabled:s})]}),L&&R&&jsxs(mt,{label:t("formattingBar.groups.image"),children:[jsx(jf,{imageContext:L,onChange:R,disabled:s}),I&&jsx(Yf,{onTransform:I,disabled:s}),z&&jsx(ot,{onClick:z,disabled:s,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(K,{name:"tune",size:pt})})]}),Z?.isInTable&&V&&jsxs(mt,{label:t("formattingBar.groups.table"),children:[jsx(Of,{onAction:fn,disabled:s}),jsx(Zf,{onAction:fn,disabled:s,theme:E,value:Rt(Z?.cellBorderColor,E)}),jsx(qf,{onAction:fn,disabled:s}),jsx(zf,{onAction:fn,disabled:s,theme:E,value:Z?.cellBackgroundColor}),jsx(Uf,{onAction:fn,disabled:s,tableContext:Z})]}),jsx(ot,{onClick:()=>se("clearFormatting"),disabled:s,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(K,{name:"format_clear",size:pt})}),p]})}function XE({children:e,className:t,style:n,...o}){return jsx(Nr.Provider,{value:o,children:jsx("div",{className:J("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:Ve.toolbar,...n},"data-testid":"editor-toolbar",children:e})})}var We=XE;We.TitleBar=mc;We.Logo=fi;We.DocumentName=pc;We.MenuBar=bi;We.TitleBarRight=gi;We.Toolbar=wc;var e2=new Map([["#ffff00","yellow"],["#00ff00","green"],["#00ffff","cyan"],["#ff00ff","magenta"],["#0000ff","blue"],["#ff0000","red"],["#000080","darkBlue"],["#008080","darkCyan"],["#008000","darkGreen"],["#800080","darkMagenta"],["#800000","darkRed"],["#808000","darkYellow"],["#808080","darkGray"],["#c0c0c0","lightGray"],["#ffffff","white"]]),t2=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function o2({source:e,scale:t,measurer:n,documentName:o,onStateChange:r,onError:a,onSave:i,renderTitleBarLeft:l,renderTitleBarRight:c,ref:s,colorMode:d,onZoomChange:u,documentFontFamily:m,className:g}){let p=useRef(null),[f,b]=useState(null),[h,P]=useState({}),[x,C]=useState(null),v=useCallback(w=>{b(w);let E=p.current?.formatting();E&&P({bold:E.bold,italic:E.italic,underline:E.underline,strike:E.strikethrough,superscript:E.superscript,subscript:E.subscript,...E.fontFamily?{fontFamily:E.fontFamily}:{},...E.fontSizeHalfPoints?{fontSize:E.fontSizeHalfPoints}:{},...E.alignment?{alignment:E.alignment}:{},...E.styleId?{styleId:E.styleId}:{},...E.color?{color:`#${E.color}`}:{},...E.highlight?{highlight:E.highlight}:{}}),C(p.current?.sectionProperties()??null),r?.(w);},[r]),y=useCallback(w=>{let E=p.current;if(E){if(typeof w=="string")switch(w){case "bold":return E.toggleRunProperty("b");case "italic":return E.toggleRunProperty("i");case "underline":return E.toggleRunProperty("u",{val:"single"});case "strikethrough":return E.toggleRunProperty("strike");case "superscript":return E.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return E.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":E.setRunProperty("b",{val:"0"}),E.setRunProperty("i",{val:"0"}),E.setRunProperty("u",{val:"none"}),E.setRunProperty("strike",{val:"0"}),E.setRunProperty("vertAlign",{val:"baseline"});return;default:return}switch(w.type){case "fontFamily":return E.setRunProperty("rFonts",{ascii:w.value,hAnsi:w.value});case "fontSize":return E.setRunProperty("sz",{val:String(Math.round(w.value*2))});case "textColor":{let D=w.value,F=typeof D=="string"?t2(D):Rt(D,null)??null;return F?E.setRunProperty("color",{val:F}):void 0}case "highlightColor":{let D=w.value.trim().toLowerCase();if(D==="none"||D==="")return E.setRunProperty("highlight",{val:"none"});let F=e2.get(D.startsWith("#")?D:`#${D}`);return F?E.setRunProperty("highlight",{val:F}):void 0}case "alignment":return E.setParagraphProperty("jc",{val:String(w.value)});case "lineSpacing":return E.setParagraphProperty("spacing",{line:String(Math.round(w.value)),lineRule:"auto"});case "applyStyle":return E.setParagraphProperty("pStyle",{val:w.value});default:return}}},[]);useImperativeHandle(s,()=>p.current,[]);let T=t===void 0?1:t/(96/72),M=x?{pageWidthTwips:x.pageSize.widthTwips,pageHeightTwips:x.pageSize.heightTwips,orientation:x.landscape?"landscape":"portrait",marginsTwips:{top:x.margins.topTwips,right:x.margins.rightTwips,bottom:x.margins.bottomTwips,left:x.margins.leftTwips}}:null;return jsxs("div",{className:["docx-editor docx-paginated-shell",d==="dark"?"dark":"",g??""].filter(Boolean).join(" "),style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:"var(--doc-bg)",color:"var(--doc-text)"},"data-testid":"paginated-shell",children:[jsxs(We,{currentFormatting:h,onFormat:y,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:T,onZoomChange:u,onSave:()=>{let w=p.current?.save();w&&i?.(w);},children:[jsxs(We.TitleBar,{children:[l&&jsx(We.Logo,{children:l()}),jsx(We.DocumentName,{value:o??"Document",editable:false}),c&&jsx(We.TitleBarRight,{children:c()}),jsx(We.MenuBar,{})]}),jsx(We.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[M?jsx("div",{style:{padding:"4px 0"},children:jsx(uo,{pageSetup:M,zoom:T})}):null,jsx(lc,{ref:p,source:e,...m?{documentFontFamily:m}:{},...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onStateChange:v,...a?{onError:a}:{}})]})]})}var _i=class{constructor(t){rt(this,"listeners",new Set);rt(this,"snapshot");rt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t);}));rt(this,"getSnapshot",()=>this.snapshot);this.snapshot=t;}setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var Di=class extends _i{constructor(){super({notifications:[]});rt(this,"notifications",[]);rt(this,"idCounter",0);rt(this,"timers",new Set);}showError(n,o){return this.addNotification(n,"error",o)}showWarning(n,o){return this.addNotification(n,"warning",o)}showInfo(n,o){return this.addNotification(n,"info",o)}dismiss(n){this.notifications=this.notifications.map(r=>r.id===n?{...r,dismissed:true}:r),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(r=>r.id!==n),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let n of this.timers)clearTimeout(n);this.timers.clear(),this.emitSnapshot();}destroy(){for(let n of this.timers)clearTimeout(n);this.timers.clear(),this.notifications=[];}addNotification(n,o,r){let a=`error-${++this.idCounter}-${Date.now()}`,i={id:a,message:n,severity:o,details:r,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let l=setTimeout(()=>{this.timers.delete(l),this.dismiss(a);},5e3);this.timers.add(l);}return a}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var s2=createContext(null);function t0({children:e}){let t=useMemo(()=>new Di,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((s,d)=>{t.showError(s,d);},[t]),r=useCallback((s,d)=>{t.showWarning(s,d);},[t]),a=useCallback((s,d)=>{t.showInfo(s,d);},[t]),i=useCallback(s=>{t.dismiss(s);},[t]),l=useCallback(()=>{t.clearAll();},[t]),c=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:a,dismissNotification:i,clearNotifications:l}),[n.notifications,o,r,a,i,l]);return jsxs(s2.Provider,{value:c,children:[e,jsx(c2,{notifications:n.notifications,onDismiss:i})]})}function c2({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:n.map(r=>jsx(d2,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function d2({notification:e,onDismiss:t}){let{t:n}=_(),[o,r]=useState(false),i=(f=>{switch(f){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),l={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"slideIn 0.3s ease-out"},c={display:"flex",alignItems:"flex-start",gap:"8px"},s={color:i.icon,flexShrink:0},d={flex:1,minWidth:0},u={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},m={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},g={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},p=f=>{switch(f){case "error":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:[jsx("style",{children:`
3
3
  @keyframes slideIn {
4
4
  from {
5
5
  opacity: 0;
@@ -10,9 +10,9 @@ import*as Ye from'react';import Ye__default,{createContext,useState,useEffect,fo
10
10
  transform: translateX(0);
11
11
  }
12
12
  }
13
- `}),jsxs("div",{style:c,children:[jsx("span",{style:l,children:g(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:p,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>r(!o),style:{...m,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n(o?"errors.hideDetails":"errors.showDetails")}),o&&jsx("div",{style:f,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:m,title:n("common.dismiss"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Pi=class extends Component{constructor(n){super(n);nt(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:a}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsx(x2,{error:r,errorInfo:a,showDetails:o,onReset:this.resetError})}return this.props.children}};function x2({error:e,errorInfo:t,showDetails:n,onReset:o}){let{t:r}=_(),a={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},s={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},c={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxs("div",{className:"docx-error-fallback",style:a,children:[jsx("div",{style:i,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:s,children:r("errors.somethingWentWrong")}),jsx("p",{style:c,children:r("errors.errorDescription")}),n&&jsxs("div",{style:l,children:[jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxs(Fragment,{children:[`
13
+ `}),jsxs("div",{style:c,children:[jsx("span",{style:s,children:p(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:u,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>r(!o),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n(o?"errors.hideDetails":"errors.showDetails")}),o&&jsx("div",{style:m,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:g,title:n("common.dismiss"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Ni=class extends Component{constructor(n){super(n);rt(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:a}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsx(u2,{error:r,errorInfo:a,showDetails:o,onReset:this.resetError})}return this.props.children}};function u2({error:e,errorInfo:t,showDetails:n,onReset:o}){let{t:r}=_(),a={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},c={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},s={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxs("div",{className:"docx-error-fallback",style:a,children:[jsx("div",{style:i,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:l,children:r("errors.somethingWentWrong")}),jsx("p",{style:c,children:r("errors.errorDescription")}),n&&jsxs("div",{style:s,children:[jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxs(Fragment,{children:[`
14
14
 
15
- `,jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:d,children:r("errors.tryAgain")})]})}function Nf({onClick:e,topPx:t,scrollLeft:n=0,leftOffset:o=tr}){let{t:r}=_();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:a=>a.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:o-n,top:t,zIndex:Ve.outline},children:jsx(K,{name:"format_list_bulleted",size:20})})}function dc({currentPage:e,totalPages:t,visible:n}){let{t:o}=_();return jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:n?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:o("viewer.pageIndicator",{current:e,total:t})})}function S2({i18n:e,isDark:t,onEditorError:n,containerRef:o,scrollContainerRef:r,editorContentRef:a,className:i,containerStyle:s,mainContentStyle:c,editorContainerStyle:l,showRuler:d,readOnlyProp:p,showOutline:f,showOutlineButton:m,sidebarOpen:g,minLayoutWidth:u,toolbarHeight:h,editorScrollLeft:b,expandedSidebarItem:v,trackedChanges:C,onScrollContainerMouseDown:P,onEditorBgMouseDown:S,onEditorContextMenu:y,horizontalRulerProps:x,verticalRulerProps:M,outlineProps:E,onToggleOutline:w,scrollPageInfo:N,toolbar:F,pagedArea:H,overlays:k,dialogs:D,fileInputs:I}){return jsx(Qt.Provider,{value:true,children:jsx(wo,{i18n:e,children:jsx(kf,{children:jsx(Pi,{onError:n,children:jsxs("div",{ref:o,className:j("docx-editor",t&&"dark",i),style:s,"data-testid":"docx-editor",children:[jsx("div",{style:c,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[F,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:l,onMouseDown:P,children:[d&&jsx("div",{className:"flex justify-center py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:Ve.ruler,paddingLeft:20,paddingRight:20+(g?352:0),minWidth:u,transition:"padding 0.2s ease"},children:jsx(ao,{...x})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:u},children:jsxs("div",{ref:a,style:{position:"relative",flex:1,minWidth:0},onMouseDown:S,onContextMenu:y,children:[d&&!p&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:Ve.ruler,paddingTop:48},children:jsx(er,{...M})}),v&&v.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${v.replace("comment-","")}"] { background-color: var(--doc-comment-active-bg) !important; border-bottom-width: 2px !important; border-bottom-style: solid !important; border-bottom-color: var(--doc-comment-active-border) !important; }`}),v?.startsWith("tc-")&&(()=>{let R=v.split("-")[1],Z=C.find($=>String($.id)===R)?.id??R;return jsx("style",{children:`
15
+ `,jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:d,children:r("errors.tryAgain")})]})}function r0({onClick:e,topPx:t,scrollLeft:n=0,leftOffset:o=Uo}){let{t:r}=_();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:a=>a.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:o-n,top:t,zIndex:Ve.outline},children:jsx(K,{name:"format_list_bulleted",size:20})})}function Rc({currentPage:e,totalPages:t,visible:n}){let{t:o}=_();return jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:n?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:o("viewer.pageIndicator",{current:e,total:t})})}function m2({i18n:e,isDark:t,onEditorError:n,containerRef:o,scrollContainerRef:r,editorContentRef:a,className:i,containerStyle:l,mainContentStyle:c,editorContainerStyle:s,showRuler:d,readOnlyProp:u,showOutline:m,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:b,editorScrollLeft:h,expandedSidebarItem:P,trackedChanges:x,onScrollContainerMouseDown:C,onEditorBgMouseDown:v,onEditorContextMenu:y,horizontalRulerProps:T,verticalRulerProps:M,outlineProps:w,onToggleOutline:E,scrollPageInfo:D,toolbar:F,pagedArea:H,overlays:k,dialogs:L,fileInputs:R}){return jsx(no.Provider,{value:true,children:jsx(Do,{i18n:e,children:jsx(t0,{children:jsx(Ni,{onError:n,children:jsxs("div",{ref:o,className:J("docx-editor",t&&"dark",i),style:l,"data-testid":"docx-editor",children:[jsx("div",{style:c,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[F,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:s,onMouseDown:C,children:[d&&jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:Ve.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsx(uo,{...T})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxs("div",{ref:a,style:{position:"relative",flex:1,minWidth:0},onMouseDown:v,onContextMenu:y,children:[d&&!u&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:Ve.ruler,paddingTop:48},children:jsx(cr,{...M})}),P&&P.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${P.replace("comment-","")}"] { background-color: var(--doc-comment-active-bg) !important; border-bottom-width: 2px !important; border-bottom-style: solid !important; border-bottom-color: var(--doc-comment-active-border) !important; }`}),P?.startsWith("tc-")&&(()=>{let I=P.split("-")[1],Z=x.find(V=>String(V.id)===I)?.id??I;return jsx("style",{children:`
16
16
  .paged-editor__pages .docx-insertion[data-revision-id="${Z}"] { background-color: rgba(52, 168, 83, 0.2) !important; border-bottom: 2px solid #2e7d32 !important; }
17
17
  .paged-editor__pages .docx-deletion[data-revision-id="${Z}"] { background-color: rgba(211, 47, 47, 0.2) !important; text-decoration-thickness: 2px !important; }
18
- `})})(),H]})})]}),N.totalPages>1&&jsx(dc,{currentPage:N.currentPage,totalPages:N.totalPages,visible:N.visible}),f&&jsx(Na,{...E,leftOffset:_a+(d?Bo:0)}),m&&!f&&jsx(Nf,{onClick:w,topPx:h+(d?30:0)+48,scrollLeft:b,leftOffset:tr+(d?Bo:0)})]})}),k,D,I]})})})})})}function k2(e){let[t,n]=useState(0);return useEffect(()=>{if(!e)return;let o=()=>n(i=>i+1),r=e.on("change",o),a=e.on("selectionChange",o);return o(),()=>{r(),a();}},[e]),t}var sH="0.0.2";export{Be as CONTENT_CONTROL_SLOTS,fo as ContextMenuCellVerticalAlignment,fr as ContextMenuCopy,mr as ContextMenuCut,gr as ContextMenuDelete,Jo as ContextMenuDeleteTable,Qo as ContextMenuDeleteTableColumn,jo as ContextMenuDeleteTableRow,Yo as ContextMenuInsertColumnLeft,Xo as ContextMenuInsertColumnRight,Uo as ContextMenuInsertRowAbove,Go as ContextMenuInsertRowBelow,Qa as ContextMenuItem,Wo as ContextMenuPaste,br as ContextMenuSelectAll,Gs as DocumentName,YC as DocxEditor,Fr as DocxEditorContent,oi as DocxEditorContentControl,vr as DocxEditorContextMenu,ms as DocxEditorDocumentOutline,Ba as DocxEditorFontNotice,za as DocxEditorHeaderFooterChrome,ka as DocxEditorHorizontalRuler,$a as DocxEditorHyperLink,sl as DocxEditorImagePropertiesDialog,Ai as DocxEditorLoading,Fi as DocxEditorLoadingSpinner,jn as DocxEditorMenu,xs as DocxEditorNavigation,Wa as DocxEditorNotesChrome,Vn as DocxEditorPageSetupDialog,qr as DocxEditorRoot,S2 as DocxEditorShell,zn as DocxEditorToolbar,Ra as DocxEditorVerticalRuler,zr as DocxEditorViewport,ao as HorizontalRuler,Qr as ImageAltText,Nr as ImageInsertProvider,Dr as ImageInsertTrigger,oa as ImagePropertiesTrigger,jr as ImageWrap,wo as LocaleProvider,ai as Logo,li as MenuBar,Lp as NAVIGATION_PANE_GAP,Da as NAVIGATION_PANE_INSET,qo as NAVIGATION_PANE_WIDTH,rr as NavigationClose,cr as NavigationFind,nr as NavigationHeader,sr as NavigationHeadings,lr as NavigationTab,ir as NavigationTabs,ar as NavigationTitle,dr as NavigationToggle,dc as PageIndicator,zs as PaginatedDocxEditor,u2 as PaginatedDocxEditorShell,Bo as RULER_WIDTH,St as ReviewRailContext,hs as SEARCH_DEBOUNCE_MS,vs as SEARCH_MATCH_LIMIT,W as Slot,Ys as TitleBar,ii as TitleBarRight,sc as Toolbar,tt as ToolbarButton,dt as ToolbarGroup,sH as VERSION,er as VerticalRuler,Ko as navigationPaneReservation,La as navigationShift,kr as normalizeImageBytes,Tc as useChromeTranslate,pt as useContentControl,Zr as useContentControlInstance,Jp as useContextMenuTarget,Ha as useDocumentOutline,Fa as useDocumentSearch,A as useDocxEditor,eP as useDocxSource,sP as useEditorCaret,ne as useEditorCommand,Dl as useEditorEvent,k2 as useEditorSnapshot,q as useEditorState,xn as useEditorValueCommand,ia as useFontFamily,rP as useFonts,Ps as useHeaderFooterState,Zi as useHyperlinkPopup,Or as useHyperlinkPopupInstance,Oa as useNavigationPane,Ro as useNavigationShift,Fs as useNotePropertiesState,Hs as useNoteScopeState,eo as usePageSetup,ss as useParagraphIndent,la as useParagraphStyle,Hu as useTableBorderTargetLabel,_ as useTranslation,ul as useZoom};
18
+ `})})(),H]})})]}),D.totalPages>1&&jsx(Rc,{currentPage:D.currentPage,totalPages:D.totalPages,visible:D.visible}),m&&jsx(ur,{...w,leftOffset:dr+(d?Wo:0)}),g&&!m&&jsx(r0,{onClick:E,topPx:b+(d?30:0)+48,scrollLeft:h,leftOffset:Uo+(d?Wo:0)})]})}),k,L,R]})})})})})}function x2(e){let[t,n]=useState(0);return useEffect(()=>{if(!e)return;let o=()=>n(i=>i+1),r=e.on("change",o),a=e.on("selectionChange",o);return o(),()=>{r(),a();}},[e]),t}export{Be as CONTENT_CONTROL_SLOTS,xo as ContextMenuCellVerticalAlignment,wr as ContextMenuCopy,Er as ContextMenuCut,Mr as ContextMenuDelete,an as ContextMenuDeleteTable,rn as ContextMenuDeleteTableColumn,nn as ContextMenuDeleteTableRow,tn as ContextMenuInsertColumnLeft,on as ContextMenuInsertColumnRight,Jo as ContextMenuInsertRowAbove,en as ContextMenuInsertRowBelow,li as ContextMenuItem,Qo as ContextMenuPaste,ln as ContextMenuRefreshToc,sn as ContextMenuRefreshTocPageNumbers,Rr as ContextMenuSelectAll,pc as DocumentName,ur as DocumentOutline,FP as DocxEditor,Yi as DocxEditorAuthorStyle,ji as DocxEditorColorByChangeType,jr as DocxEditorContent,ui as DocxEditorContentControl,kr as DocxEditorContextMenu,Ds as DocxEditorDocumentOutline,Qa as DocxEditorFontNotice,ei as DocxEditorHeaderFooterChrome,Ka as DocxEditorHorizontalRuler,oi as DocxEditorHyperLink,Ml as DocxEditorImagePropertiesDialog,Xr as DocxEditorLoading,Gi as DocxEditorLoadingSpinner,ir as DocxEditorMenu,Bs as DocxEditorNavigation,ni as DocxEditorNotesChrome,Xa as DocxEditorPageNumber,Jn as DocxEditorPageSetupDialog,En as DocxEditorRoot,m2 as DocxEditorShell,Qn as DocxEditorToolbar,za as DocxEditorVerticalRuler,ra as DocxEditorViewport,uo as HorizontalRuler,ma as ImageAltText,$r as ImageInsertProvider,Wr as ImageInsertTrigger,ha as ImagePropertiesTrigger,pa as ImageWrap,Do as LocaleProvider,fi as Logo,bi as MenuBar,im as NAVIGATION_PANE_GAP,Va as NAVIGATION_PANE_INSET,Go as NAVIGATION_PANE_WIDTH,gr as NavigationClose,xr as NavigationFind,fr as NavigationHeader,yr as NavigationHeadings,vr as NavigationTab,hr as NavigationTabs,br as NavigationTitle,Tr as NavigationToggle,Uo as OUTLINE_BUTTON_LEFT_OFFSET,DS as OUTLINE_BUTTON_RESERVED_SPACE,dr as OUTLINE_LEFT_OFFSET,kS as OUTLINE_RESERVED_SPACE,Rc as PageIndicator,Ya as PageNumberTranslationContext,lc as PaginatedDocxEditor,o2 as PaginatedDocxEditorShell,sl as REVIEW_MARKERS_GUTTER,cl as REVIEW_PANE_GUTTER,Wo as RULER_WIDTH,at as ReviewRailContext,Fs as SEARCH_DEBOUNCE_MS,As as SEARCH_MATCH_LIMIT,W as Slot,mc as TitleBar,gi as TitleBarRight,wc as Toolbar,ot as ToolbarButton,Xt as ToolbarContext,mt as ToolbarGroup,Bo as ToolbarImageProperties,h0 as VERSION,cr as VerticalRuler,w0 as editorStateActiveSubscriptionCount,xn as isFieldLink,fo as navigationPaneReservation,$a as navigationShift,qr as normalizeImageBytes,zg as provideDocxEditor,fd as reviewGutter,Bc as useChromeTranslate,ft as useContentControl,ea as useContentControlInstance,Pm as useContextMenuTarget,Wa as useDocumentOutline,Ua as useDocumentSearch,A as useDocxEditor,qP as useDocxSource,JP as useEditorCaret,ne as useEditorCommand,Ql as useEditorEvent,x2 as useEditorSnapshot,B as useEditorState,kn as useEditorValueCommand,Ta as useFontFamily,$P as useFonts,Ks as useHeaderFooterState,Xi as useHyperlinkPopup,Jr as useHyperlinkPopupInstance,Ga as useNavigationPane,oo as useNavigationShift,ec as useNotePropertiesState,Js as useNoteScopeState,ao as usePageSetup,ws as useParagraphIndent,Sa as useParagraphStyle,jP as useReviewAuthors,Fo as useReviewGutter,je as useScopeClassName,Sr as useScopedChromeAnchor,lp as useTableBorderTargetLabel,N0 as useToolbarContext,Y as useToolbarLabel,Kr as useToolbarLabelFor,_ as useTranslation,kl as useZoom};