@docx-editor.dev/react 2.9.0 → 2.9.2

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 rt from'react';import rt__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,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 ye from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var bd={version:"2.9.0"};var pg=bd.version;var hd="(prefers-color-scheme: dark)";function vd(){return typeof window<"u"&&typeof window.matchMedia=="function"}function yd(){return vd()?window.matchMedia(hd).matches:false}function xd(e,t){return e==="dark"||e==="system"&&t}function Sd(e){if(!vd())return ()=>{};let t=window.matchMedia(hd);e(t.matches);let n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}var cl=createContext(null);function H(){return useContext(cl)}var ft=createContext(null);var dl=createContext(en),ul=createContext("en");function Xo({i18n:e,children:t}){let n=useContext(dl),o=useContext(ul),r=typeof e?._lang=="string"?e._lang:o,i=useMemo(()=>deepMerge(n,e),[n,e]);return jsx(ul.Provider,{value:r,children:jsx(dl.Provider,{value:i,children:t})})}function _(){let e=useContext(dl),t=useContext(ul);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e}}function wd(e){let{t}=_();return useCallback((n,o)=>e?.get(n)??t(n,o),[e,t])}var pl=0,ml=false,fl=false;function kd(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(ml||(ml=true,pl+=1,queueMicrotask(()=>{ml=false;}),fl||(fl=true,setTimeout(()=>{fl=false,pl=0;},0))),pl>16)}function Rd(e){let t=false;return ()=>{if(t)return;t=true;let n=()=>{t=false,e();};kd()?setTimeout(n,0):queueMicrotask(n);}}var xg=()=>{},bl=0;function Sg(){return bl}function hl(e){return Rd(e)}function O(e,t=Object.is,n){let o=H(),r=n?.onSubscribe,i=n?.onUnsubscribe,a=useCallback(d=>{if(!o)return xg;let m=false;bl++,r?.();let p=hl(()=>{m||d();}),g=[o.on("change",p),o.on("selectionChange",p),o.on("error",p)];return ()=>{m=true,bl--,i?.();for(let u of g)u();}},[o,r,i]),l=useMemo(()=>{let d=false,m,p;return g=>{if(d&&g===m)return p;let u=e(g);return d&&t(p,u)?(m=g,p):(d=true,m=g,p=u,u)}},[o,e,t]),c=useCallback(()=>l(o?o.snapshot():LOADING_SNAPSHOT),[o,l]),s=useCallback(()=>l(LOADING_SNAPSHOT),[l]);return useSyncExternalStore(a,c,s)}var Id=12700,Md=96;function Eg(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function wg(e,t,n,o){let r=e*72/n,i=t*72/o;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function ma(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(!Eg(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:i,heightPoints:a}=wg(o.pixelWidth,o.pixelHeight,Md,Md);return Object.freeze({ok:true,bytes:e,mime:n,widthPoints:i,heightPoints:a})}function $t(e){return Math.round(e/Id*100)/100}function Bn(e){return Math.round(e*Id)}var fo=createContext({t:void 0,onSave:void 0});function Rg(){return useContext(fo)}function fa(e){let{t}=_();return n=>e?.(n)??t(n)}function X(){let{t:e}=useContext(fo);return fa(e)}function Lg(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function vl(e){return typeof e=="string"}function le(e){let t=H(),{t:n}=_(),o=vl(e)?e:editorCommandKey(e),r=useRef(e);r.current=e;let i=useCallback(c=>{let s=r.current;if(vl(s)){let m=toolbarCommandState(t,s);return {active:m.active,enabled:m.enabled,disabledReason:localizeDisabledReason(m.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]),a=O(i,Lg),l=useCallback(()=>{let c=r.current;return vl(c)?runToolbarCommand(t,c).ok:t?t.exec(c).ok:false},[t,o]);return useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason}),[l,a])}function Og(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function Bg(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=Og(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 j({children:e,...t}){let n=Children.only(e);if(!isValidElement(n))return null;let o=n.props,r=Bg(t,o),i=n.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let c of [i,a])typeof c=="function"?c(l):c&&typeof c=="object"&&(c.current=l);}),cloneElement(n,r)}function J(e){for(let t of CHROME_GROUPS)for(let n of t.controls)if(chromeSlotId(t,n)===e)return n;return null}function re(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 B(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function go(e){let{slot:t,icon:n,asChild:o,className:r,children:i,hidden:a}=e,{execute:l,isActive:c,isEnabled:s,disabledReason:d}=le(t),m=X();if(a)return null;let p=J(t),g=m(p?.labelKey??t),u=commandForSlot(t),f=u?.type==="toggleMark"||u?.type==="setAlignment",h={onClick:()=>l(),onMouseDown:B,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(j,{...h,children:i}):jsx("button",{type:"button",...h,children:n??i??re(p?.paths)})}go.docxToolbarPart=true;var Gg="image/png,image/jpeg,image/gif",xl=createContext(null);function ba(){let e=useContext(xl);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Sl(){return useContext(xl)}function ha({children:e}){let t=H(),{t:n}=_(),o=useRef(null),r=useRef(false),i=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),a=O(i,(f,h)=>f.enabled===h.enabled&&f.disabledReason===h.disabledReason),l=a.enabled,c=localizeDisabledReason(a.disabledReason,n),s=useCallback(async f=>{if(!t||r.current)return;let h=ma(f);if(!h.ok){window.alert(n(h.reasonKey));return}let S={type:"insertImage",data:h.bytes,mime:h.mime,widthPoints:h.widthPoints,heightPoints:h.heightPoints},C=t.canExecuteImageCommand?.(S);if(C&&!C.ok){window.alert(C.reason??n("imageInsert.errors.refused"));return}r.current=true;try{let v=await executeImageCommand(t,S);v.ok?t.focus():window.alert(v.reason??n("imageInsert.errors.refused"));}finally{r.current=false;}},[t,n]),d=useCallback(async f=>{let h=f?.[0];if(!h)return;let S=await h.arrayBuffer();await s(new Uint8Array(S));},[s]),m=useCallback(async f=>{if(!f)return;let h=[...f.files].find(S=>S.type.startsWith("image/"));if(h){await d([h]);return}for(let S of f.items){if(S.kind!=="file"||!S.type.startsWith("image/"))continue;let C=S.getAsFile();if(!C)continue;let v=await C.arrayBuffer();await s(new Uint8Array(v));return}},[s,d]),p=useCallback(()=>{l&&o.current?.click();},[l]),g=useCallback(async f=>{let h=f.currentTarget;await d(h.files),h.value="";},[d]),u=useMemo(()=>({openFilePicker:p,insertFromFileList:d,insertFromDataTransfer:m,isEnabled:l,disabledReason:c,inputRef:o,onInputChange:g}),[p,d,m,l,c,g]);return jsxs(xl.Provider,{value:u,children:[jsx("input",{ref:o,type:"file",accept:Gg,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:f=>f.stopPropagation()}),e]})}function va({className:e,hidden:t,asChild:n,children:o}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=ba(),l=X();if(t)return null;let c=J("image.insert"),s=l(c?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":s,title:a??s,onMouseDown:B,onClick:r};return n?jsx(j,{...d,children:o}):jsx("button",{...d,children:o??re(c?.paths)})}va.docxSlot="image.insert";var Zn=Object.assign(va,{docxSlot:"image.insert"});var ib=["nw","n","ne","e","se","s","sw","w"],Zd=40,qd=12;function lb(e){return `imageOverlay.handle.${e}`}function sb(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 cb(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 db(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 Tl({containerRef:e,portalRef:t,scrollPort:n}){let o=H(),{t:r}=_(),[i,a]=useState(null),[l,c]=useState(null),s=useRef(null);s.current=l;let d=useRef(null),m=useRef(null),p=useRef(null),g=useRef(null),u=useRef(null);useEffect(()=>{let b=e.current;if(!b)return;let y=T=>{let E=(T.target instanceof Element?T.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");g.current=E??null,E&&E===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return b.addEventListener("pointerdown",y,{capture:true}),()=>b.removeEventListener("pointerdown",y,{capture:true})},[e,i?.id]),useEffect(()=>{if(!o){a(null);return}let b=()=>{a(selectedDrawingOverlayTargetOf(o.surface));},y=()=>{queueMicrotask(b);};b();let T=[o.on("change",y),o.on("selectionChange",b)];return ()=>{for(let k of T)k();}},[o]),useEffect(()=>{if(n){u.current=n;return}let b=e.current;if(!b||!o?.surface)return;let y=b.closest(".docx-editor__scroll-container");if(!y)return;let T=o.surface.overlayCoordinates();return u.current=createImageOverlayScrollPort(y,T.paintScale),()=>{u.current=null;}},[e,o,n]);let f=useCallback(()=>{c(null),d.current=null;let b=m.current;if(m.current=null,b)try{b.releasePointerCapture(b._lastPointerId??0);}catch{}},[]),h=useCallback((b,y,T,k,E,w,A)=>{if(!o?.surface)return;let N=captureImageMutationPreconditions(o);if(!N)return;let F=o.surface.publishedLayout();d.current=Object.freeze({x:k,y:E}),m.current=w,w._lastPointerId=A;try{w.setPointerCapture(A);}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:b,handle:y,preconditions:N,layoutRevision:F.revision,packageRevision:o.surface.session.packageRevision(),kind:T.kind}),bounds:T,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});},[o]),S=useCallback((b,y,T,k,E)=>{if(!o)return;if(isStaleImageInteractionCommit(o,b)){f();return}b.mode==="resize"?o.exec({type:"setImageProperties",widthEmu:y,heightEmu:T,...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}:{}}:{}}):b.mode==="move"&&E&&o.exec({type:"setImagePosition",...E}),f();},[f,o]),C=useCallback(b=>{if(!o)return;let y=s.current?.bounds??selectedDrawingOverlayTargetOf(o.surface);if(!y)return;if(s.current&&b.key==="Escape"){b.preventDefault(),b.stopPropagation(),f();return}if(s.current)return;let T=b.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(b.key==="Delete"||b.key==="Backspace"){b.preventDefault(),b.stopPropagation(),o.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(b.key))return;b.preventDefault(),b.stopPropagation();let k=b.key==="ArrowLeft"?-T:b.key==="ArrowRight"?T:0,E=b.key==="ArrowUp"?-T:b.key==="ArrowDown"?T:0;if(b.altKey){if(!y.canResize)return;let A=db(k,E),N=computeImageResizeResult({handle:A,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:k,deltaYPt:E,transform:y.transform,preserveAspect:resizePreservesAspect(A,y.aspectLocked,b.shiftKey),kind:y.kind});o.exec({type:"setImageProperties",widthEmu:N.widthEmu,heightEmu:N.heightEmu,...N.position?.mode==="simple"?{horizontalEmu:N.position.horizontalEmu,verticalEmu:N.position.verticalEmu}:{},...N.position?.mode==="frame"?{...N.position.horizontalEmu!==void 0?{horizontalEmu:N.position.horizontalEmu}:{},...N.position.verticalEmu!==void 0?{verticalEmu:N.position.verticalEmu}:{}}:{}});return}if(y.kind!=="anchored"||!y.canMove||!y.position)return;let w=computeMovedImagePosition(y.position,k,E);o.exec({type:"setImagePosition",...w});},[f,o]);useEffect(()=>{if(!l||!o?.surface)return;let b=o.surface.overlayCoordinates(),y=k=>{let E=s.current,w=d.current;if(!E||!w)return;let A=cssPixelsToLayoutPoints(k.clientX-w.x,b.paintScale),N=cssPixelsToLayoutPoints(k.clientY-w.y,b.paintScale);if(E.session.mode==="move"){let I=0,D=u.current,R=e.current?.closest(".docx-editor__scroll-container");if(D&&R){let ae=R.getBoundingClientRect();k.clientY>ae.bottom-Zd?I=qd:k.clientY<ae.top+Zd&&(I=-qd),I!==0&&(I=D.scrollBy(I));}let M=E.accumulatedScrollPt+I;c({...E,accumulatedScrollPt:M,bounds:Object.freeze({...E.bounds,x:E.session.startBounds.x+A,y:E.session.startBounds.y+N+M})});return}if(!E.session.handle)return;let F=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:A,deltaYPt:N,transform:E.session.transform,preserveAspect:resizePreservesAspect(E.session.handle,E.bounds.aspectLocked,k.shiftKey),kind:E.session.kind});c({...E,bounds:Object.freeze({...E.bounds,x:F.previewBounds.x,y:F.previewBounds.y,width:F.previewBounds.width,height:F.previewBounds.height,widthEmu:F.widthEmu,heightEmu:F.heightEmu})});},T=k=>{let E=s.current;if(E)if(k.type==="pointerup"){let w=cssPixelsToLayoutPoints(k.clientX-(d.current?.x??k.clientX),b.paintScale),A=cssPixelsToLayoutPoints(k.clientY-(d.current?.y??k.clientY),b.paintScale),N=finalizeImageOverlayInteraction({session:E.session,deltaXPt:w,deltaYPt:A,accumulatedScrollPt:E.accumulatedScrollPt,aspectLocked:E.bounds.aspectLocked,shiftKey:k.shiftKey,anchorFrameOrigin:E.session.anchorFrameOrigin});S(E.session,N.widthEmu,N.heightEmu,N.previewBounds,N.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,S,e,o,l]),useEffect(()=>{!i||g.current!==i.id||(g.current=null,p.current?.focus({preventScroll:true}));},[i]);let v=l?.bounds??i,x=useMemo(()=>{if(!o?.surface||!v)return null;let b=o.surface.publishedLayout(),y=o.surface.overlayCoordinates(),T=overlayFrameToSheetCssPixels(b,{pageIndex:v.pageIndex,x:v.x,y:v.y,width:v.width,height:v.height},y),k=v.canResize,E=v.kind==="anchored"&&v.canMove;return jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":v.id,tabIndex:0,onKeyDown:C,children:[jsx("div",{className:`docx-image-selection-overlay__frame${E?" 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:E?"move":"default"},onPointerDown:w=>{B(w),!(!E||!v.position)&&w.button===0&&(w.preventDefault(),w.stopPropagation(),h("move",null,v,w.clientX,w.clientY,w.currentTarget,w.pointerId));}}),k?ib.map(w=>{let A=cb(w);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(lb(w)),tabIndex:0,style:{left:`calc(${T.left}px + ${T.width}px * ${parseFloat(A.x)/100} - 5px)`,top:`calc(${T.top}px + ${T.height}px * ${parseFloat(A.y)/100} - 5px)`,cursor:sb(w)},onPointerDown:N=>{B(N),N.button===0&&(N.preventDefault(),N.stopPropagation(),h("resize",w,v,N.clientX,N.clientY,N.currentTarget,N.pointerId));}},w)}):null]})},[v,h,o,C,r]);return !x||!t.current?null:createPortal(x,t.current)}function Pl(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Sa({className:e}){let t=H(),n=Sl(),o=useRef(null),r=useRef(null);useLayoutEffect(()=>{let c=o.current;if(!(!t||!c))return t.attach(c),()=>{t.detach();}},[t]);let i=useCallback(c=>{if(!n?.isEnabled)return;let s=c.clipboardData;s&&Pl(s)&&(c.preventDefault(),n.insertFromDataTransfer(s));},[n]),a=useCallback(c=>{!n?.isEnabled||!Pl(c.dataTransfer)||c.preventDefault();},[n]),l=useCallback(c=>{n?.isEnabled&&Pl(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:i,onDragOver:a,onDrop:l}),t?jsx(Tl,{containerRef:o,portalRef:r}):null]})}function Pe(e){return e/1440*96}function Ta(e){return e/96*1440}function Ye(e){return `${Math.round(e*100)/100}px`}function El(e){return e/2}var fb=e=>e.isLoading||e.isOpening===true,gb=e=>({width:Pe(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:Pe(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),bb=(e,t)=>e.width===t.width&&e.height===t.height;function wl({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function hb({when:e=false,overlay:t=false,className:n,style:o,children:r}){let i=O(fb),a=O(gb,bb),{t:l}=_();if(!e&&!i)return null;let c=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${n?` ${n}`:""}`;return jsx("div",{className:c,style:o,role:"status","aria-live":"polite",children:r??jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:a.width,height:a.height},children:jsx("div",{className:"docx-pages",children:jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxs("div",{className:"docx-editor__loading-page-status",children:[jsx(wl,{}),jsx("span",{className:"docx-editor-sr-only",children:l("loading.label")})]})})})})})}var Ca=Object.assign(hb,{Spinner:wl});function Vd(){let e=new Set,t=new Map,n=new Map,o=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let p=Object.create(null),g=[...t].sort((u,f)=>(n.get(u[0])??0)-(n.get(f[0])??0));for(let[,{author:u,style:f}]of g)p[u]=f;return {authors:p,others:e.size>0?"kind":"author"}}let l=null,c=false;function s(p){if(p===void 0)return "none";if(typeof p=="string")return p;let g=Object.entries(p.authors).map(([u,f])=>`${u}\0${JSON.stringify(f)}`).sort();return `${p.others??"kind"}${g.join("")}`}function d(){if(!r)return;let p=a(),g=s(p);if(g!==l){if(p===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(p),i=true,l=g;}}function m(){!r||c||(c=true,queueMicrotask(()=>{c=false,d();}));}return {registerScheme(p){e.add(p),m();},register(p,g,u){n.has(p)||n.set(p,o++),t.set(p,{author:g,style:u}),m();},unregister(p){(e.delete(p)||t.delete(p))&&m();},connect(p){r=p;let g=a();i=p!==null&&g!==void 0,l=p===null?null:s(g),m();},current:a}}var zn=createContext(null);function Gd(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function kl(){let e=useContext(zn),t=Gd();return useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function Rl(e){let{author:t,color:n,background:o,spanClassName:r,avatarUrl:i}=e,a=useContext(zn),l=Gd();return useEffect(()=>{if(a)return a.register(l,t,{...n!==void 0?{color:n}:{},...o!==void 0?{background:o}:{},...r!==void 0?{spanClassName:r}:{},...i!==void 0?{avatarUrl:i}:{}}),()=>a.unregister(l)},[a,l,t,n,o,r,i]),null}function Kn(e){return e.paragraphId===""}var ho=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),Eb=e=>e;function wb(){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,a=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(a))return {left:a.left,top:a.bottom}}return null}var $n=createContext(null);function Ml(){let e=useContext($n),t=Ea(e===null);return e??t}function Ea(e=true){let t=H(),[n,o]=useState(ho),r=useRef(null),i=useRef(n);i.current=n;let a=O(Eb),l=t?t.can({type:"insertText",text:""}).ok:false,c=useCallback(()=>{let v=r.current;v&&(v.editor.releaseSelection(v.pin),r.current=null);},[]),s=useCallback((v,x)=>{c(),o({mode:v?"reading":"editing",link:v??null,anchor:x??null,text:v?.text??"",url:v?v.kind==="internal"?`#${v.anchor??""}`:v.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c]),d=useCallback(()=>{c(),o(ho);},[c]);useEffect(()=>c,[c]);let m=useCallback(()=>{let v=wb();c();let x=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(x&&Kn(x)){s(x,v);return}if(x){o({mode:"editing",link:x,anchor:v,text:x.text,url:x.kind==="internal"?`#${x.anchor??""}`:x.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let b=t?.query({type:"selectedText"})??"",y=t?.retainSelection()??null;t&&y&&(r.current={editor:t,pin:y}),o({mode:"editing",link:null,anchor:v,text:b,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:v=>s(v.link,{left:v.rect.left,top:v.rect.bottom}),onRequest:m})},[t,e,s,m]),useEffect(()=>{let v=i.current;if(v.mode!=="reading"||!v.link)return;let x=Kn(v.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;x&&x.id===v.link.id||o(ho);},[a,t]),useEffect(()=>{let v=i.current;if(v.mode!=="editing"||v.link)return;let x=t?.surface;!x||x.retainedSelection()||o(ho);},[a,t]);let p=useCallback(async()=>{let v=i.current.link?.href;if(!v)return false;try{await navigator.clipboard.writeText(v);}catch{return false}return o(x=>({...x,copied:true})),true},[]),g=useCallback(()=>{o(v=>({...v,mode:"editing",copied:false,error:false}));},[]),u=useCallback(v=>{o(x=>({...x,text:v,copied:false,error:false}));},[]),f=useCallback(v=>{o(x=>({...x,url:v,copied:false,error:false}));},[]),h=useCallback(()=>{let v=i.current,x=t?.surface?.hyperlinks;if(!x)return false;let b=v.url.trim();if(b.length===0)return o(k=>({...k,error:true})),false;let y=b.startsWith("#");return x.applyHyperlink({...y?{anchor:b.slice(1)}:{url:b},...v.text.trim().length>0?{text:v.text}:{}})?(d(),true):(o(k=>({...k,error:true})),false)},[t,d]),S=useCallback(()=>{let v=t?.surface?.hyperlinks,x=i.current.link;if(!v)return false;let b=v.removeHyperlink(x?.id);return b&&d(),b},[t,d]),C=useCallback(()=>{let v=t?.surface?.navigation,x=i.current.link;if(!v||!x)return false;if(x.kind==="internal"){let y=x.anchor?v.goToBookmark(x.anchor):false;return y&&o(ho),y}let b=v.openExternal(x.href);return b&&o(ho),b},[t]);return useMemo(()=>({state:n.mode==="closed"?ho:{...n,canEdit:l},open:s,openAtCaret:m,close:d,copy:p,beginEdit:g,setText:u,setUrl:f,commitEdit:h,unlink:S,openTarget:C}),[n,l,s,m,d,p,g,u,f,h,S,C])}var Xe={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function Ib(e){return e==="sdtLocked"||e==="sdtContentLocked"}function _b(e){return e==="contentLocked"||e==="sdtContentLocked"}function _l(e,t){return !e.ok&&e.code===t}function Et(){let e=useContext(Dl),t=wa();return e??t}function wa(){let e=H(),[t,n]=useState(false),[o,r]=useState(false),[i,a]=useState(false),l=O(T=>T),c=e?.surface??null,s=c?.contentControls;useEffect(()=>{r(s?.showAll()??c?.state().contentControls.showAll??false),a(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,M=s?.disabledReason(T.id,"remove")??null;return {id:T.id,tag:T.tag??null,alias:T.alias??null,controlType:T.controlType,locked:_b(T.effectiveLock)||R==="locked",removalLocked:Ib(T.effectiveLock)||M==="locked",placeholder:T.placeholder,bound:T.bound||R==="bound",effectiveLock:T.effectiveLock}}let k=e.query({type:"contentControlAt"});if(!k)return null;let E=s?.disabledReason(k.id,"edit")??null,w=s?.disabledReason(k.id,"remove")??null,A=e.can({type:"setContentControlValue",value:""}),N=e.can({type:"removeContentControl"}),F=k.locked===true||E==="locked"||_l(A,"locked"),I=E==="bound"||_l(A,"bound"),D=w==="locked"||_l(N,"locked");return {id:k.id,tag:k.tag??null,alias:k.alias??null,controlType:k.controlType,locked:F,removalLocked:D,placeholder:false,bound:I,effectiveLock:null}},[e,l,s]),m=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),p=useCallback(T=>{s?.setShowAll(T),r(T);},[s]),g=useCallback(T=>{s?.setFormFill(T),a(T);},[s]),u=useCallback(()=>p(!o),[p,o]),f=useCallback(()=>g(!i),[g,i]),h=useCallback(()=>n(true),[]),S=useCallback(()=>n(false),[]),C=useCallback(()=>n(T=>!T),[]),v=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let k=s.disabledReason(d.id,"edit");return k==="locked"?"the content control is locked":k==="bound"?"the content control is bound to external data":k==="notFound"?"the content control was not found":k}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]),x=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let k=s.disabledReason(d.id,"remove");return k==="locked"?"the content control is locked":k==="notFound"?"the content control was not found":k}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]),b=useCallback(T=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(s&&d){let k=s.disabledReason(d.id,"edit");if(k)return {ok:false,code:k==="bound"?"bound":k==="locked"?"locked":"notFound",reason:k==="bound"?"the content control is bound to external data":k==="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 k=s.disabledReason(T,"remove");return k?{ok:false,code:k==="locked"?"locked":"notFound",reason:k==="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:m,showAll:o,formFill:i,inspectorOpen:t,canSetValue:v===null&&d!==null,canRemove:x===null&&d!==null,setValueDisabledReason:v,removeDisabledReason:x,setShowAll:p,toggleShowAll:u,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:S,toggleInspector:C,remove:y,setValue:b}),[d,m,o,i,t,v,x,p,u,g,f,h,S,C,y,b])}var Dl=createContext(null);function Yd(){let e=0,t=0,n=null,o=new Set,r=new Set,i=new Set,a=l=>{for(let c of [...l])c();};return {getShift:()=>e,setShift(l){let c=Math.max(0,Math.round(l));c!==e&&(e=c,a(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,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>n,setViewport(l){l!==n&&(n=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Ll=createContext(null);function yo(){return useContext(Ll)}var Xd=()=>0,Fl=()=>()=>{};function xo(){let e=yo(),t=useCallback(o=>e?e.subscribeShift(o):Fl(),[e]),n=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,n,Xd)}function Jd(){let e=yo(),t=useCallback(o=>e?e.subscribeReservation(o):Fl(),[e]),n=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,n,Xd)}function Ft(){let e=yo(),t=useCallback(r=>e?e.subscribeViewport(r):Fl(),[e]),n=useCallback(()=>e?e.getViewport():null,[e]),o=useCallback(()=>null,[]);return useSyncExternalStore(t,n,o)}function Ob(e,t){if(e===t)return true;let n=resolveZoomMode(e),o=resolveZoomMode(t);return n!==null&&o!==null&&sameZoomMode(n,o)}function Bb(e){let t=useRef(e);t.current=e;let[n,o]=useState(null),{onReady:r,onChange:i,onFontError:a,...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:Gn,rootProps:l,rootListeners:c,editorRef:n}}function Gn(e){let{document:t,fonts:n,zoom:o,zoomMode:r,tableInteractionLabel:i,imageDecodePort:a,children:l}=e,{t:c}=_(),s=useCallback((b,y)=>c(b,y),[c]),d=useRef(e);d.current=e;let[m,p]=useState(null),g=useRef(null);g.current??=Vd();let u=g.current;useEffect(()=>{let b=d.current,y=b.translate??s,T=u.current(),k=createDocxEditor({...b.document!==void 0?{document:b.document}:{},...b.fonts?{fonts:b.fonts}:{},...b.author!==void 0?{author:b.author}:{},...b.locale!==void 0?{locale:b.locale}:{},translate:y,...b.mode!==void 0?{mode:b.mode}:{},...T!==void 0?{revisionStyles:T}:{},...b.modules!==void 0?{modules:b.modules}:{},...b.zoom!==void 0?{zoom:b.zoom}:{},...b.zoomMode!==void 0?{zoomMode:b.zoomMode}:{},...b.tableInteractionLabel?{tableInteractionLabel:b.tableInteractionLabel}:{},...b.imageDecodePort?{imageDecodePort:b.imageDecodePort}:{},onFontError:w=>d.current.onFontError?.(w)}),E=k.on("change",w=>d.current.onChange?.(w));return p(k),()=>{E(),k.destroy(),p(w=>w===k?null:w);}},[t,n,s,a,u]),useEffect(()=>{if(!m)return;if(!m.snapshot().isOpening){d.current.onReady?.(m);return}let b=m.on("change",()=>{b(),d.current.onReady?.(m);});return b},[m]);let f=useRef({editor:null,zoom:void 0,mode:void 0});useEffect(()=>{if(!m)return;f.current.editor!==m&&(f.current={editor:m,zoom:void 0,mode:void 0});let y=false;o!==void 0&&o!==f.current.zoom&&(f.current.zoom=o,m.setZoom(o),y=true);let T=f.current.mode,k=r!==void 0&&(T===void 0||!Ob(T,r)),E=r===void 0?null:resolveZoomMode(r),w=y&&r!==void 0&&E!==null&&E.type==="fit";(k||w)&&(f.current.mode=r,m.setZoomMode(r));},[m,o,r]),useEffect(()=>{m&&m.setTableInteractionLabel(i??defaultTableLabel);},[m,i]);let[h,S]=useState(0),C=useRef([]),v=useMemo(()=>({mounted:h,register:()=>(S(b=>b+1),()=>S(b=>Math.max(0,b-1))),registerCommentDraft:b=>(C.current.push(b),()=>{let y=C.current.indexOf(b);y!==-1&&C.current.splice(y,1);}),requestCommentDraft:()=>{let b=C.current.at(-1);return b?(b(),true):false}}),[h]),x=useMemo(Yd,[]);return useEffect(()=>(u.connect(m),()=>u.connect(null)),[u,m]),jsx(ft.Provider,{value:v,children:jsx(cl.Provider,{value:m,children:jsx(Ll.Provider,{value:x,children:jsx(zn.Provider,{value:u,children:jsx(Zb,{children:jsx(qb,{children:jsx(ha,{children:l})})})})})})})}function Zb({children:e}){let t=Ea(true);return jsx($n.Provider,{value:t,children:e})}function qb({children:e}){let t=wa();return jsx(Dl.Provider,{value:t,children:e})}var Zl=316,Bl=44,Ub=24,ka={inlineStart:0,inlineEnd:Zl},Qd={inlineStart:Bl,inlineEnd:Bl},Wb={inlineStart:0,inlineEnd:0};function ou({open:e,viewportWidth:t,pageWidthPx:n,inlineStartReservation:o=0,docked:r=false}){if(!e)return Qd;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)return ka;let i=Number.isFinite(o)&&o>0?o:0;return t-i-n-2*Ub>=Zl?ka:Qd}var Gb=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}},jb=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function nu(){let e=Ft(),[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 tn(){let e=useContext(ft),{pageSetup:t,reviewPaneOpen:n,entitledZoom:o}=O(Gb,jb),r=Ft(),i=Jd(),a=useRef(null);t&&(a.current=t.pageWidthTwips);let l=t?.pageWidthTwips??a.current,c=(e?.mounted??0)>0,s=useCallback(p=>c?ou({open:n,viewportWidth:p??0,pageWidthPx:l===null||o===null?0:Pe(l)*o,inlineStartReservation:i,docked:o===null}):Wb,[c,n,l,o,i]),[d,m]=useState(()=>s(r?r.clientWidth:null));return useEffect(()=>{let p=()=>m(s(r?r.clientWidth:null));if(p(),!r||typeof ResizeObserver>"u")return;let g=new ResizeObserver(p);return g.observe(r),()=>g.disconnect()},[r,s]),d}var Ra=[.25,.5,.75,1,1.25,1.5,2];function jn(e,t){return t==="in"?Ra.find(o=>o>e+.001)??null:[...Ra].reverse().find(o=>o<e-.001)??null}function ru(e,t){return e==="0"?1:e==="+"||e==="="?jn(t,"in")??t:e==="-"?jn(t,"out")??t:null}var So=createContext(false);function ot(){return useContext(So)?"":"docx-editor "}var Qb=e=>e.reviewPaneOpen??true,eh=e=>e.zoomMode?.type==="fit";function Ma({className:e,style:t,children:n}){let o=ot(),r=H(),i=O(Qb),a=tn(),l=O(eh),s=(useContext(ft)?.mounted??0)>0,d=yo(),m=xo(),p=useCallback(u=>d?.setViewport(u),[d]),g=useCallback(u=>{if(!r||!(u.metaKey||u.ctrlKey)||u.altKey)return;let f=u.target;if(f instanceof Element&&f.closest('input, textarea, select, [role="dialog"]'))return;let h=ru(u.key,r.getZoom());h!==null&&(u.preventDefault(),r.setZoom(h));},[r]);return jsx("div",{ref:p,"data-testid":"docx-editor-scroll",onKeyDownCapture:g,...s?{"data-review-pane":i?"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":`${m}px`,...s?{"--docx-review-gutter":`${a.inlineEnd}px`,"--docx-review-gutter-start":`${a.inlineStart}px`}:{}},children:jsx(So.Provider,{value:true,children:n})})}var oh=LOADING_SNAPSHOT;function lu({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)??oh}),[t]);}var sh=e=>e.editingMode??"editing",ch=e=>e.isLoading||e.isOpening===true,zl=[{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"}],dh="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function _a({className:e,hidden:t}){let n=H(),o=O(sh),r=O(ch),i=X(),{t:a}=_(),[l,c]=useState(false),s=useRef(null),d=useRef(null),m=useRef(null);useEffect(()=>{if(!l)return;let C=m.current?.querySelectorAll('[role="menuitemradio"]');(m.current?.querySelector('[aria-checked="true"]')??C?.[0]??void 0)?.focus();},[l]);let p=useCallback(C=>{let v=[...m.current?.querySelectorAll('[role="menuitemradio"]')??[]],x=v.indexOf(document.activeElement),b=y=>{C.preventDefault(),v[(y+v.length)%v.length]?.focus();};C.key==="ArrowDown"?b(x+1):C.key==="ArrowUp"?b(x-1):C.key==="Home"?b(0):C.key==="End"&&b(v.length-1);},[]);useEffect(()=>{if(!l)return;let C=x=>{let b=s.current;b&&x.target instanceof Node&&b.contains(x.target)||c(false);},v=x=>{x.key==="Escape"&&(x.preventDefault(),c(false));};return document.addEventListener("mousedown",C,true),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",C,true),document.removeEventListener("keydown",v);}},[l]);let g=useCallback(C=>{c(false),runToolbarCommand(n,"review.editingMode",C),n?.focus();},[n]),u=toolbarCommandState(n,"review.editingMode"),f=localizeDisabledReason(u.disabledReason,a),h=useMemo(()=>zl.find(C=>C.mode===o)??zl[0],[o]);if(t)return null;let S=J("review.editingMode");return jsxs("div",{ref:s,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":o,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(S?.labelKey??"editingMode.label"),disabled:r||!u.enabled,...f?{title:f}:{},onMouseDown:B,onClick:()=>c(C=>!C),children:[Kl(h.path),jsx("span",{className:"docx-toolbar__picker-value",children:i(h.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(S?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:p,children:zl.map(C=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":C.mode===o,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${C.mode}`,onMouseDown:B,onClick:()=>g(C.mode),children:[Kl(C.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:i(C.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:i(C.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:C.mode===o?Kl(dh):null})]},C.mode))}):null]})}_a.docxSlot="review.editingMode";function Kl(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 on(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 Na({entries:e,children:t,preset:n,keyOfEntry:o,keyOfChild:r,renderEntry:i}){if(!n)return t;let a=new Map,l=[];for(let m of Children.toArray(t)){let p=r(m);p?a.set(p,m):l.push(m);}let c=e.map((m,p)=>{let g=o(m,p),u=a.get(g);return u?jsx(Fragment$1,{children:u},g):jsx(Fragment$1,{children:i(m,p)},g)}),s=new Set(e.map(o)),d=[...a.entries()].filter(([m])=>!s.has(m)).map(([m,p])=>jsx(Fragment$1,{children:p},m));return jsxs(Fragment,{children:[c,d,l]})}var bh={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},hh=e=>{let t=e.formatting??null;if(!t)return null;let n=t.indent,o=t.paragraphFlags??bh;return {alignment:t.alignment==="both"?"justify":t.alignment??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:n&&!n.mixed.left?n.left:null,indentRightTwips:n&&!n.mixed.right?n.right:null,indentFirstLineTwips:n&&!n.mixed.firstLine?n.firstLine:null,contextualSpacing:o.contextualSpacing,keepNext:o.keepNext,keepLines:o.keepLines,widowControl:o.widowControl,pageBreakBefore:o.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!n,disagrees:{alignment:t.disagrees?.alignment??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:n?.mixed.left??false,indentRight:n?.mixed.right??false,indentFirstLine:n?.mixed.firstLine??false}}},vh=["alignment","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],yh=(e,t)=>vh.every(n=>e.disagrees[n]===t.disagrees[n]),xh=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value&&e.indentLeftTwips===t.indentLeftTwips&&e.indentRightTwips===t.indentRightTwips&&e.indentFirstLineTwips===t.indentFirstLineTwips&&e.contextualSpacing===t.contextualSpacing&&e.keepNext===t.keepNext&&e.keepLines===t.keepLines&&e.widowControl===t.widowControl&&e.pageBreakBefore===t.pageBreakBefore&&yh(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((n,o)=>n.positionTwips===t.tabStops?.[o]?.positionTwips&&n.alignment===t.tabStops?.[o]?.alignment&&(n.leader??"none")===(t.tabStops?.[o]?.leader??"none")),Sh=e=>e.editable;function Vl(){let e=H(),t=O(hh,xh),n=O(Sh),o=useMemo(()=>n&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,n]),r=useCallback(i=>{if(!e)return false;let a={type:"setParagraphFormat",...i};return e.can(a).ok?e.exec(a).ok:false},[e]);return {format:t,isEnabled:o,apply:r}}var Yn=e=>Math.round(e/1440*100)/100,Ul=e=>Yn(e).toLocaleString(void 0,{maximumFractionDigits:2}),La=e=>Math.round(e*1440),uu={left:"dialogs.paragraph.tabAlignLeft",center:"dialogs.paragraph.tabAlignCenter",right:"dialogs.paragraph.tabAlignRight",decimal:"dialogs.paragraph.tabAlignDecimal",bar:"dialogs.paragraph.tabAlignBar"},Th=e=>e===null||e===0?"none":e<0?"hanging":"firstLine",Ch=(e,t)=>e==="none"?0:e==="hanging"?-Math.abs(t):Math.abs(t);function pu(e){let t=e.indentFirstLineTwips;return {alignment:e.alignment??"left",indentLeft:e.indentLeftTwips??0,indentRight:e.indentRightTwips??0,special:Th(t),specialBy:Math.abs(t??0),spaceBefore:e.spaceBeforePt??0,spaceAfter:e.spaceAfterPt??0,lineRule:e.lineSpacing?.rule??"multiple",lineValue:e.lineSpacing?.value??1.08,contextualSpacing:e.contextualSpacing===true,keepNext:e.keepNext===true,keepLines:e.keepLines===true,widowControl:e.widowControl!==false,pageBreakBefore:e.pageBreakBefore===true,tabStops:e.tabStops??[],clearedAllTabStops:false}}var Fa={contextualSpacing:false,keepNext:false,keepLines:false,widowControl:false,pageBreakBefore:false,tabStops:false,alignment:false,indentLeft:false,indentRight:false,special:false,spaceBefore:false,spaceAfter:false,lineSpacing:false};function mu(e){return {contextualSpacing:e.contextualSpacing===null,keepNext:e.keepNext===null,keepLines:e.keepLines===null,widowControl:e.widowControl===null,pageBreakBefore:e.pageBreakBefore===null,tabStops:e.disagrees.tabStops,alignment:e.disagrees.alignment,indentLeft:e.disagrees.indentLeft||e.indentUnknown,indentRight:e.disagrees.indentRight||e.indentUnknown,special:e.disagrees.indentFirstLine||e.indentUnknown,spaceBefore:e.disagrees.spaceBeforePt,spaceAfter:e.disagrees.spaceAfterPt,lineSpacing:e.disagrees.lineSpacing}}function Ph(e,t){return e===t?true:e.length!==t.length?false:e.every((n,o)=>{let r=t[o];return r!==void 0&&n.positionTwips===r.positionTwips&&n.alignment===r.alignment&&(n.leader??"none")===(r.leader??"none")})}function fu(e,t,n=Fa,o=n){let r={},i=false,a=(c,s)=>{r[c]=s,i=true;},l=c=>n[c]&&!o[c];return (e.alignment!==t.alignment||l("alignment"))&&a("alignment",t.alignment),(e.indentLeft!==t.indentLeft||l("indentLeft"))&&a("indentLeftTwips",t.indentLeft),(e.indentRight!==t.indentRight||l("indentRight"))&&a("indentRightTwips",t.indentRight),(e.special!==t.special||e.specialBy!==t.specialBy||l("special"))&&a("indentFirstLineTwips",Ch(t.special,t.specialBy)),(e.spaceBefore!==t.spaceBefore||l("spaceBefore"))&&a("spaceBeforePt",t.spaceBefore),(e.spaceAfter!==t.spaceAfter||l("spaceAfter"))&&a("spaceAfterPt",t.spaceAfter),!o.lineSpacing&&(e.lineRule!==t.lineRule||e.lineValue!==t.lineValue||l("lineSpacing"))&&a("lineSpacing",{rule:t.lineRule,value:t.lineValue}),(e.contextualSpacing!==t.contextualSpacing||l("contextualSpacing"))&&a("contextualSpacing",t.contextualSpacing),(e.keepNext!==t.keepNext||l("keepNext"))&&a("keepNext",t.keepNext),(e.keepLines!==t.keepLines||l("keepLines"))&&a("keepLines",t.keepLines),(e.widowControl!==t.widowControl||l("widowControl"))&&a("widowControl",t.widowControl),(e.pageBreakBefore!==t.pageBreakBefore||l("pageBreakBefore"))&&a("pageBreakBefore",t.pageBreakBefore),(!Ph(e.tabStops,t.tabStops)||l("tabStops")&&t.clearedAllTabStops)&&a("tabStops",t.tabStops),i?r:null}function gu(e,t){return [...e.filter(o=>o.positionTwips!==t.positionTwips),t].sort((o,r)=>o.positionTwips-r.positionTwips)}function bu(e,t){if(t.key!=="Tab")return false;let n=[...e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')].filter(a=>!a.hasAttribute("disabled")&&a.tabIndex!==-1);if(n.length===0)return false;let o=n[0],r=n[n.length-1],i=e.ownerDocument.activeElement;return t.shiftKey&&(i===o||i===e)?(r.focus(),true):!t.shiftKey&&i===r?(o.focus(),true):false}var kh={marginRight:"auto",fontSize:"12px",color:"var(--doc-danger)"},Rh={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},Mh={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:620,maxWidth:720,width:"100%",margin:20,maxHeight:"90vh",display:"flex",flexDirection:"column",minHeight:0},Ih={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",flexShrink:0,fontSize:16,fontWeight:600,color:"var(--doc-text)"},_h={padding:"16px 20px",overflowY:"auto",minHeight:0},Dh={display:"grid",gridTemplateColumns:"1fr 1fr",gap:28},yu={display:"flex",flexDirection:"column",gap:14,minWidth:0},Xn={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},it={display:"flex",alignItems:"center",gap:12},bt={width:92,fontSize:13,color:"var(--doc-text-muted)"},wt={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Jn={fontSize:11,color:"var(--doc-text-muted)",width:20},Nh={display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--doc-text)"},Lh={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,flexShrink:0},Qn={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"};function To({open:e,onClose:t,className:n}){let{t:o}=_(),{format:r,isEnabled:i,apply:a}=Vl(),[l,c]=useState("left"),[s,d]=useState(0),[m,p]=useState(0),[g,u]=useState("none"),[f,h]=useState(0),[S,C]=useState(0),[v,x]=useState(0),[b,y]=useState("multiple"),[T,k]=useState(1.08),[E,w]=useState(false),[A,N]=useState(false),[F,I]=useState(false),[D,R]=useState(true),[M,ae]=useState(false),[K,$]=useState([]),[V,oe]=useState(false),[ne,be]=useState(0),[he,W]=useState("left"),[Z,we]=useState("none"),[ce,de]=useState(Fa),[Ve,uo]=useState(false),mt=q=>o(Ve&&(q==="indentLeft"||q==="indentRight"||q==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),po=useRef(Fa),Me=useId(),[sl,Fn]=useState(false),Pt=useRef(null),An=useRef(false),Yo=useRef(null);useEffect(()=>{if(!e){An.current=false;return}if(An.current||r===null)return;let q=pu(r);c(q.alignment),d(q.indentLeft),p(q.indentRight),u(q.special),h(q.specialBy),C(q.spaceBefore),x(q.spaceAfter),y(q.lineRule),k(q.lineValue),w(q.contextualSpacing),N(q.keepNext),I(q.keepLines),R(q.widowControl),ae(q.pageBreakBefore),$(q.tabStops),oe(false);let ve=mu(r);de(ve),uo(r.indentUnknown),be(0),W("left"),we("none"),po.current=ve,Fn(false),Yo.current=q,An.current=true;},[e,r]),useEffect(()=>{e&&Pt.current?.focus();},[e]);let pe=useCallback(()=>{let q=Yo.current,ve=q===null?null:fu(q,{alignment:l,indentLeft:s,indentRight:m,special:g,specialBy:f,spaceBefore:S,spaceAfter:v,lineRule:b,lineValue:T,contextualSpacing:E,keepNext:A,keepLines:F,widowControl:D,pageBreakBefore:M,tabStops:K,clearedAllTabStops:V},po.current,ce);if(ve===null){t();return}if(a(ve)){Fn(false),t();return}Fn(true);},[a,t,ce,V,l,s,m,g,f,S,v,b,T,E,A,F,D,M,K]),me=useCallback(()=>{let q=Math.round(ne);return q<=0?false:(de(ve=>({...ve,tabStops:false})),$(gu(K,{positionTwips:q,alignment:he,...Z!=="none"?{leader:Z}:{}})),be(0),W("left"),we("none"),true)},[K,ne,he,Z]);if(!e)return null;let at=q=>de(ve=>({...ve,[q]:false})),Hn=(q,ve,Kt,Ue)=>jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-${q}`,children:o(`dialogs.paragraph.${q}`)}),jsx("input",{id:`${Me}-${q}`,type:"number",style:wt,min:0,step:.1,value:ce[Ue]?"":Yn(ve),placeholder:ce[Ue]?mt(Ue):void 0,onChange:On=>{at(Ue),Kt(La(Number(On.target.value)||0));},"aria-label":o(`dialogs.paragraph.${q}`)}),jsx("span",{style:Jn,children:o("dialogs.paragraph.unitInches")})]}),ua=(q,ve,Kt,Ue)=>jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-${q}`,children:o(`dialogs.paragraph.${q}`)}),jsx("input",{id:`${Me}-${q}`,type:"number",style:wt,min:0,step:1,value:ce[Ue]?"":ve,placeholder:ce[Ue]?mt(Ue):void 0,onChange:On=>{at(Ue),Kt(Math.max(0,Number(On.target.value)||0));},"aria-label":o(`dialogs.paragraph.${q}`)}),jsx("span",{style:Jn,children:o("dialogs.paragraph.unitPoints")})]}),mo=(q,ve,Kt)=>jsxs("label",{style:Nh,children:[jsx("input",{type:"checkbox",checked:ve,ref:Ue=>{Ue&&(Ue.indeterminate=ce[q]);},onChange:Ue=>{de(On=>({...On,[q]:false})),Kt(Ue.target.checked);}}),o(`dialogs.paragraph.${q}`)]}),gd=`docx-editor${document.querySelector(".docx-editor")?.classList.contains("dark")?" dark":""}`;return createPortal(jsx("div",{className:gd,style:{display:"contents"},children:jsx("div",{className:n,style:Rh,onClick:t,onKeyDown:q=>{q.key==="Escape"&&t(),Pt.current&&bu(Pt.current,q.nativeEvent)&&q.preventDefault();let ve=q.target instanceof HTMLButtonElement||q.target instanceof HTMLSelectElement;if(q.key==="Enter"&&!ve){let Kt=q.target;if(Kt instanceof HTMLElement&&Kt.dataset.docxTabEntry!==void 0){me();return}i&&pe();}},children:jsxs("div",{ref:Pt,role:"dialog","aria-modal":"true","aria-label":o("dialogs.paragraph.title"),tabIndex:-1,style:Mh,onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:[jsx("div",{style:Ih,children:o("dialogs.paragraph.title")}),jsx("div",{style:_h,children:jsxs("div",{style:Dh,children:[jsxs("div",{style:yu,children:[jsx("div",{style:Xn,children:o("dialogs.paragraph.general")}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-alignment`,children:o("dialogs.paragraph.alignment")}),jsxs("select",{id:`${Me}-alignment`,style:wt,value:ce.alignment?"":l,onChange:q=>{at("alignment"),c(q.target.value);},"aria-label":o("dialogs.paragraph.alignment"),children:[ce.alignment?jsx("option",{value:"",children:o("dialogs.paragraph.mixed")}):null,jsx("option",{value:"left",children:o("dialogs.paragraph.alignLeft")}),jsx("option",{value:"center",children:o("dialogs.paragraph.alignCenter")}),jsx("option",{value:"right",children:o("dialogs.paragraph.alignRight")}),jsx("option",{value:"justify",children:o("dialogs.paragraph.alignJustify")})]})]}),jsx("div",{style:Xn,children:o("dialogs.paragraph.indentation")}),Hn("beforeText",s,d,"indentLeft"),Hn("afterText",m,p,"indentRight"),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-special`,children:o("dialogs.paragraph.special")}),jsxs("select",{id:`${Me}-special`,style:wt,value:ce.special?"":g,onChange:q=>{at("special"),u(q.target.value);},"aria-label":o("dialogs.paragraph.special"),children:[ce.special?jsx("option",{value:"",children:mt("special")}):null,jsx("option",{value:"none",children:o("dialogs.paragraph.specialNone")}),jsx("option",{value:"firstLine",children:o("dialogs.paragraph.specialFirstLine")}),jsx("option",{value:"hanging",children:o("dialogs.paragraph.specialHanging")})]})]}),g!=="none"?jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-by`,children:o("dialogs.paragraph.by")}),jsx("input",{id:`${Me}-by`,type:"number",style:wt,min:0,step:.1,value:ce.special?"":Yn(f),placeholder:ce.special?mt("special"):void 0,onChange:q=>{at("special"),h(Math.max(0,La(Number(q.target.value)||0)));},"aria-label":o("dialogs.paragraph.by")}),jsx("span",{style:Jn,children:o("dialogs.paragraph.unitInches")})]}):null,jsx("div",{style:Xn,children:o("dialogs.paragraph.tabStops")}),K.length===0?jsx("div",{style:{fontSize:12,color:"var(--doc-text-muted)"},children:o(ce.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):K.map(q=>jsxs("div",{style:it,children:[jsx("span",{style:{...bt,color:"var(--doc-text)"},children:o("dialogs.paragraph.tabPositionLabel",{position:Ul(q.positionTwips)})}),jsx("span",{style:{flex:1,fontSize:13,color:"var(--doc-text-muted)"},children:o(uu[q.alignment])}),jsx("button",{type:"button",style:Qn,onClick:()=>$(K.filter(ve=>ve!==q)),"aria-label":o("dialogs.paragraph.tabRemoveAt",{position:Ul(q.positionTwips)}),children:o("dialogs.paragraph.tabRemove")})]},q.positionTwips)),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabPosition`,children:o("dialogs.paragraph.tabPosition")}),jsx("input",{id:`${Me}-tabPosition`,type:"number",style:wt,min:0,step:.1,value:Yn(ne),onChange:q=>be(Math.max(0,La(Number(q.target.value)||0))),"aria-label":o("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsx("span",{style:Jn,children:o("dialogs.paragraph.unitInches")})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabAlignment`,children:o("dialogs.paragraph.tabAlignment")}),jsxs("select",{id:`${Me}-tabAlignment`,style:wt,value:he,onChange:q=>W(q.target.value),"aria-label":o("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsx("option",{value:"left",children:o("dialogs.paragraph.tabAlignLeft")}),jsx("option",{value:"center",children:o("dialogs.paragraph.tabAlignCenter")}),jsx("option",{value:"right",children:o("dialogs.paragraph.tabAlignRight")}),jsx("option",{value:"decimal",children:o("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabLeader`,children:o("dialogs.paragraph.tabLeader")}),jsxs("select",{id:`${Me}-tabLeader`,style:wt,value:Z,onChange:q=>we(q.target.value),"aria-label":o("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsx("option",{value:"none",children:o("dialogs.paragraph.tabNone")}),jsx("option",{value:"dot",children:o("dialogs.paragraph.tabLeaderDot")}),jsx("option",{value:"hyphen",children:o("dialogs.paragraph.tabLeaderHyphen")}),jsx("option",{value:"underscore",children:o("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxs("div",{style:{...it,justifyContent:"flex-end"},children:[jsx("button",{type:"button",style:Qn,onClick:me,children:o("dialogs.paragraph.tabAdd")}),jsx("button",{type:"button",style:Qn,onClick:()=>{de(q=>({...q,tabStops:false})),oe(true),$([]);},children:o("dialogs.paragraph.tabClearAll")})]})]}),jsxs("div",{style:yu,children:[jsx("div",{style:Xn,children:o("dialogs.paragraph.spacing")}),ua("spaceBefore",S,C,"spaceBefore"),ua("spaceAfter",v,x,"spaceAfter"),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-lineSpacing`,children:o("dialogs.paragraph.lineSpacing")}),jsxs("select",{id:`${Me}-lineSpacing`,style:wt,value:ce.lineSpacing?"":b,onChange:q=>{let ve=q.target.value;at("lineSpacing"),y(ve),k(ve===Yo.current?.lineRule?Yo.current.lineValue:ve==="multiple"?1.08:12);},"aria-label":o("dialogs.paragraph.lineSpacing"),children:[ce.lineSpacing?jsx("option",{value:"",children:o("dialogs.paragraph.mixed")}):null,jsx("option",{value:"multiple",children:o("dialogs.paragraph.ruleMultiple")}),jsx("option",{value:"atLeast",children:o("dialogs.paragraph.ruleAtLeast")}),jsx("option",{value:"exact",children:o("dialogs.paragraph.ruleExactly")})]})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-at`,children:o("dialogs.paragraph.at")}),jsx("input",{id:`${Me}-at`,type:"number",style:wt,min:.01,step:b==="multiple"?.01:1,value:ce.lineSpacing?"":T,disabled:ce.lineSpacing,onChange:q=>{let ve=q.target.value.trim();k(ve===""?b==="multiple"?1.08:12:Number(ve)||0);},"aria-label":o("dialogs.paragraph.at")}),jsx("span",{style:Jn,children:b==="multiple"?"":o("dialogs.paragraph.unitPoints")})]}),mo("contextualSpacing",E,w),jsx("div",{style:Xn,children:o("dialogs.paragraph.pagination")}),mo("keepNext",A,N),mo("widowControl",D,R),mo("keepLines",F,I),mo("pageBreakBefore",M,ae)]})]})}),jsxs("div",{style:Lh,children:[sl?jsx("span",{role:"alert",style:kh,children:o("dialogs.paragraph.refused")}):null,jsx("button",{type:"button",style:Qn,onClick:t,children:o("dialogs.paragraph.cancel")}),jsx("button",{type:"button",style:{...Qn,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:i?1:.5},disabled:!i,onClick:pe,children:o("dialogs.paragraph.ok")})]})]})})}),document.body)}var xu=createContext(null);function Su({children:e}){let[t,n]=useState(false),o=useRef(null),r=useMemo(()=>({open:a=>{o.current=a??document.activeElement,n(true);}}),[]),i=useCallback(()=>{n(false);let a=o.current;o.current=null,a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:true});},[]);return jsxs(xu.Provider,{value:r,children:[e,jsx(To,{open:t,onClose:i})]})}function Tu(){return useContext(xu)}var Kh=["zoom","script","format","list","alignment","styles","font","text","history"],Wl=new Set(["review"]),Gl=24,Pu=new Set;function Eu(e,t=Kh){let n=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...n]}function Cu(e,t){let{widths:n,groups:o,order:r,fixed:i,more:a}=e,l=i;for(let s of o)l+=n.get(s)??0;if(l<=t)return Pu;l+=a;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 wu(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 ku=wu;function Ru(e){if(!(e.available>0))return Pu;let t=Cu(e,e.available),n=e.previous;if(!n||n.size===0||t.size>=n.size)return t;let o=Cu(e,e.available-(e.hysteresis));return wu(o,n)?n:o}function Mu(e,t,n,o){return e+t+n+o*2}function Iu(e,t){return e+t}function Yl(e,t){return e+t}function _u(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 jl(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Du(e){return jl(e.columnGap)}function Nu(e,t){return e.clientWidth-jl(t.paddingLeft)-jl(t.paddingRight)}var tr="data-toolbar-group",or="data-toolbar-fixed",Jl="data-toolbar-more",Wh=34,Xl=new Set;function Fu(e,t,n){let o=useRef(null),r=useRef(new Map),i=useRef(Wh),[a,l]=useState(Xl),c=useRef(a);c.current=a;let s=useRef({groups:t,order:n});s.current={groups:t,order:n};let d=useCallback(()=>{let p=o.current;if(!p||!e)return;let g=getComputedStyle(p),u=Du(g),f=Nu(p,g),h=p.querySelector(".docx-toolbar__separator"),S=u*2;if(h){let y=getComputedStyle(h),T=_u(y);S=Mu(h.offsetWidth,T.start,T.end,u);}for(let y of p.querySelectorAll(`[${tr}]`)){let T=y.getAttribute(tr);T&&y.offsetWidth>0&&r.current.set(T,Iu(y.offsetWidth,S));}let C=0;for(let y of p.querySelectorAll(`[${or}]`))y.offsetWidth>0&&(C+=Yl(y.offsetWidth,u));let v=p.querySelector(`[${Jl}]`);v&&v.offsetWidth>0&&(i.current=Yl(v.offsetWidth,u));let x={available:f,widths:r.current,groups:s.current.groups,order:s.current.order,fixed:C,more:i.current,previous:c.current,hysteresis:Gl},b=Ru(x);ku(b,c.current)||(c.current=b,l(b));},[e]),m=useCallback(p=>{o.current=p;},[]);return useLayoutEffect(()=>{if(!e){c.current.size>0&&(c.current=Xl,l(Xl));return}d();},[e,d]),useEffect(()=>{let p=o.current;if(!e||!p||typeof ResizeObserver>"u")return;let g=0,u=new ResizeObserver(()=>{g===0&&(g=requestAnimationFrame(()=>{g=0,d();}));});u.observe(p);for(let f of p.querySelectorAll(`[${tr}], [${or}]`))u.observe(f);return ()=>{g!==0&&cancelAnimationFrame(g),u.disconnect();}},[e,d,a]),{attach:m,overflow:a}}var tv=["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"],Hu=createContext({close:()=>{}});function ov(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function Ou({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 Bu({slot:e}){let t=X(),{close:n}=useContext(Hu),{execute:o,isActive:r,isEnabled:i,disabledReason:a}=le(e),l=J(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:!i,...a?{title:a}:{},...s?{"aria-pressed":r}:{},...r?{"data-active":""}:{},onMouseDown:B,onClick:m=>{o(),n(m.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(l?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:d})]})}function Zu({sections:e,className:t}){let n=X(),[o,r]=useState(false),i=useRef(null),a=useRef(null),l=useRef(null),c=useRef(false),s=useId(),d=n("formattingBar.more"),m=useCallback(u=>{r(false),u&&a.current?.focus();},[]),p=useMemo(()=>({close:m}),[m]);useEffect(()=>{if(!o)return;let u=f=>{let h=f.target;h instanceof Node&&i.current?.contains(h)||r(false);};return document.addEventListener("mousedown",u,true),()=>document.removeEventListener("mousedown",u,true)},[o]),useEffect(()=>{if(!o||!c.current)return;c.current=false;let u=l.current;u&&ov(u);},[o]);let g=u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),m(true));};return jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Jl]:"",children:[jsx("button",{ref:a,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:B,onClick:()=>r(u=>!u),onKeyDown:u=>{u.key==="ArrowDown"&&(u.preventDefault(),c.current=true,r(true));},children:re(tv)}),o?jsx(Hu.Provider,{value:p,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(u=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":n(u.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:n(u.labelKey)}),u.children]},u.id))})}):null]})}function lv(e,t){return e.value===t.value&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function nr(e){let t=H(),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=O(o,lv),i=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.wrap",l),value:r.value??null,options:IMAGE_WRAP_TARGETS,isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]),a=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.altText",l),value:r.value,options:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]);return e==="image.wrap"?i:a}var es=[{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 Za({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),i=X(),{execute:a,value:l,isEnabled:c,disabledReason:s}=nr("image.wrap"),[d,m]=useState(false),p=useRef(null),g=useRef(null),u=useRef(null),f=useId(),h=useMemo(()=>es.find(y=>y.value===l)??es[0],[l]),S=J("image.wrap"),C=i(S?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let y=k=>{let E=p.current;E&&k.target instanceof Node&&E.contains(k.target)||m(false);},T=k=>{k.key==="Escape"&&(k.preventDefault(),m(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 v=useCallback(y=>{m(false),a(y);},[a]);if(t)return null;let x=r("imageWrap.tooltipPrefix",{label:r(h.labelKey)}),b={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":C,title:s??x,onMouseDown:B,onClick:()=>m(y=>!y)};return jsxs("div",{ref:p,className:"docx-toolbar__image-wrap",children:[n?jsx(j,{...b,children:o}):jsx("button",{...b,children:o??re(S?.paths)}),d?jsx("div",{ref:u,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:y=>y.stopPropagation(),children:es.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:B,onClick:()=>v(y.value),children:r(y.labelKey)},y.value))}):null]})}Za.docxSlot="image.wrap";var rr=Object.assign(Za,{docxSlot:"image.wrap"});function qa({className:e,hidden:t,asChild:n,children:o}){let{t:r}=_(),i=X(),{execute:a,value:l,isEnabled:c,disabledReason:s}=nr("image.altText"),[d,m]=useState(false),[p,g]=useState(""),u=useRef(null),f=useRef(null),h=useId();useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let b=T=>{let k=u.current;k&&T.target instanceof Node&&k.contains(T.target)||m(false);},y=T=>{T.key==="Escape"&&(T.preventDefault(),m(false),f.current?.focus());};return document.addEventListener("mousedown",b,true),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",b,true),document.removeEventListener("keydown",y);}},[d]);let S=useCallback(()=>{a(p),m(false);},[p,a]);if(t)return null;let C=J("image.altText"),v=i(C?.labelKey??"formattingBar.altText"),x={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?h:void 0,"aria-label":v,title:s??v,onMouseDown:B,onClick:()=>m(b=>!b)};return jsxs("div",{ref:u,className:"docx-toolbar__alt-text",children:[n?jsx(j,{...x,children:o}):jsx("button",{...x,children:o??v}),d?jsxs("div",{id:h,role:"dialog","aria-label":r("imageAltText.panelTitle"),className:"docx-toolbar__alt-text-panel",onMouseDown:b=>b.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:p,onChange:b=>g(b.target.value),placeholder:r("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>m(false),children:r("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:S,children:r("common.apply")})]})]}):null]})}qa.docxSlot="image.altText";var ar=Object.assign(qa,{docxSlot:"image.altText"});var Gu=e=>e.image;function Wu(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 Tv(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function as(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 Cv(e,t){let n=as(t);return e.horizontalPoints!==n.horizontalPoints||e.verticalPoints!==n.verticalPoints||e.relativeToH!==n.relativeToH||e.relativeToV!==n.relativeToV}function za(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 Pv(e,t){let n=as(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let s=e.horizontalPoints!==n.horizontalPoints,d=e.verticalPoints!==n.verticalPoints,m=s?za(e.horizontalPoints):t.position?.horizontalEmu,p=d?za(e.verticalPoints):t.position?.verticalEmu;return s&&m===null?{ok:false}:d&&p===null?{ok:false}:m===void 0||p===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,verticalEmu:p}}}let o=e.horizontalPoints!==n.horizontalPoints,r=e.verticalPoints!==n.verticalPoints,i=e.relativeToH!==n.relativeToH,a=e.relativeToV!==n.relativeToV,l=o?za(e.horizontalPoints):t.position?.horizontalEmu,c=r?za(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}:{},...i||o||r?{relativeToH:e.relativeToH}:{},...a||o||r?{relativeToV:e.relativeToV}:{}}}}function Ka(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function $a(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function is({open:e,onClose:t,className:n,triggerRef:o}){let r=H(),{t:i}=_(),a=O(Gu),l=useId(),c=useId(),s=useId(),d=useRef(null),m=useRef(null),p=useRef(null),g=useRef(null),[u,f]=useState(null),[h,S]=useState(null),C=m.current,v=C?.canCrop===false,x=C?.canResize===false,b=C?.locks.changeAspect===true,y=C?.kind==="anchored"&&C.canMove===true,T=C?.kind==="inline",k=C?.kind==="anchored"&&C.canMove===false;useEffect(()=>{if(!e){m.current=null,p.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:ae}=r.surface.state().selection;p.current={paragraphId:ae.paragraphId,offset:ae.offset},g.current=r.surface.session.packageRevision();}S(null);let R=as(a),M=a.crop;f({widthPoints:String($t(a.widthEmu)),heightPoints:String($t(a.heightEmu)),cropLeft:String(M.left),cropTop:String(M.top),cropRight:String(M.right),cropBottom:String(M.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...R});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let E=useCallback(()=>{o?.current?.focus(),r?.focus();},[r,o]),w=useCallback(()=>{t(),E();},[t,E]);useEffect(()=>{if(!e)return;let R=d.current;if(!R)return;let M=Wu(R);(M.find($=>$.id==="image-prop-width"&&!$.hasAttribute("disabled"))??M.find($=>!$.hasAttribute("disabled"))??R).focus();let K=$=>{if($.key==="Escape"){$.preventDefault(),w();return}if($.key!=="Tab")return;let V=Wu(R);if(V.length===0)return;let oe=document.activeElement,ne=V.findIndex(he=>he===oe);if(ne===-1)return;$.preventDefault();let be=$.shiftKey?(ne-1+V.length)%V.length:(ne+1)%V.length;V[be]?.focus();};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[e,w]);let A=useMemo(()=>{let R=C??a;return !R||R.widthEmu<=0?1:R.widthEmu/R.heightEmu},[a,C]),N=useCallback(R=>{f(M=>{if(!M)return M;if(!M.lockAspect)return {...M,widthPoints:R};let ae=$a(R);if(ae===null)return {...M,widthPoints:R};let K=Math.round(ae/A*100)/100;return {...M,widthPoints:R,heightPoints:String(K)}});},[A]),F=useCallback(R=>{f(M=>{if(!M)return M;if(!M.lockAspect)return {...M,heightPoints:R};let ae=$a(R);if(ae===null)return {...M,heightPoints:R};let K=Math.round(ae*A*100)/100;return {...M,widthPoints:String(K),heightPoints:R}});},[A]),I=useCallback(()=>{let R=m.current;if(!R?.intrinsic)return;let M=R.intrinsic.pixelWidth*72/R.intrinsic.dpiX,ae=R.intrinsic.pixelHeight*72/R.intrinsic.dpiY;f(K=>K&&{...K,widthPoints:String(Math.round(M*100)/100),heightPoints:String(Math.round(ae*100)/100)});},[a]),D=useCallback(()=>{let R=m.current,M=p.current,ae=g.current;if(!r||!R||!u||!M||ae===null)return;let K={type:"setImageProperties",drawingNodeId:R.id,expectedPackageRevision:ae,selectionParagraphId:M.paragraphId,selectionOffset:M.offset};if(!x){let he=$a(u.widthPoints),W=$a(u.heightPoints);if(he===null||W===null){S("imageProperties.errors.invalidDimensions");return}let Z=Bn(he),we=Bn(W);Z!==R.widthEmu&&(K.widthEmu=Z),we!==R.heightEmu&&(K.heightEmu=we);}if(R.canCrop&&!v){let he=Ka(u.cropLeft),W=Ka(u.cropTop),Z=Ka(u.cropRight),we=Ka(u.cropBottom);if(he===null||W===null||Z===null||we===null){S("imageProperties.errors.invalidCrop");return}let ce=R.crop;(he!==ce.left||W!==ce.top||Z!==ce.right||we!==ce.bottom)&&(K.crop={left:he,top:W,right:Z,bottom:we});}u.title!==R.title&&(K.title=u.title),u.description!==R.description&&(K.description=u.description);let $=u.hyperlink.trim();if($!==(R.hyperlink??"")&&(K.hyperlink=$===""?null:$),R.canChangeWrap&&u.wrap!==R.wrap&&(K.wrap=u.wrap),R.kind==="anchored"&&R.canMove&&Cv(u,R)){let he=Pv(u,R);if(!he.ok){S("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(he.value,R))){S("imageProperties.errors.invalidPosition");return}Object.assign(K,he.value);}if(!(K.widthEmu!==void 0||K.heightEmu!==void 0||K.title!==void 0||K.description!==void 0||K.hyperlink!==void 0||K.crop!==void 0||K.wrap!==void 0||K.horizontalEmu!==void 0||K.verticalEmu!==void 0||K.relativeToH!==void 0||K.relativeToV!==void 0)){w();return}if(!r.can(K).ok){S("imageProperties.errors.refused");return}if(!r.exec(K).ok){S("imageProperties.errors.refused");return}w();},[r,u,v,x,w]);return !e||!u?null:jsx("div",{className:`docx-dialog-overlay${n?` ${n}`:""}`,onClick:w,onMouseDown:R=>{R.stopPropagation(),Tv(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:i("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[h?jsx("p",{className:"docx-dialog__error",children:i(h)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:u.widthPoints,disabled:x,onChange:R=>N(R.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:u.heightPoints,disabled:x,onChange:R=>F(R.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:u.lockAspect,disabled:b,onChange:R=>f(M=>M&&{...M,lockAspect:R.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:v||!C?.intrinsic,onClick:I,children:i("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),T?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,k?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,y?jsxs(Fragment,{children:[u.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:i("imageProperties.relativeToHorizontal")}),jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:u.relativeToH??"page",onChange:R=>f(M=>M&&{...M,relativeToH:R.target.value}),children:DRAWING_REL_FROM_H.map(R=>jsx("option",{value:R,children:i(`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:i("imageProperties.relativeToVertical")}),jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:u.relativeToV??"line",onChange:R=>f(M=>M&&{...M,relativeToV:R.target.value}),children:DRAWING_REL_FROM_V.map(R=>jsx("option",{value:R,children:i(`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:i("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:u.horizontalPoints,onChange:R=>f(M=>M&&{...M,horizontalPoints:R.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:u.verticalPoints,onChange:R=>f(M=>M&&{...M,verticalPoints:R.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:u.title,onChange:R=>f(M=>M&&{...M,title:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:u.description,onChange:R=>f(M=>M&&{...M,description:R.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("hyperlinkPopup.urlLabel")}),jsx("input",{id:s,className:"docx-dialog__input docx-dialog__input--full",value:u.hyperlink,onChange:R=>f(M=>M&&{...M,hyperlink:R.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("formattingBar.imageWrap")}),jsx("select",{id:c,className:"docx-dialog__select docx-dialog__input--full",value:u.wrap,disabled:C?.canChangeWrap===false,onChange:R=>f(M=>M&&{...M,wrap:R.target.value}),children:IMAGE_WRAP_TARGETS.map(R=>jsx("option",{value:R,children:i(`imageWrap.targets.${R}`)},R))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:v,value:u.cropLeft,onChange:R=>f(M=>M&&{...M,cropLeft:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:v,value:u.cropTop,onChange:R=>f(M=>M&&{...M,cropTop:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:v,value:u.cropRight,onChange:R=>f(M=>M&&{...M,cropRight:R.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:v,value:u.cropBottom,onChange:R=>f(M=>M&&{...M,cropBottom:R.target.value})})]}),v?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:i("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:D,children:i("common.apply")})]})]})})}function Va({className:e,hidden:t,asChild:n,children:o}){let r=H(),{t:i}=_(),a=O(Gu),[l,c]=useState(false),s=useRef(null),d={type:"setImageProperties",description:"probe"},m=r&&a?r.can(d):null,p=m?.ok===true,g=m&&!m.ok?m.reason:null;if(t)return null;let u=J("image.properties"),f={type:"button",ref:s,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!p,...p?{}:{"data-disabled":""},"aria-label":i("formattingBar.imagePropertiesShortcut"),title:g??i("formattingBar.imagePropertiesShortcut"),onMouseDown:B,onClick:()=>c(true)};return jsxs(Fragment,{children:[n?jsx(j,{...f,children:o}):jsx("button",{...f,children:o??re(u?.paths)}),jsx(is,{open:l,onClose:()=>c(false),triggerRef:s})]})}Va.docxSlot="image.properties";var an=Object.assign(Va,{docxSlot:"image.properties"});function Le(e){return Object.assign(n=>jsx(go,{slot:e,...n}),{docxSlot:e})}var ju=Le("history.undo"),Yu=Le("history.redo"),Xu=Le("text.bold"),Ju=Le("text.italic"),Qu=Le("text.underline"),ep=Le("text.strike"),tp=Le("format.clear"),op=Le("script.super"),np=Le("script.sub"),rp=Le("alignment.left"),ap=Le("alignment.center"),ip=Le("alignment.right"),lp=Le("alignment.justify"),sp=Le("list.bullet"),cp=Le("list.numbered"),dp=Le("list.outdent"),up=Le("list.indent");var pp=Le("table.insert"),mp=Le("review.comments");function Rv({className:e,hidden:t,icon:n,asChild:o,children:r}){let i=H(),{openAtCaret:a}=Ml(),l=chromeProbeForSlot("text.link"),c=i&&l?i.can(l):null,s=c?.ok===true,{t:d}=_(),m=localizeDisabledReason(c&&!c.ok?c.reason:null,d),p=X();if(t)return null;let g=J("text.link"),u=p(g?.labelKey??"text.link"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!s,...s?{}:{"data-disabled":""},"aria-label":u,title:m??u,onMouseDown:B,onClick:()=>a()};return o?jsx(j,{...f,children:r}):jsx("button",{...f,children:n??r??re(g?.paths)})}var ls=Object.assign(Rv,{docxSlot:"text.link"});function Mv({className:e,hidden:t}){let n=H(),{onSave:o}=useContext(fo),r=X();if(t)return null;let i=J("file.save"),a=r(i?.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":a,title:a,onMouseDown:B,onClick:()=>o?.(),children:re(i?.paths)})}var ss=Object.assign(Mv,{docxSlot:"file.save"});function ln({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}function sn(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}var Dv=e=>({zoom:e.zoom,mode:e.zoomMode}),Nv=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,gp={type:"fixed"};function cs(){let e=H(),{zoom:t,mode:n}=O(Dv,Nv),o=useCallback(i=>{e?.setZoom(i);},[e]),r=useCallback(i=>{e?.setZoomMode(i);},[e]);return useMemo(()=>{let i=n??gp,a=jn(t,"out"),l=jn(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:o,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(gp),o(1);},zoomIn:()=>l!==null&&o(l),zoomOut:()=>a!==null&&o(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Ra}},[e,t,n,o,r])}var cr=2,dr=3276,sr=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Av=e=>e.formatting?.fontSizePt??null;function vp(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function yp(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 Sp(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:B,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:B,onClick:e.onIncrease,children:"+"})]})}function Hv(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<cr||o>dr?null:o}function Ov({className:e,hidden:t}){let n=H(),o=O(Av),{isEnabled:r,disabledReason:i}=le("font.size"),a=X(),[l,c]=useState(false),[s,d]=useState(null),m=useRef(null),p=useRef(null),g=useCallback(b=>{if(!n)return;let y=commandForSlotValue("font.size",b);y&&n.can(y).ok&&n.exec(y);},[n]),u=useCallback(b=>{g(Math.min(dr,Math.max(cr,Math.round(b*2))));},[g]),f=useCallback(b=>{c(false),d(null),p.current?.blur(),b&&Bv(m.current);},[]);if(useEffect(()=>{if(!l)return;let b=y=>{let T=m.current;T&&y.target instanceof Node&&T.contains(y.target)||(c(false),d(null));};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),t)return null;let h=r&&o!==null,S=o===null?"\u2014":String(Math.round(o*2)/2),C=s??S,v=o===null?null:Math.round(o*2)/2,x=()=>{if(s===null)return;let b=Hv(s);b!==null&&g(b);};return jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsx(Sp,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsx("input",{ref:p,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:C,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),autoComplete:"off",onChange:b=>{d(b.target.value),c(true);},onFocus:b=>{b.target.select(),c(true);},onClick:()=>c(true),onKeyDown:b=>{b.key==="Enter"?(b.preventDefault(),x(),f(true)):b.key==="Escape"?(b.preventDefault(),f(true)):(b.key==="ArrowDown"||b.key==="ArrowUp")&&(b.preventDefault(),c(true),o!==null&&u(b.key==="ArrowDown"?yp(o,sr,cr/2):vp(o,sr,dr/2)));},onBlur:()=>{x(),d(null);}}),canDecrease:h&&Math.round(o*2)>cr,canIncrease:h&&Math.round(o*2)<dr,onDecrease:()=>u(yp(o??0,sr,cr/2)),onIncrease:()=>u(vp(o??0,sr,dr/2))}),l&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":a("fontSize.listLabel"),children:sr.map(b=>{let y=v===b;return jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>{u(b),f(true);},children:b},b)})}):null]})}function Bv(e){(sn(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}var ps=Object.assign(Ov,{docxSlot:"font.size"});function Zv({className:e,hidden:t}){let n=H(),{zoom:o,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:c,zoomOut:s,canZoomIn:d,canZoomOut:m,levels:p}=cs(),g=X(),[u,f]=useState(false),h=useRef(null);useEffect(()=>{if(!u)return;let y=T=>{let k=h.current;k&&T.target instanceof Node&&k.contains(T.target)||f(false);};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[u]);let S=useCallback(y=>{f(false),a(y);},[a]),C=useCallback(y=>{f(false),l(y==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let v=`${Math.round(o*100)}%`,x=sameZoomMode(i,AUTO_ZOOM_MODE),b=sameZoomMode(i,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(Sp,{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":u,"aria-label":g("zoom.zoomLevel"),onMouseDown:B,onClick:()=>f(y=>!y),children:[v,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:s,onIncrease:c}),u?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":x,...x?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>C("auto"),children:g("zoom.automatic")}),jsx("button",{type:"button",role:"option","aria-selected":b,...b?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>C("fit-width"),children:g("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),p.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:B,onClick:()=>S(y),children:`${Math.round(y*100)}%`},y)})]}):null]})}var ms=Object.assign(Zv,{docxSlot:"zoom.level"});var $v=[1,1.15,1.5,2,2.5,3],Pp=10,Ep=0,Vv=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),Uv=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function Wv({className:e,hidden:t}){let n=H(),o=O(Vv,Uv),{isEnabled:r,disabledReason:i}=le("list.lineSpacing"),a=le("paragraph.dialog"),l=Tu(),c=X(),[s,d]=useState(false),m=useRef(null),p=useRef(null);useEffect(()=>{if(!s)return;let v=x=>{let b=m.current;b&&x.target instanceof Node&&b.contains(x.target)||d(false);};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s]);let g=useCallback(v=>{if(d(false),!n)return;let x=commandForSlotValue("list.lineSpacing",v);x&&n.can(x).ok&&n.exec(x);},[n]),u=useCallback((v,x)=>{if(d(false),!n)return;let b={type:"setParagraphSpacing",[v]:x};n.can(b).ok&&n.exec(b);},[n]);if(t)return null;let f=J("list.lineSpacing"),h=(o.spaceBeforePt??0)>0,S=(o.spaceAfterPt??0)>0,C=o.lineSpacing?.rule==="multiple"?o.lineSpacing?.value??null:null;return jsxs("span",{ref:m,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxs("button",{ref:p,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":c("lineSpacing.label"),title:i??c("lineSpacing.label"),onMouseDown:B,onClick:()=>d(v=>!v),children:[re(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:[$v.map(v=>{let x=C===v;return jsx("button",{type:"button",role:"menuitemradio","aria-checked":x,...x?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>g(v),children:Number.isInteger(v*10)?v.toFixed(1):v.toFixed(2)},v)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:B,onClick:()=>{d(false),l?.open(p.current);},children:c("lineSpacing.options")}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>u("beforePt",h?Ep:Pp),children:c(h?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>u("afterPt",S?Ep:Pp),children:c(S?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var gs=Object.assign(Wv,{docxSlot:"list.lineSpacing"});var Qv=[{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"}],wp=[{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"}],kp=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Ua=["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"],Wt=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),st=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function ey(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?[st(5),st(15),st(25),st(35),st(50)]:n===0?[Wt(50),Wt(35),Wt(25),Wt(15),Wt(5)]:n>=.8?[st(10),st(25),st(50),st(75),st(90)]:[Wt(80),Wt(60),Wt(40),st(25),st(50)]}var ty=/^[0-9A-Fa-f]{6}$/;function oy(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 ny(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 Wa({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":""}:{},...ny(t.replace("#",""))?{"data-light":""}:{},onMouseDown:B,onClick:()=>r(e)})}function ry({apply:e,label:t,current:n,themeHexes:o}){let r=o.map(ey),i=[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((a,l)=>jsx(Wa,{value:a,css:`#${a.toLowerCase()}`,title:t(Ua[l]),selected:n===a,apply:e},`base-${l}`)),i.map(a=>o.map((l,c)=>{let s=r[c][a],d=oy(l,s.apply);return jsx(Wa,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Ua[c])}, ${t(s.labelKey)}`,selected:n===d,apply:e},`${a}-${c}`)}))]})]})}function ay(e){let{apply:t,label:n,current:o}=e,[r,i]=useState(""),a=ty.test(r);return jsxs(Fragment,{children:[jsx(ry,{...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:Qv.map(l=>jsx(Wa,{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=>i(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&a&&t(r.toUpperCase());}}),jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:B,onClick:()=>t(r.toUpperCase()),children:n("colorPicker.apply")})]})]})]})}function hs({apply:e,current:t}){let n=H(),o=X(),r=n?.getDocumentThemeColors()??[],i=r.length===Ua.length?r.map(l=>l.hex):kp,a=t?.toUpperCase()??null;return jsx(ay,{apply:e,label:o,current:a,themeHexes:i})}var iy=wp.filter(e=>e.value!=="white");function ly({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:iy.map(o=>jsx(Wa,{value:o.value,css:o.css,title:t(o.labelKey),selected:n===o.value,apply:e},o.value))})]})}function Rp(e){let{slot:t,defaultValue:n,cssOf:o,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:c,hidden:s,icon:d})=>{let m=H(),{isEnabled:p,disabledReason:g}=le(t),u=X(),[f,h]=useState(false),[S,C]=useState(n),v=useRef(null),x=O(w=>{if(a){let A=w.formatting?.color;return A&&A.kind==="hex"?A.value.toUpperCase():null}return w.formatting?.highlight??null}),b=m?.getDocumentThemeColors()??[],y=b.length===Ua.length?b.map(w=>w.hex):kp;useEffect(()=>{if(!f)return;let w=A=>{let N=v.current;N&&A.target instanceof Node&&N.contains(A.target)||h(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[f]);let T=useCallback(w=>{if(h(false),!m)return;let A=commandForSlotValue(t,w);A&&m.can(A).ok&&(m.exec(A),w!==r.value&&C(w));},[m]),k=useMemo(()=>J(t),[]);if(s)return null;let E=u(k?.labelKey??t);return jsxs("div",{ref:v,className:`docx-toolbar__colorsplit${c?` ${c}`:""}`,"data-slot":t,children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!p,...p?{}:{"data-disabled":""},"aria-label":E,title:g??E,onMouseDown:B,onClick:()=>T(S),children:[d??re(k?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:o(S)},"aria-hidden":"true"})]}),jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!p,...p?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":f,"aria-label":E,title:g??E,onMouseDown:B,onClick:()=>h(w=>!w),children:"\u25BE"}),f?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":E,onMouseDown:B,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:B,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"}),u(r.labelKey)]}),i({apply:T,label:u,current:x,themeHexes:y})]}):null]})},{docxSlot:t})}var sy=new Map(wp.map(e=>[e.value,e.css])),vs=Rp({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(hs,{apply:e.apply,current:e.current})}),ys=Rp({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>sy.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(ly,{...e})});var my=["alignment.left","alignment.center","alignment.right","alignment.justify"];function fy({className:e,hidden:t}){let n=le("alignment.left"),o=le("alignment.center"),r=le("alignment.right"),i=le("alignment.justify"),a=X(),[l,c]=useState(false),s=useRef(null);if(useEffect(()=>{if(!l)return;let f=h=>{let S=s.current;S&&h.target instanceof Node&&S.contains(h.target)||c(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]),t)return null;let d=[n,o,r,i],m=my.map((f,h)=>({slot:f,control:J(f),state:d[h]})),p=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.state.isEnabled),u=a(p.control?.labelKey??p.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":u,title:g?u:p.state.disabledReason??u,onMouseDown:B,onClick:()=>c(f=>!f),children:[re(p.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:m.map(f=>{let h=a(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":h,title:f.state.disabledReason??h,onMouseDown:B,onClick:()=>{f.state.execute(),c(false);},children:re(f.control?.paths)},f.slot)})}):null]})}var Ga=Object.assign(fy,{docxSlot:"alignment"});function Ss(e){let{label:t,icon:n,active:o,disabled:r,disabledReason:i,onSelect:a,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?i??t:t,onMouseDown:m=>B(m),onClick:r?void 0:a};return l?jsx(j,{...d,children:s}):jsx("button",{...d,children:n??s})}var Ty=Object.freeze([]),Cy=e=>e.formatting?.fontFamily??null,Py=e=>e;function ja(){let e=H(),t=O(Cy),n=O(Py),o=useMemo(()=>e&&!n.isLoading?e.getAvailableFonts():Ty,[e,n]),{isEnabled:r}=le("font.family"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:o,isEnabled:r}),[t,i,o,r])}var _p=createContext(null);function Cs(){return useContext(_p)}function Ps({asChild:e,className:t,children:n}){let o=Cs(),r=X();if(!o)return null;let i=r(J("font.family")?.labelKey??"font.family"),a={onClick:()=>o.setOpen(!o.open),onMouseDown:B,disabled:!o.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":i,title:i},l=n??jsx("span",{children:o.value??"\u2014"});return e?jsx(j,{...a,children:l}):jsx("button",{type:"button",...a,children:l})}Ps.docxToolbarPart=true;var Ey=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"]]),wy=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Dp({asChild:e,className:t,children:n}){let o=Cs(),r=X();if(!o||!o.open)return null;let i={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"}},a;return n!==void 0?a=n:a=wy.map(c=>({...c,fonts:o.options.filter(s=>(Ey.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(Np,{value:d},d))]},c.category)),e?jsx(j,{...i,children:a}):jsx("div",{...i,children:a})}function Np({value:e,asChild:t,className:n,children:o}){let r=Cs();if(!r)return null;let i=r.value===e,a={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:B,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(j,{...a,children:l}):jsxs("button",{type:"button",...a,children:[l,i?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function ky({hidden:e,asChild:t,className:n,children:o}){let r=ja(),[i,a]=useState(false),l=useRef(null);useEffect(()=>{if(!i)return;let m=p=>{let g=l.current;g&&p.target instanceof Node&&g.contains(p.target)||a(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[i]);let c=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);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(Ps,{}),jsx(Dp,{})]});return jsx(_p.Provider,{value:c,children:t?jsx(j,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var Es=Object.assign(ky,{docxSlot:"font.family",Trigger:Ps,Content:Dp,Item:Np});var My={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},Iy=new Set(["Title","Heading1","Heading2","Heading3"]),_y={Subtitle:"666666"},Dy="#4a6c8c";function Lp(e){let t=My[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??Iy.has(e.styleId))&&(o.fontWeight="bold"),e.italic&&(o.fontStyle="italic");let r=e.color??_y[e.styleId];return r?o.color=`#${r}`:e.styleId.startsWith("Heading")&&(o.color=Dy),o}var Ny=/^heading ([1-9])$/;function ks(e,t){let n=e||t,o=Ny.exec(n);return o?`Heading ${o[1]}`:n}function Fp(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:ks(t.name,t.styleId),priority:99}))}function qy(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 zy=Object.freeze([]),Ky=e=>e.formatting?.styleId??null,$y=e=>e;function Ya(){let e=H(),t=O(Ky),n=O($y),o=useMemo(()=>e&&!n.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:ks(a.name,a.styleId),preview:a.preview})):zy,[e,n]),{isEnabled:r}=le("styles.style"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:o,isEnabled:r}),[t,i,o,r])}var Ap=createContext(null);function Ms(){return useContext(Ap)}function Is({asChild:e,className:t,children:n}){let o=Ms(),r=X();if(!o)return null;let i=J("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>o.setOpen(!o.open),onMouseDown:B,disabled:!o.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":a,title:a},c=o.options.find(d=>d.styleId===o.value),s=n??(o.value===null?jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsx("span",{children:c?.name??o.value}));return e?jsx(j,{...l,children:s}):jsx("button",{type:"button",...l,children:s})}Is.docxToolbarPart=true;function Hp({asChild:e,className:t,children:n}){let o=Ms();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"}},i=n??o.options.map(a=>jsx(Op,{value:a.styleId},a.styleId));return e?jsx(j,{...r,children:i}):jsx("div",{...r,children:i})}function Op({value:e,asChild:t,className:n,children:o}){let r=Ms();if(!r)return null;let i=r.value===e,a=r.options.find(s=>s.styleId===e),l={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:B,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${n?` ${n}`:""}`},c=o??jsx("span",{style:a?qy(a.preview):void 0,children:a?.name??e});return t?jsx(j,{...l,children:c}):jsxs("button",{type:"button",...l,children:[c,i?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function Vy({hidden:e,asChild:t,className:n,children:o}){let r=Ya(),[i,a]=useState(false),l=useRef(null);useEffect(()=>{if(!i)return;let m=p=>{let g=l.current;g&&p.target instanceof Node&&g.contains(p.target)||a(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[i]);let c=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);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(Is,{}),jsx(Hp,{})]});return jsx(Ap.Provider,{value:c,children:t?jsx(j,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var _s=Object.assign(Vy,{docxSlot:"styles.style",Trigger:Is,Content:Hp,Item:Op});function Zp(e,t){let n=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:c})=>{let{isEnabled:s,disabledReason:d}=le(n),m=Et(),p=t==="showAll"?m.showAll:m.formFill,g=X();if(i)return null;let u=J(n),f=g(u?.labelKey??e),h={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!s,...s?{}:{"data-disabled":""},...p?{"data-active":""}:{},"aria-pressed":p,"aria-label":f,title:d??f,onMouseDown:B,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsx(j,{...h,children:c}):jsx("button",{...h,children:a??c??re(u?.paths)})},{docxSlot:n})}function Wy({className:e,hidden:t,icon:n,asChild:o,children:r}){let i=Xe.inspector,{isEnabled:a,disabledReason:l}=le(i),{inspectorOpen:c,openInspector:s}=Et(),d=X();if(t)return null;let m=J(i),p=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xe.inspector,disabled:!a,...a?{}:{"data-disabled":""},...c?{"data-active":""}:{},"aria-pressed":c,"aria-label":p,title:l??p,onMouseDown:B,onClick:()=>s()};return o?jsx(j,{...g,children:r}):jsx("button",{...g,children:n??r??re(m?.paths)})}function Gy({className:e,hidden:t,icon:n,asChild:o,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Et(),c=X();if(t)return null;let s=Xe.remove,d=J(s),m=c(d?.labelKey??"contentControl.remove"),p={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xe.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:B,onClick:()=>{l();}};return o?jsx(j,{...p,children:r}):jsx("button",{...p,children:n??r??re(d?.paths)})}var Xa=Zp(Xe.showAll,"showAll"),Ja=Zp(Xe.formFill,"formFill"),Qa=Object.assign(Gy,{docxSlot:Xe.remove}),ei=Object.assign(Wy,{docxSlot:Xe.inspector}),qp={[Xe.showAll]:Xa,[Xe.formFill]:Ja,[Xe.inspector]:ei,[Xe.remove]:Qa};function Ds(e,t){let n=H(),o=useRef(t);o.current=t,useEffect(()=>{if(!n)return;let r=((...i)=>{o.current(...i);});return n.on(e,r)},[n,e]);}var tx=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Ls=createContext(null);function Gp(){let e=useContext(Ls);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function nx(e,t){let n=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=n?`${r}|${n.rows}|${n.columns}|${n.rowIndex}|${n.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.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:i,selectionKey:l,cellSelectionKey:s,editable:t.editable,editingMode:t.editingMode??"editing"}}function rx(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function ax(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Up={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function ix(e,t){let n={};for(let o of tx){let r=tableChromeToolbarState(e,o,t);n[o]={enabled:r.enabled,disabledReason:r.disabledReason};}return n}function Fs({children:e}){let t=H(),[n,o]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,i]=useState(Up);useEffect(()=>(()=>{}),[]);let a=O(useCallback(p=>({table:p.table,editable:p.editable,editingMode:p.editingMode??"editing",headParagraphId:p.selection?.to&&"paraId"in p.selection.to?p.selection.to.paraId:p.selection?.from&&"paraId"in p.selection.from?p.selection.from.paraId:""}),[]),rx,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=useCallback(()=>{if(!t){i(Up);return}let p=nx(t,t.snapshot());i(g=>ax(g,p)?g:p);},[t]);useEffect(()=>{l();},[l,a]),Ds("selectionChange",useCallback(()=>{l();},[l]));let c=r.tableKey!=="",s=useMemo(()=>t?ix(t,n):{},[t,n,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=useCallback((p,g)=>{if(!t)return;let{result:u,nextDraft:f}=runTableChromeCommand(t,p,g,n);u.ok&&f&&o(f);},[t,n]),m=useMemo(()=>({visible:c,draft:n,setDraft:o,slotState:p=>s[p]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[c,n,s,d]);return jsx(Ls.Provider,{value:m,children:e})}function lx(){let e=useContext(Ls);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function oi(e){let t=lx(),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 cx='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Po(e){return [...e.querySelectorAll(cx)].filter(t=>t.closest('[role="menu"]')===e)}function As(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function vt(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 yt(e,t){let n=t==="first"?e[0]:e[e.length-1];return n?(n.focus(),true):false}function ni(e){(sn(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Os(e,t,n){useEffect(()=>{if(!e)return;let o=r=>{let i=n.current;i&&r.target instanceof Node&&i.contains(r.target)||t(false);};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t,n]);}function ri({enabled:e,disabledReason:t,ariaLabel:n}){let{t:o}=_(),r=localizeDisabledReason(t,o),i=useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:B,"aria-label":n,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var px='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function jp(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,i=o.current;if(!r)return;let a=()=>[...r.querySelectorAll(px)].filter(s=>s.closest('[role="menu"]')===r);queueMicrotask(()=>{let s=a();(s.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??s[0])?.focus();});let c=s=>{let d=a();if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="ArrowDown"){s.preventDefault(),vt(d,document.activeElement,1);return}if(s.key==="ArrowUp"){s.preventDefault(),vt(d,document.activeElement,-1);return}if(s.key==="Home"){s.preventDefault(),yt(d,"first");return}if(s.key==="End"){s.preventDefault(),yt(d,"last");return}if(s.key==="Enter"||s.key===" "){let m=document.activeElement;m instanceof HTMLElement&&d.includes(m)&&(s.preventDefault(),m.click());}};return r.addEventListener("keydown",c),()=>r.removeEventListener("keydown",c)},[e,t,n,o]);}function Yp(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,i=o.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(c=>c.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=c=>{if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="Enter"||c.key===" "){let s=document.activeElement,d=a();s instanceof HTMLElement&&d.includes(s)&&(c.preventDefault(),s.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,n,o]);}function tm(e,t,n){if(e)return o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(!t));}}function yx(e){return re(tableChromeIconPaths(e))}function om(){return createContext(null)}function Ht(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function Zs(e,t,n){let o=om();function r({hidden:l,asChild:c,className:s,children:d}){let{visible:m,enabled:p,disabledReason:g,draft:u,apply:f}=oi(e),[h,S]=useState(false),C=useRef(null),v=useRef(null);Os(h,S,C);let x=useMemo(()=>({open:h,setOpen:S,enabled:p,disabledReason:g,apply:f,draft:u,triggerRef:v}),[h,p,g,f,u]);if(l||!m)return null;let b={className:`${t}${s?` ${s}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},y=d??jsxs(Fragment,{children:[jsx(i,{}),jsx(a,{})]});return jsx(o.Provider,{value:x,children:c?jsx(j,{...b,ref:C,children:y}):jsx("div",{ref:C,...b,children:y})})}function i({asChild:l,className:c,children:s}){let{open:d,setOpen:m,enabled:p,disabledReason:g,triggerRef:u}=Ht(o),f=X(),h=J(e),S=f(h?.labelKey??n),{shared:C,reasonNode:v}=ri({enabled:p,disabledReason:g,ariaLabel:S}),x={...C,ref:u,className:`docx-toolbar__button docx-table-chrome__trigger${c?` ${c}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:p?()=>m(!d):void 0,...l?{tabIndex:p?0:-1,role:"button",onKeyDown:tm(p,d,m)}:{}},b=s??jsxs(Fragment,{children:[re(h?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(j,{...x,children:b}),v]}):jsxs("button",{...x,children:[b,v]})}i.docxToolbarPart=true;function a({asChild:l,className:c,children:s}){let{open:d,setOpen:m,enabled:p,triggerRef:g}=Ht(o),u=X(),f=useRef(null);if(jp(d&&p,m,f,g),!d||!p)return null;let h=J(e),S=u(h?.labelKey??n),C={ref:f,role:"menu","aria-label":S,className:`docx-table-chrome__panel${c?` ${c}`:""}`,onMouseDown:B};return l?jsx(j,{...C,children:s}):jsx("div",{...C,children:s})}return {Root:r,Trigger:i,Content:a,Ctx:o}}var mr=Zs("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function nm({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(mr.Ctx),l=X(),c=TABLE_BORDER_TARGET_OPTIONS.find(p=>p.value===e);if(!c)return null;let s=c.value==="none"?false:c.value===a.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:B,onClick:()=>{i(false),r(c.value);}},m=o??yx(c.icon);return t?jsx(j,{...d,children:m}):jsx("button",{...d,children:m})}function rm(e){let{children:t}=e;return jsx(mr.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(n=>jsx(nm,{value:n.value},n.value))})})}function xx(e){let{children:t}=e,n=t??jsxs(Fragment,{children:[jsx(mr.Trigger,{}),jsx(rm,{})]});return jsx(mr.Root,{...e,children:n})}var vr=Object.assign(xx,{docxSlot:"table.borderTarget",Trigger:mr.Trigger,Content:rm,Item:nm}),fr=Zs("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function am({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(fr.Ctx),l=X(),c=TABLE_BORDER_STYLE_OPTIONS.find(p=>p.value===e);if(!c)return null;let s=c.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":s,...s?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:B,onClick:()=>{i(false),r(c.value);}},m=o??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${c.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(c.labelKey)})]});return t?jsx(j,{...d,children:m}):jsx("button",{...d,children:m})}function im(e){let{children:t}=e;return jsx(fr.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(n=>jsx(am,{value:n.value},n.value))})}function Sx(e){let t=e.children??jsxs(Fragment,{children:[jsx(fr.Trigger,{}),jsx(im,{})]});return jsx(fr.Root,{...e,children:t})}var yr=Object.assign(Sx,{docxSlot:"table.borderStyle",Trigger:fr.Trigger,Content:im,Item:am}),gr=Zs("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function lm({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(gr.Ctx),l=X(),c=Number(e),s=TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===c);if(!s)return null;let d=s.size===a.spec.size,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:B,onClick:()=>{i(false),r(s.size);}},p=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(j,{...m,children:p}):jsx("button",{...m,children:p})}function sm(e){let{children:t}=e;return jsx(gr.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(n=>jsx(lm,{value:String(n.size)},n.size))})}function Tx(e){let t=e.children??jsxs(Fragment,{children:[jsx(gr.Trigger,{}),jsx(sm,{})]});return jsx(gr.Root,{...e,children:t})}var xr=Object.assign(Tx,{docxSlot:"table.borderWidth",Trigger:gr.Trigger,Content:sm,Item:lm});function cm(e,t,n){let o=n?.defaultHex??"FF0000",r=om();function i({hidden:d,asChild:m,className:p,children:g}){let{visible:u,enabled:f,disabledReason:h,draft:S,apply:C}=oi(e),[v,x]=useState(false),[b,y]=useState(o),T=useRef(null),k=useRef(null);Os(v,x,T);let E=useMemo(()=>({open:v,setOpen:x,enabled:f,disabledReason:h,apply:C,draft:S,triggerRef:k,lastHex:b,setLastHex:y}),[v,f,h,C,S,b]);if(d||!u)return null;let w={className:`docx-toolbar__colorsplit docx-table-chrome${p?` ${p}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},A=g??jsxs(Fragment,{children:[jsx(a,{}),jsx(l,{}),jsx(c,{clearFill:n?.clearFill??false})]});return jsx(r.Provider,{value:E,children:m?jsx(j,{...w,ref:T,children:A}):jsx("div",{ref:T,...w,children:A})})}function a({asChild:d,className:m,children:p}){let{enabled:g,disabledReason:u,apply:f,draft:h,lastHex:S}=Ht(r),C=X(),v=J(e),x=C(v?.labelKey??t),{shared:b,reasonNode:y}=ri({enabled:g,disabledReason:u,ariaLabel:x}),T=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:S??o,k={...b,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:T}):void 0},E=p??jsxs(Fragment,{children:[re(v?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${T.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(j,{...k,children:E}),y]}):jsxs("button",{...k,children:[E,y]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:p}){let{open:g,setOpen:u,enabled:f,disabledReason:h,triggerRef:S}=Ht(r),C=X(),v=J(e),x=C(v?.labelKey??t),{shared:b,reasonNode:y}=ri({enabled:f,disabledReason:h,ariaLabel:x}),T={...b,ref:S,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>u(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:tm(f,g,u)}:{}},k=p??"\u25BE";return d?jsxs(Fragment,{children:[jsx(j,{...T,children:k}),y]}):jsxs("button",{...T,children:[k,y]})}l.docxToolbarPart=true;function c({asChild:d,className:m,children:p,clearFill:g}){let{open:u,setOpen:f,enabled:h,apply:S,draft:C,triggerRef:v,lastHex:x,setLastHex:b}=Ht(r),y=X(),T=useRef(null);if(Yp(u&&h,f,T,v),!u||!h)return null;let k=y(t),E=e==="table.borderColor"&&C.spec.color.kind==="hex"?C.spec.color.value:x??o,w={ref:T,role:"dialog","aria-label":k,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:B},A=p??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:B,onClick:()=>{f(false),S(null),ni(v.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),y("table.clearCellFill")]}):null,jsx(hs,{apply:N=>{f(false),b?.(N),S({kind:"hex",value:N}),ni(v.current);},current:E})]});return d?jsx(j,{...w,children:A}):jsx("div",{...w,children:A})}function s({value:d,css:m,labelKey:p,asChild:g,className:u,children:f}){let{apply:h,setOpen:S,setLastHex:C,triggerRef:v}=Ht(r),x=X(),b=m??`#${d.toLowerCase()}`,y=p?x(p):d,T={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${u?` ${u}`:""}`,style:{backgroundColor:b},"data-value":d,"aria-label":y,title:y,onMouseDown:B,onClick:()=>{S(false),C?.(d),h({kind:"hex",value:d}),ni(v.current);}};return g?jsx(j,{...T,children:f}):jsx("button",{...T,children:f})}return {Root:i,Main:a,Trigger:l,Content:c,Item:s,Ctx:r}}var br=cm("table.borderColor","table.borderColor",{defaultHex:"000000"});function Cx(e){return jsx(br.Content,{...e,clearFill:false})}function Px(e){return jsx(br.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function Ex(e){return jsx(br.Root,{...e})}var Sr=Object.assign(Ex,{docxSlot:"table.borderColor",Trigger:br.Trigger,Content:Cx,Item:Px,Main:br.Main}),hr=cm("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function wx(e){return jsx(hr.Content,{...e,clearFill:true})}function kx(e){return jsx(hr.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function Rx(e){return jsx(hr.Root,{...e})}var Tr=Object.assign(Rx,{docxSlot:"table.cellFill",Trigger:hr.Trigger,Content:wx,Item:kx,Main:hr.Main});function dm({overrides:e=new Map}){return Gp()?jsxs(Fragment,{children:[jsx(ln,{}),[vr,Sr,yr,xr,Tr].map(o=>{let r=e.get(o.docxSlot);return r?jsx(Fragment$1,{children:r},o.docxSlot):jsx(o,{},o.docxSlot)})]}):null}function um(){let e=X(),{draft:t}=oi("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var gm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],bm={"zoom.level":ms,"styles.style":_s,"font.family":Es,"font.size":ps,"text.color":vs,"text.highlight":ys,"text.link":ls,"list.lineSpacing":gs,"review.editingMode":_a,"file.save":ss,...qp,"table.borderTarget":vr,"table.borderColor":Sr,"table.borderStyle":yr,"table.borderWidth":xr,"table.cellFill":Tr,"image.insert":Zn,"image.properties":an,"image.wrap":rr,"image.altText":ar},mm=new Map;function _x(e){let t=mm.get(e);return t||(t=n=>jsx(go,{slot:e,...n}),mm.set(e,t)),t}function Dx(e){return formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:Ga}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(n=>{let o=chromeSlotId(t,n);return {slot:o,Part:bm[o]??_x(o)}})})}var Nx=e=>e.image,Lx=e=>e.isLoading||e.isOpening===true;function Fx(e){return e==="alignment"||e in bm}function Ks(e){let t=on(e,Ks);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 qs(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(qs);let t=Ks(e);return t!=null&&gm.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(qs):false}function Ax(e,t){return t?true:Children.toArray(e).some(qs)}function Hx(e){let t=ot(),{className:n,t:o,onSave:r,preset:i=true,overflow:a=true,children:l}=e,c=useMemo(()=>({t:o,onSave:r}),[o,r]),s=fa(o),d=O(Nx),m=O(Lx),p=useMemo(()=>Dx(d),[d]),g=useMemo(()=>new Set(p.flatMap(x=>x.entries.map(b=>b.slot))),[p]),u=useMemo(()=>p.map(x=>x.id).filter(x=>!Wl.has(x)),[p]),f=useMemo(()=>Eu(u),[u]),h=i&&a,{attach:S,overflow:C}=Fu(h,u,f),v;if(!i)v=l;else {let x=Children.toArray(l),b=new Map,y=new Map,T=[];for(let N of x){let F=Ks(N);F&&g.has(F)?b.set(F,N):F&&gm.includes(F)?y.set(F,N):T.push(N);}let k=N=>{let F=b.get(N.slot);if(F)return F;let I=N.Part;return jsx(I,{})},E=[],w=[],A=0;for(let N of p){if(C.has(N.id)){let I=N.entries.flatMap(D=>{let R=Bx(D,b,s,N.labelKey,k);return R===null?[]:[jsx(Fragment$1,{children:R},D.slot)]});if(I.length===0)continue;w.push({id:N.id,labelKey:N.labelKey,children:I});continue}A>0&&E.push(jsx(ln,{},`separator-${N.id}`)),A+=1;let F=Wl.has(N.id);E.push(jsx("div",{className:"docx-toolbar__group",...F?{[or]:""}:{[tr]:N.id},children:N.entries.map(I=>jsx(Fragment$1,{children:k(I)},I.slot))},N.id));}v=jsxs(Fragment,{children:[E,jsx(dm,{overrides:y}),T.length>0?jsx("div",{className:"docx-toolbar__group",[or]:"",children:T}):null,w.length>0?jsx(Zu,{sections:w}):null]});}return jsx(fo.Provider,{value:c,children:jsx(Su,{children:jsx("fieldset",{ref:S,disabled:m,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${n?` ${n}`:""}`,...h?{"data-overflow":""}:{},onMouseDown:B,children:Ax(l,i)?jsx(Fs,{children:v}):v})})})}function Ox(e){return e?!!e.props.hidden:false}function Bx(e,t,n,o,r){let i=t.get(e.slot);return Ox(i)?null:i||Fx(e.slot)?jsx(Ou,{label:Zx(n,e,o),children:r(e)}):jsx(Bu,{slot:e.slot})}function Zx(e,t,n){let o=t.slot==="alignment"?null:J(t.slot);return e(o?.labelKey??n)}var Pr=Object.assign(Hx,{Button:go,Action:Ss,Separator:ln,Undo:ju,Redo:Yu,Bold:Xu,Italic:Ju,Underline:Qu,Strike:ep,Link:ls,ClearFormatting:tp,Superscript:op,Subscript:np,Alignment:Ga,AlignLeft:rp,AlignCenter:ap,AlignRight:ip,AlignJustify:lp,LineSpacing:gs,BulletList:sp,NumberedList:cp,Outdent:dp,Indent:up,ImageInsert:Zn,ImageProperties:an,ImageWrap:rr,ImageAltText:ar,TableInsert:pp,TableBorderTarget:vr,TableBorderColor:Sr,TableBorderStyle:yr,TableBorderWidth:xr,TableCellFill:Tr,Comments:mp,FontFamily:Es,FontSize:ps,FontColor:vs,Highlight:ys,Zoom:ms,StylePicker:_s,EditingMode:_a,Save:ss,ContentControlShowAll:Xa,ContentControlFormFill:Ja,ContentControlInspector:ei,ContentControlRemove:Qa});var $x=e=>e.pageSetup??null,Vx=e=>e.editable;function Eo(){let e=H(),t=O($x),n=O(Vx),o=useMemo(()=>n&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,n]),r=useCallback(i=>e?e.exec({...i.pageWidthTwips!==void 0?{pageWidth:i.pageWidthTwips}:{},...i.pageHeightTwips!==void 0?{pageHeight:i.pageHeightTwips}:{},...i.orientation!==void 0?{orientation:i.orientation}:{},...i.marginTopTwips!==void 0?{marginTop:i.marginTopTwips}:{},...i.marginRightTwips!==void 0?{marginRight:i.marginRightTwips}:{},...i.marginBottomTwips!==void 0?{marginBottom:i.marginBottomTwips}:{},...i.marginLeftTwips!==void 0?{marginLeft:i.marginLeftTwips}:{},...i.scope!==void 0?{scope:i.scope}:{},type:"setPageSetup"}).ok:false,[e]);return useMemo(()=>({pageSetup:t,isEnabled:o,apply:r}),[t,o,r])}var Vs=[{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}],Pm=1440,Ux=e=>Math.round(e/Pm*100)/100,Wx=e=>Math.round(e*Pm);function Gx(e,t){let n=Math.min(e,t),o=Math.max(e,t);return Vs.findIndex(r=>Math.abs(r.width-n)<20&&Math.abs(r.height-o)<20)}var jx={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},Yx={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:400,maxWidth:480,width:"100%",margin:20},Xx={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600,color:"var(--doc-text)"},Jx={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},xm={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},ai={display:"flex",alignItems:"center",gap:12},ii={width:80,fontSize:13,color:"var(--doc-text-muted)"},li={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Qx={fontSize:11,color:"var(--doc-text-muted)",width:16},eS={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},Sm={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Tm=12240,Cm=15840,jt=1440;function Er({open:e,onClose:t,className:n}){let{t:o}=_(),{pageSetup:r,isEnabled:i,apply:a}=Eo(),[l,c]=useState(Tm),[s,d]=useState(Cm),[m,p]=useState("portrait"),[g,u]=useState(jt),[f,h]=useState(jt),[S,C]=useState(jt),[v,x]=useState(jt),[b,y]=useState("document"),T=useRef(null),k=useRef("no");useEffect(()=>{if(!e){k.current="no";return}if(k.current==="yes"&&r===null){k.current="no";return}k.current==="yes"||k.current==="loading"&&r===null||(c(r?.pageWidthTwips??Tm),d(r?.pageHeightTwips??Cm),p(r?.orientation??"portrait"),u(r?.marginsTwips.top??jt),h(r?.marginsTwips.bottom??jt),C(r?.marginsTwips.left??jt),x(r?.marginsTwips.right??jt),y("document"),k.current=r===null?"loading":"yes");},[e,r]),useEffect(()=>{e&&T.current?.focus();},[e]);let E=useCallback(I=>{let D=Vs[I];D&&(c(m==="landscape"?D.height:D.width),d(m==="landscape"?D.width:D.height));},[m]),w=useCallback(I=>{I!==m&&(p(I),c(s),d(l));},[m,l,s]),A=useCallback(()=>{a({pageWidthTwips:l,pageHeightTwips:s,orientation:m,marginTopTwips:g,marginRightTwips:v,marginBottomTwips:f,marginLeftTwips:S,scope:b})&&t();},[a,l,s,m,g,v,f,S,b,t]);if(!e)return null;let N=Gx(l,s),F=(I,D,R)=>jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o(`dialogs.pageSetup.${I}`)}),jsx("input",{type:"number",style:li,min:0,max:22,step:.1,value:Ux(D),onChange:M=>R(Math.max(0,Wx(Number(M.target.value)||0))),"aria-label":o(`dialogs.pageSetup.${I}`)}),jsx("span",{style:Qx,children:"in"})]});return jsx("div",{className:n,style:jx,onClick:t,onKeyDown:I=>{I.key==="Escape"&&t(),I.key==="Enter"&&A();},children:jsxs("div",{ref:T,tabIndex:-1,style:Yx,onClick:I=>I.stopPropagation(),onMouseDown:I=>I.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o("dialogs.pageSetup.title"),children:[jsx("div",{style:Xx,children:o("dialogs.pageSetup.title")}),jsxs("div",{style:Jx,children:[jsx("div",{style:xm,children:o("dialogs.pageSetup.pageSize")}),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.sizeLabel")}),jsxs("select",{style:li,value:N,onChange:I=>E(Number(I.target.value)),"aria-label":o("dialogs.pageSetup.sizeLabel"),children:[Vs.map((I,D)=>jsx("option",{value:D,children:o(I.labelKey)},I.labelKey)),N<0&&jsx("option",{value:-1,children:o("dialogs.pageSetup.custom")})]})]}),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.orientation")}),jsxs("select",{style:li,value:m,onChange:I=>w(I.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:{...xm,marginTop:4},children:o("dialogs.pageSetup.margins")}),F("top",g,u),F("bottom",f,h),F("left",S,C),F("right",v,x),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.applyTo")}),jsxs("select",{style:li,value:b,onChange:I=>y(I.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:eS,children:[jsx("button",{type:"button",style:Sm,onClick:t,children:o("common.cancel")}),jsx("button",{type:"button",style:{...Sm,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:i?1:.5},disabled:!i,onClick:A,children:o("common.apply")})]})]})})}var wr=createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0});function nt(){return useContext(wr)}function Fe(){let{t:e}=nt(),{t}=_();return n=>e?.(n)??t(n)}var nS=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,rS=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var Em=new TextEncoder;function aS(e,t){if(Em.encode(e).length<=t)return e;let n=0,o="";for(let r of e){let i=Em.encode(r).length;if(n+i>t)break;n+=i,o+=r;}return o}function wm(e){let t=aS((e??"").replace(/\.docx$/i,"").replace(rS," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||nS.test(t)?"document.docx":`${t}.docx`}function km(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 iS="https://github.com/eigenpal/docx-editor/issues/new";function lS(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Rm(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??lS()}`,`- Viewport: ${n.width} x ${n.height}`,`- User agent: ${t}`,""].join(`
2
- `),i=new URLSearchParams({title:"[Bug] ",body:r});return `${iS}?${i.toString()}`}function kr(e){typeof window>"u"||window.open(Rm(e),"_blank","noopener,noreferrer");}var Us=6,Im=6;function Be(e){let{icon:t,shortcut:n,disabled:o,title:r,active:i,selected:a,slot:l,onSelect:c,className:s,children:d}=e,m=useId(),p=o&&r?m:void 0;return jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${s?` ${s}`:""}`,tabIndex:-1,...l?{"data-slot":l}:{},...i?{"data-active":""}:{},...o?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...p?{"aria-describedby":p}:{},...r?{title:r}:{},onMouseDown:B,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,p?jsx("span",{id:m,className:"docx-editor-sr-only",children:r}):null]})}function Mr({label:e,labelKey:t,className:n,hidden:o,children:r}){let i=Fe();if(o)return null;let a=e??(t===void 0?void 0:i(t));return jsxs("div",{role:"group",className:`docx-menubar__group${n?` ${n}`:""}`,...a?{"aria-label":a}:{},children:[a?jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function Ot({slot:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let{execute:i,isActive:a,isEnabled:l,disabledReason:c}=le(e),{setOpenMenu:s}=nt(),d=Fe();if(r)return null;let m=J(e),p=d(t??m?.labelKey??e),g=commandForSlot(e),u=g?.type==="toggleMark"||g?.type==="setAlignment",f=g?.type==="setAlignment";return jsx(Be,{slot:e,icon:re(m?.paths),...n?{shortcut:d(n)}:{},disabled:!l,...c?{title:c}:{},...u?{active:a}:{},...f?{selected:true}:{},onSelect:()=>{i(),s(null);},...o?{className:o}:{},children:p})}Ot.docxMenuRow=true;function Dm(e,t,n,o){return Object.assign(({className:i,hidden:a})=>{let l=nt(),c=Fe(),s=o(l);if(a)return null;let d=J(e),m=c(t??d?.labelKey??e);return jsx(Be,{slot:e,icon:re(d?.paths),...n?{shortcut:c(n)}:{},disabled:!s,onSelect:()=>{s?.(),l.setOpenMenu(null);},...i?{className:i}:{},children:m})},{docxSlot:e})}var Gs=Dm("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),js=Dm("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function pS({className:e,hidden:t}){let n=H(),o=nt(),r=Fe(),i=chromeProbeForSlot("file.pageSetup"),a=n&&i?n.can(i):null,l=a?.ok===true,c=a&&!a.ok?a.reason:null;if(t)return null;let s=J("file.pageSetup"),d=r(s?.labelKey??"file.pageSetup"),m=l&&!!o.onPageSetup;return jsx(Be,{slot:"file.pageSetup",icon:re(s?.paths),disabled:!m,...c?{title:c}:{},onSelect:()=>{o.onPageSetup?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}function mS({className:e,hidden:t}){let n=H(),o=nt(),r=Fe(),i=chromeProbeForSlot("paragraph.dialog"),a=n&&i?n.can(i):null,l=a?.ok===true,c=a&&!a.ok?a.reason:null;if(t)return null;let s=J("paragraph.dialog"),d=r(s?.labelKey??"lineSpacing.options"),m=l&&!!o.onParagraphDialog;return jsx(Be,{slot:"paragraph.dialog",icon:re(s?.paths),disabled:!m,...c?{title:c}:{},onSelect:()=>{o.onParagraphDialog?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}var fS=Object.assign(mS,{docxSlot:"paragraph.dialog"}),Ys=Object.assign(pS,{docxSlot:"file.pageSetup"});function gS({className:e,hidden:t}){let{openFilePicker:n,isEnabled:o,disabledReason:r}=ba(),i=nt(),a=Fe();if(t)return null;let l=J("image.insert"),c=a(l?.labelKey??"toolbar.image");return jsx(Be,{slot:"image.insert",icon:re(l?.paths),disabled:!o,...r?{title:r}:{},onSelect:()=>{n(),i.setOpenMenu(null);},...e?{className:e}:{},children:c})}var bS=Object.assign(gS,{docxSlot:"image.insert"}),Rr=8;function ko({labelKey:e,paths:t,className:n,children:o}){let r=Fe(),[i,a]=useState(false),l=useRef(null),c=useRef(null),s=useId(),d=r(e),[m,p]=useState(null);return useLayoutEffect(()=>{if(!i){p(null);return}let g=l.current,u=c.current,f=g?.ownerDocument.defaultView;if(!g||!u||!f)return;let h=g.getBoundingClientRect(),S=u.offsetWidth,C=u.offsetHeight,v=h.right+S>f.innerWidth-Rr;p({left:v?Math.max(Rr,h.left-S):Math.min(h.right,f.innerWidth-S-Rr),top:Math.max(Rr,Math.min(h.top-4,f.innerHeight-C-Rr))});},[i]),jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),onKeyDown:g=>{g.key==="ArrowRight"&&document.activeElement===l.current?(g.preventDefault(),a(true),queueMicrotask(()=>{c.current&&yt(Po(c.current),"first");})):(g.key==="ArrowLeft"||g.key==="Escape")&&i&&(g.preventDefault(),g.stopPropagation(),a(false),l.current?.focus());},onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||a(false);},children:[jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?s:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...i?{"data-open":""}:{},onMouseDown:B,onFocus:()=>a(true),onClick:()=>a(true),children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(t)}),jsx("span",{className:"docx-menubar__item-label",children:d}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),i?jsx("div",{ref:c,id:s,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:m?{position:"fixed",left:m.left,top:m.top}:{position:"fixed",visibility:"hidden"},onKeyDown:g=>{let u=c.current;if(!u)return;let f=Po(u);g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),vt(f,document.activeElement,1)):g.key==="ArrowUp"&&(g.preventDefault(),g.stopPropagation(),vt(f,document.activeElement,-1));},children:o}):null]})}function ci({slot:e="table.insert",className:t}){let n=H(),{isEnabled:o}=le(e),{setOpenMenu:r}=nt(),i=Fe(),[a,l]=useState(null),[c,s]=useState({rows:1,cols:1}),d=useRef(null),m=useCallback((u,f)=>{if(!n||!o)return;let h={type:"insertTable",rows:u,cols:f};n.can(h).ok&&(n.exec(h),r(null),n.focus());},[n,o,r]),p=useCallback(u=>{s(f=>{let h={rows:Math.min(Im,Math.max(1,f.rows+(u.rows??0))),cols:Math.min(Us,Math.max(1,u.toCol??f.cols+(u.cols??0)))};return l(h),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${h.rows}x${h.cols}"]`)?.focus()),h});},[]),g=[];for(let u=1;u<=Im;u+=1){let f=[];for(let h=1;h<=Us;h+=1){let S=!!a&&u<=a.rows&&h<=a.cols;f.push(jsx("button",{type:"button",role:"gridcell","data-cell":`${u}x${h}`,className:"docx-menubar__grid-cell",tabIndex:c.rows===u&&c.cols===h?0:-1,...S?{"data-filled":""}:{},"aria-label":`${h} \xD7 ${u}`,onMouseDown:B,onMouseEnter:()=>l({rows:u,cols:h}),onFocus:()=>l({rows:u,cols:h}),onClick:()=>m(u,h)},h));}g.push(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},u));}return jsxs("div",{ref:d,role:"grid","aria-label":i("toolbar.insertTable"),className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>l(null),onKeyDown:u=>{if(u.key==="ArrowRight")p({cols:1});else if(u.key==="ArrowLeft")p({cols:-1});else if(u.key==="ArrowDown")p({rows:1});else if(u.key==="ArrowUp")p({rows:-1});else if(u.key==="Home")p({toCol:1});else if(u.key==="End")p({toCol:Us});else return;u.preventDefault(),u.stopPropagation();},children:[jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function hS({entry:e}){let{isEnabled:t}=le(e.slot),n=J(e.slot);return t?jsx(ko,{labelKey:e.labelKey??n?.labelKey??e.slot,paths:n?.paths,children:jsx(ci,{slot:e.slot})}):jsx(Ot,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Ro({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Ir({entry:e}){return e.kind==="separator"?jsx(Ro,{}):e.kind==="submenu"?jsx(ko,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,n)=>jsx(Ir,{entry:t},n))}):e.slot==="file.open"?jsx(Gs,{}):e.slot==="file.save"?jsx(js,{}):e.slot==="file.pageSetup"?jsx(Ys,{}):e.slot==="paragraph.dialog"?jsx(fS,{}):e.slot==="image.insert"?jsx(bS,{}):e.picker==="tableGrid"?jsx(hS,{entry:e}):jsx(Ot,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Nm(e){if(!isValidElement(e))return null;let t=on(e,Nm);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 vS(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function yS(e,t,n){return Na({entries:e??[],children:t,preset:n,keyOfEntry:vS,keyOfChild:Nm,renderEntry:o=>jsx(Ir,{entry:o})})}function un({id:e,labelKey:t,label:n,icon:o,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:c,setOpenMenu:s,activeMenu:d}=nt(),m=Fe(),p=useId(),g=useRef(null),u=useRef(null),f=useRef(false),h=useRef(false),S=CHROME_MENUS.find(y=>y.id===e),C=c===e;if(i)return null;let v=n??m(t??S?.labelKey??e),x=yS(S?.entries,l,a),b=()=>{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":C,"aria-controls":C?p:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...C?{"data-open":""}:{},onMouseDown:B,onKeyDown:y=>{y.key==="ArrowDown"||y.key==="Enter"||y.key===" "||y.key==="ArrowUp"?(y.preventDefault(),f.current=true,s(e)):y.key==="Escape"&&C&&(y.preventDefault(),b());},onClick:()=>{if(h.current){h.current=false;return}s(C?null:e);},onMouseEnter:()=>{c!==null&&c!==e&&(h.current=true,s(e));},onMouseLeave:()=>{h.current=false;},children:[o?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:o}):null,v]}),C?jsx("div",{ref:y=>{u.current=y,y&&f.current&&(f.current=false,yt(Po(y),"first"));},id:p,role:"menu","aria-label":v,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:y=>{let T=u.current;if(!T)return;let k=Po(T),E=document.activeElement;y.key==="ArrowDown"?(y.preventDefault(),vt(k,E,1)):y.key==="ArrowUp"?(y.preventDefault(),vt(k,E,-1)):y.key==="Home"?(y.preventDefault(),yt(k,"first")):y.key==="End"?(y.preventDefault(),yt(k,"last")):y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),b()):y.key==="Tab"&&s(null);},children:x}):null]})}function Xs(e){return Object.assign(n=>jsx(un,{id:e,...n}),{docxMenu:e})}var Js=Xs("file"),Qs=Xs("format"),ec=Xs("insert");function xS({className:e,hidden:t,onSelect:n}){let{setOpenMenu:o,onReportIssue:r,reportIssue:i}=nt(),a=Fe();if(t||i===false)return null;let l=n??r??kr;return jsx(Be,{slot:"help.reportIssue",onSelect:()=>{l(),o(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var di=Object.assign(xS,{docxSlot:"help.reportIssue"});function SS({children:e,...t}){let{reportIssue:n}=nt();return e===void 0&&n===false?null:jsxs(un,{id:"help",...t,children:[jsx(di,{}),e]})}var tc=Object.assign(SS,{docxMenu:"help"});var PS={file:Js,format:Qs,insert:ec,help:tc},ES=new Set(CHROME_MENUS.map(e=>e.id));function Zm(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let o=Children.toArray(e.props.children).map(Zm).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===un){let n=e.props.id;if(typeof n=="string"&&ES.has(n))return n}return null}function wS(e){let t=ot(),{className:n,t:o,fileName:r,onOpen:i,onOpenFile:a,onSave:l,onPageSetup:c,onReportIssue:s,reportIssue:d,preset:m=true,children:p}=e,g=H(),{t:u}=_(),[f,h]=useState(null),[S,C]=useState(null),[v,x]=useState(null),[b,y]=useState(false),[T,k]=useState(false),E=useRef(null),w=useRef(null);useEffect(()=>{if(f===null)return;let $=oe=>{let ne=E.current;ne&&oe.target instanceof Node&&ne.contains(oe.target)||h(null);},V=oe=>{oe.key==="Escape"&&h(null);};return document.addEventListener("mousedown",$),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",V);}},[f]);let A=useCallback($=>{h($),$!==null&&x($);},[]),N=useCallback(()=>w.current?.click(),[]),F=useCallback(()=>{g&&g.save().then($=>km($,wm(r??S??void 0))).catch($=>{console.error("[docx-editor] save failed",$);});},[g,r,S]),I=useCallback(()=>y(true),[]),D=g?i??N:void 0,R=g?l??F:void 0,M=g?c??I:void 0;useEffect(()=>{let $=V=>{if(!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey)return;let oe=V.key.toLowerCase();if(oe!=="s"&&oe!=="o")return;let ne=V.target,be=sn(E.current)??E.current;!ne||!be?.contains(ne)||(oe==="s"&&R?(V.preventDefault(),R()):oe==="o"&&D&&(V.preventDefault(),D()));};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[D,R]);let ae=useMemo(()=>({t:o,openMenu:f,setOpenMenu:A,activeMenu:v,onOpen:D,onSave:R,onPageSetup:M,onParagraphDialog:()=>k(true),onReportIssue:s,reportIssue:d}),[o,f,A,v,D,R,M,s,d]),K;if(!m)K=p;else {let $=new Map,V=[];for(let oe of Children.toArray(p)){let ne=Zm(oe);ne?$.set(ne,oe):V.push(oe);}K=jsxs(Fragment,{children:[CHROME_MENUS.map(oe=>{let ne=$.get(oe.id);if(ne)return jsx(Fragment$1,{children:ne},oe.id);let be=PS[oe.id];return jsx(be,{},oe.id)}),V]});}return jsxs(wr.Provider,{value:ae,children:[jsx("div",{ref:$=>{if(E.current=$,$&&v===null){let V=As($)[0]?.closest("[data-menu]")?.getAttribute("data-menu");V&&x(V);}},role:"menubar","aria-label":o?.("titleBar.menuBarAriaLabel")??u("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${t}docx-menubar${n?` ${n}`:""}`,onMouseDown:B,onKeyDown:$=>{if($.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;let V=E.current;if(!V)return;let oe=As(V),ne=oe.indexOf(document.activeElement);if(ne===-1)return;$.preventDefault();let be=$.key==="ArrowRight"?1:-1,he=oe[(ne+be+oe.length)%oe.length],W=he?.closest("[data-menu]")?.getAttribute("data-menu");W&&(x(W),he?.focus(),f!==null&&h(W));},children:K}),jsx("input",{ref:w,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:$=>{let V=$.target.files?.[0];$.target.value="",!(!V||!g)&&(C(V.name),a?.(V),V.arrayBuffer().then(oe=>g.load(new Uint8Array(oe))).catch(oe=>{console.error("[docx-editor] could not open the file",oe);}));}}),jsx(Er,{open:b,onClose:()=>y(false)}),jsx(To,{open:T,onClose:()=>k(false)})]})}var Dr=Object.assign(wS,{Menu:un,File:Js,Format:Qs,Insert:ec,Help:tc,Item:Ot,Row:Be,Group:Mr,Separator:Ro,Submenu:ko,TableGrid:ci,Entry:Ir,Open:Gs,Save:js,PageSetup:Ys,ReportIssue:di});var _S=12240,Km=1440,Um=1440,Wm=567,Mo=20,nc=6,DS=Mo+nc+2,NS="var(--doc-text-muted)",LS="var(--doc-text-subtle)",$m="var(--doc-shadow-subtle)",FS="var(--doc-primary)",AS="var(--doc-primary-hover)",HS="var(--doc-text-subtle)",Lr=5,Nr=7,OS={left:0,right:0,firstLine:0};function Vm(e,t){return t==="inch"?(e/Um).toFixed(2)+'"':(e/Wm).toFixed(1)+" cm"}function BS(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function Io({pageSetup:e,zoom:t=1,editable:n=false,onLeftMarginChange:o,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:c=false,onIndentChange:s,onIndentDragEnd:d,unit:m="inch",className:p="",style:g,tabMarks:u,onTabMarkRemove:f}){let{t:h}=_(),[S,C]=useState(null),[v,x]=useState(null),[b,y]=useState(null),[T,k]=useState(null),E=useRef(null),w=e?.pageWidthTwips??_S,A=e?.marginsTwips.left??Km,N=e?.marginsTwips.right??Km,F=e?.gutterTwips??0,I={pageWidth:w,leftMargin:A,rightMargin:N},D=l??OS,R=Pe(w)*t,M=Pe(A)*t,ae=Pe(N)*t,K=useCallback(Z=>{let we=E.current?.getBoundingClientRect();return we?Ta((Z-we.left)/t):null},[t]),$=useCallback((Z,we,ce)=>{let de=K(we);if(de===null)return;if(k(Pe(de)*t),Z==="leftMargin"||Z==="rightMargin"){if(Z==="leftMargin"){let uo=w-N-F-720,mt=Math.round(Math.max(0,Math.min(de,uo)));y(mt),o?.(mt);}else {let uo=w-de,mt=w-A-F-720,po=Math.round(Math.max(0,Math.min(uo,mt)));y(po),r?.(po);}return}let Ve=dragIndent(Z,de,D,I,{unit:m,precise:ce});y(Z==="right"?Ve.right:Z==="firstLine"?Ve.firstLine:Ve.left),s?.(Ve);},[K,t,w,A,N,F,o,r,s,D,I,m]),V=useCallback(Z=>{Z==="leftMargin"||Z==="rightMargin"?i?.():d?.(),C(null),y(null),k(null);},[i,d]),oe=useCallback((Z,we,ce)=>{let de=handlePosition(Z,D,I),Ve=dragIndent(Z,de+we*BS(m,ce),D,I,{unit:m,precise:true});s?.(Ve),d?.();},[D,I,m,s,d]),ne=VS(w,t,m),be=a&&c&&s!==void 0,he=Z=>Pe(handlePosition(Z,D,I))*t,W=(Z,we,ce)=>({positionPx:he(Z),editable:be,isDragging:S===Z,isHovered:v===Z,onPointerEnter:()=>x(Z),onPointerLeave:()=>x(null),onPointerDown:de=>{be&&(de.preventDefault(),de.stopPropagation(),de.currentTarget.setPointerCapture(de.pointerId),C(Z));},onPointerMove:de=>{S===Z&&$(Z,de.clientX,de.altKey);},onPointerUp:de=>{S===Z&&(de.currentTarget.releasePointerCapture(de.pointerId),V(Z));},onKeyDown:de=>{be&&(de.key!=="ArrowLeft"&&de.key!=="ArrowRight"||(de.preventDefault(),oe(Z,de.key==="ArrowLeft"?-1:1,de.shiftKey)));},label:h(we),valueNow:ce,valueText:Vm(ce,m),pageWidthTwips:w});return jsxs("div",{ref:E,className:`docx-horizontal-ruler ${p}`,style:{position:"relative",width:Ye(R),height:DS,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:S?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":h("ruler.horizontal"),children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:Ye(M),height:Mo,backgroundColor:$m,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&o?Z=>{Z.preventDefault(),Z.currentTarget.setPointerCapture(Z.pointerId),C("leftMargin");}:void 0,onPointerMove:Z=>S==="leftMargin"&&$("leftMargin",Z.clientX,Z.altKey),onPointerUp:Z=>{S==="leftMargin"&&(Z.currentTarget.releasePointerCapture(Z.pointerId),V("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:Ye(ae),height:Mo,backgroundColor:$m,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&r?Z=>{Z.preventDefault(),Z.currentTarget.setPointerCapture(Z.pointerId),C("rightMargin");}:void 0,onPointerMove:Z=>S==="rightMargin"&&$("rightMargin",Z.clientX,Z.altKey),onPointerUp:Z=>{S==="rightMargin"&&(Z.currentTarget.releasePointerCapture(Z.pointerId),V("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Mo,pointerEvents:"none"},children:ne.map((Z,we)=>jsx(ZS,{tick:Z},we))}),u?.map(Z=>jsx($S,{tabMark:Z,positionPx:Pe(Z.position)*t,onDoubleClick:()=>f?.(Z.position)},Z.position)),a&&jsxs(Fragment,{children:[jsx(oc,{direction:"down",anchor:"top",...W("firstLine","ruler.firstLineIndent",D.firstLine)}),jsx(oc,{direction:"up",anchor:"strip",...W("hanging","ruler.hangingIndent",D.left)}),jsx(qS,{...W("left","ruler.leftIndent",D.left)}),jsx(oc,{direction:"up",anchor:"strip",...W("right","ruler.rightIndent",D.right)})]}),S&&b!==null&&T!==null&&jsx(zS,{value:Vm(b,m),positionPx:T})]})}function ZS({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ye(e.position),bottom:0,width:1,height:e.height,backgroundColor:LS}}),e.label&&jsx("div",{style:{position:"absolute",left:Ye(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:NS,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Gm(e){return e.editable?e.isDragging||e.isHovered?AS:FS:HS}function jm(e,t,n){return {position:"absolute",left:Ye(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...n}}function Ym(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 oc({direction:e,anchor:t,...n}){let o=Gm(n),r=t==="top"?{top:0,height:Nr+1}:{top:Mo-Nr,height:Nr};return jsx("div",{className:"docx-ruler-indent",style:jm(n,Lr*2,r),onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onKeyDown:n.onKeyDown,...Ym(n),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Lr}px solid transparent`,borderRight:`${Lr}px solid transparent`,...e==="down"?{top:0,borderTop:`${Nr}px solid ${o}`}:{bottom:0,borderBottom:`${Nr}px solid ${o}`},transition:"border-color 0.1s"}})})}function qS(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:jm(e,Lr*2,{top:Mo+1,height:nc}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Ym(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:Lr*2-2,height:nc,backgroundColor:Gm(e),borderRadius:1,transition:"background-color 0.1s"}})})}function zS({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:Ye(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 KS={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function $S({tabMark:e,positionPx:t,onDoubleClick:n}){return jsx("div",{style:{position:"absolute",left:Ye(t-5),top:Mo-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:KS[e.alignment]||"L"})}function VS(e,t,n){let o=[];if(n==="inch"){let r=Um/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;a%8===0?o.push({position:c,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?o.push({position:c,height:5}):a%2===0?o.push({position:c,height:3}):o.push({position:c,height:2});}}else {let r=Wm/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;a%10===0?o.push({position:c,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?o.push({position:c,height:5}):o.push({position:c,height:3});}}return o}var GS=15840,Qm=1440,jS=1440,YS=567,mn=20,XS="var(--doc-text-muted)",JS="var(--doc-text-subtle)",QS="var(--doc-primary)",eT="var(--doc-primary)",tT="var(--doc-primary-hover)";function Fr({pageSetup:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:c}){let{t:s}=_(),[d,m]=useState(null),[p,g]=useState(null),u=useRef(null),f=e?.pageHeightTwips??GS,h=e?.marginsTwips.top??Qm,S=e?.marginsTwips.bottom??Qm,C=Pe(f)*t,v=Pe(h)*t,x=Pe(S)*t,b=useCallback((w,A)=>{n&&(w.preventDefault(),m(A));},[n]),y=useCallback(w=>{if(!d||!u.current)return;let A=u.current.getBoundingClientRect(),N=w.clientY-A.top,F=Ta(N/t);if(d==="topMargin"){let I=f-S-720,D=Math.max(0,Math.min(F,I));o?.(Math.round(D));}else if(d==="bottomMargin"){let I=f-F,D=f-h-720,R=Math.max(0,Math.min(I,D));r?.(Math.round(R));}},[d,t,f,h,S,o,r]),T=useCallback(()=>{d!==null&&i?.(),m(null);},[d,i]);useEffect(()=>{if(d)return document.addEventListener("mousemove",y),document.addEventListener("mouseup",T),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",T);}},[d,y,T]);let k=nT(f,t,a),E={position:"relative",width:mn,height:Ye(C),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...c};return jsxs("div",{ref:u,className:`docx-vertical-ruler ${l}`,style:E,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:k.map((w,A)=>jsx(oT,{tick:w},A))}),jsx(ef,{type:"topMargin",position:v,editable:n,isDragging:d==="topMargin",isHovered:p==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:w=>b(w,"topMargin")}),jsx(ef,{type:"bottomMargin",position:C-x,editable:n,isDragging:d==="bottomMargin",isHovered:p==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:w=>b(w,"bottomMargin")})]})}function oT({tick:e}){let t={position:"absolute",top:Ye(e.position),right:0,height:1,width:e.width,backgroundColor:JS},n={position:"absolute",top:Ye(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:XS,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function ef({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:l}){let{t:c}=_(),s=o?tT:r?eT:QS,d={position:"absolute",top:Ye(t-5),right:0,width:mn,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},m={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:i,onMouseLeave:a,onMouseDown:l,role:"slider","aria-label":c(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:m})})}function nT(e,t,n){let o=[];if(n==="inch"){let r=jS/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;if(a%8===0){let s=a/8;o.push({position:c,width:10,label:s>0?String(s):void 0});}else a%4===0?o.push({position:c,width:6}):a%2===0?o.push({position:c,width:4}):o.push({position:c,width:2});}}else {let r=YS/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;if(a%10===0){let s=a/10;o.push({position:c,width:10,label:s>0?String(s):void 0});}else a%5===0?o.push({position:c,width:6}):o.push({position:c,width:3});}}return o}var _o=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var iT=e=>e.formatting?.indent??null,lT=e=>e.editable;function ic(){let e=H(),t=O(iT),n=O(lT),o=useMemo(()=>n&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,n]),r=useCallback(i=>e?e.exec({...i.left!==void 0?{left:i.left}:{},...i.right!==void 0?{right:i.right}:{},...i.firstLine!==void 0?{firstLine:i.firstLine}:{},type:"setIndent"}).ok:false,[e]);return useMemo(()=>({indent:t,isEnabled:o,apply:r}),[t,o,r])}var af=e=>e.zoom,cT=e=>e.isOpening===true;function lf(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function sf(){let{apply:e}=Eo(),[t,n]=useState({}),o=useRef({}),r=useCallback(a=>l=>{o.current={...o.current,[a]:Math.round(l)},n(o.current);},[]),i=useCallback(()=>{let a=o.current;o.current={},n({}),Object.keys(a).length!==0&&e({...a.top!==void 0?{marginTopTwips:a.top}:{},...a.right!==void 0?{marginRightTwips:a.right}:{},...a.bottom!==void 0?{marginBottomTwips:a.bottom}:{},...a.left!==void 0?{marginLeftTwips:a.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:i}}function rf(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function dT(){let e=H(),{indent:t,isEnabled:n,apply:o}=ic(),[r,i]=useState(null),a=useRef(null),l=useRef(null),c=useCallback(m=>{l.current===null&&(l.current=rf(e)),a.current=m,i(m);},[e]),s=useCallback(()=>{let m=a.current,p=l.current;a.current=null,l.current=null,i(null),m&&(p!==null&&p!==rf(e)||o({left:m.left,right:m.right,firstLine:m.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 uT(){let e=Ft(),[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 gi(e){let t=O(_o),n=O(cT),{pageSetup:o,isEnabled:r}=Eo(),i=O(af),{pending:a,preview:l,commit:c}=sf(),s=dT(),d=xo(),m=tn(),p=uT();return t?null:jsx("div",{className:`docx-ruler-frame${n?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+m.inlineStart,paddingRight:m.inlineEnd},children:jsx(Io,{pageSetup:lf(o,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:c,showIndentHandles:s.indent!==null,indent:s.indent,indentEditable:s.isEnabled,onIndentChange:s.preview,onIndentDragEnd:s.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-p}px)`,clipPath:d>0&&p>0?`inset(0 0 0 ${p}px)`:e.style?.clipPath}})})}function bi(e){let t=O(_o),{pageSetup:n,isEnabled:o}=Eo(),r=O(af),{pending:i,preview:a,commit:l}=sf(),c=xo(),s=tn(),d=nu();return t||d!==null&&d>0&&n&&Pe(n.pageWidthTwips)*r>d-c-s.inlineStart-s.inlineEnd?null:jsx(Fr,{pageSetup:lf(n,i),zoom:r,editable:o,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,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 mT(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 fT(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 gT(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 bT(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 hT(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 vT(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 yT(e){return jsx(L,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function xT(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 ST(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 TT(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 CT(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 PT(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 ET(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 wT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function kT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function RT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function MT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function dc(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 IT(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 _T(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 DT(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 NT(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function LT(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 FT(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 AT(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 HT(e){return jsx(L,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function OT(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 BT(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 ZT(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 qT(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 zT(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 cf(e){return jsx(L,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function KT(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 $T(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 VT(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 UT(e){return jsx(L,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function WT(e){return jsx(L,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function GT(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 jT(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 YT(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 XT(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 JT(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 QT(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 eC(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 tC(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 oC(e){return jsx(L,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function nC(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 rC(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 aC(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 iC(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 lC(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 sC(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 cC(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 dC(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 uC(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 pC(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 mC(e){return jsx(L,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function fC(e){return jsx(L,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function gC(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 bC(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 hC(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 vC(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 yC(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 xC(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 SC(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 TC(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 CC(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 PC(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 EC(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 wC(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 kC(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 RC(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 MC(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 IC(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 _C(e){return jsx(L,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function DC(e){return jsx(L,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function NC(e){return jsx(L,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function LC(e){return jsx(L,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function FC(e){return jsx(L,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function AC(e){return jsx(L,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function HC(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 OC(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 BC(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 ZC(e){return jsx(L,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function qC(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 zC(e){return jsx(L,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function KC(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 $C(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 VC(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 UC(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 WC(e){return jsx(L,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function GC(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 jC(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 YC(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 XC(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 JC(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 QC(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 eP(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 tP(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 oP(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 nP={undo:mT,redo:fT,print:gT,file_download:bT,file_upload:hT,format_bold:vT,format_italic:yT,format_underlined:xT,strikethrough_s:ST,superscript:TT,subscript:CT,link:PT,format_clear:ET,format_align_left:wT,format_align_center:kT,format_align_right:RT,format_align_justify:MT,format_line_spacing:dc,format_list_bulleted:IT,format_list_numbered:_T,format_indent_increase:DT,format_indent_decrease:NT,format_color_text:LT,ink_highlighter:FT,format_color_reset:AT,arrow_drop_down:HT,table:OT,table_chart:BT,grid_on:ZT,table_rows:qT,view_column:zT,border_all:cf,select_all:cf,border_outer:KT,border_inner:$T,border_clear:VT,add:UT,remove:WT,delete:GT,delete_sweep:jT,call_merge:YT,call_split:XT,drag_indicator:JT,image:QT,format_image_left:eC,format_image_right:tC,horizontal_rule:oC,flip_to_back:nC,flip_to_front:rC,open_with:aC,tune:iC,rotate_right:lC,rotate_left:sC,swap_horiz:cC,swap_vert:dC,shapes:uC,format_paint:pC,expand_more:mC,expand_less:fC,border_top:gC,border_bottom:bC,border_left:hC,border_right:vC,border_horizontal:yC,border_vertical:xC,padding:SC,text_rotation_none:TC,wrap_text:CC,height:PC,fit_width:EC,settings:wC,border_color:kC,format_color_fill:RC,vertical_align_top:MC,vertical_align_center:IC,vertical_align_bottom:_C,line_weight:DC,keyboard_arrow_up:NC,keyboard_arrow_down:LC,keyboard_arrow_left:FC,keyboard_arrow_right:AC,more_vert:HC,page_break:OC,branding_watermark:BC,arrow_back:ZC,search:qC,toc:zC,done_all:KC,check_circle:$C,chat_bubble_outline:VC,chat_bubble_check:UC,check:WC,close:GC,add_comment:jC,comment:YC,edit_note:XC,rate_review:JC,visibility:QC,format_textdirection_l_to_r:eP,format_textdirection_r_to_l:tP,"agent-sparkle":oP};function z({name:e,size:t=20,className:n="",style:o}){let r=nP[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 Ar=12,uc=240,uf=16,sP=24,cP=Ar+uc+uf,fn=12,dP=36,uP=fn+dP+uf,Hr=rt__default.memo(function({headings:t,onHeadingClick:n,onClose:o,topOffset:r=0,scrollLeft:i=0,leftOffset:a=Ar}){let{t:l}=_(),[c,s]=useState(false),d=t.length?Math.min(...t.map(m=>m.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:a-i,bottom:0,width:uc,paddingTop:sP,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:c?"translateX(0)":`translateX(-${a+uc}px)`,transition:"transform 0.15s ease-out"},onMouseDown:m=>m.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(z,{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((m,p)=>jsx("div",{style:{marginLeft:(m.level-d)*16},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>n(m.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:m.text,children:m.text})},`${m.blockId}-${p}`))})]})});var fP=e=>e,gP=Object.freeze([]),bP=()=>{};function pc(e){let t=H(),n=O(fP),o=useMemo(()=>t&&!n.isLoading?t.getOutline():gP,[t,n]),r=useCallback(i=>{if(!t)return;t.focus();let a={paragraphId:i,offset:0};t.exec({type:"setSelection",range:{anchor:a,head:a}}),t.scrollToBlock(i);},[t]);return _o(n)?null:jsx(Hr,{headings:o,onHeadingClick:r,onClose:e.onClose??bP,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var mc=createContext(null);function Jt(e){let t=useContext(mc);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var gn=280,hi=32,pf=16;function No(e=280){return 32+e+16}function vi({viewportWidth:e,pageWidthPx:t,reservation:n,inlineEndReservation:o=0,inlineStartReservation:r=0,docked:i=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 a=(e-o-t)/2,l=a>=n?0:!i&&n<=2*a?2*(n-a):n;return Math.ceil(Math.max(0,l-r))}var TP=Object.freeze([]),CP=e=>e;function yi(){let e=H(),t=O(CP),[n,o]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():TP,[e,t]),i=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]),a=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:i,selectedBlockId:n,goTo:a,isEmpty:r.length===0}}var bc=150,hc=2e3,gc=Object.freeze([]),wP=e=>e;function xi(){let e=H(),t=O(wP),[n,o]=useState(""),[r,i]=useState(""),[a,l]=useState(false),[c,s]=useState(false),[d,m]=useState(gc),[p,g]=useState(-1);useEffect(()=>{if(n===r)return;let y=setTimeout(()=>i(n),bc);return ()=>clearTimeout(y)},[n,r]);let u=useMemo(()=>({matchCase:a,wholeWord:c}),[a,c]);useEffect(()=>{if(!e||r.length===0){m(gc),g(-1);return}let y=e.findMatches(r,u);m(T=>T===y?T:y);},[e,r,u,t]);let f=useRef(d);useEffect(()=>{f.current!==d&&(f.current=d,g(y=>y>=0&&y<d.length?y:-1));},[d]);let h=useCallback(y=>{if(!e)return;let T=d[y];if(!T)return;e.focus(),e.selectMatch(T).ok&&g(y);},[e,d]),S=useCallback(y=>{if(d.length===0)return;let k=((p<0?y>0?-1:0:p)+y+d.length)%d.length;h(k);},[p,h,d.length]),C=useCallback(()=>S(1),[S]),v=useCallback(()=>S(-1),[S]),x=useCallback(y=>o(y),[]),b=useCallback(()=>{o(""),i(""),m(gc),g(-1);},[]);return {query:n,setQuery:x,matchCase:a,setMatchCase:l,wholeWord:c,setWholeWord:s,matches:d,truncated:d.length>=hc,activeIndex:p,goTo:h,next:C,previous:v,clear:b,isPending:n!==r}}var DP=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)}},NP=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Si(e={}){let{defaultOpen:t=false,defaultTab:n="headings",paneWidth:o=280}=e,[r,i]=useState(t),[a,l]=useState(n),c=e.open??r,s=e.tab??a,{onOpenChange:d,onTabChange:m}=e,p=e.open!==void 0,g=e.tab!==void 0,u=useCallback(M=>{p||i(M),d?.(M);},[p,d]),f=useCallback(()=>u(!c),[c,u]),h=useCallback(M=>{g||l(M),m?.(M);},[g,m]),S=yo(),C=Ft(),v=useContext(ft),{pageSetup:x,zoom:b,reviewPaneOpen:y,fitting:T}=O(DP,NP),[k,E]=useState(0),[w,A]=useState(0),[N,F]=useState(0);useEffect(()=>{if(!C){E(0),A(0),F(0);return}let M=()=>{E(C.clientWidth);let K=getComputedStyle(C),$=Number.parseFloat(K.paddingInlineEnd);A(Number.isFinite($)?$:0);let V=Number.parseFloat(K.getPropertyValue("--docx-review-gutter-start"));F(Number.isFinite(V)?V:0);};if(M(),typeof ResizeObserver>"u")return;let ae=new ResizeObserver(M);return ae.observe(C),()=>ae.disconnect()},[C,c,y,v?.mounted]);let I=useRef(null);x&&(I.current=x.pageWidthTwips);let D=x?.pageWidthTwips??I.current,R=useMemo(()=>!c||D===null?0:vi({viewportWidth:k,pageWidthPx:Pe(D)*b,reservation:No(o),inlineEndReservation:w,inlineStartReservation:N,docked:T}),[c,D,b,k,o,w,N,T]);return useEffect(()=>{if(S)return S.setShift(R),()=>S.setShift(0)},[S,R]),useEffect(()=>{if(S)return S.setReservation(c?No(o):0),()=>S.setReservation(0)},[S,c,o]),{open:c,setOpen:u,toggle:f,tab:s,setTab:h,paneWidth:o,shift:R}}var Br=["headings","find"],Mt=(...e)=>e.filter(Boolean).join(" ");function Zr({className:e,style:t,children:n}){return jsx("div",{className:Mt("docx-nav__header",e),style:t,children:n??jsxs(Fragment,{children:[jsx(qr,{}),jsx(zr,{})]})})}function qr({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Close");return jsx("button",{type:"button",className:Mt("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>o.setOpen(false),children:n??jsx(z,{name:"arrow_back",size:20})})}function zr({className:e,style:t,children:n}){let{t:o}=Jt("Title");return jsx("h2",{className:Mt("docx-nav__title",e),style:t,children:n??o("navigation.title")})}function Kr({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Tabs"),i=useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let c=Br.indexOf(o.tab);o.setTab(Br[(c+l+Br.length)%Br.length]);},[o]);return jsx("div",{className:Mt("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:n??Br.map(a=>jsx($r,{value:a},a))})}function $r({value:e,className:t,style:n,children:o}){let{pane:r,t:i}=Jt("Tab"),a=r.tab===e;return jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":a,"aria-controls":`docx-nav-panel-${e}`,tabIndex:a?0:-1,className:Mt("docx-nav__tab",a&&"docx-nav__tab--selected",t),style:n,onClick:()=>r.setTab(e),children:o??i(`navigation.tabs.${e}`)})}function ff({value:e,onChange:t,onClear:n,placeholder:o,label:r,clearLabel:i,autoFocus:a}){return jsxs("div",{className:"docx-nav__searchbox",children:[jsx(z,{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:a,onChange:l=>t(l.target.value)}),e.length>0&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:n,children:jsx(z,{name:"close",size:16})})]})}function Vr({className:e,style:t}){let{pane:n,outline:o,t:r}=Jt("Headings"),[i,a]=useState(""),l=O(_o),c=useMemo(()=>{let d=i.trim().toLowerCase();return d.length===0?o.items:o.items.filter(m=>m.heading.text.toLowerCase().includes(d))},[o.items,i]),s=n.tab!=="headings";return jsxs("div",{className:Mt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:s,children:[jsx(ff,{value:i,onChange:a,onClear:()=>a(""),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,m)=>jsx("li",{children:jsx("button",{type:"button",className:Mt("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}-${m}`))})]})}function HP({match:e,active:t,onSelect:n}){return jsx("li",{children:jsx("button",{type:"button",className:Mt("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 Ur({className:e,style:t}){let{pane:n,search:o,t:r}=Jt("Find"),i=n.tab!=="find",a=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:Mt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:i,children:[jsx(ff,{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:a?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(z,{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(z,{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(HP,{match:c,active:s===o.activeIndex,onSelect:()=>o.goTo(s)},`${c.blockId}-${c.start}-${s}`))})]})}function Wr({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Toggle");return jsx("button",{type:"button",className:Mt("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":o.open,title:r("navigation.openTitle"),onMouseDown:i=>i.preventDefault(),onClick:o.toggle,children:n??jsx(z,{name:"toc",size:20})})}function xc(e){let t=ot(),{t:n,toggle:o=true,className:r,style:i,children:a,...l}=e,c=Si(l),s=yi(),d=xi(),{t:m}=_(),p=useMemo(()=>({pane:c,outline:s,search:d,t:n??((u,f)=>m(u,f))}),[c,s,d,n,m]),g=e.paneWidth??280;return jsx(mc.Provider,{value:p,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":`${No(g)}px`,...i},children:[o!==false&&!c.open&&jsx(Wr,{...typeof o=="object"?o:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":p.t("navigation.ariaLabel"),inert:!c.open,children:a??jsxs(Fragment,{children:[jsx(Zr,{}),jsx(Kr,{}),jsx(Vr,{}),jsx(Ur,{})]})})]})})}var Ti=Object.assign(xc,{Header:Zr,Close:qr,Title:zr,Tabs:Kr,Tab:$r,Headings:Vr,Find:Ur,Toggle:Wr});var $P=600,VP=e=>e.page.total,Ci=createContext(null);function Pi({className:e,style:t}){let n=ot(),o=H(),r=Ft(),i=O(VP),{t:a}=_(),l=useContext(Ci),[c,s]=useState(1),[d,m]=useState(false);if(useEffect(()=>{if(m(false),!o||!r||i<=1)return;s(o.getCurrentPage("viewport"));let g=null,u=()=>{s(o.getCurrentPage("viewport")),m(true),g&&clearTimeout(g),g=setTimeout(()=>m(false),$P);};return r.addEventListener("scroll",u,{passive:true}),()=>{r.removeEventListener("scroll",u),g&&clearTimeout(g);}},[o,i,r]),i<=1)return null;let p=l?l("viewer.pageIndicator").replace(/\{current\}/g,String(c)).replace(/\{total\}/g,String(i)):a("viewer.pageIndicator",{current:c,total:i});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:p})}var GP=[],jP=e=>e.fontSubstitutions??GP;function Ei({className:e,style:t,t:n}){let o=O(jP),{t:r}=_(),i=n??r,[a,l]=useState(null);if(o.length===0)return null;let c=o.join("\0");return a===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:i("editor.fontSubstitutionNotice",{fonts:o.join(", ")}).replace("{fonts}",o.join(", "))}),jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(c),children:i("common.dismiss")})]})}var Qe={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Sc(e){return Math.round(e/1440*100)/100}function vf(e){return Math.round(e*1440)}function JP(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 Tc(){let e=H(),t=useCallback(n=>e?.getHeaderFooterState()??null,[e]);return O(t,JP)}function vn(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 Gr(e,t){let[n,o]=useState(null),r=useCallback(l=>o(l),[]),[i,a]=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,m=new ResizeObserver(()=>g()),p=()=>{s=0;let f=e(c);if(f!==d&&(m.disconnect(),m.observe(c),m.observe(n),f&&m.observe(f),d=f),!f||!f.isConnected){a({visibility:"hidden"});return}let h=f.getBoundingClientRect(),S=t==="story-label"?Math.max(n.offsetHeight,28):n.offsetHeight,C=t==="story-label"?6:4,v=l===c,x=t==="after"?h.bottom+6:h.top-S-C,b=v?vn(c,h.left,x):{left:h.left,top:x},y=b.left,T=b.top,k=v?c.scrollLeft+8:8;a({position:v?"absolute":"fixed",left:t==="story-label"?y:Math.max(k,y+8),top:t==="story-label"?T:Math.max(v?c.scrollTop+8:8,T),...t==="story-label"?{width:Math.max(240,Math.min(h.width,c.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(h.width-16,c.clientWidth-16))},visibility:"visible"});},g=()=>{s||(s=requestAnimationFrame(p));};m.observe(c),m.observe(n);let u=new MutationObserver(g);return u.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),p(),()=>{s&&cancelAnimationFrame(s),m.disconnect(),u.disconnect(),c.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[n,e,t]),{ref:r,style:i}}function nE(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 rE=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function jr(e){let t=H();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 aE(e){let{state:t,onMouseDown:n}=e,{t:o}=_(),r=H(),[i,a]=useState(false),l=useRef(null),[c,s]=useState(""),[d,m]=useState("");useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(s(String(Sc(t.headerDistanceTwips))),m(String(Sc(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),useEffect(()=>{if(!i)return;let T=k=>{l.current?.contains(k.target)||a(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[i]);let p=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),u=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),S=jr(p),C=jr(g),v=jr(u),x=jr(f),b=jr(h),y=(T,k)=>{if(!r)return;let E=Number.parseFloat(k);Number.isFinite(E)&&r.exec({type:"setHeaderFooterOptions",[T]:vf(E)});};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":i,"aria-haspopup":"menu",onClick:()=>a(T=>!T),onMouseDown:n,children:o("headerFooter.options")}),i?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:n,children:[rE.map(T=>{let k={type:"insertPageField",field:T.field},E=r?.can(k);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(k),a(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:!S.enabled,title:S.reason??void 0,onChange:()=>r?.exec(p)}),jsx("span",{children:o("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!C.enabled,title:C.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:!x.enabled,title:x.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:!v.enabled,title:v.reason??void 0,onClick:()=>r?.exec(u),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=>m(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:!b.enabled,title:b.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"}),a(false);},onMouseDown:n,children:o("common.close")})]}):null]})}function wi({className:e}){let{t}=_(),n=Tc(),o=useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=Gr(o,"story-label"),i=B;if(!n?.editing)return null;let a=nE(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:i,style:{...r.style,zIndex:Qe.hfInlineEditor},children:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(a)}),n.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsx(aE,{state:n,onMouseDown:i})]})}function Ao(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ki=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),pE="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",mE="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",fE="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",gE="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 bE({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let i=It(),a=useRef(null),{state:l,close:c}=i;useEffect(()=>{if(l.mode==="closed")return;let f=S=>{S.key==="Escape"&&(S.preventDefault(),c());},h=S=>{let C=a.current;C&&S.target instanceof Node&&C.contains(S.target)||c();};return document.addEventListener("keydown",f),document.addEventListener("mousedown",h,true),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",h,true);}},[l.mode,c]);let[s,d]=useState(null);useLayoutEffect(()=>{let f=l.anchor,h=a.current;if(!f||!h){d(null);return}let S=h.offsetParent;if(!S){d(null);return}let{left:C,top:v}=vn(S,f.left,f.top),x=Math.max(0,S.scrollWidth-h.offsetWidth);d({left:Math.max(0,Math.min(C,x)),top:v});},[l.anchor]);let{t:m}=_(),p=l.mode==="editing"?m(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):m("hyperlinkPopup.editLink"),g=r?jsx(hE,{children:o}):o;if(n)return l.mode==="closed"?null:jsx(Fragment,{children:o});let u={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Ao,style:s??void 0,"aria-label":p};return l.mode==="closed"?null:t?jsx(j,{...u,children:o}):jsx("div",{...u,children:g})}function hE({children:e}){let{state:t}=It(),n=useMemo(()=>vE(e),[e]),o=(i,a)=>i in n?n[i]:a;if(t.mode==="editing")return jsxs(Fragment,{children:[o("Fields",jsx(Mc,{})),o("Error",jsx(_c,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Apply",jsx(Ic,{})),o("Cancel",jsx(Dc,{}))]}),n.__extra]});let r=t.canEdit&&!(t.link&&Kn(t.link));return jsxs(Fragment,{children:[o("Url",jsx(Ec,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Copy",jsx(wc,{})),r?o("Edit",jsx(kc,{})):null,r?o("Unlink",jsx(Rc,{})):null]}),n.__extra]})}function vE(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 i=r.type.docxHyperLinkPart;i?t[i]=r:n.push(r);};return o(e),n.length>0&&(t.__extra=n),t}function It(){return useContext($n)??yE}var yE={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 Ec({className:e,asChild:t,hidden:n,children:o}){let{state:r,openTarget:i}=It(),{t:a}=_();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=a(l?"hyperlinkPopup.inertTarget":c?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),m={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:Ao,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsx(j,{...m,children:o}):l?jsxs("span",{...m,children:[o??s,jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxs("button",{...m,children:[o??s,ki(gE)]})}Ec.docxHyperLinkPart="Url";function wc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{state:i,copy:a}=It(),{t:l}=_();if(n||!i.link?.href)return null;let c=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":c,title:c,onMouseDown:Ao,onClick:()=>{a();}};return t?jsx(j,{...s,children:o}):jsx("button",{...s,children:r??o??ki(pE)})}wc.docxHyperLinkPart="Copy";function kc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{beginEdit:i}=It(),{t:a}=_();if(n)return null;let l=a("hyperlinkPopup.editLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:r??o??ki(mE)})}kc.docxHyperLinkPart="Edit";function Rc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{unlink:i}=It(),{t:a}=_();if(n)return null;let l=a("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:r??o??ki(fE)})}Rc.docxHyperLinkPart="Unlink";function Mc({className:e,hidden:t}){let{state:n,setText:o,setUrl:r,commitEdit:i,close:a}=It(),{t:l}=_(),c=useRef(null),s=useId(),d=useId();useEffect(()=>{n.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[n.mode]);let m=useCallback(p=>{if(p.key==="Enter"){p.preventDefault(),i();return}p.key==="Escape"&&(p.preventDefault(),a());},[i,a]);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:p=>o(p.target.value),onKeyDown:m}),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:p=>r(p.target.value),onKeyDown:m})]})}Mc.docxHyperLinkPart="Fields";function Ic({className:e,asChild:t,hidden:n,children:o}){let{state:r,commitEdit:i}=It(),{t:a}=_();if(n)return null;let l=a("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:o??l})}function _c({className:e,hidden:t}){let{state:n}=It(),{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")})}_c.docxHyperLinkPart="Error";Ic.docxHyperLinkPart="Apply";function Dc({className:e,asChild:t,hidden:n,children:o}){let{close:r}=It(),{t:i}=_();if(n)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Ao,onClick:()=>r()};return t?jsx(j,{...l,children:o}):jsx("button",{...l,children:o??a})}Dc.docxHyperLinkPart="Cancel";var Ri=Object.assign(bE,{Url:Ec,Copy:wc,Edit:kc,Unlink:Rc,Fields:Mc,Error:_c,Apply:Ic,Cancel:Dc});var CE=e=>e;function Hc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Mi(){let e=H(),{t}=_(),[n,o]=useState(null),[r,i]=useState(null),a=useRef(null),l=useRef(null),c=useRef(null),s=useId(),d=useId(),m=useId(),p=n?.activation??null,g=O(CE),u=useMemo(()=>{if(!e?.surface||!p)return {replaceEnabled:false,removeEnabled:false,reason:null};let v=e.surface.equations.can(p.equation.id,"replace"),x=e.surface.equations.can(p.equation.id,"remove"),b=v.ok?x.ok?null:x.reason:v.reason;return {replaceEnabled:v.ok,removeEnabled:x.ok,reason:b?localizeDisabledReason(b,t):null}},[p,e,g,t]),f=useCallback((v=false)=>{c.current?.(),c.current=null,o(null),v&&e&&queueMicrotask(()=>e.focus());},[e]);useEffect(()=>{if(!e)return;let v=e.setEquationChrome({onPopover:x=>{c.current?.();let b=e.surface;if(b&&typeof b.retainSelection=="function"){let y=b.retainSelection();c.current=()=>b.releaseSelection(y);}else c.current=null;o({activation:x,mountGeneration:e.mountGeneration,draft:x.equation.linear,error:false});}});return ()=>{v(),c.current?.(),c.current=null,o(null);}},[e,f]),useEffect(()=>{if(!n||!e?.surface)return;(e.mountGeneration!==n.mountGeneration||!e.surface.equations.equationById(n.activation.equation.id))&&f();},[e,g,n,f]),useEffect(()=>{if(!n)return;let v=a.current,x=v?.ownerDocument,b=x?.defaultView;if(!v||!x||!b)return;let y=k=>{k.key==="Escape"&&(k.preventDefault(),f(true));},T=k=>{k.target instanceof b.Node&&v.contains(k.target)||f();};return x.addEventListener("keydown",y),x.addEventListener("pointerdown",T,true),()=>{x.removeEventListener("keydown",y),x.removeEventListener("pointerdown",T,true);}},[n,f]),useLayoutEffect(()=>{if(!p){i(null);return}let v=a.current;if(!v)return;let x=v.offsetParent;if(!x){i(null);return}let b=p.rect,y=vn(x,b.left,b.bottom),T=Math.max(0,x.scrollWidth-v.offsetWidth);i({left:Math.max(0,Math.min(y.left,T)),top:y.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[p]);let h=useCallback(()=>{if(!n||!e?.surface||!u.replaceEnabled)return false;let v=e.surface.equations.applyEquation(n.activation.equation.id,n.draft);return v?f(true):o(x=>x&&{...x,error:true}),v},[e,n,f,u.replaceEnabled]),S=useCallback(()=>{if(!n||!e?.surface||!u.removeEnabled)return false;let v=e.surface.equations.removeEquation(n.activation.equation.id);return v?f(true):o(x=>x&&{...x,error:true}),v},[e,n,f,u.removeEnabled]);if(!n)return null;let C=[n.error?d:null,u.reason?m:null].filter(Boolean).join(" ");return jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:Hc,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:s,children:t("equationPopup.inputLabel")}),jsx("input",{id:s,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:n.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":C||void 0,onChange:v=>o(x=>x&&{...x,draft:v.target.value,error:false}),onKeyDown:v=>{v.key!=="Enter"||v.nativeEvent.isComposing||(v.preventDefault(),h());}}),n.error?jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,u.reason?jsx("div",{id:m,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:u.reason}):null,jsxs("div",{className:"docx-equation-popup__actions",children:[jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!u.replaceEnabled,title:u.reason??void 0,onMouseDown:Hc,onClick:h,children:t("equationPopup.apply")}),jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!u.removeEnabled,title:u.reason??void 0,onMouseDown:Hc,onClick:S,children:t("equationPopup.delete")})]})]})}function PE(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 Oc(){let e=H(),t=useCallback(o=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),n=O(t,PE);return n?.kind==="note"?n:null}function wf(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 kf(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&&wf(e.documentAuthored,t.documentAuthored)&&wf(e.sectionAuthored,t.sectionAuthored)}function EE(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&kf(e.footnote,t.footnote)&&kf(e.endnote,t.endnote)}function Bc(){let e=H(),t=useCallback(n=>e?.getNotePropertiesState()??null,[e]);return O(t,EE)}var wE=/^(footnote|endnote):(-?\d{1,10})$/;function Mf(e){let t=wE.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isInteger(n)?{noteKind:t[1],noteId:n}:null}function kE(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function qc(e){let t=H();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 RE(e){let{t}=_(),[n,o]=useState(false),r=useRef(null);return useEffect(()=>{if(!n)return;let i=a=>{r.current?.contains(a.target)||o(false);};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[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:B,onClick:()=>o(i=>!i),children:t("headerFooter.options")}),n?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:B,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 Ii({className:e}){let{t}=_(),n=H(),o=Oc(),[r,i]=useState(null),[a,l]=useState(null),[c,s]=useState(false),d=useRef(null),m=useCallback(E=>{if(!o)return null;let A=[...E.querySelectorAll("[data-docx-note-scope]")].find(N=>N.matches("[data-docx-note]")&&N.dataset.docxNoteScope===o.id)??null;return A?.closest("[data-docx-notes]")??A},[o]),p=Gr(m,"story-label"),g=useCallback(()=>{d.current&&clearTimeout(d.current),d.current=null,i(null);},[]);useEffect(()=>{if(!n)return;let E=document.querySelector(".docx-pages");if(!E)return;let w=F=>{let I=F.target;if(!I)return;let D=I.closest("[data-docx-note-ref]");if(D?.dataset.docxNoteScope){F.preventDefault(),g(),l(null),n.setActiveScope({kind:"note",id:D.dataset.docxNoteScope});return}I.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),g(),l(null),n.setActiveScope({kind:"body"}));},A=F=>{let I=F,R=I.target?.closest("[data-docx-note-scope]");R?.dataset.docxNoteScope&&(I.preventDefault(),l({scopeId:R.dataset.docxNoteScope,x:I.clientX,y:I.clientY}));},N=F=>{if(kE())return;let D=F.target?.closest("[data-docx-note-ref]");if(!D?.dataset.docxNoteScope){g();return}let R=D.dataset.docxNoteScope,ae=n.getNotePreviewText(R)??D.getAttribute("aria-description")??t("notes.previewFallback"),K=D.getBoundingClientRect();d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{i({scopeId:R,text:ae,x:K.left,y:K.bottom+4});},400);};return E.addEventListener("click",w),E.addEventListener("contextmenu",A),E.addEventListener("pointerover",N),E.addEventListener("scroll",g,true),()=>{E.removeEventListener("click",w),E.removeEventListener("contextmenu",A),E.removeEventListener("pointerover",N),E.removeEventListener("scroll",g,true),g();}},[n,g,t]);let u=useCallback(E=>{n&&(n.exec(E),l(null));},[n]),f=a?Mf(a.scopeId):null,h=useMemo(()=>f?{type:"deleteNote",noteKind:f.noteKind,noteId:f.noteId}:null,[f]),S=useMemo(()=>f?{type:"convertNote",fromKind:f.noteKind,noteId:f.noteId}:null,[f]),C=useMemo(()=>f?{type:"convertAllNotes",fromKind:f.noteKind}:null,[f]),v=qc(h??{type:"deleteNote",noteKind:"footnote",noteId:0}),x=qc(S??{type:"convertNote",fromKind:"footnote",noteId:0}),b=qc(C??{type:"convertAllNotes",fromKind:"footnote"}),y=useMemo(()=>({position:"fixed",left:r?.x??0,top:r?.y??0,zIndex:Qe.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?Mf(o.id):null,k=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:p.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:{...p.style,zIndex:Qe.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:k}),jsx(RE,{onOpenProperties:()=>s(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,a&&f?jsxs("div",{role:"menu","data-testid":"docx-notes-menu",style:{position:"fixed",left:a.x,top:a.y,zIndex:Qe.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:B,children:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!v.enabled,title:v.reason??void 0,onClick:()=>h&&u(h),children:t("notes.delete")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!x.enabled,title:x.reason??void 0,onClick:()=>S&&u(S),children:f.noteKind==="footnote"?t("notes.convertToEndnote"):t("notes.convertToFootnote")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!b.enabled,title:b.reason??void 0,onClick:()=>C&&u(C),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(ME,{onClose:()=>s(false),onApply:E=>{u(E),s(false);}}):null]}):null}function ME(e){let{t}=_(),n=H(),o=Bc(),[r,i]=useState("document"),[a,l]=useState("decimal"),[c,s]=useState("continuous"),[d,m]=useState("pageBottom"),[p,g]=useState("decimal"),[u,f]=useState("continuous"),[h,S]=useState("docEnd");useEffect(()=>{o&&(l(o.footnote.resolved.numFmt),s(o.footnote.resolved.numRestart),m(o.footnote.resolved.pos),g(o.endnote.resolved.numFmt),f(o.endnote.resolved.numRestart),S(o.endnote.resolved.pos));},[o]);let C=!o?.footnote.documentAuthored&&!o?.footnote.sectionAuthored,v=!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:Qe.modal},onClick:e.onClose,onKeyDown:x=>{x.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:x=>x.stopPropagation(),onMouseDown:x=>x.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:x=>i(x.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")}),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:a,onChange:x=>l(x.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:x=>s(x.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:x=>m(x.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")}),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:p,onChange:x=>g(x.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:u,onChange:x=>f(x.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:x=>S(x.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 x={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?o?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:c,position:d},endnote:{numFmt:p,numRestart:u,position:h}};n.can(x).ok&&e.onApply(x);},children:t("common.apply")})]})]})})}var _i=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Ho(){return useContext(_i)}function Df(){return useContext(_i).target}var Nf=["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"],Lf=["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"],Ff=["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"],Af=["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"],Hf=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Of=["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"],Bf=["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 Di(e,t,n){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:c})=>{let s=H(),{close:d}=Ho(),m=Fe(),{isEnabled:p,disabledReason:g}=le(t);return c?null:jsx(Be,{slot:e,icon:r??re(n.paths),shortcut:m(a??n.shortcutKey),disabled:!p,...g?{title:g}:{},onSelect:()=>{s?.exec(t),d(true);},...l?{className:l}:{},children:m(i??n.labelKey)})},{docxRow:e})}var Xr=Di("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Nf}),Jr=Di("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Lf}),Qr=Di("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:Af}),ea=Di("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Bf});function Sn({icon:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:c}=Ho(),s=Fe(),d=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:m,disabledReason:p}=le(d);if(r)return null;let g=l!==null;return jsx(Be,{slot:"edit.paste",icon:e??re(Ff),shortcut:s(n??"contextMenu.pasteShortcut"),disabled:!m||g,...l??p?{title:l??p??""}:{},onSelect:()=>{(async()=>{try{let u=await navigator.clipboard.readText();u&&i?.exec({type:"paste",text:u});}catch(u){c(u instanceof Error?u.message:"the clipboard is not readable");}finally{a(true);}})();},...o?{className:o}:{},children:s(t??"contextMenu.paste")})}Sn.docxRow="edit.paste";function Oo(e,t,n){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:c})=>{let{close:s}=Ho(),d=Fe(),m=Ni(),{isEnabled:p,disabledReason:g,execute:u}=le(t);return l||!m?null:jsx(Be,{slot:e,icon:r??re(n.paths),disabled:!p,...g?{title:g}:{},className:`${c??n.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{u()&&s(true);},children:d(i??n.labelKey)})},{docxRow:e})}var Tn=Oo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),Cn=Oo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),Pn=Oo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),En=Oo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),wn=Oo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),kn=Oo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),Rn=Oo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),DE=[{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 Bo({hidden:e}){let{close:t}=Ho(),n=Fe(),o=Ni(),r=le({type:"setTableCellVerticalAlignment",alignment:"top"}),i=le({type:"setTableCellVerticalAlignment",alignment:"center"}),a=le({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];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:DE.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:m=>{m.preventDefault(),m.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:re(tableChromeIconPaths(c.icon))},c.alignment)})})]})}Bo.docxRow="table.cellVerticalAlignment";function qf(e,t,n){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let c=H(),{close:s,tocId:d}=Ho(),m=Fe(),p=useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:u}=le(p);return l||d===null?null:jsx(Be,{slot:e,icon:r??re(n.paths),disabled:!g,...u?{title:u}:{},onSelect:()=>{c?.exec(p),s(true);},...a?{className:a}:{},children:m(i??n.labelKey)})},{docxRow:e})}var Mn=qf("toc.refresh","entire",{labelKey:"toc.refresh",paths:Hf}),In=qf("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:Of});function Ni(){return O(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function Li({label:e,icon:t,shortcut:n,disabled:o,disabledReason:r,active:i,onSelect:a,className:l}){let{close:c}=Ho();return jsx(Be,{...t?{icon:t}:{},...n?{shortcut:n}:{},...o?{disabled:o}:{},...o&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),c(true);},...l?{className:l}:{},children:e})}var Hi=8,AE=e=>e.editingMode==="viewing";function HE(){let e=H(),t=useContext(ft),n=nt(),o=Fe(),r=e?.can({type:"toggleReviewPane"}),i=O(AE),a=!r?.ok||i||(t?.mounted??0)===0||e?.getSelectionPlacement()===null,l=J("review.comments");return jsx(Be,{icon:re(l?.paths),slot:"review.comments",disabled:a,title:r&&!r.ok?r.reason:i?o("editingMode.viewingHint"):void 0,onSelect:()=>{t?.requestCommentDraft()&&n.setOpenMenu(null);},children:o("comments.addComment")})}var OE=[{kind:"row",id:"edit.cut",render:()=>jsx(Xr,{})},{kind:"row",id:"edit.copy",render:()=>jsx(Jr,{})},{kind:"row",id:"edit.paste",render:()=>jsx(Sn,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(Qr,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(ea,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(Ot,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsx(HE,{})}];function BE(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Tn.docxRow,render:()=>jsx(Tn,{})},{kind:"row",id:Cn.docxRow,render:()=>jsx(Cn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Pn.docxRow,render:()=>jsx(Pn,{})},{kind:"row",id:En.docxRow,render:()=>jsx(En,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:wn.docxRow,render:()=>jsx(wn,{})},{kind:"row",id:kn.docxRow,render:()=>jsx(kn,{})},{kind:"row",id:Rn.docxRow,render:()=>jsx(Rn,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Bo.docxRow,render:()=>jsx(Bo,{})}]}function ZE(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Mn.docxRow,render:()=>jsx(Mn,{})},{kind:"row",id:In.docxRow,render:()=>jsx(In,{})}]}function qE(e,t=false){return [...OE,...e?BE():[],...t?ZE():[]]}function Uf(e){if(!isValidElement(e))return null;let t=on(e,Uf);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 $f(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function zE(e){return e?.closest(".docx-editor__scroll-container")??null}function oa({className:e,t,preset:n=true,disabled:o,onOpenChange:r,children:i}){let a=ot(),l=H(),{t:c}=_(),s=Ni(),d=useRef(null),m=useRef(null),[p,g]=useState(null),[u,f]=useState(null),[h,S]=useState(null),C=useMemo(()=>qE(s,u!==null),[s,u]),[v,x]=useState(null),b=useCallback((F=false)=>{g(null),x(null),f(null),S(null),F&&l?.focus();},[l]);useEffect(()=>{if(o)return;let F=zE(d.current);if(!F)return;let I=D=>{D.preventDefault();let R=D.button===-1||D.clientX===0&&D.clientY===0,M=F.getBoundingClientRect();f(l?.snapshot().tocContext?.id??null),S(R||!(D.target instanceof HTMLElement)?null:D.target),g(R?{x:M.left+16,y:M.top+16}:{x:D.clientX,y:D.clientY});};return F.addEventListener("contextmenu",I),()=>F.removeEventListener("contextmenu",I)},[o,l]),useEffect(()=>{o&&b();},[o,b]),useEffect(()=>{if(!p)return;let F=R=>{m.current?.contains(R.target)||b();},I=R=>{R.key==="Escape"?(R.preventDefault(),b(true)):R.key==="Tab"&&b();},D=()=>b();return document.addEventListener("pointerdown",F,true),document.addEventListener("keydown",I),document.addEventListener("scroll",D,{capture:true,passive:true}),window.addEventListener("blur",D),window.addEventListener("resize",D),()=>{document.removeEventListener("pointerdown",F,true),document.removeEventListener("keydown",I),document.removeEventListener("scroll",D,true),window.removeEventListener("blur",D),window.removeEventListener("resize",D);}},[p,b]),useLayoutEffect(()=>{let F=m.current;if(!p||!F)return;let{width:I,height:D}=F.getBoundingClientRect(),R=window.innerWidth-I-Hi,M=window.innerHeight-D-Hi,ae=Math.max(Hi,p.x>R?p.x-I:p.x),K=Math.max(Hi,p.y>M?p.y-D:p.y);x({x:ae,y:K});},[p]),useLayoutEffect(()=>{v&&m.current?.focus({preventScroll:true});},[v]);let y=useRef(r);y.current=r;let T=useRef(false);useEffect(()=>{let F=p!==null;F!==T.current&&(T.current=F,y.current?.(F));},[p]);let k=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>b(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,b]),[E,w]=useState(null),A=useMemo(()=>({close:b,anchor:p,tocId:u,target:h,clipboardRefusal:E,reportClipboardRefusal:w}),[b,p,u,h,E]),N={position:"fixed",left:(v??p)?.x??0,top:(v??p)?.y??0,visibility:v?"visible":"hidden"};return jsx("div",{ref:d,style:{display:"contents"},children:p?jsx(wr.Provider,{value:k,children:jsx(_i.Provider,{value:A,children:jsxs("div",{ref:m,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:N,onKeyDown:F=>{let I=m.current;if(!I)return;let D=Po(I);F.key==="ArrowDown"?(F.preventDefault(),vt(D,document.activeElement,1)):F.key==="ArrowUp"?(F.preventDefault(),vt(D,document.activeElement,-1)):F.key==="Home"?(F.preventDefault(),yt(D,"first")):F.key==="End"&&(F.preventDefault(),yt(D,"last"));},children:[Children.toArray(i).filter($f),Na({entries:C,children:Children.toArray(i).filter(F=>!$f(F)),preset:n,keyOfEntry:F=>F.id,keyOfChild:Uf,renderEntry:F=>F.kind==="separator"?jsx(Ro,{}):F.render()})]})})}):null})}var $c=Object.assign(oa,{Cut:Xr,Copy:Jr,Paste:Sn,Delete:Qr,SelectAll:ea,InsertRowAbove:Tn,InsertRowBelow:Cn,InsertColumnLeft:Pn,InsertColumnRight:En,DeleteTableRow:wn,DeleteTableColumn:kn,DeleteTable:Rn,CellVerticalAlignment:Bo,RefreshToc:Mn,RefreshTocPageNumbers:In,Item:Li,Slot:Ot,Row:Be,Group:Mr,Separator:Ro,Submenu:ko});function Vc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Gf=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),UE="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",WE="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",GE={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},jE={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},YE={color:"var(--doc-text-muted)",flexShrink:0},XE={textAlign:"right",wordBreak:"break-word"},JE={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},QE={display:"flex",gap:8,marginTop:4},jf={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 e1(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 t1(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 _n({label:e,value:t,testId:n}){return jsxs("div",{style:jE,"data-testid":n,children:[jsx("span",{style:YE,children:e}),jsx("span",{style:XE,children:t})]})}function o1({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let i=Et(),a=useRef(null),l=useId(),{t:c}=_(),{control:s,inspectorOpen:d,closeInspector:m}=i;if(useEffect(()=>{if(!d)return;let f=S=>{S.key==="Escape"&&(S.preventDefault(),m());},h=S=>{let C=a.current;C&&S.target instanceof Node&&C.contains(S.target)||m();};return document.addEventListener("keydown",f),document.addEventListener("mousedown",h,true),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",h,true);}},[d,m]),useEffect(()=>{d&&!s&&m();},[d,s,m]),n||!d||!s)return null;let p=r?jsxs(Fragment,{children:[jsx(Yf,{}),jsx(Xf,{}),jsx("div",{style:QE,children:jsx(Jf,{})}),o]}):o,g={ref:a,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:GE,onMouseDown:f=>{Vc(f),f.stopPropagation();}},u=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:c("contentControl.inspectorPanel.title")}),p]});return t?jsx(j,{...g,children:u}):jsx("div",{...g,children:u})}function Yf({className:e,asChild:t,hidden:n,children:o}){let{closeInspector:r}=Et(),{t:i}=_();if(n)return null;let a={style:JE,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxs(Fragment,{children:[jsx("span",{children:o??i("contentControl.inspectorPanel.title")}),jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...jf,padding:4,border:"none",background:"transparent"},onMouseDown:Vc,onClick:()=>r(),children:Gf(UE)})]});return t?jsx(j,{...a,children:l}):jsx("div",{...a,children:l})}function Xf({className:e,asChild:t,hidden:n,children:o}){let{control:r}=Et(),{t:i}=_();if(n||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),c=i("contentControl.inspectorPanel.no"),s=o??jsxs(Fragment,{children:[jsx(_n,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsx(_n,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsx(_n,{label:i("contentControl.inspectorPanel.type"),value:i(e1(r.controlType)),testId:"content-control-inspector-type"}),jsx(_n,{label:i("contentControl.inspectorPanel.lock"),value:i(t1(r)),testId:"content-control-inspector-lock"}),jsx(_n,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:c,testId:"content-control-inspector-placeholder"}),jsx(_n,{label:i("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:i("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:i("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(j,{...d,children:s}):jsx("div",{...d,children:s})}function Jf({className:e,asChild:t,hidden:n,icon:o,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:c}=Et(),{t:s}=_();if(n)return null;let d=s("contentControl.remove"),m={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,style:jf,onMouseDown:Vc,onClick:()=>{l().ok&&c();}},p=jsxs(Fragment,{children:[o??r??Gf(WE),jsx("span",{children:d})]});return t?jsx(j,{...m,children:p}):jsx("button",{...m,children:p})}var Oi=Object.assign(o1,{Header:Yf,Fields:Xf,Remove:Jf});var i1={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},l1={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},s1={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},c1={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},d1={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},u1={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)"},p1={padding:"8px 12px"},m1={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},f1={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},g1={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function b1({forwardedRef:e}){let t=H(),n=useRef(null);return n.current=t,lu({ref:e,editorRef:n}),null}var h1=forwardRef(function(t,n){let{document:o,fonts:r,className:i,t:a,chrome:l=true,title:c,onTitleChange:s,renderTitleBarLeft:d,renderTitleBarRight:m,colorMode:p="light",author:g,locale:u,mode:f="edit",modules:h,zoom:S,zoomMode:C,onReady:v,onChange:x,onFontError:b,onOpen:y,onSave:T,hyperlinkPopup:k,contextMenu:E=true,menu:w=true,navigation:A=true,rulers:N=true}=t,[F,I]=useState(yd);useEffect(()=>{if(p==="system")return Sd(I)},[p]);let D=xd(p,F),{t:R}=_(),M=useCallback((V,oe)=>a?a(V,oe):R(V,oe),[a,R]),ae=jsxs(Ma,{className:l?D?"dark":void 0:i,style:l?l1:void 0,children:[l?jsx(wi,{}):null,l?jsx(Ii,{}):null,jsx(Sa,{}),jsx(Ri,{hidden:k===false}),jsx(Mi,{}),E===false?null:jsx(oa,{t:M,...typeof E=="object"?E:{}}),jsx(Oi,{}),N&&l?jsx("div",{style:d1,"aria-hidden":"true",children:jsx(bi,{})}):null,t.children]}),K=l?jsxs("div",{className:`docx-editor${D?" dark":""}${i?` ${i}`:""}`,style:i1,children:[jsxs("div",{style:u1,children:[jsxs("div",{style:m1,children:[d?.(),jsxs("div",{style:f1,children:[s?jsx("input",{"aria-label":M("titleBar.documentNameAriaLabel"),value:c??"",placeholder:M("titleBar.untitled"),onChange:V=>s(V.target.value),style:g1}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:c??M("titleBar.untitled")}),w!==false?jsx(Dr,{t:M,...c!==void 0?{fileName:c}:{},...y?{onOpen:y}:{},...T?{onSave:T}:{},...typeof w=="object"?w:{}}):null]}),m?.()]}),jsx("div",{style:p1,children:jsx(Pr,{t:M})})]}),N?jsx("div",{style:c1,"data-testid":"docx-editor-ruler-row",children:jsx(gi,{})}):null,jsx(Ei,{t:M}),jsxs("div",{style:s1,children:[A?jsx(Ti,{t:M}):null,ae,jsx(Ci.Provider,{value:M,children:jsx(Pi,{})}),jsx(Ca,{overlay:true})]})]}):ae,$=useCallback(V=>M(V),[M]);return jsxs(Gn,{...o!==void 0?{document:o}:{},...r?{fonts:r}:{},...g!==void 0?{author:g}:{},...u!==void 0?{locale:u}:{},translate:M,mode:f,...h!==void 0?{modules:h}:{},...S!==void 0?{zoom:S}:{},...C!==void 0?{zoomMode:C}:{},tableInteractionLabel:$,...v?{onReady:v}:{},...x?{onChange:x}:{},...b?{onFontError:b}:{},children:[jsx(b1,{forwardedRef:n}),jsx(So.Provider,{value:l,children:K})]})}),v1=forwardRef(function(t,n){return jsx(Xo,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(h1,{...t,ref:n})})}),y1=Object.assign(v1,{Root:Gn,Viewport:Ma,Content:Sa,Toolbar:Pr,Menu:Dr,Loading:Ca,ColorByChangeType:kl,AuthorStyle:Rl,HorizontalRuler:gi,VerticalRuler:bi,DocumentOutline:pc,Navigation:Ti,PageSetupDialog:Er,ParagraphDialog:To,PageNumber:Pi,FontNotice:Ei,HeaderFooterChrome:wi,NotesChrome:Ii,Equation:Mi,HyperLink:Ri,ContextMenu:$c,ContentControl:Oi});function T1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}async function C1(e){return typeof e=="function"?e():e}function P1(e,t={}){let[n,o]=useState(void 0),[r,i]=useState(void 0),[a,l]=useState(null),[c,s]=useState(e!=null),[d,m]=useState(t.fonts===void 0),p=useRef(t);return p.current=t,useEffect(()=>{let g=p.current.fonts;if(g===void 0)return;let u=true;return (async()=>{try{let f=await C1(g);u&&i(composeFontConfiguration(f));}catch{}finally{u&&m(true);}})(),()=>{u=false;}},[]),useEffect(()=>{if(e==null){o(void 0),l(null),s(false);return}let g=T1(e);if(g){o(g),l(null),s(false);return}let u=true,f=new AbortController;return s(true),l(null),(async()=>{try{let h=await fetch(String(e),{...p.current.fetchOptions,signal:f.signal});if(!h.ok)throw new Error(`could not open the document: ${h.status} ${h.statusText}`);let S=new Uint8Array(await h.arrayBuffer());if(!u)return;o(S),s(!1);}catch(h){if(!u||h instanceof Error&&h.name==="AbortError")return;l(h instanceof Error?h:new Error("could not open the document")),s(false);}})(),()=>{u=false,f.abort();}},[e]),{document:d?n:void 0,fonts:r,error:a,isLoading:c||!d}}function R1(e,...t){let n=useRef({source:e,fragments:t});return n.current={source:e,fragments:t},useMemo(()=>async o=>{let r=n.current,a=[typeof r.source=="function"?await r.source(o):await r.source,...r.fragments].filter(s=>s!==void 0);if(a.length===0)return;let{epoch:l,...c}=composeFontConfiguration(a[0],...a.slice(1));return c},[])}var o0=[],_1=()=>{};function D1(){let e=H(),t=useCallback(n=>{if(!e)return _1;let o=hl(n),r=e.on("change",o),i=e.on("selectionChange",o);return ()=>{r(),i();}},[e]);return useSyncExternalStore(t,()=>e?.getReviewAuthors()??o0,()=>o0)}function F1(e){let n=e?.surface?.state?.().selection?.head;return n&&typeof n.paragraphId=="string"&&Number.isFinite(n.offset)?n:null}function A1(){let e=H(),t=useRef(null),n=useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),o=useCallback(()=>{let r=F1(e),i=t.current;return (r===null?i===null:i!==null&&H1(i,r))?i:(t.current=r,r)},[e]);return useSyncExternalStore(n,o,()=>null)}function H1(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function Uc({source:e,scale:t,measurer:n,onStateChange:o,onError:r,className:i,documentFontFamily:a,ref:l}){let c=useRef(null),s=useRef(null),[d,m]=useState(null),p=useRef(o);p.current=o;let g=useRef(r);return g.current=r,useEffect(()=>{let u=c.current;if(!u)return;let f=mountPaginatedSurface(u,e,{...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onChange:S=>{m(S),p.current?.(S);}});if(!f.ok){g.current?.(f.reason,f.detail);return}s.current=f.surface;let h=f.surface.state();return m(h),p.current?.(h),()=>{f.surface.destroy(),s.current=null;}},[e,n]),useImperativeHandle(l,()=>({focus:()=>s.current?.focus(),type:u=>s.current?.type(u),undo:()=>s.current?.undo(),redo:()=>s.current?.redo(),selectAll:()=>s.current?.selectAll(),navigate:(u,f)=>s.current?.navigate(u,f),toggleRunProperty:(u,f)=>s.current?.toggleRunProperty(u,f),setRunProperty:(u,f)=>s.current?.setRunProperty(u,f),setParagraphProperty:(u,f,h)=>s.current?.setParagraphProperty(u,f,h),formatting:()=>s.current?.formatting()??null,sectionProperties:()=>s.current?.sectionProperties()??null,save:()=>{let u=s.current;return u?(u.flushPendingInput(),u.session.save()):null}}),[]),jsx("div",{ref:c,style:{margin:"24px auto",...a?{fontFamily:a}:{}},className:i?`docx-paginated-surface ${i}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var aa=createContext(null);function r0(){let e=useContext(aa);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function U1(e){return "type"in e&&e.type==="separator"}var l0={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"},W1={...l0,background:"var(--doc-bg-hover)"},s0={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"},G1={...s0,opacity:.4,cursor:"default"},j1={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},Y1={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},X1={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 ia({label:e,items:t,disabled:n,showChevron:o=false}){let[r,i]=useState(false),[a,l]=useState(null),c=useRef(null),s=useRef(null),[d,m]=useState({top:0,left:0}),p=useCallback(()=>{i(false),l(null);},[]);useEffect(()=>{if(!r||!c.current)return;let u=c.current.getBoundingClientRect();m({top:u.bottom+2,left:u.left});},[r]),useEffect(()=>{if(!r)return;function u(S){let C=S.target;c.current&&!c.current.contains(C)&&s.current&&!s.current.contains(C)&&p();}function f(S){S.key==="Escape"&&p();}function h(){p();}return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),window.addEventListener("scroll",h,true),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f),window.removeEventListener("scroll",h,true);}},[r,p]);let g=u=>{u.disabled||u.submenuContent||u.onClick&&(u.onClick(),p());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:c,type:"button",onClick:()=>!n&&i(!r),onMouseDown:u=>u.preventDefault(),disabled:n,style:r?W1:l0,children:[e,o&&jsx(z,{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:u=>u.preventDefault(),children:t.map((u,f)=>{if(U1(u))return jsx("div",{style:j1},`sep-${f}`);let h=u;if(h.customContent)return jsx("div",{onMouseDown:v=>v.preventDefault(),children:h.customContent},h.label);let S=!!h.submenuContent,C=a===h.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>S&&l(h.label),onMouseLeave:()=>S&&l(null),children:[jsxs("button",{type:"button",style:h.disabled?G1:s0,onClick:()=>g(h),onMouseDown:v=>v.preventDefault(),onMouseOver:v=>{h.disabled||(v.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:v=>{v.currentTarget.style.backgroundColor="transparent";},disabled:h.disabled,children:[h.icon&&jsx(z,{name:h.icon,size:18}),jsx("span",{children:h.label}),h.shortcut&&jsx("span",{style:Y1,children:h.shortcut}),S&&jsx("span",{style:{marginLeft:"auto"},children:jsx(z,{name:"keyboard_arrow_right",size:16})})]}),S&&C&&jsx("div",{style:X1,onMouseDown:v=>v.preventDefault(),children:h.submenuContent(p)})]},h.label)})})]})}var jc=18,Q1=2,d0={width:jc,height:jc,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},e2={...d0,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},t2={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function u0({onInsert:e,gridRows:t=6,gridColumns:n=6}){let[o,r]=useState(0),[i,a]=useState(0),l=useCallback(()=>{o>0&&i>0&&e(o,i);},[o,i,e]),c=[];for(let d=1;d<=t;d++)for(let m=1;m<=n;m++){let p=d<=o&&m<=i;c.push(jsx("div",{style:p?e2:d0,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":p},`${d}-${m}`));}let s=o>0&&i>0?`${i} \xD7 ${o}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:Q1,gridTemplateColumns:`repeat(${n}, ${jc}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:c}),jsx("div",{style:t2,children:s})]})}function a2({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(z,{name:n.icon,size:18}),jsx("span",{children:n.label})]},n.label)})})}function i2(){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 qi({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function l2(e){return e.replace(/\.docx$/i,"")}function Xc({value:e,onChange:t,placeholder:n,editable:o=true}){let{t:r}=_(),i=n??r("titleBar.untitled"),a=l2(e)??"";return o?jsx("input",{type:"text",value:a,onChange:l=>{let c=l.target.value;t?.(c.endsWith(".docx")?c:c+".docx");},placeholder:i,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:a||i})}function zi({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Ki(){let{t:e}=_(),t=r0(),{disabled:n=false,onFormat:o,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:c,onInsertTable:s,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:p,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:u,onInsertTOC:f,onWatermark:h,onRefocusEditor:S}=t,C=useCallback(y=>{!n&&o&&o(y);},[n,o]),v=useCallback((y,T)=>{!n&&s&&(s(y,T),requestAnimationFrame(()=>S?.()));},[n,s,S]),x=!!r||!!l,b=x||i||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[b&&jsx(ia,{label:e("toolbar.file"),disabled:n,items:[...i?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:i}]:[],...a?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:a}]:[],...(i||a)&&x?[{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(ia,{label:e("toolbar.format"),disabled:n,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>C("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>C("setRtl")}]}),jsx(ia,{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(u0,{onInsert:(T,k)=>{v(T,k),y();}})}]:[],...c||d&&s?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:y=>jsx(a2,{closeMenu:y,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:p},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:u}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...h?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:h}]:[]]}),m&&jsx(ia,{label:e("toolbar.help"),disabled:n,items:[{label:e("toolbar.reportIssue"),onClick:()=>kr()}]})]})}function Jc({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===qi?t=a:a.type===zi?n=a:a.type===Ki?r.push(a):o.push(a));});let i=useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(i2,{})}),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 $i={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},u2={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:""},p0={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 p2(e,t){let n=p0[t]??p0[t.toLowerCase()]??t,r=e?.colorScheme?.[n];return typeof r=="string"&&r?r:$i[n]??"000000"}function m0(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 Qc(e,t,n="000000"){if(!e||e.kind==="auto")return `#${n}`;if(e.kind==="hex")return `#${m0(e.value)??n}`;let o=Object.entries(t?.colorScheme??$i).map(([i,a])=>({slot:i,hex:String(a)})),r=resolveThemeColorHex(e,o);return `#${r.ok?r.hex:p2(t,e.slot)}`}function Zt(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?m0(e.value):Qc(e,t).slice(1)}function f0(e){if(!e||e==="none")return "";let t=u2[e];return t?`#${t}`:""}var m2=[{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"}],f2=[{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 g0(e){let t=e??$i;return f2.map(n=>m2.map(o=>{let r=t[o.slot]??$i[o.slot]??"000000",a={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"?a.tint=n.keep:n.type==="shade"&&(a.shade=n.keep),a}))}function ee(...e){return clsx(e)}var h2=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"}}),Ae=rt.forwardRef(({className:e,variant:t,size:n,...o},r)=>jsx("button",{className:ee(h2({variant:t,size:n,className:e})),ref:r,...o}));Ae.displayName="Button";function ct({content:e,children:t,side:n="bottom",delayMs:o=400}){let[r,i]=rt.useState(false),[a,l]=rt.useState({x:0,y:0}),c=rt.useRef(null),s=rt.useRef(null),d=rt.useCallback(()=>{s.current=setTimeout(()=>{if(c.current){let u=c.current.getBoundingClientRect(),f=u.left+u.width/2,h=n==="top"?u.top-8:u.bottom+8;l({x:f,y:h});}i(true);},o);},[o,n]),m=rt.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),i(false);},[]);rt.useEffect(()=>()=>{s.current&&clearTimeout(s.current);},[]);let p=t.props,g=rt.cloneElement(t,{ref:c,onMouseEnter:u=>{d(),p.onMouseEnter?.(u);},onMouseLeave:u=>{m(),p.onMouseLeave?.(u);}});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:a.x,top:a.y,transform:n==="top"?"translate(-50%, -100%)":n==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var to=ye.Root,oo=ye.Group,Vi=ye.Value;function no({className:e,children:t,onMouseDown:n,...o}){return jsxs(ye.Trigger,{className:ee("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(ye.Icon,{asChild:true,children:jsx(T2,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function ro({className:e,children:t,position:n="popper",onCloseAutoFocus:o,...r}){let i=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsx(ye.Portal,{children:jsx("div",{className:ee("docx-editor",i&&"dark"),children:jsx(ye.Content,{className:ee("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:a=>{a.preventDefault(),o?.(a);},...r,children:jsx(ye.Viewport,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:a=>a.preventDefault(),children:t})})})})}function qo({className:e,...t}){return jsx(ye.Label,{className:ee("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function dt({className:e,children:t,onMouseDown:n,...o}){return jsxs(ye.Item,{className:ee("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(ye.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(ye.ItemIndicator,{children:jsx(C2,{className:"h-4 w-4"})})})]})}function zo({className:e,...t}){return jsx(ye.Separator,{className:ee("-mx-1 my-1 h-px bg-muted",e),...t})}function T2({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 C2({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 ed(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 P2=[{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 v0({value:e,onChange:t,fonts:n=P2,documentFonts:o,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:c=true}){let{t:s}=_(),d=rt.useMemo(()=>{if(!o)return [];let f=new Set(n.map(h=>h.name.toLowerCase()));return o.filter(h=>!f.has(h.name.toLowerCase()))},[o,n]),m=rt.useMemo(()=>[...d,...n],[d,n]),p=rt.useMemo(()=>e?m.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||ed(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=rt.useCallback(f=>{let h=m.find(S=>S.name===f);h&&t?.(ed(h.fontFamily)||h.name);},[t,m]),u=rt.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return n.forEach(h=>{let S=h.category||"other";f[S].push(h);}),f},[n]);return jsxs(to,{value:p,onValueChange:g,disabled:r,children:[jsx(no,{className:ee("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":s("font.selectAriaLabel"),children:jsx(Vi,{placeholder:a,children:p})}),jsxs(ro,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(oo,{children:[jsx(qo,{children:s("font.documentFonts")}),d.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(zo,{})]}),u["sans-serif"].length>0&&jsxs(oo,{children:[jsx(qo,{children:s("font.sansSerif")}),u["sans-serif"].map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),u.serif.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsxs(oo,{children:[jsx(qo,{children:s("font.serif")}),u.serif.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),u.monospace.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsxs(oo,{children:[jsx(qo,{children:s("font.monospace")}),u.monospace.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),u.other.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsx(oo,{children:u.other.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function td(e){if(e===void 0)return;let t=e.map(n=>typeof n=="string"?{name:n,fontFamily:n,category:"other"}:n);return t}function R2(e,t,n,o){let i=Math.max(8,window.innerWidth-n-8),a=Math.max(8,window.innerHeight-o-8);return {top:Math.min(Math.max(8,e),a),left:Math.min(Math.max(8,t),i)}}function et({isOpen:e,onClose:t,align:n="left"}){let o=useRef(null),r=useRef(null),[i,a]=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(),m=R2(s.bottom+4,s.right-d.width,d.width,d.height);a(m);}else a({top:s.bottom+4,left:s.left});}):a({top:s.bottom+4,left:s.left});},[e,n]),useEffect(()=>{if(!e)return;let s=performance.now()+150,d=g=>{let u=g.target;o.current&&!o.current.contains(u)&&r.current&&!r.current.contains(u)&&t();},m=g=>{g.key==="Escape"&&t();},p=g=>{if(performance.now()<s)return;let u=g.target;u&&r.current&&r.current.contains(u)||u instanceof Element&&u!==document.documentElement&&u!==document.body&&o.current&&u.contains(o.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),window.addEventListener("scroll",p,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m),window.removeEventListener("scroll",p,true);}},[e,t]);let l=useCallback(s=>{s.preventDefault(),s.stopPropagation();},[]),c={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:o,dropdownRef:r,dropdownStyle:c,handleMouseDown:l}}var _2=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],D2=1,N2=400;function S0(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function T0(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 C0({value:e,onChange:t,sizes:n=_2,disabled:o=false,className:r,placeholder:i="11",minSize:a=D2,maxSize:l=N2}){let{t:c}=_(),[s,d]=useState(false),[m,p]=useState(""),[g,u]=useState(false),f=useRef(null),h=useCallback(()=>{u(false),d(false);},[]),{containerRef:S,dropdownRef:C,dropdownStyle:v}=et({isOpen:g,onClose:h}),x=e??(parseInt(i,10)||11),b=e!==void 0?e.toString():i,y=useCallback(I=>{if(I.preventDefault(),o)return;let D=T0(x,n,a);t?.(D);},[x,n,a,o,t]),T=useCallback(I=>{if(I.preventDefault(),o)return;let D=S0(x,n,l);t?.(D);},[x,n,l,o,t]),k=useCallback(I=>{I.preventDefault(),!o&&(d(true),p(b),u(true),requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[o,b]),E=useCallback(I=>{p(I.target.value);},[]),w=useCallback(()=>{d(false);let I=parseFloat(m);if(!isNaN(I)&&I>=a&&I<=l){let D=Math.round(I*2)/2;t?.(D);}},[m,a,l,t]),A=useCallback(I=>{if(I.key==="Enter")I.preventDefault(),w(),u(false);else if(I.key==="Escape")d(false),u(false);else if(I.key==="ArrowUp"){I.preventDefault();let D=S0(x,n,l);p(D.toString()),t?.(D);}else if(I.key==="ArrowDown"){I.preventDefault();let D=T0(x,n,a);p(D.toString()),t?.(D);}},[w,x,n,l,a,t]),N=useCallback(I=>{t?.(I),u(false),d(false);},[t]),F=useCallback(I=>{I.target.tagName!=="INPUT"&&I.preventDefault();},[]);return jsxs("div",{ref:S,className:ee("flex items-center",r),onMouseDown:F,children:[jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("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||x<=a,"aria-label":c("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(z,{name:"remove",size:18})}),jsx("div",{className:"relative",children:s?jsx("input",{ref:f,type:"text",value:m,onChange:E,onBlur:w,onKeyDown:A,className:ee("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:k,className:ee("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:b})}),g&&jsx("div",{ref:C,style:{...v,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(I=>jsx("button",{type:"button",onClick:()=>N(I),className:ee("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",I===x&&"bg-muted font-medium"),role:"option","aria-selected":I===x,children:I},I))}),jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("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||x>=l,"aria-label":c("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(z,{name:"add",size:18})})]})}var A2=[{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"}],Wi=18,H2=2,O2={position:"relative",display:"inline-block"},B2={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)"},Z2={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},rd={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},ad={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},w0={display:"grid",gap:`${H2}px`},Gi={width:`${Wi}px`,height:`${Wi}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},k0={...Gi,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},R0={...Gi,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},q2={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)"},z2={display:"flex",alignItems:"center",gap:"6px"},K2={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},$2={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},P0={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},V2={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},U2={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)"},W2={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 id(e,t,n){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let o=f0(e);return o||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Qc(e,n)}function E0(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 M0(e,t,n){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Zt(e,n))===t.toUpperCase():false}function G2({matrix:e,selectedColor:t,theme:n,onSelect:o}){let[r,i]=useState(null);return jsx("div",{style:{...w0,gridTemplateColumns:`repeat(10, ${Wi}px)`},children:e.flatMap((a,l)=>a.map((c,s)=>{let d=`${l}-${s}`,m=r===d,p=M0(t,c.hex,n);return jsx("button",{type:"button",style:{...p?R0:m?k0:Gi,backgroundColor:`#${c.hex}`},title:c.label,"aria-label":c.label,"aria-selected":p,onClick:()=>o(c),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function j2({selectedColor:e,theme:t,onSelect:n}){let[o,r]=useState(null),{t:i}=_();return jsx("div",{style:{...w0,gridTemplateColumns:`repeat(10, ${Wi}px)`},children:A2.map((a,l)=>{let c=o===l,s=M0(e,a.hex,t),d=i(a.nameKey);return jsx("button",{type:"button",style:{...s?R0:c?k0:Gi,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":s,onClick:()=>n(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function Vo({mode:e,value:t,onChange:n,theme:o,disabled:r=false,className:i,style:a,title:l,icon:c,autoLabel:s,splitButton:d=true,defaultColor:m}){let[p,g]=useState(false),[u,f]=useState(false),[h,S]=useState(false),[C,v]=useState(false),[x,b]=useState(""),[y,T]=useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:k}=_();useEffect(()=>{let W=id(t,e,o).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(W)&&b(W.toUpperCase());},[t,e,o]);let E=useCallback(()=>g(false),[]),{containerRef:w,dropdownRef:A,dropdownStyle:N}=et({isOpen:p,onClose:E}),F=o?.colorScheme??null,I=useMemo(()=>g0(F),[F]),D=useMemo(()=>id(t,e,o),[t,e,o]),R=useMemo(()=>id(y,e,o),[y,e,o]),M=useCallback(()=>{r||g(W=>!W);},[r]),ae=useCallback(W=>{let Z;e==="highlight"?Z=W.hex:Z={kind:"theme",slot:W.themeSlot,...W.tint!==void 0?{tint:W.tint}:{},...W.shade!==void 0?{shade:W.shade}:{}},T(Z),n?.(Z),g(false);},[e,n]),K=useCallback(W=>{let Z=e==="highlight"?W:{kind:"hex",value:W};T(Z),n?.(Z),g(false);},[e,n]),$=useCallback(()=>{n?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,n]),V=useCallback(()=>{let W=x.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(W)){let Z=e==="highlight"?W:{kind:"hex",value:W};T(Z),n?.(Z),g(false),b("");}},[e,x,n]),oe=useCallback(()=>{r||n?.(y);},[r,y,n]),ne={...B2,...r?{cursor:"default",opacity:.38}:p?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:u?{backgroundColor:"var(--doc-bg-hover)"}:{}},be=k(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),he=c??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:w,className:`docx-color-picker ${i||""}`,style:{...O2,...a},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...V2,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...U2,...r?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:oe,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>S(true),onMouseLeave:()=>S(false),disabled:r,title:l||be,"aria-label":l||be,children:[jsx(z,{name:he,size:18}),jsx("div",{style:{...P0,backgroundColor:R==="transparent"?"#fff":R,outline:R==="transparent"||E0(R)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...W2,...r?{cursor:"default"}:p?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:C?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:M,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>v(true),onMouseLeave:()=>v(false),disabled:r,title:l||be,"aria-label":l||be,"aria-haspopup":"true","aria-expanded":p,children:jsx(z,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:ne,onClick:M,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||be,"aria-label":l||be,"aria-haspopup":"true","aria-expanded":p,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(z,{name:he,size:18}),jsx("div",{style:{...P0,backgroundColor:D==="transparent"?"#fff":D,outline:D==="transparent"||E0(D)?"1px solid #bbb":"none"}})]}),jsx(z,{name:"arrow_drop_down",size:14})]}),p&&jsx("div",{ref:A,className:"docx-color-picker-dropdown",style:{...N,...Z2},role:"dialog","aria-label":`${be} picker`,onMouseDown:W=>{W.target.tagName!=="INPUT"&&W.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:q2,onClick:$,onMouseDown:W=>W.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??k(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:ad}),jsx("div",{style:rd,children:k("colorPicker.themeColors")}),jsx(G2,{matrix:I,selectedColor:t,theme:o,onSelect:ae}),jsx("div",{style:ad}),jsx("div",{style:rd,children:k("colorPicker.standardColors")}),jsx(j2,{selectedColor:t,theme:o,onSelect:K}),jsx("div",{style:ad}),jsx("div",{style:rd,children:k("colorPicker.customColor")}),jsxs("div",{style:z2,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:K2,value:x,onChange:W=>b(W.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:W=>{W.key==="Enter"&&V();},onMouseDown:W=>{W.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...$2,opacity:/^[0-9A-Fa-f]{6}$/.test(x)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(x)?"pointer":"default"},onClick:V,onMouseDown:W=>W.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(x),children:k("common.apply")})]})]})})]})}var sa=20,ld=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(z,{name:"format_align_left",size:sa}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(z,{name:"format_align_center",size:sa}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(z,{name:"format_align_right",size:sa}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(z,{name:"format_align_justify",size:sa}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function D0({value:e="left",onChange:t,disabled:n=false}){let{t:o}=_(),[r,i]=useState(false),a=useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:c,dropdownStyle:s,handleMouseDown:d}=et({isOpen:r,onClose:a}),m=useCallback(S=>{n||t?.(S),i(false);},[n,t]),p=ld.find(S=>S.value===e)||ld[0],g=o(p.labelKey),u=p.shortcutKey?o(p.shortcutKey):void 0,f=`${g}${u?` (${u})`:""}`,h=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",n&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!n&&i(S=>!S),disabled:n,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(z,{name:p.iconName,size:sa}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(ct,{content:f,children:h}),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:S=>S.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:ld.map(S=>{let C=e===S.value,v=o(S.labelKey),x=S.shortcutKey?o(S.shortcutKey):void 0;return jsx("button",{type:"button",title:`${v}${x?` (${x})`:""}`,"data-testid":`alignment-${S.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,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)"},onMouseDown:b=>b.preventDefault(),onMouseEnter:b=>{C||(b.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:b=>{b.currentTarget.style.backgroundColor=C?"var(--doc-primary-light)":"transparent";},onClick:()=>m(S.value),children:jsx(z,{name:S.iconName,size:18})},S.value)})})})]})}function ji(){return {type:"none",level:0,isInList:false}}var ew={display:"inline-flex",alignItems:"center",gap:"4px"},N0={display:"inline-flex",alignItems:"center",gap:"4px"},Qi={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)"},tw={...Qi,backgroundColor:"var(--doc-bg-hover)"},ow={...Qi,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},nw={...Qi,cursor:"default",opacity:.38},rw={width:"28px",height:"28px",padding:"2px"},aw={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Yi=20;function Xi({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,style:a}){let[l,c]=useState(false),s={...t?nw:e?ow:l?tw:Qi,...a},d=m=>{m.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,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 L0({listState:e,onBulletList:t,onNumberedList:n,onIndent:o,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:c=true,compact:s=false,hasIndent:d=false}){let{t:m}=_(),p=useCallback(()=>s?{...rw}:{},[s]),g=e?.type==="bullet",u=e?.type==="numbered",h=(e?.isInList||g||u)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...ew,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxs("div",{style:N0,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsx(Xi,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:p(),children:jsx(z,{name:"format_list_bulleted",size:Yi})}),jsx(Xi,{active:u,disabled:i,title:m("lists.numberedList"),onClick:n,style:p(),children:jsx(z,{name:"format_list_numbered",size:Yi})})]}),c&&jsxs(Fragment,{children:[jsx("div",{style:aw,role:"separator"}),jsxs("div",{style:N0,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsx(Xi,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:r,style:p(),children:jsx(z,{name:"format_indent_decrease",size:Yi})}),jsx(Xi,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:o,style:p(),children:jsx(z,{name:"format_indent_increase",size:Yi})})]})]})]})}var lw=[{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 A0({value:e,onChange:t,options:n=lw,disabled:o=false,className:r}){let{t:i}=_(),a=rt.useMemo(()=>e===void 0?n[0]:n.find(s=>s.twipsValue===e)||n[0],[e,n]),l=rt.useCallback(s=>{let d=parseInt(s,10);isNaN(d)||t?.(d);},[t]),c=s=>s.labelKey?i(s.labelKey):s.label;return jsxs(to,{value:a.twipsValue.toString(),onValueChange:l,disabled:o,children:[jsx(no,{className:ee("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:c(a)}),children:jsx(dc,{className:"h-5 w-5 shrink-0"})}),jsxs(ro,{children:[n.map(s=>jsx(dt,{value:s.twipsValue.toString(),children:c(s)},s.twipsValue)),jsx(zo,{}),jsx(oo,{children:jsx(qo,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var H0=[{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 O0({value:e,onChange:t,styles:n,disabled:o=false,className:r,width:i=120}){let{t:a}=_(),l=rt.useMemo(()=>{let g=Fp(n);return g.length===0?H0:g.map(u=>({...u,type:"paragraph",nameKey:H0.find(f=>f.styleId===u.styleId)?.nameKey}))},[n]),c=rt.useCallback(g=>{t?.(g);},[t]),s=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",m=l.find(g=>g.styleId===d),p=m?s(m):d;return jsxs(to,{value:d,onValueChange:c,disabled:o,children:[jsx(no,{className:ee("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:p})}),jsx(ro,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(dt,{value:g.styleId,className:"py-2.5 px-3",children:jsx("span",{style:Lp(g),children:s(g)})},g.styleId))})]})}var cw=[{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 Z0({value:e=1,onChange:t,levels:n=cw,disabled:o=false,className:r,compact:i=false}){let{t:a}=_(),l=rt.useMemo(()=>{let g=n.find(u=>Math.abs(u.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[n,e]),c=rt.useCallback(g=>{let u=parseFloat(g);isNaN(u)||t?.(u);},[t]),s=rt.useMemo(()=>[...n].sort((g,u)=>g.value-u.value),[n]),d=rt.useMemo(()=>[...s].reverse().find(g=>g.value<e-.001),[s,e]),m=rt.useMemo(()=>s.find(g=>g.value>e+.001),[s,e]),p=i?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee(p,"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":a("zoom.zoomOut"),children:jsx(z,{name:"remove",size:18})}),jsxs(to,{value:e.toString(),onValueChange:c,disabled:o,children:[jsx(no,{className:ee(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsx(Vi,{placeholder:"100%",children:l})}),jsx(ro,{children:n.map(g=>jsx(dt,{value:g.value.toString(),children:g.label},g.value))})]}),jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee(p,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(o||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:o||!m,"aria-label":a("zoom.zoomIn"),children:jsx(z,{name:"add",size:18})})]})}var uw=[{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 K0({onAction:e,disabled:t=false}){let{t:n}=_(),[o,r]=useState(false),i=useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=et({isOpen:o,onClose:i}),d=useCallback(p=>{e(p),r(false);},[e]),m=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&r(p=>!p),disabled:t,"aria-label":n("table.borders.styleAriaLabel"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(z,{name:"border_all",size:20}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsx(ct,{content:n("table.borders.tooltip"),children:m}),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:p=>p.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:uw.map(({action:p,icon:g,labelKey:u})=>jsx("button",{type:"button",title:n(u),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(p),children:jsx(z,{name:g,size:18})},typeof p=="string"?p:p.type))})})]})}function $0({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),i=useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Zt(a,n);l&&e({type:"borderColor",color:l});},[e,n]);return jsx(Vo,{mode:"border",value:o,onChange:i,theme:n,disabled:t,title:r("table.borderColor")})}var gw=[{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 U0({onAction:e,disabled:t=false}){let[n,o]=useState(false),{t:r}=_(),i=useCallback(()=>o(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=et({isOpen:n,onClose:i}),d=useCallback(p=>{e({type:"borderWidth",size:p}),o(false);},[e]),m=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&o(p=>!p),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(z,{name:"line_weight",size:20}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?m:jsx(ct,{content:r("table.borderWidth"),children:m}),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:p=>p.stopPropagation(),children:gw.map(({size:p,label:g,thickness:u})=>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(p),children:[jsx("div",{style:{width:50,height:Math.max(u,1),backgroundColor:"#000",borderRadius:u>2?1:0}}),jsx("span",{children:g})]},p))})]})}function G0({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=_(),i=useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsx(Vo,{mode:"highlight",value:o,onChange:i,theme:n,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var hw={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"},Go={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},X0={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function J0({onAction:e,disabled:t=false,tableContext:n}){let{t:o}=_(),[r,i]=useState(false),[a,l]=useState(null),c=useCallback(()=>i(false),[]),{containerRef:s,dropdownRef:d,dropdownStyle:m,handleMouseDown:p}=et({isOpen:r,onClose:c,align:"right"}),g=n?.table?.attrs?.justification??"left",u=useCallback(S=>{e(S),i(false);},[e]),f=(S,C,v,x,b)=>{let y=t||b?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...hw,backgroundColor:a===S&&!y?"var(--doc-bg-hover)":"transparent",color:y?"var(--doc-text-muted)":b?.danger?"var(--doc-error)":"var(--doc-text)",cursor:y?"not-allowed":"pointer"},onClick:()=>!y&&u(x),onMouseEnter:()=>l(S),onMouseLeave:()=>l(null),disabled:y,children:[jsx(z,{name:C,size:16,className:b?.danger&&!y?"text-destructive":""}),jsx("span",{style:{flex:1},children:v})]},S)},h=jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:p,onClick:()=>!t&&i(S=>!S),disabled:t,"aria-label":o("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(z,{name:"more_vert",size:20})});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(ct,{content:o("table.moreOptions"),children:h}),r&&!t&&jsxs("div",{ref:d,style:{...m,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:S=>S.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:Go,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:Go,role:"separator"}),f("selectTable","select_all",o("table.selectTable"),"selectTable"),jsx("div",{style:Go,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:Go,role:"separator"}),jsx("div",{style:X0,children:o("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(S=>{let C={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"}[S]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:x=>x.preventDefault(),onMouseEnter:x=>{x.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent";},onClick:()=>u({type:"cellVerticalAlign",align:S}),children:jsx(z,{name:C[S],size:16})},S)})}),jsx("div",{style:Go,role:"separator"}),jsx("div",{style:X0,children:o("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(S=>{let C={left:"format_align_left",center:"format_align_center",right:"format_align_right"},v=g===S;return jsx("button",{type:"button",title:o({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[S]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",borderColor:v?"var(--doc-primary)":"var(--doc-border)",color:v?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:x=>x.preventDefault(),onClick:()=>u({type:"tableProperties",props:{justification:S}}),children:jsx(z,{name:C[S],size:16})},S)})}),jsx("div",{style:Go,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:Go,role:"separator"}),f("properties","settings",o("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var yw=20;function ol({options:e,activeValue:t,triggerIcon:n,tooltipContent:o,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:c=false}){let[s,d]=useState(false),m=useCallback(()=>d(false),[]),{containerRef:p,dropdownRef:g,dropdownStyle:u,handleMouseDown:f}=et({isOpen:s,onClose:m}),h=useCallback(C=>{i||r(C),d(false);},[i,r]),S=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",s&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(C=>!C),disabled:i,"aria-label":a??o,"aria-expanded":s,"aria-haspopup":"true","data-testid":l,children:[jsx(z,{name:n,size:yw}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:p,style:{position:"relative",display:"inline-block"},children:[s?S:jsx(ct,{content:o,children:S}),s&&!i&&jsx("div",{ref:g,style:{...u,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:C=>C.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",gap:c?1:2,minWidth:c?200:void 0},children:e.map(C=>{let v=t===C.value;return jsxs("button",{type:"button",title:C.label,"data-testid":l?`${l}-${C.value}`:void 0,style:{display:"flex",alignItems:"center",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)",...c?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:x=>x.preventDefault(),onMouseEnter:x=>{v||(x.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:x=>{x.currentTarget.style.backgroundColor=v?"var(--doc-primary-light)":"transparent";},onClick:()=>h(C.value),children:[jsx(z,{name:C.iconName,size:18}),c&&jsx("span",{style:{flex:1},children:C.label})]},C.value)})})})]})}var xw=[{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 Sw(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function eg({imageContext:e,onChange:t,disabled:n=false}){let{t:o}=_(),r=xw.map(l=>({...l,label:o(l.labelKey)})),i=Sw(e),a=r.find(l=>l.value===i)||r[0];return jsx(ol,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:n,testId:"toolbar-image-wrap",showLabels:true})}var Cw=[{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 tg({onTransform:e,disabled:t=false}){let{t:n}=_(),o=Cw.map(r=>({...r,label:n(r.labelKey)}));return jsx(ol,{options:o,triggerIcon:"rotate_right",tooltipContent:n("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var Tt=18;function ut({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||n?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),c=d=>{d.preventDefault();},s=jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"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":a||n,"data-testid":l?`toolbar-${l}`:void 0,children:r});return n?jsx(ct,{content:n,children:s}):s}function Ct({label:e,children:t,className:n}){return jsx("div",{className:ee("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 Rw(e){let t=rt__default.useContext(aa);return t?{...t,...Mw(e)}:e}function Mw(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function ud(e){let{t}=_(),n=Rw(e),{currentFormatting:o={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:c=false,disabled:s=false,className:d,style:m,enableShortcuts:p=true,editorRef:g,children:u,showFontPicker:f=true,fontFamilies:h,documentFonts:S,showFontSizePicker:C=true,showTextColorPicker:v=true,showHighlightColorPicker:x=true,showAlignmentButtons:b=true,showListButtons:y=true,showLineSpacingPicker:T=true,showStylePicker:k=true,documentStyles:E,theme:w,showZoomControl:A=true,zoom:N,onZoomChange:F,onRefocusEditor:I,imageContext:D,onImageWrapType:R,onImageTransform:M,onOpenImageProperties:ae,tableContext:K,onTableAction:$,inline:V=false}=n,oe=useRef(null),ne=useCallback(pe=>{!s&&r&&r(pe);},[s,r]),be=useCallback(()=>{!s&&l&&i&&i();},[s,l,i]),he=useCallback(()=>{!s&&c&&a&&a();},[s,c,a]),W=useCallback(pe=>{!s&&r&&r({type:"fontFamily",value:pe});},[s,r]),Z=rt__default.useMemo(()=>td(h),[h]),we=useCallback(pe=>{!s&&r&&r({type:"fontSize",value:pe});},[s,r]),ce=useCallback(pe=>{!s&&r&&r({type:"textColor",value:pe});},[s,r]),de=useCallback(pe=>{!s&&r&&r({type:"highlightColor",value:typeof pe=="string"?pe:""});},[s,r]),Ve=useCallback(pe=>{!s&&r&&r({type:"alignment",value:pe});},[s,r]),uo=useCallback(()=>{!s&&r&&r("bulletList");},[s,r]),mt=useCallback(()=>{!s&&r&&r("numberedList");},[s,r]),po=useCallback(()=>{!s&&r&&r("indent");},[s,r]),Me=useCallback(()=>{!s&&r&&r("outdent");},[s,r]),sl=useCallback(pe=>{!s&&r&&(r({type:"lineSpacing",value:pe}),requestAnimationFrame(()=>I?.()));},[s,r,I]),Fn=useCallback(pe=>{!s&&r&&r({type:"applyStyle",value:pe});},[s,r]),Pt=useCallback(pe=>{!s&&$&&($(pe),requestAnimationFrame(()=>I?.()));},[s,$,I]);useEffect(()=>{if(!p)return;let pe=me=>{if(me.defaultPrevented)return;let at=me.target,Hn=g?.current,ua=oe.current,mo=Hn?.contains(at),fd=ua?.contains(at);if(!mo&&!fd)return;if((me.ctrlKey||me.metaKey)&&!me.altKey)switch(me.key.toLowerCase()){case "b":me.preventDefault(),ne("bold");break;case "i":me.preventDefault(),ne("italic");break;case "u":me.preventDefault(),ne("underline");break;case "=":me.shiftKey?(me.preventDefault(),ne("superscript")):(me.preventDefault(),ne("subscript"));break;case "l":me.preventDefault(),Ve("left");break;case "e":me.preventDefault(),Ve("center");break;case "r":me.preventDefault(),Ve("right");break;case "j":me.preventDefault(),Ve("both");break;case "k":me.preventDefault(),ne("insertLink");break}};return document.addEventListener("keydown",pe),()=>{document.removeEventListener("keydown",pe);}},[p,ne,Ve,g]);let An=useCallback(pe=>{let me=pe.target;me.tagName==="INPUT"||me.tagName==="TEXTAREA"||me.tagName==="SELECT"||me.tagName==="OPTION"||pe.preventDefault();},[]),Yo=useCallback(pe=>{let me=pe.target,at=document.activeElement;me.tagName==="SELECT"||me.tagName==="OPTION"||at?.tagName==="SELECT"||requestAnimationFrame(()=>{I?.();});},[I]);return jsxs("div",{ref:oe,className:ee(!V&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:V?{display:"contents",...m}:m,role:V?void 0:"toolbar","aria-label":V?void 0:t("toolbar.ariaLabel"),"data-testid":V?void 0:"formatting-bar",onMouseDown:V?void 0:An,onMouseUp:V?void 0:Yo,children:[jsxs(Ct,{label:t("formattingBar.groups.history"),children:[jsx(ut,{onClick:be,disabled:s||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(z,{name:"undo",size:Tt})}),jsx(ut,{onClick:he,disabled:s||!c,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(z,{name:"redo",size:Tt})})]}),A&&jsx(Ct,{label:t("formattingBar.groups.zoom"),children:jsx(Z0,{value:N,onChange:F,disabled:s,compact:true})}),k&&jsx(Ct,{label:t("formattingBar.groups.styles"),children:jsx(O0,{value:o.styleId||"Normal",onChange:Fn,styles:E,theme:w,disabled:s,width:120})}),(f||C)&&jsxs(Ct,{label:t("formattingBar.groups.font"),children:[f&&jsx(v0,{value:o.fontFamily||"Arial",onChange:W,fonts:Z,documentFonts:S,disabled:s,width:60,placeholder:"Arial"}),C&&jsx(C0,{value:o.fontSize!==void 0?El(o.fontSize):11,onChange:we,disabled:s,width:42,placeholder:"11"})]}),jsxs(Ct,{label:t("formattingBar.groups.textFormatting"),children:[jsx(ut,{onClick:()=>ne("bold"),active:o.bold,disabled:s,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(z,{name:"format_bold",size:Tt})}),jsx(ut,{onClick:()=>ne("italic"),active:o.italic,disabled:s,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(z,{name:"format_italic",size:Tt})}),jsx(ut,{onClick:()=>ne("underline"),active:o.underline,disabled:s,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(z,{name:"format_underlined",size:Tt})}),jsx(ut,{onClick:()=>ne("strikethrough"),active:o.strike,disabled:s,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(z,{name:"strikethrough_s",size:Tt})}),v&&jsx(Vo,{mode:"text",value:o.color?.replace(/^#/,""),onChange:ce,theme:w,disabled:s,title:t("formattingBar.fontColor")}),x&&jsx(Vo,{mode:"highlight",value:o.highlight,onChange:de,theme:w,disabled:s,title:t("formattingBar.highlightColor")}),jsx(ut,{onClick:()=>ne("insertLink"),disabled:s,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(z,{name:"link",size:Tt})})]}),jsxs(Ct,{label:t("formattingBar.groups.script"),children:[jsx(ut,{onClick:()=>ne("superscript"),active:o.superscript,disabled:s,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(z,{name:"superscript",size:Tt})}),jsx(ut,{onClick:()=>ne("subscript"),active:o.subscript,disabled:s,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(z,{name:"subscript",size:Tt})})]}),b&&jsx(Ct,{label:t("formattingBar.groups.alignment"),children:jsx(D0,{value:o.alignment||"left",onChange:Ve,disabled:s})}),(y||T)&&jsxs(Ct,{label:t("formattingBar.groups.listFormatting"),children:[y&&jsx(L0,{listState:o.listState||ji(),onBulletList:uo,onNumberedList:mt,onIndent:po,onOutdent:Me,disabled:s,showIndentButtons:true,compact:true,hasIndent:(o.indentLeft??0)>0}),T&&jsx(A0,{value:o.lineSpacing,onChange:sl,disabled:s})]}),D&&R&&jsxs(Ct,{label:t("formattingBar.groups.image"),children:[jsx(eg,{imageContext:D,onChange:R,disabled:s}),M&&jsx(tg,{onTransform:M,disabled:s}),ae&&jsx(ut,{onClick:ae,disabled:s,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(z,{name:"tune",size:Tt})})]}),K?.isInTable&&$&&jsxs(Ct,{label:t("formattingBar.groups.table"),children:[jsx(K0,{onAction:Pt,disabled:s}),jsx($0,{onAction:Pt,disabled:s,theme:w,value:Zt(K?.cellBorderColor,w)}),jsx(U0,{onAction:Pt,disabled:s}),jsx(G0,{onAction:Pt,disabled:s,theme:w,value:K?.cellBackgroundColor}),jsx(J0,{onAction:Pt,disabled:s,tableContext:K})]}),jsx(ut,{onClick:()=>ne("clearFormatting"),disabled:s,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(z,{name:"format_clear",size:Tt})}),u]})}function Iw({children:e,className:t,style:n,...o}){return jsx(aa.Provider,{value:o,children:jsx("div",{className:ee("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:Qe.toolbar,...n},"data-testid":"editor-toolbar",children:e})})}var tt=Iw;tt.TitleBar=Jc;tt.Logo=qi;tt.DocumentName=Xc;tt.MenuBar=Ki;tt.TitleBarRight=zi;tt.Toolbar=ud;var Nw=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"]]),Lw=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function Fw({source:e,scale:t,measurer:n,documentName:o,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:c,ref:s,colorMode:d,onZoomChange:m,documentFontFamily:p,className:g}){let u=useRef(null),[f,h]=useState(null),[S,C]=useState({}),[v,x]=useState(null),b=useCallback(E=>{h(E);let w=u.current?.formatting();w&&C({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}:{}}),x(u.current?.sectionProperties()??null),r?.(E);},[r]),y=useCallback(E=>{let w=u.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 A=E.value,N=typeof A=="string"?Lw(A):Zt(A,null)??null;return N?w.setRunProperty("color",{val:N}):void 0}case "highlightColor":{let A=E.value.trim().toLowerCase();if(A==="none"||A==="")return w.setRunProperty("highlight",{val:"none"});let N=Nw.get(A.startsWith("#")?A:`#${A}`);return N?w.setRunProperty("highlight",{val:N}):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"},{mergeAttributes:true});case "applyStyle":return w.setParagraphProperty("pStyle",{val:E.value});default:return}}},[]);useImperativeHandle(s,()=>u.current,[]);let T=t===void 0?1:t/(96/72),k=v?{pageWidthTwips:v.pageSize.widthTwips,pageHeightTwips:v.pageSize.heightTwips,orientation:v.landscape?"landscape":"portrait",marginsTwips:{top:v.margins.topTwips,right:v.margins.rightTwips,bottom:v.margins.bottomTwips,left:v.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(tt,{currentFormatting:S,onFormat:y,onUndo:()=>u.current?.undo(),onRedo:()=>u.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:T,onZoomChange:m,onSave:()=>{let E=u.current?.save();E&&a?.(E);},children:[jsxs(tt.TitleBar,{children:[l&&jsx(tt.Logo,{children:l()}),jsx(tt.DocumentName,{value:o??"Document",editable:false}),c&&jsx(tt.TitleBarRight,{children:c()}),jsx(tt.MenuBar,{})]}),jsx(tt.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[k?jsx("div",{style:{padding:"4px 0"},children:jsx(Io,{pageSetup:k,zoom:T})}):null,jsx(Uc,{ref:u,source:e,...p?{documentFontFamily:p}:{},...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onStateChange:b,...i?{onError:i}:{}})]})]})}var rl=class{listeners=new Set;snapshot;constructor(t){this.snapshot=t;}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t);});getSnapshot=()=>this.snapshot;setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var al=class extends rl{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,n){return this.addNotification(t,"error",n)}showWarning(t,n){return this.addNotification(t,"warning",n)}showInfo(t,n){return this.addNotification(t,"info",n)}dismiss(t){this.notifications=this.notifications.map(o=>o.id===t?{...o,dismissed:true}:o),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(o=>o.id!==t),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,n,o){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:n,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),n!=="error"){let a=setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var qw=createContext(null);function ig({children:e}){let t=useMemo(()=>new al,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((s,d)=>{t.showError(s,d);},[t]),r=useCallback((s,d)=>{t.showWarning(s,d);},[t]),i=useCallback((s,d)=>{t.showInfo(s,d);},[t]),a=useCallback(s=>{t.dismiss(s);},[t]),l=useCallback(()=>{t.clearAll();},[t]),c=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[n.notifications,o,r,i,a,l]);return jsxs(qw.Provider,{value:c,children:[e,jsx(zw,{notifications:n.notifications,onDismiss:a})]})}function zw({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(Kw,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function Kw({notification:e,onDismiss:t}){let{t:n}=_(),[o,r]=useState(false),a=(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:a.bg,border:`1px solid ${a.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:a.icon,flexShrink:0},d={flex:1,minWidth:0},m={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},p={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:a.text,maxHeight:"200px",overflow:"auto"},g={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:a.text},u=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:`
1
+ import*as rt from'react';import rt__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,overlayHostOrigin,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,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 ye from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var hd={version:"2.9.2"};var p0=hd.version;var vd="(prefers-color-scheme: dark)";function yd(){return typeof window<"u"&&typeof window.matchMedia=="function"}function xd(){return yd()?window.matchMedia(vd).matches:false}function Sd(e,t){return e==="dark"||e==="system"&&t}function Td(e){if(!yd())return ()=>{};let t=window.matchMedia(vd);e(t.matches);let n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}var cl=createContext(null);function H(){return useContext(cl)}var ft=createContext(null);var dl=createContext(en),ul=createContext("en");function Xo({i18n:e,children:t}){let n=useContext(dl),o=useContext(ul),r=typeof e?._lang=="string"?e._lang:o,i=useMemo(()=>deepMerge(n,e),[n,e]);return jsx(ul.Provider,{value:r,children:jsx(dl.Provider,{value:i,children:t})})}function N(){let e=useContext(dl),t=useContext(ul);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e}}function kd(e){let{t}=N();return useCallback((n,o)=>e?.get(n)??t(n,o),[e,t])}var pl=0,ml=false,fl=false;function Rd(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(ml||(ml=true,pl+=1,queueMicrotask(()=>{ml=false;}),fl||(fl=true,setTimeout(()=>{fl=false,pl=0;},0))),pl>16)}function Md(e){let t=false;return ()=>{if(t)return;t=true;let n=()=>{t=false,e();};Rd()?setTimeout(n,0):queueMicrotask(n);}}var x0=()=>{},bl=0;function S0(){return bl}function hl(e){return Md(e)}function O(e,t=Object.is,n){let o=H(),r=n?.onSubscribe,i=n?.onUnsubscribe,a=useCallback(d=>{if(!o)return x0;let m=false;bl++,r?.();let p=hl(()=>{m||d();}),g=[o.on("change",p),o.on("selectionChange",p),o.on("error",p)];return ()=>{m=true,bl--,i?.();for(let u of g)u();}},[o,r,i]),l=useMemo(()=>{let d=false,m,p;return g=>{if(d&&g===m)return p;let u=e(g);return d&&t(p,u)?(m=g,p):(d=true,m=g,p=u,u)}},[o,e,t]),c=useCallback(()=>l(o?o.snapshot():LOADING_SNAPSHOT),[o,l]),s=useCallback(()=>l(LOADING_SNAPSHOT),[l]);return useSyncExternalStore(a,c,s)}var _d=12700,Id=96;function E0(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function w0(e,t,n,o){let r=e*72/n,i=t*72/o;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function fa(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(!E0(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:i,heightPoints:a}=w0(o.pixelWidth,o.pixelHeight,Id,Id);return Object.freeze({ok:true,bytes:e,mime:n,widthPoints:i,heightPoints:a})}function $t(e){return Math.round(e/_d*100)/100}function Zn(e){return Math.round(e*_d)}var fo=createContext({t:void 0,onSave:void 0});function R0(){return useContext(fo)}function ga(e){let{t}=N();return n=>e?.(n)??t(n)}function X(){let{t:e}=useContext(fo);return ga(e)}function L0(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function vl(e){return typeof e=="string"}function le(e){let t=H(),{t:n}=N(),o=vl(e)?e:editorCommandKey(e),r=useRef(e);r.current=e;let i=useCallback(c=>{let s=r.current;if(vl(s)){let m=toolbarCommandState(t,s);return {active:m.active,enabled:m.enabled,disabledReason:localizeDisabledReason(m.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]),a=O(i,L0),l=useCallback(()=>{let c=r.current;return vl(c)?runToolbarCommand(t,c).ok:t?t.exec(c).ok:false},[t,o]);return useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason}),[l,a])}function O0(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]=O0(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 j({children:e,...t}){let n=Children.only(e);if(!isValidElement(n))return null;let o=n.props,r=B0(t,o),i=n.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let c of [i,a])typeof c=="function"?c(l):c&&typeof c=="object"&&(c.current=l);}),cloneElement(n,r)}function J(e){for(let t of CHROME_GROUPS)for(let n of t.controls)if(chromeSlotId(t,n)===e)return n;return null}function re(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 B(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function go(e){let{slot:t,icon:n,asChild:o,className:r,children:i,hidden:a}=e,{execute:l,isActive:c,isEnabled:s,disabledReason:d}=le(t),m=X();if(a)return null;let p=J(t),g=m(p?.labelKey??t),u=commandForSlot(t),f=u?.type==="toggleMark"||u?.type==="setAlignment",b={onClick:()=>l(),onMouseDown:B,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(j,{...b,children:i}):jsx("button",{type:"button",...b,children:n??i??re(p?.paths)})}go.docxToolbarPart=true;var G0="image/png,image/jpeg,image/gif",xl=createContext(null);function ha(){let e=useContext(xl);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Sl(){return useContext(xl)}function va({children:e}){let t=H(),{t:n}=N(),o=useRef(null),r=useRef(false),i=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),a=O(i,(f,b)=>f.enabled===b.enabled&&f.disabledReason===b.disabledReason),l=a.enabled,c=localizeDisabledReason(a.disabledReason,n),s=useCallback(async f=>{if(!t||r.current)return;let b=fa(f);if(!b.ok){window.alert(n(b.reasonKey));return}let x={type:"insertImage",data:b.bytes,mime:b.mime,widthPoints:b.widthPoints,heightPoints:b.heightPoints},T=t.canExecuteImageCommand?.(x);if(T&&!T.ok){window.alert(T.reason??n("imageInsert.errors.refused"));return}r.current=true;try{let h=await executeImageCommand(t,x);h.ok?t.focus():window.alert(h.reason??n("imageInsert.errors.refused"));}finally{r.current=false;}},[t,n]),d=useCallback(async f=>{let b=f?.[0];if(!b)return;let x=await b.arrayBuffer();await s(new Uint8Array(x));},[s]),m=useCallback(async f=>{if(!f)return;let b=[...f.files].find(x=>x.type.startsWith("image/"));if(b){await d([b]);return}for(let x of f.items){if(x.kind!=="file"||!x.type.startsWith("image/"))continue;let T=x.getAsFile();if(!T)continue;let h=await T.arrayBuffer();await s(new Uint8Array(h));return}},[s,d]),p=useCallback(()=>{l&&o.current?.click();},[l]),g=useCallback(async f=>{let b=f.currentTarget;await d(b.files),b.value="";},[d]),u=useMemo(()=>({openFilePicker:p,insertFromFileList:d,insertFromDataTransfer:m,isEnabled:l,disabledReason:c,inputRef:o,onInputChange:g}),[p,d,m,l,c,g]);return jsxs(xl.Provider,{value:u,children:[jsx("input",{ref:o,type:"file",accept:G0,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:f=>f.stopPropagation()}),e]})}function ya({className:e,hidden:t,asChild:n,children:o}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=ha(),l=X();if(t)return null;let c=J("image.insert"),s=l(c?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":s,title:a??s,onMouseDown:B,onClick:r};return n?jsx(j,{...d,children:o}):jsx("button",{...d,children:o??re(c?.paths)})}ya.docxSlot="image.insert";var qn=Object.assign(ya,{docxSlot:"image.insert"});var lb=["nw","n","ne","e","se","s","sw","w"],Zd=40,qd=12;function sb(e){return `imageOverlay.handle.${e}`}function cb(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 db(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 ub(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 Cl({containerRef:e,portalRef:t,scrollPort:n}){let o=H(),{t:r}=N(),[i,a]=useState(null),[l,c]=useState(null),[s,d]=useState({left:0,top:0}),m=useRef(null);m.current=l;let p=useRef(null),g=useRef(null),u=useRef(null),f=useRef(null),b=useRef(null);useEffect(()=>{let P=e.current;if(!P)return;let R=E=>{let D=(E.target instanceof Element?E.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=D??null,D&&D===i?.id&&queueMicrotask(()=>u.current?.focus({preventScroll:true}));};return P.addEventListener("pointerdown",R,{capture:true}),()=>P.removeEventListener("pointerdown",R,{capture:true})},[e,i?.id]),useEffect(()=>{if(!o){a(null);return}let P=()=>{a(selectedDrawingOverlayTargetOf(o.surface));},R=()=>{queueMicrotask(P);};P();let E=[o.on("change",R),o.on("selectionChange",P)];return ()=>{for(let L of E)L();}},[o]);let x=useCallback(()=>{d(P=>{let R=overlayHostOrigin(e.current);return R.left===P.left&&R.top===P.top?P:R});},[e]);useEffect(()=>{x();let P=t.current;if(!P||typeof ResizeObserver!="function")return;let R=new ResizeObserver(x);R.observe(P);let E=e.current;return E&&R.observe(E),()=>R.disconnect()},[e,t,x,i]),useEffect(()=>{if(n){b.current=n;return}let P=e.current;if(!P||!o?.surface)return;let R=P.closest(".docx-editor__scroll-container");if(!R)return;let E=o.surface.overlayCoordinates();return b.current=createImageOverlayScrollPort(R,E.paintScale),()=>{b.current=null;}},[e,o,n]);let T=useCallback(()=>{c(null),p.current=null;let P=g.current;if(g.current=null,P)try{P.releasePointerCapture(P._lastPointerId??0);}catch{}},[]),h=useCallback((P,R,E,L,D,F,M)=>{if(!o?.surface)return;let _=o.surface.layout(),k=captureImageMutationPreconditions(o);if(k){p.current=Object.freeze({x:L,y:D}),g.current=F,F._lastPointerId=M;try{F.setPointerCapture(M);}catch{}c({session:Object.freeze({drawingNodeId:E.id,startBounds:Object.freeze({x:E.x,y:E.y,width:E.width,height:E.height}),startWidthEmu:E.widthEmu,startHeightEmu:E.heightEmu,startPosition:E.position,anchorFrameOrigin:E.anchorFrameOrigin,transform:E.transform,mode:P,handle:R,preconditions:k,layoutRevision:_.revision,packageRevision:o.surface.session.packageRevision(),kind:E.kind}),bounds:E,accumulatedScrollPt:0}),u.current?.focus({preventScroll:true});}},[o]),v=useCallback((P,R,E,L,D)=>{if(!o)return;if(isStaleImageInteractionCommit(o,P)){T();return}P.mode==="resize"?o.exec({type:"setImageProperties",widthEmu:R,heightEmu:E,...D?.mode==="simple"?{horizontalEmu:D.horizontalEmu,verticalEmu:D.verticalEmu}:{},...D?.mode==="frame"?{...D.horizontalEmu!==void 0?{horizontalEmu:D.horizontalEmu}:{},...D.verticalEmu!==void 0?{verticalEmu:D.verticalEmu}:{}}:{}}):P.mode==="move"&&D&&o.exec({type:"setImagePosition",...D}),T();},[T,o]),y=useCallback(P=>{if(!o)return;let R=m.current?.bounds??selectedDrawingOverlayTargetOf(o.surface);if(!R)return;if(m.current&&P.key==="Escape"){P.preventDefault(),P.stopPropagation(),T();return}if(m.current)return;let E=P.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(P.key==="Delete"||P.key==="Backspace"){P.preventDefault(),P.stopPropagation(),o.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(P.key))return;P.preventDefault(),P.stopPropagation();let L=P.key==="ArrowLeft"?-E:P.key==="ArrowRight"?E:0,D=P.key==="ArrowUp"?-E:P.key==="ArrowDown"?E:0;if(P.altKey){if(!R.canResize)return;let M=ub(L,D),_=computeImageResizeResult({handle:M,startWidthEmu:R.widthEmu,startHeightEmu:R.heightEmu,startBounds:{x:R.x,y:R.y,width:R.width,height:R.height},startPosition:R.position,anchorFrameOrigin:R.anchorFrameOrigin,deltaXPt:L,deltaYPt:D,transform:R.transform,preserveAspect:resizePreservesAspect(M,R.aspectLocked,P.shiftKey),kind:R.kind});o.exec({type:"setImageProperties",widthEmu:_.widthEmu,heightEmu:_.heightEmu,..._.position?.mode==="simple"?{horizontalEmu:_.position.horizontalEmu,verticalEmu:_.position.verticalEmu}:{},..._.position?.mode==="frame"?{..._.position.horizontalEmu!==void 0?{horizontalEmu:_.position.horizontalEmu}:{},..._.position.verticalEmu!==void 0?{verticalEmu:_.position.verticalEmu}:{}}:{}});return}if(R.kind!=="anchored"||!R.canMove||!R.position)return;let F=computeMovedImagePosition(R.position,L,D);o.exec({type:"setImagePosition",...F});},[T,o]);useEffect(()=>{if(!l||!o?.surface)return;let P=o.surface.overlayCoordinates(),R=L=>{let D=m.current,F=p.current;if(!D||!F)return;let M=cssPixelsToLayoutPoints(L.clientX-F.x,P.paintScale),_=cssPixelsToLayoutPoints(L.clientY-F.y,P.paintScale);if(D.session.mode==="move"){let I=0,ae=b.current,K=e.current?.closest(".docx-editor__scroll-container");if(ae&&K){let V=K.getBoundingClientRect();L.clientY>V.bottom-Zd?I=qd:L.clientY<V.top+Zd&&(I=-qd),I!==0&&(I=ae.scrollBy(I));}let $=D.accumulatedScrollPt+I;c({...D,accumulatedScrollPt:$,bounds:Object.freeze({...D.bounds,x:D.session.startBounds.x+M,y:D.session.startBounds.y+_+$})});return}if(!D.session.handle)return;let k=computeImageResizeResult({handle:D.session.handle,startWidthEmu:D.session.startWidthEmu,startHeightEmu:D.session.startHeightEmu,startBounds:D.session.startBounds,startPosition:D.session.startPosition,anchorFrameOrigin:D.session.anchorFrameOrigin,deltaXPt:M,deltaYPt:_,transform:D.session.transform,preserveAspect:resizePreservesAspect(D.session.handle,D.bounds.aspectLocked,L.shiftKey),kind:D.session.kind});c({...D,bounds:Object.freeze({...D.bounds,x:k.previewBounds.x,y:k.previewBounds.y,width:k.previewBounds.width,height:k.previewBounds.height,widthEmu:k.widthEmu,heightEmu:k.heightEmu})});},E=L=>{let D=m.current;if(D)if(L.type==="pointerup"){let F=cssPixelsToLayoutPoints(L.clientX-(p.current?.x??L.clientX),P.paintScale),M=cssPixelsToLayoutPoints(L.clientY-(p.current?.y??L.clientY),P.paintScale),_=finalizeImageOverlayInteraction({session:D.session,deltaXPt:F,deltaYPt:M,accumulatedScrollPt:D.accumulatedScrollPt,aspectLocked:D.bounds.aspectLocked,shiftKey:L.shiftKey,anchorFrameOrigin:D.session.anchorFrameOrigin});v(D.session,_.widthEmu,_.heightEmu,_.previewBounds,_.position);}else T();};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E);}},[T,v,e,o,l]),useEffect(()=>{!i||f.current!==i.id||(f.current=null,u.current?.focus({preventScroll:true}));},[i]);let S=l?.bounds??i,w=useMemo(()=>{if(!o?.surface||!S)return null;let P=o.surface.publishedLayout(),R=o.surface.overlayCoordinates(),E=overlayFrameToSheetCssPixels(P,{pageIndex:S.pageIndex,x:S.x,y:S.y,width:S.width,height:S.height},R),L={left:E.left+s.left,top:E.top+s.top,width:E.width,height:E.height},D=S.canResize,F=S.kind==="anchored"&&S.canMove;return jsxs("div",{ref:u,className:"docx-image-selection-overlay","data-drawing-node-id":S.id,tabIndex:0,onKeyDown:y,children:[jsx("div",{className:`docx-image-selection-overlay__frame${F?" docx-editor-one-surface__overlay-control":""}`,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${L.left}px`,top:`${L.top}px`,width:`${L.width}px`,height:`${L.height}px`,cursor:F?"move":"default"},onPointerDown:M=>{B(M),!(!F||!S.position)&&M.button===0&&(M.preventDefault(),M.stopPropagation(),h("move",null,S,M.clientX,M.clientY,M.currentTarget,M.pointerId));}}),D?lb.map(M=>{let _=db(M);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(sb(M)),tabIndex:0,style:{left:`calc(${L.left}px + ${L.width}px * ${parseFloat(_.x)/100} - 5px)`,top:`calc(${L.top}px + ${L.height}px * ${parseFloat(_.y)/100} - 5px)`,cursor:cb(M)},onPointerDown:k=>{B(k),k.button===0&&(k.preventDefault(),k.stopPropagation(),h("resize",M,S,k.clientX,k.clientY,k.currentTarget,k.pointerId));}},M)}):null]})},[S,h,o,y,s.left,s.top,r]);return !w||!t.current?null:createPortal(w,t.current)}function El(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Sa({className:e}){let t=H(),n=Sl(),o=useRef(null),r=useRef(null);useLayoutEffect(()=>{let c=o.current;if(!(!t||!c))return t.attach(c),()=>{t.detach();}},[t]);let i=useCallback(c=>{if(!n?.isEnabled)return;let s=c.clipboardData;s&&El(s)&&(c.preventDefault(),n.insertFromDataTransfer(s));},[n]),a=useCallback(c=>{!n?.isEnabled||!El(c.dataTransfer)||c.preventDefault();},[n]),l=useCallback(c=>{n?.isEnabled&&El(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:i,onDragOver:a,onDrop:l}),t?jsx(Cl,{containerRef:o,portalRef:r}):null]})}function Pe(e){return e/1440*96}function Ta(e){return e/96*1440}function Ye(e){return `${Math.round(e*100)/100}px`}function wl(e){return e/2}var gb=e=>e.isLoading||e.isOpening===true,bb=e=>({width:Pe(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:Pe(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),hb=(e,t)=>e.width===t.width&&e.height===t.height;function kl({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function vb({when:e=false,overlay:t=false,className:n,style:o,children:r}){let i=O(gb),a=O(bb,hb),{t:l}=N();if(!e&&!i)return null;let c=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${n?` ${n}`:""}`;return jsx("div",{className:c,style:o,role:"status","aria-live":"polite",children:r??jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:a.width,height:a.height},children:jsx("div",{className:"docx-pages",children:jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxs("div",{className:"docx-editor__loading-page-status",children:[jsx(kl,{}),jsx("span",{className:"docx-editor-sr-only",children:l("loading.label")})]})})})})})}var Ca=Object.assign(vb,{Spinner:kl});function Vd(){let e=new Set,t=new Map,n=new Map,o=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let p=Object.create(null),g=[...t].sort((u,f)=>(n.get(u[0])??0)-(n.get(f[0])??0));for(let[,{author:u,style:f}]of g)p[u]=f;return {authors:p,others:e.size>0?"kind":"author"}}let l=null,c=false;function s(p){if(p===void 0)return "none";if(typeof p=="string")return p;let g=Object.entries(p.authors).map(([u,f])=>`${u}\0${JSON.stringify(f)}`).sort();return `${p.others??"kind"}${g.join("")}`}function d(){if(!r)return;let p=a(),g=s(p);if(g!==l){if(p===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(p),i=true,l=g;}}function m(){!r||c||(c=true,queueMicrotask(()=>{c=false,d();}));}return {registerScheme(p){e.add(p),m();},register(p,g,u){n.has(p)||n.set(p,o++),t.set(p,{author:g,style:u}),m();},unregister(p){(e.delete(p)||t.delete(p))&&m();},connect(p){r=p;let g=a();i=p!==null&&g!==void 0,l=p===null?null:s(g),m();},current:a}}var Kn=createContext(null);function Gd(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function Rl(){let e=useContext(Kn),t=Gd();return useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function Ml(e){let{author:t,color:n,background:o,spanClassName:r,avatarUrl:i}=e,a=useContext(Kn),l=Gd();return useEffect(()=>{if(a)return a.register(l,t,{...n!==void 0?{color:n}:{},...o!==void 0?{background:o}:{},...r!==void 0?{spanClassName:r}:{},...i!==void 0?{avatarUrl:i}:{}}),()=>a.unregister(l)},[a,l,t,n,o,r,i]),null}function $n(e){return e.paragraphId===""}var ho=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),wb=e=>e;function kb(){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,a=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(a))return {left:a.left,top:a.bottom}}return null}var Vn=createContext(null);function Il(){let e=useContext(Vn),t=Ea(e===null);return e??t}function Ea(e=true){let t=H(),[n,o]=useState(ho),r=useRef(null),i=useRef(n);i.current=n;let a=O(wb),l=t?t.can({type:"insertText",text:""}).ok:false,c=useCallback(()=>{let h=r.current;h&&(h.editor.releaseSelection(h.pin),r.current=null);},[]),s=useCallback((h,v)=>{c(),o({mode:h?"reading":"editing",link:h??null,anchor:v??null,text:h?.text??"",url:h?h.kind==="internal"?`#${h.anchor??""}`:h.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c]),d=useCallback(()=>{c(),o(ho);},[c]);useEffect(()=>c,[c]);let m=useCallback(()=>{let h=kb();c();let v=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(v&&$n(v)){s(v,h);return}if(v){o({mode:"editing",link:v,anchor:h,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 y=t?.query({type:"selectedText"})??"",S=t?.retainSelection()??null;t&&S&&(r.current={editor:t,pin:S}),o({mode:"editing",link:null,anchor:h,text:y,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:h=>s(h.link,{left:h.rect.left,top:h.rect.bottom}),onRequest:m})},[t,e,s,m]),useEffect(()=>{let h=i.current;if(h.mode!=="reading"||!h.link)return;let v=$n(h.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;v&&v.id===h.link.id||o(ho);},[a,t]),useEffect(()=>{let h=i.current;if(h.mode!=="editing"||h.link)return;let v=t?.surface;!v||v.retainedSelection()||o(ho);},[a,t]);let p=useCallback(async()=>{let h=i.current.link?.href;if(!h)return false;try{await navigator.clipboard.writeText(h);}catch{return false}return o(v=>({...v,copied:true})),true},[]),g=useCallback(()=>{o(h=>({...h,mode:"editing",copied:false,error:false}));},[]),u=useCallback(h=>{o(v=>({...v,text:h,copied:false,error:false}));},[]),f=useCallback(h=>{o(v=>({...v,url:h,copied:false,error:false}));},[]),b=useCallback(()=>{let h=i.current,v=t?.surface?.hyperlinks;if(!v)return false;let y=h.url.trim();if(y.length===0)return o(P=>({...P,error:true})),false;let S=y.startsWith("#");return v.applyHyperlink({...S?{anchor:y.slice(1)}:{url:y},...h.text.trim().length>0?{text:h.text}:{}})?(d(),true):(o(P=>({...P,error:true})),false)},[t,d]),x=useCallback(()=>{let h=t?.surface?.hyperlinks,v=i.current.link;if(!h)return false;let y=h.removeHyperlink(v?.id);return y&&d(),y},[t,d]),T=useCallback(()=>{let h=t?.surface?.navigation,v=i.current.link;if(!h||!v)return false;if(v.kind==="internal"){let S=v.anchor?h.goToBookmark(v.anchor):false;return S&&o(ho),S}let y=h.openExternal(v.href);return y&&o(ho),y},[t]);return useMemo(()=>({state:n.mode==="closed"?ho:{...n,canEdit:l},open:s,openAtCaret:m,close:d,copy:p,beginEdit:g,setText:u,setUrl:f,commitEdit:b,unlink:x,openTarget:T}),[n,l,s,m,d,p,g,u,f,b,x,T])}var Xe={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function _b(e){return e==="sdtLocked"||e==="sdtContentLocked"}function Db(e){return e==="contentLocked"||e==="sdtContentLocked"}function Dl(e,t){return !e.ok&&e.code===t}function Et(){let e=useContext(Nl),t=wa();return e??t}function wa(){let e=H(),[t,n]=useState(false),[o,r]=useState(false),[i,a]=useState(false),l=O(w=>w),c=e?.surface??null,s=c?.contentControls;useEffect(()=>{r(s?.showAll()??c?.state().contentControls.showAll??false),a(s?.formFill()??c?.state().contentControls.formFill??false);},[l,s,c]);let d=useMemo(()=>{if(!e)return null;let w=s?.atCaret()??null;if(w){let k=s?.disabledReason(w.id,"edit")??null,I=s?.disabledReason(w.id,"remove")??null;return {id:w.id,tag:w.tag??null,alias:w.alias??null,controlType:w.controlType,locked:Db(w.effectiveLock)||k==="locked",removalLocked:_b(w.effectiveLock)||I==="locked",placeholder:w.placeholder,bound:w.bound||k==="bound",effectiveLock:w.effectiveLock}}let P=e.query({type:"contentControlAt"});if(!P)return null;let R=s?.disabledReason(P.id,"edit")??null,E=s?.disabledReason(P.id,"remove")??null,L=e.can({type:"setContentControlValue",value:""}),D=e.can({type:"removeContentControl"}),F=P.locked===true||R==="locked"||Dl(L,"locked"),M=R==="bound"||Dl(L,"bound"),_=E==="locked"||Dl(D,"locked");return {id:P.id,tag:P.tag??null,alias:P.alias??null,controlType:P.controlType,locked:F,removalLocked:_,placeholder:false,bound:M,effectiveLock:null}},[e,l,s]),m=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),p=useCallback(w=>{s?.setShowAll(w),r(w);},[s]),g=useCallback(w=>{s?.setFormFill(w),a(w);},[s]),u=useCallback(()=>p(!o),[p,o]),f=useCallback(()=>g(!i),[g,i]),b=useCallback(()=>n(true),[]),x=useCallback(()=>n(false),[]),T=useCallback(()=>n(w=>!w),[]),h=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let P=s.disabledReason(d.id,"edit");return P==="locked"?"the content control is locked":P==="bound"?"the content control is bound to external data":P==="notFound"?"the content control was not found":P}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 w=e.can({type:"setContentControlValue",value:""});return w.ok?null:w.reason},[d,s,e]),v=useMemo(()=>{if(!d)return "no content control at the current selection";if(s){let P=s.disabledReason(d.id,"remove");return P==="locked"?"the content control is locked":P==="notFound"?"the content control was not found":P}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let w=e.can({type:"removeContentControl"});return w.ok?null:w.reason},[d,s,e]),y=useCallback(w=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(s&&d){let P=s.disabledReason(d.id,"edit");if(P)return {ok:false,code:P==="bound"?"bound":P==="locked"?"locked":"notFound",reason:P==="bound"?"the content control is bound to external data":P==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:w})},[e,s,d]),S=useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(s){let w=d?.id;if(!w)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let P=s.disabledReason(w,"remove");return P?{ok:false,code:P==="locked"?"locked":"notFound",reason:P==="locked"?"the content control is locked":"the content control was not found"}:s.remove(w)?{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:m,showAll:o,formFill:i,inspectorOpen:t,canSetValue:h===null&&d!==null,canRemove:v===null&&d!==null,setValueDisabledReason:h,removeDisabledReason:v,setShowAll:p,toggleShowAll:u,setFormFill:g,toggleFormFill:f,openInspector:b,closeInspector:x,toggleInspector:T,remove:S,setValue:y}),[d,m,o,i,t,h,v,p,u,g,f,b,x,T,S,y])}var Nl=createContext(null);function Yd(){let e=0,t=0,n=null,o=new Set,r=new Set,i=new Set,a=l=>{for(let c of [...l])c();};return {getShift:()=>e,setShift(l){let c=Math.max(0,Math.round(l));c!==e&&(e=c,a(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,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>n,setViewport(l){l!==n&&(n=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Fl=createContext(null);function yo(){return useContext(Fl)}var Xd=()=>0,Al=()=>()=>{};function xo(){let e=yo(),t=useCallback(o=>e?e.subscribeShift(o):Al(),[e]),n=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,n,Xd)}function Jd(){let e=yo(),t=useCallback(o=>e?e.subscribeReservation(o):Al(),[e]),n=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,n,Xd)}function Ft(){let e=yo(),t=useCallback(r=>e?e.subscribeViewport(r):Al(),[e]),n=useCallback(()=>e?e.getViewport():null,[e]),o=useCallback(()=>null,[]);return useSyncExternalStore(t,n,o)}function Bb(e,t){if(e===t)return true;let n=resolveZoomMode(e),o=resolveZoomMode(t);return n!==null&&o!==null&&sameZoomMode(n,o)}function Zb(e){let t=useRef(e);t.current=e;let[n,o]=useState(null),{onReady:r,onChange:i,onFontError:a,...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:jn,rootProps:l,rootListeners:c,editorRef:n}}function jn(e){let{document:t,fonts:n,zoom:o,zoomMode:r,tableInteractionLabel:i,imageDecodePort:a,children:l}=e,{t:c}=N(),s=useCallback((y,S)=>c(y,S),[c]),d=useRef(e);d.current=e;let[m,p]=useState(null),g=useRef(null);g.current??=Vd();let u=g.current;useEffect(()=>{let y=d.current,S=y.translate??s,w=u.current(),P=createDocxEditor({...y.document!==void 0?{document:y.document}:{},...y.fonts?{fonts:y.fonts}:{},...y.author!==void 0?{author:y.author}:{},...y.locale!==void 0?{locale:y.locale}:{},translate:S,...y.mode!==void 0?{mode:y.mode}:{},...w!==void 0?{revisionStyles:w}:{},...y.modules!==void 0?{modules:y.modules}:{},...y.zoom!==void 0?{zoom:y.zoom}:{},...y.zoomMode!==void 0?{zoomMode:y.zoomMode}:{},...y.tableInteractionLabel?{tableInteractionLabel:y.tableInteractionLabel}:{},...y.imageDecodePort?{imageDecodePort:y.imageDecodePort}:{},onFontError:E=>d.current.onFontError?.(E)}),R=P.on("change",E=>d.current.onChange?.(E));return p(P),()=>{R(),P.destroy(),p(E=>E===P?null:E);}},[t,n,s,a,u]),useEffect(()=>{if(!m)return;if(!m.snapshot().isOpening){d.current.onReady?.(m);return}let y=m.on("change",()=>{y(),d.current.onReady?.(m);});return y},[m]);let f=useRef({editor:null,zoom:void 0,mode:void 0});useEffect(()=>{if(!m)return;f.current.editor!==m&&(f.current={editor:m,zoom:void 0,mode:void 0});let S=false;o!==void 0&&o!==f.current.zoom&&(f.current.zoom=o,m.setZoom(o),S=true);let w=f.current.mode,P=r!==void 0&&(w===void 0||!Bb(w,r)),R=r===void 0?null:resolveZoomMode(r),E=S&&r!==void 0&&R!==null&&R.type==="fit";(P||E)&&(f.current.mode=r,m.setZoomMode(r));},[m,o,r]),useEffect(()=>{m&&m.setTableInteractionLabel(i??defaultTableLabel);},[m,i]);let[b,x]=useState(0),T=useRef([]),h=useMemo(()=>({mounted:b,register:()=>(x(y=>y+1),()=>x(y=>Math.max(0,y-1))),registerCommentDraft:y=>(T.current.push(y),()=>{let S=T.current.indexOf(y);S!==-1&&T.current.splice(S,1);}),requestCommentDraft:()=>{let y=T.current.at(-1);return y?(y(),true):false}}),[b]),v=useMemo(Yd,[]);return useEffect(()=>(u.connect(m),()=>u.connect(null)),[u,m]),jsx(ft.Provider,{value:h,children:jsx(cl.Provider,{value:m,children:jsx(Fl.Provider,{value:v,children:jsx(Kn.Provider,{value:u,children:jsx(qb,{children:jsx(zb,{children:jsx(va,{children:l})})})})})})})}function qb({children:e}){let t=Ea(true);return jsx(Vn.Provider,{value:t,children:e})}function zb({children:e}){let t=wa();return jsx(Nl.Provider,{value:t,children:e})}var ql=316,Zl=44,Wb=24,ka={inlineStart:0,inlineEnd:ql},Qd={inlineStart:Zl,inlineEnd:Zl},Gb={inlineStart:0,inlineEnd:0};function ou({open:e,viewportWidth:t,pageWidthPx:n,inlineStartReservation:o=0,docked:r=false}){if(!e)return Qd;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)return ka;let i=Number.isFinite(o)&&o>0?o:0;return t-i-n-2*Wb>=ql?ka:Qd}var jb=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}},Yb=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function nu(){let e=Ft(),[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 on(){let e=useContext(ft),{pageSetup:t,reviewPaneOpen:n,entitledZoom:o}=O(jb,Yb),r=Ft(),i=Jd(),a=useRef(null);t&&(a.current=t.pageWidthTwips);let l=t?.pageWidthTwips??a.current,c=(e?.mounted??0)>0,s=useCallback(p=>c?ou({open:n,viewportWidth:p??0,pageWidthPx:l===null||o===null?0:Pe(l)*o,inlineStartReservation:i,docked:o===null}):Gb,[c,n,l,o,i]),[d,m]=useState(()=>s(r?r.clientWidth:null));return useEffect(()=>{let p=()=>m(s(r?r.clientWidth:null));if(p(),!r||typeof ResizeObserver>"u")return;let g=new ResizeObserver(p);return g.observe(r),()=>g.disconnect()},[r,s]),d}var Ra=[.25,.5,.75,1,1.25,1.5,2];function Yn(e,t){return t==="in"?Ra.find(o=>o>e+.001)??null:[...Ra].reverse().find(o=>o<e-.001)??null}function ru(e,t){return e==="0"?1:e==="+"||e==="="?Yn(t,"in")??t:e==="-"?Yn(t,"out")??t:null}var So=createContext(false);function ot(){return useContext(So)?"":"docx-editor "}var eh=e=>e.reviewPaneOpen??true,th=e=>e.zoomMode?.type==="fit";function Ma({className:e,style:t,children:n}){let o=ot(),r=H(),i=O(eh),a=on(),l=O(th),s=(useContext(ft)?.mounted??0)>0,d=yo(),m=xo(),p=useCallback(u=>d?.setViewport(u),[d]),g=useCallback(u=>{if(!r||!(u.metaKey||u.ctrlKey)||u.altKey)return;let f=u.target;if(f instanceof Element&&f.closest('input, textarea, select, [role="dialog"]'))return;let b=ru(u.key,r.getZoom());b!==null&&(u.preventDefault(),r.setZoom(b));},[r]);return jsx("div",{ref:p,"data-testid":"docx-editor-scroll",onKeyDownCapture:g,...s?{"data-review-pane":i?"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":`${m}px`,...s?{"--docx-review-gutter":`${a.inlineEnd}px`,"--docx-review-gutter-start":`${a.inlineStart}px`}:{}},children:jsx(So.Provider,{value:true,children:n})})}var nh=LOADING_SNAPSHOT;function lu({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)??nh}),[t]);}var ch=e=>e.editingMode??"editing",dh=e=>e.isLoading||e.isOpening===true,Kl=[{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"}],uh="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function _a({className:e,hidden:t}){let n=H(),o=O(ch),r=O(dh),i=X(),{t:a}=N(),[l,c]=useState(false),s=useRef(null),d=useRef(null),m=useRef(null);useEffect(()=>{if(!l)return;let T=m.current?.querySelectorAll('[role="menuitemradio"]');(m.current?.querySelector('[aria-checked="true"]')??T?.[0]??void 0)?.focus();},[l]);let p=useCallback(T=>{let h=[...m.current?.querySelectorAll('[role="menuitemradio"]')??[]],v=h.indexOf(document.activeElement),y=S=>{T.preventDefault(),h[(S+h.length)%h.length]?.focus();};T.key==="ArrowDown"?y(v+1):T.key==="ArrowUp"?y(v-1):T.key==="Home"?y(0):T.key==="End"&&y(h.length-1);},[]);useEffect(()=>{if(!l)return;let T=v=>{let y=s.current;y&&v.target instanceof Node&&y.contains(v.target)||c(false);},h=v=>{v.key==="Escape"&&(v.preventDefault(),c(false));};return document.addEventListener("mousedown",T,true),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",T,true),document.removeEventListener("keydown",h);}},[l]);let g=useCallback(T=>{c(false),runToolbarCommand(n,"review.editingMode",T),n?.focus();},[n]),u=toolbarCommandState(n,"review.editingMode"),f=localizeDisabledReason(u.disabledReason,a),b=useMemo(()=>Kl.find(T=>T.mode===o)??Kl[0],[o]);if(t)return null;let x=J("review.editingMode");return jsxs("div",{ref:s,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":o,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:r||!u.enabled,...f?{title:f}:{},onMouseDown:B,onClick:()=>c(T=>!T),children:[$l(b.path),jsx("span",{className:"docx-toolbar__picker-value",children:i(b.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:p,children:Kl.map(T=>jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T.mode===o,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${T.mode}`,onMouseDown:B,onClick:()=>g(T.mode),children:[$l(T.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:i(T.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:i(T.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:T.mode===o?$l(uh):null})]},T.mode))}):null]})}_a.docxSlot="review.editingMode";function $l(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 nn(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 Na({entries:e,children:t,preset:n,keyOfEntry:o,keyOfChild:r,renderEntry:i}){if(!n)return t;let a=new Map,l=[];for(let m of Children.toArray(t)){let p=r(m);p?a.set(p,m):l.push(m);}let c=e.map((m,p)=>{let g=o(m,p),u=a.get(g);return u?jsx(Fragment$1,{children:u},g):jsx(Fragment$1,{children:i(m,p)},g)}),s=new Set(e.map(o)),d=[...a.entries()].filter(([m])=>!s.has(m)).map(([m,p])=>jsx(Fragment$1,{children:p},m));return jsxs(Fragment,{children:[c,d,l]})}var hh={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},vh=e=>{let t=e.formatting??null;if(!t)return null;let n=t.indent,o=t.paragraphFlags??hh;return {alignment:t.alignment==="both"?"justify":t.alignment??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:n&&!n.mixed.left?n.left:null,indentRightTwips:n&&!n.mixed.right?n.right:null,indentFirstLineTwips:n&&!n.mixed.firstLine?n.firstLine:null,contextualSpacing:o.contextualSpacing,keepNext:o.keepNext,keepLines:o.keepLines,widowControl:o.widowControl,pageBreakBefore:o.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!n,disagrees:{alignment:t.disagrees?.alignment??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:n?.mixed.left??false,indentRight:n?.mixed.right??false,indentFirstLine:n?.mixed.firstLine??false}}},yh=["alignment","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],xh=(e,t)=>yh.every(n=>e.disagrees[n]===t.disagrees[n]),Sh=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value&&e.indentLeftTwips===t.indentLeftTwips&&e.indentRightTwips===t.indentRightTwips&&e.indentFirstLineTwips===t.indentFirstLineTwips&&e.contextualSpacing===t.contextualSpacing&&e.keepNext===t.keepNext&&e.keepLines===t.keepLines&&e.widowControl===t.widowControl&&e.pageBreakBefore===t.pageBreakBefore&&xh(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((n,o)=>n.positionTwips===t.tabStops?.[o]?.positionTwips&&n.alignment===t.tabStops?.[o]?.alignment&&(n.leader??"none")===(t.tabStops?.[o]?.leader??"none")),Th=e=>e.editable;function Ul(){let e=H(),t=O(vh,Sh),n=O(Th),o=useMemo(()=>n&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,n]),r=useCallback(i=>{if(!e)return false;let a={type:"setParagraphFormat",...i};return e.can(a).ok?e.exec(a).ok:false},[e]);return {format:t,isEnabled:o,apply:r}}var Xn=e=>Math.round(e/1440*100)/100,Wl=e=>Xn(e).toLocaleString(void 0,{maximumFractionDigits:2}),La=e=>Math.round(e*1440),uu={left:"dialogs.paragraph.tabAlignLeft",center:"dialogs.paragraph.tabAlignCenter",right:"dialogs.paragraph.tabAlignRight",decimal:"dialogs.paragraph.tabAlignDecimal",bar:"dialogs.paragraph.tabAlignBar"},Ch=e=>e===null||e===0?"none":e<0?"hanging":"firstLine",Ph=(e,t)=>e==="none"?0:e==="hanging"?-Math.abs(t):Math.abs(t);function pu(e){let t=e.indentFirstLineTwips;return {alignment:e.alignment??"left",indentLeft:e.indentLeftTwips??0,indentRight:e.indentRightTwips??0,special:Ch(t),specialBy:Math.abs(t??0),spaceBefore:e.spaceBeforePt??0,spaceAfter:e.spaceAfterPt??0,lineRule:e.lineSpacing?.rule??"multiple",lineValue:e.lineSpacing?.value??1.08,contextualSpacing:e.contextualSpacing===true,keepNext:e.keepNext===true,keepLines:e.keepLines===true,widowControl:e.widowControl!==false,pageBreakBefore:e.pageBreakBefore===true,tabStops:e.tabStops??[],clearedAllTabStops:false}}var Fa={contextualSpacing:false,keepNext:false,keepLines:false,widowControl:false,pageBreakBefore:false,tabStops:false,alignment:false,indentLeft:false,indentRight:false,special:false,spaceBefore:false,spaceAfter:false,lineSpacing:false};function mu(e){return {contextualSpacing:e.contextualSpacing===null,keepNext:e.keepNext===null,keepLines:e.keepLines===null,widowControl:e.widowControl===null,pageBreakBefore:e.pageBreakBefore===null,tabStops:e.disagrees.tabStops,alignment:e.disagrees.alignment,indentLeft:e.disagrees.indentLeft||e.indentUnknown,indentRight:e.disagrees.indentRight||e.indentUnknown,special:e.disagrees.indentFirstLine||e.indentUnknown,spaceBefore:e.disagrees.spaceBeforePt,spaceAfter:e.disagrees.spaceAfterPt,lineSpacing:e.disagrees.lineSpacing}}function Eh(e,t){return e===t?true:e.length!==t.length?false:e.every((n,o)=>{let r=t[o];return r!==void 0&&n.positionTwips===r.positionTwips&&n.alignment===r.alignment&&(n.leader??"none")===(r.leader??"none")})}function fu(e,t,n=Fa,o=n){let r={},i=false,a=(c,s)=>{r[c]=s,i=true;},l=c=>n[c]&&!o[c];return (e.alignment!==t.alignment||l("alignment"))&&a("alignment",t.alignment),(e.indentLeft!==t.indentLeft||l("indentLeft"))&&a("indentLeftTwips",t.indentLeft),(e.indentRight!==t.indentRight||l("indentRight"))&&a("indentRightTwips",t.indentRight),(e.special!==t.special||e.specialBy!==t.specialBy||l("special"))&&a("indentFirstLineTwips",Ph(t.special,t.specialBy)),(e.spaceBefore!==t.spaceBefore||l("spaceBefore"))&&a("spaceBeforePt",t.spaceBefore),(e.spaceAfter!==t.spaceAfter||l("spaceAfter"))&&a("spaceAfterPt",t.spaceAfter),!o.lineSpacing&&(e.lineRule!==t.lineRule||e.lineValue!==t.lineValue||l("lineSpacing"))&&a("lineSpacing",{rule:t.lineRule,value:t.lineValue}),(e.contextualSpacing!==t.contextualSpacing||l("contextualSpacing"))&&a("contextualSpacing",t.contextualSpacing),(e.keepNext!==t.keepNext||l("keepNext"))&&a("keepNext",t.keepNext),(e.keepLines!==t.keepLines||l("keepLines"))&&a("keepLines",t.keepLines),(e.widowControl!==t.widowControl||l("widowControl"))&&a("widowControl",t.widowControl),(e.pageBreakBefore!==t.pageBreakBefore||l("pageBreakBefore"))&&a("pageBreakBefore",t.pageBreakBefore),(!Eh(e.tabStops,t.tabStops)||l("tabStops")&&t.clearedAllTabStops)&&a("tabStops",t.tabStops),i?r:null}function gu(e,t){return [...e.filter(o=>o.positionTwips!==t.positionTwips),t].sort((o,r)=>o.positionTwips-r.positionTwips)}function bu(e,t){if(t.key!=="Tab")return false;let n=[...e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')].filter(a=>!a.hasAttribute("disabled")&&a.tabIndex!==-1);if(n.length===0)return false;let o=n[0],r=n[n.length-1],i=e.ownerDocument.activeElement;return t.shiftKey&&(i===o||i===e)?(r.focus(),true):!t.shiftKey&&i===r?(o.focus(),true):false}var Rh={marginRight:"auto",fontSize:"12px",color:"var(--doc-danger)"},Mh={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},Ih={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:620,maxWidth:720,width:"100%",margin:20,maxHeight:"90vh",display:"flex",flexDirection:"column",minHeight:0},_h={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",flexShrink:0,fontSize:16,fontWeight:600,color:"var(--doc-text)"},Dh={padding:"16px 20px",overflowY:"auto",minHeight:0},Nh={display:"grid",gridTemplateColumns:"1fr 1fr",gap:28},yu={display:"flex",flexDirection:"column",gap:14,minWidth:0},Jn={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},it={display:"flex",alignItems:"center",gap:12},bt={width:92,fontSize:13,color:"var(--doc-text-muted)"},wt={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Qn={fontSize:11,color:"var(--doc-text-muted)",width:20},Lh={display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--doc-text)"},Fh={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,flexShrink:0},er={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"};function To({open:e,onClose:t,className:n}){let{t:o}=N(),{format:r,isEnabled:i,apply:a}=Ul(),[l,c]=useState("left"),[s,d]=useState(0),[m,p]=useState(0),[g,u]=useState("none"),[f,b]=useState(0),[x,T]=useState(0),[h,v]=useState(0),[y,S]=useState("multiple"),[w,P]=useState(1.08),[R,E]=useState(false),[L,D]=useState(false),[F,M]=useState(false),[_,k]=useState(true),[I,ae]=useState(false),[K,$]=useState([]),[V,oe]=useState(false),[ne,be]=useState(0),[he,W]=useState("left"),[Z,we]=useState("none"),[ce,de]=useState(Fa),[Ve,uo]=useState(false),mt=q=>o(Ve&&(q==="indentLeft"||q==="indentRight"||q==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),po=useRef(Fa),Me=useId(),[sl,An]=useState(false),Pt=useRef(null),Hn=useRef(false),Yo=useRef(null);useEffect(()=>{if(!e){Hn.current=false;return}if(Hn.current||r===null)return;let q=pu(r);c(q.alignment),d(q.indentLeft),p(q.indentRight),u(q.special),b(q.specialBy),T(q.spaceBefore),v(q.spaceAfter),S(q.lineRule),P(q.lineValue),E(q.contextualSpacing),D(q.keepNext),M(q.keepLines),k(q.widowControl),ae(q.pageBreakBefore),$(q.tabStops),oe(false);let ve=mu(r);de(ve),uo(r.indentUnknown),be(0),W("left"),we("none"),po.current=ve,An(false),Yo.current=q,Hn.current=true;},[e,r]),useEffect(()=>{e&&Pt.current?.focus();},[e]);let pe=useCallback(()=>{let q=Yo.current,ve=q===null?null:fu(q,{alignment:l,indentLeft:s,indentRight:m,special:g,specialBy:f,spaceBefore:x,spaceAfter:h,lineRule:y,lineValue:w,contextualSpacing:R,keepNext:L,keepLines:F,widowControl:_,pageBreakBefore:I,tabStops:K,clearedAllTabStops:V},po.current,ce);if(ve===null){t();return}if(a(ve)){An(false),t();return}An(true);},[a,t,ce,V,l,s,m,g,f,x,h,y,w,R,L,F,_,I,K]),me=useCallback(()=>{let q=Math.round(ne);return q<=0?false:(de(ve=>({...ve,tabStops:false})),$(gu(K,{positionTwips:q,alignment:he,...Z!=="none"?{leader:Z}:{}})),be(0),W("left"),we("none"),true)},[K,ne,he,Z]);if(!e)return null;let at=q=>de(ve=>({...ve,[q]:false})),On=(q,ve,Kt,Ue)=>jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-${q}`,children:o(`dialogs.paragraph.${q}`)}),jsx("input",{id:`${Me}-${q}`,type:"number",style:wt,min:0,step:.1,value:ce[Ue]?"":Xn(ve),placeholder:ce[Ue]?mt(Ue):void 0,onChange:Bn=>{at(Ue),Kt(La(Number(Bn.target.value)||0));},"aria-label":o(`dialogs.paragraph.${q}`)}),jsx("span",{style:Qn,children:o("dialogs.paragraph.unitInches")})]}),pa=(q,ve,Kt,Ue)=>jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-${q}`,children:o(`dialogs.paragraph.${q}`)}),jsx("input",{id:`${Me}-${q}`,type:"number",style:wt,min:0,step:1,value:ce[Ue]?"":ve,placeholder:ce[Ue]?mt(Ue):void 0,onChange:Bn=>{at(Ue),Kt(Math.max(0,Number(Bn.target.value)||0));},"aria-label":o(`dialogs.paragraph.${q}`)}),jsx("span",{style:Qn,children:o("dialogs.paragraph.unitPoints")})]}),mo=(q,ve,Kt)=>jsxs("label",{style:Lh,children:[jsx("input",{type:"checkbox",checked:ve,ref:Ue=>{Ue&&(Ue.indeterminate=ce[q]);},onChange:Ue=>{de(Bn=>({...Bn,[q]:false})),Kt(Ue.target.checked);}}),o(`dialogs.paragraph.${q}`)]}),bd=`docx-editor${document.querySelector(".docx-editor")?.classList.contains("dark")?" dark":""}`;return createPortal(jsx("div",{className:bd,style:{display:"contents"},children:jsx("div",{className:n,style:Mh,onClick:t,onKeyDown:q=>{q.key==="Escape"&&t(),Pt.current&&bu(Pt.current,q.nativeEvent)&&q.preventDefault();let ve=q.target instanceof HTMLButtonElement||q.target instanceof HTMLSelectElement;if(q.key==="Enter"&&!ve){let Kt=q.target;if(Kt instanceof HTMLElement&&Kt.dataset.docxTabEntry!==void 0){me();return}i&&pe();}},children:jsxs("div",{ref:Pt,role:"dialog","aria-modal":"true","aria-label":o("dialogs.paragraph.title"),tabIndex:-1,style:Ih,onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),children:[jsx("div",{style:_h,children:o("dialogs.paragraph.title")}),jsx("div",{style:Dh,children:jsxs("div",{style:Nh,children:[jsxs("div",{style:yu,children:[jsx("div",{style:Jn,children:o("dialogs.paragraph.general")}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-alignment`,children:o("dialogs.paragraph.alignment")}),jsxs("select",{id:`${Me}-alignment`,style:wt,value:ce.alignment?"":l,onChange:q=>{at("alignment"),c(q.target.value);},"aria-label":o("dialogs.paragraph.alignment"),children:[ce.alignment?jsx("option",{value:"",children:o("dialogs.paragraph.mixed")}):null,jsx("option",{value:"left",children:o("dialogs.paragraph.alignLeft")}),jsx("option",{value:"center",children:o("dialogs.paragraph.alignCenter")}),jsx("option",{value:"right",children:o("dialogs.paragraph.alignRight")}),jsx("option",{value:"justify",children:o("dialogs.paragraph.alignJustify")})]})]}),jsx("div",{style:Jn,children:o("dialogs.paragraph.indentation")}),On("beforeText",s,d,"indentLeft"),On("afterText",m,p,"indentRight"),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-special`,children:o("dialogs.paragraph.special")}),jsxs("select",{id:`${Me}-special`,style:wt,value:ce.special?"":g,onChange:q=>{at("special"),u(q.target.value);},"aria-label":o("dialogs.paragraph.special"),children:[ce.special?jsx("option",{value:"",children:mt("special")}):null,jsx("option",{value:"none",children:o("dialogs.paragraph.specialNone")}),jsx("option",{value:"firstLine",children:o("dialogs.paragraph.specialFirstLine")}),jsx("option",{value:"hanging",children:o("dialogs.paragraph.specialHanging")})]})]}),g!=="none"?jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-by`,children:o("dialogs.paragraph.by")}),jsx("input",{id:`${Me}-by`,type:"number",style:wt,min:0,step:.1,value:ce.special?"":Xn(f),placeholder:ce.special?mt("special"):void 0,onChange:q=>{at("special"),b(Math.max(0,La(Number(q.target.value)||0)));},"aria-label":o("dialogs.paragraph.by")}),jsx("span",{style:Qn,children:o("dialogs.paragraph.unitInches")})]}):null,jsx("div",{style:Jn,children:o("dialogs.paragraph.tabStops")}),K.length===0?jsx("div",{style:{fontSize:12,color:"var(--doc-text-muted)"},children:o(ce.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):K.map(q=>jsxs("div",{style:it,children:[jsx("span",{style:{...bt,color:"var(--doc-text)"},children:o("dialogs.paragraph.tabPositionLabel",{position:Wl(q.positionTwips)})}),jsx("span",{style:{flex:1,fontSize:13,color:"var(--doc-text-muted)"},children:o(uu[q.alignment])}),jsx("button",{type:"button",style:er,onClick:()=>$(K.filter(ve=>ve!==q)),"aria-label":o("dialogs.paragraph.tabRemoveAt",{position:Wl(q.positionTwips)}),children:o("dialogs.paragraph.tabRemove")})]},q.positionTwips)),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabPosition`,children:o("dialogs.paragraph.tabPosition")}),jsx("input",{id:`${Me}-tabPosition`,type:"number",style:wt,min:0,step:.1,value:Xn(ne),onChange:q=>be(Math.max(0,La(Number(q.target.value)||0))),"aria-label":o("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsx("span",{style:Qn,children:o("dialogs.paragraph.unitInches")})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabAlignment`,children:o("dialogs.paragraph.tabAlignment")}),jsxs("select",{id:`${Me}-tabAlignment`,style:wt,value:he,onChange:q=>W(q.target.value),"aria-label":o("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsx("option",{value:"left",children:o("dialogs.paragraph.tabAlignLeft")}),jsx("option",{value:"center",children:o("dialogs.paragraph.tabAlignCenter")}),jsx("option",{value:"right",children:o("dialogs.paragraph.tabAlignRight")}),jsx("option",{value:"decimal",children:o("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-tabLeader`,children:o("dialogs.paragraph.tabLeader")}),jsxs("select",{id:`${Me}-tabLeader`,style:wt,value:Z,onChange:q=>we(q.target.value),"aria-label":o("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsx("option",{value:"none",children:o("dialogs.paragraph.tabNone")}),jsx("option",{value:"dot",children:o("dialogs.paragraph.tabLeaderDot")}),jsx("option",{value:"hyphen",children:o("dialogs.paragraph.tabLeaderHyphen")}),jsx("option",{value:"underscore",children:o("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxs("div",{style:{...it,justifyContent:"flex-end"},children:[jsx("button",{type:"button",style:er,onClick:me,children:o("dialogs.paragraph.tabAdd")}),jsx("button",{type:"button",style:er,onClick:()=>{de(q=>({...q,tabStops:false})),oe(true),$([]);},children:o("dialogs.paragraph.tabClearAll")})]})]}),jsxs("div",{style:yu,children:[jsx("div",{style:Jn,children:o("dialogs.paragraph.spacing")}),pa("spaceBefore",x,T,"spaceBefore"),pa("spaceAfter",h,v,"spaceAfter"),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-lineSpacing`,children:o("dialogs.paragraph.lineSpacing")}),jsxs("select",{id:`${Me}-lineSpacing`,style:wt,value:ce.lineSpacing?"":y,onChange:q=>{let ve=q.target.value;at("lineSpacing"),S(ve),P(ve===Yo.current?.lineRule?Yo.current.lineValue:ve==="multiple"?1.08:12);},"aria-label":o("dialogs.paragraph.lineSpacing"),children:[ce.lineSpacing?jsx("option",{value:"",children:o("dialogs.paragraph.mixed")}):null,jsx("option",{value:"multiple",children:o("dialogs.paragraph.ruleMultiple")}),jsx("option",{value:"atLeast",children:o("dialogs.paragraph.ruleAtLeast")}),jsx("option",{value:"exact",children:o("dialogs.paragraph.ruleExactly")})]})]}),jsxs("div",{style:it,children:[jsx("label",{style:bt,htmlFor:`${Me}-at`,children:o("dialogs.paragraph.at")}),jsx("input",{id:`${Me}-at`,type:"number",style:wt,min:.01,step:y==="multiple"?.01:1,value:ce.lineSpacing?"":w,disabled:ce.lineSpacing,onChange:q=>{let ve=q.target.value.trim();P(ve===""?y==="multiple"?1.08:12:Number(ve)||0);},"aria-label":o("dialogs.paragraph.at")}),jsx("span",{style:Qn,children:y==="multiple"?"":o("dialogs.paragraph.unitPoints")})]}),mo("contextualSpacing",R,E),jsx("div",{style:Jn,children:o("dialogs.paragraph.pagination")}),mo("keepNext",L,D),mo("widowControl",_,k),mo("keepLines",F,M),mo("pageBreakBefore",I,ae)]})]})}),jsxs("div",{style:Fh,children:[sl?jsx("span",{role:"alert",style:Rh,children:o("dialogs.paragraph.refused")}):null,jsx("button",{type:"button",style:er,onClick:t,children:o("dialogs.paragraph.cancel")}),jsx("button",{type:"button",style:{...er,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:i?1:.5},disabled:!i,onClick:pe,children:o("dialogs.paragraph.ok")})]})]})})}),document.body)}var xu=createContext(null);function Su({children:e}){let[t,n]=useState(false),o=useRef(null),r=useMemo(()=>({open:a=>{o.current=a??document.activeElement,n(true);}}),[]),i=useCallback(()=>{n(false);let a=o.current;o.current=null,a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:true});},[]);return jsxs(xu.Provider,{value:r,children:[e,jsx(To,{open:t,onClose:i})]})}function Tu(){return useContext(xu)}var $h=["zoom","script","format","list","alignment","styles","font","text","history"],Gl=new Set(["review"]),jl=24,Pu=new Set;function Eu(e,t=$h){let n=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...n]}function Cu(e,t){let{widths:n,groups:o,order:r,fixed:i,more:a}=e,l=i;for(let s of o)l+=n.get(s)??0;if(l<=t)return Pu;l+=a;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 wu(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 ku=wu;function Ru(e){if(!(e.available>0))return Pu;let t=Cu(e,e.available),n=e.previous;if(!n||n.size===0||t.size>=n.size)return t;let o=Cu(e,e.available-(e.hysteresis));return wu(o,n)?n:o}function Mu(e,t,n,o){return e+t+n+o*2}function Iu(e,t){return e+t}function Xl(e,t){return e+t}function _u(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 Yl(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Du(e){return Yl(e.columnGap)}function Nu(e,t){return e.clientWidth-Yl(t.paddingLeft)-Yl(t.paddingRight)}var or="data-toolbar-group",nr="data-toolbar-fixed",Ql="data-toolbar-more",Gh=34,Jl=new Set;function Fu(e,t,n){let o=useRef(null),r=useRef(new Map),i=useRef(Gh),[a,l]=useState(Jl),c=useRef(a);c.current=a;let s=useRef({groups:t,order:n});s.current={groups:t,order:n};let d=useCallback(()=>{let p=o.current;if(!p||!e)return;let g=getComputedStyle(p),u=Du(g),f=Nu(p,g),b=p.querySelector(".docx-toolbar__separator"),x=u*2;if(b){let S=getComputedStyle(b),w=_u(S);x=Mu(b.offsetWidth,w.start,w.end,u);}for(let S of p.querySelectorAll(`[${or}]`)){let w=S.getAttribute(or);w&&S.offsetWidth>0&&r.current.set(w,Iu(S.offsetWidth,x));}let T=0;for(let S of p.querySelectorAll(`[${nr}]`))S.offsetWidth>0&&(T+=Xl(S.offsetWidth,u));let h=p.querySelector(`[${Ql}]`);h&&h.offsetWidth>0&&(i.current=Xl(h.offsetWidth,u));let v={available:f,widths:r.current,groups:s.current.groups,order:s.current.order,fixed:T,more:i.current,previous:c.current,hysteresis:jl},y=Ru(v);ku(y,c.current)||(c.current=y,l(y));},[e]),m=useCallback(p=>{o.current=p;},[]);return useLayoutEffect(()=>{if(!e){c.current.size>0&&(c.current=Jl,l(Jl));return}d();},[e,d]),useEffect(()=>{let p=o.current;if(!e||!p||typeof ResizeObserver>"u")return;let g=0,u=new ResizeObserver(()=>{g===0&&(g=requestAnimationFrame(()=>{g=0,d();}));});u.observe(p);for(let f of p.querySelectorAll(`[${or}], [${nr}]`))u.observe(f);return ()=>{g!==0&&cancelAnimationFrame(g),u.disconnect();}},[e,d,a]),{attach:m,overflow:a}}var ov=["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"],Hu=createContext({close:()=>{}});function nv(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function Ou({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 Bu({slot:e}){let t=X(),{close:n}=useContext(Hu),{execute:o,isActive:r,isEnabled:i,disabledReason:a}=le(e),l=J(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:!i,...a?{title:a}:{},...s?{"aria-pressed":r}:{},...r?{"data-active":""}:{},onMouseDown:B,onClick:m=>{o(),n(m.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(l?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:d})]})}function Zu({sections:e,className:t}){let n=X(),[o,r]=useState(false),i=useRef(null),a=useRef(null),l=useRef(null),c=useRef(false),s=useId(),d=n("formattingBar.more"),m=useCallback(u=>{r(false),u&&a.current?.focus();},[]),p=useMemo(()=>({close:m}),[m]);useEffect(()=>{if(!o)return;let u=f=>{let b=f.target;b instanceof Node&&i.current?.contains(b)||r(false);};return document.addEventListener("mousedown",u,true),()=>document.removeEventListener("mousedown",u,true)},[o]),useEffect(()=>{if(!o||!c.current)return;c.current=false;let u=l.current;u&&nv(u);},[o]);let g=u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),m(true));};return jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Ql]:"",children:[jsx("button",{ref:a,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:B,onClick:()=>r(u=>!u),onKeyDown:u=>{u.key==="ArrowDown"&&(u.preventDefault(),c.current=true,r(true));},children:re(ov)}),o?jsx(Hu.Provider,{value:p,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(u=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":n(u.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:n(u.labelKey)}),u.children]},u.id))})}):null]})}function sv(e,t){return e.value===t.value&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function rr(e){let t=H(),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=O(o,sv),i=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.wrap",l),value:r.value??null,options:IMAGE_WRAP_TARGETS,isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]),a=useMemo(()=>({execute:l=>runToolbarCommand(t,"image.altText",l),value:r.value,options:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]);return e==="image.wrap"?i:a}var ts=[{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 Za({className:e,hidden:t,asChild:n,children:o}){let{t:r}=N(),i=X(),{execute:a,value:l,isEnabled:c,disabledReason:s}=rr("image.wrap"),[d,m]=useState(false),p=useRef(null),g=useRef(null),u=useRef(null),f=useId(),b=useMemo(()=>ts.find(S=>S.value===l)??ts[0],[l]),x=J("image.wrap"),T=i(x?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let S=P=>{let R=p.current;R&&P.target instanceof Node&&R.contains(P.target)||m(false);},w=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),g.current?.focus());};return document.addEventListener("mousedown",S,true),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",S,true),document.removeEventListener("keydown",w);}},[d]);let h=useCallback(S=>{m(false),a(S);},[a]);if(t)return null;let v=r("imageWrap.tooltipPrefix",{label:r(b.labelKey)}),y={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":T,title:s??v,onMouseDown:B,onClick:()=>m(S=>!S)};return jsxs("div",{ref:p,className:"docx-toolbar__image-wrap",children:[n?jsx(j,{...y,children:o}):jsx("button",{...y,children:o??re(x?.paths)}),d?jsx("div",{ref:u,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:S=>S.stopPropagation(),children:ts.map(S=>jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===S.value,...l===S.value?{"data-active":""}:{},onMouseDown:B,onClick:()=>h(S.value),children:r(S.labelKey)},S.value))}):null]})}Za.docxSlot="image.wrap";var ar=Object.assign(Za,{docxSlot:"image.wrap"});function qa({className:e,hidden:t,asChild:n,children:o}){let{t:r}=N(),i=X(),{execute:a,value:l,isEnabled:c,disabledReason:s}=rr("image.altText"),[d,m]=useState(false),[p,g]=useState(""),u=useRef(null),f=useRef(null),b=useId();useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let y=w=>{let P=u.current;P&&w.target instanceof Node&&P.contains(w.target)||m(false);},S=w=>{w.key==="Escape"&&(w.preventDefault(),m(false),f.current?.focus());};return document.addEventListener("mousedown",y,true),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",y,true),document.removeEventListener("keydown",S);}},[d]);let x=useCallback(()=>{a(p),m(false);},[p,a]);if(t)return null;let T=J("image.altText"),h=i(T?.labelKey??"formattingBar.altText"),v={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":h,title:s??h,onMouseDown:B,onClick:()=>m(y=>!y)};return jsxs("div",{ref:u,className:"docx-toolbar__alt-text",children:[n?jsx(j,{...v,children:o}):jsx("button",{...v,children:o??h}),d?jsxs("div",{id:b,role:"dialog","aria-label":r("imageAltText.panelTitle"),className:"docx-toolbar__alt-text-panel",onMouseDown:y=>y.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:p,onChange:y=>g(y.target.value),placeholder:r("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>m(false),children:r("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:x,children:r("common.apply")})]})]}):null]})}qa.docxSlot="image.altText";var ir=Object.assign(qa,{docxSlot:"image.altText"});var Gu=e=>e.image;function Wu(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 Cv(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function is(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 Pv(e,t){let n=is(t);return e.horizontalPoints!==n.horizontalPoints||e.verticalPoints!==n.verticalPoints||e.relativeToH!==n.relativeToH||e.relativeToV!==n.relativeToV}function za(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let n=Zn(t);return Number.isInteger(n)?n:null}function Ev(e,t){let n=is(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let s=e.horizontalPoints!==n.horizontalPoints,d=e.verticalPoints!==n.verticalPoints,m=s?za(e.horizontalPoints):t.position?.horizontalEmu,p=d?za(e.verticalPoints):t.position?.verticalEmu;return s&&m===null?{ok:false}:d&&p===null?{ok:false}:m===void 0||p===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,verticalEmu:p}}}let o=e.horizontalPoints!==n.horizontalPoints,r=e.verticalPoints!==n.verticalPoints,i=e.relativeToH!==n.relativeToH,a=e.relativeToV!==n.relativeToV,l=o?za(e.horizontalPoints):t.position?.horizontalEmu,c=r?za(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}:{},...i||o||r?{relativeToH:e.relativeToH}:{},...a||o||r?{relativeToV:e.relativeToV}:{}}}}function Ka(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function $a(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function ls({open:e,onClose:t,className:n,triggerRef:o}){let r=H(),{t:i}=N(),a=O(Gu),l=useId(),c=useId(),s=useId(),d=useRef(null),m=useRef(null),p=useRef(null),g=useRef(null),[u,f]=useState(null),[b,x]=useState(null),T=m.current,h=T?.canCrop===false,v=T?.canResize===false,y=T?.locks.changeAspect===true,S=T?.kind==="anchored"&&T.canMove===true,w=T?.kind==="inline",P=T?.kind==="anchored"&&T.canMove===false;useEffect(()=>{if(!e){m.current=null,p.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:ae}=r.surface.state().selection;p.current={paragraphId:ae.paragraphId,offset:ae.offset},g.current=r.surface.session.packageRevision();}x(null);let k=is(a),I=a.crop;f({widthPoints:String($t(a.widthEmu)),heightPoints:String($t(a.heightEmu)),cropLeft:String(I.left),cropTop:String(I.top),cropRight:String(I.right),cropBottom:String(I.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...k});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let R=useCallback(()=>{o?.current?.focus(),r?.focus();},[r,o]),E=useCallback(()=>{t(),R();},[t,R]);useEffect(()=>{if(!e)return;let k=d.current;if(!k)return;let I=Wu(k);(I.find($=>$.id==="image-prop-width"&&!$.hasAttribute("disabled"))??I.find($=>!$.hasAttribute("disabled"))??k).focus();let K=$=>{if($.key==="Escape"){$.preventDefault(),E();return}if($.key!=="Tab")return;let V=Wu(k);if(V.length===0)return;let oe=document.activeElement,ne=V.findIndex(he=>he===oe);if(ne===-1)return;$.preventDefault();let be=$.shiftKey?(ne-1+V.length)%V.length:(ne+1)%V.length;V[be]?.focus();};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[e,E]);let L=useMemo(()=>{let k=T??a;return !k||k.widthEmu<=0?1:k.widthEmu/k.heightEmu},[a,T]),D=useCallback(k=>{f(I=>{if(!I)return I;if(!I.lockAspect)return {...I,widthPoints:k};let ae=$a(k);if(ae===null)return {...I,widthPoints:k};let K=Math.round(ae/L*100)/100;return {...I,widthPoints:k,heightPoints:String(K)}});},[L]),F=useCallback(k=>{f(I=>{if(!I)return I;if(!I.lockAspect)return {...I,heightPoints:k};let ae=$a(k);if(ae===null)return {...I,heightPoints:k};let K=Math.round(ae*L*100)/100;return {...I,widthPoints:String(K),heightPoints:k}});},[L]),M=useCallback(()=>{let k=m.current;if(!k?.intrinsic)return;let I=k.intrinsic.pixelWidth*72/k.intrinsic.dpiX,ae=k.intrinsic.pixelHeight*72/k.intrinsic.dpiY;f(K=>K&&{...K,widthPoints:String(Math.round(I*100)/100),heightPoints:String(Math.round(ae*100)/100)});},[a]),_=useCallback(()=>{let k=m.current,I=p.current,ae=g.current;if(!r||!k||!u||!I||ae===null)return;let K={type:"setImageProperties",drawingNodeId:k.id,expectedPackageRevision:ae,selectionParagraphId:I.paragraphId,selectionOffset:I.offset};if(!v){let he=$a(u.widthPoints),W=$a(u.heightPoints);if(he===null||W===null){x("imageProperties.errors.invalidDimensions");return}let Z=Zn(he),we=Zn(W);Z!==k.widthEmu&&(K.widthEmu=Z),we!==k.heightEmu&&(K.heightEmu=we);}if(k.canCrop&&!h){let he=Ka(u.cropLeft),W=Ka(u.cropTop),Z=Ka(u.cropRight),we=Ka(u.cropBottom);if(he===null||W===null||Z===null||we===null){x("imageProperties.errors.invalidCrop");return}let ce=k.crop;(he!==ce.left||W!==ce.top||Z!==ce.right||we!==ce.bottom)&&(K.crop={left:he,top:W,right:Z,bottom:we});}u.title!==k.title&&(K.title=u.title),u.description!==k.description&&(K.description=u.description);let $=u.hyperlink.trim();if($!==(k.hyperlink??"")&&(K.hyperlink=$===""?null:$),k.canChangeWrap&&u.wrap!==k.wrap&&(K.wrap=u.wrap),k.kind==="anchored"&&k.canMove&&Pv(u,k)){let he=Ev(u,k);if(!he.ok){x("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(he.value,k))){x("imageProperties.errors.invalidPosition");return}Object.assign(K,he.value);}if(!(K.widthEmu!==void 0||K.heightEmu!==void 0||K.title!==void 0||K.description!==void 0||K.hyperlink!==void 0||K.crop!==void 0||K.wrap!==void 0||K.horizontalEmu!==void 0||K.verticalEmu!==void 0||K.relativeToH!==void 0||K.relativeToV!==void 0)){E();return}if(!r.can(K).ok){x("imageProperties.errors.refused");return}if(!r.exec(K).ok){x("imageProperties.errors.refused");return}E();},[r,u,h,v,E]);return !e||!u?null:jsx("div",{className:`docx-dialog-overlay${n?` ${n}`:""}`,onClick:E,onMouseDown:k=>{k.stopPropagation(),Cv(k);},children:jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),children:[jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[b?jsx("p",{className:"docx-dialog__error",children:i(b)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:u.widthPoints,disabled:v,onChange:k=>D(k.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:u.heightPoints,disabled:v,onChange:k=>F(k.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:u.lockAspect,disabled:y,onChange:k=>f(I=>I&&{...I,lockAspect:k.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:h||!T?.intrinsic,onClick:M,children:i("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),w?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,P?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,S?jsxs(Fragment,{children:[u.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:i("imageProperties.relativeToHorizontal")}),jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:u.relativeToH??"page",onChange:k=>f(I=>I&&{...I,relativeToH:k.target.value}),children:DRAWING_REL_FROM_H.map(k=>jsx("option",{value:k,children:i(`dialogs.imagePosition.relativeOptions.${k}`)},k))})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:u.relativeToV??"line",onChange:k=>f(I=>I&&{...I,relativeToV:k.target.value}),children:DRAWING_REL_FROM_V.map(k=>jsx("option",{value:k,children:i(`dialogs.imagePosition.relativeOptions.${k}`)},k))})]})]}):null,jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:u.horizontalPoints,onChange:k=>f(I=>I&&{...I,horizontalPoints:k.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:u.verticalPoints,onChange:k=>f(I=>I&&{...I,verticalPoints:k.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:u.title,onChange:k=>f(I=>I&&{...I,title:k.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:u.description,onChange:k=>f(I=>I&&{...I,description:k.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("hyperlinkPopup.urlLabel")}),jsx("input",{id:s,className:"docx-dialog__input docx-dialog__input--full",value:u.hyperlink,onChange:k=>f(I=>I&&{...I,hyperlink:k.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("formattingBar.imageWrap")}),jsx("select",{id:c,className:"docx-dialog__select docx-dialog__input--full",value:u.wrap,disabled:T?.canChangeWrap===false,onChange:k=>f(I=>I&&{...I,wrap:k.target.value}),children:IMAGE_WRAP_TARGETS.map(k=>jsx("option",{value:k,children:i(`imageWrap.targets.${k}`)},k))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:h,value:u.cropLeft,onChange:k=>f(I=>I&&{...I,cropLeft:k.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:h,value:u.cropTop,onChange:k=>f(I=>I&&{...I,cropTop:k.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:h,value:u.cropRight,onChange:k=>f(I=>I&&{...I,cropRight:k.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:h,value:u.cropBottom,onChange:k=>f(I=>I&&{...I,cropBottom:k.target.value})})]}),h?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:E,children:i("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:_,children:i("common.apply")})]})]})})}function Va({className:e,hidden:t,asChild:n,children:o}){let r=H(),{t:i}=N(),a=O(Gu),[l,c]=useState(false),s=useRef(null),d={type:"setImageProperties",description:"probe"},m=r&&a?r.can(d):null,p=m?.ok===true,g=m&&!m.ok?m.reason:null;if(t)return null;let u=J("image.properties"),f={type:"button",ref:s,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!p,...p?{}:{"data-disabled":""},"aria-label":i("formattingBar.imagePropertiesShortcut"),title:g??i("formattingBar.imagePropertiesShortcut"),onMouseDown:B,onClick:()=>c(true)};return jsxs(Fragment,{children:[n?jsx(j,{...f,children:o}):jsx("button",{...f,children:o??re(u?.paths)}),jsx(ls,{open:l,onClose:()=>c(false),triggerRef:s})]})}Va.docxSlot="image.properties";var ln=Object.assign(Va,{docxSlot:"image.properties"});function Le(e){return Object.assign(n=>jsx(go,{slot:e,...n}),{docxSlot:e})}var ju=Le("history.undo"),Yu=Le("history.redo"),Xu=Le("text.bold"),Ju=Le("text.italic"),Qu=Le("text.underline"),ep=Le("text.strike"),tp=Le("format.clear"),op=Le("script.super"),np=Le("script.sub"),rp=Le("alignment.left"),ap=Le("alignment.center"),ip=Le("alignment.right"),lp=Le("alignment.justify"),sp=Le("list.bullet"),cp=Le("list.numbered"),dp=Le("list.outdent"),up=Le("list.indent");var pp=Le("table.insert"),mp=Le("review.comments");function Mv({className:e,hidden:t,icon:n,asChild:o,children:r}){let i=H(),{openAtCaret:a}=Il(),l=chromeProbeForSlot("text.link"),c=i&&l?i.can(l):null,s=c?.ok===true,{t:d}=N(),m=localizeDisabledReason(c&&!c.ok?c.reason:null,d),p=X();if(t)return null;let g=J("text.link"),u=p(g?.labelKey??"text.link"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!s,...s?{}:{"data-disabled":""},"aria-label":u,title:m??u,onMouseDown:B,onClick:()=>a()};return o?jsx(j,{...f,children:r}):jsx("button",{...f,children:n??r??re(g?.paths)})}var ss=Object.assign(Mv,{docxSlot:"text.link"});function Iv({className:e,hidden:t}){let n=H(),{onSave:o}=useContext(fo),r=X();if(t)return null;let i=J("file.save"),a=r(i?.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":a,title:a,onMouseDown:B,onClick:()=>o?.(),children:re(i?.paths)})}var cs=Object.assign(Iv,{docxSlot:"file.save"});function sn({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}function cn(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}var Nv=e=>({zoom:e.zoom,mode:e.zoomMode}),Lv=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,gp={type:"fixed"};function ds(){let e=H(),{zoom:t,mode:n}=O(Nv,Lv),o=useCallback(i=>{e?.setZoom(i);},[e]),r=useCallback(i=>{e?.setZoomMode(i);},[e]);return useMemo(()=>{let i=n??gp,a=Yn(t,"out"),l=Yn(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:o,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(gp),o(1);},zoomIn:()=>l!==null&&o(l),zoomOut:()=>a!==null&&o(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Ra}},[e,t,n,o,r])}var dr=2,ur=3276,cr=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Hv=e=>e.formatting?.fontSizePt??null;function vp(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function yp(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 Sp(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:B,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:B,onClick:e.onIncrease,children:"+"})]})}function Ov(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<dr||o>ur?null:o}function Bv({className:e,hidden:t}){let n=H(),o=O(Hv),{isEnabled:r,disabledReason:i}=le("font.size"),a=X(),[l,c]=useState(false),[s,d]=useState(null),m=useRef(null),p=useRef(null),g=useCallback(y=>{if(!n)return;let S=commandForSlotValue("font.size",y);S&&n.can(S).ok&&n.exec(S);},[n]),u=useCallback(y=>{g(Math.min(ur,Math.max(dr,Math.round(y*2))));},[g]),f=useCallback(y=>{c(false),d(null),p.current?.blur(),y&&Zv(m.current);},[]);if(useEffect(()=>{if(!l)return;let y=S=>{let w=m.current;w&&S.target instanceof Node&&w.contains(S.target)||(c(false),d(null));};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]),t)return null;let b=r&&o!==null,x=o===null?"\u2014":String(Math.round(o*2)/2),T=s??x,h=o===null?null:Math.round(o*2)/2,v=()=>{if(s===null)return;let y=Ov(s);y!==null&&g(y);};return jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsx(Sp,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsx("input",{ref:p,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:T,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),autoComplete:"off",onChange:y=>{d(y.target.value),c(true);},onFocus:y=>{y.target.select(),c(true);},onClick:()=>c(true),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),v(),f(true)):y.key==="Escape"?(y.preventDefault(),f(true)):(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),c(true),o!==null&&u(y.key==="ArrowDown"?yp(o,cr,dr/2):vp(o,cr,ur/2)));},onBlur:()=>{v(),d(null);}}),canDecrease:b&&Math.round(o*2)>dr,canIncrease:b&&Math.round(o*2)<ur,onDecrease:()=>u(yp(o??0,cr,dr/2)),onIncrease:()=>u(vp(o??0,cr,ur/2))}),l&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":a("fontSize.listLabel"),children:cr.map(y=>{let S=h===y;return jsx("button",{type:"button",role:"option","aria-selected":S,...S?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>{u(y),f(true);},children:y},y)})}):null]})}function Zv(e){(cn(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}var ms=Object.assign(Bv,{docxSlot:"font.size"});function qv({className:e,hidden:t}){let n=H(),{zoom:o,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:c,zoomOut:s,canZoomIn:d,canZoomOut:m,levels:p}=ds(),g=X(),[u,f]=useState(false),b=useRef(null);useEffect(()=>{if(!u)return;let S=w=>{let P=b.current;P&&w.target instanceof Node&&P.contains(w.target)||f(false);};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[u]);let x=useCallback(S=>{f(false),a(S);},[a]),T=useCallback(S=>{f(false),l(S==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let h=`${Math.round(o*100)}%`,v=sameZoomMode(i,AUTO_ZOOM_MODE),y=sameZoomMode(i,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:b,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(Sp,{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":u,"aria-label":g("zoom.zoomLevel"),onMouseDown:B,onClick:()=>f(S=>!S),children:[h,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:s,onIncrease:c}),u?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":v,...v?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>T("auto"),children:g("zoom.automatic")}),jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>T("fit-width"),children:g("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),p.map(S=>{let w=!r&&Math.abs(S-o)<.001;return jsx("button",{type:"button",role:"option","aria-selected":w,...w?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>x(S),children:`${Math.round(S*100)}%`},S)})]}):null]})}var fs=Object.assign(qv,{docxSlot:"zoom.level"});var Vv=[1,1.15,1.5,2,2.5,3],Pp=10,Ep=0,Uv=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),Wv=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function Gv({className:e,hidden:t}){let n=H(),o=O(Uv,Wv),{isEnabled:r,disabledReason:i}=le("list.lineSpacing"),a=le("paragraph.dialog"),l=Tu(),c=X(),[s,d]=useState(false),m=useRef(null),p=useRef(null);useEffect(()=>{if(!s)return;let h=v=>{let y=m.current;y&&v.target instanceof Node&&y.contains(v.target)||d(false);};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);let g=useCallback(h=>{if(d(false),!n)return;let v=commandForSlotValue("list.lineSpacing",h);v&&n.can(v).ok&&n.exec(v);},[n]),u=useCallback((h,v)=>{if(d(false),!n)return;let y={type:"setParagraphSpacing",[h]:v};n.can(y).ok&&n.exec(y);},[n]);if(t)return null;let f=J("list.lineSpacing"),b=(o.spaceBeforePt??0)>0,x=(o.spaceAfterPt??0)>0,T=o.lineSpacing?.rule==="multiple"?o.lineSpacing?.value??null:null;return jsxs("span",{ref:m,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxs("button",{ref:p,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":c("lineSpacing.label"),title:i??c("lineSpacing.label"),onMouseDown:B,onClick:()=>d(h=>!h),children:[re(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:[Vv.map(h=>{let v=T===h;return jsx("button",{type:"button",role:"menuitemradio","aria-checked":v,...v?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>g(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","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:B,onClick:()=>{d(false),l?.open(p.current);},children:c("lineSpacing.options")}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>u("beforePt",b?Ep:Pp),children:c(b?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:B,onClick:()=>u("afterPt",x?Ep:Pp),children:c(x?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var bs=Object.assign(Gv,{docxSlot:"list.lineSpacing"});var ey=[{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"}],wp=[{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"}],kp=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Ua=["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"],Wt=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),st=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function ty(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?[st(5),st(15),st(25),st(35),st(50)]:n===0?[Wt(50),Wt(35),Wt(25),Wt(15),Wt(5)]:n>=.8?[st(10),st(25),st(50),st(75),st(90)]:[Wt(80),Wt(60),Wt(40),st(25),st(50)]}var oy=/^[0-9A-Fa-f]{6}$/;function ny(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 ry(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 Wa({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":""}:{},...ry(t.replace("#",""))?{"data-light":""}:{},onMouseDown:B,onClick:()=>r(e)})}function ay({apply:e,label:t,current:n,themeHexes:o}){let r=o.map(ty),i=[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((a,l)=>jsx(Wa,{value:a,css:`#${a.toLowerCase()}`,title:t(Ua[l]),selected:n===a,apply:e},`base-${l}`)),i.map(a=>o.map((l,c)=>{let s=r[c][a],d=ny(l,s.apply);return jsx(Wa,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Ua[c])}, ${t(s.labelKey)}`,selected:n===d,apply:e},`${a}-${c}`)}))]})]})}function iy(e){let{apply:t,label:n,current:o}=e,[r,i]=useState(""),a=oy.test(r);return jsxs(Fragment,{children:[jsx(ay,{...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:ey.map(l=>jsx(Wa,{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=>i(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&a&&t(r.toUpperCase());}}),jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:B,onClick:()=>t(r.toUpperCase()),children:n("colorPicker.apply")})]})]})]})}function vs({apply:e,current:t}){let n=H(),o=X(),r=n?.getDocumentThemeColors()??[],i=r.length===Ua.length?r.map(l=>l.hex):kp,a=t?.toUpperCase()??null;return jsx(iy,{apply:e,label:o,current:a,themeHexes:i})}var ly=wp.filter(e=>e.value!=="white");function sy({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:ly.map(o=>jsx(Wa,{value:o.value,css:o.css,title:t(o.labelKey),selected:n===o.value,apply:e},o.value))})]})}function Rp(e){let{slot:t,defaultValue:n,cssOf:o,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:c,hidden:s,icon:d})=>{let m=H(),{isEnabled:p,disabledReason:g}=le(t),u=X(),[f,b]=useState(false),[x,T]=useState(n),h=useRef(null),v=O(E=>{if(a){let L=E.formatting?.color;return L&&L.kind==="hex"?L.value.toUpperCase():null}return E.formatting?.highlight??null}),y=m?.getDocumentThemeColors()??[],S=y.length===Ua.length?y.map(E=>E.hex):kp;useEffect(()=>{if(!f)return;let E=L=>{let D=h.current;D&&L.target instanceof Node&&D.contains(L.target)||b(false);};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[f]);let w=useCallback(E=>{if(b(false),!m)return;let L=commandForSlotValue(t,E);L&&m.can(L).ok&&(m.exec(L),E!==r.value&&T(E));},[m]),P=useMemo(()=>J(t),[]);if(s)return null;let R=u(P?.labelKey??t);return jsxs("div",{ref:h,className:`docx-toolbar__colorsplit${c?` ${c}`:""}`,"data-slot":t,children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!p,...p?{}:{"data-disabled":""},"aria-label":R,title:g??R,onMouseDown:B,onClick:()=>w(x),children:[d??re(P?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:o(x)},"aria-hidden":"true"})]}),jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!p,...p?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":f,"aria-label":R,title:g??R,onMouseDown:B,onClick:()=>b(E=>!E),children:"\u25BE"}),f?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":R,onMouseDown:B,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:B,onClick:()=>w(r.value),children:[jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),u(r.labelKey)]}),i({apply:w,label:u,current:v,themeHexes:S})]}):null]})},{docxSlot:t})}var cy=new Map(wp.map(e=>[e.value,e.css])),ys=Rp({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(vs,{apply:e.apply,current:e.current})}),xs=Rp({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>cy.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(sy,{...e})});var fy=["alignment.left","alignment.center","alignment.right","alignment.justify"];function gy({className:e,hidden:t}){let n=le("alignment.left"),o=le("alignment.center"),r=le("alignment.right"),i=le("alignment.justify"),a=X(),[l,c]=useState(false),s=useRef(null);if(useEffect(()=>{if(!l)return;let f=b=>{let x=s.current;x&&b.target instanceof Node&&x.contains(b.target)||c(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]),t)return null;let d=[n,o,r,i],m=fy.map((f,b)=>({slot:f,control:J(f),state:d[b]})),p=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.state.isEnabled),u=a(p.control?.labelKey??p.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":u,title:g?u:p.state.disabledReason??u,onMouseDown:B,onClick:()=>c(f=>!f),children:[re(p.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:m.map(f=>{let b=a(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:B,onClick:()=>{f.state.execute(),c(false);},children:re(f.control?.paths)},f.slot)})}):null]})}var Ga=Object.assign(gy,{docxSlot:"alignment"});function Ts(e){let{label:t,icon:n,active:o,disabled:r,disabledReason:i,onSelect:a,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?i??t:t,onMouseDown:m=>B(m),onClick:r?void 0:a};return l?jsx(j,{...d,children:s}):jsx("button",{...d,children:n??s})}var Cy=Object.freeze([]),Py=e=>e.formatting?.fontFamily??null,Ey=e=>e;function ja(){let e=H(),t=O(Py),n=O(Ey),o=useMemo(()=>e&&!n.isLoading?e.getAvailableFonts():Cy,[e,n]),{isEnabled:r}=le("font.family"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:o,isEnabled:r}),[t,i,o,r])}var _p=createContext(null);function Ps(){return useContext(_p)}function Es({asChild:e,className:t,children:n}){let o=Ps(),r=X();if(!o)return null;let i=r(J("font.family")?.labelKey??"font.family"),a={onClick:()=>o.setOpen(!o.open),onMouseDown:B,disabled:!o.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":i,title:i},l=n??jsx("span",{children:o.value??"\u2014"});return e?jsx(j,{...a,children:l}):jsx("button",{type:"button",...a,children:l})}Es.docxToolbarPart=true;var wy=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"]]),ky=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Dp({asChild:e,className:t,children:n}){let o=Ps(),r=X();if(!o||!o.open)return null;let i={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"}},a;return n!==void 0?a=n:a=ky.map(c=>({...c,fonts:o.options.filter(s=>(wy.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(Np,{value:d},d))]},c.category)),e?jsx(j,{...i,children:a}):jsx("div",{...i,children:a})}function Np({value:e,asChild:t,className:n,children:o}){let r=Ps();if(!r)return null;let i=r.value===e,a={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:B,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(j,{...a,children:l}):jsxs("button",{type:"button",...a,children:[l,i?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function Ry({hidden:e,asChild:t,className:n,children:o}){let r=ja(),[i,a]=useState(false),l=useRef(null);useEffect(()=>{if(!i)return;let m=p=>{let g=l.current;g&&p.target instanceof Node&&g.contains(p.target)||a(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[i]);let c=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);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(Es,{}),jsx(Dp,{})]});return jsx(_p.Provider,{value:c,children:t?jsx(j,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var ws=Object.assign(Ry,{docxSlot:"font.family",Trigger:Es,Content:Dp,Item:Np});var Iy={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},_y=new Set(["Title","Heading1","Heading2","Heading3"]),Dy={Subtitle:"666666"},Ny="#4a6c8c";function Lp(e){let t=Iy[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??_y.has(e.styleId))&&(o.fontWeight="bold"),e.italic&&(o.fontStyle="italic");let r=e.color??Dy[e.styleId];return r?o.color=`#${r}`:e.styleId.startsWith("Heading")&&(o.color=Ny),o}var Ly=/^heading ([1-9])$/;function Rs(e,t){let n=e||t,o=Ly.exec(n);return o?`Heading ${o[1]}`:n}function Fp(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Rs(t.name,t.styleId),priority:99}))}function zy(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 Ky=Object.freeze([]),$y=e=>e.formatting?.styleId??null,Vy=e=>e;function Ya(){let e=H(),t=O($y),n=O(Vy),o=useMemo(()=>e&&!n.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:Rs(a.name,a.styleId),preview:a.preview})):Ky,[e,n]),{isEnabled:r}=le("styles.style"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:o,isEnabled:r}),[t,i,o,r])}var Ap=createContext(null);function Is(){return useContext(Ap)}function _s({asChild:e,className:t,children:n}){let o=Is(),r=X();if(!o)return null;let i=J("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>o.setOpen(!o.open),onMouseDown:B,disabled:!o.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...o.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":o.open,"aria-label":a,title:a},c=o.options.find(d=>d.styleId===o.value),s=n??(o.value===null?jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsx("span",{children:c?.name??o.value}));return e?jsx(j,{...l,children:s}):jsx("button",{type:"button",...l,children:s})}_s.docxToolbarPart=true;function Hp({asChild:e,className:t,children:n}){let o=Is();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"}},i=n??o.options.map(a=>jsx(Op,{value:a.styleId},a.styleId));return e?jsx(j,{...r,children:i}):jsx("div",{...r,children:i})}function Op({value:e,asChild:t,className:n,children:o}){let r=Is();if(!r)return null;let i=r.value===e,a=r.options.find(s=>s.styleId===e),l={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:B,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${n?` ${n}`:""}`},c=o??jsx("span",{style:a?zy(a.preview):void 0,children:a?.name??e});return t?jsx(j,{...l,children:c}):jsxs("button",{type:"button",...l,children:[c,i?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function Uy({hidden:e,asChild:t,className:n,children:o}){let r=Ya(),[i,a]=useState(false),l=useRef(null);useEffect(()=>{if(!i)return;let m=p=>{let g=l.current;g&&p.target instanceof Node&&g.contains(p.target)||a(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[i]);let c=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);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(_s,{}),jsx(Hp,{})]});return jsx(Ap.Provider,{value:c,children:t?jsx(j,{...s,ref:l,children:d}):jsx("div",{ref:l,...s,children:d})})}var Ds=Object.assign(Uy,{docxSlot:"styles.style",Trigger:_s,Content:Hp,Item:Op});function Zp(e,t){let n=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:c})=>{let{isEnabled:s,disabledReason:d}=le(n),m=Et(),p=t==="showAll"?m.showAll:m.formFill,g=X();if(i)return null;let u=J(n),f=g(u?.labelKey??e),b={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!s,...s?{}:{"data-disabled":""},...p?{"data-active":""}:{},"aria-pressed":p,"aria-label":f,title:d??f,onMouseDown:B,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsx(j,{...b,children:c}):jsx("button",{...b,children:a??c??re(u?.paths)})},{docxSlot:n})}function Gy({className:e,hidden:t,icon:n,asChild:o,children:r}){let i=Xe.inspector,{isEnabled:a,disabledReason:l}=le(i),{inspectorOpen:c,openInspector:s}=Et(),d=X();if(t)return null;let m=J(i),p=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xe.inspector,disabled:!a,...a?{}:{"data-disabled":""},...c?{"data-active":""}:{},"aria-pressed":c,"aria-label":p,title:l??p,onMouseDown:B,onClick:()=>s()};return o?jsx(j,{...g,children:r}):jsx("button",{...g,children:n??r??re(m?.paths)})}function jy({className:e,hidden:t,icon:n,asChild:o,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Et(),c=X();if(t)return null;let s=Xe.remove,d=J(s),m=c(d?.labelKey??"contentControl.remove"),p={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xe.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:B,onClick:()=>{l();}};return o?jsx(j,{...p,children:r}):jsx("button",{...p,children:n??r??re(d?.paths)})}var Xa=Zp(Xe.showAll,"showAll"),Ja=Zp(Xe.formFill,"formFill"),Qa=Object.assign(jy,{docxSlot:Xe.remove}),ei=Object.assign(Gy,{docxSlot:Xe.inspector}),qp={[Xe.showAll]:Xa,[Xe.formFill]:Ja,[Xe.inspector]:ei,[Xe.remove]:Qa};function Ns(e,t){let n=H(),o=useRef(t);o.current=t,useEffect(()=>{if(!n)return;let r=((...i)=>{o.current(...i);});return n.on(e,r)},[n,e]);}var ox=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Fs=createContext(null);function Gp(){let e=useContext(Fs);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function rx(e,t){let n=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=n?`${r}|${n.rows}|${n.columns}|${n.rowIndex}|${n.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.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:i,selectionKey:l,cellSelectionKey:s,editable:t.editable,editingMode:t.editingMode??"editing"}}function ax(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function ix(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Up={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function lx(e,t){let n={};for(let o of ox){let r=tableChromeToolbarState(e,o,t);n[o]={enabled:r.enabled,disabledReason:r.disabledReason};}return n}function As({children:e}){let t=H(),[n,o]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,i]=useState(Up);useEffect(()=>(()=>{}),[]);let a=O(useCallback(p=>({table:p.table,editable:p.editable,editingMode:p.editingMode??"editing",headParagraphId:p.selection?.to&&"paraId"in p.selection.to?p.selection.to.paraId:p.selection?.from&&"paraId"in p.selection.from?p.selection.from.paraId:""}),[]),ax,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=useCallback(()=>{if(!t){i(Up);return}let p=rx(t,t.snapshot());i(g=>ix(g,p)?g:p);},[t]);useEffect(()=>{l();},[l,a]),Ns("selectionChange",useCallback(()=>{l();},[l]));let c=r.tableKey!=="",s=useMemo(()=>t?lx(t,n):{},[t,n,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=useCallback((p,g)=>{if(!t)return;let{result:u,nextDraft:f}=runTableChromeCommand(t,p,g,n);u.ok&&f&&o(f);},[t,n]),m=useMemo(()=>({visible:c,draft:n,setDraft:o,slotState:p=>s[p]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[c,n,s,d]);return jsx(Fs.Provider,{value:m,children:e})}function sx(){let e=useContext(Fs);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function oi(e){let t=sx(),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 dx='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Po(e){return [...e.querySelectorAll(dx)].filter(t=>t.closest('[role="menu"]')===e)}function Hs(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function vt(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 yt(e,t){let n=t==="first"?e[0]:e[e.length-1];return n?(n.focus(),true):false}function ni(e){(cn(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Bs(e,t,n){useEffect(()=>{if(!e)return;let o=r=>{let i=n.current;i&&r.target instanceof Node&&i.contains(r.target)||t(false);};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t,n]);}function ri({enabled:e,disabledReason:t,ariaLabel:n}){let{t:o}=N(),r=localizeDisabledReason(t,o),i=useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:B,"aria-label":n,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var mx='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function jp(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,i=o.current;if(!r)return;let a=()=>[...r.querySelectorAll(mx)].filter(s=>s.closest('[role="menu"]')===r);queueMicrotask(()=>{let s=a();(s.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??s[0])?.focus();});let c=s=>{let d=a();if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="ArrowDown"){s.preventDefault(),vt(d,document.activeElement,1);return}if(s.key==="ArrowUp"){s.preventDefault(),vt(d,document.activeElement,-1);return}if(s.key==="Home"){s.preventDefault(),yt(d,"first");return}if(s.key==="End"){s.preventDefault(),yt(d,"last");return}if(s.key==="Enter"||s.key===" "){let m=document.activeElement;m instanceof HTMLElement&&d.includes(m)&&(s.preventDefault(),m.click());}};return r.addEventListener("keydown",c),()=>r.removeEventListener("keydown",c)},[e,t,n,o]);}function Yp(e,t,n,o){useEffect(()=>{if(!e)return;let r=n.current,i=o.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(c=>c.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=c=>{if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="Enter"||c.key===" "){let s=document.activeElement,d=a();s instanceof HTMLElement&&d.includes(s)&&(c.preventDefault(),s.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,n,o]);}function tm(e,t,n){if(e)return o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n(!t));}}function xx(e){return re(tableChromeIconPaths(e))}function om(){return createContext(null)}function Ht(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function qs(e,t,n){let o=om();function r({hidden:l,asChild:c,className:s,children:d}){let{visible:m,enabled:p,disabledReason:g,draft:u,apply:f}=oi(e),[b,x]=useState(false),T=useRef(null),h=useRef(null);Bs(b,x,T);let v=useMemo(()=>({open:b,setOpen:x,enabled:p,disabledReason:g,apply:f,draft:u,triggerRef:h}),[b,p,g,f,u]);if(l||!m)return null;let y={className:`${t}${s?` ${s}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},S=d??jsxs(Fragment,{children:[jsx(i,{}),jsx(a,{})]});return jsx(o.Provider,{value:v,children:c?jsx(j,{...y,ref:T,children:S}):jsx("div",{ref:T,...y,children:S})})}function i({asChild:l,className:c,children:s}){let{open:d,setOpen:m,enabled:p,disabledReason:g,triggerRef:u}=Ht(o),f=X(),b=J(e),x=f(b?.labelKey??n),{shared:T,reasonNode:h}=ri({enabled:p,disabledReason:g,ariaLabel:x}),v={...T,ref:u,className:`docx-toolbar__button docx-table-chrome__trigger${c?` ${c}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:p?()=>m(!d):void 0,...l?{tabIndex:p?0:-1,role:"button",onKeyDown:tm(p,d,m)}:{}},y=s??jsxs(Fragment,{children:[re(b?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(j,{...v,children:y}),h]}):jsxs("button",{...v,children:[y,h]})}i.docxToolbarPart=true;function a({asChild:l,className:c,children:s}){let{open:d,setOpen:m,enabled:p,triggerRef:g}=Ht(o),u=X(),f=useRef(null);if(jp(d&&p,m,f,g),!d||!p)return null;let b=J(e),x=u(b?.labelKey??n),T={ref:f,role:"menu","aria-label":x,className:`docx-table-chrome__panel${c?` ${c}`:""}`,onMouseDown:B};return l?jsx(j,{...T,children:s}):jsx("div",{...T,children:s})}return {Root:r,Trigger:i,Content:a,Ctx:o}}var fr=qs("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function nm({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(fr.Ctx),l=X(),c=TABLE_BORDER_TARGET_OPTIONS.find(p=>p.value===e);if(!c)return null;let s=c.value==="none"?false:c.value===a.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:B,onClick:()=>{i(false),r(c.value);}},m=o??xx(c.icon);return t?jsx(j,{...d,children:m}):jsx("button",{...d,children:m})}function rm(e){let{children:t}=e;return jsx(fr.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(n=>jsx(nm,{value:n.value},n.value))})})}function Sx(e){let{children:t}=e,n=t??jsxs(Fragment,{children:[jsx(fr.Trigger,{}),jsx(rm,{})]});return jsx(fr.Root,{...e,children:n})}var yr=Object.assign(Sx,{docxSlot:"table.borderTarget",Trigger:fr.Trigger,Content:rm,Item:nm}),gr=qs("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function am({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(gr.Ctx),l=X(),c=TABLE_BORDER_STYLE_OPTIONS.find(p=>p.value===e);if(!c)return null;let s=c.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":s,...s?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:B,onClick:()=>{i(false),r(c.value);}},m=o??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${c.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(c.labelKey)})]});return t?jsx(j,{...d,children:m}):jsx("button",{...d,children:m})}function im(e){let{children:t}=e;return jsx(gr.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(n=>jsx(am,{value:n.value},n.value))})}function Tx(e){let t=e.children??jsxs(Fragment,{children:[jsx(gr.Trigger,{}),jsx(im,{})]});return jsx(gr.Root,{...e,children:t})}var xr=Object.assign(Tx,{docxSlot:"table.borderStyle",Trigger:gr.Trigger,Content:im,Item:am}),br=qs("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function lm({value:e,asChild:t,className:n,children:o}){let{apply:r,setOpen:i,draft:a}=Ht(br.Ctx),l=X(),c=Number(e),s=TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===c);if(!s)return null;let d=s.size===a.spec.size,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${n?` ${n}`:""}`,onMouseDown:B,onClick:()=>{i(false),r(s.size);}},p=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(j,{...m,children:p}):jsx("button",{...m,children:p})}function sm(e){let{children:t}=e;return jsx(br.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(n=>jsx(lm,{value:String(n.size)},n.size))})}function Cx(e){let t=e.children??jsxs(Fragment,{children:[jsx(br.Trigger,{}),jsx(sm,{})]});return jsx(br.Root,{...e,children:t})}var Sr=Object.assign(Cx,{docxSlot:"table.borderWidth",Trigger:br.Trigger,Content:sm,Item:lm});function cm(e,t,n){let o=n?.defaultHex??"FF0000",r=om();function i({hidden:d,asChild:m,className:p,children:g}){let{visible:u,enabled:f,disabledReason:b,draft:x,apply:T}=oi(e),[h,v]=useState(false),[y,S]=useState(o),w=useRef(null),P=useRef(null);Bs(h,v,w);let R=useMemo(()=>({open:h,setOpen:v,enabled:f,disabledReason:b,apply:T,draft:x,triggerRef:P,lastHex:y,setLastHex:S}),[h,f,b,T,x,y]);if(d||!u)return null;let E={className:`docx-toolbar__colorsplit docx-table-chrome${p?` ${p}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},L=g??jsxs(Fragment,{children:[jsx(a,{}),jsx(l,{}),jsx(c,{clearFill:n?.clearFill??false})]});return jsx(r.Provider,{value:R,children:m?jsx(j,{...E,ref:w,children:L}):jsx("div",{ref:w,...E,children:L})})}function a({asChild:d,className:m,children:p}){let{enabled:g,disabledReason:u,apply:f,draft:b,lastHex:x}=Ht(r),T=X(),h=J(e),v=T(h?.labelKey??t),{shared:y,reasonNode:S}=ri({enabled:g,disabledReason:u,ariaLabel:v}),w=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:x??o,P={...y,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:w}):void 0},R=p??jsxs(Fragment,{children:[re(h?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${w.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(j,{...P,children:R}),S]}):jsxs("button",{...P,children:[R,S]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:p}){let{open:g,setOpen:u,enabled:f,disabledReason:b,triggerRef:x}=Ht(r),T=X(),h=J(e),v=T(h?.labelKey??t),{shared:y,reasonNode:S}=ri({enabled:f,disabledReason:b,ariaLabel:v}),w={...y,ref:x,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>u(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:tm(f,g,u)}:{}},P=p??"\u25BE";return d?jsxs(Fragment,{children:[jsx(j,{...w,children:P}),S]}):jsxs("button",{...w,children:[P,S]})}l.docxToolbarPart=true;function c({asChild:d,className:m,children:p,clearFill:g}){let{open:u,setOpen:f,enabled:b,apply:x,draft:T,triggerRef:h,lastHex:v,setLastHex:y}=Ht(r),S=X(),w=useRef(null);if(Yp(u&&b,f,w,h),!u||!b)return null;let P=S(t),R=e==="table.borderColor"&&T.spec.color.kind==="hex"?T.spec.color.value:v??o,E={ref:w,role:"dialog","aria-label":P,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:B},L=p??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:B,onClick:()=>{f(false),x(null),ni(h.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),S("table.clearCellFill")]}):null,jsx(vs,{apply:D=>{f(false),y?.(D),x({kind:"hex",value:D}),ni(h.current);},current:R})]});return d?jsx(j,{...E,children:L}):jsx("div",{...E,children:L})}function s({value:d,css:m,labelKey:p,asChild:g,className:u,children:f}){let{apply:b,setOpen:x,setLastHex:T,triggerRef:h}=Ht(r),v=X(),y=m??`#${d.toLowerCase()}`,S=p?v(p):d,w={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${u?` ${u}`:""}`,style:{backgroundColor:y},"data-value":d,"aria-label":S,title:S,onMouseDown:B,onClick:()=>{x(false),T?.(d),b({kind:"hex",value:d}),ni(h.current);}};return g?jsx(j,{...w,children:f}):jsx("button",{...w,children:f})}return {Root:i,Main:a,Trigger:l,Content:c,Item:s,Ctx:r}}var hr=cm("table.borderColor","table.borderColor",{defaultHex:"000000"});function Px(e){return jsx(hr.Content,{...e,clearFill:false})}function Ex(e){return jsx(hr.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function wx(e){return jsx(hr.Root,{...e})}var Tr=Object.assign(wx,{docxSlot:"table.borderColor",Trigger:hr.Trigger,Content:Px,Item:Ex,Main:hr.Main}),vr=cm("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function kx(e){return jsx(vr.Content,{...e,clearFill:true})}function Rx(e){return jsx(vr.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function Mx(e){return jsx(vr.Root,{...e})}var Cr=Object.assign(Mx,{docxSlot:"table.cellFill",Trigger:vr.Trigger,Content:kx,Item:Rx,Main:vr.Main});function dm({overrides:e=new Map}){return Gp()?jsxs(Fragment,{children:[jsx(sn,{}),[yr,Tr,xr,Sr,Cr].map(o=>{let r=e.get(o.docxSlot);return r?jsx(Fragment$1,{children:r},o.docxSlot):jsx(o,{},o.docxSlot)})]}):null}function um(){let e=X(),{draft:t}=oi("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var gm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],bm={"zoom.level":fs,"styles.style":Ds,"font.family":ws,"font.size":ms,"text.color":ys,"text.highlight":xs,"text.link":ss,"list.lineSpacing":bs,"review.editingMode":_a,"file.save":cs,...qp,"table.borderTarget":yr,"table.borderColor":Tr,"table.borderStyle":xr,"table.borderWidth":Sr,"table.cellFill":Cr,"image.insert":qn,"image.properties":ln,"image.wrap":ar,"image.altText":ir},mm=new Map;function Dx(e){let t=mm.get(e);return t||(t=n=>jsx(go,{slot:e,...n}),mm.set(e,t)),t}function Nx(e){return formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:Ga}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(n=>{let o=chromeSlotId(t,n);return {slot:o,Part:bm[o]??Dx(o)}})})}var Lx=e=>e.image,Fx=e=>e.isLoading||e.isOpening===true;function Ax(e){return e==="alignment"||e in bm}function $s(e){let t=nn(e,$s);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 zs(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(zs);let t=$s(e);return t!=null&&gm.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(zs):false}function Hx(e,t){return t?true:Children.toArray(e).some(zs)}function Ox(e){let t=ot(),{className:n,t:o,onSave:r,preset:i=true,overflow:a=true,children:l}=e,c=useMemo(()=>({t:o,onSave:r}),[o,r]),s=ga(o),d=O(Lx),m=O(Fx),p=useMemo(()=>Nx(d),[d]),g=useMemo(()=>new Set(p.flatMap(v=>v.entries.map(y=>y.slot))),[p]),u=useMemo(()=>p.map(v=>v.id).filter(v=>!Gl.has(v)),[p]),f=useMemo(()=>Eu(u),[u]),b=i&&a,{attach:x,overflow:T}=Fu(b,u,f),h;if(!i)h=l;else {let v=Children.toArray(l),y=new Map,S=new Map,w=[];for(let D of v){let F=$s(D);F&&g.has(F)?y.set(F,D):F&&gm.includes(F)?S.set(F,D):w.push(D);}let P=D=>{let F=y.get(D.slot);if(F)return F;let M=D.Part;return jsx(M,{})},R=[],E=[],L=0;for(let D of p){if(T.has(D.id)){let M=D.entries.flatMap(_=>{let k=Zx(_,y,s,D.labelKey,P);return k===null?[]:[jsx(Fragment$1,{children:k},_.slot)]});if(M.length===0)continue;E.push({id:D.id,labelKey:D.labelKey,children:M});continue}L>0&&R.push(jsx(sn,{},`separator-${D.id}`)),L+=1;let F=Gl.has(D.id);R.push(jsx("div",{className:"docx-toolbar__group",...F?{[nr]:""}:{[or]:D.id},children:D.entries.map(M=>jsx(Fragment$1,{children:P(M)},M.slot))},D.id));}h=jsxs(Fragment,{children:[R,jsx(dm,{overrides:S}),w.length>0?jsx("div",{className:"docx-toolbar__group",[nr]:"",children:w}):null,E.length>0?jsx(Zu,{sections:E}):null]});}return jsx(fo.Provider,{value:c,children:jsx(Su,{children:jsx("fieldset",{ref:x,disabled:m,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${n?` ${n}`:""}`,...b?{"data-overflow":""}:{},onMouseDown:B,children:Hx(l,i)?jsx(As,{children:h}):h})})})}function Bx(e){return e?!!e.props.hidden:false}function Zx(e,t,n,o,r){let i=t.get(e.slot);return Bx(i)?null:i||Ax(e.slot)?jsx(Ou,{label:qx(n,e,o),children:r(e)}):jsx(Bu,{slot:e.slot})}function qx(e,t,n){let o=t.slot==="alignment"?null:J(t.slot);return e(o?.labelKey??n)}var Er=Object.assign(Ox,{Button:go,Action:Ts,Separator:sn,Undo:ju,Redo:Yu,Bold:Xu,Italic:Ju,Underline:Qu,Strike:ep,Link:ss,ClearFormatting:tp,Superscript:op,Subscript:np,Alignment:Ga,AlignLeft:rp,AlignCenter:ap,AlignRight:ip,AlignJustify:lp,LineSpacing:bs,BulletList:sp,NumberedList:cp,Outdent:dp,Indent:up,ImageInsert:qn,ImageProperties:ln,ImageWrap:ar,ImageAltText:ir,TableInsert:pp,TableBorderTarget:yr,TableBorderColor:Tr,TableBorderStyle:xr,TableBorderWidth:Sr,TableCellFill:Cr,Comments:mp,FontFamily:ws,FontSize:ms,FontColor:ys,Highlight:xs,Zoom:fs,StylePicker:Ds,EditingMode:_a,Save:cs,ContentControlShowAll:Xa,ContentControlFormFill:Ja,ContentControlInspector:ei,ContentControlRemove:Qa});var Vx=e=>e.pageSetup??null,Ux=e=>e.editable;function Eo(){let e=H(),t=O(Vx),n=O(Ux),o=useMemo(()=>n&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,n]),r=useCallback(i=>e?e.exec({...i.pageWidthTwips!==void 0?{pageWidth:i.pageWidthTwips}:{},...i.pageHeightTwips!==void 0?{pageHeight:i.pageHeightTwips}:{},...i.orientation!==void 0?{orientation:i.orientation}:{},...i.marginTopTwips!==void 0?{marginTop:i.marginTopTwips}:{},...i.marginRightTwips!==void 0?{marginRight:i.marginRightTwips}:{},...i.marginBottomTwips!==void 0?{marginBottom:i.marginBottomTwips}:{},...i.marginLeftTwips!==void 0?{marginLeft:i.marginLeftTwips}:{},...i.scope!==void 0?{scope:i.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}],Pm=1440,Wx=e=>Math.round(e/Pm*100)/100,Gx=e=>Math.round(e*Pm);function jx(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 Yx={position:"fixed",inset:0,backgroundColor:"var(--doc-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},Xx={backgroundColor:"var(--doc-surface)",borderRadius:8,boxShadow:"0 4px 20px var(--doc-shadow)",minWidth:400,maxWidth:480,width:"100%",margin:20},Jx={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600,color:"var(--doc-text)"},Qx={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},xm={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},ai={display:"flex",alignItems:"center",gap:12},ii={width:80,fontSize:13,color:"var(--doc-text-muted)"},li={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13,backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},eS={fontSize:11,color:"var(--doc-text-muted)",width:16},tS={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},Sm={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer",backgroundColor:"var(--doc-surface)",color:"var(--doc-text)"},Tm=12240,Cm=15840,jt=1440;function wr({open:e,onClose:t,className:n}){let{t:o}=N(),{pageSetup:r,isEnabled:i,apply:a}=Eo(),[l,c]=useState(Tm),[s,d]=useState(Cm),[m,p]=useState("portrait"),[g,u]=useState(jt),[f,b]=useState(jt),[x,T]=useState(jt),[h,v]=useState(jt),[y,S]=useState("document"),w=useRef(null),P=useRef("no");useEffect(()=>{if(!e){P.current="no";return}if(P.current==="yes"&&r===null){P.current="no";return}P.current==="yes"||P.current==="loading"&&r===null||(c(r?.pageWidthTwips??Tm),d(r?.pageHeightTwips??Cm),p(r?.orientation??"portrait"),u(r?.marginsTwips.top??jt),b(r?.marginsTwips.bottom??jt),T(r?.marginsTwips.left??jt),v(r?.marginsTwips.right??jt),S("document"),P.current=r===null?"loading":"yes");},[e,r]),useEffect(()=>{e&&w.current?.focus();},[e]);let R=useCallback(M=>{let _=Us[M];_&&(c(m==="landscape"?_.height:_.width),d(m==="landscape"?_.width:_.height));},[m]),E=useCallback(M=>{M!==m&&(p(M),c(s),d(l));},[m,l,s]),L=useCallback(()=>{a({pageWidthTwips:l,pageHeightTwips:s,orientation:m,marginTopTwips:g,marginRightTwips:h,marginBottomTwips:f,marginLeftTwips:x,scope:y})&&t();},[a,l,s,m,g,h,f,x,y,t]);if(!e)return null;let D=jx(l,s),F=(M,_,k)=>jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o(`dialogs.pageSetup.${M}`)}),jsx("input",{type:"number",style:li,min:0,max:22,step:.1,value:Wx(_),onChange:I=>k(Math.max(0,Gx(Number(I.target.value)||0))),"aria-label":o(`dialogs.pageSetup.${M}`)}),jsx("span",{style:eS,children:"in"})]});return jsx("div",{className:n,style:Yx,onClick:t,onKeyDown:M=>{M.key==="Escape"&&t(),M.key==="Enter"&&L();},children:jsxs("div",{ref:w,tabIndex:-1,style:Xx,onClick:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o("dialogs.pageSetup.title"),children:[jsx("div",{style:Jx,children:o("dialogs.pageSetup.title")}),jsxs("div",{style:Qx,children:[jsx("div",{style:xm,children:o("dialogs.pageSetup.pageSize")}),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.sizeLabel")}),jsxs("select",{style:li,value:D,onChange:M=>R(Number(M.target.value)),"aria-label":o("dialogs.pageSetup.sizeLabel"),children:[Us.map((M,_)=>jsx("option",{value:_,children:o(M.labelKey)},M.labelKey)),D<0&&jsx("option",{value:-1,children:o("dialogs.pageSetup.custom")})]})]}),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.orientation")}),jsxs("select",{style:li,value:m,onChange:M=>E(M.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:{...xm,marginTop:4},children:o("dialogs.pageSetup.margins")}),F("top",g,u),F("bottom",f,b),F("left",x,T),F("right",h,v),jsxs("div",{style:ai,children:[jsx("label",{style:ii,children:o("dialogs.pageSetup.applyTo")}),jsxs("select",{style:li,value:y,onChange:M=>S(M.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:tS,children:[jsx("button",{type:"button",style:Sm,onClick:t,children:o("common.cancel")}),jsx("button",{type:"button",style:{...Sm,backgroundColor:"var(--doc-primary)",color:"var(--doc-on-primary)",borderColor:"var(--doc-primary)",opacity:i?1:.5},disabled:!i,onClick:L,children:o("common.apply")})]})]})})}var kr=createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0});function nt(){return useContext(kr)}function Fe(){let{t:e}=nt(),{t}=N();return n=>e?.(n)??t(n)}var rS=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,aS=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var Em=new TextEncoder;function iS(e,t){if(Em.encode(e).length<=t)return e;let n=0,o="";for(let r of e){let i=Em.encode(r).length;if(n+i>t)break;n+=i,o+=r;}return o}function wm(e){let t=iS((e??"").replace(/\.docx$/i,"").replace(aS," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||rS.test(t)?"document.docx":`${t}.docx`}function km(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 lS="https://github.com/eigenpal/docx-editor/issues/new";function sS(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Rm(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??sS()}`,`- Viewport: ${n.width} x ${n.height}`,`- User agent: ${t}`,""].join(`
2
+ `),i=new URLSearchParams({title:"[Bug] ",body:r});return `${lS}?${i.toString()}`}function Rr(e){typeof window>"u"||window.open(Rm(e),"_blank","noopener,noreferrer");}var Ws=6,Im=6;function Be(e){let{icon:t,shortcut:n,disabled:o,title:r,active:i,selected:a,slot:l,onSelect:c,className:s,children:d}=e,m=useId(),p=o&&r?m:void 0;return jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${s?` ${s}`:""}`,tabIndex:-1,...l?{"data-slot":l}:{},...i?{"data-active":""}:{},...o?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...p?{"aria-describedby":p}:{},...r?{title:r}:{},onMouseDown:B,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,p?jsx("span",{id:m,className:"docx-editor-sr-only",children:r}):null]})}function Ir({label:e,labelKey:t,className:n,hidden:o,children:r}){let i=Fe();if(o)return null;let a=e??(t===void 0?void 0:i(t));return jsxs("div",{role:"group",className:`docx-menubar__group${n?` ${n}`:""}`,...a?{"aria-label":a}:{},children:[a?jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function Ot({slot:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let{execute:i,isActive:a,isEnabled:l,disabledReason:c}=le(e),{setOpenMenu:s}=nt(),d=Fe();if(r)return null;let m=J(e),p=d(t??m?.labelKey??e),g=commandForSlot(e),u=g?.type==="toggleMark"||g?.type==="setAlignment",f=g?.type==="setAlignment";return jsx(Be,{slot:e,icon:re(m?.paths),...n?{shortcut:d(n)}:{},disabled:!l,...c?{title:c}:{},...u?{active:a}:{},...f?{selected:true}:{},onSelect:()=>{i(),s(null);},...o?{className:o}:{},children:p})}Ot.docxMenuRow=true;function Dm(e,t,n,o){return Object.assign(({className:i,hidden:a})=>{let l=nt(),c=Fe(),s=o(l);if(a)return null;let d=J(e),m=c(t??d?.labelKey??e);return jsx(Be,{slot:e,icon:re(d?.paths),...n?{shortcut:c(n)}:{},disabled:!s,onSelect:()=>{s?.(),l.setOpenMenu(null);},...i?{className:i}:{},children:m})},{docxSlot:e})}var js=Dm("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Ys=Dm("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function mS({className:e,hidden:t}){let n=H(),o=nt(),r=Fe(),i=chromeProbeForSlot("file.pageSetup"),a=n&&i?n.can(i):null,l=a?.ok===true,c=a&&!a.ok?a.reason:null;if(t)return null;let s=J("file.pageSetup"),d=r(s?.labelKey??"file.pageSetup"),m=l&&!!o.onPageSetup;return jsx(Be,{slot:"file.pageSetup",icon:re(s?.paths),disabled:!m,...c?{title:c}:{},onSelect:()=>{o.onPageSetup?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}function fS({className:e,hidden:t}){let n=H(),o=nt(),r=Fe(),i=chromeProbeForSlot("paragraph.dialog"),a=n&&i?n.can(i):null,l=a?.ok===true,c=a&&!a.ok?a.reason:null;if(t)return null;let s=J("paragraph.dialog"),d=r(s?.labelKey??"lineSpacing.options"),m=l&&!!o.onParagraphDialog;return jsx(Be,{slot:"paragraph.dialog",icon:re(s?.paths),disabled:!m,...c?{title:c}:{},onSelect:()=>{o.onParagraphDialog?.(),o.setOpenMenu(null);},...e?{className:e}:{},children:d})}var gS=Object.assign(fS,{docxSlot:"paragraph.dialog"}),Xs=Object.assign(mS,{docxSlot:"file.pageSetup"});function bS({className:e,hidden:t}){let{openFilePicker:n,isEnabled:o,disabledReason:r}=ha(),i=nt(),a=Fe();if(t)return null;let l=J("image.insert"),c=a(l?.labelKey??"toolbar.image");return jsx(Be,{slot:"image.insert",icon:re(l?.paths),disabled:!o,...r?{title:r}:{},onSelect:()=>{n(),i.setOpenMenu(null);},...e?{className:e}:{},children:c})}var hS=Object.assign(bS,{docxSlot:"image.insert"}),Mr=8;function ko({labelKey:e,paths:t,className:n,children:o}){let r=Fe(),[i,a]=useState(false),l=useRef(null),c=useRef(null),s=useId(),d=r(e),[m,p]=useState(null);return useLayoutEffect(()=>{if(!i){p(null);return}let g=l.current,u=c.current,f=g?.ownerDocument.defaultView;if(!g||!u||!f)return;let b=g.getBoundingClientRect(),x=u.offsetWidth,T=u.offsetHeight,h=b.right+x>f.innerWidth-Mr;p({left:h?Math.max(Mr,b.left-x):Math.min(b.right,f.innerWidth-x-Mr),top:Math.max(Mr,Math.min(b.top-4,f.innerHeight-T-Mr))});},[i]),jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),onKeyDown:g=>{g.key==="ArrowRight"&&document.activeElement===l.current?(g.preventDefault(),a(true),queueMicrotask(()=>{c.current&&yt(Po(c.current),"first");})):(g.key==="ArrowLeft"||g.key==="Escape")&&i&&(g.preventDefault(),g.stopPropagation(),a(false),l.current?.focus());},onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||a(false);},children:[jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?s:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...i?{"data-open":""}:{},onMouseDown:B,onFocus:()=>a(true),onClick:()=>a(true),children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(t)}),jsx("span",{className:"docx-menubar__item-label",children:d}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),i?jsx("div",{ref:c,id:s,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:m?{position:"fixed",left:m.left,top:m.top}:{position:"fixed",visibility:"hidden"},onKeyDown:g=>{let u=c.current;if(!u)return;let f=Po(u);g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),vt(f,document.activeElement,1)):g.key==="ArrowUp"&&(g.preventDefault(),g.stopPropagation(),vt(f,document.activeElement,-1));},children:o}):null]})}function ci({slot:e="table.insert",className:t}){let n=H(),{isEnabled:o}=le(e),{setOpenMenu:r}=nt(),i=Fe(),[a,l]=useState(null),[c,s]=useState({rows:1,cols:1}),d=useRef(null),m=useCallback((u,f)=>{if(!n||!o)return;let b={type:"insertTable",rows:u,cols:f};n.can(b).ok&&(n.exec(b),r(null),n.focus());},[n,o,r]),p=useCallback(u=>{s(f=>{let b={rows:Math.min(Im,Math.max(1,f.rows+(u.rows??0))),cols:Math.min(Ws,Math.max(1,u.toCol??f.cols+(u.cols??0)))};return l(b),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${b.rows}x${b.cols}"]`)?.focus()),b});},[]),g=[];for(let u=1;u<=Im;u+=1){let f=[];for(let b=1;b<=Ws;b+=1){let x=!!a&&u<=a.rows&&b<=a.cols;f.push(jsx("button",{type:"button",role:"gridcell","data-cell":`${u}x${b}`,className:"docx-menubar__grid-cell",tabIndex:c.rows===u&&c.cols===b?0:-1,...x?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${u}`,onMouseDown:B,onMouseEnter:()=>l({rows:u,cols:b}),onFocus:()=>l({rows:u,cols:b}),onClick:()=>m(u,b)},b));}g.push(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},u));}return jsxs("div",{ref:d,role:"grid","aria-label":i("toolbar.insertTable"),className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>l(null),onKeyDown:u=>{if(u.key==="ArrowRight")p({cols:1});else if(u.key==="ArrowLeft")p({cols:-1});else if(u.key==="ArrowDown")p({rows:1});else if(u.key==="ArrowUp")p({rows:-1});else if(u.key==="Home")p({toCol:1});else if(u.key==="End")p({toCol:Ws});else return;u.preventDefault(),u.stopPropagation();},children:[jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function vS({entry:e}){let{isEnabled:t}=le(e.slot),n=J(e.slot);return t?jsx(ko,{labelKey:e.labelKey??n?.labelKey??e.slot,paths:n?.paths,children:jsx(ci,{slot:e.slot})}):jsx(Ot,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Ro({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function _r({entry:e}){return e.kind==="separator"?jsx(Ro,{}):e.kind==="submenu"?jsx(ko,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,n)=>jsx(_r,{entry:t},n))}):e.slot==="file.open"?jsx(js,{}):e.slot==="file.save"?jsx(Ys,{}):e.slot==="file.pageSetup"?jsx(Xs,{}):e.slot==="paragraph.dialog"?jsx(gS,{}):e.slot==="image.insert"?jsx(hS,{}):e.picker==="tableGrid"?jsx(vS,{entry:e}):jsx(Ot,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Nm(e){if(!isValidElement(e))return null;let t=nn(e,Nm);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 yS(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function xS(e,t,n){return Na({entries:e??[],children:t,preset:n,keyOfEntry:yS,keyOfChild:Nm,renderEntry:o=>jsx(_r,{entry:o})})}function pn({id:e,labelKey:t,label:n,icon:o,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:c,setOpenMenu:s,activeMenu:d}=nt(),m=Fe(),p=useId(),g=useRef(null),u=useRef(null),f=useRef(false),b=useRef(false),x=CHROME_MENUS.find(S=>S.id===e),T=c===e;if(i)return null;let h=n??m(t??x?.labelKey??e),v=xS(x?.entries,l,a),y=()=>{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":T,"aria-controls":T?p:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...T?{"data-open":""}:{},onMouseDown:B,onKeyDown:S=>{S.key==="ArrowDown"||S.key==="Enter"||S.key===" "||S.key==="ArrowUp"?(S.preventDefault(),f.current=true,s(e)):S.key==="Escape"&&T&&(S.preventDefault(),y());},onClick:()=>{if(b.current){b.current=false;return}s(T?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,h]}),T?jsx("div",{ref:S=>{u.current=S,S&&f.current&&(f.current=false,yt(Po(S),"first"));},id:p,role:"menu","aria-label":h,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:S=>{let w=u.current;if(!w)return;let P=Po(w),R=document.activeElement;S.key==="ArrowDown"?(S.preventDefault(),vt(P,R,1)):S.key==="ArrowUp"?(S.preventDefault(),vt(P,R,-1)):S.key==="Home"?(S.preventDefault(),yt(P,"first")):S.key==="End"?(S.preventDefault(),yt(P,"last")):S.key==="Escape"?(S.preventDefault(),S.stopPropagation(),y()):S.key==="Tab"&&s(null);},children:v}):null]})}function Js(e){return Object.assign(n=>jsx(pn,{id:e,...n}),{docxMenu:e})}var Qs=Js("file"),ec=Js("format"),tc=Js("insert");function SS({className:e,hidden:t,onSelect:n}){let{setOpenMenu:o,onReportIssue:r,reportIssue:i}=nt(),a=Fe();if(t||i===false)return null;let l=n??r??Rr;return jsx(Be,{slot:"help.reportIssue",onSelect:()=>{l(),o(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var di=Object.assign(SS,{docxSlot:"help.reportIssue"});function TS({children:e,...t}){let{reportIssue:n}=nt();return e===void 0&&n===false?null:jsxs(pn,{id:"help",...t,children:[jsx(di,{}),e]})}var oc=Object.assign(TS,{docxMenu:"help"});var ES={file:Qs,format:ec,insert:tc,help:oc},wS=new Set(CHROME_MENUS.map(e=>e.id));function Zm(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let o=Children.toArray(e.props.children).map(Zm).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===pn){let n=e.props.id;if(typeof n=="string"&&wS.has(n))return n}return null}function kS(e){let t=ot(),{className:n,t:o,fileName:r,onOpen:i,onOpenFile:a,onSave:l,onPageSetup:c,onReportIssue:s,reportIssue:d,preset:m=true,children:p}=e,g=H(),{t:u}=N(),[f,b]=useState(null),[x,T]=useState(null),[h,v]=useState(null),[y,S]=useState(false),[w,P]=useState(false),R=useRef(null),E=useRef(null);useEffect(()=>{if(f===null)return;let $=oe=>{let ne=R.current;ne&&oe.target instanceof Node&&ne.contains(oe.target)||b(null);},V=oe=>{oe.key==="Escape"&&b(null);};return document.addEventListener("mousedown",$),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",V);}},[f]);let L=useCallback($=>{b($),$!==null&&v($);},[]),D=useCallback(()=>E.current?.click(),[]),F=useCallback(()=>{g&&g.save().then($=>km($,wm(r??x??void 0))).catch($=>{console.error("[docx-editor] save failed",$);});},[g,r,x]),M=useCallback(()=>S(true),[]),_=g?i??D:void 0,k=g?l??F:void 0,I=g?c??M:void 0;useEffect(()=>{let $=V=>{if(!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey)return;let oe=V.key.toLowerCase();if(oe!=="s"&&oe!=="o")return;let ne=V.target,be=cn(R.current)??R.current;!ne||!be?.contains(ne)||(oe==="s"&&k?(V.preventDefault(),k()):oe==="o"&&_&&(V.preventDefault(),_()));};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[_,k]);let ae=useMemo(()=>({t:o,openMenu:f,setOpenMenu:L,activeMenu:h,onOpen:_,onSave:k,onPageSetup:I,onParagraphDialog:()=>P(true),onReportIssue:s,reportIssue:d}),[o,f,L,h,_,k,I,s,d]),K;if(!m)K=p;else {let $=new Map,V=[];for(let oe of Children.toArray(p)){let ne=Zm(oe);ne?$.set(ne,oe):V.push(oe);}K=jsxs(Fragment,{children:[CHROME_MENUS.map(oe=>{let ne=$.get(oe.id);if(ne)return jsx(Fragment$1,{children:ne},oe.id);let be=ES[oe.id];return jsx(be,{},oe.id)}),V]});}return jsxs(kr.Provider,{value:ae,children:[jsx("div",{ref:$=>{if(R.current=$,$&&h===null){let V=Hs($)[0]?.closest("[data-menu]")?.getAttribute("data-menu");V&&v(V);}},role:"menubar","aria-label":o?.("titleBar.menuBarAriaLabel")??u("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${t}docx-menubar${n?` ${n}`:""}`,onMouseDown:B,onKeyDown:$=>{if($.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;let V=R.current;if(!V)return;let oe=Hs(V),ne=oe.indexOf(document.activeElement);if(ne===-1)return;$.preventDefault();let be=$.key==="ArrowRight"?1:-1,he=oe[(ne+be+oe.length)%oe.length],W=he?.closest("[data-menu]")?.getAttribute("data-menu");W&&(v(W),he?.focus(),f!==null&&b(W));},children:K}),jsx("input",{ref:E,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:$=>{let V=$.target.files?.[0];$.target.value="",!(!V||!g)&&(T(V.name),a?.(V),V.arrayBuffer().then(oe=>g.load(new Uint8Array(oe))).catch(oe=>{console.error("[docx-editor] could not open the file",oe);}));}}),jsx(wr,{open:y,onClose:()=>S(false)}),jsx(To,{open:w,onClose:()=>P(false)})]})}var Nr=Object.assign(kS,{Menu:pn,File:Qs,Format:ec,Insert:tc,Help:oc,Item:Ot,Row:Be,Group:Ir,Separator:Ro,Submenu:ko,TableGrid:ci,Entry:_r,Open:js,Save:Ys,PageSetup:Xs,ReportIssue:di});var DS=12240,Km=1440,Um=1440,Wm=567,Mo=20,rc=6,NS=Mo+rc+2,LS="var(--doc-text-muted)",FS="var(--doc-text-subtle)",$m="var(--doc-shadow-subtle)",AS="var(--doc-primary)",HS="var(--doc-primary-hover)",OS="var(--doc-text-subtle)",Fr=5,Lr=7,BS={left:0,right:0,firstLine:0};function Vm(e,t){return t==="inch"?(e/Um).toFixed(2)+'"':(e/Wm).toFixed(1)+" cm"}function ZS(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function Io({pageSetup:e,zoom:t=1,editable:n=false,onLeftMarginChange:o,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:c=false,onIndentChange:s,onIndentDragEnd:d,unit:m="inch",className:p="",style:g,tabMarks:u,onTabMarkRemove:f}){let{t:b}=N(),[x,T]=useState(null),[h,v]=useState(null),[y,S]=useState(null),[w,P]=useState(null),R=useRef(null),E=e?.pageWidthTwips??DS,L=e?.marginsTwips.left??Km,D=e?.marginsTwips.right??Km,F=e?.gutterTwips??0,M={pageWidth:E,leftMargin:L,rightMargin:D},_=l??BS,k=Pe(E)*t,I=Pe(L)*t,ae=Pe(D)*t,K=useCallback(Z=>{let we=R.current?.getBoundingClientRect();return we?Ta((Z-we.left)/t):null},[t]),$=useCallback((Z,we,ce)=>{let de=K(we);if(de===null)return;if(P(Pe(de)*t),Z==="leftMargin"||Z==="rightMargin"){if(Z==="leftMargin"){let uo=E-D-F-720,mt=Math.round(Math.max(0,Math.min(de,uo)));S(mt),o?.(mt);}else {let uo=E-de,mt=E-L-F-720,po=Math.round(Math.max(0,Math.min(uo,mt)));S(po),r?.(po);}return}let Ve=dragIndent(Z,de,_,M,{unit:m,precise:ce});S(Z==="right"?Ve.right:Z==="firstLine"?Ve.firstLine:Ve.left),s?.(Ve);},[K,t,E,L,D,F,o,r,s,_,M,m]),V=useCallback(Z=>{Z==="leftMargin"||Z==="rightMargin"?i?.():d?.(),T(null),S(null),P(null);},[i,d]),oe=useCallback((Z,we,ce)=>{let de=handlePosition(Z,_,M),Ve=dragIndent(Z,de+we*ZS(m,ce),_,M,{unit:m,precise:true});s?.(Ve),d?.();},[_,M,m,s,d]),ne=US(E,t,m),be=a&&c&&s!==void 0,he=Z=>Pe(handlePosition(Z,_,M))*t,W=(Z,we,ce)=>({positionPx:he(Z),editable:be,isDragging:x===Z,isHovered:h===Z,onPointerEnter:()=>v(Z),onPointerLeave:()=>v(null),onPointerDown:de=>{be&&(de.preventDefault(),de.stopPropagation(),de.currentTarget.setPointerCapture(de.pointerId),T(Z));},onPointerMove:de=>{x===Z&&$(Z,de.clientX,de.altKey);},onPointerUp:de=>{x===Z&&(de.currentTarget.releasePointerCapture(de.pointerId),V(Z));},onKeyDown:de=>{be&&(de.key!=="ArrowLeft"&&de.key!=="ArrowRight"||(de.preventDefault(),oe(Z,de.key==="ArrowLeft"?-1:1,de.shiftKey)));},label:b(we),valueNow:ce,valueText:Vm(ce,m),pageWidthTwips:E});return jsxs("div",{ref:R,className:`docx-horizontal-ruler ${p}`,style:{position:"relative",width:Ye(k),height:NS,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:x?"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:Ye(I),height:Mo,backgroundColor:$m,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&o?Z=>{Z.preventDefault(),Z.currentTarget.setPointerCapture(Z.pointerId),T("leftMargin");}:void 0,onPointerMove:Z=>x==="leftMargin"&&$("leftMargin",Z.clientX,Z.altKey),onPointerUp:Z=>{x==="leftMargin"&&(Z.currentTarget.releasePointerCapture(Z.pointerId),V("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:Ye(ae),height:Mo,backgroundColor:$m,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:n?"ew-resize":"default",zIndex:1},onPointerDown:n&&r?Z=>{Z.preventDefault(),Z.currentTarget.setPointerCapture(Z.pointerId),T("rightMargin");}:void 0,onPointerMove:Z=>x==="rightMargin"&&$("rightMargin",Z.clientX,Z.altKey),onPointerUp:Z=>{x==="rightMargin"&&(Z.currentTarget.releasePointerCapture(Z.pointerId),V("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Mo,pointerEvents:"none"},children:ne.map((Z,we)=>jsx(qS,{tick:Z},we))}),u?.map(Z=>jsx(VS,{tabMark:Z,positionPx:Pe(Z.position)*t,onDoubleClick:()=>f?.(Z.position)},Z.position)),a&&jsxs(Fragment,{children:[jsx(nc,{direction:"down",anchor:"top",...W("firstLine","ruler.firstLineIndent",_.firstLine)}),jsx(nc,{direction:"up",anchor:"strip",...W("hanging","ruler.hangingIndent",_.left)}),jsx(zS,{...W("left","ruler.leftIndent",_.left)}),jsx(nc,{direction:"up",anchor:"strip",...W("right","ruler.rightIndent",_.right)})]}),x&&y!==null&&w!==null&&jsx(KS,{value:Vm(y,m),positionPx:w})]})}function qS({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ye(e.position),bottom:0,width:1,height:e.height,backgroundColor:FS}}),e.label&&jsx("div",{style:{position:"absolute",left:Ye(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:LS,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Gm(e){return e.editable?e.isDragging||e.isHovered?HS:AS:OS}function jm(e,t,n){return {position:"absolute",left:Ye(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...n}}function Ym(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 nc({direction:e,anchor:t,...n}){let o=Gm(n),r=t==="top"?{top:0,height:Lr+1}:{top:Mo-Lr,height:Lr};return jsx("div",{className:"docx-ruler-indent",style:jm(n,Fr*2,r),onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onKeyDown:n.onKeyDown,...Ym(n),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Fr}px solid transparent`,borderRight:`${Fr}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 zS(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:jm(e,Fr*2,{top:Mo+1,height:rc}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Ym(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:Fr*2-2,height:rc,backgroundColor:Gm(e),borderRadius:1,transition:"background-color 0.1s"}})})}function KS({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:Ye(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 $S={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function VS({tabMark:e,positionPx:t,onDoubleClick:n}){return jsx("div",{style:{position:"absolute",left:Ye(t-5),top:Mo-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:$S[e.alignment]||"L"})}function US(e,t,n){let o=[];if(n==="inch"){let r=Um/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;a%8===0?o.push({position:c,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?o.push({position:c,height:5}):a%2===0?o.push({position:c,height:3}):o.push({position:c,height:2});}}else {let r=Wm/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;a%10===0?o.push({position:c,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?o.push({position:c,height:5}):o.push({position:c,height:3});}}return o}var jS=15840,Qm=1440,YS=1440,XS=567,fn=20,JS="var(--doc-text-muted)",QS="var(--doc-text-subtle)",eT="var(--doc-primary)",tT="var(--doc-primary)",oT="var(--doc-primary-hover)";function Ar({pageSetup:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:c}){let{t:s}=N(),[d,m]=useState(null),[p,g]=useState(null),u=useRef(null),f=e?.pageHeightTwips??jS,b=e?.marginsTwips.top??Qm,x=e?.marginsTwips.bottom??Qm,T=Pe(f)*t,h=Pe(b)*t,v=Pe(x)*t,y=useCallback((E,L)=>{n&&(E.preventDefault(),m(L));},[n]),S=useCallback(E=>{if(!d||!u.current)return;let L=u.current.getBoundingClientRect(),D=E.clientY-L.top,F=Ta(D/t);if(d==="topMargin"){let M=f-x-720,_=Math.max(0,Math.min(F,M));o?.(Math.round(_));}else if(d==="bottomMargin"){let M=f-F,_=f-b-720,k=Math.max(0,Math.min(M,_));r?.(Math.round(k));}},[d,t,f,b,x,o,r]),w=useCallback(()=>{d!==null&&i?.(),m(null);},[d,i]);useEffect(()=>{if(d)return document.addEventListener("mousemove",S),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",w);}},[d,S,w]);let P=rT(f,t,a),R={position:"relative",width:fn,height:Ye(T),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...c};return jsxs("div",{ref:u,className:`docx-vertical-ruler ${l}`,style:R,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:P.map((E,L)=>jsx(nT,{tick:E},L))}),jsx(ef,{type:"topMargin",position:h,editable:n,isDragging:d==="topMargin",isHovered:p==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>y(E,"topMargin")}),jsx(ef,{type:"bottomMargin",position:T-v,editable:n,isDragging:d==="bottomMargin",isHovered:p==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>y(E,"bottomMargin")})]})}function nT({tick:e}){let t={position:"absolute",top:Ye(e.position),right:0,height:1,width:e.width,backgroundColor:QS},n={position:"absolute",top:Ye(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:JS,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function ef({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:l}){let{t:c}=N(),s=o?oT:r?tT:eT,d={position:"absolute",top:Ye(t-5),right:0,width:fn,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},m={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:i,onMouseLeave:a,onMouseDown:l,role:"slider","aria-label":c(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:m})})}function rT(e,t,n){let o=[];if(n==="inch"){let r=YS/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;if(a%8===0){let s=a/8;o.push({position:c,width:10,label:s>0?String(s):void 0});}else a%4===0?o.push({position:c,width:6}):a%2===0?o.push({position:c,width:4}):o.push({position:c,width:2});}}else {let r=XS/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let c=Pe(l)*t;if(a%10===0){let s=a/10;o.push({position:c,width:10,label:s>0?String(s):void 0});}else a%5===0?o.push({position:c,width:6}):o.push({position:c,width:3});}}return o}var _o=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var lT=e=>e.formatting?.indent??null,sT=e=>e.editable;function lc(){let e=H(),t=O(lT),n=O(sT),o=useMemo(()=>n&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,n]),r=useCallback(i=>e?e.exec({...i.left!==void 0?{left:i.left}:{},...i.right!==void 0?{right:i.right}:{},...i.firstLine!==void 0?{firstLine:i.firstLine}:{},type:"setIndent"}).ok:false,[e]);return useMemo(()=>({indent:t,isEnabled:o,apply:r}),[t,o,r])}var af=e=>e.zoom,dT=e=>e.isOpening===true;function lf(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function sf(){let{apply:e}=Eo(),[t,n]=useState({}),o=useRef({}),r=useCallback(a=>l=>{o.current={...o.current,[a]:Math.round(l)},n(o.current);},[]),i=useCallback(()=>{let a=o.current;o.current={},n({}),Object.keys(a).length!==0&&e({...a.top!==void 0?{marginTopTwips:a.top}:{},...a.right!==void 0?{marginRightTwips:a.right}:{},...a.bottom!==void 0?{marginBottomTwips:a.bottom}:{},...a.left!==void 0?{marginLeftTwips:a.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:i}}function rf(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function uT(){let e=H(),{indent:t,isEnabled:n,apply:o}=lc(),[r,i]=useState(null),a=useRef(null),l=useRef(null),c=useCallback(m=>{l.current===null&&(l.current=rf(e)),a.current=m,i(m);},[e]),s=useCallback(()=>{let m=a.current,p=l.current;a.current=null,l.current=null,i(null),m&&(p!==null&&p!==rf(e)||o({left:m.left,right:m.right,firstLine:m.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 pT(){let e=Ft(),[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 gi(e){let t=O(_o),n=O(dT),{pageSetup:o,isEnabled:r}=Eo(),i=O(af),{pending:a,preview:l,commit:c}=sf(),s=uT(),d=xo(),m=on(),p=pT();return t?null:jsx("div",{className:`docx-ruler-frame${n?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+m.inlineStart,paddingRight:m.inlineEnd},children:jsx(Io,{pageSetup:lf(o,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:c,showIndentHandles:s.indent!==null,indent:s.indent,indentEditable:s.isEnabled,onIndentChange:s.preview,onIndentDragEnd:s.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-p}px)`,clipPath:d>0&&p>0?`inset(0 0 0 ${p}px)`:e.style?.clipPath}})})}function bi(e){let t=O(_o),{pageSetup:n,isEnabled:o}=Eo(),r=O(af),{pending:i,preview:a,commit:l}=sf(),c=xo(),s=on(),d=nu();return t||d!==null&&d>0&&n&&Pe(n.pageWidthTwips)*r>d-c-s.inlineStart-s.inlineEnd?null:jsx(Ar,{pageSetup:lf(n,i),zoom:r,editable:o,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function A({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 fT(e){return jsx(A,{...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 gT(e){return jsx(A,{...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 bT(e){return jsx(A,{...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 hT(e){return jsx(A,{...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 vT(e){return jsx(A,{...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 yT(e){return jsx(A,{...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 xT(e){return jsx(A,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function ST(e){return jsx(A,{...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 TT(e){return jsx(A,{...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 CT(e){return jsx(A,{...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 PT(e){return jsx(A,{...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 ET(e){return jsx(A,{...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 wT(e){return jsx(A,{...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 kT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function RT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function MT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function IT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function uc(e){return jsx(A,{...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 _T(e){return jsx(A,{...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 DT(e){return jsx(A,{...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 NT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function LT(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function FT(e){return jsx(A,{...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 AT(e){return jsx(A,{...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 HT(e){return jsx(A,{...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 OT(e){return jsx(A,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function BT(e){return jsx(A,{...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 ZT(e){return jsx(A,{...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 qT(e){return jsx(A,{...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 zT(e){return jsx(A,{...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 KT(e){return jsx(A,{...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 cf(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function $T(e){return jsx(A,{...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 VT(e){return jsx(A,{...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 UT(e){return jsx(A,{...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 WT(e){return jsx(A,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function GT(e){return jsx(A,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function jT(e){return jsx(A,{...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 YT(e){return jsx(A,{...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 XT(e){return jsx(A,{...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 JT(e){return jsx(A,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function QT(e){return jsx(A,{...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 eC(e){return jsx(A,{...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 tC(e){return jsx(A,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function oC(e){return jsx(A,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function nC(e){return jsx(A,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function rC(e){return jsx(A,{...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 aC(e){return jsx(A,{...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 iC(e){return jsx(A,{...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 lC(e){return jsx(A,{...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 sC(e){return jsx(A,{...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 cC(e){return jsx(A,{...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 dC(e){return jsx(A,{...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 uC(e){return jsx(A,{...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 pC(e){return jsx(A,{...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 mC(e){return jsx(A,{...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 fC(e){return jsx(A,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function gC(e){return jsx(A,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function bC(e){return jsx(A,{...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 hC(e){return jsx(A,{...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 vC(e){return jsx(A,{...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 yC(e){return jsx(A,{...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 xC(e){return jsx(A,{...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 SC(e){return jsx(A,{...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 TC(e){return jsx(A,{...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 CC(e){return jsx(A,{...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 PC(e){return jsx(A,{...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 EC(e){return jsx(A,{...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 wC(e){return jsx(A,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function kC(e){return jsx(A,{...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 RC(e){return jsx(A,{...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 MC(e){return jsx(A,{...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 IC(e){return jsx(A,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function _C(e){return jsx(A,{...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 DC(e){return jsx(A,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function NC(e){return jsx(A,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function LC(e){return jsx(A,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function FC(e){return jsx(A,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function AC(e){return jsx(A,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function HC(e){return jsx(A,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function OC(e){return jsx(A,{...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 BC(e){return jsx(A,{...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 ZC(e){return jsx(A,{...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 qC(e){return jsx(A,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function zC(e){return jsx(A,{...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 KC(e){return jsx(A,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function $C(e){return jsx(A,{...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 VC(e){return jsx(A,{...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 UC(e){return jsx(A,{...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 WC(e){return jsxs(A,{...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 GC(e){return jsx(A,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function jC(e){return jsx(A,{...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 YC(e){return jsx(A,{...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 XC(e){return jsx(A,{...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 JC(e){return jsx(A,{...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 QC(e){return jsx(A,{...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 eP(e){return jsx(A,{...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 tP(e){return jsx(A,{...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 oP(e){return jsx(A,{...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 nP(e){return jsx(A,{...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 rP={undo:fT,redo:gT,print:bT,file_download:hT,file_upload:vT,format_bold:yT,format_italic:xT,format_underlined:ST,strikethrough_s:TT,superscript:CT,subscript:PT,link:ET,format_clear:wT,format_align_left:kT,format_align_center:RT,format_align_right:MT,format_align_justify:IT,format_line_spacing:uc,format_list_bulleted:_T,format_list_numbered:DT,format_indent_increase:NT,format_indent_decrease:LT,format_color_text:FT,ink_highlighter:AT,format_color_reset:HT,arrow_drop_down:OT,table:BT,table_chart:ZT,grid_on:qT,table_rows:zT,view_column:KT,border_all:cf,select_all:cf,border_outer:$T,border_inner:VT,border_clear:UT,add:WT,remove:GT,delete:jT,delete_sweep:YT,call_merge:XT,call_split:JT,drag_indicator:QT,image:eC,format_image_left:tC,format_image_right:oC,horizontal_rule:nC,flip_to_back:rC,flip_to_front:aC,open_with:iC,tune:lC,rotate_right:sC,rotate_left:cC,swap_horiz:dC,swap_vert:uC,shapes:pC,format_paint:mC,expand_more:fC,expand_less:gC,border_top:bC,border_bottom:hC,border_left:vC,border_right:yC,border_horizontal:xC,border_vertical:SC,padding:TC,text_rotation_none:CC,wrap_text:PC,height:EC,fit_width:wC,settings:kC,border_color:RC,format_color_fill:MC,vertical_align_top:IC,vertical_align_center:_C,vertical_align_bottom:DC,line_weight:NC,keyboard_arrow_up:LC,keyboard_arrow_down:FC,keyboard_arrow_left:AC,keyboard_arrow_right:HC,more_vert:OC,page_break:BC,branding_watermark:ZC,arrow_back:qC,search:zC,toc:KC,done_all:$C,check_circle:VC,chat_bubble_outline:UC,chat_bubble_check:WC,check:GC,close:jC,add_comment:YC,comment:XC,edit_note:JC,rate_review:QC,visibility:eP,format_textdirection_l_to_r:tP,format_textdirection_r_to_l:oP,"agent-sparkle":nP};function z({name:e,size:t=20,className:n="",style:o}){let r=rP[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 Hr=12,pc=240,uf=16,cP=24,dP=Hr+pc+uf,gn=12,uP=36,pP=gn+uP+uf,Or=rt__default.memo(function({headings:t,onHeadingClick:n,onClose:o,topOffset:r=0,scrollLeft:i=0,leftOffset:a=Hr}){let{t:l}=N(),[c,s]=useState(false),d=t.length?Math.min(...t.map(m=>m.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:a-i,bottom:0,width:pc,paddingTop:cP,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:c?"translateX(0)":`translateX(-${a+pc}px)`,transition:"transform 0.15s ease-out"},onMouseDown:m=>m.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(z,{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((m,p)=>jsx("div",{style:{marginLeft:(m.level-d)*16},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>n(m.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:m.text,children:m.text})},`${m.blockId}-${p}`))})]})});var gP=e=>e,bP=Object.freeze([]),hP=()=>{};function mc(e){let t=H(),n=O(gP),o=useMemo(()=>t&&!n.isLoading?t.getOutline():bP,[t,n]),r=useCallback(i=>{if(!t)return;t.focus();let a={paragraphId:i,offset:0};t.exec({type:"setSelection",range:{anchor:a,head:a}}),t.scrollToBlock(i);},[t]);return _o(n)?null:jsx(Or,{headings:o,onHeadingClick:r,onClose:e.onClose??hP,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var fc=createContext(null);function Jt(e){let t=useContext(fc);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var bn=280,hi=32,pf=16;function No(e=280){return 32+e+16}function vi({viewportWidth:e,pageWidthPx:t,reservation:n,inlineEndReservation:o=0,inlineStartReservation:r=0,docked:i=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 a=(e-o-t)/2,l=a>=n?0:!i&&n<=2*a?2*(n-a):n;return Math.ceil(Math.max(0,l-r))}var CP=Object.freeze([]),PP=e=>e;function yi(){let e=H(),t=O(PP),[n,o]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():CP,[e,t]),i=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]),a=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:i,selectedBlockId:n,goTo:a,isEmpty:r.length===0}}var hc=150,vc=2e3,bc=Object.freeze([]),kP=e=>e;function xi(){let e=H(),t=O(kP),[n,o]=useState(""),[r,i]=useState(""),[a,l]=useState(false),[c,s]=useState(false),[d,m]=useState(bc),[p,g]=useState(-1);useEffect(()=>{if(n===r)return;let S=setTimeout(()=>i(n),hc);return ()=>clearTimeout(S)},[n,r]);let u=useMemo(()=>({matchCase:a,wholeWord:c}),[a,c]);useEffect(()=>{if(!e||r.length===0){m(bc),g(-1);return}let S=e.findMatches(r,u);m(w=>w===S?w:S);},[e,r,u,t]);let f=useRef(d);useEffect(()=>{f.current!==d&&(f.current=d,g(S=>S>=0&&S<d.length?S:-1));},[d]);let b=useCallback(S=>{if(!e)return;let w=d[S];if(!w)return;e.focus(),e.selectMatch(w).ok&&g(S);},[e,d]),x=useCallback(S=>{if(d.length===0)return;let P=((p<0?S>0?-1:0:p)+S+d.length)%d.length;b(P);},[p,b,d.length]),T=useCallback(()=>x(1),[x]),h=useCallback(()=>x(-1),[x]),v=useCallback(S=>o(S),[]),y=useCallback(()=>{o(""),i(""),m(bc),g(-1);},[]);return {query:n,setQuery:v,matchCase:a,setMatchCase:l,wholeWord:c,setWholeWord:s,matches:d,truncated:d.length>=vc,activeIndex:p,goTo:b,next:T,previous:h,clear:y,isPending:n!==r}}var NP=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)}},LP=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Si(e={}){let{defaultOpen:t=false,defaultTab:n="headings",paneWidth:o=280}=e,[r,i]=useState(t),[a,l]=useState(n),c=e.open??r,s=e.tab??a,{onOpenChange:d,onTabChange:m}=e,p=e.open!==void 0,g=e.tab!==void 0,u=useCallback(I=>{p||i(I),d?.(I);},[p,d]),f=useCallback(()=>u(!c),[c,u]),b=useCallback(I=>{g||l(I),m?.(I);},[g,m]),x=yo(),T=Ft(),h=useContext(ft),{pageSetup:v,zoom:y,reviewPaneOpen:S,fitting:w}=O(NP,LP),[P,R]=useState(0),[E,L]=useState(0),[D,F]=useState(0);useEffect(()=>{if(!T){R(0),L(0),F(0);return}let I=()=>{R(T.clientWidth);let K=getComputedStyle(T),$=Number.parseFloat(K.paddingInlineEnd);L(Number.isFinite($)?$:0);let V=Number.parseFloat(K.getPropertyValue("--docx-review-gutter-start"));F(Number.isFinite(V)?V:0);};if(I(),typeof ResizeObserver>"u")return;let ae=new ResizeObserver(I);return ae.observe(T),()=>ae.disconnect()},[T,c,S,h?.mounted]);let M=useRef(null);v&&(M.current=v.pageWidthTwips);let _=v?.pageWidthTwips??M.current,k=useMemo(()=>!c||_===null?0:vi({viewportWidth:P,pageWidthPx:Pe(_)*y,reservation:No(o),inlineEndReservation:E,inlineStartReservation:D,docked:w}),[c,_,y,P,o,E,D,w]);return useEffect(()=>{if(x)return x.setShift(k),()=>x.setShift(0)},[x,k]),useEffect(()=>{if(x)return x.setReservation(c?No(o):0),()=>x.setReservation(0)},[x,c,o]),{open:c,setOpen:u,toggle:f,tab:s,setTab:b,paneWidth:o,shift:k}}var Zr=["headings","find"],Mt=(...e)=>e.filter(Boolean).join(" ");function qr({className:e,style:t,children:n}){return jsx("div",{className:Mt("docx-nav__header",e),style:t,children:n??jsxs(Fragment,{children:[jsx(zr,{}),jsx(Kr,{})]})})}function zr({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Close");return jsx("button",{type:"button",className:Mt("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>o.setOpen(false),children:n??jsx(z,{name:"arrow_back",size:20})})}function Kr({className:e,style:t,children:n}){let{t:o}=Jt("Title");return jsx("h2",{className:Mt("docx-nav__title",e),style:t,children:n??o("navigation.title")})}function $r({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Tabs"),i=useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let c=Zr.indexOf(o.tab);o.setTab(Zr[(c+l+Zr.length)%Zr.length]);},[o]);return jsx("div",{className:Mt("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:n??Zr.map(a=>jsx(Vr,{value:a},a))})}function Vr({value:e,className:t,style:n,children:o}){let{pane:r,t:i}=Jt("Tab"),a=r.tab===e;return jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":a,"aria-controls":`docx-nav-panel-${e}`,tabIndex:a?0:-1,className:Mt("docx-nav__tab",a&&"docx-nav__tab--selected",t),style:n,onClick:()=>r.setTab(e),children:o??i(`navigation.tabs.${e}`)})}function ff({value:e,onChange:t,onClear:n,placeholder:o,label:r,clearLabel:i,autoFocus:a}){return jsxs("div",{className:"docx-nav__searchbox",children:[jsx(z,{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:a,onChange:l=>t(l.target.value)}),e.length>0&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:n,children:jsx(z,{name:"close",size:16})})]})}function Ur({className:e,style:t}){let{pane:n,outline:o,t:r}=Jt("Headings"),[i,a]=useState(""),l=O(_o),c=useMemo(()=>{let d=i.trim().toLowerCase();return d.length===0?o.items:o.items.filter(m=>m.heading.text.toLowerCase().includes(d))},[o.items,i]),s=n.tab!=="headings";return jsxs("div",{className:Mt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:s,children:[jsx(ff,{value:i,onChange:a,onClear:()=>a(""),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,m)=>jsx("li",{children:jsx("button",{type:"button",className:Mt("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}-${m}`))})]})}function OP({match:e,active:t,onSelect:n}){return jsx("li",{children:jsx("button",{type:"button",className:Mt("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 Wr({className:e,style:t}){let{pane:n,search:o,t:r}=Jt("Find"),i=n.tab!=="find",a=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:Mt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:i,children:[jsx(ff,{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:a?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(z,{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(z,{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(OP,{match:c,active:s===o.activeIndex,onSelect:()=>o.goTo(s)},`${c.blockId}-${c.start}-${s}`))})]})}function Gr({className:e,style:t,children:n}){let{pane:o,t:r}=Jt("Toggle");return jsx("button",{type:"button",className:Mt("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":o.open,title:r("navigation.openTitle"),onMouseDown:i=>i.preventDefault(),onClick:o.toggle,children:n??jsx(z,{name:"toc",size:20})})}function Sc(e){let t=ot(),{t:n,toggle:o=true,className:r,style:i,children:a,...l}=e,c=Si(l),s=yi(),d=xi(),{t:m}=N(),p=useMemo(()=>({pane:c,outline:s,search:d,t:n??((u,f)=>m(u,f))}),[c,s,d,n,m]),g=e.paneWidth??280;return jsx(fc.Provider,{value:p,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":`${No(g)}px`,...i},children:[o!==false&&!c.open&&jsx(Gr,{...typeof o=="object"?o:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":p.t("navigation.ariaLabel"),inert:!c.open,children:a??jsxs(Fragment,{children:[jsx(qr,{}),jsx($r,{}),jsx(Ur,{}),jsx(Wr,{})]})})]})})}var Ti=Object.assign(Sc,{Header:qr,Close:zr,Title:Kr,Tabs:$r,Tab:Vr,Headings:Ur,Find:Wr,Toggle:Gr});var VP=600,UP=e=>e.page.total,Ci=createContext(null);function Pi({className:e,style:t}){let n=ot(),o=H(),r=Ft(),i=O(UP),{t:a}=N(),l=useContext(Ci),[c,s]=useState(1),[d,m]=useState(false);if(useEffect(()=>{if(m(false),!o||!r||i<=1)return;s(o.getCurrentPage("viewport"));let g=null,u=()=>{s(o.getCurrentPage("viewport")),m(true),g&&clearTimeout(g),g=setTimeout(()=>m(false),VP);};return r.addEventListener("scroll",u,{passive:true}),()=>{r.removeEventListener("scroll",u),g&&clearTimeout(g);}},[o,i,r]),i<=1)return null;let p=l?l("viewer.pageIndicator").replace(/\{current\}/g,String(c)).replace(/\{total\}/g,String(i)):a("viewer.pageIndicator",{current:c,total:i});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:p})}var jP=[],YP=e=>e.fontSubstitutions??jP;function Ei({className:e,style:t,t:n}){let o=O(YP),{t:r}=N(),i=n??r,[a,l]=useState(null);if(o.length===0)return null;let c=o.join("\0");return a===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:i("editor.fontSubstitutionNotice",{fonts:o.join(", ")}).replace("{fonts}",o.join(", "))}),jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(c),children:i("common.dismiss")})]})}var Qe={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Tc(e){return Math.round(e/1440*100)/100}function vf(e){return Math.round(e*1440)}function QP(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 Cc(){let e=H(),t=useCallback(n=>e?.getHeaderFooterState()??null,[e]);return O(t,QP)}function yn(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 jr(e,t){let[n,o]=useState(null),r=useCallback(l=>o(l),[]),[i,a]=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,m=new ResizeObserver(()=>g()),p=()=>{s=0;let f=e(c);if(f!==d&&(m.disconnect(),m.observe(c),m.observe(n),f&&m.observe(f),d=f),!f||!f.isConnected){a({visibility:"hidden"});return}let b=f.getBoundingClientRect(),x=t==="story-label"?Math.max(n.offsetHeight,28):n.offsetHeight,T=t==="story-label"?6:4,h=l===c,v=t==="after"?b.bottom+6:b.top-x-T,y=h?yn(c,b.left,v):{left:b.left,top:v},S=y.left,w=y.top,P=h?c.scrollLeft+8:8;a({position:h?"absolute":"fixed",left:t==="story-label"?S:Math.max(P,S+8),top:t==="story-label"?w:Math.max(h?c.scrollTop+8:8,w),...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(p));};m.observe(c),m.observe(n);let u=new MutationObserver(g);return u.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),p(),()=>{s&&cancelAnimationFrame(s),m.disconnect(),u.disconnect(),c.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[n,e,t]),{ref:r,style:i}}function rE(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 aE=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Yr(e){let t=H();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 iE(e){let{state:t,onMouseDown:n}=e,{t:o}=N(),r=H(),[i,a]=useState(false),l=useRef(null),[c,s]=useState(""),[d,m]=useState("");useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(s(String(Tc(t.headerDistanceTwips))),m(String(Tc(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),useEffect(()=>{if(!i)return;let w=P=>{l.current?.contains(P.target)||a(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]);let p=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),u=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),b=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),x=Yr(p),T=Yr(g),h=Yr(u),v=Yr(f),y=Yr(b),S=(w,P)=>{if(!r)return;let R=Number.parseFloat(P);Number.isFinite(R)&&r.exec({type:"setHeaderFooterOptions",[w]:vf(R)});};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":i,"aria-haspopup":"menu",onClick:()=>a(w=>!w),onMouseDown:n,children:o("headerFooter.options")}),i?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:n,children:[aE.map(w=>{let P={type:"insertPageField",field:w.field},R=r?.can(P);return jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!R?.ok,title:R&&!R.ok?R.reason:void 0,onClick:()=>{r?.exec(P),a(false);},onMouseDown:n,children:o(w.labelKey)},w.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:!x.enabled,title:x.reason??void 0,onChange:()=>r?.exec(p)}),jsx("span",{children:o("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!T.enabled,title:T.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:!v.enabled,title:v.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:!h.enabled,title:h.reason??void 0,onClick:()=>r?.exec(u),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:w=>s(w.target.value),onBlur:()=>S("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:w=>m(w.target.value),onBlur:()=>S("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:!y.enabled,title:y.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"}),a(false);},onMouseDown:n,children:o("common.close")})]}):null]})}function wi({className:e}){let{t}=N(),n=Cc(),o=useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=jr(o,"story-label"),i=B;if(!n?.editing)return null;let a=rE(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:i,style:{...r.style,zIndex:Qe.hfInlineEditor},children:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(a)}),n.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsx(iE,{state:n,onMouseDown:i})]})}function Ao(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ki=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),mE="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",fE="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",gE="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",bE="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 hE({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let i=It(),a=useRef(null),{state:l,close:c}=i;useEffect(()=>{if(l.mode==="closed")return;let f=x=>{x.key==="Escape"&&(x.preventDefault(),c());},b=x=>{let T=a.current;T&&x.target instanceof Node&&T.contains(x.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=a.current;if(!f||!b){d(null);return}let x=b.offsetParent;if(!x){d(null);return}let{left:T,top:h}=yn(x,f.left,f.top),v=Math.max(0,x.scrollWidth-b.offsetWidth);d({left:Math.max(0,Math.min(T,v)),top:h});},[l.anchor]);let{t:m}=N(),p=l.mode==="editing"?m(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):m("hyperlinkPopup.editLink"),g=r?jsx(vE,{children:o}):o;if(n)return l.mode==="closed"?null:jsx(Fragment,{children:o});let u={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Ao,style:s??void 0,"aria-label":p};return l.mode==="closed"?null:t?jsx(j,{...u,children:o}):jsx("div",{...u,children:g})}function vE({children:e}){let{state:t}=It(),n=useMemo(()=>yE(e),[e]),o=(i,a)=>i in n?n[i]:a;if(t.mode==="editing")return jsxs(Fragment,{children:[o("Fields",jsx(Ic,{})),o("Error",jsx(Dc,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Apply",jsx(_c,{})),o("Cancel",jsx(Nc,{}))]}),n.__extra]});let r=t.canEdit&&!(t.link&&$n(t.link));return jsxs(Fragment,{children:[o("Url",jsx(wc,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[o("Copy",jsx(kc,{})),r?o("Edit",jsx(Rc,{})):null,r?o("Unlink",jsx(Mc,{})):null]}),n.__extra]})}function yE(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 i=r.type.docxHyperLinkPart;i?t[i]=r:n.push(r);};return o(e),n.length>0&&(t.__extra=n),t}function It(){return useContext(Vn)??xE}var xE={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 wc({className:e,asChild:t,hidden:n,children:o}){let{state:r,openTarget:i}=It(),{t:a}=N();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=a(l?"hyperlinkPopup.inertTarget":c?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),m={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:Ao,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsx(j,{...m,children:o}):l?jsxs("span",{...m,children:[o??s,jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxs("button",{...m,children:[o??s,ki(bE)]})}wc.docxHyperLinkPart="Url";function kc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{state:i,copy:a}=It(),{t:l}=N();if(n||!i.link?.href)return null;let c=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":c,title:c,onMouseDown:Ao,onClick:()=>{a();}};return t?jsx(j,{...s,children:o}):jsx("button",{...s,children:r??o??ki(mE)})}kc.docxHyperLinkPart="Copy";function Rc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{beginEdit:i}=It(),{t:a}=N();if(n)return null;let l=a("hyperlinkPopup.editLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:r??o??ki(fE)})}Rc.docxHyperLinkPart="Edit";function Mc({className:e,asChild:t,hidden:n,children:o,icon:r}){let{unlink:i}=It(),{t:a}=N();if(n)return null;let l=a("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:r??o??ki(gE)})}Mc.docxHyperLinkPart="Unlink";function Ic({className:e,hidden:t}){let{state:n,setText:o,setUrl:r,commitEdit:i,close:a}=It(),{t:l}=N(),c=useRef(null),s=useId(),d=useId();useEffect(()=>{n.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[n.mode]);let m=useCallback(p=>{if(p.key==="Enter"){p.preventDefault(),i();return}p.key==="Escape"&&(p.preventDefault(),a());},[i,a]);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:p=>o(p.target.value),onKeyDown:m}),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:p=>r(p.target.value),onKeyDown:m})]})}Ic.docxHyperLinkPart="Fields";function _c({className:e,asChild:t,hidden:n,children:o}){let{state:r,commitEdit:i}=It(),{t:a}=N();if(n)return null;let l=a("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Ao,onClick:()=>i()};return t?jsx(j,{...c,children:o}):jsx("button",{...c,children:o??l})}function Dc({className:e,hidden:t}){let{state:n}=It(),{t:o}=N();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")})}Dc.docxHyperLinkPart="Error";_c.docxHyperLinkPart="Apply";function Nc({className:e,asChild:t,hidden:n,children:o}){let{close:r}=It(),{t:i}=N();if(n)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Ao,onClick:()=>r()};return t?jsx(j,{...l,children:o}):jsx("button",{...l,children:o??a})}Nc.docxHyperLinkPart="Cancel";var Ri=Object.assign(hE,{Url:wc,Copy:kc,Edit:Rc,Unlink:Mc,Fields:Ic,Error:Dc,Apply:_c,Cancel:Nc});var PE=e=>e;function Oc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Mi(){let e=H(),{t}=N(),[n,o]=useState(null),[r,i]=useState(null),a=useRef(null),l=useRef(null),c=useRef(null),s=useId(),d=useId(),m=useId(),p=n?.activation??null,g=O(PE),u=useMemo(()=>{if(!e?.surface||!p)return {replaceEnabled:false,removeEnabled:false,reason:null};let h=e.surface.equations.can(p.equation.id,"replace"),v=e.surface.equations.can(p.equation.id,"remove"),y=h.ok?v.ok?null:v.reason:h.reason;return {replaceEnabled:h.ok,removeEnabled:v.ok,reason:y?localizeDisabledReason(y,t):null}},[p,e,g,t]),f=useCallback((h=false)=>{c.current?.(),c.current=null,o(null),h&&e&&queueMicrotask(()=>e.focus());},[e]);useEffect(()=>{if(!e)return;let h=e.setEquationChrome({onPopover:v=>{c.current?.();let y=e.surface;if(y&&typeof y.retainSelection=="function"){let S=y.retainSelection();c.current=()=>y.releaseSelection(S);}else c.current=null;o({activation:v,mountGeneration:e.mountGeneration,draft:v.equation.linear,error:false});}});return ()=>{h(),c.current?.(),c.current=null,o(null);}},[e,f]),useEffect(()=>{if(!n||!e?.surface)return;(e.mountGeneration!==n.mountGeneration||!e.surface.equations.equationById(n.activation.equation.id))&&f();},[e,g,n,f]),useEffect(()=>{if(!n)return;let h=a.current,v=h?.ownerDocument,y=v?.defaultView;if(!h||!v||!y)return;let S=P=>{P.key==="Escape"&&(P.preventDefault(),f(true));},w=P=>{P.target instanceof y.Node&&h.contains(P.target)||f();};return v.addEventListener("keydown",S),v.addEventListener("pointerdown",w,true),()=>{v.removeEventListener("keydown",S),v.removeEventListener("pointerdown",w,true);}},[n,f]),useLayoutEffect(()=>{if(!p){i(null);return}let h=a.current;if(!h)return;let v=h.offsetParent;if(!v){i(null);return}let y=p.rect,S=yn(v,y.left,y.bottom),w=Math.max(0,v.scrollWidth-h.offsetWidth);i({left:Math.max(0,Math.min(S.left,w)),top:S.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[p]);let b=useCallback(()=>{if(!n||!e?.surface||!u.replaceEnabled)return false;let h=e.surface.equations.applyEquation(n.activation.equation.id,n.draft);return h?f(true):o(v=>v&&{...v,error:true}),h},[e,n,f,u.replaceEnabled]),x=useCallback(()=>{if(!n||!e?.surface||!u.removeEnabled)return false;let h=e.surface.equations.removeEquation(n.activation.equation.id);return h?f(true):o(v=>v&&{...v,error:true}),h},[e,n,f,u.removeEnabled]);if(!n)return null;let T=[n.error?d:null,u.reason?m:null].filter(Boolean).join(" ");return jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:Oc,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:s,children:t("equationPopup.inputLabel")}),jsx("input",{id:s,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:n.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":T||void 0,onChange:h=>o(v=>v&&{...v,draft:h.target.value,error:false}),onKeyDown:h=>{h.key!=="Enter"||h.nativeEvent.isComposing||(h.preventDefault(),b());}}),n.error?jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,u.reason?jsx("div",{id:m,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:u.reason}):null,jsxs("div",{className:"docx-equation-popup__actions",children:[jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!u.replaceEnabled,title:u.reason??void 0,onMouseDown:Oc,onClick:b,children:t("equationPopup.apply")}),jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!u.removeEnabled,title:u.reason??void 0,onMouseDown:Oc,onClick:x,children:t("equationPopup.delete")})]})]})}function EE(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 Bc(){let e=H(),t=useCallback(o=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),n=O(t,EE);return n?.kind==="note"?n:null}function wf(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 kf(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&&wf(e.documentAuthored,t.documentAuthored)&&wf(e.sectionAuthored,t.sectionAuthored)}function wE(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&kf(e.footnote,t.footnote)&&kf(e.endnote,t.endnote)}function Zc(){let e=H(),t=useCallback(n=>e?.getNotePropertiesState()??null,[e]);return O(t,wE)}var kE=/^(footnote|endnote):(-?\d{1,10})$/;function Mf(e){let t=kE.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isInteger(n)?{noteKind:t[1],noteId:n}:null}function RE(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function zc(e){let t=H();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 ME(e){let{t}=N(),[n,o]=useState(false),r=useRef(null);return useEffect(()=>{if(!n)return;let i=a=>{r.current?.contains(a.target)||o(false);};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[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:B,onClick:()=>o(i=>!i),children:t("headerFooter.options")}),n?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:B,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 Ii({className:e}){let{t}=N(),n=H(),o=Bc(),[r,i]=useState(null),[a,l]=useState(null),[c,s]=useState(false),d=useRef(null),m=useCallback(R=>{if(!o)return null;let L=[...R.querySelectorAll("[data-docx-note-scope]")].find(D=>D.matches("[data-docx-note]")&&D.dataset.docxNoteScope===o.id)??null;return L?.closest("[data-docx-notes]")??L},[o]),p=jr(m,"story-label"),g=useCallback(()=>{d.current&&clearTimeout(d.current),d.current=null,i(null);},[]);useEffect(()=>{if(!n)return;let R=document.querySelector(".docx-pages");if(!R)return;let E=F=>{let M=F.target;if(!M)return;let _=M.closest("[data-docx-note-ref]");if(_?.dataset.docxNoteScope){F.preventDefault(),g(),l(null),n.setActiveScope({kind:"note",id:_.dataset.docxNoteScope});return}M.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),g(),l(null),n.setActiveScope({kind:"body"}));},L=F=>{let M=F,k=M.target?.closest("[data-docx-note-scope]");k?.dataset.docxNoteScope&&(M.preventDefault(),l({scopeId:k.dataset.docxNoteScope,x:M.clientX,y:M.clientY}));},D=F=>{if(RE())return;let _=F.target?.closest("[data-docx-note-ref]");if(!_?.dataset.docxNoteScope){g();return}let k=_.dataset.docxNoteScope,ae=n.getNotePreviewText(k)??_.getAttribute("aria-description")??t("notes.previewFallback"),K=_.getBoundingClientRect();d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{i({scopeId:k,text:ae,x:K.left,y:K.bottom+4});},400);};return R.addEventListener("click",E),R.addEventListener("contextmenu",L),R.addEventListener("pointerover",D),R.addEventListener("scroll",g,true),()=>{R.removeEventListener("click",E),R.removeEventListener("contextmenu",L),R.removeEventListener("pointerover",D),R.removeEventListener("scroll",g,true),g();}},[n,g,t]);let u=useCallback(R=>{n&&(n.exec(R),l(null));},[n]),f=a?Mf(a.scopeId):null,b=useMemo(()=>f?{type:"deleteNote",noteKind:f.noteKind,noteId:f.noteId}:null,[f]),x=useMemo(()=>f?{type:"convertNote",fromKind:f.noteKind,noteId:f.noteId}:null,[f]),T=useMemo(()=>f?{type:"convertAllNotes",fromKind:f.noteKind}:null,[f]),h=zc(b??{type:"deleteNote",noteKind:"footnote",noteId:0}),v=zc(x??{type:"convertNote",fromKind:"footnote",noteId:0}),y=zc(T??{type:"convertAllNotes",fromKind:"footnote"}),S=useMemo(()=>({position:"fixed",left:r?.x??0,top:r?.y??0,zIndex:Qe.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]),w=o?Mf(o.id):null,P=w?t("notes.editingRegion",{kind:w.noteKind==="footnote"?t("notes.footnoteKind"):t("notes.endnoteKind"),number:w.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&&w?jsxs("div",{ref:p.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:{...p.style,zIndex:Qe.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:P}),jsx(ME,{onOpenProperties:()=>s(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,r?jsx("div",{role:"tooltip","data-testid":"docx-notes-preview",style:S,onMouseDown:R=>{R.preventDefault(),R.stopPropagation();},children:r.text}):null,a&&f?jsxs("div",{role:"menu","data-testid":"docx-notes-menu",style:{position:"fixed",left:a.x,top:a.y,zIndex:Qe.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:B,children:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!h.enabled,title:h.reason??void 0,onClick:()=>b&&u(b),children:t("notes.delete")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!v.enabled,title:v.reason??void 0,onClick:()=>x&&u(x),children:f.noteKind==="footnote"?t("notes.convertToEndnote"):t("notes.convertToFootnote")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!y.enabled,title:y.reason??void 0,onClick:()=>T&&u(T),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(IE,{onClose:()=>s(false),onApply:R=>{u(R),s(false);}}):null]}):null}function IE(e){let{t}=N(),n=H(),o=Zc(),[r,i]=useState("document"),[a,l]=useState("decimal"),[c,s]=useState("continuous"),[d,m]=useState("pageBottom"),[p,g]=useState("decimal"),[u,f]=useState("continuous"),[b,x]=useState("docEnd");useEffect(()=>{o&&(l(o.footnote.resolved.numFmt),s(o.footnote.resolved.numRestart),m(o.footnote.resolved.pos),g(o.endnote.resolved.numFmt),f(o.endnote.resolved.numRestart),x(o.endnote.resolved.pos));},[o]);let T=!o?.footnote.documentAuthored&&!o?.footnote.sectionAuthored,h=!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:Qe.modal},onClick:e.onClose,onKeyDown:v=>{v.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:v=>v.stopPropagation(),onMouseDown:v=>v.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:v=>i(v.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")}),T?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:a,onChange:v=>l(v.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:v=>s(v.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:v=>m(v.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")}),h?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:p,onChange:v=>g(v.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:u,onChange:v=>f(v.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:v=>x(v.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 v={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?o?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:c,position:d},endnote:{numFmt:p,numRestart:u,position:b}};n.can(v).ok&&e.onApply(v);},children:t("common.apply")})]})]})})}var _i=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Ho(){return useContext(_i)}function Df(){return useContext(_i).target}var Nf=["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"],Lf=["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"],Ff=["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"],Af=["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"],Hf=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Of=["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"],Bf=["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 Di(e,t,n){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:c})=>{let s=H(),{close:d}=Ho(),m=Fe(),{isEnabled:p,disabledReason:g}=le(t);return c?null:jsx(Be,{slot:e,icon:r??re(n.paths),shortcut:m(a??n.shortcutKey),disabled:!p,...g?{title:g}:{},onSelect:()=>{s?.exec(t),d(true);},...l?{className:l}:{},children:m(i??n.labelKey)})},{docxRow:e})}var Jr=Di("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Nf}),Qr=Di("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Lf}),ea=Di("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:Af}),ta=Di("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Bf});function Tn({icon:e,labelKey:t,shortcutKey:n,className:o,hidden:r}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:c}=Ho(),s=Fe(),d=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:m,disabledReason:p}=le(d);if(r)return null;let g=l!==null;return jsx(Be,{slot:"edit.paste",icon:e??re(Ff),shortcut:s(n??"contextMenu.pasteShortcut"),disabled:!m||g,...l??p?{title:l??p??""}:{},onSelect:()=>{(async()=>{try{let u=await navigator.clipboard.readText();u&&i?.exec({type:"paste",text:u});}catch(u){c(u instanceof Error?u.message:"the clipboard is not readable");}finally{a(true);}})();},...o?{className:o}:{},children:s(t??"contextMenu.paste")})}Tn.docxRow="edit.paste";function Oo(e,t,n){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:c})=>{let{close:s}=Ho(),d=Fe(),m=Ni(),{isEnabled:p,disabledReason:g,execute:u}=le(t);return l||!m?null:jsx(Be,{slot:e,icon:r??re(n.paths),disabled:!p,...g?{title:g}:{},className:`${c??n.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{u()&&s(true);},children:d(i??n.labelKey)})},{docxRow:e})}var Cn=Oo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),Pn=Oo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),En=Oo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),wn=Oo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),kn=Oo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),Rn=Oo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),Mn=Oo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),NE=[{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 Bo({hidden:e}){let{close:t}=Ho(),n=Fe(),o=Ni(),r=le({type:"setTableCellVerticalAlignment",alignment:"top"}),i=le({type:"setTableCellVerticalAlignment",alignment:"center"}),a=le({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];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:NE.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:m=>{m.preventDefault(),m.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:re(tableChromeIconPaths(c.icon))},c.alignment)})})]})}Bo.docxRow="table.cellVerticalAlignment";function qf(e,t,n){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let c=H(),{close:s,tocId:d}=Ho(),m=Fe(),p=useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:u}=le(p);return l||d===null?null:jsx(Be,{slot:e,icon:r??re(n.paths),disabled:!g,...u?{title:u}:{},onSelect:()=>{c?.exec(p),s(true);},...a?{className:a}:{},children:m(i??n.labelKey)})},{docxRow:e})}var In=qf("toc.refresh","entire",{labelKey:"toc.refresh",paths:Hf}),_n=qf("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:Of});function Ni(){return O(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function Li({label:e,icon:t,shortcut:n,disabled:o,disabledReason:r,active:i,onSelect:a,className:l}){let{close:c}=Ho();return jsx(Be,{...t?{icon:t}:{},...n?{shortcut:n}:{},...o?{disabled:o}:{},...o&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),c(true);},...l?{className:l}:{},children:e})}var Hi=8,HE=e=>e.editingMode==="viewing";function OE(){let e=H(),t=useContext(ft),n=nt(),o=Fe(),r=e?.can({type:"toggleReviewPane"}),i=O(HE),a=!r?.ok||i||(t?.mounted??0)===0||e?.getSelectionPlacement()===null,l=J("review.comments");return jsx(Be,{icon:re(l?.paths),slot:"review.comments",disabled:a,title:r&&!r.ok?r.reason:i?o("editingMode.viewingHint"):void 0,onSelect:()=>{t?.requestCommentDraft()&&n.setOpenMenu(null);},children:o("comments.addComment")})}var BE=[{kind:"row",id:"edit.cut",render:()=>jsx(Jr,{})},{kind:"row",id:"edit.copy",render:()=>jsx(Qr,{})},{kind:"row",id:"edit.paste",render:()=>jsx(Tn,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(ea,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(ta,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(Ot,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsx(OE,{})}];function ZE(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Cn.docxRow,render:()=>jsx(Cn,{})},{kind:"row",id:Pn.docxRow,render:()=>jsx(Pn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:En.docxRow,render:()=>jsx(En,{})},{kind:"row",id:wn.docxRow,render:()=>jsx(wn,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:kn.docxRow,render:()=>jsx(kn,{})},{kind:"row",id:Rn.docxRow,render:()=>jsx(Rn,{})},{kind:"row",id:Mn.docxRow,render:()=>jsx(Mn,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Bo.docxRow,render:()=>jsx(Bo,{})}]}function qE(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:In.docxRow,render:()=>jsx(In,{})},{kind:"row",id:_n.docxRow,render:()=>jsx(_n,{})}]}function zE(e,t=false){return [...BE,...e?ZE():[],...t?qE():[]]}function Uf(e){if(!isValidElement(e))return null;let t=nn(e,Uf);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 $f(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function KE(e){return e?.closest(".docx-editor__scroll-container")??null}function na({className:e,t,preset:n=true,disabled:o,onOpenChange:r,children:i}){let a=ot(),l=H(),{t:c}=N(),s=Ni(),d=useRef(null),m=useRef(null),[p,g]=useState(null),[u,f]=useState(null),[b,x]=useState(null),T=useMemo(()=>zE(s,u!==null),[s,u]),[h,v]=useState(null),y=useCallback((F=false)=>{g(null),v(null),f(null),x(null),F&&l?.focus();},[l]);useEffect(()=>{if(o)return;let F=KE(d.current);if(!F)return;let M=_=>{_.preventDefault();let k=_.button===-1||_.clientX===0&&_.clientY===0,I=F.getBoundingClientRect();f(l?.snapshot().tocContext?.id??null),x(k||!(_.target instanceof HTMLElement)?null:_.target),g(k?{x:I.left+16,y:I.top+16}:{x:_.clientX,y:_.clientY});};return F.addEventListener("contextmenu",M),()=>F.removeEventListener("contextmenu",M)},[o,l]),useEffect(()=>{o&&y();},[o,y]),useEffect(()=>{if(!p)return;let F=k=>{m.current?.contains(k.target)||y();},M=k=>{k.key==="Escape"?(k.preventDefault(),y(true)):k.key==="Tab"&&y();},_=()=>y();return document.addEventListener("pointerdown",F,true),document.addEventListener("keydown",M),document.addEventListener("scroll",_,{capture:true,passive:true}),window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{document.removeEventListener("pointerdown",F,true),document.removeEventListener("keydown",M),document.removeEventListener("scroll",_,true),window.removeEventListener("blur",_),window.removeEventListener("resize",_);}},[p,y]),useLayoutEffect(()=>{let F=m.current;if(!p||!F)return;let{width:M,height:_}=F.getBoundingClientRect(),k=window.innerWidth-M-Hi,I=window.innerHeight-_-Hi,ae=Math.max(Hi,p.x>k?p.x-M:p.x),K=Math.max(Hi,p.y>I?p.y-_:p.y);v({x:ae,y:K});},[p]),useLayoutEffect(()=>{h&&m.current?.focus({preventScroll:true});},[h]);let S=useRef(r);S.current=r;let w=useRef(false);useEffect(()=>{let F=p!==null;F!==w.current&&(w.current=F,S.current?.(F));},[p]);let P=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>y(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,y]),[R,E]=useState(null),L=useMemo(()=>({close:y,anchor:p,tocId:u,target:b,clipboardRefusal:R,reportClipboardRefusal:E}),[y,p,u,b,R]),D={position:"fixed",left:(h??p)?.x??0,top:(h??p)?.y??0,visibility:h?"visible":"hidden"};return jsx("div",{ref:d,style:{display:"contents"},children:p?jsx(kr.Provider,{value:P,children:jsx(_i.Provider,{value:L,children:jsxs("div",{ref:m,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:D,onKeyDown:F=>{let M=m.current;if(!M)return;let _=Po(M);F.key==="ArrowDown"?(F.preventDefault(),vt(_,document.activeElement,1)):F.key==="ArrowUp"?(F.preventDefault(),vt(_,document.activeElement,-1)):F.key==="Home"?(F.preventDefault(),yt(_,"first")):F.key==="End"&&(F.preventDefault(),yt(_,"last"));},children:[Children.toArray(i).filter($f),Na({entries:T,children:Children.toArray(i).filter(F=>!$f(F)),preset:n,keyOfEntry:F=>F.id,keyOfChild:Uf,renderEntry:F=>F.kind==="separator"?jsx(Ro,{}):F.render()})]})})}):null})}var Vc=Object.assign(na,{Cut:Jr,Copy:Qr,Paste:Tn,Delete:ea,SelectAll:ta,InsertRowAbove:Cn,InsertRowBelow:Pn,InsertColumnLeft:En,InsertColumnRight:wn,DeleteTableRow:kn,DeleteTableColumn:Rn,DeleteTable:Mn,CellVerticalAlignment:Bo,RefreshToc:In,RefreshTocPageNumbers:_n,Item:Li,Slot:Ot,Row:Be,Group:Ir,Separator:Ro,Submenu:ko});function Uc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Gf=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),WE="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",GE="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",jE={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},YE={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},XE={color:"var(--doc-text-muted)",flexShrink:0},JE={textAlign:"right",wordBreak:"break-word"},QE={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},e1={display:"flex",gap:8,marginTop:4},jf={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 t1(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 o1(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 Dn({label:e,value:t,testId:n}){return jsxs("div",{style:YE,"data-testid":n,children:[jsx("span",{style:XE,children:e}),jsx("span",{style:JE,children:t})]})}function n1({className:e,asChild:t,hidden:n,children:o,preset:r=true}){let i=Et(),a=useRef(null),l=useId(),{t:c}=N(),{control:s,inspectorOpen:d,closeInspector:m}=i;if(useEffect(()=>{if(!d)return;let f=x=>{x.key==="Escape"&&(x.preventDefault(),m());},b=x=>{let T=a.current;T&&x.target instanceof Node&&T.contains(x.target)||m();};return document.addEventListener("keydown",f),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",f),document.removeEventListener("mousedown",b,true);}},[d,m]),useEffect(()=>{d&&!s&&m();},[d,s,m]),n||!d||!s)return null;let p=r?jsxs(Fragment,{children:[jsx(Yf,{}),jsx(Xf,{}),jsx("div",{style:e1,children:jsx(Jf,{})}),o]}):o,g={ref:a,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:jE,onMouseDown:f=>{Uc(f),f.stopPropagation();}},u=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:c("contentControl.inspectorPanel.title")}),p]});return t?jsx(j,{...g,children:u}):jsx("div",{...g,children:u})}function Yf({className:e,asChild:t,hidden:n,children:o}){let{closeInspector:r}=Et(),{t:i}=N();if(n)return null;let a={style:QE,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxs(Fragment,{children:[jsx("span",{children:o??i("contentControl.inspectorPanel.title")}),jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...jf,padding:4,border:"none",background:"transparent"},onMouseDown:Uc,onClick:()=>r(),children:Gf(WE)})]});return t?jsx(j,{...a,children:l}):jsx("div",{...a,children:l})}function Xf({className:e,asChild:t,hidden:n,children:o}){let{control:r}=Et(),{t:i}=N();if(n||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),c=i("contentControl.inspectorPanel.no"),s=o??jsxs(Fragment,{children:[jsx(Dn,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsx(Dn,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsx(Dn,{label:i("contentControl.inspectorPanel.type"),value:i(t1(r.controlType)),testId:"content-control-inspector-type"}),jsx(Dn,{label:i("contentControl.inspectorPanel.lock"),value:i(o1(r)),testId:"content-control-inspector-lock"}),jsx(Dn,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:c,testId:"content-control-inspector-placeholder"}),jsx(Dn,{label:i("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:i("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:i("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(j,{...d,children:s}):jsx("div",{...d,children:s})}function Jf({className:e,asChild:t,hidden:n,icon:o,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:c}=Et(),{t:s}=N();if(n)return null;let d=s("contentControl.remove"),m={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,style:jf,onMouseDown:Uc,onClick:()=>{l().ok&&c();}},p=jsxs(Fragment,{children:[o??r??Gf(GE),jsx("span",{children:d})]});return t?jsx(j,{...m,children:p}):jsx("button",{...m,children:p})}var Oi=Object.assign(n1,{Header:Yf,Fields:Xf,Remove:Jf});var l1={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},s1={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},c1={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},d1={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},u1={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},p1={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)"},m1={padding:"8px 12px"},f1={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},g1={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},b1={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function h1({forwardedRef:e}){let t=H(),n=useRef(null);return n.current=t,lu({ref:e,editorRef:n}),null}var v1=forwardRef(function(t,n){let{document:o,fonts:r,className:i,t:a,chrome:l=true,title:c,onTitleChange:s,renderTitleBarLeft:d,renderTitleBarRight:m,colorMode:p="light",author:g,locale:u,mode:f="edit",modules:b,zoom:x,zoomMode:T,onReady:h,onChange:v,onFontError:y,onOpen:S,onSave:w,hyperlinkPopup:P,contextMenu:R=true,menu:E=true,navigation:L=true,rulers:D=true}=t,[F,M]=useState(xd);useEffect(()=>{if(p==="system")return Td(M)},[p]);let _=Sd(p,F),{t:k}=N(),I=useCallback((V,oe)=>a?a(V,oe):k(V,oe),[a,k]),ae=jsxs(Ma,{className:l?_?"dark":void 0:i,style:l?s1:void 0,children:[l?jsx(wi,{}):null,l?jsx(Ii,{}):null,jsx(Sa,{}),jsx(Ri,{hidden:P===false}),jsx(Mi,{}),R===false?null:jsx(na,{t:I,...typeof R=="object"?R:{}}),jsx(Oi,{}),D&&l?jsx("div",{style:u1,"aria-hidden":"true",children:jsx(bi,{})}):null,t.children]}),K=l?jsxs("div",{className:`docx-editor${_?" dark":""}${i?` ${i}`:""}`,style:l1,children:[jsxs("div",{style:p1,children:[jsxs("div",{style:f1,children:[d?.(),jsxs("div",{style:g1,children:[s?jsx("input",{"aria-label":I("titleBar.documentNameAriaLabel"),value:c??"",placeholder:I("titleBar.untitled"),onChange:V=>s(V.target.value),style:b1}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:c??I("titleBar.untitled")}),E!==false?jsx(Nr,{t:I,...c!==void 0?{fileName:c}:{},...S?{onOpen:S}:{},...w?{onSave:w}:{},...typeof E=="object"?E:{}}):null]}),m?.()]}),jsx("div",{style:m1,children:jsx(Er,{t:I})})]}),D?jsx("div",{style:d1,"data-testid":"docx-editor-ruler-row",children:jsx(gi,{})}):null,jsx(Ei,{t:I}),jsxs("div",{style:c1,children:[L?jsx(Ti,{t:I}):null,ae,jsx(Ci.Provider,{value:I,children:jsx(Pi,{})}),jsx(Ca,{overlay:true})]})]}):ae,$=useCallback(V=>I(V),[I]);return jsxs(jn,{...o!==void 0?{document:o}:{},...r?{fonts:r}:{},...g!==void 0?{author:g}:{},...u!==void 0?{locale:u}:{},translate:I,mode:f,...b!==void 0?{modules:b}:{},...x!==void 0?{zoom:x}:{},...T!==void 0?{zoomMode:T}:{},tableInteractionLabel:$,...h?{onReady:h}:{},...v?{onChange:v}:{},...y?{onFontError:y}:{},children:[jsx(h1,{forwardedRef:n}),jsx(So.Provider,{value:l,children:K})]})}),y1=forwardRef(function(t,n){return jsx(Xo,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(v1,{...t,ref:n})})}),x1=Object.assign(y1,{Root:jn,Viewport:Ma,Content:Sa,Toolbar:Er,Menu:Nr,Loading:Ca,ColorByChangeType:Rl,AuthorStyle:Ml,HorizontalRuler:gi,VerticalRuler:bi,DocumentOutline:mc,Navigation:Ti,PageSetupDialog:wr,ParagraphDialog:To,PageNumber:Pi,FontNotice:Ei,HeaderFooterChrome:wi,NotesChrome:Ii,Equation:Mi,HyperLink:Ri,ContextMenu:Vc,ContentControl:Oi});function C1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}async function P1(e){return typeof e=="function"?e():e}function E1(e,t={}){let[n,o]=useState(void 0),[r,i]=useState(void 0),[a,l]=useState(null),[c,s]=useState(e!=null),[d,m]=useState(t.fonts===void 0),p=useRef(t);return p.current=t,useEffect(()=>{let g=p.current.fonts;if(g===void 0)return;let u=true;return (async()=>{try{let f=await P1(g);u&&i(composeFontConfiguration(f));}catch{}finally{u&&m(true);}})(),()=>{u=false;}},[]),useEffect(()=>{if(e==null){o(void 0),l(null),s(false);return}let g=C1(e);if(g){o(g),l(null),s(false);return}let u=true,f=new AbortController;return s(true),l(null),(async()=>{try{let b=await fetch(String(e),{...p.current.fetchOptions,signal:f.signal});if(!b.ok)throw new Error(`could not open the document: ${b.status} ${b.statusText}`);let x=new Uint8Array(await b.arrayBuffer());if(!u)return;o(x),s(!1);}catch(b){if(!u||b instanceof Error&&b.name==="AbortError")return;l(b instanceof Error?b:new Error("could not open the document")),s(false);}})(),()=>{u=false,f.abort();}},[e]),{document:d?n:void 0,fonts:r,error:a,isLoading:c||!d}}function M1(e,...t){let n=useRef({source:e,fragments:t});return n.current={source:e,fragments:t},useMemo(()=>async o=>{let r=n.current,a=[typeof r.source=="function"?await r.source(o):await r.source,...r.fragments].filter(s=>s!==void 0);if(a.length===0)return;let{epoch:l,...c}=composeFontConfiguration(a[0],...a.slice(1));return c},[])}var og=[],D1=()=>{};function N1(){let e=H(),t=useCallback(n=>{if(!e)return D1;let o=hl(n),r=e.on("change",o),i=e.on("selectionChange",o);return ()=>{r(),i();}},[e]);return useSyncExternalStore(t,()=>e?.getReviewAuthors()??og,()=>og)}function A1(e){let n=e?.surface?.state?.().selection?.head;return n&&typeof n.paragraphId=="string"&&Number.isFinite(n.offset)?n:null}function H1(){let e=H(),t=useRef(null),n=useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),o=useCallback(()=>{let r=A1(e),i=t.current;return (r===null?i===null:i!==null&&O1(i,r))?i:(t.current=r,r)},[e]);return useSyncExternalStore(n,o,()=>null)}function O1(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function Wc({source:e,scale:t,measurer:n,onStateChange:o,onError:r,className:i,documentFontFamily:a,ref:l}){let c=useRef(null),s=useRef(null),[d,m]=useState(null),p=useRef(o);p.current=o;let g=useRef(r);return g.current=r,useEffect(()=>{let u=c.current;if(!u)return;let f=mountPaginatedSurface(u,e,{...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onChange:x=>{m(x),p.current?.(x);}});if(!f.ok){g.current?.(f.reason,f.detail);return}s.current=f.surface;let b=f.surface.state();return m(b),p.current?.(b),()=>{f.surface.destroy(),s.current=null;}},[e,n]),useImperativeHandle(l,()=>({focus:()=>s.current?.focus(),type:u=>s.current?.type(u),undo:()=>s.current?.undo(),redo:()=>s.current?.redo(),selectAll:()=>s.current?.selectAll(),navigate:(u,f)=>s.current?.navigate(u,f),toggleRunProperty:(u,f)=>s.current?.toggleRunProperty(u,f),setRunProperty:(u,f)=>s.current?.setRunProperty(u,f),setParagraphProperty:(u,f,b)=>s.current?.setParagraphProperty(u,f,b),formatting:()=>s.current?.formatting()??null,sectionProperties:()=>s.current?.sectionProperties()??null,save:()=>{let u=s.current;return u?(u.flushPendingInput(),u.session.save()):null}}),[]),jsx("div",{ref:c,style:{margin:"24px auto",...a?{fontFamily:a}:{}},className:i?`docx-paginated-surface ${i}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var ia=createContext(null);function rg(){let e=useContext(ia);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function W1(e){return "type"in e&&e.type==="separator"}var lg={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"},G1={...lg,background:"var(--doc-bg-hover)"},sg={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"},j1={...sg,opacity:.4,cursor:"default"},Y1={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},X1={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},J1={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 la({label:e,items:t,disabled:n,showChevron:o=false}){let[r,i]=useState(false),[a,l]=useState(null),c=useRef(null),s=useRef(null),[d,m]=useState({top:0,left:0}),p=useCallback(()=>{i(false),l(null);},[]);useEffect(()=>{if(!r||!c.current)return;let u=c.current.getBoundingClientRect();m({top:u.bottom+2,left:u.left});},[r]),useEffect(()=>{if(!r)return;function u(x){let T=x.target;c.current&&!c.current.contains(T)&&s.current&&!s.current.contains(T)&&p();}function f(x){x.key==="Escape"&&p();}function b(){p();}return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),window.addEventListener("scroll",b,true),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f),window.removeEventListener("scroll",b,true);}},[r,p]);let g=u=>{u.disabled||u.submenuContent||u.onClick&&(u.onClick(),p());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:c,type:"button",onClick:()=>!n&&i(!r),onMouseDown:u=>u.preventDefault(),disabled:n,style:r?G1:lg,children:[e,o&&jsx(z,{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:u=>u.preventDefault(),children:t.map((u,f)=>{if(W1(u))return jsx("div",{style:Y1},`sep-${f}`);let b=u;if(b.customContent)return jsx("div",{onMouseDown:h=>h.preventDefault(),children:b.customContent},b.label);let x=!!b.submenuContent,T=a===b.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>x&&l(b.label),onMouseLeave:()=>x&&l(null),children:[jsxs("button",{type:"button",style:b.disabled?j1:sg,onClick:()=>g(b),onMouseDown:h=>h.preventDefault(),onMouseOver:h=>{b.disabled||(h.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsx(z,{name:b.icon,size:18}),jsx("span",{children:b.label}),b.shortcut&&jsx("span",{style:X1,children:b.shortcut}),x&&jsx("span",{style:{marginLeft:"auto"},children:jsx(z,{name:"keyboard_arrow_right",size:16})})]}),x&&T&&jsx("div",{style:J1,onMouseDown:h=>h.preventDefault(),children:b.submenuContent(p)})]},b.label)})})]})}var Yc=18,e2=2,dg={width:Yc,height:Yc,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},t2={...dg,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},o2={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function ug({onInsert:e,gridRows:t=6,gridColumns:n=6}){let[o,r]=useState(0),[i,a]=useState(0),l=useCallback(()=>{o>0&&i>0&&e(o,i);},[o,i,e]),c=[];for(let d=1;d<=t;d++)for(let m=1;m<=n;m++){let p=d<=o&&m<=i;c.push(jsx("div",{style:p?t2:dg,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":p},`${d}-${m}`));}let s=o>0&&i>0?`${i} \xD7 ${o}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:e2,gridTemplateColumns:`repeat(${n}, ${Yc}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:c}),jsx("div",{style:o2,children:s})]})}function i2({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(z,{name:n.icon,size:18}),jsx("span",{children:n.label})]},n.label)})})}function l2(){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 qi({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function s2(e){return e.replace(/\.docx$/i,"")}function Jc({value:e,onChange:t,placeholder:n,editable:o=true}){let{t:r}=N(),i=n??r("titleBar.untitled"),a=s2(e)??"";return o?jsx("input",{type:"text",value:a,onChange:l=>{let c=l.target.value;t?.(c.endsWith(".docx")?c:c+".docx");},placeholder:i,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:a||i})}function zi({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Ki(){let{t:e}=N(),t=rg(),{disabled:n=false,onFormat:o,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:c,onInsertTable:s,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:p,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:u,onInsertTOC:f,onWatermark:b,onRefocusEditor:x}=t,T=useCallback(S=>{!n&&o&&o(S);},[n,o]),h=useCallback((S,w)=>{!n&&s&&(s(S,w),requestAnimationFrame(()=>x?.()));},[n,s,x]),v=!!r||!!l,y=v||i||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[y&&jsx(la,{label:e("toolbar.file"),disabled:n,items:[...i?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:i}]:[],...a?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:a}]:[],...(i||a)&&v?[{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(la,{label:e("toolbar.format"),disabled:n,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>T("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>T("setRtl")}]}),jsx(la,{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:S=>jsx(ug,{onInsert:(w,P)=>{h(w,P),S();}})}]:[],...c||d&&s?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:S=>jsx(i2,{closeMenu:S,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:p},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:u}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),m&&jsx(la,{label:e("toolbar.help"),disabled:n,items:[{label:e("toolbar.reportIssue"),onClick:()=>Rr()}]})]})}function Qc({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===qi?t=a:a.type===zi?n=a:a.type===Ki?r.push(a):o.push(a));});let i=useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(l2,{})}),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 $i={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},p2={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:""},pg={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 m2(e,t){let n=pg[t]??pg[t.toLowerCase()]??t,r=e?.colorScheme?.[n];return typeof r=="string"&&r?r:$i[n]??"000000"}function mg(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 ed(e,t,n="000000"){if(!e||e.kind==="auto")return `#${n}`;if(e.kind==="hex")return `#${mg(e.value)??n}`;let o=Object.entries(t?.colorScheme??$i).map(([i,a])=>({slot:i,hex:String(a)})),r=resolveThemeColorHex(e,o);return `#${r.ok?r.hex:m2(t,e.slot)}`}function Zt(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?mg(e.value):ed(e,t).slice(1)}function fg(e){if(!e||e==="none")return "";let t=p2[e];return t?`#${t}`:""}var f2=[{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"}],g2=[{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 gg(e){let t=e??$i;return g2.map(n=>f2.map(o=>{let r=t[o.slot]??$i[o.slot]??"000000",a={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"?a.tint=n.keep:n.type==="shade"&&(a.shade=n.keep),a}))}function ee(...e){return clsx(e)}var v2=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"}}),Ae=rt.forwardRef(({className:e,variant:t,size:n,...o},r)=>jsx("button",{className:ee(v2({variant:t,size:n,className:e})),ref:r,...o}));Ae.displayName="Button";function ct({content:e,children:t,side:n="bottom",delayMs:o=400}){let[r,i]=rt.useState(false),[a,l]=rt.useState({x:0,y:0}),c=rt.useRef(null),s=rt.useRef(null),d=rt.useCallback(()=>{s.current=setTimeout(()=>{if(c.current){let u=c.current.getBoundingClientRect(),f=u.left+u.width/2,b=n==="top"?u.top-8:u.bottom+8;l({x:f,y:b});}i(true);},o);},[o,n]),m=rt.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),i(false);},[]);rt.useEffect(()=>()=>{s.current&&clearTimeout(s.current);},[]);let p=t.props,g=rt.cloneElement(t,{ref:c,onMouseEnter:u=>{d(),p.onMouseEnter?.(u);},onMouseLeave:u=>{m(),p.onMouseLeave?.(u);}});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:a.x,top:a.y,transform:n==="top"?"translate(-50%, -100%)":n==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var to=ye.Root,oo=ye.Group,Vi=ye.Value;function no({className:e,children:t,onMouseDown:n,...o}){return jsxs(ye.Trigger,{className:ee("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(ye.Icon,{asChild:true,children:jsx(C2,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function ro({className:e,children:t,position:n="popper",onCloseAutoFocus:o,...r}){let i=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsx(ye.Portal,{children:jsx("div",{className:ee("docx-editor",i&&"dark"),children:jsx(ye.Content,{className:ee("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:a=>{a.preventDefault(),o?.(a);},...r,children:jsx(ye.Viewport,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:a=>a.preventDefault(),children:t})})})})}function qo({className:e,...t}){return jsx(ye.Label,{className:ee("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function dt({className:e,children:t,onMouseDown:n,...o}){return jsxs(ye.Item,{className:ee("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(ye.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(ye.ItemIndicator,{children:jsx(P2,{className:"h-4 w-4"})})})]})}function zo({className:e,...t}){return jsx(ye.Separator,{className:ee("-mx-1 my-1 h-px bg-muted",e),...t})}function C2({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 P2({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 td(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 E2=[{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 vg({value:e,onChange:t,fonts:n=E2,documentFonts:o,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:c=true}){let{t:s}=N(),d=rt.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]),m=rt.useMemo(()=>[...d,...n],[d,n]),p=rt.useMemo(()=>e?m.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||td(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=rt.useCallback(f=>{let b=m.find(x=>x.name===f);b&&t?.(td(b.fontFamily)||b.name);},[t,m]),u=rt.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return n.forEach(b=>{let x=b.category||"other";f[x].push(b);}),f},[n]);return jsxs(to,{value:p,onValueChange:g,disabled:r,children:[jsx(no,{className:ee("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":s("font.selectAriaLabel"),children:jsx(Vi,{placeholder:a,children:p})}),jsxs(ro,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(oo,{children:[jsx(qo,{children:s("font.documentFonts")}),d.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(zo,{})]}),u["sans-serif"].length>0&&jsxs(oo,{children:[jsx(qo,{children:s("font.sansSerif")}),u["sans-serif"].map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),u.serif.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsxs(oo,{children:[jsx(qo,{children:s("font.serif")}),u.serif.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),u.monospace.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsxs(oo,{children:[jsx(qo,{children:s("font.monospace")}),u.monospace.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),u.other.length>0&&jsxs(Fragment,{children:[jsx(zo,{}),jsx(oo,{children:u.other.map(f=>jsx(dt,{value:f.name,style:c?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function od(e){if(e===void 0)return;let t=e.map(n=>typeof n=="string"?{name:n,fontFamily:n,category:"other"}:n);return t}function M2(e,t,n,o){let i=Math.max(8,window.innerWidth-n-8),a=Math.max(8,window.innerHeight-o-8);return {top:Math.min(Math.max(8,e),a),left:Math.min(Math.max(8,t),i)}}function et({isOpen:e,onClose:t,align:n="left"}){let o=useRef(null),r=useRef(null),[i,a]=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(),m=M2(s.bottom+4,s.right-d.width,d.width,d.height);a(m);}else a({top:s.bottom+4,left:s.left});}):a({top:s.bottom+4,left:s.left});},[e,n]),useEffect(()=>{if(!e)return;let s=performance.now()+150,d=g=>{let u=g.target;o.current&&!o.current.contains(u)&&r.current&&!r.current.contains(u)&&t();},m=g=>{g.key==="Escape"&&t();},p=g=>{if(performance.now()<s)return;let u=g.target;u&&r.current&&r.current.contains(u)||u instanceof Element&&u!==document.documentElement&&u!==document.body&&o.current&&u.contains(o.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),window.addEventListener("scroll",p,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m),window.removeEventListener("scroll",p,true);}},[e,t]);let l=useCallback(s=>{s.preventDefault(),s.stopPropagation();},[]),c={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:o,dropdownRef:r,dropdownStyle:c,handleMouseDown:l}}var D2=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],N2=1,L2=400;function Sg(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function Tg(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 Cg({value:e,onChange:t,sizes:n=D2,disabled:o=false,className:r,placeholder:i="11",minSize:a=N2,maxSize:l=L2}){let{t:c}=N(),[s,d]=useState(false),[m,p]=useState(""),[g,u]=useState(false),f=useRef(null),b=useCallback(()=>{u(false),d(false);},[]),{containerRef:x,dropdownRef:T,dropdownStyle:h}=et({isOpen:g,onClose:b}),v=e??(parseInt(i,10)||11),y=e!==void 0?e.toString():i,S=useCallback(M=>{if(M.preventDefault(),o)return;let _=Tg(v,n,a);t?.(_);},[v,n,a,o,t]),w=useCallback(M=>{if(M.preventDefault(),o)return;let _=Sg(v,n,l);t?.(_);},[v,n,l,o,t]),P=useCallback(M=>{M.preventDefault(),!o&&(d(true),p(y),u(true),requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[o,y]),R=useCallback(M=>{p(M.target.value);},[]),E=useCallback(()=>{d(false);let M=parseFloat(m);if(!isNaN(M)&&M>=a&&M<=l){let _=Math.round(M*2)/2;t?.(_);}},[m,a,l,t]),L=useCallback(M=>{if(M.key==="Enter")M.preventDefault(),E(),u(false);else if(M.key==="Escape")d(false),u(false);else if(M.key==="ArrowUp"){M.preventDefault();let _=Sg(v,n,l);p(_.toString()),t?.(_);}else if(M.key==="ArrowDown"){M.preventDefault();let _=Tg(v,n,a);p(_.toString()),t?.(_);}},[E,v,n,l,a,t]),D=useCallback(M=>{t?.(M),u(false),d(false);},[t]),F=useCallback(M=>{M.target.tagName!=="INPUT"&&M.preventDefault();},[]);return jsxs("div",{ref:x,className:ee("flex items-center",r),onMouseDown:F,children:[jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:S,disabled:o||v<=a,"aria-label":c("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(z,{name:"remove",size:18})}),jsx("div",{className:"relative",children:s?jsx("input",{ref:f,type:"text",value:m,onChange:R,onBlur:E,onKeyDown:L,className:ee("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:P,className:ee("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:y})}),g&&jsx("div",{ref:T,style:{...h,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(M=>jsx("button",{type:"button",onClick:()=>D(M),className:ee("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",M===v&&"bg-muted font-medium"),role:"option","aria-selected":M===v,children:M},M))}),jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:w,disabled:o||v>=l,"aria-label":c("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(z,{name:"add",size:18})})]})}var H2=[{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"}],Wi=18,O2=2,B2={position:"relative",display:"inline-block"},Z2={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)"},q2={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},ad={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},id={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},wg={display:"grid",gap:`${O2}px`},Gi={width:`${Wi}px`,height:`${Wi}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},kg={...Gi,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},Rg={...Gi,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},z2={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)"},K2={display:"flex",alignItems:"center",gap:"6px"},$2={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},V2={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},Pg={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},U2={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},W2={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)"},G2={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 ld(e,t,n){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let o=fg(e);return o||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return ed(e,n)}function Eg(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 Mg(e,t,n){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Zt(e,n))===t.toUpperCase():false}function j2({matrix:e,selectedColor:t,theme:n,onSelect:o}){let[r,i]=useState(null);return jsx("div",{style:{...wg,gridTemplateColumns:`repeat(10, ${Wi}px)`},children:e.flatMap((a,l)=>a.map((c,s)=>{let d=`${l}-${s}`,m=r===d,p=Mg(t,c.hex,n);return jsx("button",{type:"button",style:{...p?Rg:m?kg:Gi,backgroundColor:`#${c.hex}`},title:c.label,"aria-label":c.label,"aria-selected":p,onClick:()=>o(c),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function Y2({selectedColor:e,theme:t,onSelect:n}){let[o,r]=useState(null),{t:i}=N();return jsx("div",{style:{...wg,gridTemplateColumns:`repeat(10, ${Wi}px)`},children:H2.map((a,l)=>{let c=o===l,s=Mg(e,a.hex,t),d=i(a.nameKey);return jsx("button",{type:"button",style:{...s?Rg:c?kg:Gi,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":s,onClick:()=>n(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function Vo({mode:e,value:t,onChange:n,theme:o,disabled:r=false,className:i,style:a,title:l,icon:c,autoLabel:s,splitButton:d=true,defaultColor:m}){let[p,g]=useState(false),[u,f]=useState(false),[b,x]=useState(false),[T,h]=useState(false),[v,y]=useState(""),[S,w]=useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:P}=N();useEffect(()=>{let W=ld(t,e,o).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(W)&&y(W.toUpperCase());},[t,e,o]);let R=useCallback(()=>g(false),[]),{containerRef:E,dropdownRef:L,dropdownStyle:D}=et({isOpen:p,onClose:R}),F=o?.colorScheme??null,M=useMemo(()=>gg(F),[F]),_=useMemo(()=>ld(t,e,o),[t,e,o]),k=useMemo(()=>ld(S,e,o),[S,e,o]),I=useCallback(()=>{r||g(W=>!W);},[r]),ae=useCallback(W=>{let Z;e==="highlight"?Z=W.hex:Z={kind:"theme",slot:W.themeSlot,...W.tint!==void 0?{tint:W.tint}:{},...W.shade!==void 0?{shade:W.shade}:{}},w(Z),n?.(Z),g(false);},[e,n]),K=useCallback(W=>{let Z=e==="highlight"?W:{kind:"hex",value:W};w(Z),n?.(Z),g(false);},[e,n]),$=useCallback(()=>{n?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,n]),V=useCallback(()=>{let W=v.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(W)){let Z=e==="highlight"?W:{kind:"hex",value:W};w(Z),n?.(Z),g(false),y("");}},[e,v,n]),oe=useCallback(()=>{r||n?.(S);},[r,S,n]),ne={...Z2,...r?{cursor:"default",opacity:.38}:p?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:u?{backgroundColor:"var(--doc-bg-hover)"}:{}},be=P(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),he=c??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:E,className:`docx-color-picker ${i||""}`,style:{...B2,...a},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...U2,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...W2,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:oe,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>x(true),onMouseLeave:()=>x(false),disabled:r,title:l||be,"aria-label":l||be,children:[jsx(z,{name:he,size:18}),jsx("div",{style:{...Pg,backgroundColor:k==="transparent"?"#fff":k,outline:k==="transparent"||Eg(k)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...G2,...r?{cursor:"default"}:p?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:T?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:I,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),disabled:r,title:l||be,"aria-label":l||be,"aria-haspopup":"true","aria-expanded":p,children:jsx(z,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:ne,onClick:I,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||be,"aria-label":l||be,"aria-haspopup":"true","aria-expanded":p,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(z,{name:he,size:18}),jsx("div",{style:{...Pg,backgroundColor:_==="transparent"?"#fff":_,outline:_==="transparent"||Eg(_)?"1px solid #bbb":"none"}})]}),jsx(z,{name:"arrow_drop_down",size:14})]}),p&&jsx("div",{ref:L,className:"docx-color-picker-dropdown",style:{...D,...q2},role:"dialog","aria-label":`${be} picker`,onMouseDown:W=>{W.target.tagName!=="INPUT"&&W.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:z2,onClick:$,onMouseDown:W=>W.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??P(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:id}),jsx("div",{style:ad,children:P("colorPicker.themeColors")}),jsx(j2,{matrix:M,selectedColor:t,theme:o,onSelect:ae}),jsx("div",{style:id}),jsx("div",{style:ad,children:P("colorPicker.standardColors")}),jsx(Y2,{selectedColor:t,theme:o,onSelect:K}),jsx("div",{style:id}),jsx("div",{style:ad,children:P("colorPicker.customColor")}),jsxs("div",{style:K2,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:$2,value:v,onChange:W=>y(W.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:W=>{W.key==="Enter"&&V();},onMouseDown:W=>{W.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...V2,opacity:/^[0-9A-Fa-f]{6}$/.test(v)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(v)?"pointer":"default"},onClick:V,onMouseDown:W=>W.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(v),children:P("common.apply")})]})]})})]})}var ca=20,sd=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(z,{name:"format_align_left",size:ca}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(z,{name:"format_align_center",size:ca}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(z,{name:"format_align_right",size:ca}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(z,{name:"format_align_justify",size:ca}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function Dg({value:e="left",onChange:t,disabled:n=false}){let{t:o}=N(),[r,i]=useState(false),a=useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:c,dropdownStyle:s,handleMouseDown:d}=et({isOpen:r,onClose:a}),m=useCallback(x=>{n||t?.(x),i(false);},[n,t]),p=sd.find(x=>x.value===e)||sd[0],g=o(p.labelKey),u=p.shortcutKey?o(p.shortcutKey):void 0,f=`${g}${u?` (${u})`:""}`,b=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",n&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!n&&i(x=>!x),disabled:n,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(z,{name:p.iconName,size:ca}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(ct,{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:x=>x.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:sd.map(x=>{let T=e===x.value,h=o(x.labelKey),v=x.shortcutKey?o(x.shortcutKey):void 0;return jsx("button",{type:"button",title:`${h}${v?` (${v})`:""}`,"data-testid":`alignment-${x.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:T?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:T?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{T||(y.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:y=>{y.currentTarget.style.backgroundColor=T?"var(--doc-primary-light)":"transparent";},onClick:()=>m(x.value),children:jsx(z,{name:x.iconName,size:18})},x.value)})})})]})}function ji(){return {type:"none",level:0,isInList:false}}var tw={display:"inline-flex",alignItems:"center",gap:"4px"},Ng={display:"inline-flex",alignItems:"center",gap:"4px"},Qi={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)"},ow={...Qi,backgroundColor:"var(--doc-bg-hover)"},nw={...Qi,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},rw={...Qi,cursor:"default",opacity:.38},aw={width:"28px",height:"28px",padding:"2px"},iw={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Yi=20;function Xi({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,style:a}){let[l,c]=useState(false),s={...t?rw:e?nw:l?ow:Qi,...a},d=m=>{m.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,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 Lg({listState:e,onBulletList:t,onNumberedList:n,onIndent:o,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:c=true,compact:s=false,hasIndent:d=false}){let{t:m}=N(),p=useCallback(()=>s?{...aw}:{},[s]),g=e?.type==="bullet",u=e?.type==="numbered",b=(e?.isInList||g||u)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...tw,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxs("div",{style:Ng,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsx(Xi,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:p(),children:jsx(z,{name:"format_list_bulleted",size:Yi})}),jsx(Xi,{active:u,disabled:i,title:m("lists.numberedList"),onClick:n,style:p(),children:jsx(z,{name:"format_list_numbered",size:Yi})})]}),c&&jsxs(Fragment,{children:[jsx("div",{style:iw,role:"separator"}),jsxs("div",{style:Ng,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsx(Xi,{active:false,disabled:i||!b,title:m("lists.decreaseIndent"),onClick:r,style:p(),children:jsx(z,{name:"format_indent_decrease",size:Yi})}),jsx(Xi,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:o,style:p(),children:jsx(z,{name:"format_indent_increase",size:Yi})})]})]})]})}var sw=[{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 Ag({value:e,onChange:t,options:n=sw,disabled:o=false,className:r}){let{t:i}=N(),a=rt.useMemo(()=>e===void 0?n[0]:n.find(s=>s.twipsValue===e)||n[0],[e,n]),l=rt.useCallback(s=>{let d=parseInt(s,10);isNaN(d)||t?.(d);},[t]),c=s=>s.labelKey?i(s.labelKey):s.label;return jsxs(to,{value:a.twipsValue.toString(),onValueChange:l,disabled:o,children:[jsx(no,{className:ee("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:c(a)}),children:jsx(uc,{className:"h-5 w-5 shrink-0"})}),jsxs(ro,{children:[n.map(s=>jsx(dt,{value:s.twipsValue.toString(),children:c(s)},s.twipsValue)),jsx(zo,{}),jsx(oo,{children:jsx(qo,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var Hg=[{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 Og({value:e,onChange:t,styles:n,disabled:o=false,className:r,width:i=120}){let{t:a}=N(),l=rt.useMemo(()=>{let g=Fp(n);return g.length===0?Hg:g.map(u=>({...u,type:"paragraph",nameKey:Hg.find(f=>f.styleId===u.styleId)?.nameKey}))},[n]),c=rt.useCallback(g=>{t?.(g);},[t]),s=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",m=l.find(g=>g.styleId===d),p=m?s(m):d;return jsxs(to,{value:d,onValueChange:c,disabled:o,children:[jsx(no,{className:ee("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:p})}),jsx(ro,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(dt,{value:g.styleId,className:"py-2.5 px-3",children:jsx("span",{style:Lp(g),children:s(g)})},g.styleId))})]})}var dw=[{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 Zg({value:e=1,onChange:t,levels:n=dw,disabled:o=false,className:r,compact:i=false}){let{t:a}=N(),l=rt.useMemo(()=>{let g=n.find(u=>Math.abs(u.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[n,e]),c=rt.useCallback(g=>{let u=parseFloat(g);isNaN(u)||t?.(u);},[t]),s=rt.useMemo(()=>[...n].sort((g,u)=>g.value-u.value),[n]),d=rt.useMemo(()=>[...s].reverse().find(g=>g.value<e-.001),[s,e]),m=rt.useMemo(()=>s.find(g=>g.value>e+.001),[s,e]),p=i?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee(p,"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":a("zoom.zoomOut"),children:jsx(z,{name:"remove",size:18})}),jsxs(to,{value:e.toString(),onValueChange:c,disabled:o,children:[jsx(no,{className:ee(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsx(Vi,{placeholder:"100%",children:l})}),jsx(ro,{children:n.map(g=>jsx(dt,{value:g.value.toString(),children:g.label},g.value))})]}),jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee(p,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(o||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:o||!m,"aria-label":a("zoom.zoomIn"),children:jsx(z,{name:"add",size:18})})]})}var pw=[{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 Kg({onAction:e,disabled:t=false}){let{t:n}=N(),[o,r]=useState(false),i=useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=et({isOpen:o,onClose:i}),d=useCallback(p=>{e(p),r(false);},[e]),m=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&r(p=>!p),disabled:t,"aria-label":n("table.borders.styleAriaLabel"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(z,{name:"border_all",size:20}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsx(ct,{content:n("table.borders.tooltip"),children:m}),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:p=>p.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:pw.map(({action:p,icon:g,labelKey:u})=>jsx("button",{type:"button",title:n(u),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(p),children:jsx(z,{name:g,size:18})},typeof p=="string"?p:p.type))})})]})}function $g({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=N(),i=useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Zt(a,n);l&&e({type:"borderColor",color:l});},[e,n]);return jsx(Vo,{mode:"border",value:o,onChange:i,theme:n,disabled:t,title:r("table.borderColor")})}var bw=[{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 Ug({onAction:e,disabled:t=false}){let[n,o]=useState(false),{t:r}=N(),i=useCallback(()=>o(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:c,handleMouseDown:s}=et({isOpen:n,onClose:i}),d=useCallback(p=>{e({type:"borderWidth",size:p}),o(false);},[e]),m=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:s,onClick:()=>!t&&o(p=>!p),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(z,{name:"line_weight",size:20}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?m:jsx(ct,{content:r("table.borderWidth"),children:m}),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:p=>p.stopPropagation(),children:bw.map(({size:p,label:g,thickness:u})=>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(p),children:[jsx("div",{style:{width:50,height:Math.max(u,1),backgroundColor:"#000",borderRadius:u>2?1:0}}),jsx("span",{children:g})]},p))})]})}function Gg({onAction:e,disabled:t=false,theme:n,value:o}){let{t:r}=N(),i=useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsx(Vo,{mode:"highlight",value:o,onChange:i,theme:n,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var vw={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"},Go={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},Xg={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function Jg({onAction:e,disabled:t=false,tableContext:n}){let{t:o}=N(),[r,i]=useState(false),[a,l]=useState(null),c=useCallback(()=>i(false),[]),{containerRef:s,dropdownRef:d,dropdownStyle:m,handleMouseDown:p}=et({isOpen:r,onClose:c,align:"right"}),g=n?.table?.attrs?.justification??"left",u=useCallback(x=>{e(x),i(false);},[e]),f=(x,T,h,v,y)=>{let S=t||y?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...vw,backgroundColor:a===x&&!S?"var(--doc-bg-hover)":"transparent",color:S?"var(--doc-text-muted)":y?.danger?"var(--doc-error)":"var(--doc-text)",cursor:S?"not-allowed":"pointer"},onClick:()=>!S&&u(v),onMouseEnter:()=>l(x),onMouseLeave:()=>l(null),disabled:S,children:[jsx(z,{name:T,size:16,className:y?.danger&&!S?"text-destructive":""}),jsx("span",{style:{flex:1},children:h})]},x)},b=jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:p,onClick:()=>!t&&i(x=>!x),disabled:t,"aria-label":o("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(z,{name:"more_vert",size:20})});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(ct,{content:o("table.moreOptions"),children:b}),r&&!t&&jsxs("div",{ref:d,style:{...m,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:x=>x.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:Go,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:Go,role:"separator"}),f("selectTable","select_all",o("table.selectTable"),"selectTable"),jsx("div",{style:Go,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:Go,role:"separator"}),jsx("div",{style:Xg,children:o("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(x=>{let T={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"}[x]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:v=>v.preventDefault(),onMouseEnter:v=>{v.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:v=>{v.currentTarget.style.backgroundColor="transparent";},onClick:()=>u({type:"cellVerticalAlign",align:x}),children:jsx(z,{name:T[x],size:16})},x)})}),jsx("div",{style:Go,role:"separator"}),jsx("div",{style:Xg,children:o("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(x=>{let T={left:"format_align_left",center:"format_align_center",right:"format_align_right"},h=g===x;return jsx("button",{type:"button",title:o({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[x]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:h?"var(--doc-primary-light)":"transparent",borderColor:h?"var(--doc-primary)":"var(--doc-border)",color:h?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:v=>v.preventDefault(),onClick:()=>u({type:"tableProperties",props:{justification:x}}),children:jsx(z,{name:T[x],size:16})},x)})}),jsx("div",{style:Go,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:Go,role:"separator"}),f("properties","settings",o("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var xw=20;function ol({options:e,activeValue:t,triggerIcon:n,tooltipContent:o,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:c=false}){let[s,d]=useState(false),m=useCallback(()=>d(false),[]),{containerRef:p,dropdownRef:g,dropdownStyle:u,handleMouseDown:f}=et({isOpen:s,onClose:m}),b=useCallback(T=>{i||r(T),d(false);},[i,r]),x=jsxs(Ae,{variant:"ghost",size:"icon-sm",className:ee("text-muted-foreground hover:text-foreground hover:bg-muted/80",s&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(T=>!T),disabled:i,"aria-label":a??o,"aria-expanded":s,"aria-haspopup":"true","data-testid":l,children:[jsx(z,{name:n,size:xw}),jsx(z,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:p,style:{position:"relative",display:"inline-block"},children:[s?x:jsx(ct,{content:o,children:x}),s&&!i&&jsx("div",{ref:g,style:{...u,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:T=>T.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:c?"column":"row",gap:c?1:2,minWidth:c?200:void 0},children:e.map(T=>{let h=t===T.value;return jsxs("button",{type:"button",title:T.label,"data-testid":l?`${l}-${T.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:h?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:h?"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:v=>v.preventDefault(),onMouseEnter:v=>{h||(v.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:v=>{v.currentTarget.style.backgroundColor=h?"var(--doc-primary-light)":"transparent";},onClick:()=>b(T.value),children:[jsx(z,{name:T.iconName,size:18}),c&&jsx("span",{style:{flex:1},children:T.label})]},T.value)})})})]})}var Sw=[{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 Tw(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function e0({imageContext:e,onChange:t,disabled:n=false}){let{t:o}=N(),r=Sw.map(l=>({...l,label:o(l.labelKey)})),i=Tw(e),a=r.find(l=>l.value===i)||r[0];return jsx(ol,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:n,testId:"toolbar-image-wrap",showLabels:true})}var Pw=[{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 t0({onTransform:e,disabled:t=false}){let{t:n}=N(),o=Pw.map(r=>({...r,label:n(r.labelKey)}));return jsx(ol,{options:o,triggerIcon:"rotate_right",tooltipContent:n("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var Tt=18;function ut({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||n?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),c=d=>{d.preventDefault();},s=jsx(Ae,{variant:"ghost",size:"icon-sm",className:ee("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"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":a||n,"data-testid":l?`toolbar-${l}`:void 0,children:r});return n?jsx(ct,{content:n,children:s}):s}function Ct({label:e,children:t,className:n}){return jsx("div",{className:ee("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 Mw(e){let t=rt__default.useContext(ia);return t?{...t,...Iw(e)}:e}function Iw(e){let t={};for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}function pd(e){let{t}=N(),n=Mw(e),{currentFormatting:o={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:c=false,disabled:s=false,className:d,style:m,enableShortcuts:p=true,editorRef:g,children:u,showFontPicker:f=true,fontFamilies:b,documentFonts:x,showFontSizePicker:T=true,showTextColorPicker:h=true,showHighlightColorPicker:v=true,showAlignmentButtons:y=true,showListButtons:S=true,showLineSpacingPicker:w=true,showStylePicker:P=true,documentStyles:R,theme:E,showZoomControl:L=true,zoom:D,onZoomChange:F,onRefocusEditor:M,imageContext:_,onImageWrapType:k,onImageTransform:I,onOpenImageProperties:ae,tableContext:K,onTableAction:$,inline:V=false}=n,oe=useRef(null),ne=useCallback(pe=>{!s&&r&&r(pe);},[s,r]),be=useCallback(()=>{!s&&l&&i&&i();},[s,l,i]),he=useCallback(()=>{!s&&c&&a&&a();},[s,c,a]),W=useCallback(pe=>{!s&&r&&r({type:"fontFamily",value:pe});},[s,r]),Z=rt__default.useMemo(()=>od(b),[b]),we=useCallback(pe=>{!s&&r&&r({type:"fontSize",value:pe});},[s,r]),ce=useCallback(pe=>{!s&&r&&r({type:"textColor",value:pe});},[s,r]),de=useCallback(pe=>{!s&&r&&r({type:"highlightColor",value:typeof pe=="string"?pe:""});},[s,r]),Ve=useCallback(pe=>{!s&&r&&r({type:"alignment",value:pe});},[s,r]),uo=useCallback(()=>{!s&&r&&r("bulletList");},[s,r]),mt=useCallback(()=>{!s&&r&&r("numberedList");},[s,r]),po=useCallback(()=>{!s&&r&&r("indent");},[s,r]),Me=useCallback(()=>{!s&&r&&r("outdent");},[s,r]),sl=useCallback(pe=>{!s&&r&&(r({type:"lineSpacing",value:pe}),requestAnimationFrame(()=>M?.()));},[s,r,M]),An=useCallback(pe=>{!s&&r&&r({type:"applyStyle",value:pe});},[s,r]),Pt=useCallback(pe=>{!s&&$&&($(pe),requestAnimationFrame(()=>M?.()));},[s,$,M]);useEffect(()=>{if(!p)return;let pe=me=>{if(me.defaultPrevented)return;let at=me.target,On=g?.current,pa=oe.current,mo=On?.contains(at),gd=pa?.contains(at);if(!mo&&!gd)return;if((me.ctrlKey||me.metaKey)&&!me.altKey)switch(me.key.toLowerCase()){case "b":me.preventDefault(),ne("bold");break;case "i":me.preventDefault(),ne("italic");break;case "u":me.preventDefault(),ne("underline");break;case "=":me.shiftKey?(me.preventDefault(),ne("superscript")):(me.preventDefault(),ne("subscript"));break;case "l":me.preventDefault(),Ve("left");break;case "e":me.preventDefault(),Ve("center");break;case "r":me.preventDefault(),Ve("right");break;case "j":me.preventDefault(),Ve("both");break;case "k":me.preventDefault(),ne("insertLink");break}};return document.addEventListener("keydown",pe),()=>{document.removeEventListener("keydown",pe);}},[p,ne,Ve,g]);let Hn=useCallback(pe=>{let me=pe.target;me.tagName==="INPUT"||me.tagName==="TEXTAREA"||me.tagName==="SELECT"||me.tagName==="OPTION"||pe.preventDefault();},[]),Yo=useCallback(pe=>{let me=pe.target,at=document.activeElement;me.tagName==="SELECT"||me.tagName==="OPTION"||at?.tagName==="SELECT"||requestAnimationFrame(()=>{M?.();});},[M]);return jsxs("div",{ref:oe,className:ee(!V&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:V?{display:"contents",...m}:m,role:V?void 0:"toolbar","aria-label":V?void 0:t("toolbar.ariaLabel"),"data-testid":V?void 0:"formatting-bar",onMouseDown:V?void 0:Hn,onMouseUp:V?void 0:Yo,children:[jsxs(Ct,{label:t("formattingBar.groups.history"),children:[jsx(ut,{onClick:be,disabled:s||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(z,{name:"undo",size:Tt})}),jsx(ut,{onClick:he,disabled:s||!c,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(z,{name:"redo",size:Tt})})]}),L&&jsx(Ct,{label:t("formattingBar.groups.zoom"),children:jsx(Zg,{value:D,onChange:F,disabled:s,compact:true})}),P&&jsx(Ct,{label:t("formattingBar.groups.styles"),children:jsx(Og,{value:o.styleId||"Normal",onChange:An,styles:R,theme:E,disabled:s,width:120})}),(f||T)&&jsxs(Ct,{label:t("formattingBar.groups.font"),children:[f&&jsx(vg,{value:o.fontFamily||"Arial",onChange:W,fonts:Z,documentFonts:x,disabled:s,width:60,placeholder:"Arial"}),T&&jsx(Cg,{value:o.fontSize!==void 0?wl(o.fontSize):11,onChange:we,disabled:s,width:42,placeholder:"11"})]}),jsxs(Ct,{label:t("formattingBar.groups.textFormatting"),children:[jsx(ut,{onClick:()=>ne("bold"),active:o.bold,disabled:s,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(z,{name:"format_bold",size:Tt})}),jsx(ut,{onClick:()=>ne("italic"),active:o.italic,disabled:s,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(z,{name:"format_italic",size:Tt})}),jsx(ut,{onClick:()=>ne("underline"),active:o.underline,disabled:s,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(z,{name:"format_underlined",size:Tt})}),jsx(ut,{onClick:()=>ne("strikethrough"),active:o.strike,disabled:s,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(z,{name:"strikethrough_s",size:Tt})}),h&&jsx(Vo,{mode:"text",value:o.color?.replace(/^#/,""),onChange:ce,theme:E,disabled:s,title:t("formattingBar.fontColor")}),v&&jsx(Vo,{mode:"highlight",value:o.highlight,onChange:de,theme:E,disabled:s,title:t("formattingBar.highlightColor")}),jsx(ut,{onClick:()=>ne("insertLink"),disabled:s,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(z,{name:"link",size:Tt})})]}),jsxs(Ct,{label:t("formattingBar.groups.script"),children:[jsx(ut,{onClick:()=>ne("superscript"),active:o.superscript,disabled:s,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(z,{name:"superscript",size:Tt})}),jsx(ut,{onClick:()=>ne("subscript"),active:o.subscript,disabled:s,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(z,{name:"subscript",size:Tt})})]}),y&&jsx(Ct,{label:t("formattingBar.groups.alignment"),children:jsx(Dg,{value:o.alignment||"left",onChange:Ve,disabled:s})}),(S||w)&&jsxs(Ct,{label:t("formattingBar.groups.listFormatting"),children:[S&&jsx(Lg,{listState:o.listState||ji(),onBulletList:uo,onNumberedList:mt,onIndent:po,onOutdent:Me,disabled:s,showIndentButtons:true,compact:true,hasIndent:(o.indentLeft??0)>0}),w&&jsx(Ag,{value:o.lineSpacing,onChange:sl,disabled:s})]}),_&&k&&jsxs(Ct,{label:t("formattingBar.groups.image"),children:[jsx(e0,{imageContext:_,onChange:k,disabled:s}),I&&jsx(t0,{onTransform:I,disabled:s}),ae&&jsx(ut,{onClick:ae,disabled:s,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(z,{name:"tune",size:Tt})})]}),K?.isInTable&&$&&jsxs(Ct,{label:t("formattingBar.groups.table"),children:[jsx(Kg,{onAction:Pt,disabled:s}),jsx($g,{onAction:Pt,disabled:s,theme:E,value:Zt(K?.cellBorderColor,E)}),jsx(Ug,{onAction:Pt,disabled:s}),jsx(Gg,{onAction:Pt,disabled:s,theme:E,value:K?.cellBackgroundColor}),jsx(Jg,{onAction:Pt,disabled:s,tableContext:K})]}),jsx(ut,{onClick:()=>ne("clearFormatting"),disabled:s,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(z,{name:"format_clear",size:Tt})}),u]})}function _w({children:e,className:t,style:n,...o}){return jsx(ia.Provider,{value:o,children:jsx("div",{className:ee("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:Qe.toolbar,...n},"data-testid":"editor-toolbar",children:e})})}var tt=_w;tt.TitleBar=Qc;tt.Logo=qi;tt.DocumentName=Jc;tt.MenuBar=Ki;tt.TitleBarRight=zi;tt.Toolbar=pd;var Lw=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"]]),Fw=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function Aw({source:e,scale:t,measurer:n,documentName:o,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:c,ref:s,colorMode:d,onZoomChange:m,documentFontFamily:p,className:g}){let u=useRef(null),[f,b]=useState(null),[x,T]=useState({}),[h,v]=useState(null),y=useCallback(R=>{b(R);let E=u.current?.formatting();E&&T({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}:{}}),v(u.current?.sectionProperties()??null),r?.(R);},[r]),S=useCallback(R=>{let E=u.current;if(E){if(typeof R=="string")switch(R){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(R.type){case "fontFamily":return E.setRunProperty("rFonts",{ascii:R.value,hAnsi:R.value});case "fontSize":return E.setRunProperty("sz",{val:String(Math.round(R.value*2))});case "textColor":{let L=R.value,D=typeof L=="string"?Fw(L):Zt(L,null)??null;return D?E.setRunProperty("color",{val:D}):void 0}case "highlightColor":{let L=R.value.trim().toLowerCase();if(L==="none"||L==="")return E.setRunProperty("highlight",{val:"none"});let D=Lw.get(L.startsWith("#")?L:`#${L}`);return D?E.setRunProperty("highlight",{val:D}):void 0}case "alignment":return E.setParagraphProperty("jc",{val:String(R.value)});case "lineSpacing":return E.setParagraphProperty("spacing",{line:String(Math.round(R.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return E.setParagraphProperty("pStyle",{val:R.value});default:return}}},[]);useImperativeHandle(s,()=>u.current,[]);let w=t===void 0?1:t/(96/72),P=h?{pageWidthTwips:h.pageSize.widthTwips,pageHeightTwips:h.pageSize.heightTwips,orientation:h.landscape?"landscape":"portrait",marginsTwips:{top:h.margins.topTwips,right:h.margins.rightTwips,bottom:h.margins.bottomTwips,left:h.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(tt,{currentFormatting:x,onFormat:S,onUndo:()=>u.current?.undo(),onRedo:()=>u.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:w,onZoomChange:m,onSave:()=>{let R=u.current?.save();R&&a?.(R);},children:[jsxs(tt.TitleBar,{children:[l&&jsx(tt.Logo,{children:l()}),jsx(tt.DocumentName,{value:o??"Document",editable:false}),c&&jsx(tt.TitleBarRight,{children:c()}),jsx(tt.MenuBar,{})]}),jsx(tt.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[P?jsx("div",{style:{padding:"4px 0"},children:jsx(Io,{pageSetup:P,zoom:w})}):null,jsx(Wc,{ref:u,source:e,...p?{documentFontFamily:p}:{},...t===void 0?{}:{scale:t},...n?{measurer:n}:{},onStateChange:y,...i?{onError:i}:{}})]})]})}var rl=class{listeners=new Set;snapshot;constructor(t){this.snapshot=t;}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t);});getSnapshot=()=>this.snapshot;setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var al=class extends rl{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,n){return this.addNotification(t,"error",n)}showWarning(t,n){return this.addNotification(t,"warning",n)}showInfo(t,n){return this.addNotification(t,"info",n)}dismiss(t){this.notifications=this.notifications.map(o=>o.id===t?{...o,dismissed:true}:o),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(o=>o.id!==t),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,n,o){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:n,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),n!=="error"){let a=setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var zw=createContext(null);function i0({children:e}){let t=useMemo(()=>new al,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((s,d)=>{t.showError(s,d);},[t]),r=useCallback((s,d)=>{t.showWarning(s,d);},[t]),i=useCallback((s,d)=>{t.showInfo(s,d);},[t]),a=useCallback(s=>{t.dismiss(s);},[t]),l=useCallback(()=>{t.clearAll();},[t]),c=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[n.notifications,o,r,i,a,l]);return jsxs(zw.Provider,{value:c,children:[e,jsx(Kw,{notifications:n.notifications,onDismiss:a})]})}function Kw({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($w,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function $w({notification:e,onDismiss:t}){let{t:n}=N(),[o,r]=useState(false),a=(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:a.bg,border:`1px solid ${a.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:a.icon,flexShrink:0},d={flex:1,minWidth:0},m={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},p={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:a.text,maxHeight:"200px",overflow:"auto"},g={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:a.text},u=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 rt from'react';import rt__default,{createContext,useState,useEffect,fo
10
10
  transform: translateX(0);
11
11
  }
12
12
  }
13
- `}),jsxs("div",{style:c,children:[jsx("span",{style:s,children:u(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:m,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:p,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 il=class extends Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,n){this.setState({errorInfo:n}),console.error("ErrorBoundary caught an error:",t,n),this.props.onError&&this.props.onError(t,n);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:n=true}=this.props,{error:o,errorInfo:r}=this.state;return t?typeof t=="function"?t(o,this.resetError):t:jsx($w,{error:o,errorInfo:r,showDetails:n,onReset:this.resetError})}return this.props.children}};function $w({error:e,errorInfo:t,showDetails:n,onReset:o}){let{t:r}=_(),i={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"},a={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:i,children:[jsx("div",{style:a,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:[`
13
+ `}),jsxs("div",{style:c,children:[jsx("span",{style:s,children:u(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:m,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:p,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 il=class extends Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,n){this.setState({errorInfo:n}),console.error("ErrorBoundary caught an error:",t,n),this.props.onError&&this.props.onError(t,n);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:n=true}=this.props,{error:o,errorInfo:r}=this.state;return t?typeof t=="function"?t(o,this.resetError):t:jsx(Vw,{error:o,errorInfo:r,showDetails:n,onReset:this.resetError})}return this.props.children}};function Vw({error:e,errorInfo:t,showDetails:n,onReset:o}){let{t:r}=N(),i={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"},a={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:i,children:[jsx("div",{style:a,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 cg({onClick:e,topPx:t,scrollLeft:n=0,leftOffset:o=fn}){let{t:r}=_();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:o-n,top:t,zIndex:Qe.outline},children:jsx(z,{name:"format_list_bulleted",size:20})})}function md({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 Uw({i18n:e,isDark:t,onEditorError:n,containerRef:o,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:c,editorContainerStyle:s,showRuler:d,readOnlyProp:m,showOutline:p,showOutlineButton:g,sidebarOpen:u,minLayoutWidth:f,toolbarHeight:h,editorScrollLeft:S,expandedSidebarItem:C,trackedChanges:v,onScrollContainerMouseDown:x,onEditorBgMouseDown:b,onEditorContextMenu:y,horizontalRulerProps:T,verticalRulerProps:k,outlineProps:E,onToggleOutline:w,scrollPageInfo:A,toolbar:N,pagedArea:F,overlays:I,dialogs:D,fileInputs:R}){return jsx(So.Provider,{value:true,children:jsx(Xo,{i18n:e,children:jsx(ig,{children:jsx(il,{onError:n,children:jsxs("div",{ref:o,className:ee("docx-editor",t&&"dark",a),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:[N,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:s,onMouseDown:x,children:[d&&jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:Qe.ruler,paddingLeft:20,paddingRight:20+(u?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsx(Io,{...T})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:b,onContextMenu:y,children:[d&&!m&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:Qe.ruler,paddingTop:48},children:jsx(Fr,{...k})}),C&&C.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${C.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; }`}),C?.startsWith("tc-")&&(()=>{let M=C.split("-")[1],K=v.find($=>String($.id)===M)?.id??M;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 c0({onClick:e,topPx:t,scrollLeft:n=0,leftOffset:o=gn}){let{t:r}=N();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:o-n,top:t,zIndex:Qe.outline},children:jsx(z,{name:"format_list_bulleted",size:20})})}function fd({currentPage:e,totalPages:t,visible:n}){let{t:o}=N();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 Ww({i18n:e,isDark:t,onEditorError:n,containerRef:o,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:c,editorContainerStyle:s,showRuler:d,readOnlyProp:m,showOutline:p,showOutlineButton:g,sidebarOpen:u,minLayoutWidth:f,toolbarHeight:b,editorScrollLeft:x,expandedSidebarItem:T,trackedChanges:h,onScrollContainerMouseDown:v,onEditorBgMouseDown:y,onEditorContextMenu:S,horizontalRulerProps:w,verticalRulerProps:P,outlineProps:R,onToggleOutline:E,scrollPageInfo:L,toolbar:D,pagedArea:F,overlays:M,dialogs:_,fileInputs:k}){return jsx(So.Provider,{value:true,children:jsx(Xo,{i18n:e,children:jsx(i0,{children:jsx(il,{onError:n,children:jsxs("div",{ref:o,className:ee("docx-editor",t&&"dark",a),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:[D,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:s,onMouseDown:v,children:[d&&jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:Qe.ruler,paddingLeft:20,paddingRight:20+(u?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsx(Io,{...w})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y,onContextMenu:S,children:[d&&!m&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:Qe.ruler,paddingTop:48},children:jsx(Ar,{...P})}),T&&T.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${T.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; }`}),T?.startsWith("tc-")&&(()=>{let I=T.split("-")[1],K=h.find($=>String($.id)===I)?.id??I;return jsx("style",{children:`
16
16
  .paged-editor__pages .docx-insertion[data-revision-id="${K}"] { 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="${K}"] { background-color: rgba(211, 47, 47, 0.2) !important; text-decoration-thickness: 2px !important; }
18
- `})})(),F]})})]}),A.totalPages>1&&jsx(md,{currentPage:A.currentPage,totalPages:A.totalPages,visible:A.visible}),p&&jsx(Hr,{...E,leftOffset:Ar+(d?mn:0)}),g&&!p&&jsx(cg,{onClick:w,topPx:h+(d?30:0)+48,scrollLeft:S,leftOffset:fn+(d?mn:0)})]})}),I,D,R]})})})})})}function Qw(e){let[t,n]=useState(0);return useEffect(()=>{if(!e)return;let o=()=>n(a=>a+1),r=e.on("change",o),i=e.on("selectionChange",o);return o(),()=>{r(),i();}},[e]),t}export{Xe as CONTENT_CONTROL_SLOTS,Bo as ContextMenuCellVerticalAlignment,Jr as ContextMenuCopy,Xr as ContextMenuCut,Qr as ContextMenuDelete,Rn as ContextMenuDeleteTable,kn as ContextMenuDeleteTableColumn,wn as ContextMenuDeleteTableRow,Pn as ContextMenuInsertColumnLeft,En as ContextMenuInsertColumnRight,Tn as ContextMenuInsertRowAbove,Cn as ContextMenuInsertRowBelow,Li as ContextMenuItem,Sn as ContextMenuPaste,Mn as ContextMenuRefreshToc,In as ContextMenuRefreshTocPageNumbers,ea as ContextMenuSelectAll,Xc as DocumentName,Hr as DocumentOutline,y1 as DocxEditor,Rl as DocxEditorAuthorStyle,kl as DocxEditorColorByChangeType,Sa as DocxEditorContent,Oi as DocxEditorContentControl,oa as DocxEditorContextMenu,pc as DocxEditorDocumentOutline,Mi as DocxEditorEquation,Ei as DocxEditorFontNotice,wi as DocxEditorHeaderFooterChrome,gi as DocxEditorHorizontalRuler,Ri as DocxEditorHyperLink,is as DocxEditorImagePropertiesDialog,Ca as DocxEditorLoading,wl as DocxEditorLoadingSpinner,Dr as DocxEditorMenu,xc as DocxEditorNavigation,Ii as DocxEditorNotesChrome,Pi as DocxEditorPageNumber,Er as DocxEditorPageSetupDialog,To as DocxEditorParagraphDialog,Gn as DocxEditorRoot,Uw as DocxEditorShell,Pr as DocxEditorToolbar,bi as DocxEditorVerticalRuler,Ma as DocxEditorViewport,Io as HorizontalRuler,qa as ImageAltText,ha as ImageInsertProvider,va as ImageInsertTrigger,Va as ImagePropertiesTrigger,Za as ImageWrap,Xo as LocaleProvider,qi as Logo,Ki as MenuBar,pf as NAVIGATION_PANE_GAP,hi as NAVIGATION_PANE_INSET,gn as NAVIGATION_PANE_WIDTH,qr as NavigationClose,Ur as NavigationFind,Zr as NavigationHeader,Vr as NavigationHeadings,$r as NavigationTab,Kr as NavigationTabs,zr as NavigationTitle,Wr as NavigationToggle,fn as OUTLINE_BUTTON_LEFT_OFFSET,uP as OUTLINE_BUTTON_RESERVED_SPACE,Ar as OUTLINE_LEFT_OFFSET,cP as OUTLINE_RESERVED_SPACE,md as PageIndicator,Ci as PageNumberTranslationContext,Uc as PaginatedDocxEditor,Fw as PaginatedDocxEditorShell,Bl as REVIEW_MARKERS_GUTTER,Zl as REVIEW_PANE_GUTTER,mn as RULER_WIDTH,ft as ReviewRailContext,bc as SEARCH_DEBOUNCE_MS,hc as SEARCH_MATCH_LIMIT,j as Slot,Jc as TitleBar,zi as TitleBarRight,ud as Toolbar,ut as ToolbarButton,fo as ToolbarContext,Ct as ToolbarGroup,an as ToolbarImageProperties,pg as VERSION,Fr as VerticalRuler,Sg as editorStateActiveSubscriptionCount,Kn as isFieldLink,No as navigationPaneReservation,vi as navigationShift,ma as normalizeImageBytes,kd as notificationYieldsToTask,Bb as provideDocxEditor,ou as reviewGutter,wd as useChromeTranslate,Et as useContentControl,wa as useContentControlInstance,Df as useContextMenuTarget,yi as useDocumentOutline,xi as useDocumentSearch,H as useDocxEditor,P1 as useDocxSource,A1 as useEditorCaret,le as useEditorCommand,Ds as useEditorEvent,Qw as useEditorSnapshot,O as useEditorState,nr as useEditorValueCommand,ja as useFontFamily,R1 as useFonts,Tc as useHeaderFooterState,Ml as useHyperlinkPopup,Ea as useHyperlinkPopupInstance,Si as useNavigationPane,xo as useNavigationShift,Bc as useNotePropertiesState,Oc as useNoteScopeState,Eo as usePageSetup,Vl as useParagraphFormat,ic as useParagraphIndent,Ya as useParagraphStyle,D1 as useReviewAuthors,tn as useReviewGutter,ot as useScopeClassName,Gr as useScopedChromeAnchor,um as useTableBorderTargetLabel,Rg as useToolbarContext,X as useToolbarLabel,fa as useToolbarLabelFor,_ as useTranslation,cs as useZoom};
18
+ `})})(),F]})})]}),L.totalPages>1&&jsx(fd,{currentPage:L.currentPage,totalPages:L.totalPages,visible:L.visible}),p&&jsx(Or,{...R,leftOffset:Hr+(d?fn:0)}),g&&!p&&jsx(c0,{onClick:E,topPx:b+(d?30:0)+48,scrollLeft:x,leftOffset:gn+(d?fn:0)})]})}),M,_,k]})})})})})}function e8(e){let[t,n]=useState(0);return useEffect(()=>{if(!e)return;let o=()=>n(a=>a+1),r=e.on("change",o),i=e.on("selectionChange",o);return o(),()=>{r(),i();}},[e]),t}export{Xe as CONTENT_CONTROL_SLOTS,Bo as ContextMenuCellVerticalAlignment,Qr as ContextMenuCopy,Jr as ContextMenuCut,ea as ContextMenuDelete,Mn as ContextMenuDeleteTable,Rn as ContextMenuDeleteTableColumn,kn as ContextMenuDeleteTableRow,En as ContextMenuInsertColumnLeft,wn as ContextMenuInsertColumnRight,Cn as ContextMenuInsertRowAbove,Pn as ContextMenuInsertRowBelow,Li as ContextMenuItem,Tn as ContextMenuPaste,In as ContextMenuRefreshToc,_n as ContextMenuRefreshTocPageNumbers,ta as ContextMenuSelectAll,Jc as DocumentName,Or as DocumentOutline,x1 as DocxEditor,Ml as DocxEditorAuthorStyle,Rl as DocxEditorColorByChangeType,Sa as DocxEditorContent,Oi as DocxEditorContentControl,na as DocxEditorContextMenu,mc as DocxEditorDocumentOutline,Mi as DocxEditorEquation,Ei as DocxEditorFontNotice,wi as DocxEditorHeaderFooterChrome,gi as DocxEditorHorizontalRuler,Ri as DocxEditorHyperLink,ls as DocxEditorImagePropertiesDialog,Ca as DocxEditorLoading,kl as DocxEditorLoadingSpinner,Nr as DocxEditorMenu,Sc as DocxEditorNavigation,Ii as DocxEditorNotesChrome,Pi as DocxEditorPageNumber,wr as DocxEditorPageSetupDialog,To as DocxEditorParagraphDialog,jn as DocxEditorRoot,Ww as DocxEditorShell,Er as DocxEditorToolbar,bi as DocxEditorVerticalRuler,Ma as DocxEditorViewport,Io as HorizontalRuler,qa as ImageAltText,va as ImageInsertProvider,ya as ImageInsertTrigger,Va as ImagePropertiesTrigger,Za as ImageWrap,Xo as LocaleProvider,qi as Logo,Ki as MenuBar,pf as NAVIGATION_PANE_GAP,hi as NAVIGATION_PANE_INSET,bn as NAVIGATION_PANE_WIDTH,zr as NavigationClose,Wr as NavigationFind,qr as NavigationHeader,Ur as NavigationHeadings,Vr as NavigationTab,$r as NavigationTabs,Kr as NavigationTitle,Gr as NavigationToggle,gn as OUTLINE_BUTTON_LEFT_OFFSET,pP as OUTLINE_BUTTON_RESERVED_SPACE,Hr as OUTLINE_LEFT_OFFSET,dP as OUTLINE_RESERVED_SPACE,fd as PageIndicator,Ci as PageNumberTranslationContext,Wc as PaginatedDocxEditor,Aw as PaginatedDocxEditorShell,Zl as REVIEW_MARKERS_GUTTER,ql as REVIEW_PANE_GUTTER,fn as RULER_WIDTH,ft as ReviewRailContext,hc as SEARCH_DEBOUNCE_MS,vc as SEARCH_MATCH_LIMIT,j as Slot,Qc as TitleBar,zi as TitleBarRight,pd as Toolbar,ut as ToolbarButton,fo as ToolbarContext,Ct as ToolbarGroup,ln as ToolbarImageProperties,p0 as VERSION,Ar as VerticalRuler,S0 as editorStateActiveSubscriptionCount,$n as isFieldLink,No as navigationPaneReservation,vi as navigationShift,fa as normalizeImageBytes,Rd as notificationYieldsToTask,Zb as provideDocxEditor,ou as reviewGutter,kd as useChromeTranslate,Et as useContentControl,wa as useContentControlInstance,Df as useContextMenuTarget,yi as useDocumentOutline,xi as useDocumentSearch,H as useDocxEditor,E1 as useDocxSource,H1 as useEditorCaret,le as useEditorCommand,Ns as useEditorEvent,e8 as useEditorSnapshot,O as useEditorState,rr as useEditorValueCommand,ja as useFontFamily,M1 as useFonts,Cc as useHeaderFooterState,Il as useHyperlinkPopup,Ea as useHyperlinkPopupInstance,Si as useNavigationPane,xo as useNavigationShift,Zc as useNotePropertiesState,Bc as useNoteScopeState,Eo as usePageSetup,Ul as useParagraphFormat,lc as useParagraphIndent,Ya as useParagraphStyle,N1 as useReviewAuthors,on as useReviewGutter,ot as useScopeClassName,jr as useScopedChromeAnchor,um as useTableBorderTargetLabel,R0 as useToolbarContext,X as useToolbarLabel,ga as useToolbarLabelFor,N as useTranslation,ds as useZoom};