@docx-editor.dev/react 2.30.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/dist/index.d.mts +866 -83
- package/dist/index.d.ts +866 -83
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/docs/accept-reject-without-scrolling.md +72 -0
- package/docs/comment-on-found-text.md +47 -0
- package/docs/custom-review-cards.md +105 -0
- package/docs/highlight-ranges.md +25 -0
- package/docs/index.md +36 -0
- package/docs/propose-rewrite.md +247 -0
- package/docs/tracked-replacement.md +45 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var Et=require('react'),i18n=require('@docx-editor.dev/i18n'),jsxRuntime=require('react/jsx-runtime'),editor=require('@docx-editor.dev/core/editor'),store=require('@docx-editor.dev/core/store'),reactDom=require('react-dom'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),we=require('@radix-ui/react-select'),editor$1=require('@docx-editor.dev/core/contracts/editor');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Et__namespace=/*#__PURE__*/_interopNamespace(Et);var we__namespace=/*#__PURE__*/_interopNamespace(we);var fm={version:"2.30.0"};var Qy=fm.version;var dc=Et.createContext(i18n.en),uc=Et.createContext("en");function Un({i18n:e,children:t}){let o=Et.useContext(dc),n=Et.useContext(uc),r=typeof e?._lang=="string"?e._lang:n,i=Et.useMemo(()=>i18n.deepMerge(o,e),[o,e]);return jsxRuntime.jsx(uc.Provider,{value:r,children:jsxRuntime.jsx(dc.Provider,{value:i,children:t})})}function N(){let e=Et.useContext(dc),t=Et.useContext(uc);return {t:Et.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e}}function vm(e){let{t}=N();return Et.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var pc=Et.createContext(null);function H(){return Et.useContext(pc)}var Ct=Et.createContext(null);var mc=0,fc=false,gc=false;function xm(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(fc||(fc=true,mc+=1,queueMicrotask(()=>{fc=false;}),gc||(gc=true,setTimeout(()=>{gc=false,mc=0;},0))),mc>16)}function Cm(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};xm()?setTimeout(o,0):queueMicrotask(o);}}var lx=()=>{},bc=0;function sx(){return bc}function $r(e){return Cm(e)}function B(e,t=Object.is,o){let n=H(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=Et.useCallback(d=>{if(!n)return lx;let f=false;bc++,r?.();let u=$r(()=>{f||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{f=true,bc--,i?.();for(let m of g)m();}},[n,r,i]),s=Et.useMemo(()=>{let d=false,f,u;return g=>{if(d&&g===f)return u;let m=e(g);return d&&t(u,m)?(f=g,u):(d=true,f=g,u=m,m)}},[n,e,t]),l=Et.useCallback(()=>s(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,s]),c=Et.useCallback(()=>s(editor.LOADING_SNAPSHOT),[s]);return Et.useSyncExternalStore(a,l,c)}function px(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function mx(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=px(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function G({children:e,...t}){let o=Et.Children.only(e);if(!Et.isValidElement(o))return null;let n=o.props,r=mx(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=s=>{for(let l of [i,a])typeof l=="function"?l(s):l&&typeof l=="object"&&(l.current=s);}),Et.cloneElement(o,r)}var Sm=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function ko(){let e=Et.createContext(null),t=new Map,o=y=>{let x=t.get(y.type);return x==="field"?`field:${y.props.name}`:x};function n(y,x){Et.Children.forEach(y,b=>{Et.isValidElement(b)&&(x(b),n(b.props.children,x));});}function r(){let y=Et.useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,x){return Et.Children.map(y,b=>{if(!Et.isValidElement(b))return b;let h=Sm(b.props);return h&&x.has(h)?x.get(h):b.props.children===void 0?b:Et.cloneElement(b,{children:i(b.props.children,x)})})}function a(y){function x(b){let h=Et.useContext(e);if(!h||b.hidden)return null;let C=y==="field"?`field:${b.name}`:y,T=h.defaults.get(C);if(!T)return b.children??null;let{children:S,asChild:P,className:k,style:w,hidden:E,name:D,...A}=b,_={...A,...T.props,className:[T.props.className,k].filter(Boolean).join(" "),style:{...T.props.style,...w}};if(P){let{children:F,className:M,style:I,...U}=_;return jsxRuntime.jsx(G,{...U,...k?{className:k}:{},...w?{style:w}:{},children:S})}return Et.cloneElement(T,_,S===void 0?i(T.props.children,h.overrides):S)}return t.set(x,y),x}let s=a("header"),l=a("title"),c=a("body"),d=a("footer"),f=a("apply"),u=a("cancel"),g=a("reset"),m=a("error"),p=a("field");function v({defaults:y,children:x,preset:b=true,state:h}){let C=new Map;n(y,k=>{let w=Sm(k.props);w&&C.set(w,k);});let T=new Map;n(x,k=>{let w=o(k);w&&T.set(w,k);});let S=k=>Et.Children.toArray(k).flatMap(w=>Et.isValidElement(w)&&w.type===Et.Fragment?S(w.props.children):[w]),P=S(x).filter(k=>!Et.isValidElement(k)||!o(k));return jsxRuntime.jsx(e.Provider,{value:{defaults:C,overrides:T,state:h},children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(y,T),P]}):x})}return {Header:s,Title:l,Body:c,Footer:d,Apply:f,Cancel:u,Reset:g,Error:m,Field:p,Composition:v,useState:r}}function pt({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:s,children:l,dismissOutside:c=true,sessionSignal:d,restoreFocus:f=true}){let u=Et.useRef(null),g=s??u,m=Et.useRef(i);return m.current=i,Et.useLayoutEffect(()=>{let p=g.current;if(!p)return;p.parentElement?.closest(".docx-editor")||p.classList.add("docx-editor");let v=p.ownerDocument.activeElement,y=()=>{p.open&&p.close?.();};return d?.addEventListener("abort",y),typeof p.showModal=="function"?p.showModal():p.setAttribute("open",""),p.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",y),typeof p.close=="function"&&p.open&&p.close(),f&&v?.isConnected&&v.focus({preventScroll:true});}},[g,d,f]),jsxRuntime.jsx("dialog",{ref:g,role:t,"aria-modal":"true","aria-label":r,className:`docx-dialog${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:p=>{p.preventDefault(),m.current();},onMouseDown:p=>p.stopPropagation(),onClick:p=>{if(c&&p.target===p.currentTarget){let v=p.currentTarget.getBoundingClientRect();(p.clientX<v.left||p.clientX>v.right||p.clientY<v.top||p.clientY>v.bottom)&&m.current();}p.stopPropagation();},onKeyDown:p=>{p.key==="Escape"&&!p.nativeEvent.isComposing?(p.preventDefault(),m.current()):editor.trapTabWithin(p.currentTarget,p.nativeEvent)?p.preventDefault():!p.nativeEvent.isComposing&&!p.defaultPrevented&&a?.(p),p.stopPropagation();},children:l})}function Ai(e,t){let o=H(),n=Cc(),r=Et.useRef(null);return Et.useEffect(()=>{if(!e){r.current=null;return}o?.surface&&(r.current===null?r.current=o.mountGeneration:r.current!==o.mountGeneration&&t());},[e,o,n,t]),()=>!!o?.surface&&r.current===o.mountGeneration}function Cc(){let e=H(),t=Et.useCallback(o=>{if(!e)return ()=>{};let n=true,r=$r(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return Et.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Em(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=s=>{for(let l of [...s])l();};return {getShift:()=>e,setShift(s){let l=Math.max(0,Math.round(s));l!==e&&(e=l,a(n));},subscribeShift(s){return n.add(s),()=>n.delete(s)},getReservation:()=>t,setReservation(s){let l=Math.max(0,Math.round(s));l!==t&&(t=l,a(r));},subscribeReservation(s){return r.add(s),()=>r.delete(s)},getViewport:()=>o,setViewport(s){s!==o&&(o=s,a(i));},subscribeViewport(s){return i.add(s),()=>i.delete(s)}}}var Pc=Et.createContext(null);function rn(){return Et.useContext(Pc)}var wm=()=>0,Sc=()=>()=>{};function an(){let e=rn(),t=Et.useCallback(n=>e?e.subscribeShift(n):Sc(),[e]),o=Et.useCallback(()=>e?e.getShift():0,[e]);return Et.useSyncExternalStore(t,o,wm)}function Mm(){let e=rn(),t=Et.useCallback(n=>e?e.subscribeReservation(n):Sc(),[e]),o=Et.useCallback(()=>e?e.getReservation():0,[e]);return Et.useSyncExternalStore(t,o,wm)}function Ye(){let e=rn(),t=Et.useCallback(r=>e?e.subscribeViewport(r):Sc(),[e]),o=Et.useCallback(()=>e?e.getViewport():null,[e]),n=Et.useCallback(()=>null,[]);return Et.useSyncExternalStore(t,o,n)}function go(e,t,o){let n=Ye(),r=Et.useRef({close:o,viewport:n});r.current={close:o,viewport:n},Et.useEffect(()=>{let i=e.current;if(!(!t||!i))return kx(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function kx(e,t,o){let n=s=>{if(s.defaultPrevented||s.altKey||s.ctrlKey||s.metaKey)return;let l=s.target;if(l.matches('input[role="combobox"]')||l.matches("input, textarea, select")&&s.key!=="ArrowDown"&&s.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let f=d.indexOf(l),u;if(s.key==="Home")u=0;else if(s.key==="End")u=d.length-1;else if(s.key==="ArrowDown")u=(f+1)%d.length;else if(s.key==="ArrowUp")u=f<0?d.length-1:(f-1+d.length)%d.length;else return;s.preventDefault(),s.stopPropagation(),d[u]?.focus();},r=s=>{s.relatedTarget instanceof Node&&!e.contains(s.relatedTarget)&&t();},i=editor.listenForPopupEscape({popup:e,contains:s=>e.contains(s),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:s=>s.target instanceof Element&&e.contains(s.target)&&s.target.matches('input[role="combobox"]'),close:s=>{s&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=editor.listenForPopupFocusLeave({popup:e,contains:s=>e.contains(s),close:t});return e.addEventListener("keydown",n),e.addEventListener("focusout",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("focusout",r),i(),a();}}function Hx(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Ec(e){return typeof e=="string"}function se(e){let t=H(),{t:o}=N(),n=Ec(e)?e:editor.editorCommandKey(e),r=Et.useRef(e);r.current=e;let i=Et.useCallback(l=>{let c=r.current;if(Ec(c)){let f=editor.toolbarCommandState(t,c);return {active:f.active,enabled:f.enabled,disabledReason:i18n.localizeDisabledReason(f.disabledReason,o),value:f.value??null}}if(!t)return {active:false,enabled:false,disabledReason:null,value:null};let d=t.can(c);return {active:t.isActive(c),enabled:d.ok,disabledReason:d.ok?null:i18n.localizeDisabledReason(d.reason??null,o),value:null}},[t,n,o]),a=B(i,Hx),s=Et.useCallback(l=>{let c=editor.commandExecOptions(l),d=r.current;return Ec(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Et.useMemo(()=>({execute:s,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[s,a])}var ln=Et.createContext({t:void 0,onSave:void 0});function Ox(){return Et.useContext(ln)}function Oi(e){let{t}=N();return o=>e?.(o)??t(o)}function Q(){let{t:e}=Et.useContext(ln);return Oi(e)}var Kx=()=>()=>{},Wx=()=>true,zx=()=>false;function Do(){let e=Et.useSyncExternalStore(Kx,Wx,zx);return Et.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function $x(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function Ux(){try{return undefined}catch{return}}function mt(){let e=typeof process<"u";return $x({viteEnv:Ux(),nodeEnv:e?"production":void 0,hasProcess:e})}var Im=new Set;function Io(e){!mt()||Im.has(e)||(Im.add(e),console.warn(`[docx-editor] ${e}`));}function _m(e){Io(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Nm(e){Io(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Lm(){Io("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function Fm(){Io("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function Hm(e){Io(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Am(){Io("A Toolbar.Button has no slotId, so it renders nothing.");}function ee(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function ae(e){return e?jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsxRuntime.jsx("path",{d:t,fill:"currentColor"},t))}):null}function Z(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Yx(e){if(e.slotId)return e.slotId;if(e.slot)return Hm(e.slot),e.slot;Am();}function sn(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=Yx(e)??"",{execute:s,isActive:l,isEnabled:c,disabledReason:d,value:f}=se(a),u=Q(),g=Do();if(i||!a)return null;let m=ee(a),p=g(u(m?.labelKey??a)),v=editor.chromeSlotIsToggle(a),y={onClick:()=>s(),onMouseDown:Z,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...l?{"data-active":""}:{},...c?{}:{"data-disabled":""},...v?{"aria-pressed":l}:{},...f!==null?{"data-value":f}:{},"aria-label":p,title:d??p};return o?jsxRuntime.jsx(G,{...y,children:r}):jsxRuntime.jsx("button",{type:"button",...y,children:t??r??ae(m?.paths)})}sn.docxToolbarPart=true;var oC=[{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"}],Om=[{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"}],Bm=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Zi=["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"],_o=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Mt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function nC(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[Mt(5),Mt(15),Mt(25),Mt(35),Mt(50)]:o===0?[_o(50),_o(35),_o(25),_o(15),_o(5)]:o>=.8?[Mt(10),Mt(25),Mt(50),Mt(75),Mt(90)]:[_o(80),_o(60),_o(40),Mt(25),Mt(50)]}var rC=/^[0-9A-Fa-f]{6}$/;function aC(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function iC(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function Gn({value:e,css:t,title:o,selected:n,apply:r}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||iC(t.replace("#",""))?{"data-light":""}:{},onMouseDown:Z,onClick:()=>r(e)})}function lC({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(nC),i=[0,1,2,3,4];return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[n.map((a,s)=>jsxRuntime.jsx(Gn,{value:a,css:`#${a.toLowerCase()}`,title:t(Zi[s]),selected:o===a,apply:e},`base-${s}`)),i.map(a=>n.map((s,l)=>{let c=r[l][a],d=aC(s,c.apply);return jsxRuntime.jsx(Gn,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Zi[l])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${l}`)}))]})]})}function sC(e){let{apply:t,label:o,current:n}=e,[r,i]=Et.useState(""),a=rC.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lC,{...e}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:oC.map(s=>jsxRuntime.jsx(Gn,{value:s.value,css:s.css,title:o(s.labelKey),selected:n===s.value,apply:t},s.value))})]}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsxRuntime.jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":o("colorPicker.customColor"),onChange:s=>i(s.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:s=>{s.key==="Enter"&&a&&t(r.toUpperCase());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:Z,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Mc({apply:e,current:t}){let o=H(),n=Q(),r=o?.getDocumentThemeColors()??[],i=r.length===Zi.length?r.map(s=>s.hex):Bm,a=t?.toUpperCase()??null;return jsxRuntime.jsx(sC,{apply:e,label:n,current:a,themeHexes:i})}var cC=Om.filter(e=>e.value!=="white");function dC({apply:e,label:t,current:o}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:cC.map(n=>jsxRuntime.jsx(Gn,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Zm(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:l,hidden:c,icon:d})=>{let f=H(),{isEnabled:u,disabledReason:g}=se(t),m=Q(),[p,v]=Et.useState(false),[y,x]=Et.useState(o),b=Et.useRef(null);go(b,p,()=>v(false));let h=B(w=>{if(a){let E=w.formatting?.color;return E&&E.kind==="hex"?E.value.toUpperCase():null}return w.formatting?.highlight??null}),C=f?.getDocumentThemeColors()??[],T=C.length===Zi.length?C.map(w=>w.hex):Bm;Et.useEffect(()=>{if(!p)return;let w=E=>{let D=b.current;D&&E.target instanceof Node&&D.contains(E.target)||v(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[p]);let S=Et.useCallback(w=>{if(v(false),!f)return;f.focus();let E=editor.commandForSlotValue(t,w);E&&f.can(E).ok&&(f.exec(E),w!==r.value&&x(w));},[f]),P=Et.useMemo(()=>ee(t),[]);if(c)return null;let k=m(P?.labelKey??t);return jsxRuntime.jsxs("div",{ref:b,className:`docx-toolbar__colorsplit${l?` ${l}`:""}`,"data-slot":t,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!u,...u?{}:{"data-disabled":""},"aria-label":k,title:g??k,onMouseDown:Z,onClick:()=>S(y),children:[d??ae(P?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(y)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":p,"aria-label":k,title:g??k,onMouseDown:Z,onClick:()=>v(w=>!w),children:"\u25BE"}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":k,onMouseDown:Z,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>S(r.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),m(r.labelKey)]}),i({apply:S,label:m,current:h,themeHexes:T})]}):null]})},{docxSlot:t})}var uC=new Map(Om.map(e=>[e.value,e.css])),Rc=Zm({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Mc,{apply:e.apply,current:e.current})}),kc=Zm({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>uC.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(dC,{...e})});var Ic=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Ki({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=Et.useId(),[s,l]=Et.useState(false),c=Et.useRef(null),d=Et.useRef(null),f=Et.useRef(null);Et.useLayoutEffect(()=>{if(!s||!f.current||!d.current)return;let g=editor.observeContentControlPopup(f.current,d.current);return (f.current.querySelector("[data-selected]")??f.current.querySelector("button"))?.focus(),g},[s]),Et.useEffect(()=>{if(n&&l(false),!s)return;let g=c.current?.ownerDocument,m=p=>{c.current?.contains(p.target)||l(false);};return g?.addEventListener("pointerdown",m),()=>g?.removeEventListener("pointerdown",m)},[s,n]);let u=()=>{l(false),d.current?.focus();};return jsxRuntime.jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(false);},children:[jsxRuntime.jsx("span",{id:`${a}-label`,children:e}),jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-revision-color-trigger",disabled:n,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":s&&!n,"aria-controls":`${a}-options`,onClick:()=>l(!s),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Ic(t)}}),jsxRuntime.jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),jsxRuntime.jsxs("div",{ref:f,id:`${a}-options`,className:"docx-revision-color-options",hidden:!s||n,role:"group","aria-labelledby":`${a}-label`,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),u());let m=Array.from(g.currentTarget.querySelectorAll("button")),p=m.indexOf(g.target),v=g.key==="Home"?0:g.key==="End"?m.length-1:["ArrowRight","ArrowDown"].includes(g.key)?(p+1)%m.length:["ArrowLeft","ArrowUp"].includes(g.key)?(p-1+m.length)%m.length:null;v!==null&&(g.preventDefault(),g.stopPropagation(),m[v]?.focus());},children:[jsxRuntime.jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{r(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Ic(g)}}),i(`values.${g}`)]},g))}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsx(Gn,{value:g,css:Ic(g),title:i(`values.${g}`),selected:t===g,apply:m=>{r(m),u();}},g))})]})]})}var qm=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],vC=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Km(e,t,o){let{values:n}=e,r=a=>{let s=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...qm,"hidden","caret","pound"]:qm,l=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("div",{className:"docx-revision-markup-row",children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsxRuntime.jsx("select",{value:n[a].mark,disabled:l,onChange:c=>e.setValue(a,{...n[a],mark:c.target.value}),children:s.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(Ki,{label:t(`${a}Color`),value:n[a].color,values:vC,disabled:l,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(Ki,{label:t(`${a}Background`),value:n[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:l,t,change:c=>e.setValue(a,{...n[a],background:c})})})]})},i=a=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n[a],"aria-describedby":`${o}-${a}`,onChange:s=>e.setValue(a,s.target.checked)}),t(a)]}),jsxRuntime.jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("markup")}),r("insertions"),r("deletions"),r("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),r("movedFrom"),r("movedTo")]}),jsxRuntime.jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsxRuntime.jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsxRuntime.jsx(Ki,{label:t(`${a}Cells`),value:n.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:s=>e.setValue("cells",{...n.cells,[a]:s})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),r("formatting")]})]})}var Ht=ko();function EC(){return Ht.useState()}function wC({session:e,...t}){return e?jsxRuntime.jsx(MC,{session:e,...t}):null}function MC({session:e,children:t,preset:o,className:n,style:r}){let i=Et.useId(),{t:a}=N(),s=p=>a(`revisionMarkup.${p}`),l=Et.useCallback(p=>e.subscribe(p),[e]),c=Et.useCallback(()=>e.get(),[e]),d=Et.useSyncExternalStore(l,c,c),[f,u]=Et.useState(e.signal.aborted),g=Et.useRef(null);Et.useEffect(()=>{g.current=e;let p=()=>u(true);return u(e.signal.aborted),e.signal.addEventListener("abort",p),()=>{e.signal.removeEventListener("abort",p),g.current=null,queueMicrotask(()=>{g.current!==e&&e.cancel();});}},[e]);let m={values:d,setValue(p,v){e.set({[p]:v});},errors:{},isEnabled:!f&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return f?null:jsxRuntime.jsx(pt,{kind:"revisionMarkup",label:s("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:m.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(Ht.Composition,{state:m,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",children:jsxRuntime.jsx("h2",{"data-docx-part":"title",children:s("title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:Km(m,s,i)}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"reset",type:"button",onClick:m.reset,children:s("reset")}),jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",children:m.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",onClick:m.cancel,children:s("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!m.isEnabled,onClick:m.apply,children:s("ok")})]})]}),children:t})})}var Ur=Object.assign(wC,{Header:Ht.Header,Title:Ht.Title,Body:Ht.Body,Footer:Ht.Footer,Apply:Ht.Apply,Cancel:Ht.Cancel,Error:Ht.Error,Field:Ht.Field,Reset:Ht.Reset});function Nc(e){let t=H(),o=Et.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return Et.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Et.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Vr({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:s}){let{t:l}=N();if(!e)return null;let c=l(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(pt,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:s??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[o&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:n?"alert":"status",children:n||l("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l(n?"common.close":"toolbar.exportContinueEditing")})})]})})}function Gr({open:e,pending:t,error:o,url:n,onClose:r,className:i,style:a,children:s}){let{t:l}=N();if(!e)return null;let c=l(o?"toolbar.printFailed":"toolbar.printPreparing"),d=n.startsWith("blob:")?n:"";return jsxRuntime.jsx(pt,{kind:"print",label:c,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,onKeyDown:f=>{editor.isChromePrintShortcut(f.nativeEvent)&&f.preventDefault();},children:s??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[t&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),o&&jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[o&&d&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:l("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l(o?"common.close":"common.cancel")})]})]})})}var ct={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function jn({text:e,x:t,y:o,className:n}){return jsxRuntime.jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:ct.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function Yn({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:s,deleteEnabled:l,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:f,convertDisabledReason:u,convertAllDisabledReason:g,className:m}){let{t:p}=N();return jsxRuntime.jsxs("div",{role:"menu",className:m,onKeyDown:v=>{v.key==="Escape"&&s();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:ct.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!l,title:f,onClick:n,children:p("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:p(e==="footnote"?"notes.convertToEndnote":"notes.convertToFootnote")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!d,title:g,onClick:i,children:p(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:p("dialogs.footnoteProperties.title")})]})}function FC(e){return t=>Et.createElement(e,t)}var Vm=new WeakMap,HC=0;function ke(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=Vm.get(o);return r===void 0&&Vm.set(o,r=++HC),Et.createElement(Et.Fragment,{key:r},n)}function Xn(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function Yr(e){return e.paragraphId===""}var dn=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),qC=e=>e;function KC(){let e=o=>!!o&&(o.width>0||o.height>0);if(typeof document<"u"){let n=document.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom}}let t=typeof window>"u"?null:window.getSelection();if(t&&t.rangeCount>0){let o=t.getRangeAt(0),n=o.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom};let r=o.startContainer,a=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(a))return {left:a.left,top:a.bottom}}return null}var Xr=Et.createContext(null);function Fc(){let e=Et.useContext(Xr),t=zi(e===null);return e??t}function zi(e=true){let t=H(),[o,n]=Et.useState(dn),r=Et.useRef(null),i=Et.useRef(o);i.current=o;let a=B(qC),s=t?t.can({type:"insertText",text:""}).ok:false,l=Et.useCallback(()=>{let b=r.current;b&&(b.editor.releaseSelection(b.pin),r.current=null);},[]),c=Et.useCallback((b,h)=>{l(),n({mode:b?"reading":"editing",link:b??null,anchor:h??null,text:b?.text??"",url:b?b.kind==="internal"?`#${b.anchor??""}`:b.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,l]),d=Et.useCallback(()=>{l(),n(dn);},[l]);Et.useEffect(()=>l,[l]);let f=Et.useCallback(()=>{let b=KC();l();let h=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(h&&Yr(h)){c(h,b);return}if(h){n({mode:"editing",link:h,anchor:b,text:h.text,url:h.kind==="internal"?`#${h.anchor??""}`:h.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let C=t?.query({type:"selectedText"})??"",T=t?.retainSelection()??null;t&&T&&(r.current={editor:t,pin:T}),n({mode:"editing",link:null,anchor:b,text:C,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c,l]);Et.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:b=>c(b.link,{left:b.rect.left,top:b.rect.bottom}),onRequest:f})},[t,e,c,f]),Et.useEffect(()=>{let b=i.current;if(b.mode!=="reading"||!b.link)return;let h=Yr(b.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;h&&h.id===b.link.id||n(dn);},[a,t]),Et.useEffect(()=>{let b=i.current;if(b.mode!=="editing"||b.link)return;let h=t?.surface;!h||h.retainedSelection()||n(dn);},[a,t]);let u=Et.useCallback(async()=>{let b=i.current.link?.href;if(!b)return false;try{await navigator.clipboard.writeText(b);}catch{return false}return n(h=>({...h,copied:true})),true},[]),g=Et.useCallback(()=>{n(b=>({...b,mode:"editing",copied:false,error:false}));},[]),m=Et.useCallback(b=>{n(h=>({...h,text:b,copied:false,error:false}));},[]),p=Et.useCallback(b=>{n(h=>({...h,url:b,copied:false,error:false}));},[]),v=Et.useCallback(()=>{let b=i.current,h=t?.surface?.hyperlinks;if(!h)return false;let C=b.url.trim();if(C.length===0)return n(P=>({...P,error:true})),false;let T=C.startsWith("#");return h.applyHyperlink({...T?{anchor:C.slice(1)}:{url:C},...b.text.trim().length>0?{text:b.text}:{}})?(d(),true):(n(P=>({...P,error:true})),false)},[t,d]),y=Et.useCallback(()=>{let b=t?.surface?.hyperlinks,h=i.current.link;if(!b)return false;let C=b.removeHyperlink(h?.id);return C&&d(),C},[t,d]),x=Et.useCallback(()=>{let b=t?.surface?.navigation,h=i.current.link;if(!b||!h)return false;if(h.kind==="internal"){let T=h.anchor?b.goToBookmark(h.anchor):false;return T&&n(dn),T}let C=b.openExternal(h.href);return C&&n(dn),C},[t]);return Et.useMemo(()=>({state:o.mode==="closed"?dn:{...o,canEdit:s},open:c,openAtCaret:f,close:d,copy:u,beginEdit:g,setText:m,setUrl:p,commitEdit:v,unlink:y,openTarget:x}),[o,s,c,f,d,u,g,m,p,v,y,x])}function pn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var $i=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),jC="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",YC="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",XC="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",JC="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 QC({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Qt(),a=Et.useRef(null),{state:s,close:l}=i;Et.useEffect(()=>{if(s.mode==="closed")return;let p=y=>{y.key==="Escape"&&(y.preventDefault(),l());},v=y=>{let x=a.current;x&&y.target instanceof Node&&x.contains(y.target)||l();};return document.addEventListener("keydown",p),document.addEventListener("mousedown",v,true),()=>{document.removeEventListener("keydown",p),document.removeEventListener("mousedown",v,true);}},[s.mode,l]);let[c,d]=Et.useState(null);Et.useLayoutEffect(()=>{let p=s.anchor,v=a.current;if(!p||!v){d(null);return}let y=v.offsetParent;if(!y){d(null);return}let{left:x,top:b}=Xn(y,p.left,p.top),h=Math.max(0,y.scrollWidth-v.offsetWidth);d({left:Math.max(0,Math.min(x,h)),top:b});},[s.anchor]);let{t:f}=N(),u=s.mode==="editing"?f(s.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):f("hyperlinkPopup.editLink"),g=r?jsxRuntime.jsx(eT,{children:n}):n;if(o)return s.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let m={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":s.mode,role:"dialog","aria-modal":false,onMouseDown:pn,style:c??void 0,"aria-label":u};return s.mode==="closed"?null:t?jsxRuntime.jsx(G,{...m,children:n}):jsxRuntime.jsx("div",{...m,children:g})}function eT({children:e}){let{state:t}=Qt(),o=Et.useMemo(()=>tT(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Fields",jsxRuntime.jsx(qc,{})),n("Error",jsxRuntime.jsx(Wc,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(Kc,{})),n("Cancel",jsxRuntime.jsx(zc,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&Yr(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(Ac,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(Oc,{})),r?n("Edit",jsxRuntime.jsx(Bc,{})):null,r?n("Unlink",jsxRuntime.jsx(Zc,{})):null]}),o.__extra]})}function tT(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===Et.Fragment){n(r.props.children);return}let i=r.type.docxHyperLinkPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Qt(){return Et.useContext(Xr)??oT}var oT={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 Ac({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=Qt(),{t:a}=N();if(o||!r.link)return null;let s=!r.link.href,l=r.link.kind==="internal",c=l?`#${r.link.anchor??""}`:r.link.authored,d=a(s?"hyperlinkPopup.inertTarget":l?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),f={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...s?{"data-inert":""}:{},title:d,onMouseDown:pn,...s?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(G,{...f,className:e,children:n}):s?jsxRuntime.jsxs("span",{...f,children:[n??c,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxRuntime.jsxs("button",{...f,children:[n??c,$i(JC)]})}Ac.docxHyperLinkPart="Url";function Oc({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=Qt(),{t:s}=N();if(o||!i.link?.href)return null;let l=i.copied?s("editor.linkCopied"):s("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":l,title:l,onMouseDown:pn,onClick:()=>{a();}};return t?jsxRuntime.jsx(G,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??$i(jC)})}Oc.docxHyperLinkPart="Copy";function Bc({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=Qt(),{t:a}=N();if(o)return null;let s=a("hyperlinkPopup.editLink"),l={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":s,title:s,onMouseDown:pn,onClick:()=>i()};return t?jsxRuntime.jsx(G,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:r??n??$i(YC)})}Bc.docxHyperLinkPart="Edit";function Zc({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=Qt(),{t:a}=N();if(o)return null;let s=a("hyperlinkPopup.removeLink"),l={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":s,title:s,onMouseDown:pn,onClick:()=>i()};return t?jsxRuntime.jsx(G,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:r??n??$i(XC)})}Zc.docxHyperLinkPart="Unlink";function qc({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=Qt(),{t:s}=N(),l=Et.useRef(null),c=Et.useId(),d=Et.useId();Et.useEffect(()=>{o.mode==="editing"&&(l.current?.focus({preventScroll:true}),l.current?.select());},[o.mode]);let f=Et.useCallback(u=>{if(u.key==="Enter"){u.preventDefault(),i();return}u.key==="Escape"&&(u.preventDefault(),a());},[i,a]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:s("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:c,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,placeholder:s("hyperlinkPopup.displayTextPlaceholder"),onChange:u=>n(u.target.value),onKeyDown:f}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:s("hyperlinkPopup.urlPlaceholder")}),jsxRuntime.jsx("input",{id:d,ref:l,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,placeholder:s("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:f})]})}qc.docxHyperLinkPart="Fields";function Kc({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=Qt(),{t:a}=N();if(o)return null;let s=a("hyperlinkPopup.apply"),l={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:pn,onClick:()=>i()};return t?jsxRuntime.jsx(G,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:n??s})}function Wc({className:e,hidden:t}){let{state:o}=Qt(),{t:n}=N();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:n("hyperlinkPopup.refused")})}Wc.docxHyperLinkPart="Error";Kc.docxHyperLinkPart="Apply";function zc({className:e,asChild:t,hidden:o,children:n}){let{close:r}=Qt(),{t:i}=N();if(o)return null;let a=i("hyperlinkPopup.cancel"),s={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:pn,onClick:()=>r()};return t?jsxRuntime.jsx(G,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??a})}zc.docxHyperLinkPart="Cancel";var Jr=Object.assign(QC,{Url:Ac,Copy:Oc,Edit:Bc,Unlink:Zc,Fields:qc,Error:Wc,Apply:Kc,Cancel:zc});var gt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function iT(e){return e==="sdtLocked"||e==="sdtContentLocked"}function lT(e){return e==="contentLocked"||e==="sdtContentLocked"}function Uc(e,t){return !e.ok&&e.code===t}function eo(){let e=Et.useContext(Vc),t=Ui();return e??t}function Ui(){let e=H(),[t,o]=Et.useState(false),[n,r]=Et.useState(false),[i,a]=Et.useState(false),s=B(S=>S),l=e?.surface??null,c=l?.contentControls;Et.useEffect(()=>{r(c?.showAll()??l?.state().contentControls.showAll??false),a(c?.formFill()??l?.state().contentControls.formFill??false);},[s,c,l]);let d=Et.useMemo(()=>{if(!e)return null;let S=c?.atCaret()??null;if(S){let M=c?.disabledReason(S.id,"edit")??null,I=c?.disabledReason(S.id,"remove")??null;return {id:S.id,tag:S.tag??null,alias:S.alias??null,controlType:S.controlType,locked:lT(S.effectiveLock)||M==="locked",removalLocked:iT(S.effectiveLock)||I==="locked",placeholder:S.placeholder,bound:S.bound||M==="bound",effectiveLock:S.effectiveLock}}let P=e.query({type:"contentControlAt"});if(!P)return null;let k=c?.disabledReason(P.id,"edit")??null,w=c?.disabledReason(P.id,"remove")??null,E=e.can({type:"setContentControlValue",value:""}),D=e.can({type:"removeContentControl"}),A=P.locked===true||k==="locked"||Uc(E,"locked"),_=k==="bound"||Uc(E,"bound"),F=w==="locked"||Uc(D,"locked");return {id:P.id,tag:P.tag??null,alias:P.alias??null,controlType:P.controlType,locked:A,removalLocked:F,placeholder:false,bound:_,effectiveLock:null}},[e,s,c]),f=Et.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,s]),u=Et.useCallback(S=>{c?.setShowAll(S),r(S);},[c]),g=Et.useCallback(S=>{c?.setFormFill(S),a(S);},[c]),m=Et.useCallback(()=>u(!n),[u,n]),p=Et.useCallback(()=>g(!i),[g,i]),v=Et.useCallback(()=>o(true),[]),y=Et.useCallback(()=>o(false),[]),x=Et.useCallback(()=>o(S=>!S),[]),b=Et.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let P=c.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 S=e.can({type:"setContentControlValue",value:""});return S.ok?null:S.reason},[d,c,e]),h=Et.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let P=c.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 S=e.can({type:"removeContentControl"});return S.ok?null:S.reason},[d,c,e]),C=Et.useCallback(S=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let P=c.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:S})},[e,c,d]),T=Et.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let S=d?.id;if(!S)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let P=c.disabledReason(S,"remove");return P?{ok:false,code:P==="locked"?"locked":"notFound",reason:P==="locked"?"the content control is locked":"the content control was not found"}:c.remove(S)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return Et.useMemo(()=>({control:d,controls:f,showAll:n,formFill:i,inspectorOpen:t,canSetValue:b===null&&d!==null,canRemove:h===null&&d!==null,setValueDisabledReason:b,removeDisabledReason:h,setShowAll:u,toggleShowAll:m,setFormFill:g,toggleFormFill:p,openInspector:v,closeInspector:y,toggleInspector:x,remove:T,setValue:C}),[d,f,n,i,t,b,h,u,m,g,p,v,y,x,T,C])}var Vc=Et.createContext(null);function Gc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ef=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),dT="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",uT="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",pT={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},mT={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},fT={color:"var(--doc-text-muted)",flexShrink:0},gT={textAlign:"right",wordBreak:"break-word"},hT={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},bT={display:"flex",gap:8,marginTop:4},tf={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 vT(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 "buildingBlockGallery":return "contentControl.types.buildingBlockGallery";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function yT(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 Jn({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:mT,"data-testid":o,children:[jsxRuntime.jsx("span",{style:fT,children:e}),jsxRuntime.jsx("span",{style:gT,children:t})]})}function xT({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=eo(),a=Et.useRef(null),s=Et.useId(),{t:l}=N(),{control:c,inspectorOpen:d,closeInspector:f}=i;if(Et.useEffect(()=>{if(!d)return;let p=y=>{y.key==="Escape"&&(y.preventDefault(),f());},v=y=>{let x=a.current;x&&y.target instanceof Node&&x.contains(y.target)||f();};return document.addEventListener("keydown",p),document.addEventListener("mousedown",v,true),()=>{document.removeEventListener("keydown",p),document.removeEventListener("mousedown",v,true);}},[d,f]),Et.useEffect(()=>{d&&!c&&f();},[d,c,f]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(of,{}),jsxRuntime.jsx(nf,{}),jsxRuntime.jsx("div",{style:bT,children:jsxRuntime.jsx(rf,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":s,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:pT,onMouseDown:p=>{Gc(p),p.stopPropagation();}},m=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{id:s,className:"docx-editor-sr-only",children:l("contentControl.inspectorPanel.title")}),u]});return t?jsxRuntime.jsx(G,{...g,children:m}):jsxRuntime.jsx("div",{...g,children:m})}function of({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=eo(),{t:i}=N();if(o)return null;let a={style:hT,className:e??void 0,"data-testid":"content-control-inspector-header"},s=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:n??i("contentControl.inspectorPanel.title")}),jsxRuntime.jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...tf,padding:4,border:"none",background:"transparent"},onMouseDown:Gc,onClick:()=>r(),children:ef(dT)})]});return t?jsxRuntime.jsx(G,{...a,children:s}):jsxRuntime.jsx("div",{...a,children:s})}function nf({className:e,asChild:t,hidden:o,children:n}){let{control:r}=eo(),{t:i}=N();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),s=i("contentControl.inspectorPanel.yes"),l=i("contentControl.inspectorPanel.no"),c=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.type"),value:i(vT(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.lock"),value:i(yT(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?s:l,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Jn,{label:i("contentControl.inspectorPanel.bound"),value:r.bound?s:l,testId:"content-control-inspector-bound"}),r.bound?jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsx(G,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function rf({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:s,closeInspector:l}=eo(),{t:c}=N();if(o)return null;let d=c("contentControl.remove"),f={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:tf,onMouseDown:Gc,onClick:()=>{s().ok&&l();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??ef(uT),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(G,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}var ta=Object.assign(xT,{Header:of,Fields:nf,Remove:rf});var ST=e=>e;function Qc(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function oa(){let e=H(),{t}=N(),[o,n]=Et.useState(null),[r,i]=Et.useState(null),a=Et.useRef(null),s=Et.useRef(null),l=Et.useRef(null),c=Et.useId(),d=Et.useId(),f=Et.useId(),u=o?.activation??null,g=B(ST),m=Et.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let b=e.surface.equations.can(u.equation.id,"replace"),h=e.surface.equations.can(u.equation.id,"remove"),C=b.ok?h.ok?null:h.reason:b.reason;return {replaceEnabled:b.ok,removeEnabled:h.ok,reason:C?i18n.localizeDisabledReason(C,t):null}},[u,e,g,t]),p=Et.useCallback((b=false)=>{l.current?.(),l.current=null,n(null),b&&e&&queueMicrotask(()=>e.focus());},[e]);Et.useEffect(()=>{if(!e)return;let b=e.setEquationChrome({onPopover:h=>{l.current?.();let C=e.surface;if(C&&typeof C.retainSelection=="function"){let T=C.retainSelection();l.current=()=>C.releaseSelection(T);}else l.current=null;n({activation:h,mountGeneration:e.mountGeneration,draft:h.equation.linear,error:false});}});return ()=>{b(),l.current?.(),l.current=null,n(null);}},[e,p]),Et.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&p();},[e,g,o,p]),Et.useEffect(()=>{if(!o)return;let b=a.current,h=b?.ownerDocument,C=h?.defaultView;if(!b||!h||!C)return;let T=P=>{P.key==="Escape"&&(P.preventDefault(),p(true));},S=P=>{P.target instanceof C.Node&&b.contains(P.target)||p();};return h.addEventListener("keydown",T),h.addEventListener("pointerdown",S,true),()=>{h.removeEventListener("keydown",T),h.removeEventListener("pointerdown",S,true);}},[o,p]),Et.useLayoutEffect(()=>{if(!u){i(null);return}let b=a.current;if(!b)return;let h=b.offsetParent;if(!h){i(null);return}let C=u.rect,T=Xn(h,C.left,C.bottom),S=Math.max(0,h.scrollWidth-b.offsetWidth);i({left:Math.max(0,Math.min(T.left,S)),top:T.top}),s.current?.focus({preventScroll:true}),s.current?.select();},[u]);let v=Et.useCallback(()=>{if(!o||!e?.surface||!m.replaceEnabled)return false;let b=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return b?p(true):n(h=>h&&{...h,error:true}),b},[e,o,p,m.replaceEnabled]),y=Et.useCallback(()=>{if(!o||!e?.surface||!m.removeEnabled)return false;let b=e.surface.equations.removeEquation(o.activation.equation.id);return b?p(true):n(h=>h&&{...h,error:true}),b},[e,o,p,m.removeEnabled]);if(!o)return null;let x=[o.error?d:null,m.reason?f:null].filter(Boolean).join(" ");return jsxRuntime.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:Qc,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:s,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":x||void 0,onChange:b=>n(h=>h&&{...h,draft:b.target.value,error:false}),onKeyDown:b=>{b.key!=="Enter"||b.nativeEvent.isComposing||(b.preventDefault(),v());}}),o.error?jsxRuntime.jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,m.reason?jsxRuntime.jsx("div",{id:f,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:m.reason}):null,jsxRuntime.jsxs("div",{className:"docx-equation-popup__actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!m.replaceEnabled,title:m.reason??void 0,onMouseDown:Qc,onClick:v,children:t("equationPopup.apply")}),jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!m.removeEnabled,title:m.reason??void 0,onMouseDown:Qc,onClick:y,children:t("equationPopup.delete")})]})]})}var sf="review.comments",ed="review.addComment";function cf(e){return e!==sf?e:(Io(`The context-menu row "${sf}" is now "${ed}". The old id still works in this release; write "${ed}".`),ed)}function tr(e,t){if(!Et.isValidElement(e)||e.type!==Et.Fragment)return null;let n=Et.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function Vi({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:s}){if(!o)return t;let l=new Map,c=[];for(let m of Et.Children.toArray(t)){let p=r(m);p?l.set(p,m):c.push(m);}let d=new Set,f=m=>m.map((p,v)=>{let y=n(p,v);d.add(y);let x=a?.(p),b=x?f(x):void 0,h=l.get(y);return jsxRuntime.jsx(Et.Fragment,{children:h??i(p,v,b)},y)}),u=f(e),g=[...l.entries()].filter(([m])=>!d.has(m)).map(([m,p])=>(s?.(m,p),jsxRuntime.jsx(Et.Fragment,{children:p},m)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var RT="review.addComment",kT=e=>e.editingMode==="viewing";function Gi(e){let{isEnabled:t,disabledReason:o}=se(RT),n=B(kT);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var na=Et.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}),or="docx-menubar-more",ji=Et.createContext({measuring:false,overflow:new Set,inMore:false});function mf(){return Et.useContext(ji)}function at(){return Et.useContext(na)}function De(){let{t:e}=at(),{t}=N();return o=>e?.(o)??t(o)}var nr=Et.createContext(-1);var DT='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function mn(e){return [...e.querySelectorAll(DT)].filter(t=>t.closest('[role="menu"]')===e)}function nd(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function Ot(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function Bt(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function rd(e){let t=e?.ownerDocument.activeElement;((t&&e?.contains(t)?t.closest("[data-menu]"):null)?.querySelector(':scope > [role="menuitem"]')??e?.querySelector('.docx-menubar__trigger[aria-expanded="true"]'))?.focus({preventScroll:true});}var Fo="data-toolbar-group",fn="data-toolbar-fixed",aa="data-toolbar-more",WT=34,Yi=new Set;function Xi(e,t,o){let n=Et.useRef(null),r=Et.useRef(new Map),i=Et.useRef(WT),[a,s]=Et.useState(Yi),l=Et.useRef(a);l.current=a;let c=Et.useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),f=o.join("\0"),u=Et.useCallback(()=>{let m=n.current;if(!m||!e)return;let p=getComputedStyle(m),v=editor.readColumnGap(p),y=editor.readAvailableWidth(m,p),x=m.querySelector(".docx-toolbar__separator"),b=v*2;if(x){let k=getComputedStyle(x),w=editor.readInlineMargins(k);b=editor.separatorLeadingCost(x.offsetWidth,w.start,w.end,v);}for(let k of m.querySelectorAll(`[${Fo}]`)){let w=k.getAttribute(Fo);w&&k.offsetWidth>0&&r.current.set(w,editor.collapsibleGroupCost(k.offsetWidth,b));}let h=0;for(let k of m.querySelectorAll(`[${fn}]`))k.offsetWidth>0&&(h+=editor.trailingGapCost(k.offsetWidth,v));let C=m.querySelector(`[${aa}]`);C&&C.offsetWidth>0&&(i.current=editor.trailingGapCost(C.offsetWidth,v));let T={available:y,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:h,more:i.current,previous:l.current,hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS},P=l.current.size===0&&editor.controlsOverflow(m,p)===false?Yi:editor.toolbarOverflowGroups(T);editor.sameOverflow(P,l.current)||(l.current=P,s(P));},[e]),g=Et.useCallback(m=>{n.current=m;},[]);return Et.useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=Yi,s(Yi));return}u();},[e,d,u,f]),Et.useEffect(()=>{let m=n.current;if(!e||!m||typeof ResizeObserver>"u")return;let p=0,v=new ResizeObserver(()=>{p===0&&(p=requestAnimationFrame(()=>{p=0,u();}));});v.observe(m),m.parentElement&&v.observe(m.parentElement);for(let y of m.querySelectorAll(`[${Fo}], [${fn}]`))v.observe(y);return ()=>{p!==0&&cancelAnimationFrame(p),v.disconnect();}},[e,d,u,f,a]),{attach:g,overflow:a}}function hf(e,t,o){let n=e.overflow.has(t),r=t===or;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[Fo]:t}:{},...r?{[aa]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function bf(e,t,o){let[n,r]=Et.useState(void 0);return Et.useLayoutEffect(()=>{if(!e){r(void 0);return}let i=()=>{let s=t.current,l=o.current,c=s?.parentElement,d=s?.ownerDocument.defaultView;if(!s||!l||!c||!d)return;let f=s.getBoundingClientRect(),u=editor.toolbarPanelPlacement({triggerLeft:f.left,triggerRight:f.right,panelWidth:l.offsetWidth,viewportWidth:d.innerWidth});r({left:u.left-c.getBoundingClientRect().left,right:"auto",maxInlineSize:u.maxWidth});};i();let a=t.current?.ownerDocument.defaultView;return a?.addEventListener("resize",i),()=>a?.removeEventListener("resize",i)},[e,o,t]),n}var yf=12700,vf=96;function YT(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function XT(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Ji(e){let t=editor.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 o=editor.sniffImageMime(e);if(!YT(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let n=editor.validateRasterHeader(e,o);if(!n)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(n.pixelWidth*n.pixelHeight>t.maxPixels||n.pixelWidth>t.maxDimension||n.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=XT(n.pixelWidth,n.pixelHeight,n.dpiX??vf,n.dpiY??vf);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function Ho(e){return Math.round(e/yf*100)/100}function ia(e){return Math.round(e*yf)}var oP="image/png,image/jpeg,image/gif",id=Et.createContext(null);function Pf(){let e=Et.useContext(id);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function la(){return Et.useContext(id)}function Qi({children:e}){let t=H(),{t:o}=N(),n=Et.useRef(null),r=Et.useRef(false),i=Et.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),a=B(i,(p,v)=>p.enabled===v.enabled&&p.disabledReason===v.disabledReason),s=a.enabled,l=i18n.localizeDisabledReason(a.disabledReason,o),c=Et.useCallback(async p=>{if(!t||r.current)return;let v=Ji(p);if(!v.ok){window.alert(o(v.reasonKey));return}let y={type:"insertImage",data:v.bytes,mime:v.mime,widthPoints:v.widthPoints,heightPoints:v.heightPoints};r.current=true;try{let x=await editor.executeImageCommand(t,y);x.ok?t.focus():window.alert(i18n.localizeDisabledReason(nP(x.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),d=Et.useCallback(async p=>{let v=p?.[0];if(!v)return;let y=await v.arrayBuffer();await c(new Uint8Array(y));},[c]),f=Et.useCallback(async p=>{if(!p)return;let v=[...p.files].find(y=>y.type.startsWith("image/"));if(v){await d([v]);return}for(let y of p.items){if(y.kind!=="file"||!y.type.startsWith("image/"))continue;let x=y.getAsFile();if(!x)continue;let b=await x.arrayBuffer();await c(new Uint8Array(b));return}},[c,d]),u=Et.useCallback(()=>{s&&n.current?.click();},[s]),g=Et.useCallback(async p=>{let v=p.currentTarget;await d(v.files),v.value="";},[d]),m=Et.useMemo(()=>({openFilePicker:u,insertFromFileList:d,insertFromDataTransfer:f,isEnabled:s,disabledReason:l,inputRef:n,onInputChange:g}),[u,d,f,s,l,g]);return jsxRuntime.jsxs(id.Provider,{value:m,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:oP,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:p=>p.stopPropagation()}),e]})}function el({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Pf(),s=Q();if(t)return null;let l=ee("image.insert"),c=s(l?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:Z,onClick:r};return o?jsxRuntime.jsx(G,{...d,children:n}):jsxRuntime.jsx("button",{...d,children:n??ae(l?.paths)})}el.docxSlot="image.insert";var sa=Object.assign(el,{docxSlot:"image.insert"});function nP(e){return e&&/\s/.test(e)?e:void 0}var ld=6,wf=6;function ol({slot:e,label:t,onInserted:o,className:n}){let r=H(),{isEnabled:i}=se(e),[a,s]=Et.useState(null),[l,c]=Et.useState({rows:1,cols:1}),d=Et.useRef(null),f=Et.useCallback((m,p)=>{if(!r||!i)return;let v={type:"insertTable",rows:m,cols:p};r.can(v).ok&&(r.exec(v),o(),r.focus());},[r,i,o]),u=Et.useCallback(m=>{c(p=>{let v={rows:Math.min(wf,Math.max(1,p.rows+(m.rows??0))),cols:Math.min(ld,Math.max(1,m.toCol??p.cols+(m.cols??0)))};return s(v),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${v.rows}x${v.cols}"]`)?.focus()),v});},[]),g=[];for(let m=1;m<=wf;m+=1){let p=[];for(let v=1;v<=ld;v+=1){let y=!!a&&m<=a.rows&&v<=a.cols;p.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${m}x${v}`,className:"docx-menubar__grid-cell",tabIndex:l.rows===m&&l.cols===v?0:-1,...y?{"data-filled":""}:{},"aria-label":`${v} \xD7 ${m}`,onMouseDown:Z,onMouseEnter:()=>s({rows:m,cols:v}),onFocus:()=>s({rows:m,cols:v}),onClick:()=>f(m,v)},v));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:p},m));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":t,className:`docx-menubar__grid${n?` ${n}`:""}`,onMouseLeave:()=>s(null),onKeyDown:m=>{if(m.key==="ArrowRight")u({cols:1});else if(m.key==="ArrowLeft")u({cols:-1});else if(m.key==="ArrowDown")u({rows:1});else if(m.key==="ArrowUp")u({rows:-1});else if(m.key==="Home")u({toCol:1});else if(m.key==="End")u({toCol:ld});else return;m.preventDefault(),m.stopPropagation();},children:[jsxRuntime.jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsxRuntime.jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function ar({slot:e="table.insert",className:t}){let{setOpenMenu:o}=at(),n=De(),r=Et.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(ol,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function _e(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:s,onSelect:l,className:c,children:d}=e,f=e["data-value"],u=Do(),g=Et.useId(),m=Et.useContext(nr),p=n&&r?g:void 0;return jsxRuntime.jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${c?` ${c}`:""}`,tabIndex:m,...s?{"data-slot":s}:{},...f!==void 0?{"data-value":f}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...p?{"aria-describedby":p}:{},...r?{title:r}:{},onMouseDown:Z,onClick:n?void 0:l,children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsxRuntime.jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,p?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function da({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=De();if(n)return null;let a=e??(t===void 0?void 0:i(t));return jsxRuntime.jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?jsxRuntime.jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function nl(e){if(e.slotId)return e.slotId;if(e.slot)return _m(e.slot),e.slot;Lm();}function bo(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=nl(e)??"",{execute:a,isActive:s,isEnabled:l,disabledReason:c,value:d}=se(i),{setOpenMenu:f}=at(),u=De();if(r||!i)return null;let g=ee(i),m=u(t??g?.labelKey??i),p=editor.chromeSlotIsToggle(i),v=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(_e,{slot:i,icon:ae(g?.paths),...o?{shortcut:u(o)}:{},disabled:!l,...c?{title:c}:{},...p?{active:s}:{},...v?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),f(null);},...n?{className:n}:{},children:m})}bo.docxMenuRow=true;function ua(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:s})=>{let l=at(),c=De(),d=n(l),f=o&&r(l)?o:void 0;if(s)return null;let u=ee(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(_e,{slot:e,icon:ae(u?.paths),...f?{shortcut:c(f)}:{},disabled:!d,onSelect:()=>{d?.(),l.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var cd=ua("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),dd=ua("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),ud=ua("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),pd=ua("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),md=ua("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function gP({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(editor.chromeProbeForSlot("file.pageSetup")),r=at(),i=De();if(t)return null;let a=ee("file.pageSetup"),s=i(a?.labelKey??"file.pageSetup"),l=o&&!!r.onPageSetup;return jsxRuntime.jsx(_e,{slot:"file.pageSetup",icon:ae(a?.paths),disabled:!l,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:s})}function hP({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(editor.chromeProbeForSlot("paragraph.dialog")),r=at(),i=De();if(t)return null;let a=ee("paragraph.dialog"),s=i(a?.labelKey??"lineSpacing.options"),l=o&&!!r.onParagraphDialog;return jsxRuntime.jsx(_e,{slot:"paragraph.dialog",icon:ae(a?.paths),disabled:!l,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:s})}var bP=Object.assign(hP,{docxSlot:"paragraph.dialog"}),fd=Object.assign(gP,{docxSlot:"file.pageSetup"});function vP({className:e,hidden:t}){let o=la(),n=at(),r=De();if(t)return null;let i=ee("image.insert"),a=r(i?.labelKey??"toolbar.image"),s=o?.isEnabled??false,l=o?.disabledReason??null;return jsxRuntime.jsx(_e,{slot:"image.insert",icon:ae(i?.paths),disabled:!s,...l?{title:l}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var gd=Object.assign(vP,{docxSlot:"image.insert"}),ca=8;function Zt({labelKey:e,label:t,paths:o,className:n,children:r}){let i=De(),[a,s]=Et.useState(false),l=Et.useRef(null),c=Et.useRef(null),d=Et.useId();t===void 0&&e===void 0&&Fm();let f=t??i(e??""),[u,g]=Et.useState(null);return Et.useLayoutEffect(()=>{if(!a){g(null);return}let m=l.current,p=c.current,v=m?.ownerDocument.defaultView;if(!m||!p||!v)return;let y=m.getBoundingClientRect(),x=p.offsetWidth,b=p.offsetHeight,h=y.right+x>v.innerWidth-ca;g({left:h?Math.max(ca,y.left-x):Math.min(y.right,v.innerWidth-x-ca),top:Math.max(ca,Math.min(y.top-4,v.innerHeight-b-ca))});},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),onKeyDown:m=>{m.key==="ArrowRight"&&document.activeElement===l.current?(m.preventDefault(),s(true),queueMicrotask(()=>{c.current&&Bt(mn(c.current),"first");})):(m.key==="ArrowLeft"||m.key==="Escape")&&a&&(m.preventDefault(),m.stopPropagation(),s(false),l.current?.focus());},onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||s(false);},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:Z,onFocus:()=>s(true),onClick:()=>s(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:ae(o)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:f}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsxRuntime.jsx("div",{ref:c,id:d,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":f,style:u?{position:"fixed",left:u.left,top:u.top}:{position:"fixed",visibility:"hidden"},onKeyDown:m=>{let p=c.current;if(!p)return;let v=mn(p);m.key==="ArrowDown"?(m.preventDefault(),m.stopPropagation(),Ot(v,document.activeElement,1)):m.key==="ArrowUp"&&(m.preventDefault(),m.stopPropagation(),Ot(v,document.activeElement,-1));},children:jsxRuntime.jsx(nr.Provider,{value:-1,children:r})}):null]})}function yP({entry:e}){let{isEnabled:t}=se(e.slot),o=ee(e.slot);return t?jsxRuntime.jsx(Zt,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(ar,{slot:e.slot})}):jsxRuntime.jsx(bo,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function gn({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function pa({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(gn,{}):e.kind==="submenu"?jsxRuntime.jsx(Zt,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsxRuntime.jsx(pa,{entry:o},n))}):e.slot==="file.open"?jsxRuntime.jsx(cd,{}):e.slot==="file.save"?jsxRuntime.jsx(dd,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(ud,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(pd,{}):e.slot==="file.print"?jsxRuntime.jsx(md,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(fd,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(bP,{}):e.slot==="image.insert"?jsxRuntime.jsx(gd,{}):e.picker==="tableGrid"?jsxRuntime.jsx(yP,{entry:e}):jsxRuntime.jsx(bo,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Df(e){if(!Et.isValidElement(e))return null;let t=tr(e,Df);if(t!==null)return t;let o=e.type;return typeof o!="function"&&typeof o!="object"?null:typeof o.docxSlot=="string"?o.docxSlot:o.docxMenuRow===true?nl(e.props)??null:null}function xP(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function Rf(e,t,o){return Vi({entries:e??[],children:t,preset:o,keyOfEntry:xP,keyOfChild:Df,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsxRuntime.jsx(pa,{entry:n,children:i})})}function qt({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:s}){let{openMenu:l,setOpenMenu:c,activeMenu:d,opening:f}=at(),u=mf(),g=De(),m=Et.useId(),p=Et.useRef(null),v=Et.useRef(null),y=Et.useRef(false),x=Et.useRef(false),b=editor.CHROME_MENUS.find(E=>E.id===e),h=l===e,C=bf(h&&e===or,p,v);if(i)return null;let T=o??g(t??b?.labelKey??e),S=hf(u,e,d);if(S.skip)return null;if(S.asSubmenu)return jsxRuntime.jsx(Zt,{labelKey:t??b?.labelKey??e,label:T,children:Rf(b?.entries,s,a)});let P=Rf(b?.entries,s,a),k=S.iconOnly,w=()=>{c(null),p.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...S.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:p,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?m:void 0,className:"docx-menubar__trigger",disabled:f===true,tabIndex:S.tabStop?0:-1,...h?{"data-open":""}:{},...k?{"aria-label":T,title:T}:{},onMouseDown:Z,onKeyDown:E=>{E.key==="ArrowDown"||E.key==="Enter"||E.key===" "||E.key==="ArrowUp"?(E.preventDefault(),y.current=true,c(e)):E.key==="Escape"&&h&&(E.preventDefault(),w());},onClick:()=>{if(x.current){x.current=false;return}c(h?null:e);},onMouseEnter:()=>{l!==null&&l!==e&&(x.current=true,c(e));},onMouseLeave:()=>{x.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,k?null:T]}),h?jsxRuntime.jsx("div",{ref:E=>{v.current=E,E&&y.current&&(y.current=false,Bt(mn(E),"first"));},id:m,role:"menu","aria-label":T,style:C,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:E=>{let D=v.current;if(!D)return;let A=mn(D),_=document.activeElement;E.key==="ArrowDown"?(E.preventDefault(),Ot(A,_,1)):E.key==="ArrowUp"?(E.preventDefault(),Ot(A,_,-1)):E.key==="Home"?(E.preventDefault(),Bt(A,"first")):E.key==="End"?(E.preventDefault(),Bt(A,"last")):E.key==="Escape"?(E.preventDefault(),E.stopPropagation(),w()):E.key==="Tab"&&c(null);},children:jsxRuntime.jsx(nr.Provider,{value:-1,children:P})}):null]})}function hd(e){return Object.assign(o=>jsxRuntime.jsx(qt,{id:e,...o}),{docxMenu:e})}var bd=hd("file"),vd=hd("format"),yd=hd("insert");var rl=Et.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Ao(){return Et.useContext(rl)}function _f(){return Et.useContext(rl).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"],xd=["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"],Ff=["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"],Af=["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"],Of=["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 sr(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:s,hidden:l})=>{let c=H(),{close:d}=Ao(),f=De(),{isEnabled:u,disabledReason:g}=se(t);return l?null:jsxRuntime.jsx(_e,{slot:e,icon:r??ae(o.paths),shortcut:f(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...s?{className:s}:{},children:f(i??o.labelKey)})},{docxRow:e})}var ma=sr("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Nf}),fa=sr("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Lf}),ga=sr("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:Ff}),ha=sr("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Of});function cr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=H(),{close:a,clipboardRefusal:s,reportClipboardRefusal:l}=Ao(),c=De(),d=Et.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=s!==null;return jsxRuntime.jsx(_e,{slot:"edit.paste",icon:e??ae(xd),shortcut:c(o??"contextMenu.pasteShortcut"),disabled:!f||g,...s??u?{title:s??u??""}:{},onSelect:()=>{(async()=>{try{let{text:m,html:p}=await PP();(m||p)&&i?.exec({type:"paste",text:m,...p?{html:p}:{}});}catch(m){l(m instanceof Error?m.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.paste")})}cr.docxRow="edit.paste";async function PP(){let e=navigator.clipboard;if(typeof e.read=="function"&&typeof ClipboardItem<"u")try{let t=await e.read(),o="",n=null;for(let r of t)r.types.includes("text/plain")&&(o=await(await r.getType("text/plain")).text()),r.types.includes("text/html")&&(n=await(await r.getType("text/html")).text());if(o||n)return {text:o,html:n}}catch{}return {text:await e.readText(),html:null}}function dr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=H(),{close:a,clipboardRefusal:s,reportClipboardRefusal:l}=Ao(),c=De(),d=Et.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=s!==null;return jsxRuntime.jsx(_e,{slot:"edit.pasteWithoutFormatting",icon:e??ae(xd),shortcut:c(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!f||g,...s??u?{title:s??u??""}:{},onSelect:()=>{(async()=>{try{let m=await navigator.clipboard.readText();m&&i?.exec({type:"pasteWithoutFormatting",text:m});}catch(m){l(m instanceof Error?m.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.pasteWithoutFormatting")})}dr.docxRow="edit.pasteWithoutFormatting";var Bf=ee("format.painter")?.paths??[],al=sr("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:Bf}),il=sr("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:Bf});function hn(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:s,destructive:l})=>{let{close:c}=Ao(),d=De(),f=ll(),{isEnabled:u,disabledReason:g,execute:m}=se(t);return s||!f?null:jsxRuntime.jsx(_e,{slot:e,icon:r??ae(o.paths),disabled:!u,...g?{title:g}:{},className:`${l??o.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{m()&&c(true);},children:d(i??o.labelKey)})},{docxRow:e})}var ur=hn("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),pr=hn("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),mr=hn("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),fr=hn("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),gr=hn("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),hr=hn("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),br=hn("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),SP=[{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 bn({hidden:e}){let{close:t}=Ao(),o=De(),n=ll(),r=se({type:"setTableCellVerticalAlignment",alignment:"top"}),i=se({type:"setTableCellVerticalAlignment",alignment:"center"}),a=se({type:"setTableCellVerticalAlignment",alignment:"bottom"}),s=[r,i,a];return e||!n?null:jsxRuntime.jsxs("div",{className:"docx-contextmenu__table-align",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":o("tableAdvanced.verticalAlignment"),children:SP.map((l,c)=>{let d=s[c];return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":o(l.labelKey),title:d.disabledReason??o(l.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:f=>{f.preventDefault(),f.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:ae(editor.tableChromeIconPaths(l.icon))},l.alignment)})})]})}bn.docxRow="table.cellVerticalAlignment";function Zf(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:s})=>{let l=H(),{close:c,tocId:d}=Ao(),f=De(),u=Et.useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:m}=se(u);return s||d===null?null:jsxRuntime.jsx(_e,{slot:e,icon:r??ae(o.paths),disabled:!g,...m?{title:m}:{},onSelect:()=>{l?.exec(u),c(true);},...a?{className:a}:{},children:f(i??o.labelKey)})},{docxRow:e})}var vr=Zf("toc.refresh","entire",{labelKey:"toc.refresh",paths:Hf}),yr=Zf("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:Af});function ll(){return B(Et.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function sl({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:s}){let{close:l}=Ao();return jsxRuntime.jsx(_e,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),l(true);},...s?{className:s}:{},children:e})}var vn=Et.createContext(false);function Tt(){return Et.useContext(vn)?"":"docx-editor "}var ul=8;function DP(){let e=Et.useContext(Ct),t=at(),o=De(),{isEnabled:n,reason:r}=Gi(o);if((e?.mounted??0)===0)return null;let i=ee("review.addComment");return jsxRuntime.jsx(_e,{icon:ae(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function IP(){let e=H(),t=at(),o=De();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(_e,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var _P=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(IP,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(ma,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(fa,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(cr,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(dr,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(al,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(il,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(ga,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(ha,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(bo,{slotId:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(DP,{})}];function NP(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:ur.docxRow,render:()=>jsxRuntime.jsx(ur,{})},{kind:"row",id:pr.docxRow,render:()=>jsxRuntime.jsx(pr,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:mr.docxRow,render:()=>jsxRuntime.jsx(mr,{})},{kind:"row",id:fr.docxRow,render:()=>jsxRuntime.jsx(fr,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:gr.docxRow,render:()=>jsxRuntime.jsx(gr,{})},{kind:"row",id:hr.docxRow,render:()=>jsxRuntime.jsx(hr,{})},{kind:"row",id:br.docxRow,render:()=>jsxRuntime.jsx(br,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:bn.docxRow,render:()=>jsxRuntime.jsx(bn,{})}]}function LP(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:vr.docxRow,render:()=>jsxRuntime.jsx(vr,{})},{kind:"row",id:yr.docxRow,render:()=>jsxRuntime.jsx(yr,{})}]}function FP(e,t=false){return [..._P,...e?NP():[],...t?LP():[]]}function $f(e){if(!Et.isValidElement(e))return null;let t=tr(e,$f);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=nl(e.props);if(n)return n}return null}function Wf(e){if(!Et.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function HP(e){return e?.closest(".docx-editor__scroll-container")??null}function va({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=Tt(),s=H(),{t:l}=N(),c=ll(),d=Et.useRef(null),f=Et.useRef(null),[u,g]=Et.useState(null),[m,p]=Et.useState(null),[v,y]=Et.useState(null),x=Et.useMemo(()=>FP(c,m!==null),[c,m]),[b,h]=Et.useState(null),C=Et.useCallback((A=false)=>{g(null),h(null),p(null),y(null),A&&s?.focus();},[s]);Et.useEffect(()=>{if(n)return;let A=HP(d.current);if(!A)return;let _=F=>{F.preventDefault();let M=F.button===-1||F.clientX===0&&F.clientY===0,I=A.getBoundingClientRect();p(s?.snapshot().tocContext?.id??null),y(M||!(F.target instanceof HTMLElement)?null:F.target),g(M?{x:I.left+16,y:I.top+16}:{x:F.clientX,y:F.clientY});};return A.addEventListener("contextmenu",_),()=>A.removeEventListener("contextmenu",_)},[n,s]),Et.useEffect(()=>{n&&C();},[n,C]),Et.useEffect(()=>{if(!u)return;let A=M=>{f.current?.contains(M.target)||C();},_=M=>{M.key==="Escape"?(M.preventDefault(),C(true)):M.key==="Tab"&&C();},F=()=>C();return document.addEventListener("pointerdown",A,true),document.addEventListener("keydown",_),document.addEventListener("scroll",F,{capture:true,passive:true}),window.addEventListener("blur",F),window.addEventListener("resize",F),()=>{document.removeEventListener("pointerdown",A,true),document.removeEventListener("keydown",_),document.removeEventListener("scroll",F,true),window.removeEventListener("blur",F),window.removeEventListener("resize",F);}},[u,C]),Et.useLayoutEffect(()=>{let A=f.current;if(!u||!A)return;let{width:_,height:F}=A.getBoundingClientRect(),M=window.innerWidth-_-ul,I=window.innerHeight-F-ul,U=Math.max(ul,u.x>M?u.x-_:u.x),L=Math.max(ul,u.y>I?u.y-F:u.y);h({x:U,y:L});},[u]),Et.useLayoutEffect(()=>{b&&f.current?.focus({preventScroll:true});},[b]);let T=Et.useRef(r);T.current=r;let S=Et.useRef(false);Et.useEffect(()=>{let A=u!==null;A!==S.current&&(S.current=A,T.current?.(A));},[u]);let P=Et.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>C(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,C]),[k,w]=Et.useState(null),E=Et.useMemo(()=>({close:C,anchor:u,tocId:m,target:v,clipboardRefusal:k,reportClipboardRefusal:w}),[C,u,m,v,k]),D={position:"fixed",left:(b??u)?.x??0,top:(b??u)?.y??0,visibility:b?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:d,style:{display:"contents"},children:u?jsxRuntime.jsx(na.Provider,{value:P,children:jsxRuntime.jsx(rl.Provider,{value:E,children:jsxRuntime.jsxs("div",{ref:f,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??l("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:D,onKeyDown:A=>{let _=f.current;if(!_)return;let F=mn(_);A.key==="ArrowDown"?(A.preventDefault(),Ot(F,document.activeElement,1)):A.key==="ArrowUp"?(A.preventDefault(),Ot(F,document.activeElement,-1)):A.key==="Home"?(A.preventDefault(),Bt(F,"first")):A.key==="End"&&(A.preventDefault(),Bt(F,"last"));},children:[Et.Children.toArray(i).filter(Wf),Vi({entries:x,children:Et.Children.toArray(i).filter(A=>!Wf(A)),preset:o,keyOfEntry:A=>A.id,keyOfChild:A=>cf($f(A)),renderEntry:A=>A.kind==="separator"?jsxRuntime.jsx(gn,{}):A.render(),onUnmatched:(A,_)=>{_.props.hidden&&Nm(A);}})]})})}):null})}var Pd=Object.assign(va,{Cut:ma,Copy:fa,Paste:cr,PasteWithoutFormatting:dr,Delete:ga,SelectAll:ha,InsertRowAbove:ur,InsertRowBelow:pr,InsertColumnLeft:mr,InsertColumnRight:fr,DeleteTableRow:gr,DeleteTableColumn:hr,DeleteTable:br,CellVerticalAlignment:bn,RefreshToc:vr,RefreshTocPageNumbers:yr,Item:sl,Slot:bo,Row:_e,Group:da,Separator:gn,Submenu:Zt});var Uf=Et.createContext(void 0),Vf=Uf.Provider,Kt=()=>Et.useContext(Uf);function Gf(){let e=Kt(),{t}=N();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&ke(e.hyperlink,{}),e?.contentControl&&ke(e.contentControl,{}),e?.equation&&ke(e.equation,{}),e?.contextMenu&&ke(e.contextMenu,{t:o=>t(o)})]})}function jf(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(Jr,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(ta,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(oa,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&ke(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(va,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function KP(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 Sd(){let e=H(),t=Et.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=B(t,KP);return o?.kind==="note"?o:null}function Yf(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 Xf(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&&Yf(e.documentAuthored,t.documentAuthored)&&Yf(e.sectionAuthored,t.sectionAuthored)}function WP(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Xf(e.footnote,t.footnote)&&Xf(e.endnote,t.endnote)}function Ed(){let e=H(),t=Et.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return B(t,WP)}function ya(e,t){let[o,n]=Et.useState(null),r=Et.useCallback(s=>n(s),[]),[i,a]=Et.useState({visibility:"hidden"});return Et.useLayoutEffect(()=>{let s=o?.closest(".docx-editor__scroll-container"),l=s??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!l)return;let c=0,d=null,f=new ResizeObserver(()=>g()),u=()=>{c=0;let p=e(l);if(p!==d&&(f.disconnect(),f.observe(l),f.observe(o),p&&f.observe(p),d=p),!p||!p.isConnected){a({visibility:"hidden"});return}let v=p.getBoundingClientRect(),y=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,b=s===l,h=t==="after"?v.bottom+6:v.top-y-x,C=b?Xn(l,v.left,h):{left:v.left,top:h},T=C.left,S=C.top,P=b?l.scrollLeft+8:8;a({position:b?"absolute":"fixed",left:t==="story-label"?T:Math.max(P,T+8),top:t==="story-label"?S:Math.max(b?l.scrollTop+8:8,S),...t==="story-label"?{width:Math.max(240,Math.min(v.width,l.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(v.width-16,l.clientWidth-16))},visibility:"visible"});},g=()=>{c||(c=requestAnimationFrame(u));};f.observe(l),f.observe(o);let m=new MutationObserver(g);return m.observe(l,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),l.addEventListener("scroll",g,{passive:true}),window.addEventListener("resize",g),u(),()=>{c&&cancelAnimationFrame(c),f.disconnect(),m.disconnect(),l.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[o,e,t]),{ref:r,style:i}}var UP=/^(footnote|endnote):(-?\d{1,10})$/;function eg(e){let t=UP.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function VP(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function Md(e){let t=H();return Et.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function GP(e){let{t}=N(),[o,n]=Et.useState(false),r=Et.useRef(null);return Et.useEffect(()=>{if(!o)return;let i=a=>{r.current?.contains(a.target)||n(false);};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]),jsxRuntime.jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":o,"aria-haspopup":"menu",onMouseDown:Z,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),n(false);},children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),n(false);},children:t("common.close")})]}):null]})}function fl({className:e}){let t=Kt(),o=Et.useRef(null),{t:n}=N(),r=H(),i=Sd(),[a,s]=Et.useState(null),[l,c]=Et.useState(null),[d,f]=Et.useState(false),u=Et.useRef(null),g=Et.useCallback(D=>{if(!i)return null;let _=[...D.querySelectorAll("[data-docx-note-scope]")].find(F=>F.matches("[data-docx-note]")&&F.dataset.docxNoteScope===i.id)??null;return _?.closest("[data-docx-notes]")??_},[i]),m=ya(g,"story-label"),p=Et.useCallback(()=>{u.current&&clearTimeout(u.current),u.current=null,s(null);},[]);Et.useEffect(()=>{if(!r)return;let D=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!D)return;let A=M=>{let I=M.target;if(!I)return;let U=I.closest("[data-docx-note-ref]");if(U?.dataset.docxNoteScope){M.preventDefault(),p(),c(null),r.setActiveScope({kind:"note",id:U.dataset.docxNoteScope});return}I.closest("[data-docx-note-mark-back]")&&(M.preventDefault(),p(),c(null),r.setActiveScope({kind:"body"}));},_=M=>{let I=M,L=I.target?.closest("[data-docx-note-scope]");L?.dataset.docxNoteScope&&(I.preventDefault(),c({scopeId:L.dataset.docxNoteScope,x:I.clientX,y:I.clientY}));},F=M=>{if(VP())return;let U=M.target?.closest("[data-docx-note-ref]");if(!U?.dataset.docxNoteScope){p();return}let L=U.dataset.docxNoteScope,j=r.getNotePreviewText(L)??U.getAttribute("aria-description")??n("notes.previewFallback"),me=U.getBoundingClientRect();u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({scopeId:L,text:j,x:me.left,y:me.bottom+4});},400);};return D.addEventListener("click",A),D.addEventListener("contextmenu",_),D.addEventListener("pointerover",F),D.addEventListener("scroll",p,true),()=>{D.removeEventListener("click",A),D.removeEventListener("contextmenu",_),D.removeEventListener("pointerover",F),D.removeEventListener("scroll",p,true),p();}},[r,p,n]);let v=Et.useCallback(D=>{r&&(r.exec(D),c(null));},[r]),y=l?eg(l.scopeId):null,x=Et.useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),b=Et.useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),h=Et.useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),C=Md(x??{type:"deleteNote",noteKind:"footnote",noteId:0}),T=Md(b??{type:"convertNote",fromKind:"footnote",noteId:0}),S=Md(h??{type:"convertAllNotes",fromKind:"footnote"}),P=i?eg(i.id):null,k=P?n("notes.editingRegion",{kind:P.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:P.noteId}):null,w=l&&y?{...l,...y,onDelete:()=>{x&&v(x);},onConvert:()=>{b&&v(b);},onConvertAll:()=>{h&&v(h);},onOpenProperties:()=>f(true),onClose:()=>c(null),deleteEnabled:C.enabled,convertEnabled:T.enabled,convertAllEnabled:S.enabled,deleteDisabledReason:C.reason??void 0,convertDisabledReason:T.reason??void 0,convertAllDisabledReason:S.reason??void 0}:null,E={onClose:()=>f(false),onApply:D=>{v(D),f(false);}};return r?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&P?jsxRuntime.jsxs("div",{ref:m.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...m.style,zIndex:ct.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:k}),jsxRuntime.jsx(GP,{onOpenProperties:()=>f(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?ke(t.notePreview,a):jsxRuntime.jsx(jn,{...a}):null,w&&t?.notesContextMenu!==false?t?.notesContextMenu?ke(t.notesContextMenu,w):jsxRuntime.jsx(Yn,{...w}):null,d&&t?.noteProperties!==false?t?.noteProperties?ke(t.noteProperties,E):jsxRuntime.jsx(gl,{...E}):null]}):null}function gl(e){let{t}=N(),o=H(),n=Ed(),[r,i]=Et.useState("document"),[a,s]=Et.useState("decimal"),[l,c]=Et.useState("continuous"),[d,f]=Et.useState("pageBottom"),[u,g]=Et.useState("decimal"),[m,p]=Et.useState("continuous"),[v,y]=Et.useState("docEnd");Et.useEffect(()=>{n&&(s(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),f(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),p(n.endnote.resolved.numRestart),y(n.endnote.resolved.pos));},[n]);let x=!n?.footnote.documentAuthored&&!n?.footnote.sectionAuthored,b=!n?.endnote.documentAuthored&&!n?.endnote.sectionAuthored;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","data-docx-modal":"","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:ct.modal},onClick:e.onClose,onKeyDown:h=>{h.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.stopPropagation(),children:[jsxRuntime.jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-note-properties__body",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__scope",children:[jsxRuntime.jsx("span",{children:t("notes.scope")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:r,onChange:h=>i(h.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:h=>s(h.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:l,onChange:h=>c(h.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:d,onChange:h=>f(h.target.value),children:[jsxRuntime.jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsxRuntime.jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),b?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:u,onChange:h=>g(h.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:m,onChange:h=>p(h.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:v,"data-testid":"docx-notes-endnote-position",onChange:h=>y(h.target.value),children:[jsxRuntime.jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsxRuntime.jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__footer",children:[jsxRuntime.jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsxRuntime.jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!o)return;let h={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:l,position:d},endnote:{numFmt:u,numRestart:m,position:v}};o.can(h).ok&&e.onApply(h);},children:t("common.apply")})]})]})})}var ng=e=>e.image;function og(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 tS(e){e&&!e.closest(".docx-editor")&&e.classList.add("docx-editor");}function oS(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Nd(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(Ho(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(Ho(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(Ho(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(Ho(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function nS(e,t){let o=Nd(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function hl(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=ia(t);return Number.isInteger(o)?o:null}function rS(e,t){let o=Nd(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,f=c?hl(e.horizontalPoints):t.position?.horizontalEmu,u=d?hl(e.verticalPoints):t.position?.verticalEmu;return c&&f===null?{ok:false}:d&&u===null?{ok:false}:f===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:f,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,s=n?hl(e.horizontalPoints):t.position?.horizontalEmu,l=r?hl(e.verticalPoints):t.position?.verticalEmu;return n&&s===null?{ok:false}:r&&l===null?{ok:false}:{ok:true,value:{...typeof s=="number"?{horizontalEmu:s}:{},...typeof l=="number"?{verticalEmu:l}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function bl(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function vl(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Ca({open:e,onClose:t,className:o,triggerRef:n}){let r=H(),{t:i}=N(),a=B(ng),s=Et.useId(),l=Et.useId(),c=Et.useId(),d=Et.useRef(null),f=Et.useRef(null),u=Et.useRef(null),g=Et.useRef(null),[m,p]=Et.useState(null),[v,y]=Et.useState(null),x=f.current,b=x?.canCrop===false,h=x?.canResize===false,C=x?.locks.changeAspect===true,T=x?.kind==="anchored"&&x.canMove===true,S=x?.kind==="inline",P=x?.kind==="anchored"&&x.canMove===false;Et.useEffect(()=>{if(!e){f.current=null,u.current=null,g.current=null;return}if(!a)return;if(f.current=a,r?.surface){let{anchor:U}=r.surface.state().selection;u.current={paragraphId:U.paragraphId,offset:U.offset},g.current=r.surface.session.packageRevision();}y(null);let M=Nd(a),I=a.crop;p({widthPoints:String(Ho(a.widthEmu)),heightPoints:String(Ho(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,...M});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let k=Et.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=Et.useCallback(()=>{t(),k();},[t,k]);Et.useEffect(()=>{if(!e)return;let M=d.current;if(!M)return;let I=og(M);(I.find(Y=>Y.id==="image-prop-width"&&!Y.hasAttribute("disabled"))??I.find(Y=>!Y.hasAttribute("disabled"))??M).focus();let L=Y=>{if(Y.key==="Escape"){Y.preventDefault(),w();return}if(Y.key!=="Tab")return;let j=og(M);if(j.length===0)return;let me=document.activeElement,z=j.findIndex(J=>J===me);if(z===-1)return;Y.preventDefault();let ie=Y.shiftKey?(z-1+j.length)%j.length:(z+1)%j.length;j[ie]?.focus();};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[e,w]);let E=Et.useMemo(()=>{let M=x??a;return !M||M.widthEmu<=0?1:M.widthEmu/M.heightEmu},[a,x]),D=Et.useCallback(M=>{p(I=>{if(!I)return I;if(!I.lockAspect)return {...I,widthPoints:M};let U=vl(M);if(U===null)return {...I,widthPoints:M};let L=Math.round(U/E*100)/100;return {...I,widthPoints:M,heightPoints:String(L)}});},[E]),A=Et.useCallback(M=>{p(I=>{if(!I)return I;if(!I.lockAspect)return {...I,heightPoints:M};let U=vl(M);if(U===null)return {...I,heightPoints:M};let L=Math.round(U*E*100)/100;return {...I,widthPoints:String(L),heightPoints:M}});},[E]),_=Et.useCallback(()=>{let M=f.current;if(!M?.intrinsic)return;let I=M.intrinsic.pixelWidth*72/M.intrinsic.dpiX,U=M.intrinsic.pixelHeight*72/M.intrinsic.dpiY;p(L=>L&&{...L,widthPoints:String(Math.round(I*100)/100),heightPoints:String(Math.round(U*100)/100)});},[a]),F=Et.useCallback(()=>{let M=f.current,I=u.current,U=g.current;if(!r||!M||!m||!I||U===null)return;let L={type:"setImageProperties",drawingNodeId:M.id,expectedPackageRevision:U,selectionParagraphId:I.paragraphId,selectionOffset:I.offset};if(!h){let J=vl(m.widthPoints),W=vl(m.heightPoints);if(J===null||W===null){y("imageProperties.errors.invalidDimensions");return}let q=ia(J),fe=ia(W);q!==M.widthEmu&&(L.widthEmu=q),fe!==M.heightEmu&&(L.heightEmu=fe);}if(M.canCrop&&!b){let J=bl(m.cropLeft),W=bl(m.cropTop),q=bl(m.cropRight),fe=bl(m.cropBottom);if(J===null||W===null||q===null||fe===null){y("imageProperties.errors.invalidCrop");return}let ve=M.crop;(J!==ve.left||W!==ve.top||q!==ve.right||fe!==ve.bottom)&&(L.crop={left:J,top:W,right:q,bottom:fe});}m.title!==M.title&&(L.title=m.title),m.description!==M.description&&(L.description=m.description);let Y=m.hyperlink.trim();if(Y!==(M.hyperlink??"")&&(L.hyperlink=Y===""?null:Y),M.canChangeWrap&&m.wrap!==M.wrap&&(L.wrap=m.wrap),M.kind==="anchored"&&M.canMove&&nS(m,M)){let J=rS(m,M);if(!J.ok){y("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(J.value,M))){y("imageProperties.errors.invalidPosition");return}Object.assign(L,J.value);}if(!(L.widthEmu!==void 0||L.heightEmu!==void 0||L.title!==void 0||L.description!==void 0||L.hyperlink!==void 0||L.crop!==void 0||L.wrap!==void 0||L.horizontalEmu!==void 0||L.verticalEmu!==void 0||L.relativeToH!==void 0||L.relativeToV!==void 0)){w();return}if(!r.can(L).ok){y("imageProperties.errors.refused");return}if(!r.exec(L).ok){y("imageProperties.errors.refused");return}w();},[r,m,b,h,w]);return !e||!m?null:jsxRuntime.jsx("div",{ref:tS,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:M=>{M.stopPropagation(),oS(M);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","data-docx-modal":"","aria-labelledby":s,className:"docx-dialog docx-image-properties-dialog",onClick:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),children:[jsxRuntime.jsx("div",{id:s,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[v?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(v)}):null,jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsxRuntime.jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:m.widthPoints,disabled:h,onChange:M=>D(M.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsxRuntime.jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:m.heightPoints,disabled:h,onChange:M=>A(M.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m.lockAspect,disabled:C,onChange:M=>p(I=>I&&{...I,lockAspect:M.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:b||!x?.intrinsic,onClick:_,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,P?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,T?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[m.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:m.relativeToH??"page",onChange:M=>p(I=>I&&{...I,relativeToH:M.target.value}),children:editor.DRAWING_REL_FROM_H.map(M=>jsxRuntime.jsx("option",{value:M,children:i(`dialogs.imagePosition.relativeOptions.${M}`)},M))})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsxRuntime.jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:m.relativeToV??"line",onChange:M=>p(I=>I&&{...I,relativeToV:M.target.value}),children:editor.DRAWING_REL_FROM_V.map(M=>jsxRuntime.jsx("option",{value:M,children:i(`dialogs.imagePosition.relativeOptions.${M}`)},M))})]})]}):null,jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:m.horizontalPoints,onChange:M=>p(I=>I&&{...I,horizontalPoints:M.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:m.verticalPoints,onChange:M=>p(I=>I&&{...I,verticalPoints:M.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsxRuntime.jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:m.title,onChange:M=>p(I=>I&&{...I,title:M.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:m.description,onChange:M=>p(I=>I&&{...I,description:M.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:c,className:"docx-dialog__input docx-dialog__input--full",value:m.hyperlink,onChange:M=>p(I=>I&&{...I,hyperlink:M.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:l,children:i("formattingBar.imageWrap")}),jsxRuntime.jsx("select",{id:l,className:"docx-dialog__select docx-dialog__input--full",value:m.wrap,disabled:x?.canChangeWrap===false,onChange:M=>p(I=>I&&{...I,wrap:M.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(M=>jsxRuntime.jsx("option",{value:M,children:i(`imageWrap.targets.${M}`)},M))})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsxRuntime.jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:b,value:m.cropLeft,onChange:M=>p(I=>I&&{...I,cropLeft:M.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsxRuntime.jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:b,value:m.cropTop,onChange:M=>p(I=>I&&{...I,cropTop:M.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsxRuntime.jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:b,value:m.cropRight,onChange:M=>p(I=>I&&{...I,cropRight:M.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsxRuntime.jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:b,value:m.cropBottom,onChange:M=>p(I=>I&&{...I,cropBottom:M.target.value})})]}),b?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:F,children:i("common.apply")})]})]})})}function yl({className:e,hidden:t,asChild:o,children:n}){let r=Kt(),i=H(),{t:a}=N(),s=B(ng),[l,c]=Et.useState(false),d=Et.useRef(null),f={type:"setImageProperties",description:"probe"},u=i&&s?i.can(f):null,g=u?.ok===true,m=u&&!u.ok?u.reason:null;if(t)return null;let p=ee("image.properties"),v={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:m??a("formattingBar.imagePropertiesShortcut"),onMouseDown:Z,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(G,{...v,children:n}):jsxRuntime.jsx("button",{...v,children:n??ae(p?.paths)}),l&&r?.imageProperties!==false?r?.imageProperties?ke(r.imageProperties,{open:l,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(Ca,{open:l,onClose:()=>c(false),triggerRef:d}):null]})}yl.docxSlot="image.properties";var Cr=Object.assign(yl,{docxSlot:"image.properties"});function Ta(e){let t=H(),o=Et.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=B(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return Et.useMemo(()=>({execute:(r,i)=>editor.runToolbarCommand(t,e,r,i),value:n.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(n.value):n.value,options:e==="image.wrap"?editor.IMAGE_WRAP_TARGETS:[],isEnabled:n.enabled,disabledReason:n.disabledReason}),[t,e,n])}function xl({className:e,hidden:t,asChild:o,children:n}){let r=Kt(),i=Q(),{execute:a,value:s,isEnabled:l,disabledReason:c}=Ta("image.altText"),[d,f]=Et.useState(false),[u,g]=Et.useState(""),m=Et.useRef(null),p=Et.useRef(null),v=Et.useId();Et.useEffect(()=>{d&&g(s??"");},[d,s]),Et.useEffect(()=>{if(!d)return;let T=P=>{let k=m.current;P.target instanceof Node&&(k?.contains(P.target)||k?.ownerDocument.getElementById(v)?.contains(P.target))||f(false);},S=P=>{P.key==="Escape"&&(P.preventDefault(),f(false),p.current?.focus());};return document.addEventListener("mousedown",T,true),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",T,true),document.removeEventListener("keydown",S);}},[d,v]);let y=Et.useCallback(()=>{a(u),f(false);},[u,a]);if(t)return null;let x=ee("image.altText"),b=i(x?.labelKey??"formattingBar.altText"),h={type:"button",ref:p,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!l,...l?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?v:void 0,"aria-label":b,title:c??b,onMouseDown:Z,onClick:()=>f(T=>!T)},C={id:v,value:u,onValueChange:g,onApply:y,onClose:()=>f(false),isEnabled:l,anchorRef:p};return jsxRuntime.jsxs("div",{ref:m,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(G,{...h,children:n}):jsxRuntime.jsx("button",{...h,children:n??b}),d&&r?.imageAltText!==false?r?.imageAltText?ke(r.imageAltText,C):jsxRuntime.jsx(Cl,{...C}):null]})}xl.docxSlot="image.altText";var Pa=Object.assign(xl,{docxSlot:"image.altText"});function Cl({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:s}=N();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":s("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:l=>l.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:s("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:l=>o(l.target.value),placeholder:s("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:n,children:s("common.apply")})]})]})}var lg=Et.createContext(void 0),sg=lg.Provider;function Ue(){let e=Et.useContext(lg),{t}=N();return Et.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}function Hd(e){let[t,o]=Et.useState(e.session),[n,r]=Et.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(bS,{...e},n)}function bS({session:e,className:t,style:o,children:n}){let r=Ue(),[i,a]=Et.useState(e.signal.aborted),s=Et.useRef(null);return Et.useEffect(()=>{let l=()=>a(true);return e.signal.addEventListener("abort",l,{once:true}),e.signal.aborted&&l(),()=>e.signal.removeEventListener("abort",l)},[e]),i?null:jsxRuntime.jsx(pt,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:s,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(l.preventDefault(),e.acknowledge());},children:n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:r("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:r(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:r("textFormField.apply")})})]})})}var ug=Et.createContext(null),pg=ug.Provider;function Qe(){let e=Et.useContext(ug);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function kS(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function mg(e){let t=`docx-cc-list-${Et.useId()}`,[o,n]=Et.useState(()=>kS(e)),[r,i]=Et.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Et.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[s,l]=Et.useState(false),c=Et.useCallback(E=>{i(E),l(false);},[]),d=B(()=>e.canApply()),f=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Et.useState(()=>{let E=f??new Date;return {year:E.getFullYear(),month:E.getMonth()}}),m=Et.useCallback(E=>{let D=e.apply(E??o);return l(!D),D},[e,o]),p=Et.useCallback(()=>e.cancel(),[e]),v=Et.useCallback(async E=>{if(!e.replaceImage)return l(true),false;try{let D=E instanceof Uint8Array?E.byteLength:E.size;if(!e.canApply()||D>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return l(!0),!1;let A=E instanceof Uint8Array?E:new Uint8Array(await E.arrayBuffer()),_=await e.replaceImage(A);return l(!_),_}catch{return l(true),false}},[e]),y=Et.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),x=Et.useCallback(()=>{g(E=>editor.shiftMonth(E.year,E.month,-1)),S(null);},[]),b=Et.useCallback(()=>{g(E=>editor.shiftMonth(E.year,E.month,1)),S(null);},[]),h=Et.useCallback(E=>m(E),[m]),C=Et.useCallback(()=>m(editor.isoDateOf(new Date)),[m]),[T,S]=Et.useState(null),P=Et.useCallback(E=>{let D=editor.parseIsoDate(E);D&&(g({year:D.getFullYear(),month:D.getMonth()}),S(editor.isoDateOf(D)));},[]),k=Et.useCallback(()=>{let E=editor.calendarDateFromText(r,e.locale);return E?m(E):(l(true),false)},[r,e.locale,m]),w=Et.useCallback((E,D)=>{!Number.isInteger(E)||E<100||E>9999||!Number.isInteger(D)||D<0||D>11||(g({year:E,month:D}),S(null));},[]);return Et.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:s,apply:m,cancel:p,calendar:y,previousMonth:x,nextMonth:b,selectDay:h,selectToday:C,focusIso:T,focusDay:P,dateText:r,setDateText:c,applyDateText:k,showMonth:w,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:v}),[e,v,o,d,s,m,p,y,x,b,h,C,T,P,r,c,k,w,a,t])}function Ve(e,t,o,n){if(t.hidden)return null;let{children:r,asChild:i,className:a,style:s,hidden:l,id:c,title:d,"aria-label":f,...u}=t,g=r===void 0?n:r,{key:m,...p}=o,v={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...f!==void 0?{"aria-label":f}:{}};if(i){let{className:x,style:b,...h}=p;return jsxRuntime.jsx(G,{...u,...h,...v,...a?{className:a}:{},style:{...b,...s},children:g},m)}return jsxRuntime.jsx(e,{...u,...p,...v,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...s},children:g},m)}var Cn=e=>e.stopPropagation();function Zd(e){return Ve("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(qd,{}),jsxRuntime.jsx(Xd,{}),jsxRuntime.jsx(Kd,{}),jsxRuntime.jsx(Wd,{className:"docx-content-control-calendar-announcement"})]}))}function qd(e){let t=Qe(),o=Ue();return Ve("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:Cn,onClick:t.previousMonth},"\u2039")}function Kd(e){let t=Qe(),o=Ue();return Ve("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:Cn,onClick:t.nextMonth},"\u203A")}function Wd(e){let t=Qe();return Ve("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function zd(e){let t=Qe();return Ve("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,n)=>jsxRuntime.jsx("span",{children:o},n)))}function $d({day:e,...t}){let o=Qe(),n=o.calendar.days.find(i=>i.iso===o.focusIso)??o.calendar.days.find(i=>i.selected)??o.calendar.days.find(i=>i.today&&!i.otherMonth)??o.calendar.days.find(i=>!i.otherMonth),r=i=>{if(i.nativeEvent.isComposing||i.altKey||i.ctrlKey||i.metaKey)return;let a=editor.calendarDateForKey(e.iso,i.key,o.session.locale,i.shiftKey);a&&(i.preventDefault(),o.focusDay(a));};return Ve("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===n?.iso?0:-1,"aria-label":e.label,...e.selected?{"data-selected":"","aria-selected":true}:{},"aria-current":e.today?"date":void 0,"aria-selected":e.selected,...e.today?{"data-today":""}:{},...e.otherMonth?{"data-other-month":""}:{},disabled:!o.isEnabled,onMouseDown:Cn,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function Ud(e){let t=Qe(),o=Et.useRef(null);return Et.useLayoutEffect(()=>{let n=o.current;if(!n||n.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?n.querySelector(`[data-iso="${t.focusIso}"]`):null)??n.querySelector("[data-selected]")??n.querySelector("[data-today]:not([data-other-month])")??n.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),Ve("div",e,{ref:o,className:"docx-content-control-calendar-grid","data-docx-part":"grid",role:"grid","aria-label":t.calendar.title},Array.from({length:6},(n,r)=>jsxRuntime.jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(r*7,r*7+7).map(i=>jsxRuntime.jsx($d,{day:i},i.iso))},r)))}function Vd(e){let t=Qe(),o=Ue();return Ve("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:Cn,onClick:t.selectToday},o("contentControl.calendar.today"))}function Gd(e){return Ve("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zd,{}),jsxRuntime.jsx(zd,{}),jsxRuntime.jsx(Ud,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Vd,{}),jsxRuntime.jsx(Pl,{})]}),jsxRuntime.jsx(Tr,{}),jsxRuntime.jsx(El,{})]}))}function jd({item:e,...t}){let o=Qe();return Ve("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(n=>n.value===o.value)<0?o.items[0]===e?0:-1:o.value===e.value?0:-1,"aria-selected":o.value===e.value,disabled:!o.isEnabled,onMouseDown:Cn,onClick:()=>o.apply(e.value)},e.displayText)}function Tl(e){let t=Qe(),o=Ue();return Ve("div",e,{className:"docx-content-control-menu-list","data-docx-part":"list",role:"listbox",id:t.listId,"aria-label":o(`contentControl.types.${t.kind}`)},t.kind==="buildingBlockGallery"&&t.items.length===0?jsxRuntime.jsx("div",{className:"docx-content-control-menu-empty","data-docx-part":"empty",role:"note",tabIndex:0,children:o("contentControl.gallery.empty")}):t.items.map((n,r)=>jsxRuntime.jsx(jd,{item:n},r)))}function Pl(e){let t=Qe(),o=Ue();return Ve("input",e,{type:"text",className:"docx-content-control-menu-input","data-docx-part":"input","aria-label":o(`contentControl.types.${t.kind}`),value:t.kind==="date"?t.dateText:t.value,placeholder:t.kind==="date"?editor.calendarDateText("2006-11-22",t.session.locale):void 0,"aria-invalid":t.refused||void 0,role:t.kind==="comboBox"?"combobox":void 0,"aria-expanded":t.kind==="comboBox"?true:void 0,"aria-controls":t.kind==="comboBox"?t.listId:void 0,"aria-autocomplete":t.kind==="comboBox"?"list":void 0,onKeyDown:n=>{n.key!=="Enter"||n.nativeEvent.isComposing||(n.preventDefault(),n.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:Cn,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function Tr(e){let t=Qe(),o=Ue();return t.refused?Ve("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Yd(e){let t=Qe(),o=Ue();return Ve("button",e,{type:"button",className:"docx-dialog__button docx-dialog__button--primary","data-docx-part":"apply",disabled:!t.isEnabled,onClick:()=>t.kind==="date"?t.applyDateText():t.apply()},o("common.apply"))}function Sl(e){let t=Qe(),o=Ue();return Ve("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function El(e){return Ve("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Sl,{}),jsxRuntime.jsx(Yd,{})]}))}function Xd(e){return Ve("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Jd,{}),jsxRuntime.jsx(Qd,{})]}))}function Jd(e){let t=Qe(),o=Ue();return Ve("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:n=>t.showMonth(t.calendar.year,Number(n.target.value))},editor.calendarMonthNames(t.session.locale).map((n,r)=>jsxRuntime.jsx("option",{value:r,children:n},r)))}function Qd(e){let t=Qe(),o=Ue();return Ve("input",e,{type:"number",min:100,max:9999,className:"docx-content-control-calendar-year","data-docx-part":"year","aria-label":o("contentControl.calendar.year"),key:t.calendar.year,defaultValue:t.calendar.year,onBlur:n=>{let r=Number(n.target.value);if(!Number.isInteger(r)||r<100||r>9999){n.target.value=String(t.calendar.year);return}t.showMonth(r,t.calendar.month);},onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),n.currentTarget.blur());}},void 0)}function eu({autoOpen:e,...t}){let o=Qe(),n=Ue(),r=Et.useRef(null),i=Et.useRef(false);return Et.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),Ve("input",t,{ref:r,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":n("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:Cn,onCancel:o.cancel,onChange:a=>{let s=a.target.files?.[0];a.target.value="",s&&o.replaceImage(s);}},void 0)}function OS(e){let[t,o]=Et.useState(e.session),[n,r]=Et.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(BS,{...e},n)}function BS({session:e,className:t,style:o,children:n}){let r=Ue(),i=mg(e),[a,s]=Et.useState(e.signal.aborted),l=Et.useRef(null),[c]=Et.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(Et.useEffect(()=>{let u=()=>s(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Et.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Et.useLayoutEffect(()=>{if(a||d)return;let u=l.current,g=u?.ownerDocument,m=u&&e.anchor?editor.observeContentControlPopup(u,e.anchor):void 0;return u?.querySelector('[data-docx-part="grid"]')||(u?.querySelector("input")??u?.querySelector('[role=option][tabindex="0"]')??u?.querySelector("select,button,[data-docx-part=empty]"))?.focus({preventScroll:true}),()=>{m?.();let p=g?.activeElement;c?.isConnected&&(p===g?.body||p&&u?.contains(p))&&c.focus({preventScroll:true});}},[e,a,d,c]),Et.useEffect(()=>{let u=l.current;if(!u||a||d)return;let g=m=>{u.contains(m.target)||e.cancel();};return u.ownerDocument.addEventListener("pointerdown",g,true),()=>u.ownerDocument.removeEventListener("pointerdown",g,true)},[e,a,d]),a||d)return null;let f=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(pg,{value:i,children:jsxRuntime.jsx("div",{ref:l,role:"dialog","aria-label":f,className:`docx-content-control-widget-popup${t?` ${t}`:""}`,style:o,"data-docx-popup":"contentControlWidget","data-docx-part":"popup","data-kind":e.kind,onPointerDown:u=>u.stopPropagation(),onKeyDown:u=>{editor.contentControlPopupKeyDown(u.currentTarget,u.nativeEvent,e.cancel),i.listNavigation.keyDown(u.nativeEvent,u.currentTarget);},children:n??ZS(i)})})}function ZS(e){return e.kind==="date"?jsxRuntime.jsx(Gd,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(eu,{}),jsxRuntime.jsx(Tr,{}),jsxRuntime.jsx(Sl,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Pl,{}),jsxRuntime.jsx(Tl,{}),jsxRuntime.jsx(Tr,{}),jsxRuntime.jsx(El,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tl,{}),jsxRuntime.jsx(Tr,{})]})}var ru=Object.assign(OS,{Navigation:Xd,Month:Jd,Year:Qd,Calendar:Gd,Header:Zd,PreviousMonth:qd,Title:Wd,NextMonth:Kd,Weekdays:zd,Grid:Ud,Day:$d,Today:Vd,List:Tl,Item:jd,Input:Pl,Picture:eu,Error:Tr,Footer:El,Apply:Yd,Cancel:Sl});var to=ko();function KS(){return to.useState()}function WS({session:e,...t}){let[o,n]=Et.useState(e),[r,i]=Et.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(zS,{session:e,...t},r):null}function zS({session:e,children:t,preset:o,className:n,style:r}){let i=Ue(),a=B(()=>e.canApply()),[s,l]=Et.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Et.useState(e.signal.aborted),[f,u]=Et.useState(false);Et.useEffect(()=>{let x=()=>d(true);return e.signal.addEventListener("abort",x),e.signal.aborted&&x(),()=>e.signal.removeEventListener("abort",x)},[e]);let g=()=>{if(e.signal.aborted)return;let x=Number.isInteger(s.maxLength)&&s.maxLength>=0&&s.maxLength<=32767&&e.apply(s.defaultText,{type:s.type,maxLength:s.maxLength,format:s.format,enabled:s.enabled});u(!x);},m={values:s,setValue(x,b){l(h=>({...h,[x]:b,...x==="type"?{format:""}:{}})),u(false);},errors:f?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let p=editor.TEXT_FORM_FORMATS[s.type]??[],v={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(x,b)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),b]});return jsxRuntime.jsx(pt,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),e.cancel()),x.key==="Enter"&&x.target instanceof HTMLInputElement&&(x.preventDefault(),g());},children:jsxRuntime.jsx(to.Composition,{state:m,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[y("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:s.defaultText,onChange:x=>m.setValue("defaultText",x.target.value)})),y("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:s.type,onChange:x=>m.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsxRuntime.jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(editor.TEXT_FORM_FORMATS,s.type)?null:jsxRuntime.jsx("option",{value:s.type,disabled:true,children:i("textFormField.preservedType")})]})),y("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(s.maxLength)?"":s.maxLength,onChange:x=>m.setValue("maxLength",x.target.valueAsNumber)})),y("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:s.format,onChange:x=>m.setValue("format",x.target.value),children:[p.map(x=>jsxRuntime.jsx("option",{value:x,children:v[x]?i(v[x]):x||i("textFormField.noFormat")},x)),p.includes(s.format)?null:jsxRuntime.jsx("option",{value:s.format,disabled:true,children:s.format||i("textFormField.noFormat")})]})),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:s.enabled,onChange:x=>m.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:m.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var Ma=Object.assign(WS,{Header:to.Header,Title:to.Title,Body:to.Body,Footer:to.Footer,Apply:to.Apply,Cancel:to.Cancel,Error:to.Error,Field:to.Field});var hg="(prefers-color-scheme: dark)";function bg(){return typeof window<"u"&&typeof window.matchMedia=="function"}function vg(){return bg()?window.matchMedia(hg).matches:false}function yg(e,t){return e==="dark"||e==="system"&&t}function xg(e){if(!bg())return ()=>{};let t=window.matchMedia(hg);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function iu(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function Tg(){let e=H(),t=Kt(),o=Et.useRef(t);o.current=t;let[n,r]=Et.useState(null),[i,a]=Et.useState(null),s=t?.contentControlWidget!==void 0,l=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Et.useEffect(()=>{if(!e||!s&&!l&&!c)return;let u=true,g=[...s?["dropdown","comboBox","date","buildingBlockGallery"]:[],...l?["checkbox"]:[],...c?["picture"]:[]],m=e.setContentControlWidgetChrome({kinds:g,onRequest(p){if(o.current?.[iu(p.kind)]===false)return p.cancel();r(p),p.signal.addEventListener("abort",()=>{u&&r(v=>v===p?null:v);},{once:true});}},{fallback:true});return ()=>{u=false,m(),r(null);}},[e,s,l,c]),Et.useEffect(()=>{if(!e||!d)return;let u=true,g=e.setInvalidTextFormFieldChrome({onRequest(m){if(o.current?.invalidTextFormField===false)return m.cancel();a(m),m.signal.addEventListener("abort",()=>{u&&a(p=>p===m?null:p);},{once:true});}},{fallback:true});return ()=>{u=false,g(),a(null);}},[e,d]),Et.useEffect(()=>{n&&t?.[iu(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let f=n?t?.[iu(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&f&&ke(f,{session:n},n),i&&t?.invalidTextFormField&&ke(t.invalidTextFormField,{session:i},i)]})}var YS=e=>e.pageSetup??null,XS=e=>e.editable;function Pn(){let e=H(),t=B(YS),o=B(XS),n=Et.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=Et.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 Et.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var su=[{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}],Mg=1440,QS=e=>Math.round(e/Mg*100)/100,eE=e=>Math.round(e*Mg);function tE(e,t){let o=Math.min(e,t),n=Math.max(e,t);return su.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var Eg=12240,wg=15840,Bo=1440;function oE({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=N(),s=Ai(e,t),{pageSetup:l,isEnabled:c,apply:d}=Pn(),[f,u]=Et.useState(Eg),[g,m]=Et.useState(wg),[p,v]=Et.useState("portrait"),[y,x]=Et.useState(Bo),[b,h]=Et.useState(Bo),[C,T]=Et.useState(Bo),[S,P]=Et.useState(Bo),[k,w]=Et.useState(false),[E,D]=Et.useState("document"),A=Et.useRef(null),_=Et.useRef("no");Et.useEffect(()=>{if(!e){_.current="no";return}if(_.current==="yes"&&l===null){_.current="no";return}_.current==="yes"||_.current==="loading"&&l===null||(w(false),u(l?.pageWidthTwips??Eg),m(l?.pageHeightTwips??wg),v(l?.orientation??"portrait"),x(l?.marginsTwips.top??Bo),h(l?.marginsTwips.bottom??Bo),T(l?.marginsTwips.left??Bo),P(l?.marginsTwips.right??Bo),D("document"),_.current=l===null?"loading":"yes");},[e,l]);let F=Et.useCallback(z=>{let ie=su[z];ie&&(u(p==="landscape"?ie.height:ie.width),m(p==="landscape"?ie.width:ie.height));},[p]),M=Et.useCallback(z=>{z!==p&&(v(z),u(g),m(f));},[p,f,g]),I=Et.useCallback(()=>{if(!c)return;if(!s()){t();return}let z=d({pageWidthTwips:f,pageHeightTwips:g,orientation:p,marginTopTwips:y,marginRightTwips:S,marginBottomTwips:b,marginLeftTwips:C,scope:E});w(!z),z&&t();},[c,s,d,f,g,p,y,S,b,C,E,t]);if(!e)return null;let U=tE(f,g),L=(z,ie,J)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${z[0].toUpperCase()}${z.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${z}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:QS(ie),onChange:W=>J(Math.max(0,eE(Number(W.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"in"})]}),Y={pageWidth:f,pageHeight:g,orientation:p,marginTop:y,marginBottom:b,marginLeft:C,marginRight:S,scope:E},j={pageWidth:u,pageHeight:m,orientation:M,marginTop:x,marginBottom:h,marginLeft:T,marginRight:P,scope:D},me={values:Y,setValue(z,ie){j[z](ie);},errors:k?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:I,cancel:t};return jsxRuntime.jsx(pt,{kind:"pageSetup",className:o,style:n,panelRef:A,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t(),z.key==="Enter"&&z.target instanceof HTMLInputElement&&c&&(z.preventDefault(),I());},children:jsxRuntime.jsx(no.Composition,{state:me,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:U,onChange:z=>F(Number(z.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[su.map((z,ie)=>jsxRuntime.jsx("option",{value:ie,children:a(z.labelKey)},z.labelKey)),U<0&&jsxRuntime.jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:p,onChange:z=>M(z.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsxRuntime.jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsxRuntime.jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label docx-dialog__section-label--spaced",children:a("dialogs.pageSetup.margins")}),L("top",y,x),L("bottom",b,h),L("left",C,T),L("right",S,P),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:E,onChange:z=>D(z.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsxRuntime.jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsxRuntime.jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:k?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:I,children:a("common.apply")})]})]}),children:r})})}var no=ko();function nE(){return no.useState()}var Sn=Object.assign(oE,{Header:no.Header,Title:no.Title,Body:no.Body,Footer:no.Footer,Apply:no.Apply,Cancel:no.Cancel,Error:no.Error,Field:no.Field});var lE={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},sE=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??lE;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,direction:t.disagrees?.direction??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},cE=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],dE=(e,t)=>cE.every(o=>e.disagrees[o]===t.disagrees[o]),uE=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.direction===t.direction&&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&&dE(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),pE=e=>e.editable;function cu(){let e=H(),t=B(sE,uE),o=B(pE),n=Et.useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=Et.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:n,apply:r}}function gE({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=N(),s=Ai(e,t),{format:l,isEnabled:c,apply:d}=cu(),[f,u]=Et.useState("left"),[g,m]=Et.useState("ltr"),[p,v]=Et.useState(0),[y,x]=Et.useState(0),[b,h]=Et.useState("none"),[C,T]=Et.useState(0),[S,P]=Et.useState(0),[k,w]=Et.useState(0),[E,D]=Et.useState("multiple"),[A,_]=Et.useState(1.08),[F,M]=Et.useState(false),[I,U]=Et.useState(false),[L,Y]=Et.useState(false),[j,me]=Et.useState(true),[z,ie]=Et.useState(false),[J,W]=Et.useState([]),[q,fe]=Et.useState(false),[ve,de]=Et.useState(0),[ze,Lt]=Et.useState("left"),[Je,ut]=Et.useState("none"),[Se,uo]=Et.useState(editor.NO_MIXED_FIELDS),[po,mo]=Et.useState(false),Mo=K=>a(po&&(K==="indentLeft"||K==="indentRight"||K==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Yt=Et.useRef(editor.NO_MIXED_FIELDS),ne=Et.useId(),[ge,xt]=Et.useState(false),zn=Et.useRef(null),re=Et.useRef(false),oe=Et.useRef(null);Et.useEffect(()=>{if(!e){re.current=false;return}if(re.current||l===null)return;let K=editor.seedFields(l);u(K.alignment),m(K.direction),v(K.indentLeft),x(K.indentRight),h(K.special),T(K.specialBy),P(K.spaceBefore),w(K.spaceAfter),D(K.lineRule),_(K.lineValue),M(K.contextualSpacing),U(K.keepNext),Y(K.keepLines),me(K.widowControl),ie(K.pageBreakBefore),W(K.tabStops),fe(false);let be=editor.mixedFieldsOf(l);uo(be),mo(l.indentUnknown),de(0),Lt("left"),ut("none"),Yt.current=be,xt(false),oe.current=K,re.current=true;},[e,l]);let ye=Et.useCallback(()=>{if(!c)return;if(!s()){t();return}let K=oe.current,be=K===null?null:editor.changedFields(K,{alignment:f,direction:g,indentLeft:p,indentRight:y,special:b,specialBy:C,spaceBefore:S,spaceAfter:k,lineRule:E,lineValue:A,contextualSpacing:F,keepNext:I,keepLines:L,widowControl:j,pageBreakBefore:z,tabStops:J,clearedAllTabStops:q},Yt.current,Se);if(be===null){t();return}if(d(be)){xt(false),t();return}xt(true);},[c,s,d,t,Se,q,f,g,p,y,b,C,S,k,E,A,F,I,L,j,z,J]),$e=Et.useCallback(()=>{let K=Math.round(ve);return K<=0?false:(uo(be=>({...be,tabStops:false})),W(editor.withTabStop(J,{positionTwips:K,alignment:ze,...Je!=="none"?{leader:Je}:{}})),de(0),Lt("left"),ut("none"),true)},[J,ve,ze,Je]);if(!e)return null;let Ze=K=>uo(be=>({...be,[K]:false})),fo=(K,be,Ro,rt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":rt,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${ne}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Se[rt]?"":editor.twipsToInches(be),placeholder:Se[rt]?Mo(rt):void 0,onChange:zr=>{Ze(rt),Ro(editor.inchesToTwips(Number(zr.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),$n=(K,be,Ro,rt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${ne}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Se[rt]?"":be,placeholder:Se[rt]?Mo(rt):void 0,onChange:zr=>{Ze(rt),Ro(Math.max(0,Number(zr.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),Wr=(K,be,Ro)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:be,ref:rt=>{rt&&(rt.indeterminate=Se[K]);},onChange:rt=>{uo(zr=>({...zr,[K]:false})),Ro(rt.target.checked);}}),a(`dialogs.paragraph.${K}`)]}),jy={alignment:f,direction:g,indentLeft:p,indentRight:y,special:b,specialBy:C,spaceBefore:S,spaceAfter:k,lineRule:E,lineValue:A,contextualSpacing:F,keepNext:I,keepLines:L,widowControl:j,pageBreakBefore:z,tabStops:J,clearedAllTabStops:q},mm=K=>{let be=Yt.current;K!==g&&!be.direction&&!be.alignment&&u(editor.alignmentAfterDirectionChange),m(K);},Yy={alignment:u,direction:mm,indentLeft:v,indentRight:x,special:h,specialBy:T,spaceBefore:P,spaceAfter:w,lineRule:D,lineValue:_,contextualSpacing:M,keepNext:U,keepLines:Y,widowControl:me,pageBreakBefore:ie,tabStops:W,clearedAllTabStops:fe},Xy={values:jy,mixed:Se,setValue(K,be){Yy[K](be),K==="lineRule"?(Ze("lineSpacing"),_(be===oe.current?.lineRule?oe.current.lineValue:be==="multiple"?1.08:12)):K==="specialBy"?Ze("special"):K in Se&&Ze(K);},errors:ge?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:ye,cancel:t};return jsxRuntime.jsx(pt,{kind:"paragraph",className:o,style:n,panelRef:zn,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:K=>{K.key==="Escape"&&t();let be=K.target instanceof HTMLButtonElement||K.target instanceof HTMLSelectElement;if(K.key==="Enter"&&!be){let Ro=K.target;if(Ro instanceof HTMLElement&&Ro.dataset.docxTabEntry!==void 0){$e();return}c&&ye();}},children:jsxRuntime.jsx(ro.Composition,{state:Xy,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__columns",children:[jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${ne}-alignment`,className:"docx-dialog__input",value:Se.alignment?"":f,onChange:K=>{Ze("alignment"),u(K.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Se.alignment?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsxRuntime.jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${ne}-direction`,className:"docx-dialog__input",value:Se.direction?"":g,onChange:K=>{Ze("direction"),mm(K.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Se.direction?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsxRuntime.jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),fo("beforeText",p,v,"indentLeft"),fo("afterText",y,x,"indentRight"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${ne}-special`,className:"docx-dialog__input",value:Se.special?"":b,onChange:K=>{Ze("special"),h(K.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Se.special?jsxRuntime.jsx("option",{value:"",children:Mo("special")}):null,jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsxRuntime.jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsxRuntime.jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),b!=="none"?jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${ne}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Se.special?"":editor.twipsToInches(C),placeholder:Se.special?Mo("special"):void 0,onChange:K=>{Ze("special"),T(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),J.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(Se.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):J.map(K=>jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:editor.formatInches(K.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[K.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>W(J.filter(be=>be!==K)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(K.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},K.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${ne}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(ve),onChange:K=>de(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${ne}-tabAlignment`,className:"docx-dialog__input",value:ze,onChange:K=>Lt(K.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsxRuntime.jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${ne}-tabLeader`,className:"docx-dialog__input",value:Je,onChange:K=>ut(K.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsxRuntime.jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsxRuntime.jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsxRuntime.jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:$e,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{uo(K=>({...K,tabStops:false})),fe(true),W([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),$n("spaceBefore",S,P,"spaceBefore"),$n("spaceAfter",k,w,"spaceAfter"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${ne}-lineSpacing`,className:"docx-dialog__input",value:Se.lineSpacing?"":E,onChange:K=>{let be=K.target.value;Ze("lineSpacing"),D(be),_(be===oe.current?.lineRule?oe.current.lineValue:be==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Se.lineSpacing?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsxRuntime.jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsxRuntime.jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ne}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${ne}-at`,type:"number",className:"docx-dialog__input",min:.01,step:E==="multiple"?.01:1,value:Se.lineSpacing?"":A,disabled:Se.lineSpacing,onChange:K=>{let be=K.target.value.trim();_(be===""?E==="multiple"?1.08:12:Number(be)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:E==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),Wr("contextualSpacing",F,M),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),Wr("keepNext",I,U),Wr("widowControl",j,me),Wr("keepLines",L,Y),Wr("pageBreakBefore",z,ie)]})]})}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:ge?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:ye,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var ro=ko();function hE(){return ro.useState()}var xo=Object.assign(gE,{Header:ro.Header,Title:ro.Title,Body:ro.Body,Footer:ro.Footer,Apply:ro.Apply,Cancel:ro.Cancel,Error:ro.Error,Field:ro.Field});var Hg=Et.createContext(null),Pr=()=>Et.useContext(Hg);function Ag({popups:e,children:t}){let o=H(),n=Cc(),[r,i]=Et.useState(null),[a,s]=Et.useState(null),[l,c]=Et.useState(null),[d,f]=Et.useState(null),u=Et.useRef(d);u.current=d;let g=Et.useRef(e);g.current=e;let m=Et.useRef(null),p=Et.useRef(l);p.current=l;let v=()=>s(null);Et.useEffect(()=>{if(a!==null)return;let h=m.current;m.current=null,h?.isConnected&&h.focus({preventScroll:true});},[a]),Et.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(h){if(g.current?.textFormField===false){h.cancel();return}u.current?.cancel(),s(null),c(h),h.signal.addEventListener("abort",()=>c(C=>C===h?null:C),{once:true});}},{fallback:true})},[o]),Et.useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let h=o.setRevisionMarkupChrome({onRequest(C){if(g.current?.revisionMarkup===false){C.cancel();return}p.current?.cancel(),s(null),f(C),C.signal.addEventListener("abort",()=>f(T=>T===C?null:T),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),h();}},[o,r,e?.revisionMarkup===false]),Et.useEffect(()=>{s(null),c(null),f(null);},[o,n]),Et.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&p.current?.cancel(),a&&e?.[a]===false&&s(null);},[e,a]);let y=Et.useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(h,C){p.current?.cancel(),u.current?.cancel(),g.current?.[h]!==false&&(m.current=C??r?.ownerDocument.activeElement,s(h));}}),[r,e?.pageSetup]),x={open:true,onClose:v},b=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?ke(e.pageSetup,x):jsxRuntime.jsx(Sn,{...x}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?ke(e.paragraph,x):jsxRuntime.jsx(xo,{...x}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?ke(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ur,{session:d}):l&&e?.textFormField!==false?e?.textFormField?ke(e.textFormField,{session:l},l):jsxRuntime.jsx(Ma,{session:l}):null;return jsxRuntime.jsxs(Hg.Provider,{value:y,children:[t,r?reactDom.createPortal(b,r):null]})}function Og(){let e=Pr();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer})}function Bg({children:e}){let t=Pr();return t?.container?reactDom.createPortal(e,t.container):e}var NE=["nw","n","ne","e","se","s","sw","w"],Wg=40,zg=12;function LE(e){return `imageOverlay.handle.${e}`}function FE(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 HE(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 AE(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 mu({containerRef:e,portalRef:t,scrollPort:o}){let n=H(),{t:r}=N(),[i,a]=Et.useState(null),[s,l]=Et.useState(null),[c,d]=Et.useState({left:0,top:0}),f=Et.useRef(null);f.current=s;let u=Et.useRef(null),g=Et.useRef(null),m=Et.useRef(null),p=Et.useRef(null),v=Et.useRef(null);Et.useEffect(()=>{let P=e.current;if(!P)return;let k=w=>{let E=w.target instanceof Element?w.target:null;if(E?.closest(".docx-drawing-textbox-content")){p.current=null;return}let D=E?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");p.current=D??null,D&&D===i?.id&&queueMicrotask(()=>m.current?.focus({preventScroll:true}));};return P.addEventListener("pointerdown",k,{capture:true}),()=>P.removeEventListener("pointerdown",k,{capture:true})},[e,i?.id]),Et.useEffect(()=>{if(!n){a(null);return}let P=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},k=()=>{queueMicrotask(P);};P();let w=[n.on("change",k),n.on("selectionChange",P)];return ()=>{for(let E of w)E();}},[n]);let y=Et.useCallback(()=>{d(P=>{let k=editor.overlayHostOrigin(e.current);return k.left===P.left&&k.top===P.top?P:k});},[e]);Et.useEffect(()=>{y();let P=t.current;if(!P||typeof ResizeObserver!="function")return;let k=new ResizeObserver(y);k.observe(P);let w=e.current;return w&&k.observe(w),()=>k.disconnect()},[e,t,y,i]),Et.useEffect(()=>{if(o){v.current=o;return}let P=e.current;if(!P||!n?.surface)return;let k=P.closest(".docx-editor__scroll-container");if(!k)return;let w=n.surface.overlayCoordinates();return v.current=editor.createImageOverlayScrollPort(k,w.paintScale),()=>{v.current=null;}},[e,n,o]);let x=Et.useCallback(()=>{l(null),u.current=null;let P=g.current;if(g.current=null,P)try{P.releasePointerCapture(P._lastPointerId??0);}catch{}},[]),b=Et.useCallback((P,k,w,E,D,A,_)=>{if(!n?.surface)return;let F=n.surface.activeScope();if(F.kind==="frame"&&!n.surface.selectDrawing(w.id,F.hostParagraphId))return;let M=n.surface.layout(),I=editor.captureImageMutationPreconditions(n);if(I){u.current=Object.freeze({x:E,y:D}),g.current=A,A._lastPointerId=_;try{A.setPointerCapture(_);}catch{}l({session:Object.freeze({drawingNodeId:w.id,startBounds:Object.freeze({x:w.x,y:w.y,width:w.width,height:w.height}),startWidthEmu:w.widthEmu,startHeightEmu:w.heightEmu,startPosition:w.position,anchorFrameOrigin:w.anchorFrameOrigin,transform:w.transform,mode:P,handle:k,preconditions:I,layoutRevision:M.revision,packageRevision:n.surface.session.packageRevision(),kind:w.kind}),bounds:w,accumulatedScrollPt:0}),m.current?.focus({preventScroll:true});}},[n]),h=Et.useCallback((P,k,w,E,D)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,P)){x();return}P.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:k,heightEmu:w,...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&&n.exec({type:"setImagePosition",...D}),x();},[x,n]),C=Et.useCallback(P=>{if(!n)return;let k=f.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!k)return;if(f.current&&P.key==="Escape"){P.preventDefault(),P.stopPropagation(),x();return}if(f.current)return;let w=P.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(P.key==="Delete"||P.key==="Backspace"){P.preventDefault(),P.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(P.key))return;P.preventDefault(),P.stopPropagation();let E=P.key==="ArrowLeft"?-w:P.key==="ArrowRight"?w:0,D=P.key==="ArrowUp"?-w:P.key==="ArrowDown"?w:0;if(P.altKey){if(!k.canResize)return;let _=AE(E,D),F=editor.computeImageResizeResult({handle:_,startWidthEmu:k.widthEmu,startHeightEmu:k.heightEmu,startBounds:{x:k.x,y:k.y,width:k.width,height:k.height},startPosition:k.position,anchorFrameOrigin:k.anchorFrameOrigin,deltaXPt:E,deltaYPt:D,transform:k.transform,preserveAspect:editor.resizePreservesAspect(_,k.aspectLocked,P.shiftKey,k.textbox),kind:k.kind});n.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(k.kind!=="anchored"||!k.canMove||!k.position)return;let A=editor.computeMovedImagePosition(k.position,E,D);n.exec({type:"setImagePosition",...A});},[x,n]);Et.useEffect(()=>{if(!s||!n?.surface)return;let P=n.surface.overlayCoordinates(),k=E=>{let D=f.current,A=u.current;if(!D||!A)return;let _=editor.cssPixelsToLayoutPoints(E.clientX-A.x,P.paintScale),F=editor.cssPixelsToLayoutPoints(E.clientY-A.y,P.paintScale);if(D.session.mode==="move"){let I=0,U=v.current,L=e.current?.closest(".docx-editor__scroll-container");if(U&&L){let j=L.getBoundingClientRect();E.clientY>j.bottom-Wg?I=zg:E.clientY<j.top+Wg&&(I=-zg),I!==0&&(I=U.scrollBy(I));}let Y=D.accumulatedScrollPt+I;l({...D,accumulatedScrollPt:Y,bounds:Object.freeze({...D.bounds,x:D.session.startBounds.x+_,y:D.session.startBounds.y+F+Y})});return}if(!D.session.handle)return;let M=editor.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:_,deltaYPt:F,transform:D.session.transform,preserveAspect:editor.resizePreservesAspect(D.session.handle,D.bounds.aspectLocked,E.shiftKey,D.bounds.textbox),kind:D.session.kind});l({...D,bounds:Object.freeze({...D.bounds,x:M.previewBounds.x,y:M.previewBounds.y,width:M.previewBounds.width,height:M.previewBounds.height,widthEmu:M.widthEmu,heightEmu:M.heightEmu})});},w=E=>{let D=f.current;if(D)if(E.type==="pointerup"){let A=editor.cssPixelsToLayoutPoints(E.clientX-(u.current?.x??E.clientX),P.paintScale),_=editor.cssPixelsToLayoutPoints(E.clientY-(u.current?.y??E.clientY),P.paintScale),F=editor.finalizeImageOverlayInteraction({session:D.session,deltaXPt:A,deltaYPt:_,accumulatedScrollPt:D.accumulatedScrollPt,aspectLocked:D.bounds.aspectLocked,textbox:D.bounds.textbox,shiftKey:E.shiftKey,anchorFrameOrigin:D.session.anchorFrameOrigin});h(D.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else x();};return window.addEventListener("pointermove",k),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w),()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w);}},[x,h,e,n,s]),Et.useEffect(()=>{!i||p.current!==i.id||(p.current=null,m.current?.focus({preventScroll:true}));},[i]);let T=s?.bounds??i,S=Et.useMemo(()=>{if(!n?.surface||!T)return null;let P=n.surface.publishedLayout(),k=n.surface.overlayCoordinates(),w=editor.overlayFrameToSheetCssPixels(P,{pageIndex:T.pageIndex,x:T.x,y:T.y,width:T.width,height:T.height},k),E={left:w.left+c.left,top:w.top+c.top,width:w.width,height:w.height},D=T.canResize,A=T.kind==="anchored"&&T.canMove;return jsxRuntime.jsxs("div",{ref:m,className:"docx-image-selection-overlay","data-drawing-node-id":T.id,tabIndex:0,onKeyDown:C,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${A?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":T.textbox?"true":void 0,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${E.left}px`,top:`${E.top}px`,width:`${E.width}px`,height:`${E.height}px`,cursor:A?"move":"default"},onPointerDown:_=>{Z(_),!(!A||!T.position)&&_.button===0&&(_.preventDefault(),_.stopPropagation(),b("move",null,T,_.clientX,_.clientY,_.currentTarget,_.pointerId));}}),D?NE.map(_=>{let F=HE(_);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(LE(_)),tabIndex:0,style:{left:`calc(${E.left}px + ${E.width}px * ${parseFloat(F.x)/100} - 5px)`,top:`calc(${E.top}px + ${E.height}px * ${parseFloat(F.y)/100} - 5px)`,cursor:FE(_)},onPointerDown:M=>{Z(M),M.button===0&&(M.preventDefault(),M.stopPropagation(),b("resize",_,T,M.clientX,M.clientY,M.currentTarget,M.pointerId));}},_)}):null]})},[T,b,n,C,c.left,c.top,r]);return !S||!t.current?null:reactDom.createPortal(S,t.current)}function gu(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Ll({className:e}){let t=H(),o=la(),n=Et.useRef(null),r=Et.useRef(null);Et.useLayoutEffect(()=>{let l=n.current;if(!(!t||!l))return t.attach(l),()=>{t.detach();}},[t]);let i=Et.useCallback(l=>{if(!o?.isEnabled)return;let c=l.clipboardData;c&&gu(c)&&(editor.clipboardPasteLandsContent(c)||(l.preventDefault(),o.insertFromDataTransfer(c)));},[o]),a=Et.useCallback(l=>{!o?.isEnabled||!gu(l.dataTransfer)||l.preventDefault();},[o]),s=Et.useCallback(l=>{if(o?.isEnabled&&gu(l.dataTransfer)){if(editor.clipboardDropLandsText(l.dataTransfer)){if((l.target instanceof Element?l.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;l.preventDefault();return}l.preventDefault(),o.insertFromDataTransfer(l.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:r,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:n,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:i,onDragOver:a,onDrop:s}),jsxRuntime.jsx(Og,{}),jsxRuntime.jsx(Gf,{}),jsxRuntime.jsx(Tg,{}),t?jsxRuntime.jsx(mu,{containerRef:n,portalRef:r}):null]})}function Ne(e){return e/1440*96}function Fl(e){return e/96*1440}function ht(e){return `${Math.round(e*100)/100}px`}function hu(e){return e/2}var UE=e=>e.isLoading||e.isOpening===true,VE=e=>({width:Ne(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:Ne(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),GE=(e,t)=>e.width===t.width&&e.height===t.height;function bu({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var Vg=false;function Gg(){Vg||!mt()||(Vg=true,console.warn("[docx-editor] loadingIndicator is ignored with chrome={false}, which renders no loading screen. Compose <DocxEditor.Loading overlay indicator={...} /> in a positioned box instead."));}function jE(e){let t=H(),[o,n]=Et.useState(null);return Et.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function YE({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=B(UE),s=B(VE,GE),l=jE(t),{t:c}=N();if(!e&&!a)return null;let d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bu,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:c("loading.label")})]});if(l)return reactDom.createPortal(d,l);let f=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:f,style:n,role:"status","aria-live":"polite",children:i??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:s.width,height:s.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsx("div",{className:"docx-editor__loading-page-status",children:d})})})})})}var Hl=Object.assign(YE,{Spinner:bu});function jg(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((m,p)=>(o.get(m[0])??0)-(o.get(p[0])??0));for(let[,{author:m,style:p}]of g)u[m]=p;return {authors:u,others:e.size>0?"kind":"author"}}let s=null,l=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([m,p])=>`${m}\0${JSON.stringify(p)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==s){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,s=g);return}r.setRevisionStyles(u),i=true,s=g;}}function f(){!r||l||(l=true,queueMicrotask(()=>{l=false,d();}));}return {registerScheme(u){e.add(u),f();},register(u,g,m){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:m}),f();},unregister(u){(e.delete(u)||t.delete(u))&&f();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,s=u===null?null:c(g),f();},current:a}}var _a=Et.createContext(null);function Jg(){let e=Et.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function vu(){let e=Et.useContext(_a),t=Jg();return Et.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function yu(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,s=Et.useContext(_a),l=Jg();return Et.useEffect(()=>{if(s)return s.register(l,t,{...o!==void 0?{color:o}:{},...n!==void 0?{background:n}:{},...r!==void 0?{activeBackground:r}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>s.unregister(l)},[s,l,t,o,n,r,i,a]),null}var Qg=false;function eh(e,t){e===t||Qg||!mt()||(Qg=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var th=false,oh=e=>e?.allowFormattingInLockedContent===true;function nh(e,t){oh(e)===oh(t)||th||!mt()||(th=true,console.warn("[docx-editor] contentLockPolicy changed after the editor was created, so the change is ignored. The editor reads contentLockPolicy once; create a new editor to change it."));}var rh=false;function ah(e){return e===void 0?"characters":e}function ih(e,t){ah(e)===ah(t)||rh||!mt()||(rh=true,console.warn("[docx-editor] lockedControlNavigation changed after the editor was created, so the change is ignored. The editor reads lockedControlNavigation once; create a new editor to change it."));}function iw(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),n=editor.resolveZoomMode(t);return o!==null&&n!==null&&editor.sameZoomMode(o,n)}function lw(e){let t=Et.useRef(e);t.current=e;let[o,n]=Et.useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:s,...l}=e,c=Et.useMemo(()=>({onReady:d=>{n(d),t.current.onReady?.(d);},onChange:d=>t.current.onChange?.(d),onFontError:d=>t.current.onFontError?.(d),onRevisionMarkupChange:d=>t.current.onRevisionMarkupChange?.(d)}),[]);return {DocxEditorRoot:Na,rootProps:l,rootListeners:c,editorRef:o}}function Na(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:s,zoom:l,zoomMode:c,tableInteractionLabel:d,imageDecodePort:f,children:u}=e,{t:g}=N(),m=Et.useCallback((L,Y)=>g(L,Y),[g]),p=Et.useRef(m);p.current=m;let v=Et.useRef(false),[y,x]=Et.useState(0),b=Et.useRef(e);b.current=e;let h=n?.maxFontBytes,[C,T]=Et.useState(null),S=Et.useRef(e.fieldResults),P=Et.useRef(e.contentLockPolicy),k=Et.useRef(e.lockedControlNavigation),w=Et.useRef(null);w.current??=jg();let E=w.current;Et.useEffect(()=>{let L=b.current,Y=L.translate??p.current,j=E.current();S.current=L.fieldResults,P.current=L.contentLockPolicy,k.current=L.lockedControlNavigation;let me=editor.createDocxEditor({...L.document!==void 0?{document:L.document}:{},...L.fonts?{fonts:L.fonts}:{},...L.fontShaping?{fontShaping:L.fontShaping}:{},...L.author!==void 0?{author:L.author}:{},...L.locale!==void 0?{locale:L.locale}:{},translate:Y,...L.revisionMarkup!==void 0?{revisionMarkup:L.revisionMarkup}:{},...L.reviewDisplayMode!==void 0?{reviewDisplayMode:L.reviewDisplayMode}:{},...L.fieldResults!==void 0?{fieldResults:L.fieldResults}:{},...L.contentLockPolicy!==void 0?{contentLockPolicy:L.contentLockPolicy}:{},...L.lockedControlNavigation!==void 0?{lockedControlNavigation:L.lockedControlNavigation}:{},...L.mode!==void 0?{mode:L.mode}:{},...j!==void 0?{revisionStyles:j}:{},...L.modules!==void 0?{modules:L.modules}:{},...L.zoom!==void 0?{zoom:L.zoom}:{},...L.zoomMode!==void 0?{zoomMode:L.zoomMode}:{},...L.tableInteractionLabel?{tableInteractionLabel:L.tableInteractionLabel}:{},...L.imageDecodePort?{imageDecodePort:L.imageDecodePort}:{},onFontError:J=>b.current.onFontError?.(J)}),z=me.on("revisionMarkupChange",J=>{v.current||(b.current.onRevisionMarkupChange?.(J),x(W=>W+1));}),ie=me.on("change",J=>b.current.onChange?.(J));return T(me),()=>{z(),ie(),me.destroy(),T(J=>J===me?null:J);}},[t,o,h,f,E]),Et.useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){b.current.onReady?.(C);return}let L=C.on("change",()=>{L(),b.current.onReady?.(C);});return L},[C]);let D=Et.useRef({editor:null,zoom:void 0,mode:void 0});Et.useEffect(()=>{if(!C)return;D.current.editor!==C&&(D.current={editor:C,zoom:void 0,mode:void 0});let Y=false;l!==void 0&&l!==D.current.zoom&&(D.current.zoom=l,C.setZoom(l),Y=true);let j=D.current.mode,me=c!==void 0&&(j===void 0||!iw(j,c)),z=c===void 0?null:editor.resolveZoomMode(c),ie=Y&&c!==void 0&&z!==null&&z.type==="fit";(me||ie)&&(D.current.mode=c,C.setZoomMode(c));},[C,l,c]),Et.useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let L=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(L)!==JSON.stringify(C.snapshot().revisionMarkup)){v.current=true;try{C.setRevisionMarkup(L);}finally{v.current=false;}}},[C,e.revisionMarkup,y]),Et.useEffect(()=>{C&&C.setAuthor(r);},[C,r]);let A=Et.useRef({editor:null,value:void 0});Et.useEffect(()=>{if(C){if(A.current.editor!==C){A.current={editor:C,value:s};return}A.current.value!==s&&(A.current.value=s,C.setMode(s));}},[C,s]),Et.useEffect(()=>{C&&C.setTranslate(a??m);},[C,a,m]),Et.useEffect(()=>{C&&C.setLocale(i);},[C,i]),Et.useEffect(()=>{C&&eh(S.current,e.fieldResults);},[C,e.fieldResults]),Et.useEffect(()=>{C&&nh(P.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),Et.useEffect(()=>{C&&ih(k.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),Et.useEffect(()=>{C&&C.setTableInteractionLabel(d??editor.defaultTableLabel);},[C,d]);let[_,F]=Et.useState(0),M=Et.useRef([]),I=Et.useMemo(()=>({mounted:_,register:()=>(F(L=>L+1),()=>F(L=>Math.max(0,L-1))),registerCommentDraft:L=>(M.current.push(L),()=>{let Y=M.current.indexOf(L);Y!==-1&&M.current.splice(Y,1);}),requestCommentDraft:()=>{let L=M.current.at(-1);return L?(L(),true):false}}),[_]),U=Et.useMemo(Em,[]);return Et.useEffect(()=>(E.connect(C),()=>E.connect(null)),[E,C]),jsxRuntime.jsx(sg,{value:a??m,children:jsxRuntime.jsx(Ct.Provider,{value:I,children:jsxRuntime.jsx(pc.Provider,{value:C,children:jsxRuntime.jsx(Pc.Provider,{value:U,children:jsxRuntime.jsx(_a.Provider,{value:E,children:jsxRuntime.jsx(sw,{children:jsxRuntime.jsx(cw,{children:jsxRuntime.jsx(Qi,{children:jsxRuntime.jsx(Vf,{value:e.popups,children:jsxRuntime.jsx(Ag,{popups:e.popups,children:u})})})})})})})})})})}function sw({children:e}){let t=zi(true);return jsxRuntime.jsx(Xr.Provider,{value:t,children:e})}function cw({children:e}){let t=Ui();return jsxRuntime.jsx(Vc.Provider,{value:t,children:e})}var La=316,wr=editor.REVIEW_MARKERS_GUTTER_PX,dh=24,Ol={inlineStart:0,inlineEnd:La},lh={inlineStart:wr,inlineEnd:wr},gw={inlineStart:0,inlineEnd:0},Tu={inlineStart:dh,inlineEnd:La};function hw(e){return e.inlineStart===Tu.inlineStart&&e.inlineEnd===Tu.inlineEnd}function uh(e,t){return hw(e)?Math.max(0,t-(La-wr)):t}function ph({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return lh;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Ol;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*dh>=La?Ol:i?Tu:lh}var bw=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:editor.reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},vw=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function mh(){let e=Ye(),[t,o]=Et.useState(null);return Et.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);if(n(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e]),t}function qo(){let e=Et.useContext(Ct),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=B(bw,vw),i=Ye(),a=Mm(),s=Et.useRef(null);t&&(s.current=t.pageWidthTwips);let l=t?.pageWidthTwips??s.current,c=(e?.mounted??0)>0,d=Et.useCallback(g=>c?ph({open:o,viewportWidth:g??0,pageWidthPx:l===null||n===null?0:Ne(l)*n,inlineStartReservation:a,docked:n===null,scroll:r}):gw,[c,o,l,n,a,r]),[f,u]=Et.useState(()=>d(i?i.clientWidth:null));return Et.useEffect(()=>{let g=()=>u(d(i?i.clientWidth:null));if(g(),!i||typeof ResizeObserver>"u")return;let m=new ResizeObserver(g);return m.observe(i),()=>m.disconnect()},[i,d]),f}var Bl=[.25,.5,.75,1,1.25,1.5,2];function Fa(e,t){return t==="in"?Bl.find(n=>n>e+.001)??null:[...Bl].reverse().find(n=>n<e-.001)??null}function fh(e,t){return e==="0"?1:e==="+"||e==="="?Fa(t,"in")??t:e==="-"?Fa(t,"out")??t:null}var Pu=Et.createContext(false);function gh(e){let t=Et.useContext(Pu),[o,n]=Et.useState(null);return Et.useLayoutEffect(()=>{let r=t?e?.parentElement??null:null;n(r?{host:r,scoped:r.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var Sw=e=>e.reviewPaneOpen??true,Ew=e=>e.zoomMode?.type==="fit";function Zl({className:e,style:t,children:o}){let{t:n}=N(),r=Tt(),i=H(),a=B(Sw),s=qo(),l=B(Ew),d=(Et.useContext(Ct)?.mounted??0)>0,f=rn(),u=an(),g=Et.useCallback(p=>f?.setViewport(p),[f]),m=Et.useCallback(p=>{if(!i||!(p.metaKey||p.ctrlKey)||p.altKey)return;let v=p.target;if(v instanceof Element&&v.closest('input, textarea, select, [role="dialog"]'))return;let y=fh(p.key,i.getZoom());y!==null&&(p.preventDefault(),i.setZoom(y));},[i]);return jsxRuntime.jsx("div",{ref:g,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:m,...d?{"data-review-pane":a?"open":"closed"}:{},...l?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${u}px`,...d?{"--docx-review-gutter":`${s.inlineEnd}px`,"--docx-review-gutter-start":`${s.inlineStart}px`,"--docx-review-strip":`${2*wr}px`}:{}},children:jsxRuntime.jsx(vn.Provider,{value:true,children:jsxRuntime.jsx(Pu.Provider,{value:true,children:o})})})}var Mw=editor.LOADING_SNAPSHOT;function bh({ref:e,editorRef:t}){Et.useImperativeHandle(e,()=>({load:o=>t.current?.load(o),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(o,n)=>t.current?.exec(o,n)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??Mw}),[t]);}function Mr(e,t,o,n){let r=Ye(),i=Et.useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},Et.useEffect(()=>{let a=t.current;if(!e||!a)return;let s=d=>a.contains(d),l=editor.listenForPopupEscape({popup:a,contains:s,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current.viewport],skip:d=>i.current.skip?.(d)===true,close:d=>i.current.close(d)}),c=editor.listenForPopupFocusLeave({popup:a,contains:s,close:()=>i.current.close(false)});return ()=>{l(),c();}},[e,t]);}var Hw=e=>e.editingMode??"editing",wu='[role="menuitemradio"]:not([disabled])',Aw=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),Ow=e=>e.isLoading||e.isOpening===true,Ha=[{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"}],Bw=Object.freeze(Ha.map(()=>null));function Zw(e){return e?Ha.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):Bw}var qw="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function Kl({className:e,hidden:t}){let o=H(),n=B(Hw),r=B(Ow),i=Q(),{t:a}=N(),[s,l]=Et.useState(false),c=Et.useRef(null),d=Et.useRef(null),f=Et.useRef(null);Et.useEffect(()=>{if(!s)return;let b=f.current?.querySelectorAll(wu);(f.current?.querySelector(`${wu}[aria-checked="true"]`)??b?.[0]??void 0)?.focus();},[s]);let u=Et.useCallback(b=>{let h=[...f.current?.querySelectorAll(wu)??[]],C=h.indexOf(document.activeElement),T=S=>{b.preventDefault(),h[(S+h.length)%h.length]?.focus();};b.key==="ArrowDown"?T(C+1):b.key==="ArrowUp"?T(C-1):b.key==="Home"?T(0):b.key==="End"&&T(h.length-1);},[]);Et.useEffect(()=>{if(!s)return;let b=h=>{let C=c.current;C&&h.target instanceof Node&&C.contains(h.target)||l(false);};return document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("mousedown",b,true);}},[s]),Mr(s,c,b=>{l(false),b&&d.current?.focus();});let g=Et.useCallback(b=>{l(false),editor.runToolbarCommand(o,"review.editingMode",b),o?.focus();},[o]),m=editor.toolbarCommandState(o,"review.editingMode"),p=i18n.localizeDisabledReason(m.disabledReason,a),v=B(()=>Zw(o),Aw),y=Et.useMemo(()=>Ha.find(b=>b.mode===n)??Ha[0],[n]);if(t)return null;let x=ee("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":n,"aria-haspopup":"menu","aria-expanded":s,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:r||!m.enabled,...p?{title:p}:{},onMouseDown:Z,onClick:()=>l(b=>!b),children:[Mu(y.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(y.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxRuntime.jsx("div",{ref:f,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Ha.map((b,h)=>{let C=i18n.localizeDisabledReason(v[h]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":b.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${b.mode}`,disabled:C!==null,...C?{title:C}:{},onMouseDown:Z,onClick:()=>g(b.mode),children:[Mu(b.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(b.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(b.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:b.mode===n?Mu(qw):null})]},b.mode)})}):null]})}Kl.docxSlot="review.editingMode";function Mu(e){return jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})})}var Ch=[],zw=()=>{};function Aa(){let e=H(),t=Et.useCallback(o=>{if(!e)return zw;let n=$r(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return Et.useSyncExternalStore(t,()=>e?.getReviewAuthors()??Ch,()=>Ch)}var Yw=e=>e.hiddenReviewAuthors??[];function zl({className:e,hidden:t,icon:o}){let n=H(),r=Aa(),i=B(Yw),a=new Set(i),s=r.every(h=>!a.has(h.author)),[l,c]=Et.useState(false),d=Et.useRef(null),f=Et.useRef(null),u=Et.useRef(null),g=Q(),{t:m}=N();Et.useEffect(()=>{if(!l)return;u.current?.querySelector('[role="menuitemcheckbox"]')?.focus();let h=C=>{d.current?.contains(C.target)||c(false);};return document.addEventListener("mousedown",h,true),()=>{document.removeEventListener("mousedown",h,true);}},[l]),Mr(l,d,h=>{c(false),h&&f.current?.focus();});let p=Et.useCallback(h=>{let C=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],T=C.indexOf(document.activeElement),S=P=>{h.preventDefault(),C[(P+C.length)%C.length]?.focus();};h.key==="ArrowDown"?S(T+1):h.key==="ArrowUp"?S(T-1):h.key==="Home"?S(0):h.key==="End"?S(C.length-1):h.key==="Tab"&&c(false);},[]);if(t)return null;let v=ee("review.authors"),y=editor.toolbarCommandState(n,"review.authors"),x=i18n.localizeDisabledReason(y.disabledReason,m),b=g(v?.labelKey??"reviewers.label");return jsxRuntime.jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[jsxRuntime.jsxs("button",{ref:f,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":l,"aria-label":b,disabled:!y.enabled,title:x??b,onMouseDown:Z,onClick:()=>c(h=>!h),children:[o??ae(v?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:b}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":b,"data-testid":"reviewers-menu",onKeyDown:p,children:[jsxRuntime.jsx(Th,{checked:s,label:m("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!s)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(h=>jsxRuntime.jsx(Th,{checked:!a.has(h.author),label:h.author||"\u2014",testId:`reviewer-${h.slot}`,color:h.color,onChoose:()=>n?.setReviewAuthorVisible(h.author,a.has(h.author))},h.author))]}):null]})}zl.docxSlot="review.authors";function Th(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:Z,onClick:e.onChoose,children:[jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var Ph=Et.createContext(null);function Sh({children:e}){let t=Pr(),[o,n]=Et.useState(false),r=Et.useRef(null),i=Et.useMemo(()=>({open:s=>{if(t){t.open("paragraph",s);return}r.current=s??document.activeElement,n(true);}}),[t]),a=Et.useCallback(()=>{n(false);let s=r.current;r.current=null,s instanceof HTMLElement&&s.isConnected&&s.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(Ph.Provider,{value:i,children:[e,jsxRuntime.jsx(xo,{open:o,onClose:a})]})}function Eh(){return Et.useContext(Ph)}var ku=["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"],Du=Et.createContext({close:()=>{}});function Rr(){return Et.useContext(Du).close}function g1(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function kh({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__more-control",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function Dh({slot:e}){let t=Q(),o=Do(),{close:n}=Et.useContext(Du),{execute:r,isActive:i,isEnabled:a,disabledReason:s,value:l}=se(e),c=ee(e),d=editor.chromeSlotIsToggle(e),f=o(t(c?.labelKey??e));return jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...s?{title:s}:{},...d?{"aria-pressed":i}:{},...i?{"data-active":""}:{},...l!==null?{"data-value":l}:{},onMouseDown:Z,onClick:u=>{r(),n(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:ae(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:f})]})}function Ih({sections:e,className:t}){let o=Q(),[n,r]=Et.useState(false),i=Et.useRef(null),a=Et.useRef(null),s=Et.useRef(null),l=Et.useRef(false),c=Et.useId(),d=Ye(),f=Et.useRef(d);f.current=d;let u=o("formattingBar.more"),g=Et.useCallback(x=>{r(false),x&&a.current?.focus();},[]),m=Et.useMemo(()=>({close:g}),[g]);Et.useEffect(()=>{if(!n)return;let x=S=>{let P=S.target;P instanceof Node&&i.current?.contains(P)||r(false);},b=i.current,h=S=>i.current?.contains(S)===true||s.current?.contains(S)===true,C=b?editor.listenForPopupEscape({popup:b,contains:h,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[f.current],skip:()=>editor.hasOpenNestedPopup(s.current),close:g}):void 0,T=b?editor.listenForPopupFocusLeave({popup:b,contains:h,close:()=>r(false)}):void 0;return document.addEventListener("mousedown",x,true),()=>{document.removeEventListener("mousedown",x,true),C?.(),T?.();}},[n,g]);let[p,v]=Et.useState(null);Et.useLayoutEffect(()=>{if(!n){v(null);return}let x=()=>{let h=i.current,C=s.current,T=a.current,S=h?.ownerDocument.defaultView;if(!h||!C||!T||!S)return;let P=T.getBoundingClientRect(),k=editor.toolbarPanelPlacement({triggerLeft:P.left,triggerRight:P.right,panelWidth:C.offsetWidth,viewportWidth:S.innerWidth}),w=k.left-h.getBoundingClientRect().left;v(E=>E&&E.left===w&&E.maxWidth===k.maxWidth&&E.anchor===k.anchor?E:{...k,left:w});};x();let b=i.current?.ownerDocument.defaultView;return b?.addEventListener("resize",x),()=>b?.removeEventListener("resize",x)},[n]),Et.useEffect(()=>{if(!n||!l.current)return;l.current=false;let x=s.current;x&&g1(x);},[n]);let y=x=>{x.key!=="Escape"||x.defaultPrevented||(x.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[aa]:"",children:[jsxRuntime.jsx("button",{ref:a,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?c:void 0,"aria-label":u,title:u,...n?{"data-active":""}:{},onMouseDown:Z,onClick:()=>r(x=>!x),onKeyDown:x=>{x.key==="ArrowDown"&&(x.preventDefault(),l.current=true,r(true));},children:ae(ku)}),n?jsxRuntime.jsx(Du.Provider,{value:m,children:jsxRuntime.jsx("div",{ref:s,id:c,role:"dialog","aria-label":u,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",...p?{"data-anchor":p.anchor}:{},style:p?{left:p.left,right:"auto",maxInlineSize:p.maxWidth}:void 0,onKeyDown:y,children:e.map(x=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":x.label??o(x.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:x.label??o(x.labelKey)}),x.children]},x.id))})}):null]})}function b1(e){if(!Et.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function Nh(e,t,o,n){let r=new Map,i=new Map,a=new Map,s=[];for(let l of Et.Children.toArray(e)){if(b1(l)){a.delete(l.props.id),a.set(l.props.id,l.props);continue}let c=t(l);if(c&&o(c))r.set(c,l);else if(c&&n(c))i.set(c,l);else {if(c&&Et.isValidElement(l)&&l.props.hidden===true)continue;s.push(l);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:s}}function Ul(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function Iu(e){let t=Q();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":Ul(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}Iu.docxToolbarGroup=true;function Ba(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}Ba.docxToolbarSlot=true;var _u=Et.createContext("bar");function Lh(){return Et.useContext(_u)}var Vl="review.addComment";function T1({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Et.useContext(Ct),a=Q(),{isEnabled:s,reason:l}=Gi(a),c=Rr();if(t||(i?.mounted??0)===0)return null;let d=ee(Vl),f=a(d?.labelKey??Vl),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Vl,disabled:!s,...s?{}:{"data-disabled":""},"aria-label":f,title:l??f,onMouseDown:Z,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsxRuntime.jsx(G,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??ae(d?.paths)})}var Nu=Object.assign(T1,{docxSlot:Vl});var Ah=new Set;function Gl(e){!mt()||Ah.has(e)||(Ah.add(e),console.warn(`[docx-editor] ${e}`));}function Oh(e,t,o){Gl(`Toolbar.Group "${e}" has after="${t}", but no group has that id. The group is placed after every other group. Known ids: ${o.join(", ")}.`);}function Bh(e,t){Gl(`Toolbar.Group "${e}" is a built-in group, so its ${t} is ignored. A built-in group keeps its own label and place in the bar.`);}function Zh(e){Gl(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function qh(e,t){Gl(t?`Toolbar slot "${e}" is not part of the preset arrangement, so its content is appended after the groups. Put it in a Toolbar.Group to give it a place.`:`"${e}" is not a toolbar slot id. Its content is appended after the groups. Use a ChromeSlotId such as "text.bold".`);}var Fu=[{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 Yl({className:e,hidden:t,asChild:o,children:n}){let{t:r}=N(),i=Q(),{execute:a,value:s,isEnabled:l,disabledReason:c}=Ta("image.wrap"),[d,f]=Et.useState(false),u=Et.useRef(null),g=Et.useRef(null),m=Et.useRef(null),p=Et.useId(),v=Et.useMemo(()=>Fu.find(T=>T.value===s)??Fu[0],[s]),y=ee("image.wrap"),x=i(y?.labelKey??"formattingBar.imageWrap");Et.useEffect(()=>{if(!d)return;let T=P=>{let k=u.current;k&&P.target instanceof Node&&k.contains(P.target)||f(false);},S=P=>{P.key==="Escape"&&(P.preventDefault(),f(false),g.current?.focus());};return document.addEventListener("mousedown",T,true),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",T,true),document.removeEventListener("keydown",S);}},[d]);let b=Et.useCallback(T=>{f(false),a(T);},[a]);if(t)return null;let h=r("imageWrap.tooltipPrefix",{label:r(v.labelKey)}),C={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!l,...l?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?p:void 0,"aria-label":x,title:c??h,onMouseDown:Z,onClick:()=>f(T=>!T)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(G,{...C,children:n}):jsxRuntime.jsx("button",{...C,children:n??ae(y?.paths)}),d?jsxRuntime.jsx("div",{ref:m,id:p,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:T=>T.stopPropagation(),children:Fu.map(T=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":s===T.value,...s===T.value?{"data-active":""}:{},onMouseDown:Z,onClick:()=>b(T.value),children:r(T.labelKey)},T.value))}):null]})}Yl.docxSlot="image.wrap";var Za=Object.assign(Yl,{docxSlot:"image.wrap"});var kr="table.insert";function L1({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=H(),{isEnabled:a,disabledReason:s}=se(kr),l=Q(),[c,d]=Et.useState(false),f=Et.useRef(null),u=Et.useRef(null),g=Et.useRef(null),m=Et.useId(),p=Rr();Et.useEffect(()=>{let C=f.current?.ownerDocument;if(!c||!C)return;let T=S=>{let P=f.current;P&&S.target instanceof Node&&P.contains(S.target)||d(false);};return C.addEventListener("mousedown",T,true),()=>C.removeEventListener("mousedown",T,true)},[c]),Et.useEffect(()=>{c&&f.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let v=c&&a;Et.useLayoutEffect(()=>{let C=g.current,T=f.current,S=T?.ownerDocument.defaultView;if(!v||!C||!T||!S||T.closest(".docx-toolbar__more-panel"))return;let P=T.getBoundingClientRect(),k=editor.toolbarPopupLeft({anchorLeft:P.left,popupWidth:C.offsetWidth,viewportWidth:S.innerWidth});C.style.left=`${k-P.left}px`;},[v]);let y=Et.useCallback(()=>{d(false),p(false);},[p]);if(t)return null;let x=ee(kr),b=l(x?.labelKey??kr),h={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":kr,disabled:!a,...a?{}:{"data-disabled":""},...v?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":v,"aria-controls":v?m:void 0,"aria-label":b,title:s??b,onMouseDown:Z,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:C=>{C.key==="ArrowDown"&&(C.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__table-insert",children:[n?jsxRuntime.jsx(G,{...h,children:r}):jsxRuntime.jsx("button",{...h,children:o??r??ae(x?.paths)}),v?jsxRuntime.jsx("div",{ref:g,id:m,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:C=>{let T=C.relatedTarget;T instanceof Node&&!f.current?.contains(T)&&d(false);},onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(ol,{slot:kr,label:l("toolbar.insertTable"),onInserted:y})}):null]})}var Au=Object.assign(L1,{docxSlot:kr});function Ge(e){return Object.assign(o=>jsxRuntime.jsx(sn,{slotId:e,...o}),{docxSlot:e})}var Wh=Ge("history.undo"),zh=Ge("history.redo"),$h=Ge("text.bold"),Uh=Ge("text.italic"),Vh=Ge("text.underline"),Gh=Ge("text.strike"),jh=Ge("format.clear"),Yh=Ge("script.super"),Xh=Ge("script.sub"),Jh=Ge("alignment.left"),Qh=Ge("alignment.center"),e0=Ge("alignment.right"),t0=Ge("alignment.justify"),o0=Ge("direction.ltr"),n0=Ge("direction.rtl"),r0=Ge("list.bullet"),a0=Ge("list.numbered"),i0=Ge("list.outdent"),l0=Ge("list.indent");var s0=Ge("review.comments");function B1({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=H(),{openAtCaret:a}=Fc(),s=editor.chromeProbeForSlot("text.link"),l=i&&s?i.can(s):null,c=l?.ok===true,{t:d}=N(),f=i18n.localizeDisabledReason(l&&!l.ok?l.reason:null,d),u=Q();if(t)return null;let g=ee("text.link"),m=u(g?.labelKey??"text.link"),p={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!c,...c?{}:{"data-disabled":""},"aria-label":m,title:f??m,onMouseDown:Z,onClick:()=>a()};return n?jsxRuntime.jsx(G,{...p,children:r}):jsxRuntime.jsx("button",{...p,children:o??r??ae(g?.paths)})}var Ou=Object.assign(B1,{docxSlot:"text.link"});function Z1({className:e,hidden:t}){let o=H(),{onSave:n}=Et.useContext(ln),r=Q();if(t)return null;let i=ee("file.save"),a=r(i?.labelKey??"file.save"),s=!o||!n;return jsxRuntime.jsx("button",{type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"file.save",disabled:s,...s?{"data-disabled":""}:{},"aria-label":a,title:a,onMouseDown:Z,onClick:()=>n?.(),children:ae(i?.paths)})}var Bu=Object.assign(Z1,{docxSlot:"file.save"});function En({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var W1=e=>({zoom:e.zoom,mode:e.zoomMode}),z1=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,d0={type:"fixed"};function Zu(){let e=H(),{zoom:t,mode:o}=B(W1,z1),n=Et.useCallback(i=>{e?.setZoom(i);},[e]),r=Et.useCallback(i=>{e?.setZoomMode(i);},[e]);return Et.useMemo(()=>{let i=o??d0,a=Fa(t,"out"),s=Fa(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(d0),n(1);},zoomIn:()=>s!==null&&n(s),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&s!==null,canZoomOut:!!e&&a!==null,levels:Bl}},[e,t,o,n,r])}var Wa=2,za=3276,Ka=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],G1=e=>e.formatting?.fontSizePt??null;function m0(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function f0(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function h0(e){return jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:Z,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:Z,onClick:e.onIncrease,children:"+"})]})}function j1(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<Wa||n>za?null:n}function Y1({className:e,hidden:t}){let o=H(),n=B(G1),{isEnabled:r,disabledReason:i}=se("font.size"),a=Q(),[s,l]=Et.useState(false),[c,d]=Et.useState(null),f=Et.useRef(null);go(f,s,()=>l(false));let u=Et.useRef(null),g=Et.useId(),m=Et.useCallback(T=>{if(!o)return;let S=editor.commandForSlotValue("font.size",T);S&&o.can(S).ok&&o.exec(S);},[o]),p=Et.useCallback(T=>{m(Math.min(za,Math.max(Wa,Math.round(T*2))));},[m]),v=Et.useCallback(T=>{l(false),d(null),u.current?.blur(),T&&o?.focus();},[o]);if(Et.useEffect(()=>{if(!s)return;let T=S=>{let P=f.current;P&&S.target instanceof Node&&P.contains(S.target)||(l(false),d(null));};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[s]),t)return null;let y=r&&n!==null,x=n===null?"\u2014":String(Math.round(n*2)/2),b=c??x,h=n===null?null:Math.round(n*2)/2,C=()=>{if(c===null)return;let T=j1(c);T!==null&&m(T);};return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(h0,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsxRuntime.jsx("input",{ref:u,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:b,disabled:!r,role:"combobox","aria-expanded":s,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":s?g:void 0,autoComplete:"off",onChange:T=>{d(T.target.value),l(true);},onFocus:T=>{T.target.select(),l(true);},onClick:()=>l(true),onKeyDown:T=>{T.key==="Enter"?(T.preventDefault(),C(),v(true)):T.key==="Escape"?(T.preventDefault(),v(true)):(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),l(true),n!==null&&p(T.key==="ArrowDown"?f0(n,Ka,Wa/2):m0(n,Ka,za/2)));},onBlur:()=>{C(),d(null);}}),canDecrease:y&&Math.round(n*2)>Wa,canIncrease:y&&Math.round(n*2)<za,onDecrease:()=>p(f0(n??0,Ka,Wa/2)),onIncrease:()=>p(m0(n??0,Ka,za/2))}),s&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:Ka.map(T=>{let S=h===T;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":S,...S?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>{p(T),v(true);},children:T},T)})}):null]})}var Wu=Object.assign(Y1,{docxSlot:"font.size"});function X1({className:e,hidden:t}){let o=H(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:s,zoomIn:l,zoomOut:c,canZoomIn:d,canZoomOut:f,levels:u}=Zu(),g=Q(),[m,p]=Et.useState(false),v=Et.useRef(null);go(v,m,()=>p(false)),Et.useEffect(()=>{if(!m)return;let T=S=>{let P=v.current;P&&S.target instanceof Node&&P.contains(S.target)||p(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[m]);let y=Et.useCallback(T=>{v.current?.querySelector("[aria-haspopup]")?.focus(),p(false),a(T);},[a]),x=Et.useCallback(T=>{v.current?.querySelector("[aria-haspopup]")?.focus(),p(false),s(T==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[s]);if(t)return null;let b=`${Math.round(n*100)}%`,h=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),C=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:v,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(h0,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle:jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!o,"aria-haspopup":"listbox","aria-expanded":m,"aria-label":`${g("zoom.zoomLevel")}: ${b}`,onMouseDown:Z,onClick:()=>p(T=>!T),children:[b,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:f,canIncrease:d,onDecrease:c,onIncrease:l}),m?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(T=>{let S=!r&&Math.abs(T-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":S,...S?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>y(T),children:`${Math.round(T*100)}%`},T)})]}):null]})}var zu=Object.assign(X1,{docxSlot:"zoom.level"});function wn(e,t,o,n=false){let r=Ye(),i=Et.useRef(r);i.current=r,Et.useEffect(()=>{e&&n&&t(false);},[e,n,t]),Et.useEffect(()=>{let a=o.current;if(!e||n||!a)return;let s=a.ownerDocument,l=u=>a.contains(u),c=u=>{u.composedPath().includes(a)||t(false);},d=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:u=>{t(false),u&&a.querySelector("[aria-haspopup]")?.focus();}}),f=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)});return s.addEventListener("mousedown",c),()=>{s.removeEventListener("mousedown",c),d(),f();}},[e,n,t,o]);}var nM=[1,1.15,1.5,2,2.5,3],x0=10,C0=0,rM=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),aM=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function iM({className:e,hidden:t}){let o=H(),n=B(rM,aM),{isEnabled:r,disabledReason:i}=se("list.lineSpacing"),a=se("paragraph.dialog"),s=Eh(),l=Q(),[c,d]=Et.useState(false),f=Et.useRef(null),u=Et.useRef(null);wn(c,d,f,t);let g=Et.useCallback(b=>{if(d(false),!o)return;let h=editor.commandForSlotValue("list.lineSpacing",b);h&&o.can(h).ok&&o.exec(h);},[o]),m=Et.useCallback((b,h)=>{if(d(false),!o)return;let C={type:"setParagraphSpacing",[b]:h};o.can(C).ok&&o.exec(C);},[o]);if(t)return null;let p=ee("list.lineSpacing"),v=(n.spaceBeforePt??0)>0,y=(n.spaceAfterPt??0)>0,x=n.lineSpacing?.rule==="multiple"?n.lineSpacing?.value??null:null;return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:u,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":c,"aria-label":l("lineSpacing.label"),title:i??l("lineSpacing.label"),onMouseDown:Z,onClick:()=>d(b=>!b),children:[ae(p?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),c&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[nM.map(b=>{let h=x===b;return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>g(b),children:Number.isInteger(b*10)?b.toFixed(1):b.toFixed(2)},b)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:Z,onClick:()=>{d(false),s?.open(u.current);},children:l("lineSpacing.options")}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>m("beforePt",v?C0:x0),children:l(v?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>m("afterPt",y?C0:x0),children:l(y?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Uu=Object.assign(iM,{docxSlot:"list.lineSpacing"});var cM=["alignment.left","alignment.center","alignment.right","alignment.justify"];function dM({className:e,hidden:t}){let o=se("alignment.left"),n=se("alignment.center"),r=se("alignment.right"),i=se("alignment.justify"),a=Q(),[s,l]=Et.useState(false),c=Et.useRef(null);if(wn(s,l,c,t),t)return null;let d=[o,n,r,i],f=cM.map((p,v)=>({slot:p,control:ee(p),state:d[v]})),u=f.find(p=>p.state.isActive)??f[0],g=f.some(p=>p.state.isEnabled),m=a(u.control?.labelKey??u.slot);return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!g,...g?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":s,"aria-label":m,title:g?m:u.state.disabledReason??m,onMouseDown:Z,onClick:()=>l(p=>!p),children:[ae(u.control?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:f.map(p=>{let v=a(p.control?.labelKey??p.slot);return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":p.slot,disabled:!p.state.isEnabled,...p.state.isActive?{"data-active":""}:{},"aria-pressed":p.state.isActive,"aria-label":v,title:p.state.disabledReason??v,onMouseDown:Z,onClick:()=>{p.state.execute(),l(false);},children:ae(p.control?.paths)},p.slot)})}):null]})}var Jl=Object.assign(dM,{docxSlot:"alignment"});function Gu(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:s,className:l,children:c}=e,d=Lh(),f=Rr();if(d==="panel"&&!s)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${l?` ${l}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>Z(g),onClick:g=>{a?.(),f(g.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]});let u={type:"button",className:`docx-toolbar__button${l?` ${l}`:""}`,disabled:r,...n?{"data-active":""}:{},...r?{"data-disabled":""}:{},...n!==void 0?{"aria-pressed":n}:{},"aria-label":t,title:r?i??t:t,onMouseDown:g=>Z(g),onClick:r?void 0:a};return s?jsxRuntime.jsx(G,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var bM=Object.freeze([]),vM=e=>e.formatting?.fontFamily??null,yM=e=>e;function ts(){let e=H(),t=B(vM),o=B(yM),n=Et.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():bM,[e,o]),{isEnabled:r}=se("font.family"),i=Et.useCallback(a=>{if(!e)return;let s=editor.commandForSlotValue("font.family",a);s&&e.can(s).ok&&e.exec(s);},[e]);return Et.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var E0=Et.createContext(null);function Yu(){return Et.useContext(E0)}function Xu({asChild:e,className:t,children:o}){let n=Yu(),r=Q();if(!n)return null;let i=r(ee("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},s=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(G,{...a,children:s}):jsxRuntime.jsx("button",{type:"button",...a,children:s})}Xu.docxToolbarPart=true;var xM=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"]]),CM=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function w0({asChild:e,className:t,children:o}){let n=Yu(),r=Q(),[i,a]=Et.useState("");if(Et.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let s={role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},l;return o!==void 0?l=o:l=CM.map(d=>({...d,fonts:n.options.filter(f=>f.toLowerCase().includes(i.toLowerCase())&&(xM.get(f.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,f)=>jsxRuntime.jsxs("div",{role:"group",children:[f>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(M0,{value:u},u))]},d.category)),e?jsxRuntime.jsx(G,{...s,children:l}):o!==void 0?jsxRuntime.jsx("div",{...s,children:l}):jsxRuntime.jsxs("div",{className:s.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":r("font.search"),placeholder:r("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:l})]})}function M0({value:e,asChild:t,className:o,children:n}){let r=H(),i=Yu();if(!i)return null;let a=i.value===e,s={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},l=n??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(G,{...s,children:l}):jsxRuntime.jsxs("button",{type:"button",...s,children:[l,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function TM({hidden:e,asChild:t,className:o,children:n}){let r=ts(),[i,a]=Et.useState(false),s=Et.useRef(null);go(s,i,()=>a(false)),Et.useEffect(()=>{if(!i)return;let f=u=>{let g=s.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let l=Et.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xu,{}),jsxRuntime.jsx(w0,{})]});return jsxRuntime.jsx(E0.Provider,{value:l,children:t?jsxRuntime.jsx(G,{...c,ref:s,children:d}):jsxRuntime.jsx("div",{ref:s,...c,children:d})})}var Ju=Object.assign(TM,{docxSlot:"font.family",Trigger:Xu,Content:w0,Item:M0});var SM={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},EM=new Set(["Title","Heading1","Heading2","Heading3"]),wM={Subtitle:"666666"},MM="#4a6c8c";function R0(e){let t=SM[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??EM.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??wM[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=MM),n}var RM=/^heading ([1-9])$/;function Qu(e,t){let o=e||t,n=RM.exec(o);return n?`Heading ${n[1]}`:o}function k0(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Qu(t.name,t.styleId),priority:99}))}function HM(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 AM=Object.freeze([]),OM=e=>e.formatting?.styleId??null,BM=e=>e;function os(){let e=H(),t=B(OM),o=B(BM),n=Et.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:Qu(a.name,a.styleId),preview:a.preview})):AM,[e,o]),{isEnabled:r}=se("styles.style"),i=Et.useCallback(a=>{if(!e)return;let s=editor.commandForSlotValue("styles.style",a);s&&e.can(s).ok&&e.exec(s);},[e]);return Et.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var D0=Et.createContext(null);function tp(){return Et.useContext(D0)}function op({asChild:e,className:t,children:o}){let n=tp(),r=Q();if(!n)return null;let i=ee("styles.style"),a=r(i?.labelKey??"styles.style"),s={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,title:a},l=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:l?.name??n.value}));return e?jsxRuntime.jsx(G,{...s,children:c}):jsxRuntime.jsx("button",{type:"button",...s,children:c})}op.docxToolbarPart=true;function I0({asChild:e,className:t,children:o}){let n=Q(),r=tp();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(s=>jsxRuntime.jsx(_0,{value:s.styleId},s.styleId));return e?jsxRuntime.jsx(G,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function _0({value:e,asChild:t,className:o,children:n}){let r=H(),i=tp();if(!i)return null;let a=i.value===e,s=i.options.find(d=>d.styleId===e),l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsxRuntime.jsx("span",{style:s?HM(s.preview):void 0,children:s?.name??e});return t?jsxRuntime.jsx(G,{...l,children:c}):jsxRuntime.jsxs("button",{type:"button",...l,children:[c,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function ZM({hidden:e,asChild:t,className:o,children:n}){let r=os(),[i,a]=Et.useState(false),s=Et.useRef(null);go(s,i,()=>a(false)),Et.useEffect(()=>{if(!i)return;let f=u=>{let g=s.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let l=Et.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(op,{}),jsxRuntime.jsx(I0,{})]});return jsxRuntime.jsx(D0.Provider,{value:l,children:t?jsxRuntime.jsx(G,{...c,ref:s,children:d}):jsxRuntime.jsx("div",{ref:s,...c,children:d})})}var np=Object.assign(ZM,{docxSlot:"styles.style",Trigger:op,Content:I0,Item:_0});function L0(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:s,children:l})=>{let{isEnabled:c,disabledReason:d}=se(o),f=eo(),u=t==="showAll"?f.showAll:f.formFill,g=Q();if(i)return null;let m=ee(o),p=g(m?.labelKey??e),v={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":p,title:d??p,onMouseDown:Z,onClick:()=>{t==="showAll"?f.toggleShowAll():f.toggleFormFill();}};return s?jsxRuntime.jsx(G,{...v,children:l}):jsxRuntime.jsx("button",{...v,children:a??l??ae(m?.paths)})},{docxSlot:o})}function KM({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=gt.inspector,{isEnabled:a,disabledReason:s}=se(i),{inspectorOpen:l,openInspector:c}=eo(),d=Q();if(t)return null;let f=ee(i),u=d(f?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":gt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...l?{"data-active":""}:{},"aria-pressed":l,"aria-label":u,title:s??u,onMouseDown:Z,onClick:()=>c()};return n?jsxRuntime.jsx(G,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??ae(f?.paths)})}function WM({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:s}=eo(),l=Q();if(t)return null;let c=gt.remove,d=ee(c),f=l(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":gt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":f,title:a??f,onMouseDown:Z,onClick:()=>{s();}};return n?jsxRuntime.jsx(G,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??ae(d?.paths)})}var ns=L0(gt.showAll,"showAll"),rs=L0(gt.formFill,"formFill"),as=Object.assign(WM,{docxSlot:gt.remove}),is=Object.assign(KM,{docxSlot:gt.inspector}),F0={[gt.showAll]:ns,[gt.formFill]:rs,[gt.inspector]:is,[gt.remove]:as};function rp(e,t){let o=H(),n=Et.useRef(t);n.current=t,Et.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var YM=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],ip=Et.createContext(null);function K0(){let e=Et.useContext(ip);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function JM(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.columnIndex}`:"",a=t.selection,s=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.to.paraId:""}|${t.selectionCollapsed}`:"",l=e?.getTableCellSelection()??null,c=l?`${l.tableId}|${l.rows.from}-${l.rows.to}|${l.columns.from}-${l.columns.to}|${l.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:s,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function QM(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function eR(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Z0={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function tR(e,t){let o={};for(let n of YM){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function lp({children:e}){let t=H(),[o,n]=Et.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=Et.useState(Z0);Et.useEffect(()=>(()=>{}),[]);let a=B(Et.useCallback(u=>({table:u.table,editable:u.editable,editingMode:u.editingMode??"editing",headParagraphId:u.selection?.to&&"paraId"in u.selection.to?u.selection.to.paraId:u.selection?.from&&"paraId"in u.selection.from?u.selection.from.paraId:""}),[]),QM,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),s=Et.useCallback(()=>{if(!t){i(Z0);return}let u=JM(t,t.snapshot());i(g=>eR(g,u)?g:u);},[t]);Et.useEffect(()=>{s();},[s,a]),rp("selectionChange",Et.useCallback(()=>{s();},[s]));let l=r.tableKey!=="",c=Et.useMemo(()=>t?tR(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=Et.useCallback((u,g)=>{if(!t)return;let{result:m,nextDraft:p}=editor.runTableChromeCommand(t,u,g,o);m.ok&&p&&n(p);},[t,o]),f=Et.useMemo(()=>({visible:l,draft:o,setDraft:n,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[l,o,c,d]);return jsxRuntime.jsx(ip.Provider,{value:f,children:e})}function oR(){let e=Et.useContext(ip);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function ss(e){let t=oR(),o=t.slotState(e);return Et.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function cs(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function ds({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=N(),r=i18n.localizeDisabledReason(t,n),i=Et.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:Z,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var lR='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function z0(e,t,o,n){Et.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(lR)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(f=>f.hasAttribute("data-selected")||f.hasAttribute("data-active"))??c[0])?.focus();});let l=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),Ot(d,document.activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Ot(d,document.activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),Bt(d,"first");return}if(c.key==="End"){c.preventDefault(),Bt(d,"last");return}if(c.key==="Enter"||c.key===" "){let f=document.activeElement;f instanceof HTMLElement&&d.includes(f)&&(c.preventDefault(),f.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function $0(e,t,o,n){Et.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(l=>l.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let s=l=>{if(l.key==="Escape"){l.preventDefault(),t(false),i?.focus();return}if(l.key==="Enter"||l.key===" "){let c=document.activeElement,d=a();c instanceof HTMLElement&&d.includes(c)&&(l.preventDefault(),c.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function Y0(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function fR(e){return ae(editor.tableChromeIconPaths(e))}function X0(){return Et.createContext(null)}function Co(e){let t=Et.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function cp(e,t,o){let n=X0();function r({hidden:s,asChild:l,className:c,children:d}){let{visible:f,enabled:u,disabledReason:g,draft:m,apply:p}=ss(e),[v,y]=Et.useState(false),x=Et.useRef(null),b=Et.useRef(null);wn(v,y,x,s||!f);let h=Et.useMemo(()=>({open:v,setOpen:y,enabled:u,disabledReason:g,apply:p,draft:m,triggerRef:b}),[v,u,g,p,m]);if(s||!f)return null;let C={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},T=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:h,children:l?jsxRuntime.jsx(G,{...C,ref:x,children:T}):jsxRuntime.jsx("div",{ref:x,...C,children:T})})}function i({asChild:s,className:l,children:c}){let{open:d,setOpen:f,enabled:u,disabledReason:g,triggerRef:m}=Co(n),p=Q(),v=ee(e),y=p(v?.labelKey??o),{shared:x,reasonNode:b}=ds({enabled:u,disabledReason:g,ariaLabel:y}),h={...x,ref:m,className:`docx-toolbar__button docx-table-chrome__trigger${l?` ${l}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>f(!d):void 0,...s?{tabIndex:u?0:-1,role:"button",onKeyDown:Y0(u,d,f)}:{}},C=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ae(v?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return s?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(G,{...h,children:C}),b]}):jsxRuntime.jsxs("button",{...h,children:[C,b]})}i.docxToolbarPart=true;function a({asChild:s,className:l,children:c}){let{open:d,setOpen:f,enabled:u,triggerRef:g}=Co(n),m=Q(),p=Et.useRef(null);if(z0(d&&u,f,p,g),!d||!u)return null;let v=ee(e),y=m(v?.labelKey??o),x={ref:p,role:"menu","aria-label":y,className:`docx-table-chrome__panel${l?` ${l}`:""}`,onMouseDown:Z};return s?jsxRuntime.jsx(G,{...x,children:c}):jsxRuntime.jsx("div",{...x,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var Va=cp("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function J0({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Co(Va.Ctx),s=Q(),l=editor.TABLE_BORDER_TARGET_OPTIONS.find(u=>u.value===e);if(!l)return null;let c=l.value==="none"?false:l.value===a.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":c,"data-value":l.value,className:`docx-table-chrome__target-btn${o?` ${o}`:""}`,...c?{"data-active":""}:{},"aria-label":s(l.labelKey),title:s(l.labelKey),onMouseDown:Z,onClick:()=>{i(false),r(l.value);}},f=n??fR(l.icon);return t?jsxRuntime.jsx(G,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function Q0(e){let{children:t}=e;return jsxRuntime.jsx(Va.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(J0,{value:o.value},o.value))})})}function gR(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Va.Trigger,{}),jsxRuntime.jsx(Q0,{})]});return jsxRuntime.jsx(Va.Root,{...e,children:o})}var Ja=Object.assign(gR,{docxSlot:"table.borderTarget",Trigger:Va.Trigger,Content:Q0,Item:J0}),Ga=cp("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function eb({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Co(Ga.Ctx),s=Q(),l=editor.TABLE_BORDER_STYLE_OPTIONS.find(u=>u.value===e);if(!l)return null;let c=l.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":c,...c?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(l.value);}},f=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${l.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:s(l.labelKey)})]});return t?jsxRuntime.jsx(G,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function tb(e){let{children:t}=e;return jsxRuntime.jsx(Ga.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(eb,{value:o.value},o.value))})}function hR(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ga.Trigger,{}),jsxRuntime.jsx(tb,{})]});return jsxRuntime.jsx(Ga.Root,{...e,children:t})}var Qa=Object.assign(hR,{docxSlot:"table.borderStyle",Trigger:Ga.Trigger,Content:tb,Item:eb}),ja=cp("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function ob({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Co(ja.Ctx),s=Q(),l=Number(e),c=editor.TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===l);if(!c)return null;let d=c.size===a.spec.size,f={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(c.size);}},u=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:s(c.labelKey)})]});return t?jsxRuntime.jsx(G,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}function nb(e){let{children:t}=e;return jsxRuntime.jsx(ja.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(ob,{value:String(o.size)},o.size))})}function bR(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ja.Trigger,{}),jsxRuntime.jsx(nb,{})]});return jsxRuntime.jsx(ja.Root,{...e,children:t})}var ei=Object.assign(bR,{docxSlot:"table.borderWidth",Trigger:ja.Trigger,Content:nb,Item:ob});function rb(e,t,o){let n=o?.defaultHex??"FF0000",r=X0();function i({hidden:d,asChild:f,className:u,children:g}){let{visible:m,enabled:p,disabledReason:v,draft:y,apply:x}=ss(e),[b,h]=Et.useState(false),[C,T]=Et.useState(n),S=Et.useRef(null),P=Et.useRef(null);wn(b,h,S,d||!m);let k=Et.useMemo(()=>({open:b,setOpen:h,enabled:p,disabledReason:v,apply:x,draft:y,triggerRef:P,lastHex:C,setLastHex:T}),[b,p,v,x,y,C]);if(d||!m)return null;let w={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},E=g??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(a,{}),jsxRuntime.jsx(s,{}),jsxRuntime.jsx(l,{clearFill:o?.clearFill??false})]});return jsxRuntime.jsx(r.Provider,{value:k,children:f?jsxRuntime.jsx(G,{...w,ref:S,children:E}):jsxRuntime.jsx("div",{ref:S,...w,children:E})})}function a({asChild:d,className:f,children:u}){let{enabled:g,disabledReason:m,apply:p,draft:v,lastHex:y}=Co(r),x=Q(),b=ee(e),h=x(b?.labelKey??t),{shared:C,reasonNode:T}=ds({enabled:g,disabledReason:m,ariaLabel:h}),S=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:y??n,P={...C,className:`docx-toolbar__button docx-toolbar__colorsplit-main${f?` ${f}`:""}`,onClick:g?()=>p({kind:"hex",value:S}):void 0},k=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ae(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${S.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(G,{...P,children:k}),T]}):jsxRuntime.jsxs("button",{...P,children:[k,T]})}a.docxToolbarPart=true;function s({asChild:d,className:f,children:u}){let{open:g,setOpen:m,enabled:p,disabledReason:v,triggerRef:y}=Co(r),x=Q(),b=ee(e),h=x(b?.labelKey??t),{shared:C,reasonNode:T}=ds({enabled:p,disabledReason:v,ariaLabel:h}),S={...C,ref:y,className:`docx-toolbar__colorsplit-caret${f?` ${f}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:p?()=>m(!g):void 0,...d?{tabIndex:p?0:-1,role:"button",onKeyDown:Y0(p,g,m)}:{}},P=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(G,{...S,children:P}),T]}):jsxRuntime.jsxs("button",{...S,children:[P,T]})}s.docxToolbarPart=true;function l({asChild:d,className:f,children:u,clearFill:g}){let{open:m,setOpen:p,enabled:v,apply:y,draft:x,triggerRef:b,lastHex:h,setLastHex:C}=Co(r),T=Q(),S=Et.useRef(null);if($0(m&&v,p,S,b),!m||!v)return null;let P=T(t),k=e==="table.borderColor"&&x.spec.color.kind==="hex"?x.spec.color.value:h??n,w={ref:S,role:"dialog","aria-label":P,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${f?` ${f}`:""}`,onMouseDown:Z},E=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>{p(false),y(null),cs(b.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),T("table.clearCellFill")]}):null,jsxRuntime.jsx(Mc,{apply:D=>{p(false),C?.(D),y({kind:"hex",value:D}),cs(b.current);},current:k})]});return d?jsxRuntime.jsx(G,{...w,children:E}):jsxRuntime.jsx("div",{...w,children:E})}function c({value:d,css:f,labelKey:u,asChild:g,className:m,children:p}){let{apply:v,setOpen:y,setLastHex:x,triggerRef:b}=Co(r),h=Q(),C=f??`#${d.toLowerCase()}`,T=u?h(u):d,S={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${m?` ${m}`:""}`,style:{backgroundColor:C},"data-value":d,"aria-label":T,title:T,onMouseDown:Z,onClick:()=>{y(false),x?.(d),v({kind:"hex",value:d}),cs(b.current);}};return g?jsxRuntime.jsx(G,{...S,children:p}):jsxRuntime.jsx("button",{...S,children:p})}return {Root:i,Main:a,Trigger:s,Content:l,Item:c,Ctx:r}}var Ya=rb("table.borderColor","table.borderColor",{defaultHex:"000000"});function vR(e){return jsxRuntime.jsx(Ya.Content,{...e,clearFill:false})}function yR(e){return jsxRuntime.jsx(Ya.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function xR(e){return jsxRuntime.jsx(Ya.Root,{...e})}var ti=Object.assign(xR,{docxSlot:"table.borderColor",Trigger:Ya.Trigger,Content:vR,Item:yR,Main:Ya.Main}),Xa=rb("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function CR(e){return jsxRuntime.jsx(Xa.Content,{...e,clearFill:true})}function TR(e){return jsxRuntime.jsx(Xa.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function PR(e){return jsxRuntime.jsx(Xa.Root,{...e})}var oi=Object.assign(PR,{docxSlot:"table.cellFill",Trigger:Xa.Trigger,Content:CR,Item:TR,Main:Xa.Main});function ab({overrides:e=new Map,separator:t=true}){return K0()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(En,{}):null,[Ja,ti,Qa,ei,oi].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Et.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function ib(){let e=Q(),{draft:t}=ss("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var up=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Nr="contextual-table",pp={"zoom.level":zu,"styles.style":np,"font.family":Ju,"font.size":Wu,"text.color":Rc,"text.highlight":kc,"text.link":Ou,"list.lineSpacing":Uu,"review.editingMode":Kl,"review.authors":zl,"file.save":Bu,...F0,"table.borderTarget":Ja,"table.borderColor":ti,"table.borderStyle":Qa,"table.borderWidth":ei,"table.cellFill":oi,"image.insert":sa,"image.properties":Cr,"image.wrap":Za,"image.altText":Pa},us={id:Nr,labelKey:"formattingBar.groups.table",entries:up.map(e=>({slot:e,Part:pp[e]}))},lb=new Map;function DR(e){let t=lb.get(e);return t||(t=o=>jsxRuntime.jsx(sn,{slotId:e,...o}),lb.set(e,t)),t}function IR(e){return editor.formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:Jl}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(o=>{let n=editor.chromeSlotId(t,o);return {slot:n,Part:pp[n]??DR(n)}})})}var _R=e=>e.image,NR=e=>e.isLoading||e.isOpening===true,LR=e=>e.table!==null;function FR(e){return e==="alignment"||e in pp}function ms(e){let t=tr(e,ms);if(t!==null)return t;if(!Et.isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function dp(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(dp);let t=ms(e);return t!=null&&up.includes(t)?true:Et.isValidElement(e)?Et.Children.toArray(e.props.children).some(dp):false}function HR(e,t){return t?true:Et.Children.toArray(e).some(dp)}function AR(e){let t=Tt(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:s}=e,l=Et.useMemo(()=>({t:n,onSave:r}),[n,r]),c=Oi(n),d=B(_R),f=B(NR),u=B(LR),g=Et.useMemo(()=>IR(d),[d]),m=Et.useMemo(()=>new Set(g.flatMap(S=>S.entries.map(P=>P.slot))),[g]),p=Et.useMemo(()=>i?Nh(s,ms,S=>m.has(S),S=>up.includes(S)):null,[i,s,m]),v=Et.useMemo(()=>p?OR(g,p):[],[g,p]),y=Et.useMemo(()=>[...v.filter(S=>!S.pinned).map(S=>S.id),...u?[Nr]:[]],[v,u]),x=Et.useMemo(()=>{let S=new Map;for(let P of v)P.priority!==void 0&&S.set(P.id,P.priority);return editor.collapseOrder(y,editor.TOOLBAR_COLLAPSE_ORDER,S)},[v,y]),b=i&&a,{attach:h,overflow:C}=Xi(b,y,x),T;if(!p)T=s;else {let{overrides:S,tableOverrides:P,appended:k}=p,w=M=>{let I=S.get(M.slot);if(I)return I;let U=M.Part;return jsxRuntime.jsx(U,{})},E=M=>{let I=P.get(M.slot);if(I)return I;let U=M.Part;return jsxRuntime.jsx(U,{})},D=[],A=[],_=0;for(let M of v){if(C.has(M.id)){let I=M.entries.flatMap(L=>{let Y=sb(L,S,c,M.labelKey,w);return Y===null?[]:[jsxRuntime.jsx(Et.Fragment,{children:Y},L.slot)]}),U=ZR(M);if(U!==null&&I.push(jsxRuntime.jsx(Et.Fragment,{children:U},"host")),I.length===0)continue;A.push({id:M.id,labelKey:M.labelKey,...M.heading?{label:Ul(M.heading,c)}:{},children:I});continue}_>0&&D.push(jsxRuntime.jsx(En,{},`separator-${M.id}`)),_+=1,D.push(jsxRuntime.jsxs("div",{className:`docx-toolbar__group${M.className?` ${M.className}`:""}`,...M.heading?{role:"group","aria-label":Ul(M.heading,c)}:{},...M.pinned?{[fn]:""}:{[Fo]:M.id},children:[M.entries.map(I=>jsxRuntime.jsx(Et.Fragment,{children:w(I)},I.slot)),M.extras.length>0?jsxRuntime.jsx(Et.Fragment,{children:M.extras},"host"):null]},M.id));}let F=C.has(Nr);if(u&&F){let M=us.entries.flatMap(I=>{let U=sb(I,P,c,us.labelKey,E);return U===null?[]:[jsxRuntime.jsx(Et.Fragment,{children:U},I.slot)]});M.length>0&&A.unshift({id:us.id,labelKey:us.labelKey,children:M});}T=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[D,u&&!F?jsxRuntime.jsx(En,{},"separator-contextual-table"):null,F?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[Fo]:Nr,children:jsxRuntime.jsx(ab,{overrides:P,separator:false})}),k.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[fn]:"",children:k}):null,A.length>0?jsxRuntime.jsx(Ih,{sections:A}):null]});}return jsxRuntime.jsx(ln.Provider,{value:l,children:jsxRuntime.jsx(Sh,{children:jsxRuntime.jsx("fieldset",{ref:h,disabled:f,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,...b?{"data-overflow":""}:{},onMouseDown:Z,children:HR(s,i)?jsxRuntime.jsx(lp,{children:T}):T})})})}function mp(e){if(!e)return false;if(e.type===Et.Fragment){let t=Et.Children.toArray(e.props.children).find(o=>ms(o)!==null);return Et.isValidElement(t)?mp(t):false}return !!e.props.hidden}function OR(e,t){let o=new Map(t.groups.map(l=>[l.id,l])),n=new Set(e.map(l=>l.id)),r=new Map;for(let l of e){let c=o.get(l.id);if(c&&BR(c),c?.hidden)continue;let d=Et.Children.toArray(c?.children);!l.entries.some(u=>!mp(t.overrides.get(u.slot)))&&d.length===0||r.set(l.id,{id:l.id,labelKey:l.labelKey,heading:void 0,entries:l.entries,extras:d,pinned:c?.pinned??editor.TOOLBAR_PINNED_GROUPS.has(l.id),priority:c?.priority,overflowContent:c?.overflowContent,className:c?.className,host:false});}for(let l of t.groups)l.id===Nr&&Zh(l.id);let i=t.groups.filter(l=>!n.has(l.id)&&l.id!==Nr);for(let l of i){let c=Et.Children.toArray(l.children);l.hidden||c.length===0||r.set(l.id,{id:l.id,labelKey:l.labelKey??l.id,heading:{id:l.id,label:l.label,labelKey:l.labelKey},entries:[],extras:c,pinned:l.pinned===true,priority:l.priority,overflowContent:l.overflowContent,className:l.className,host:true});}let a=[...n,...i.map(l=>l.id)];for(let l of i)l.after!==void 0&&!a.includes(l.after)&&Oh(l.id,l.after,a);for(let l of t.appended){if(!Et.isValidElement(l)||l.type!==Ba)continue;let c=l.props.slotId;qh(c,ee(c)!==null);}return editor.arrangeToolbarGroups(e.map(l=>l.id),i.map(l=>({id:l.id,after:l.after}))).flatMap(l=>{let c=r.get(l);return c?[c]:[]})}function BR(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Bh(e.id,t);}function ZR(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(_u.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function sb(e,t,o,n,r){let i=t.get(e.slot);if(mp(i))return null;let a=i?.type===Ba?i.props.overflowContent:void 0;return i||FR(e.slot)?jsxRuntime.jsx(kh,{label:qR(o,e,n),children:a?a():r(e)}):jsxRuntime.jsx(Dh,{slot:e.slot})}function qR(e,t,o){let n=t.slot==="alignment"?null:ee(t.slot);return e(n?.labelKey??o)}var ri=Object.assign(AR,{Button:sn,Action:Gu,Separator:En,Group:Iu,Slot:Ba,AddComment:Nu,Undo:Wh,Redo:zh,Bold:$h,Italic:Uh,Underline:Vh,Strike:Gh,Link:Ou,ClearFormatting:jh,Superscript:Yh,Subscript:Xh,Alignment:Jl,AlignLeft:Jh,AlignCenter:Qh,AlignRight:e0,AlignJustify:t0,LeftToRight:o0,RightToLeft:n0,LineSpacing:Uu,BulletList:r0,NumberedList:a0,Outdent:i0,Indent:l0,ImageInsert:sa,ImageProperties:Cr,ImageWrap:Za,ImageAltText:Pa,TableInsert:Au,TableBorderTarget:Ja,TableBorderColor:ti,TableBorderStyle:Qa,TableBorderWidth:ei,TableCellFill:oi,Comments:s0,FontFamily:Ju,FontSize:Wu,FontColor:Rc,Highlight:kc,Zoom:zu,StylePicker:np,EditingMode:Kl,Reviewers:zl,Save:Bu,ContentControlShowAll:ns,ContentControlFormFill:rs,ContentControlInspector:is,ContentControlRemove:as});var db=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,WR=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var ub=new TextEncoder;function zR(e,t){if(ub.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=ub.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function pb(e){let t=e.length;for(;t>0;){let o=e.charCodeAt(t-1);if(o!==46&&o!==32)break;t-=1;}return e.slice(0,t)}function mb(e){return pb(pb(e).replace(/\.docx$/i,""))}function fs(e){let t=(e??"").replace(WR," ").replace(/\s+/g," ").trim(),o=mb(t).replace(/^[. ]+/,""),n=zR(o,200),r=n===o?o:mb(n);return !r||db.test(r)?"document.docx":db.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function gs(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let n=URL.createObjectURL(new Blob([e],{type:o})),r=document.createElement("a");r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),0);}function fb(e,t,o){let{t:n}=N(),r=Et.useRef(false),[i,a]=Et.useState(false),[s,l]=Et.useState(""),[c,d]=Et.useState("pdf"),[f,u]=Et.useState(false),[g,m]=Et.useState({});return {pending:i,error:s,format:c,visible:f,session:g,dismiss:()=>u(false),execute:async v=>{if(!(!e||r.current)){r.current=true,m({}),d(v),u(true),a(true),l("");try{let y=await editor.runChromeExport(e,v,t);gs(y.bytes.slice().buffer,fs(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),l(y instanceof editor.ChromeExportError?n(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{r.current=false,a(false);}}}}}function hb(e,t,o){let{t:n}=N(),r=Et.useRef({editor:e,exporters:t,feedback:o,t:n});r.current={editor:e,exporters:t,feedback:o,t:n};let i=Et.useRef(null),a=Et.useRef(null),[s,l]=Et.useState(false),[c,d]=Et.useState(""),[f,u]=Et.useState(""),[g,m]=Et.useState(false),[p,v]=Et.useState(false),[y,x]=Et.useState({}),b=Et.useCallback(T=>{let{t:S}=r.current;if(T instanceof editor.ChromeExportError)return S("toolbar.printPdfMissing");if(T instanceof editor.ChromePrintError){if(T.code==="pdf-viewer-unavailable")return S("toolbar.printNoViewer");if(T.code==="pdf-load-failed")return S("toolbar.printLoadFailed");if(T.code==="print-refused")return S("toolbar.printRefused")}return S("toolbar.printFailedMessage",{message:T instanceof Error?T.message:String(T)})},[]),h=Et.useCallback(()=>{i.current=null,v(false),m(false),l(false);},[]),C=Et.useCallback(async T=>{let{editor:S,exporters:P}=r.current;if(!S||i.current)return;let k={};i.current=k,a.current?.dispose(),a.current=null,x(k),v(true),m(true),l(true),d(""),u("");try{let w=await editor.runChromePrint(S,P,T??document);if(i.current!==k){w.dispose();return}a.current=w,await w.print({beforePrint:()=>{if(i.current!==k)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>m(!1));}}),i.current===k&&h();}catch(w){if(i.current!==k)return;if(!r.current.feedback){console.error("[docx-editor] print failed",w),h();return}l(false),u(a.current?.url??""),d(b(w)),m(true);}},[h,b]);return Et.useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:s,error:c,url:f,visible:g,active:p,session:y,execute:C,close:h}}var JR="https://github.com/eigenpal/docx-editor/issues/new";function QR(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function bb(e={}){let t=e.userAgent??(typeof navigator<"u"?navigator.userAgent:"unknown"),o=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??QR()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
-
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${JR}?${i.toString()}`}function ii(e){typeof window>"u"||window.open(bb(e),"_blank","noopener,noreferrer");}function ek({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=at(),a=De();if(t||i===false)return null;let s=o??r??ii;return jsxRuntime.jsx(_e,{slot:"help.reportIssue",onSelect:()=>{s(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var hs=Object.assign(ek,{docxSlot:"help.reportIssue"});function tk({children:e,...t}){let{reportIssue:o}=at();return e===void 0&&o===false?null:jsxRuntime.jsxs(qt,{id:"help",...t,children:[jsxRuntime.jsx(hs,{}),e]})}var hp=Object.assign(tk,{docxMenu:"help"});var ak=e=>e.hiddenReviewAuthors??[];function bs({className:e,hidden:t}){let o=H(),n=Aa(),r=B(ak),i=De(),{t:a}=N();if(t)return null;let s=i("reviewers.label"),l=editor.toolbarCommandState(o,"review.authors"),c=i18n.localizeDisabledReason(l.disabledReason,a);if(!l.enabled)return jsxRuntime.jsx(_e,{disabled:true,title:c??void 0,slot:"review.authors",children:s});let d=new Set(r),f=n.every(u=>!d.has(u.author));return jsxRuntime.jsxs(Zt,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(yb,{checked:f,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!f)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsxRuntime.jsx(yb,{checked:!d.has(u.author),label:u.author||"\u2014",slot:`reviewer-${u.slot}`,onChoose:()=>o?.setReviewAuthorVisible(u.author,d.has(u.author))},u.author))]})}function yb(e){return jsxRuntime.jsx(_e,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsxRuntime.jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function ik({children:e,...t}){return jsxRuntime.jsxs(qt,{id:"review",...t,children:[jsxRuntime.jsx(Zt,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(bs,{className:"docx-menubar__reviewers-submenu"})}),e]})}var vs=Object.assign(ik,{docxMenu:"review"});var sk={file:bd,format:vd,insert:yd,review:vs,help:hp};function si(e,t=false){if(!Et.isValidElement(e))return null;if(e.type===Et.Fragment){let i=Et.Children.toArray(e.props.children).map(a=>si(a,t)).filter(a=>a!==null);return i.length===1?i[0]:null}let o=e.props;if(o.hidden===true&&!t)return null;let n=e.type;return (typeof n=="function"||typeof n=="object")&&typeof n.docxMenu=="string"?n.docxMenu:e.type===qt&&typeof o.id=="string"?o.id:null}var ck=new Set(editor.CHROME_MENUS.map(e=>e.id));function Ts(e){if(!Et.isValidElement(e))return null;if(e.type===Et.Fragment){let n=Et.Children.toArray(e.props.children).map(Ts).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===qt){let o=e.props.id;if(typeof o=="string"&&ck.has(o))return o}return null}var dk=e=>e.isOpening===true;function uk(e){let t=Pr(),o=Kt(),n=Tt(),{className:r,t:i,fileName:a,exporters:s,onOpen:l,onOpenFile:c,onSave:d,onPageSetup:f,onReportIssue:u,reportIssue:g,preset:m=true,overflow:p=true,children:v}=e,y=H(),{t:x}=N(),[b,h]=Et.useState(null),C=B(dk);Et.useEffect(()=>{C&&h(null);},[C]);let[T,S]=Et.useState(null),P=fb(y,s,a??T??void 0),{pending:k,execute:w}=P,E=hb(y,s,o?.print!==false),{active:D,execute:A}=E,_=E.visible&&o?.print!==false,[F,M]=Et.useState(null),[I,U]=Et.useState(false),[L,Y]=Et.useState(false),j=Et.useRef(null),me=Et.useRef(null);Et.useEffect(()=>{if(b===null)return;let re=oe=>{let ye=j.current;ye&&oe.target instanceof Node&&ye.contains(oe.target)||h(null);};return document.addEventListener("mousedown",re),()=>{document.removeEventListener("mousedown",re);}},[b]),Mr(b!==null,j,()=>h(null),re=>re.target instanceof Node&&j.current?.contains(re.target)===true);let z=Et.useCallback(re=>{h(re),re!==null&&M(re);},[]),ie=Et.useCallback(()=>me.current?.click(),[]),J=Et.useCallback(()=>{y&&y.save().then(re=>gs(re,fs(a??T??void 0))).catch(re=>{console.error("[docx-editor] save failed",re);});},[y,a,T]),W=Et.useCallback(()=>t?t.open("pageSetup",j.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):U(true),[t]),q=y?l??ie:void 0,fe=y?d??J:void 0,ve=!!s?.pdf,de=Et.useMemo(()=>y&&!D?()=>{rd(j.current),A(editor.editorInstanceScope(j.current)??j.current??void 0);}:void 0,[y,D,A]),ze=y?t?.ownsPageSetup?W:f??W:void 0;Et.useEffect(()=>{let re=oe=>{if(!(oe.metaKey||oe.ctrlKey)||oe.altKey||oe.shiftKey)return;let ye=oe.key.toLowerCase(),$e=editor.isChromePrintShortcut(oe);if(ye!=="s"&&ye!=="o"&&!$e)return;let Ze=oe.target,fo=editor.editorInstanceScope(j.current)??j.current;if(!(!Ze||!fo?.contains(Ze)))if($e){if(!ve||!y||!de&&!_)return;oe.preventDefault(),de?.();}else ye==="s"&&fe?(oe.preventDefault(),fe()):ye==="o"&&q&&(oe.preventDefault(),q());};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[q,fe,de,_,ve,y]);let Lt=Et.useMemo(()=>({t:i,openMenu:b,setOpenMenu:z,activeMenu:F,onOpen:q,onSave:fe,onExport:y&&!k?re=>(rd(j.current),w(re)):void 0,onPrint:de,printShortcut:ve,onPageSetup:ze,onParagraphDialog:()=>t?t.open("paragraph",j.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):Y(true),onReportIssue:u,reportIssue:g,opening:C}),[C,y,k,w,de,ve,i,b,z,F,q,fe,ze,t,u,g]),Je=Et.Children.toArray(v),ut=[];if(m){let re=new Map(Je.map(oe=>[Ts(oe),oe]));for(let oe of editor.CHROME_MENUS){let ye=re.get(oe.id);(ye===void 0||si(ye)!==null)&&ut.push(oe.id);}for(let oe of Je){if(Ts(oe)!==null)continue;let ye=si(oe);ye!==null&&ut.push(ye);}}else for(let re of Je){let oe=si(re);oe!==null&&ut.push(oe);}let Se=[...ut].reverse(),{attach:uo,overflow:po}=Xi(p,ut,Se),mo=Et.useMemo(()=>({measuring:p,overflow:po,inMore:false}),[p,po]),Mo=Et.useMemo(()=>({measuring:false,overflow:po,inMore:true}),[po]),Yt=re=>si(re,true)!==null,ne=(re,oe)=>jsxRuntime.jsx("div",{role:"none",className:"docx-menubar__host",[fn]:"",children:re},oe),ge,xt;if(!m)ge=Je.filter(Yt),xt=p?Je.map((re,oe)=>Yt(re)?re:ne([re],`host-${oe}`)):v;else {let re=new Map,oe=[];for(let $e of Je){let Ze=Ts($e);Ze?re.set(Ze,$e):oe.push($e);}ge=[...editor.CHROME_MENUS.map($e=>{let Ze=re.get($e.id);if(Ze)return jsxRuntime.jsx(Et.Fragment,{children:Ze},$e.id);let fo=sk[$e.id];return jsxRuntime.jsx(fo,{},$e.id)}),...oe.filter(Yt)];let ye=oe.filter($e=>!Yt($e));xt=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ge,ye.length>0?ne(ye,"host"):null]});}let zn=i?.("formattingBar.more")??x("formattingBar.more");return jsxRuntime.jsxs(na.Provider,{value:Lt,children:[jsxRuntime.jsx("div",{ref:re=>{if(j.current=re,uo(re),re&&F===null){let oe=nd(re)[0]?.closest("[data-menu]")?.getAttribute("data-menu");oe&&M(oe);}},role:"menubar","aria-label":i?.("titleBar.menuBarAriaLabel")??x("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...p?{"data-overflow":""}:{},className:`${n}docx-menubar${r?` ${r}`:""}`,onMouseDown:Z,onKeyDown:re=>{if(re.key!=="ArrowLeft"&&re.key!=="ArrowRight")return;let oe=j.current;if(!oe)return;let ye=nd(oe),$e=ye.indexOf(document.activeElement);if($e===-1)return;re.preventDefault();let Ze=re.key==="ArrowRight"?1:-1,fo=ye[($e+Ze+ye.length)%ye.length],$n=fo?.closest("[data-menu]")?.getAttribute("data-menu");$n&&(M($n),fo?.focus(),b!==null&&h($n));},children:jsxRuntime.jsxs(ji.Provider,{value:mo,children:[jsxRuntime.jsx(nr.Provider,{value:0,children:xt}),po.size>0?jsxRuntime.jsx(qt,{id:or,label:zn,icon:ae(ku),preset:false,children:jsxRuntime.jsx(ji.Provider,{value:Mo,children:ge})}):null]})}),jsxRuntime.jsxs(Bg,{children:[P.visible&&o?.export!==false?o?.export?ke(o.export,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss},P.session):jsxRuntime.jsx(Vr,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss}):null,E.visible&&o?.print!==false?o?.print?ke(o.print,{open:true,pending:E.pending,error:E.error,url:E.url,onClose:E.close},E.session):jsxRuntime.jsx(Gr,{open:true,pending:E.pending,error:E.error,url:E.url,onClose:E.close}):null]}),jsxRuntime.jsx("input",{ref:me,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:re=>{let oe=re.target.files?.[0];re.target.value="",!(!oe||!y)&&(S(oe.name),c?.(oe),oe.arrayBuffer().then(ye=>y.load(new Uint8Array(ye))).catch(ye=>{console.error("[docx-editor] could not open the file",ye);}));}}),jsxRuntime.jsx(Sn,{open:I,onClose:()=>U(false)}),jsxRuntime.jsx(xo,{open:L,onClose:()=>Y(false)})]})}var ci=Object.assign(uk,{Menu:qt,File:bd,Format:vd,Insert:yd,Review:vs,Help:hp,Item:bo,Row:_e,Group:da,Separator:gn,Submenu:Zt,TableGrid:ar,Entry:pa,Open:cd,Save:dd,ExportMarkdown:ud,ExportPdf:pd,Print:md,PageSetup:fd,ImageInsert:gd,Reviewers:bs,ReportIssue:hs});var hk=12240,wb=1440,kb=1440,Db=567,kn=20,Tp=6,Sp=kn+Tp+2,bk="var(--doc-text-muted)",vk="var(--doc-text-subtle)",Mb="var(--doc-shadow-subtle)",yk="var(--doc-primary)",xk="var(--doc-primary-hover)",Ck="var(--doc-text-subtle)",ui=5,di=7,Tk={left:0,right:0,firstLine:0};function Rb(e,t){return t==="inch"?(e/kb).toFixed(2)+'"':(e/Db).toFixed(1)+" cm"}function Pk(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function Dn({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:s,indentEditable:l=false,onIndentChange:c,onIndentDragEnd:d,unit:f="inch",className:u="",style:g,tabMarks:m,onTabMarkRemove:p}){let{t:v}=N(),[y,x]=Et.useState(null),[b,h]=Et.useState(null),[C,T]=Et.useState(null),[S,P]=Et.useState(null),k=Et.useRef(null),w=e?.pageWidthTwips??hk,E=e?.marginsTwips.left??wb,D=e?.marginsTwips.right??wb,A=e?.gutterTwips??0,_={pageWidth:w,leftMargin:E,rightMargin:D},F=s??Tk,M=Ne(w)*t,I=Ne(E)*t,U=Ne(D)*t,L=Et.useCallback(q=>{let fe=k.current?.getBoundingClientRect();return fe?Fl((q-fe.left)/t):null},[t]),Y=Et.useCallback((q,fe,ve)=>{let de=L(fe);if(de===null)return;if(P(Ne(de)*t),q==="leftMargin"||q==="rightMargin"){if(q==="leftMargin"){let Lt=w-D-A-720,Je=Math.round(Math.max(0,Math.min(de,Lt)));T(Je),n?.(Je);}else {let Lt=w-de,Je=w-E-A-720,ut=Math.round(Math.max(0,Math.min(Lt,Je)));T(ut),r?.(ut);}return}let ze=editor.dragIndent(q,de,F,_,{unit:f,precise:ve});T(q==="right"?ze.right:q==="firstLine"?ze.firstLine:ze.left),c?.(ze);},[L,t,w,E,D,A,n,r,c,F,_,f]),j=Et.useCallback(q=>{q==="leftMargin"||q==="rightMargin"?i?.():d?.(),x(null),T(null),P(null);},[i,d]),me=Et.useCallback((q,fe,ve)=>{let de=editor.handlePosition(q,F,_),ze=editor.dragIndent(q,de+fe*Pk(f,ve),F,_,{unit:f,precise:true});c?.(ze),d?.();},[F,_,f,c,d]),z=kk(w,t,f),ie=a&&l&&c!==void 0,J=q=>Ne(editor.handlePosition(q,F,_))*t,W=(q,fe,ve)=>({positionPx:J(q),editable:ie,isDragging:y===q,isHovered:b===q,onPointerEnter:()=>h(q),onPointerLeave:()=>h(null),onPointerDown:de=>{ie&&(de.preventDefault(),de.stopPropagation(),de.currentTarget.setPointerCapture(de.pointerId),x(q));},onPointerMove:de=>{y===q&&Y(q,de.clientX,de.altKey);},onPointerUp:de=>{y===q&&(de.currentTarget.releasePointerCapture(de.pointerId),j(q));},onKeyDown:de=>{ie&&(de.key!=="ArrowLeft"&&de.key!=="ArrowRight"||(de.preventDefault(),me(q,de.key==="ArrowLeft"?-1:1,de.shiftKey)));},label:v(fe),valueNow:ve,valueText:Rb(ve,f),pageWidthTwips:w});return jsxRuntime.jsxs("div",{ref:k,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:ht(M),height:Sp,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:y?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":v("ruler.horizontal"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:ht(I),height:kn,backgroundColor:Mb,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("leftMargin");}:void 0,onPointerMove:q=>y==="leftMargin"&&Y("leftMargin",q.clientX,q.altKey),onPointerUp:q=>{y==="leftMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),j("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:ht(U),height:kn,backgroundColor:Mb,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("rightMargin");}:void 0,onPointerMove:q=>y==="rightMargin"&&Y("rightMargin",q.clientX,q.altKey),onPointerUp:q=>{y==="rightMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),j("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:kn,pointerEvents:"none"},children:z.map((q,fe)=>jsxRuntime.jsx(Sk,{tick:q},fe))}),m?.map(q=>jsxRuntime.jsx(Rk,{tabMark:q,positionPx:Ne(q.position)*t,onDoubleClick:()=>p?.(q.position)},q.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Cp,{direction:"down",anchor:"top",...W("firstLine","ruler.firstLineIndent",F.firstLine)}),jsxRuntime.jsx(Cp,{direction:"up",anchor:"strip",...W("hanging","ruler.hangingIndent",F.left)}),jsxRuntime.jsx(Ek,{...W("left","ruler.leftIndent",F.left)}),jsxRuntime.jsx(Cp,{direction:"up",anchor:"strip",...W("right","ruler.rightIndent",F.right)})]}),y&&C!==null&&S!==null&&jsxRuntime.jsx(wk,{value:Rb(C,f),positionPx:S})]})}function Sk({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:ht(e.position),bottom:0,width:1,height:e.height,backgroundColor:vk}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:ht(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:bk,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Ib(e){return e.editable?e.isDragging||e.isHovered?xk:yk:Ck}function _b(e,t,o){return {position:"absolute",left:ht(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function Nb(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 Cp({direction:e,anchor:t,...o}){let n=Ib(o),r=t==="top"?{top:0,height:di+1}:{top:kn-di,height:di};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:_b(o,ui*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...Nb(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${ui}px solid transparent`,borderRight:`${ui}px solid transparent`,...e==="down"?{top:0,borderTop:`${di}px solid ${n}`}:{bottom:0,borderBottom:`${di}px solid ${n}`},transition:"border-color 0.1s"}})})}function Ek(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:_b(e,ui*2,{top:kn+1,height:Tp}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Nb(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:ui*2-2,height:Tp,backgroundColor:Ib(e),borderRadius:1,transition:"background-color 0.1s"}})})}function wk({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:ht(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 Mk={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function Rk({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:ht(t-5),top:kn-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:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:Mk[e.alignment]||"L"})}function kk(e,t,o){let n=[];if(o==="inch"){let r=kb/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=Ne(s)*t;a%8===0?n.push({position:l,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?n.push({position:l,height:5}):a%2===0?n.push({position:l,height:3}):n.push({position:l,height:2});}}else {let r=Db/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=Ne(s)*t;a%10===0?n.push({position:l,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?n.push({position:l,height:5}):n.push({position:l,height:3});}}return n}var _k=15840,Hb=1440,Es=1440,ws=567,Fr=20,Nk="var(--doc-text-muted)",Lk="var(--doc-text-subtle)",Fk="var(--doc-primary)",Hk="var(--doc-primary)",Ak="var(--doc-primary-hover)";function pi({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:s="",style:l}){let{t:c}=N(),[d,f]=Et.useState(null),[u,g]=Et.useState(null),m=Et.useRef(null),p=e?.pageHeightTwips??_k,v=e?.marginsTwips.top??Hb,y=e?.marginsTwips.bottom??Hb,x=(E,D)=>{if(!o||E.altKey||E.ctrlKey||E.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(E.key))return;E.preventDefault();let A=D==="topMargin"?v:y,F=Math.max(0,p-(D==="topMargin"?y:v)-720),M=E.shiftKey?1:Math.round(a==="cm"?ws/10:Es/8),I=E.key==="Home"?0:E.key==="End"?F:Math.max(0,Math.min(F,A+(E.key==="ArrowUp"?M:-M)));I!==A&&((D==="topMargin"?n:r)?.(I),i?.());},b=Ne(p)*t,h=Ne(v)*t,C=Ne(y)*t,T=Et.useCallback((E,D)=>{o&&(E.preventDefault(),f(D));},[o]),S=Et.useCallback(E=>{if(!d||!m.current)return;let D=m.current.getBoundingClientRect(),A=E.clientY-D.top,_=Fl(A/t);if(d==="topMargin"){let F=p-y-720,M=Math.max(0,Math.min(_,F));n?.(Math.round(M));}else if(d==="bottomMargin"){let F=p-_,M=p-v-720,I=Math.max(0,Math.min(F,M));r?.(Math.round(I));}},[d,t,p,v,y,n,r]),P=Et.useCallback(()=>{d!==null&&i?.(),f(null);},[d,i]);Et.useEffect(()=>{if(d)return document.addEventListener("mousemove",S),document.addEventListener("mouseup",P),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",P);}},[d,S,P]);let k=Bk(p,t,a),w={position:"relative",width:Fr,height:ht(b),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...l};return jsxRuntime.jsxs("div",{ref:m,className:`docx-vertical-ruler ${s}`,style:w,role:"group","aria-label":c("ruler.vertical"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:k.map((E,D)=>jsxRuntime.jsx(Ok,{tick:E},D))}),jsxRuntime.jsx(Ab,{type:"topMargin",value:v,maximum:Math.max(0,p-y-720),valueText:v/(a==="cm"?ws:Es),unit:a,onKeyDown:E=>x(E,"topMargin"),position:h,editable:o,isDragging:d==="topMargin",isHovered:u==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>T(E,"topMargin")}),jsxRuntime.jsx(Ab,{type:"bottomMargin",value:y,maximum:Math.max(0,p-v-720),valueText:y/(a==="cm"?ws:Es),unit:a,onKeyDown:E=>x(E,"bottomMargin"),position:b-C,editable:o,isDragging:d==="bottomMargin",isHovered:u==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:E=>T(E,"bottomMargin")})]})}function Ok({tick:e}){let t={position:"absolute",top:ht(e.position),right:0,height:1,width:e.width,backgroundColor:Lk},o={position:"absolute",top:ht(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:Nk,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function Ab({type:e,position:t,value:o,maximum:n,valueText:r,unit:i,onKeyDown:a,editable:s,isDragging:l,isHovered:c,onMouseEnter:d,onMouseLeave:f,onMouseDown:u}){let{t:g}=N(),m=l?Ak:c?Hk:Fk,p={position:"absolute",top:ht(t-5),right:0,width:Fr,height:10,cursor:s?"ns-resize":"default",zIndex:l?10:1},v={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${m}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:p,onMouseEnter:d,onMouseLeave:f,onMouseDown:u,role:"slider","aria-label":g(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":n,"aria-valuetext":`${r.toFixed(2)} ${i==="cm"?"cm":"in"}`,"aria-disabled":!s,onKeyDown:a,tabIndex:s?0:-1,children:jsxRuntime.jsx("div",{style:v})})}function Bk(e,t,o){let n=[];if(o==="inch"){let r=Es/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=Ne(s)*t;if(a%8===0){let c=a/8;n.push({position:l,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:l,width:6}):a%2===0?n.push({position:l,width:4}):n.push({position:l,width:2});}}else {let r=ws/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=Ne(s)*t;if(a%10===0){let c=a/10;n.push({position:l,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:l,width:6}):n.push({position:l,width:3});}}return n}var In=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var Kk=e=>e.formatting?.indent??null,Wk=e=>e.editable;function wp(){let e=H(),t=B(Kk),o=B(Wk),n=Et.useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=Et.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 Et.useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var Kb=e=>e.zoom,$k=e=>e.isOpening===true;function Wb(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function zb(){let{apply:e}=Pn(),[t,o]=Et.useState({}),n=Et.useRef({}),r=Et.useCallback(a=>s=>{n.current={...n.current,[a]:Math.round(s)},o(n.current);},[]),i=Et.useCallback(()=>{let a=n.current;n.current={},o({}),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 qb(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function Uk(){let e=H(),{indent:t,isEnabled:o,apply:n}=wp(),[r,i]=Et.useState(null),a=Et.useRef(null),s=Et.useRef(null),l=Et.useCallback(f=>{s.current===null&&(s.current=qb(e)),a.current=f,i(f);},[e]),c=Et.useCallback(()=>{let f=a.current,u=s.current;a.current=null,s.current=null,i(null),f&&(u!==null&&u!==qb(e)||n({left:f.left,right:f.right,firstLine:f.firstLine}));},[e,n]),d=Et.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[r,t]);return Et.useMemo(()=>({indent:d,isEnabled:o,preview:l,commit:c}),[d,o,l,c])}function Vk(){let e=Ye(),[t,o]=Et.useState(0);return Et.useEffect(()=>{if(!e){o(0);return}let n=()=>o(e.scrollLeft);return n(),e.addEventListener("scroll",n,{passive:true}),()=>e.removeEventListener("scroll",n)},[e]),t}function Rs(e){let t=B(In),o=B($k),{pageSetup:n,isEnabled:r}=Pn(),i=B(Kb),{pending:a,preview:s,commit:l}=zb(),c=Uk(),d=an(),f=qo(),u=Vk();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+f.inlineStart,paddingRight:f.inlineEnd},children:jsxRuntime.jsx(Dn,{pageSetup:Wb(n,a),zoom:i,editable:r,onLeftMarginChange:s("left"),onRightMarginChange:s("right"),onMarginDragEnd:l,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-u}px)`,clipPath:d>0&&u>0?`inset(0 0 0 ${u}px)`:e.style?.clipPath}})})}function ks(e){let t=B(In),{pageSetup:o,isEnabled:n}=Pn(),r=B(Kb),{pending:i,preview:a,commit:s}=zb(),l=an(),c=qo(),d=mh();return t||d!==null&&d>0&&o&&Ne(o.pageWidthTwips)*r>d-l-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(pi,{pageSetup:Wb(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:s,unit:e.unit??"inch",className:e.className??"",style:e.style})}function O({size:e=20,className:t="",style:o,children:n}){return jsxRuntime.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,...o},"aria-hidden":"true",children:n})}function $b(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Ub(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Vb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Gb(e){return jsxRuntime.jsxs(O,{...e,children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function jb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function Yb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Xb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Jb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Qb(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 ev(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 tv(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 ov(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Zm-120 480v-400 400Z"})})}function Yk(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Xk(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Jk(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 Qk(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 eD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 tD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 oD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function nD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 rD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 aD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 iD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 lD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 sD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z"})})}function cD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M40-40v-240h80v-400H40v-240h240v80h400v-80h240v240h-80v400h80v240H680v-80H280v80H40Zm240-160h400v-80h80v-400h-80v-80H280v80h-80v400h80v80Zm32-120 136-360h64l136 360h-62l-32-92H408l-32 92h-64Zm114-144h108l-52-150h-4l-52 150ZM120-760h80v-80h-80v80Zm640 0h80v-80h-80v80Zm0 640h80v-80h-80v80Zm-640 0h80v-80h-80v80Zm80-640Zm560 0Zm0 560Zm-560 0Z"})})}function dD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function uD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function pD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function mD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function fD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function Dp(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 gD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 hD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 bD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function vD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function yD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function xD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 CD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 TD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function PD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 SD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 ED(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 wD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 MD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 nv(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function RD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 kD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 DD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 ID(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function _D(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function ND(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 LD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 FD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 HD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function AD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 OD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 BD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function ZD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function qD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function KD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 WD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 zD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 $D(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function UD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 VD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 GD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 jD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 YD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 XD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 JD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function QD(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function e2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 t2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 o2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 n2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 r2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 a2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 i2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 l2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 s2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 c2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 d2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function u2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 p2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 m2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 f2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function g2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 h2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function b2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function v2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function y2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function x2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function C2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function T2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 P2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 S2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 E2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function w2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 M2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function R2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 k2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 D2(e){return jsxRuntime.jsx(O,{...e,children:jsxRuntime.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 I2={undo:Yk,redo:Xk,print:Jk,file_download:Qk,file_upload:eD,format_bold:tD,format_italic:oD,format_underlined:nD,strikethrough_s:rD,superscript:aD,subscript:iD,link:lD,format_clear:dD,format_paragraph:sD,format_shapes:cD,lock:ov,format_align_left:uD,format_align_center:pD,format_align_right:mD,format_align_justify:fD,format_line_spacing:Dp,format_list_bulleted:gD,format_list_numbered:hD,format_indent_increase:bD,format_indent_decrease:vD,format_color_text:yD,ink_highlighter:xD,format_color_reset:CD,arrow_drop_down:TD,table:PD,table_chart:SD,grid_on:ED,table_rows:wD,view_column:MD,border_all:nv,select_all:nv,border_outer:RD,border_inner:kD,border_clear:DD,add:ID,remove:_D,delete:ND,delete_sweep:LD,call_merge:FD,call_split:HD,drag_indicator:AD,image:OD,format_image_left:BD,format_image_right:ZD,horizontal_rule:qD,flip_to_back:KD,flip_to_front:WD,open_with:zD,tune:$D,rotate_right:UD,rotate_left:VD,swap_horiz:GD,swap_vert:jD,shapes:YD,format_paint:XD,expand_more:JD,expand_less:QD,border_top:e2,border_bottom:t2,border_left:o2,border_right:n2,border_horizontal:r2,border_vertical:a2,padding:i2,text_rotation_none:l2,wrap_text:s2,height:c2,fit_width:d2,settings:u2,border_color:p2,format_color_fill:m2,vertical_align_top:f2,vertical_align_center:g2,vertical_align_bottom:h2,line_weight:b2,keyboard_arrow_up:v2,keyboard_arrow_down:y2,keyboard_arrow_left:x2,keyboard_arrow_right:C2,more_vert:T2,page_break:P2,branding_watermark:S2,arrow_back:E2,search:w2,toc:M2,done_all:$b,check_circle:Ub,chat_bubble_outline:Vb,chat_bubble_check:Gb,check:jb,close:Yb,add_comment:Xb,comment:Jb,edit_note:Qb,rate_review:ev,visibility:tv,format_textdirection_l_to_r:R2,format_textdirection_r_to_l:k2,"agent-sparkle":D2};function $({name:e,size:t=20,className:o="",style:n}){let r=I2[e];return r?jsxRuntime.jsx(r,{size:t,className:o,style:n}):(console.warn(`Icon not found: ${e}`),jsxRuntime.jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...n},children:e}))}var mi=12,Ip=240,av=16,F2=24,H2=mi+Ip+av,Hr=12,A2=36,O2=Hr+A2+av,fi=Et__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=mi}){let{t:s}=N(),[l,c]=Et.useState(false),d=t.length?Math.min(...t.map(f=>f.level)):0;return Et.useEffect(()=>{requestAnimationFrame(()=>c(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":s("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:Ip,paddingTop:F2,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:l?"translateX(0)":`translateX(-${a+Ip}px)`,transition:"transform 0.15s ease-out"},onMouseDown:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":s("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:s("documentOutline.closeTitle"),children:jsxRuntime.jsx($,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:s("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:s("documentOutline.noHeadings")}):t.map((f,u)=>jsxRuntime.jsx("div",{style:{marginLeft:(f.level-d)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(f.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:f.text,children:f.text})},`${f.blockId}-${u}`))})]})});var q2=e=>e,K2=Object.freeze([]),W2=()=>{};function _p(e){let t=H(),o=B(q2),n=Et.useMemo(()=>t&&!o.isLoading?t.getOutline():K2,[t,o]),r=Et.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 In(o)?null:jsxRuntime.jsx(fi,{headings:n,onHeadingClick:r,onClose:e.onClose??W2,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Np=Et.createContext(null);function Vo(e){let t=Et.useContext(Np);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var Ar=280,Ds=32,iv=16;function Or(e=280){return 32+e+16}function Is({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,s=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,s-r))}var Lp=320;function _s(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<Lp}var j2=Object.freeze([]),Y2=e=>e;function Ns(){let e=H(),t=B(Y2),[o,n]=Et.useState(null),r=Et.useMemo(()=>e&&!t.isLoading?e.getOutline():j2,[e,t]),i=Et.useMemo(()=>{if(r.length===0)return [];let s=r[0].level;for(let l of r)l.level<s&&(s=l.level);return r.map(l=>({heading:l,depth:l.level-s}))},[r]),a=Et.useCallback(s=>{if(!e||typeof s!="string"||s.length===0)return;e.focus();let l={paragraphId:s,offset:0};e.exec({type:"setSelection",range:{anchor:l,head:l}}),e.scrollToBlock(s),n(s);},[e]);return {headings:r,items:i,selectedBlockId:o,goTo:a,isEmpty:r.length===0}}var mv=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),e8=()=>()=>{},sv=()=>mv;function Ls(e={}){let t=e.highlight??"all",o=H(),n=Et.useMemo(()=>o?editor.createDocumentSearch(o):null,[o]),r=Et.useSyncExternalStore(n?n.subscribe:e8,n?n.getState:sv,n?n.getState:sv);Et.useEffect(()=>{if(!(!n||t==="none"))return n.showHighlights(t)},[n,t]);let i=Et.useMemo(()=>({setQuery:a=>n?.setQuery(a),find:(a,s)=>n?.find(a,s)??mv.matches,setMatchCase:a=>n?.setMatchCase(a),setWholeWord:a=>n?.setWholeWord(a),goTo:a=>n?.goTo(a)??false,next:()=>n?.next()??false,previous:()=>n?.previous()??false,clear:()=>n?.clear()}),[n]);return Et.useMemo(()=>({...r,...i}),[r,i])}function hv(e,t=i18n.isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:editor.chordLetter(e)==="f"}function bv(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function vv(e,t,o){if(e?.isConnected){o&&e.closest(".docx-pages")?o():e.focus({preventScroll:true});return}t?t.focus({preventScroll:true}):o?.();}function yv(e,t,o){if(!e||typeof Node>"u"||!(e instanceof Node))return false;if(t?.contains(e))return true;if(!o)return false;if(o.contains(e))return true;let n=e instanceof Element?e:e.parentElement;if(!n)return false;let r=editor.editorInstanceScope(o);if(r&&r!==o&&r.contains(n))return true;if(!n.closest(".docx-editor")||editor.editorInstanceScope(n)!==null)return false;let i=o.ownerDocument.querySelectorAll(".docx-editor__scroll-container");return i.length===1&&i[0]===o}function Hp(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let n=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(n)return n}return o.querySelector(".docx-nav__search-input")}function Ap(e){e.focus(),typeof HTMLInputElement<"u"&&e instanceof HTMLInputElement&&e.select();}function n8(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id==="docx-nav-tab-find"?"find":"headings",n=Hp(e,o);if(n){Ap(n);return}e instanceof HTMLElement&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function r8(e,t){let o=[];if(t.contains(e)){let i=e;for(;i!==t&&i.parentElement;){for(let a of i.parentElement.children)a!==i&&o.push(a);i=i.parentElement;}}else o.push(...t.children);let n=e.ownerDocument.activeElement;n&&o.some(i=>i.contains(n))&&n8(e);let r=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),r.push(i));return ()=>{for(let i of r)i.removeAttribute("inert");r.length=0;}}function xv(e,t,o){let n=r8(e,t),r=i=>{i.target instanceof Node&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function gv(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Cv(e,t){let o=()=>{let r=getComputedStyle(t),i=t.clientHeight-gv(r.paddingTop)-gv(r.paddingBottom);e.style.setProperty("--docx-nav-block-size",`${Math.max(0,Math.round(i))}px`),e.style.setProperty("--docx-nav-inline-size",`${Math.round(t.clientWidth)}px`);};if(o(),typeof ResizeObserver>"u")return ()=>{};let n=new ResizeObserver(o);return n.observe(t),()=>n.disconnect()}function Tv(e,t=true){let o=H(),n=Ye(),r=Et.useRef(null),i=Et.useRef(null),a=Et.useRef(false),s=Et.useRef(false),l=Et.useRef(false),c=Et.useRef(0),d=Et.useCallback(()=>{let h=++c.current;setTimeout(()=>{c.current===h&&(a.current=false,s.current=false,l.current=false);},0);},[]),f=Et.useRef(e);f.current=e;let u=Et.useCallback(()=>{a.current=false;let h=Hp(r.current,f.current.tab);h&&Ap(h);},[]),g=Et.useCallback(()=>{s.current=false;let h=i.current;i.current=null;let C=r.current?.querySelector(".docx-nav__toggle")??null;vv(h,C,o?()=>o.focus():null);},[o]),m=Et.useRef(g);m.current=g,Et.useEffect(()=>()=>{s.current&&m.current();},[]);let p=Et.useCallback(()=>{a.current=false,s.current=true,f.current.setOpen(false),d();},[d]),v=Et.useMemo(()=>({toggle:()=>{if(f.current.open){p();return}i.current=null,s.current=false,a.current=true,f.current.setOpen(true),d();},close:p,picked:()=>{let h=f.current;if(!h.overlay)return;let C=r.current?.ownerDocument.activeElement;l.current=!!C&&!!r.current?.contains(C),h.setOpen(false),d();}}),[p,d]),y=Et.useRef(v);y.current=v,Et.useEffect(()=>{let h=r.current?.ownerDocument;if(!h||!t)return;let C=T=>{if(T.defaultPrevented||!hv(T)||!yv(T.target,r.current,n))return;T.preventDefault();let S=h.activeElement;S instanceof HTMLElement&&!r.current?.contains(S)&&(i.current=S),s.current=false;let P=f.current;if(P.open&&P.tab==="find"){u();return}a.current=true,P.tab!=="find"&&P.setTab("find"),P.open||P.setOpen(true),d();};return h.addEventListener("keydown",C),()=>h.removeEventListener("keydown",C)},[n,u,t,d]),Et.useEffect(()=>{a.current&&(f.current.open?u():a.current=false),s.current&&(f.current.open?s.current=false:g()),l.current&&(l.current=false,f.current.open||o?.focus());});let x=e.open&&e.overlay;Et.useEffect(()=>{let h=r.current;if(!(!x||!h||!n))return xv(h,n,()=>y.current.close())},[x,n]),Et.useEffect(()=>{let h=r.current;if(!(!h||!n||!n.contains(h)))return Cv(h,n)},[n]);let b=Et.useCallback(h=>{h.key!=="Escape"||h.defaultPrevented||h.nativeEvent.isComposing||f.current.open&&(h.preventDefault(),p());},[p]);return {rootRef:r,intents:v,onKeyDown:b}}function i8(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function l8(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function Pv(e,t){let o=null,n=false,r=()=>{o=null,n||t(l8(e.getPageGeometry()));},i=()=>{n||(o!==null&&clearTimeout(o),o=setTimeout(r,150));},a=e.on("change",s=>{i8(s)&&i();});return r(),{nudge:i,dispose(){n=true,o!==null&&clearTimeout(o),o=null,a();}}}var p8=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??editor.ZOOM_MAX)&&e.zoom>(t.minZoom??editor.ZOOM_MIN)}},m8=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,f8=e=>e.page.total;function Fs(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=Et.useState(t),[a,s]=Et.useState(o),l=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:f}=e,u=e.open!==void 0,g=e.tab!==void 0,m=Et.useCallback(W=>{u||i(W),d?.(W);},[u,d]),p=Et.useCallback(()=>m(!l),[l,m]),v=Et.useCallback(W=>{g||s(W),f?.(W);},[g,f]),y=rn(),x=Ye(),b=Et.useContext(Ct),{pageSetup:h,zoom:C,reviewPaneOpen:T,fitting:S}=B(p8,m8),P=H(),k=B(f8),[w,E]=Et.useState(0),[D,A]=Et.useState(null),[_,F]=Et.useState(0),[M,I]=Et.useState(0),U=qo();Et.useEffect(()=>{if(!x){E(0),F(0),I(0);return}let W=()=>{E(x.clientWidth);let fe=getComputedStyle(x),ve=Number.parseFloat(fe.paddingInlineEnd);F(Number.isFinite(ve)?ve:0);let de=Number.parseFloat(fe.getPropertyValue("--docx-review-gutter-start"));I(Number.isFinite(de)?de:0);};if(W(),typeof ResizeObserver>"u")return;let q=new ResizeObserver(W);return q.observe(x),()=>q.disconnect()},[x,l,T,b?.mounted,U]);let L=Et.useRef(null);h&&(L.current=h.pageWidthTwips);let Y=h?.pageWidthTwips??L.current,j=Et.useRef(null);Et.useEffect(()=>{if(!l||!P)return;let W=Pv(P,A);return j.current=W,()=>{W.dispose(),j.current===W&&(j.current=null);}},[l,P]),Et.useEffect(()=>j.current?.nudge(),[k,Y]);let me=Or(n),z=uh(U,_),ie=l&&_s(w-z,me),J=Et.useMemo(()=>!l||ie||Y===null?0:Is({viewportWidth:w,pageWidthPx:Math.max(D??0,Ne(Y))*C,reservation:me,inlineEndReservation:_,inlineStartReservation:M,docked:S}),[l,ie,Y,D,C,w,me,_,M,S]);return Et.useEffect(()=>{if(y)return y.setShift(J),()=>y.setShift(0)},[y,J]),Et.useEffect(()=>{if(y)return y.setReservation(l&&!ie?me:0),()=>y.setReservation(0)},[y,l,ie,me]),{open:l,setOpen:m,toggle:p,tab:c,setTab:v,paneWidth:n,shift:J,overlay:ie}}var vi=["headings","find"],io=(...e)=>e.filter(Boolean).join(" ");function yi({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:io("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xi,{}),jsxRuntime.jsx(Ci,{})]})})}function xi({className:e,style:t,children:o}){let{intents:n,t:r}=Vo("Close");return jsxRuntime.jsx("button",{type:"button",className:io("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:n.close,children:o??jsxRuntime.jsx($,{name:"arrow_back",size:20})})}function Ci({className:e,style:t,children:o}){let{t:n}=Vo("Title");return jsxRuntime.jsx("h2",{className:io("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function Ti({className:e,style:t,children:o}){let{pane:n,t:r}=Vo("Tabs"),i=Et.useCallback(a=>{let s=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(s===0)return;a.preventDefault();let l=vi.indexOf(n.tab);n.setTab(vi[(l+s+vi.length)%vi.length]);},[n]);return jsxRuntime.jsx("div",{className:io("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??vi.map(a=>jsxRuntime.jsx(Pi,{value:a},a))})}function Pi({value:e,className:t,style:o,children:n}){let{pane:r,t:i}=Vo("Tab"),a=r.tab===e;return jsxRuntime.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:io("docx-nav__tab",a&&"docx-nav__tab--selected",t),style:o,onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function Ev({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:s}){let l=Et.useRef(null);return Et.useEffect(()=>{a&&l.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx($,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:l,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:c=>t(c.target.value),onKeyDown:c=>{!s||c.key!=="Enter"||c.nativeEvent.isComposing||(c.preventDefault(),s(c.shiftKey));}}),e.length>0&&jsxRuntime.jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsxRuntime.jsx($,{name:"close",size:16})})]})}function Si({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=Vo("Headings"),[a,s]=Et.useState(""),l=B(In),c=Et.useMemo(()=>{let f=a.trim().toLowerCase();return f.length===0?n.items:n.items.filter(u=>u.heading.text.toLowerCase().includes(f))},[n.items,a]),d=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:io("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsxRuntime.jsx(Ev,{value:a,onChange:s,onClear:()=>s(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),l?null:n.isEmpty?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.headings.noHeadings")}):c.length===0?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.find.noResults")}):jsxRuntime.jsx("ul",{className:"docx-nav__list",children:c.map((f,u)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:io("docx-nav__heading",n.selectedBlockId===f.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+f.depth*14}px`},title:f.heading.text,onClick:()=>{n.goTo(f.heading.blockId),r.picked();},children:f.heading.text})},`${f.heading.blockId}-${u}`))})]})}function x8({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:io("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsxRuntime.jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function Ei({className:e,style:t}){let{pane:o,search:n,intents:r,t:i}=Vo("Find"),a=o.tab!=="find",s=n.query.trim().length>0,l=o.open&&!a,c=n.matches.length===0?null:n.activeIndex<0?i(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):i(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxRuntime.jsxs("div",{className:io("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsxRuntime.jsx(Ev,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:l,onEnter:d=>{n.isPending&&n.find(n.query),d?n.previous():n.next();}}),jsxRuntime.jsxs("div",{className:"docx-nav__options",role:"group","aria-label":i("navigation.find.optionsAriaLabel"),children:[jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.matchCase,onChange:d=>n.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:d=>n.setWholeWord(d.target.checked)}),i("navigation.find.wholeWord")]})]}),jsxRuntime.jsxs("div",{className:"docx-nav__resultbar",children:[jsxRuntime.jsx("span",{className:"docx-nav__count","aria-live":"polite",children:s?n.isPending?i("navigation.find.searching"):c??i("navigation.find.noResults"):""}),jsxRuntime.jsxs("span",{className:"docx-nav__steppers",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsxRuntime.jsx($,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsxRuntime.jsx($,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:n.matches.map((d,f)=>jsxRuntime.jsx(x8,{match:d,active:f===n.activeIndex,onSelect:()=>{n.goTo(f),r.picked();}},`${d.blockId}-${d.start}-${f}`))})]})}function wi({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=Vo("Toggle"),l=Do()("Ctrl+F"),c=i?bv(l):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:l}):a("navigation.openTitle");return jsxRuntime.jsx("button",{type:"button",className:io("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":n.open,"aria-keyshortcuts":c,title:d,onMouseDown:f=>f.preventDefault(),onClick:r.toggle,children:o??jsxRuntime.jsx($,{name:"toc",size:20})})}function Bp(e){let t=Tt(),{t:o,toggle:n=true,searchHighlight:r="all",findShortcut:i=true,className:a,style:s,children:l,...c}=e,d=Fs(c),f=Ns(),u=d.open&&d.tab==="find"?r:"none",g=Ls({highlight:u}),m=Ue(),p=Et.useMemo(()=>o??((b,h)=>m(b,h)),[o,m]),v=Tv(d,i),y=Et.useMemo(()=>({pane:d,outline:f,search:g,t:p,intents:v.intents,findShortcut:i}),[d,f,g,p,v.intents,i]),x=e.paneWidth??280;return jsxRuntime.jsx(Np.Provider,{value:y,children:jsxRuntime.jsxs("div",{ref:v.rootRef,className:`${t}docx-nav${d.open?" docx-nav--open":""}${d.overlay?" docx-nav--overlay":""}${a?` ${a}`:""}`,"data-open":d.open?"true":"false",onKeyDown:v.onKeyDown,style:{"--docx-nav-width":`${x}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Or(x)}px`,...s},children:[n!==false&&!d.open&&jsxRuntime.jsx(wi,{...typeof n=="object"?n:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":y.t("navigation.ariaLabel"),inert:!d.open,children:l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(yi,{}),jsxRuntime.jsx(Ti,{}),jsxRuntime.jsx(Si,{}),jsxRuntime.jsx(Ei,{})]})})]})})}var Hs=Object.assign(Bp,{Header:yi,Close:xi,Title:Ci,Tabs:Ti,Tab:Pi,Headings:Si,Find:Ei,Toggle:wi});var M8=600,R8=e=>e.isOpening===true?0:e.page.total,As=Et.createContext(null);function Os({className:e,style:t}){let o=Tt(),n=H(),r=Ye(),{inside:i,host:a,hostScoped:s}=gh(r),l=B(R8),{t:c}=N(),d=Et.useContext(As),[f,u]=Et.useState(1),[g,m]=Et.useState(false);if(Et.useEffect(()=>{if(m(false),!n||!r||l<=1)return;u(n.getCurrentPage("viewport"));let x=null,b=()=>{u(n.getCurrentPage("viewport")),m(true),x&&clearTimeout(x),x=setTimeout(()=>m(false),M8);};return r.addEventListener("scroll",b,{passive:true}),()=>{r.removeEventListener("scroll",b),x&&clearTimeout(x);}},[n,l,r]),l<=1)return null;let p=a?s?"":"docx-editor ":o,v=d?d("viewer.pageIndicator").replace(/\{current\}/g,String(f)).replace(/\{total\}/g,String(l)):c("viewer.pageIndicator",{current:f,total:l}),y=jsxRuntime.jsx("div",{className:`${p}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":g?"true":"false",role:"status","aria-live":"polite",children:v});return i?a?reactDom.createPortal(y,a):null:y}var I8=[],_8=e=>e.fontSubstitutions??I8;function Bs({className:e,style:t,t:o}){let n=B(_8),{t:r}=N(),i=o??r,[a,s]=Et.useState(null);if(n.length===0)return null;let l=n.join("\0");return a===l?null:jsxRuntime.jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsxRuntime.jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:n.join(", ")}).replace("{fonts}",n.join(", "))}),jsxRuntime.jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>s(l),children:i("common.dismiss")})]})}function Zp(e){return Math.round(e/1440*100)/100}function Dv(e){return Math.round(e*1440)}function F8(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 qp(){let e=H(),t=Et.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return B(t,F8)}function O8(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 B8=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Mi(e){let t=H();return Et.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function Z8(e){let{state:t,onMouseDown:o}=e,{t:n}=N(),r=H(),[i,a]=Et.useState(false),s=Et.useRef(null),[l,c]=Et.useState(""),[d,f]=Et.useState("");Et.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(Zp(t.headerDistanceTwips))),f(String(Zp(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),Et.useEffect(()=>{if(!i)return;let S=P=>{s.current?.contains(P.target)||a(false);};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i]);let u=Et.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=Et.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),m=Et.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),p=Et.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),v=Et.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),y=Mi(u),x=Mi(g),b=Mi(m),h=Mi(p),C=Mi(v),T=(S,P)=>{if(!r)return;let k=Number.parseFloat(P);Number.isFinite(k)&&r.exec({type:"setHeaderFooterOptions",[S]:Dv(k)});};return jsxRuntime.jsxs("div",{ref:s,className:"docx-hf-chrome__options",onMouseDown:o,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":i,"aria-haspopup":"menu",onClick:()=>a(S=>!S),onMouseDown:o,children:n("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[B8.map(S=>{let P={type:"insertPageField",field:S.field},k=r?.can(P);return jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!k?.ok,title:k&&!k.ok?k.reason:void 0,onClick:()=>{r?.exec(P),a(false);},onMouseDown:o,children:n(S.labelKey)},S.field)}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!y.enabled,title:y.reason??void 0,onChange:()=>r?.exec(u)}),jsxRuntime.jsx("span",{children:n("headerFooter.differentFirstPage")})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!x.enabled,title:x.reason??void 0,onChange:()=>r?.exec(g)}),jsxRuntime.jsxs("span",{children:[n("headerFooter.differentOddEven"),jsxRuntime.jsx("span",{className:"docx-hf-chrome__menu-hint",children:n("headerFooter.differentOddEvenHint")})]})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!h.enabled,title:h.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!b.enabled,title:b.reason??void 0,onClick:()=>r?.exec(m),onMouseDown:o,children:n("headerFooter.linkToPrevious")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.headerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.headerDistance"),value:l,onChange:S=>c(S.target.value),onBlur:()=>T("headerDistanceTwips",l)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.footerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.footerDistance"),value:d,onChange:S=>f(S.target.value),onBlur:()=>T("footerDistanceTwips",d)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>r?.exec(v),onMouseDown:o,children:t.editing==="header"?n("headerFooter.removeHeader"):n("headerFooter.removeFooter")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.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:o,children:n("common.close")})]}):null]})}function Zs({className:e}){let{t}=N(),o=qp(),n=Et.useCallback(s=>s.querySelector("[data-docx-hf-active]"),[]),r=ya(n,"story-label"),i=Z;if(!o?.editing)return null;let a=O8(o.editing,o.variant);return jsxRuntime.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:ct.hfInlineEditor},children:[jsxRuntime.jsxs("div",{className:"docx-context-bar__label",children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsxRuntime.jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsxRuntime.jsx(Z8,{state:o,onMouseDown:i})]})}var z8={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},$8={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},U8={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},V8={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},G8={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},j8={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:"var(--doc-z-overlay)",backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},Y8={padding:"8px 12px"},X8={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},J8={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},Q8={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function eI({forwardedRef:e}){let t=H(),o=Et.useRef(null);return o.current=t,bh({ref:e,editorRef:o}),null}var tI=Et.forwardRef(function(t,o){let{document:n,fonts:r,fontShaping:i,className:a,t:s,chrome:l=true,title:c,onTitleChange:d,renderTitleBarLeft:f,renderTitleBarRight:u,loadingIndicator:g,colorMode:m="light",author:p,locale:v,mode:y="edit",modules:x,zoom:b,zoomMode:h,revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,fieldResults:P,contentLockPolicy:k,lockedControlNavigation:w,onReady:E,onChange:D,onFontError:A,onOpen:_,onSave:F,hyperlinkPopup:M,contextMenu:I=true,menu:U=true,navigation:L=true,rulers:Y=true}=t;!l&&g!==void 0&&Gg();let[j,me]=Et.useState(vg);Et.useEffect(()=>{if(m==="system")return xg(me)},[m]);let z=yg(m,j),{t:ie}=N(),J=Et.useCallback((ve,de)=>s?s(ve,de):ie(ve,de),[s,ie]),W=jsxRuntime.jsxs(Zl,{className:l?z?"dark":void 0:a,style:l?$8:void 0,children:[l?jsxRuntime.jsx(Zs,{}):null,l?jsxRuntime.jsx(fl,{}):null,jsxRuntime.jsx(Ll,{}),Y&&l?jsxRuntime.jsx("div",{style:G8,children:jsxRuntime.jsx(ks,{})}):null,t.children]}),q=l?jsxRuntime.jsxs("div",{className:`docx-editor${z?" dark":""}${a?` ${a}`:""}`,style:z8,children:[jsxRuntime.jsxs("div",{style:j8,children:[jsxRuntime.jsxs("div",{style:X8,children:[f?.(),jsxRuntime.jsxs("div",{style:J8,children:[d?jsxRuntime.jsx("input",{"aria-label":J("titleBar.documentNameAriaLabel"),value:c??"",placeholder:J("titleBar.untitled"),onChange:ve=>d(ve.target.value),style:Q8}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:c??J("titleBar.untitled")}),U!==false?jsxRuntime.jsx(ci,{t:J,...c!==void 0?{fileName:c}:{},..._?{onOpen:_}:{},...F?{onSave:F}:{},...typeof U=="object"?U:{}}):null]}),u?.()]}),jsxRuntime.jsx("div",{style:Y8,children:jsxRuntime.jsx(ri,{t:J})})]}),Y?jsxRuntime.jsx("div",{style:V8,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(Rs,{})}):null,jsxRuntime.jsx(Bs,{t:J}),jsxRuntime.jsxs("div",{style:U8,children:[L===false?null:jsxRuntime.jsx(Hs,{t:J,...typeof L=="object"?L:{}}),W,jsxRuntime.jsx(As.Provider,{value:J,children:jsxRuntime.jsx(Os,{})}),jsxRuntime.jsx(Hl,{overlay:true,indicator:g})]})]}):W,fe=Et.useCallback(ve=>J(ve),[J]);return jsxRuntime.jsxs(Na,{popups:jf(t.popups,M,I,J),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...p!==void 0?{author:p}:{},...v!==void 0?{locale:v}:{},translate:J,mode:y,...x!==void 0?{modules:x}:{},...b!==void 0?{zoom:b}:{},revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,...P!==void 0?{fieldResults:P}:{},...k!==void 0?{contentLockPolicy:k}:{},...w!==void 0?{lockedControlNavigation:w}:{},...h!==void 0?{zoomMode:h}:{},tableInteractionLabel:fe,...E?{onReady:E}:{},...D?{onChange:D}:{},...A?{onFontError:A}:{},children:[jsxRuntime.jsx(eI,{forwardedRef:o}),jsxRuntime.jsx(vn.Provider,{value:l,children:q})]})}),oI=Et.forwardRef(function(t,o){return jsxRuntime.jsx(Un,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(tI,{...t,ref:o})})}),nI=Object.assign(oI,{Root:Na,Viewport:Zl,Content:Ll,Toolbar:ri,Menu:ci,Loading:Hl,ColorByChangeType:vu,RevisionMarkup:Nc,RevisionMarkupDialog:Ur,AuthorStyle:yu,HorizontalRuler:Rs,VerticalRuler:ks,DocumentOutline:_p,Navigation:Hs,ExportDialog:Vr,PrintDialog:Gr,PageSetupDialog:Sn,ParagraphDialog:xo,TextFormFieldDialog:Ma,PageNumber:Os,FontNotice:Bs,HeaderFooterChrome:Zs,NotesChrome:fl,Equation:oa,HyperLink:Jr,ContextMenu:Pd,ContentControlWidget:ru,InvalidTextFormFieldDialog:Hd,ImageAltTextPopup:Cl,ImagePropertiesDialog:Ca,NotePropertiesDialog:gl,NotePreview:jn,NotesContextMenu:Yn,ContentControl:ta});function sI(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function Wp(e){return Array.isArray(e)?e:[e]}function cI(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function Fv(e){return e!==void 0&&Wp(e).some(t=>editor.isFontResolver(t))}async function dI(e){return typeof e!="function"?await e:await e()}function uI(e,t={}){let[o,n]=Et.useState(void 0),[r,i]=Et.useState(void 0),[a,s]=Et.useState(null),[l,c]=Et.useState(e!=null),d=Fv(t.fonts),f=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=Et.useState(t.fonts===void 0),m=Et.useRef(t);m.current=t;let p=Et.useMemo(()=>editor.defineFontResolver(v=>editor.composeFontOrigins(Wp(m.current.fonts??[]).map(cI),v)),[]);return Et.useEffect(()=>{let v=m.current.fonts;if(v===void 0){i(void 0),g(true);return}if(Fv(v)){g(true);return}g(false);let y=true;return (async()=>{try{let x=await Promise.allSettled(Wp(v).map(dI)),b=[];for(let h of x){if(h.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",h.reason);continue}h.value!==void 0&&b.push(h.value);}y&&b.length>0&&i(editor.composeFontConfiguration(b[0],...b.slice(1)));}catch(x){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",x);}finally{y&&g(true);}})(),()=>{y=false;}},[f]),Et.useEffect(()=>{if(e==null){n(void 0),s(null),c(false);return}let v=sI(e);if(v){n(v),s(null),c(false);return}let y=true,x=new AbortController;return c(true),s(null),(async()=>{try{let b=await fetch(String(e),{...m.current.fetchOptions,signal:x.signal});if(!b.ok)throw new Error(`could not open the document: ${b.status} ${b.statusText}`);let h=new Uint8Array(await b.arrayBuffer());if(!y)return;n(h),c(!1);}catch(b){if(!y||b instanceof Error&&b.name==="AbortError")return;s(b instanceof Error?b:new Error("could not open the document")),c(false);}})(),()=>{y=false,x.abort();}},[e]),{document:u?o:void 0,fonts:d?p:r,error:a,isLoading:l||!u}}function hI(...e){let t=Et.useRef(e);return t.current=e,Et.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function yI(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function xI(){let e=H(),t=Et.useRef(null),o=Et.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=Et.useCallback(()=>{let r=yI(e),i=t.current;return (r===null?i===null:i!==null&&CI(i,r))?i:(t.current=r,r)},[e]);return Et.useSyncExternalStore(o,n,()=>null)}function CI(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}var Zv=Object.freeze({applied:0,unavailable:0});function qv(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:n,className:r,priority:i}=e;return JSON.stringify([t,o,n,r,i])}function EI(e,t,o){let n=H(),[r,i]=Et.useState(Zv),a=Et.useRef(null),s=Et.useRef(o);s.current=o;let l=Et.useRef(t);l.current=t;let c=qv(o);return Et.useEffect(()=>{if(!n){i(Zv);return}let d=editor.watchHighlights(n,e,l.current,{...s.current,onResult:i});return a.current={watch:d,source:l.current,key:qv(s.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),Et.useEffect(()=>{let d=a.current;!d||d.source===t&&d.key===c||(d.source=t,d.key=c,d.watch.update(t,s.current??{}));},[t,c]),r}function RI(e,t){return e===t?true:!e||!t?false:e.name===t.name&&e.index===t.index&&e.range===t.range&&e.active===t.active&&e.rect.left===t.rect.left&&e.rect.top===t.rect.top&&e.rect.width===t.rect.width&&e.rect.height===t.rect.height}function kI(e){let t=H(),[o,n]=Et.useState(null);return Et.useEffect(()=>{if(!t){n(null);return}let r=globalThis.document,i=0,a=null,s=()=>{i=0;let u=a?t.getHighlightsAt(a.x,a.y).find(g=>e===void 0||g.name===e)??null:null;n(g=>RI(g,u)?g:u);},l=()=>{i===0&&(i=requestAnimationFrame(s));},c=u=>{let g=u.target;a=g instanceof Element&&g.closest("[data-page-index]")!==null?{x:u.clientX,y:u.clientY}:null,l();},d=u=>{u.relatedTarget||(a=null,l());};r.addEventListener("pointermove",c,{passive:true}),r.addEventListener("pointerout",d,{passive:true}),r.addEventListener("scroll",l,{passive:true,capture:true});let f=t.on("change",l);return ()=>{r.removeEventListener("pointermove",c),r.removeEventListener("pointerout",d),r.removeEventListener("scroll",l,{capture:true}),f(),i!==0&&cancelAnimationFrame(i);}},[t,e]),o}function $p({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:s}){let l=Et.useRef(null),c=Et.useRef(null),[d,f]=Et.useState(null),u=Et.useRef(n);u.current=n;let g=Et.useRef(r);return g.current=r,Et.useEffect(()=>{let m=l.current;if(!m)return;let p=editor.mountPaginatedSurface(m,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:y=>{f(y),u.current?.(y);}});if(!p.ok){g.current?.(p.reason,p.detail);return}c.current=p.surface;let v=p.surface.state();return f(v),u.current?.(v),()=>{p.surface.destroy(),c.current=null;}},[e,o]),Et.useImperativeHandle(s,()=>({focus:()=>c.current?.focus(),type:m=>c.current?.type(m),undo:()=>c.current?.undo(),redo:()=>c.current?.redo(),selectAll:()=>c.current?.selectAll(),navigate:(m,p)=>c.current?.navigate(m,p),toggleRunProperty:(m,p)=>c.current?.toggleRunProperty(m,p),setRunProperty:(m,p)=>c.current?.setRunProperty(m,p),setParagraphProperty:(m,p,v)=>c.current?.setParagraphProperty(m,p,v),formatting:()=>c.current?.formatting()??null,sectionProperties:()=>c.current?.sectionProperties()??null,save:()=>c.current?.save()??null}),[]),jsxRuntime.jsx("div",{ref:l,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 ki=Et.createContext(null);function Kv(){let e=Et.useContext(ki);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function OI(e){return "type"in e&&e.type==="separator"}var $v={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"},BI={...$v,background:"var(--doc-bg-hover)"},Uv={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"},ZI={...Uv,opacity:.4,cursor:"default"},qI={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},KI={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},WI={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 Di({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=Et.useState(false),[a,s]=Et.useState(null),l=Et.useRef(null),c=Et.useRef(null),[d,f]=Et.useState({top:0,left:0}),u=Et.useCallback(()=>{i(false),s(null);},[]);Et.useEffect(()=>{if(!r||!l.current)return;let m=l.current.getBoundingClientRect();f({top:m.bottom+2,left:m.left});},[r]),Et.useEffect(()=>{if(!r)return;function m(y){let x=y.target;l.current&&!l.current.contains(x)&&c.current&&!c.current.contains(x)&&u();}function p(y){y.key==="Escape"&&u();}function v(){u();}return document.addEventListener("mousedown",m),document.addEventListener("keydown",p),window.addEventListener("scroll",v,true),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",p),window.removeEventListener("scroll",v,true);}},[r,u]);let g=m=>{m.disabled||m.submenuContent||m.onClick&&(m.onClick(),u());};return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",onClick:()=>!o&&i(!r),onMouseDown:m=>m.preventDefault(),disabled:o,style:r?BI:$v,children:[e,n&&jsxRuntime.jsx($,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:c,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:m=>m.preventDefault(),children:t.map((m,p)=>{if(OI(m))return jsxRuntime.jsx("div",{style:qI},`sep-${p}`);let v=m;if(v.customContent)return jsxRuntime.jsx("div",{onMouseDown:b=>b.preventDefault(),children:v.customContent},v.label);let y=!!v.submenuContent,x=a===v.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>y&&s(v.label),onMouseLeave:()=>y&&s(null),children:[jsxRuntime.jsxs("button",{type:"button",style:v.disabled?ZI:Uv,onClick:()=>g(v),onMouseDown:b=>b.preventDefault(),onMouseOver:b=>{v.disabled||(b.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:b=>{b.currentTarget.style.backgroundColor="transparent";},disabled:v.disabled,children:[v.icon&&jsxRuntime.jsx($,{name:v.icon,size:18}),jsxRuntime.jsx("span",{children:v.label}),v.shortcut&&jsxRuntime.jsx("span",{style:KI,children:v.shortcut}),y&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx($,{name:"keyboard_arrow_right",size:16})})]}),y&&x&&jsxRuntime.jsx("div",{style:WI,onMouseDown:b=>b.preventDefault(),children:v.submenuContent(u)})]},v.label)})})]})}var Gp=18,$I=2,Gv={width:Gp,height:Gp,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},UI={...Gv,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},VI={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function jv({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=Et.useState(0),[i,a]=Et.useState(0),s=Et.useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),l=[];for(let d=1;d<=t;d++)for(let f=1;f<=o;f++){let u=d<=n&&f<=i;l.push(jsxRuntime.jsx("div",{style:u?UI:Gv,onMouseEnter:()=>{r(d),a(f);},onClick:s,role:"gridcell","aria-selected":u},`${d}-${f}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:$I,gridTemplateColumns:`repeat(${o}, ${Gp}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:l}),jsxRuntime.jsx("div",{style:VI,children:c})]})}function XI({items:e,closeMenu:t}){return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let n=!o.onClick;return jsxRuntime.jsxs("button",{type:"button",disabled:n,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:n?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:n?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{n||(o.onClick?.(),t());},onMouseOver:r=>{n||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsxRuntime.jsx($,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function JI(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Ws({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function QI(e){return e.replace(/\.docx$/i,"")}function Yp({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=N(),i=o??r("titleBar.untitled"),a=QI(e)??"";return n?jsxRuntime.jsx("input",{type:"text",value:a,onChange:s=>{let l=s.target.value;t?.(l.endsWith(".docx")?l:l+".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")}):jsxRuntime.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 zs({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function $s(){let{t:e}=N(),t=Kv(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:s,onInsertImage:l,onInsertTable:c,showTableInsert:d=true,showHelpMenu:f=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:m,onInsertTOC:p,onWatermark:v,onRefocusEditor:y}=t,x=Et.useCallback(T=>{!o&&n&&n(T);},[o,n]),b=Et.useCallback((T,S)=>{!o&&c&&(c(T,S),requestAnimationFrame(()=>y?.()));},[o,c,y]),h=!!r||!!s,C=h||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[C&&jsxRuntime.jsx(Di,{label:e("toolbar.file"),disabled:o,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)&&h?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...s?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:s}]:[]]}),jsxRuntime.jsx(Di,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>x("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>x("setRtl")}]}),jsxRuntime.jsx(Di,{label:e("toolbar.insert"),disabled:o,items:[...l?[{icon:"image",label:e("toolbar.image"),onClick:l}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:T=>jsxRuntime.jsx(jv,{onInsert:(S,P)=>{b(S,P),T();}})}]:[],...l||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:T=>jsxRuntime.jsx(XI,{closeMenu:T,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:m}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:p,disabled:!p},...v?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:v}]:[]]}),f&&jsxRuntime.jsx(Di,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>ii()}]})]})}function Xp({children:e}){let t=null,o=null,n=[],r=[];Et.Children.forEach(e,a=>{Et.isValidElement(a)&&(a.type===Ws?t=a:a.type===zs?o=a:a.type===$s?r.push(a):n.push(a));});let i=Et.useCallback(a=>{let s=a.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(JI,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[n.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:n}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),o&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var Us={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},n_={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:""},Yv={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 r_(e,t){let o=Yv[t]??Yv[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:Us[o]??"000000"}function Xv(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(o=>o+o).join("")}function Jp(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${Xv(e.value)??o}`;let n=Object.entries(t?.colorScheme??Us).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:r_(t,e.slot)}`}function So(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?Xv(e.value):Jp(e,t).slice(1)}function Jv(e){if(!e||e==="none")return "";let t=n_[e];return t?`#${t}`:""}var a_=[{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"}],i_=[{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 Qv(e){let t=e??Us;return i_.map(o=>a_.map(n=>{let r=t[n.slot]??Us[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?editor.applyThemeTint(r,o.keep):editor.applyThemeShade(r,o.keep),themeSlot:n.slot,label:`${n.name}${o.labelSuffix}`};return o.type==="tint"?a.tint=o.keep:o.type==="shade"&&(a.shade=o.keep),a}))}function le(...e){return clsx.clsx(e)}var c_=classVarianceAuthority.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"}}),Xe=Et__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:le(c_({variant:t,size:o,className:e})),ref:r,...n}));Xe.displayName="Button";function It({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=Et__namespace.useState(false),[a,s]=Et__namespace.useState({x:0,y:0}),l=Et__namespace.useRef(null),c=Et__namespace.useRef(null),d=Et__namespace.useCallback(()=>{c.current=setTimeout(()=>{if(l.current){let m=l.current.getBoundingClientRect(),p=m.left+m.width/2,v=o==="top"?m.top-8:m.bottom+8;s({x:p,y:v});}i(true);},n);},[n,o]),f=Et__namespace.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null),i(false);},[]);Et__namespace.useEffect(()=>()=>{c.current&&clearTimeout(c.current);},[]);let u=t.props,g=Et__namespace.cloneElement(t,{ref:l,onMouseEnter:m=>{d(),u.onMouseEnter?.(m);},onMouseLeave:m=>{f(),u.onMouseLeave?.(m);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g,r&&jsxRuntime.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:o==="top"?"translate(-50%, -100%)":o==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var Go=we__namespace.Root,jo=we__namespace.Group,Vs=we__namespace.Value;function Yo({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(we__namespace.Trigger,{className:le("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(),o?.(r);},...n,children:[t,jsxRuntime.jsx(we__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(f_,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Xo({className:e,children:t,position:o="popper",onCloseAutoFocus:n,...r}){let i=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsxRuntime.jsx(we__namespace.Portal,{children:jsxRuntime.jsx("div",{className:le("docx-editor",i&&"dark"),children:jsxRuntime.jsx(we__namespace.Content,{className:le("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",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:o,onCloseAutoFocus:a=>{a.preventDefault(),n?.(a);},...r,children:jsxRuntime.jsx(we__namespace.Viewport,{className:le("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:a=>a.preventDefault(),children:t})})})})}function Fn({className:e,...t}){return jsxRuntime.jsx(we__namespace.Label,{className:le("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function _t({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(we__namespace.Item,{className:le("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(),o?.(r);},...n,children:[jsxRuntime.jsx(we__namespace.ItemText,{children:t}),jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(we__namespace.ItemIndicator,{children:jsxRuntime.jsx(g_,{className:"h-4 w-4"})})})]})}function Hn({className:e,...t}){return jsxRuntime.jsx(we__namespace.Separator,{className:le("-mx-1 my-1 h-px bg-muted",e),...t})}function f_({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.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 g_({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.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 Qp(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var h_=[{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 oy({value:e,onChange:t,fonts:o=h_,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:s=120,showPreview:l=true}){let{t:c}=N(),d=Et__namespace.useMemo(()=>{if(!n)return [];let p=new Set(o.map(v=>v.name.toLowerCase()));return n.filter(v=>!p.has(v.name.toLowerCase()))},[n,o]),f=Et__namespace.useMemo(()=>[...d,...o],[d,o]),u=Et__namespace.useMemo(()=>e?f.find(v=>v.fontFamily===e||v.name.toLowerCase()===e.toLowerCase()||Qp(v.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,f,a]),g=Et__namespace.useCallback(p=>{let v=f.find(y=>y.name===p);v&&t?.(Qp(v.fontFamily)||v.name);},[t,f]),m=Et__namespace.useMemo(()=>{let p={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(v=>{let y=v.category||"other";p[y].push(v);}),p},[o]);return jsxRuntime.jsxs(Go,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(Yo,{className:le("h-8 text-sm",i),style:{minWidth:typeof s=="number"?`${s}px`:s},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(Vs,{placeholder:a,children:u})}),jsxRuntime.jsxs(Xo,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(jo,{children:[jsxRuntime.jsx(Fn,{children:c("font.documentFonts")}),d.map(p=>jsxRuntime.jsx(_t,{value:p.name,style:l?{fontFamily:p.fontFamily}:void 0,children:p.name},`doc-${p.name}`))]}),jsxRuntime.jsx(Hn,{})]}),m["sans-serif"].length>0&&jsxRuntime.jsxs(jo,{children:[jsxRuntime.jsx(Fn,{children:c("font.sansSerif")}),m["sans-serif"].map(p=>jsxRuntime.jsx(_t,{value:p.name,style:l?{fontFamily:p.fontFamily}:void 0,children:p.name},p.name))]}),m.serif.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hn,{}),jsxRuntime.jsxs(jo,{children:[jsxRuntime.jsx(Fn,{children:c("font.serif")}),m.serif.map(p=>jsxRuntime.jsx(_t,{value:p.name,style:l?{fontFamily:p.fontFamily}:void 0,children:p.name},p.name))]})]}),m.monospace.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hn,{}),jsxRuntime.jsxs(jo,{children:[jsxRuntime.jsx(Fn,{children:c("font.monospace")}),m.monospace.map(p=>jsxRuntime.jsx(_t,{value:p.name,style:l?{fontFamily:p.fontFamily}:void 0,children:p.name},p.name))]})]}),m.other.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hn,{}),jsxRuntime.jsx(jo,{children:m.other.map(p=>jsxRuntime.jsx(_t,{value:p.name,style:l?{fontFamily:p.fontFamily}:void 0,children:p.name},p.name))})]})]})]})}function em(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);if(mt()){let o=new Set,n=new Set;for(let r of t)n.has(r.name)&&!o.has(r.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${r.name}"`),o.add(r.name)),n.add(r.name);}return t}function y_(e,t,o,n){let i=Math.max(8,window.innerWidth-o-8),a=Math.max(8,window.innerHeight-n-8);return {top:Math.min(Math.max(8,e),a),left:Math.min(Math.max(8,t),i)}}function vt({isOpen:e,onClose:t,align:o="left"}){let n=Et.useRef(null),r=Et.useRef(null),[i,a]=Et.useState({top:0,left:0});Et.useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();o==="right"?requestAnimationFrame(()=>{if(r.current){let d=r.current.getBoundingClientRect(),f=y_(c.bottom+4,c.right-d.width,d.width,d.height);a(f);}else a({top:c.bottom+4,left:c.left});}):a({top:c.bottom+4,left:c.left});},[e,o]),Et.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=g=>{let m=g.target;n.current&&!n.current.contains(m)&&r.current&&!r.current.contains(m)&&t();},f=g=>{g.key==="Escape"&&t();},u=g=>{if(performance.now()<c)return;let m=g.target;m&&r.current&&r.current.contains(m)||m instanceof Element&&m!==document.documentElement&&m!==document.body&&n.current&&m.contains(n.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),window.addEventListener("scroll",u,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f),window.removeEventListener("scroll",u,true);}},[e,t]);let s=Et.useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),l={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:n,dropdownRef:r,dropdownStyle:l,handleMouseDown:s}}var T_=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],P_=1,S_=400;function ay(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function iy(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function ly({value:e,onChange:t,sizes:o=T_,disabled:n=false,className:r,placeholder:i="11",minSize:a=P_,maxSize:s=S_}){let{t:l}=N(),[c,d]=Et.useState(false),[f,u]=Et.useState(""),[g,m]=Et.useState(false),p=Et.useRef(null),v=Et.useCallback(()=>{m(false),d(false);},[]),{containerRef:y,dropdownRef:x,dropdownStyle:b}=vt({isOpen:g,onClose:v}),h=e??(parseInt(i,10)||11),C=e!==void 0?e.toString():i,T=Et.useCallback(_=>{if(_.preventDefault(),n)return;let F=iy(h,o,a);t?.(F);},[h,o,a,n,t]),S=Et.useCallback(_=>{if(_.preventDefault(),n)return;let F=ay(h,o,s);t?.(F);},[h,o,s,n,t]),P=Et.useCallback(_=>{_.preventDefault(),!n&&(d(true),u(C),m(true),requestAnimationFrame(()=>{p.current?.focus(),p.current?.select();}));},[n,C]),k=Et.useCallback(_=>{u(_.target.value);},[]),w=Et.useCallback(()=>{d(false);let _=parseFloat(f);if(!isNaN(_)&&_>=a&&_<=s){let F=Math.round(_*2)/2;t?.(F);}},[f,a,s,t]),E=Et.useCallback(_=>{if(_.key==="Enter")_.preventDefault(),w(),m(false);else if(_.key==="Escape")d(false),m(false);else if(_.key==="ArrowUp"){_.preventDefault();let F=ay(h,o,s);u(F.toString()),t?.(F);}else if(_.key==="ArrowDown"){_.preventDefault();let F=iy(h,o,a);u(F.toString()),t?.(F);}},[w,h,o,s,a,t]),D=Et.useCallback(_=>{t?.(_),m(false),d(false);},[t]),A=Et.useCallback(_=>{_.target.tagName!=="INPUT"&&_.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:y,className:le("flex items-center",r),onMouseDown:A,children:[jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:T,disabled:n||h<=a,"aria-label":l("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx($,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:p,type:"text",value:f,onChange:k,onBlur:w,onKeyDown:E,className:le("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":l("fontSize.label"),"data-testid":"font-size-input"}):jsxRuntime.jsx("button",{type:"button",onClick:P,className:le("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",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":l("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:C})}),g&&jsxRuntime.jsx("div",{ref:x,style:{...b,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":l("fontSize.listLabel"),children:o.map(_=>jsxRuntime.jsx("button",{type:"button",onClick:()=>D(_),className:le("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",_===h&&"bg-muted font-medium"),role:"option","aria-selected":_===h,children:_},_))}),jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:S,disabled:n||h>=s,"aria-label":l("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx($,{name:"add",size:18})})]})}var M_=[{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"}],js=18,R_=2,k_={position:"relative",display:"inline-block"},D_={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)"},I_={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},nm={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},rm={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},dy={display:"grid",gap:`${R_}px`},Ys={width:`${js}px`,height:`${js}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},uy={...Ys,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},py={...Ys,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},__={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)"},N_={display:"flex",alignItems:"center",gap:"6px"},L_={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},F_={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},sy={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},H_={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},A_={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)"},O_={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 am(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=Jv(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Jp(e,o)}function cy(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function my(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():So(e,o))===t.toUpperCase():false}function B_({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=Et.useState(null);return jsxRuntime.jsx("div",{style:{...dy,gridTemplateColumns:`repeat(10, ${js}px)`},children:e.flatMap((a,s)=>a.map((l,c)=>{let d=`${s}-${c}`,f=r===d,u=my(t,l.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?py:f?uy:Ys,backgroundColor:`#${l.hex}`},title:l.label,"aria-label":l.label,"aria-selected":u,onClick:()=>n(l),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function Z_({selectedColor:e,theme:t,onSelect:o}){let[n,r]=Et.useState(null),{t:i}=N();return jsxRuntime.jsx("div",{style:{...dy,gridTemplateColumns:`repeat(10, ${js}px)`},children:M_.map((a,s)=>{let l=n===s,c=my(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?py:l?uy:Ys,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:f=>f.preventDefault(),onMouseEnter:()=>r(s),onMouseLeave:()=>r(null)},a.hex)})})}function Bn({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:s,icon:l,autoLabel:c,splitButton:d=true,defaultColor:f}){let[u,g]=Et.useState(false),[m,p]=Et.useState(false),[v,y]=Et.useState(false),[x,b]=Et.useState(false),[h,C]=Et.useState(""),[T,S]=Et.useState(()=>f??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:P}=N();Et.useEffect(()=>{let W=am(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(W)&&C(W.toUpperCase());},[t,e,n]);let k=Et.useCallback(()=>g(false),[]),{containerRef:w,dropdownRef:E,dropdownStyle:D}=vt({isOpen:u,onClose:k}),A=n?.colorScheme??null,_=Et.useMemo(()=>Qv(A),[A]),F=Et.useMemo(()=>am(t,e,n),[t,e,n]),M=Et.useMemo(()=>am(T,e,n),[T,e,n]),I=Et.useCallback(()=>{r||g(W=>!W);},[r]),U=Et.useCallback(W=>{let q;e==="highlight"?q=W.hex:q={kind:"theme",slot:W.themeSlot,...W.tint!==void 0?{tint:W.tint}:{},...W.shade!==void 0?{shade:W.shade}:{}},S(q),o?.(q),g(false);},[e,o]),L=Et.useCallback(W=>{let q=e==="highlight"?W:{kind:"hex",value:W};S(q),o?.(q),g(false);},[e,o]),Y=Et.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),j=Et.useCallback(()=>{let W=h.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(W)){let q=e==="highlight"?W:{kind:"hex",value:W};S(q),o?.(q),g(false),C("");}},[e,h,o]),me=Et.useCallback(()=>{r||o?.(T);},[r,T,o]),z={...D_,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:m?{backgroundColor:"var(--doc-bg-hover)"}:{}},ie=P(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),J=l??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:w,className:`docx-color-picker ${i||""}`,style:{...k_,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...H_,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...A_,...r?{cursor:"default"}:v?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:me,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:s||ie,"aria-label":s||ie,children:[jsxRuntime.jsx($,{name:J,size:18}),jsxRuntime.jsx("div",{style:{...sy,backgroundColor:M==="transparent"?"#fff":M,outline:M==="transparent"||cy(M)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...O_,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:x?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:I,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),disabled:r,title:s||ie,"aria-label":s||ie,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx($,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:z,onClick:I,onMouseDown:W=>W.preventDefault(),onMouseEnter:()=>p(true),onMouseLeave:()=>p(false),disabled:r,title:s||ie,"aria-label":s||ie,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx($,{name:J,size:18}),jsxRuntime.jsx("div",{style:{...sy,backgroundColor:F==="transparent"?"#fff":F,outline:F==="transparent"||cy(F)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:E,className:"docx-color-picker-dropdown",style:{...D,...I_},role:"dialog","aria-label":`${ie} picker`,onMouseDown:W=>{W.target.tagName!=="INPUT"&&W.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:__,onClick:Y,onMouseDown:W=>W.preventDefault(),children:[e==="highlight"?jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsxRuntime.jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??P(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:rm}),jsxRuntime.jsx("div",{style:nm,children:P("colorPicker.themeColors")}),jsxRuntime.jsx(B_,{matrix:_,selectedColor:t,theme:n,onSelect:U}),jsxRuntime.jsx("div",{style:rm}),jsxRuntime.jsx("div",{style:nm,children:P("colorPicker.standardColors")}),jsxRuntime.jsx(Z_,{selectedColor:t,theme:n,onSelect:L}),jsxRuntime.jsx("div",{style:rm}),jsxRuntime.jsx("div",{style:nm,children:P("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:N_,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:L_,value:h,onChange:W=>C(W.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:W=>{W.key==="Enter"&&j();},onMouseDown:W=>{W.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...F_,opacity:/^[0-9A-Fa-f]{6}$/.test(h)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(h)?"pointer":"default"},onClick:j,onMouseDown:W=>W.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(h),children:P("common.apply")})]})]})})]})}var _i=20,im=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx($,{name:"format_align_left",size:_i}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx($,{name:"format_align_center",size:_i}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx($,{name:"format_align_right",size:_i}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx($,{name:"format_align_justify",size:_i}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function hy({value:e="left",onChange:t,disabled:o=false}){let{t:n}=N(),[r,i]=Et.useState(false),a=Et.useCallback(()=>i(false),[]),{containerRef:s,dropdownRef:l,dropdownStyle:c,handleMouseDown:d}=vt({isOpen:r,onClose:a}),f=Et.useCallback(y=>{o||t?.(y),i(false);},[o,t]),u=im.find(y=>y.value===e)||im[0],g=n(u.labelKey),m=u.shortcutKey?n(u.shortcutKey):void 0,p=`${g}${m?` (${m})`:""}`,v=jsxRuntime.jsxs(Xe,{variant:"ghost",size:"icon-sm",className:le("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(y=>!y),disabled:o,"aria-label":p,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx($,{name:u.iconName,size:_i}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[r?v:jsxRuntime.jsx(It,{content:p,children:v}),r&&!o&&jsxRuntime.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:y=>y.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:im.map(y=>{let x=e===y.value,b=n(y.labelKey),h=y.shortcutKey?n(y.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${b}${h?` (${h})`:""}`,"data-testid":`alignment-${y.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{x||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:C=>{C.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>f(y.value),children:jsxRuntime.jsx($,{name:y.iconName,size:18})},y.value)})})})]})}function Xs(){return {type:"none",level:0,isInList:false}}var $_={display:"inline-flex",alignItems:"center",gap:"4px"},by={display:"inline-flex",alignItems:"center",gap:"4px"},tc={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)"},U_={...tc,backgroundColor:"var(--doc-bg-hover)"},V_={...tc,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},G_={...tc,cursor:"default",opacity:.38},j_={width:"28px",height:"28px",padding:"2px"},Y_={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Js=20;function Qs({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[s,l]=Et.useState(false),c={...t?G_:e?V_:s?U_:tc,...a},d=f=>{f.preventDefault();};return jsxRuntime.jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:c,onMouseDown:d,onClick:t?void 0:n,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function vy({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:s,showIndentButtons:l=true,compact:c=false,hasIndent:d=false}){let{t:f}=N(),u=Et.useCallback(()=>c?{...j_}:{},[c]),g=e?.type==="bullet",m=e?.type==="numbered",v=(e?.isInList||g||m)&&(e?.level??0)>0||d;return jsxRuntime.jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...$_,...s},role:"group","aria-label":f("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:by,role:"group","aria-label":f("lists.typeAriaLabel"),children:[jsxRuntime.jsx(Qs,{active:g,disabled:i,title:f("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx($,{name:"format_list_bulleted",size:Js})}),jsxRuntime.jsx(Qs,{active:m,disabled:i,title:f("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx($,{name:"format_list_numbered",size:Js})})]}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:Y_,role:"separator"}),jsxRuntime.jsxs("div",{style:by,role:"group","aria-label":f("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(Qs,{active:false,disabled:i||!v,title:f("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx($,{name:"format_indent_decrease",size:Js})}),jsxRuntime.jsx(Qs,{active:false,disabled:i,title:f("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx($,{name:"format_indent_increase",size:Js})})]})]})]})}var J_=[{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 xy({value:e,onChange:t,options:o=J_,disabled:n=false,className:r}){let{t:i}=N(),a=Et__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),s=Et__namespace.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),l=c=>c.labelKey?i(c.labelKey):c.label;return jsxRuntime.jsxs(Go,{value:a.twipsValue.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Yo,{className:le("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:l(a)}),children:jsxRuntime.jsx(Dp,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Xo,{children:[o.map(c=>jsxRuntime.jsx(_t,{value:c.twipsValue.toString(),children:l(c)},c.twipsValue)),jsxRuntime.jsx(Hn,{}),jsxRuntime.jsx(jo,{children:jsxRuntime.jsx(Fn,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var Cy=[{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 Ty({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=N(),s=Et__namespace.useMemo(()=>{let g=k0(o);return g.length===0?Cy:g.map(m=>({...m,type:"paragraph",nameKey:Cy.find(p=>p.styleId===m.styleId)?.nameKey}))},[o]),l=Et__namespace.useCallback(g=>{t?.(g);},[t]),c=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",f=s.find(g=>g.styleId===d),u=f?c(f):d;return jsxRuntime.jsxs(Go,{value:d,onValueChange:l,disabled:n,children:[jsxRuntime.jsx(Yo,{className:le("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsxRuntime.jsx("span",{className:"truncate",children:u})}),jsxRuntime.jsx(Xo,{className:"min-w-[260px] max-h-[400px]",children:s.map(g=>jsxRuntime.jsx(_t,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:R0(g),children:c(g)})},g.styleId))})]})}var e5=[{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 Sy({value:e=1,onChange:t,levels:o=e5,disabled:n=false,className:r,compact:i=false}){let{t:a}=N(),s=Et__namespace.useMemo(()=>{let g=o.find(m=>Math.abs(m.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),l=Et__namespace.useCallback(g=>{let m=parseFloat(g);isNaN(m)||t?.(m);},[t]),c=Et__namespace.useMemo(()=>[...o].sort((g,m)=>g.value-m.value),[o]),d=Et__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),f=Et__namespace.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsxRuntime.jsx($,{name:"remove",size:18})}),jsxRuntime.jsxs(Go,{value:e.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(Yo,{className:le(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:s}),children:jsxRuntime.jsx(Vs,{placeholder:"100%",children:s})}),jsxRuntime.jsx(Xo,{children:o.map(g=>jsxRuntime.jsx(_t,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!f)&&"opacity-30 cursor-not-allowed"),onClick:()=>f&&t?.(f.value),disabled:n||!f,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx($,{name:"add",size:18})})]})}var o5=[{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 My({onAction:e,disabled:t=false}){let{t:o}=N(),[n,r]=Et.useState(false),i=Et.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:s,dropdownStyle:l,handleMouseDown:c}=vt({isOpen:n,onClose:i}),d=Et.useCallback(u=>{e(u),r(false);},[e]),f=jsxRuntime.jsxs(Xe,{variant:"ghost",size:"icon-sm",className:le("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsxRuntime.jsx($,{name:"border_all",size:20}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?f:jsxRuntime.jsx(It,{content:o("table.borders.tooltip"),children:f}),n&&!t&&jsxRuntime.jsx("div",{ref:s,style:{...l,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:u=>u.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:o5.map(({action:u,icon:g,labelKey:m})=>jsxRuntime.jsx("button",{type:"button",title:o(m),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:p=>p.preventDefault(),onMouseEnter:p=>{p.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsxRuntime.jsx($,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function Ry({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=N(),i=Et.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let s=a.kind==="auto"?"000000":So(a,o);s&&e({type:"borderColor",color:s});},[e,o]);return jsxRuntime.jsx(Bn,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var i5=[{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 Dy({onAction:e,disabled:t=false}){let[o,n]=Et.useState(false),{t:r}=N(),i=Et.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:s,dropdownStyle:l,handleMouseDown:c}=vt({isOpen:o,onClose:i}),d=Et.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),f=jsxRuntime.jsxs(Xe,{variant:"ghost",size:"icon-sm",className:le("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsxRuntime.jsx($,{name:"line_weight",size:20}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?f:jsxRuntime.jsx(It,{content:r("table.borderWidth"),children:f}),o&&!t&&jsxRuntime.jsx("div",{ref:s,style:{...l,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:u=>u.stopPropagation(),children:i5.map(({size:u,label:g,thickness:m})=>jsxRuntime.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:p=>p.preventDefault(),onMouseEnter:p=>{p.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:[jsxRuntime.jsx("div",{style:{width:50,height:Math.max(m,1),backgroundColor:"#000",borderRadius:m>2?1:0}}),jsxRuntime.jsx("span",{children:g})]},u))})]})}function _y({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=N(),i=Et.useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsxRuntime.jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsxRuntime.jsx(Bn,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var s5={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"},Kn={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},Fy={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function Hy({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=N(),[r,i]=Et.useState(false),[a,s]=Et.useState(null),l=Et.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:f,handleMouseDown:u}=vt({isOpen:r,onClose:l,align:"right"}),g=o?.table?.attrs?.justification??"left",m=Et.useCallback(y=>{e(y),i(false);},[e]),p=(y,x,b,h,C)=>{let T=t||C?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...s5,backgroundColor:a===y&&!T?"var(--doc-bg-hover)":"transparent",color:T?"var(--doc-text-muted)":C?.danger?"var(--doc-error)":"var(--doc-text)",cursor:T?"not-allowed":"pointer"},onClick:()=>!T&&m(h),onMouseEnter:()=>s(y),onMouseLeave:()=>s(null),disabled:T,children:[jsxRuntime.jsx($,{name:x,size:16,className:C?.danger&&!T?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:b})]},y)},v=jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(y=>!y),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx($,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?v:jsxRuntime.jsx(It,{content:n("table.moreOptions"),children:v}),r&&!t&&jsxRuntime.jsxs("div",{ref:d,style:{...f,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:y=>y.stopPropagation(),children:[p("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),p("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),p("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),p("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),p("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),p("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),p("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),p("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),p("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),p("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),jsxRuntime.jsx("div",{style:Fy,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(y=>{let x={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsxRuntime.jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},onClick:()=>m({type:"cellVerticalAlign",align:y}),children:jsxRuntime.jsx($,{name:x[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),jsxRuntime.jsx("div",{style:Fy,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(y=>{let x={left:"format_align_left",center:"format_align_center",right:"format_align_right"},b=g===y;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:b?"var(--doc-primary-light)":"transparent",borderColor:b?"var(--doc-primary)":"var(--doc-border)",color:b?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onClick:()=>m({type:"tableProperties",props:{justification:y}}),children:jsxRuntime.jsx($,{name:x[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),p("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),p("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),p("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),p("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:Kn,role:"separator"}),p("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var d5=20;function rc({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:s,showLabels:l=false}){let[c,d]=Et.useState(false),f=Et.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:m,handleMouseDown:p}=vt({isOpen:c,onClose:f}),v=Et.useCallback(x=>{i||r(x),d(false);},[i,r]),y=jsxRuntime.jsxs(Xe,{variant:"ghost",size:"icon-sm",className:le("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:p,onClick:()=>!i&&d(x=>!x),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":s,children:[jsxRuntime.jsx($,{name:o,size:d5}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?y:jsxRuntime.jsx(It,{content:n,children:y}),c&&!i&&jsxRuntime.jsx("div",{ref:g,style:{...m,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:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:l?"column":"row",gap:l?1:2,minWidth:l?200:void 0},children:e.map(x=>{let b=t===x.value;return jsxRuntime.jsxs("button",{type:"button",title:x.label,"data-testid":s?`${s}-${x.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:b?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:b?"var(--doc-primary)":"var(--doc-text)",...l?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{b||(h.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=b?"var(--doc-primary-light)":"transparent";},onClick:()=>v(x.value),children:[jsxRuntime.jsx($,{name:x.iconName,size:18}),l&&jsxRuntime.jsx("span",{style:{flex:1},children:x.label})]},x.value)})})})]})}var u5=[{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 p5(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function Oy({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=N(),r=u5.map(s=>({...s,label:n(s.labelKey)})),i=p5(e),a=r.find(s=>s.value===i)||r[0];return jsxRuntime.jsx(rc,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var f5=[{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 By({onTransform:e,disabled:t=false}){let{t:o}=N(),n=f5.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(rc,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var Vt=18;function Nt({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let s=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),l=d=>{d.preventDefault();},c=jsxRuntime.jsx(Xe,{variant:"ghost",size:"icon-sm",className:le("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:l,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":s?`toolbar-${s}`:void 0,children:r});return o?jsxRuntime.jsx(It,{content:o,children:c}):c}function Gt({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:le("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",o),role:"group","aria-label":e,children:t})}function y5(e){let t=Et__namespace.default.useContext(ki);return t?{...t,...x5(e)}:e}function x5(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function dm(e){let{t}=N(),o=y5(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:s=false,canRedo:l=false,disabled:c=false,className:d,style:f,enableShortcuts:u=true,editorRef:g,children:m,showFontPicker:p=true,fontFamilies:v,documentFonts:y,showFontSizePicker:x=true,showTextColorPicker:b=true,showHighlightColorPicker:h=true,showAlignmentButtons:C=true,showListButtons:T=true,showLineSpacingPicker:S=true,showStylePicker:P=true,documentStyles:k,theme:w,showZoomControl:E=true,zoom:D,onZoomChange:A,onRefocusEditor:_,imageContext:F,onImageWrapType:M,onImageTransform:I,onOpenImageProperties:U,tableContext:L,onTableAction:Y,inline:j=false}=o,me=Et.useRef(null),z=Et.useCallback(ne=>{!c&&r&&r(ne);},[c,r]),ie=Et.useCallback(()=>{!c&&s&&i&&i();},[c,s,i]),J=Et.useCallback(()=>{!c&&l&&a&&a();},[c,l,a]),W=Et.useCallback(ne=>{!c&&r&&r({type:"fontFamily",value:ne});},[c,r]),q=Et__namespace.default.useMemo(()=>em(v),[v]),fe=Et.useCallback(ne=>{!c&&r&&r({type:"fontSize",value:ne});},[c,r]),ve=Et.useCallback(ne=>{!c&&r&&r({type:"textColor",value:ne});},[c,r]),de=Et.useCallback(ne=>{!c&&r&&r({type:"highlightColor",value:typeof ne=="string"?ne:""});},[c,r]),ze=Et.useCallback(ne=>{!c&&r&&r({type:"alignment",value:ne});},[c,r]),Lt=Et.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),Je=Et.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),ut=Et.useCallback(()=>{!c&&r&&r("indent");},[c,r]),Se=Et.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),uo=Et.useCallback(ne=>{!c&&r&&(r({type:"lineSpacing",value:ne}),requestAnimationFrame(()=>_?.()));},[c,r,_]),po=Et.useCallback(ne=>{!c&&r&&r({type:"applyStyle",value:ne});},[c,r]),mo=Et.useCallback(ne=>{!c&&Y&&(Y(ne),requestAnimationFrame(()=>_?.()));},[c,Y,_]);Et.useEffect(()=>{if(!u)return;let ne=ge=>{if(ge.defaultPrevented)return;let xt=ge.target,zn=g?.current,re=me.current,oe=zn?.contains(xt),ye=re?.contains(xt);if(!oe&&!ye)return;if((ge.ctrlKey||ge.metaKey)&&!ge.altKey)switch(ge.key.toLowerCase()){case "b":ge.preventDefault(),z("bold");break;case "i":ge.preventDefault(),z("italic");break;case "u":ge.preventDefault(),z("underline");break;case "=":ge.shiftKey?(ge.preventDefault(),z("superscript")):(ge.preventDefault(),z("subscript"));break;case "l":ge.preventDefault(),ze("left");break;case "e":ge.preventDefault(),ze("center");break;case "r":ge.preventDefault(),ze("right");break;case "j":ge.preventDefault(),ze("both");break;case "k":ge.preventDefault(),z("insertLink");break}};return document.addEventListener("keydown",ne),()=>{document.removeEventListener("keydown",ne);}},[u,z,ze,g]);let Mo=Et.useCallback(ne=>{let ge=ne.target;ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.tagName==="SELECT"||ge.tagName==="OPTION"||ne.preventDefault();},[]),Yt=Et.useCallback(ne=>{let ge=ne.target,xt=document.activeElement;ge.tagName==="SELECT"||ge.tagName==="OPTION"||xt?.tagName==="SELECT"||requestAnimationFrame(()=>{_?.();});},[_]);return jsxRuntime.jsxs("div",{ref:me,className:le(!j&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:j?{display:"contents",...f}:f,role:j?void 0:"toolbar","aria-label":j?void 0:t("toolbar.ariaLabel"),"data-testid":j?void 0:"formatting-bar",onMouseDown:j?void 0:Mo,onMouseUp:j?void 0:Yt,children:[jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(Nt,{onClick:ie,disabled:c||!s,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx($,{name:"undo",size:Vt})}),jsxRuntime.jsx(Nt,{onClick:J,disabled:c||!l,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx($,{name:"redo",size:Vt})})]}),E&&jsxRuntime.jsx(Gt,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(Sy,{value:D,onChange:A,disabled:c,compact:true})}),P&&jsxRuntime.jsx(Gt,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(Ty,{value:n.styleId||"Normal",onChange:po,styles:k,theme:w,disabled:c,width:120})}),(p||x)&&jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.font"),children:[p&&jsxRuntime.jsx(oy,{value:n.fontFamily||"Arial",onChange:W,fonts:q,documentFonts:y,disabled:c,width:60,placeholder:"Arial"}),x&&jsxRuntime.jsx(ly,{value:n.fontSize!==void 0?hu(n.fontSize):11,onChange:fe,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(Nt,{onClick:()=>z("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx($,{name:"format_bold",size:Vt})}),jsxRuntime.jsx(Nt,{onClick:()=>z("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx($,{name:"format_italic",size:Vt})}),jsxRuntime.jsx(Nt,{onClick:()=>z("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx($,{name:"format_underlined",size:Vt})}),jsxRuntime.jsx(Nt,{onClick:()=>z("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx($,{name:"strikethrough_s",size:Vt})}),b&&jsxRuntime.jsx(Bn,{mode:"text",value:n.color?.replace(/^#/,""),onChange:ve,theme:w,disabled:c,title:t("formattingBar.fontColor")}),h&&jsxRuntime.jsx(Bn,{mode:"highlight",value:n.highlight,onChange:de,theme:w,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx(Nt,{onClick:()=>z("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx($,{name:"link",size:Vt})})]}),jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(Nt,{onClick:()=>z("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx($,{name:"superscript",size:Vt})}),jsxRuntime.jsx(Nt,{onClick:()=>z("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx($,{name:"subscript",size:Vt})})]}),C&&jsxRuntime.jsx(Gt,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(hy,{value:n.alignment||"left",onChange:ze,disabled:c})}),(T||S)&&jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.listFormatting"),children:[T&&jsxRuntime.jsx(vy,{listState:n.listState||Xs(),onBulletList:Lt,onNumberedList:Je,onIndent:ut,onOutdent:Se,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),S&&jsxRuntime.jsx(xy,{value:n.lineSpacing,onChange:uo,disabled:c})]}),F&&M&&jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(Oy,{imageContext:F,onChange:M,disabled:c}),I&&jsxRuntime.jsx(By,{onTransform:I,disabled:c}),U&&jsxRuntime.jsx(Nt,{onClick:U,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx($,{name:"tune",size:Vt})})]}),L?.isInTable&&Y&&jsxRuntime.jsxs(Gt,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(My,{onAction:mo,disabled:c}),jsxRuntime.jsx(Ry,{onAction:mo,disabled:c,theme:w,value:So(L?.cellBorderColor,w)}),jsxRuntime.jsx(Dy,{onAction:mo,disabled:c}),jsxRuntime.jsx(_y,{onAction:mo,disabled:c,theme:w,value:L?.cellBackgroundColor}),jsxRuntime.jsx(Hy,{onAction:mo,disabled:c,tableContext:L})]}),jsxRuntime.jsx(Nt,{onClick:()=>z("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx($,{name:"format_clear",size:Vt})}),m]})}function C5({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(ki.Provider,{value:n,children:jsxRuntime.jsx("div",{className:le("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:ct.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var yt=C5;yt.TitleBar=Xp;yt.Logo=Ws;yt.DocumentName=Yp;yt.MenuBar=$s;yt.TitleBarRight=zs;yt.Toolbar=dm;var S5=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"]]),E5=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function w5({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:s,renderTitleBarRight:l,ref:c,colorMode:d,onZoomChange:f,documentFontFamily:u,className:g}){let m=Et.useRef(null),[p,v]=Et.useState(null),[y,x]=Et.useState({}),[b,h]=Et.useState(null),C=Et.useCallback(k=>{v(k);let w=m.current?.formatting();w&&x({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}:{}}),h(m.current?.sectionProperties()??null),r?.(k);},[r]),T=Et.useCallback(k=>{let w=m.current;if(w){if(typeof k=="string")switch(k){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;case "setRtl":case "setLtr":return w.setParagraphProperty("bidi",void 0,{paragraphDirection:k==="setRtl"?"rtl":"ltr"});default:return}switch(k.type){case "fontFamily":return w.setRunProperty("rFonts",{ascii:k.value,hAnsi:k.value});case "fontSize":return w.setRunProperty("sz",{val:String(Math.round(k.value*2))});case "textColor":{let E=k.value,D=typeof E=="string"?E5(E):So(E,null)??null;return D?w.setRunProperty("color",{val:D}):void 0}case "highlightColor":{let E=k.value.trim().toLowerCase();if(E==="none"||E==="")return w.setRunProperty("highlight",{val:"none"});let D=S5.get(E.startsWith("#")?E:`#${E}`);return D?w.setRunProperty("highlight",{val:D}):void 0}case "alignment":return w.setParagraphProperty("jc",{val:String(k.value)},{physicalAlignment:true});case "lineSpacing":return w.setParagraphProperty("spacing",{line:String(Math.round(k.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return w.setParagraphProperty("pStyle",{val:k.value});default:return}}},[]);Et.useImperativeHandle(c,()=>m.current,[]);let S=t===void 0?1:t/(96/72),P=b?{pageWidthTwips:b.pageSize.widthTwips,pageHeightTwips:b.pageSize.heightTwips,orientation:b.landscape?"landscape":"portrait",marginsTwips:{top:b.margins.topTwips,right:b.margins.rightTwips,bottom:b.margins.bottomTwips,left:b.margins.leftTwips}}:null;return jsxRuntime.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:[jsxRuntime.jsxs(yt,{currentFormatting:y,onFormat:T,onUndo:()=>m.current?.undo(),onRedo:()=>m.current?.redo(),canUndo:p?.canUndo??false,canRedo:p?.canRedo??false,zoom:S,onZoomChange:f,onSave:()=>{let k=m.current?.save();k&&a?.(k);},children:[jsxRuntime.jsxs(yt.TitleBar,{children:[s&&jsxRuntime.jsx(yt.Logo,{children:s()}),jsxRuntime.jsx(yt.DocumentName,{value:n??"Document",editable:false}),l&&jsxRuntime.jsx(yt.TitleBarRight,{children:l()}),jsxRuntime.jsx(yt.MenuBar,{})]}),jsxRuntime.jsx(yt.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[P?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(Dn,{pageSetup:P,zoom:S})}):null,jsxRuntime.jsx($p,{ref:m,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:C,...i?{onError:i}:{}})]})]})}var ic=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 lc=class extends ic{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}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,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="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 _5=Et.createContext(null);function zy({children:e}){let t=Et.useMemo(()=>new lc,[]),o=Et.useSyncExternalStore(t.subscribe,t.getSnapshot),n=Et.useCallback((c,d)=>{t.showError(c,d);},[t]),r=Et.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=Et.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=Et.useCallback(c=>{t.dismiss(c);},[t]),s=Et.useCallback(()=>{t.clearAll();},[t]),l=Et.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[o.notifications,n,r,i,a,s]);return jsxRuntime.jsxs(_5.Provider,{value:l,children:[e,jsxRuntime.jsx(N5,{notifications:o.notifications,onDismiss:a})]})}function N5({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(r=>jsxRuntime.jsx(L5,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function L5({notification:e,onDismiss:t}){let{t:o}=N(),[n,r]=Et.useState(false),a=(p=>{switch(p){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),s={background:a.bg,border:`1px solid ${a.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"docx-notification-slide-in 0.3s ease-out"},l={display:"flex",alignItems:"flex-start",gap:"8px"},c={color:a.icon,flexShrink:0},d={flex:1,minWidth:0},f={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},u={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},m=p=>{switch(p){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:s,children:jsxRuntime.jsxs("div",{style:l,children:[jsxRuntime.jsx("span",{style:c,children:m(e.severity)}),jsxRuntime.jsxs("div",{style:d,children:[jsxRuntime.jsx("div",{style:f,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>r(!n),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(n?"errors.hideDetails":"errors.showDetails")}),n&&jsxRuntime.jsx("div",{style:u,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var sc=class extends Et.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",t,o),this.props.onError&&this.props.onError(t,o);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:o=true}=this.props,{error:n,errorInfo:r}=this.state;return t?typeof t=="function"?t(n,this.resetError):t:jsxRuntime.jsx(F5,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function F5({error:e,errorInfo:t,showDetails:o,onReset:n}){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"},s={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},l={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={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 jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:i,children:[jsxRuntime.jsx("div",{style:a,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:s,children:r("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:l,children:r("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
1
|
+
'use strict';var At=require('react'),editor=require('@docx-editor.dev/core/editor'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@docx-editor.dev/i18n'),store=require('@docx-editor.dev/core/store'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),Fe=require('@radix-ui/react-select'),editor$1=require('@docx-editor.dev/core/contracts/editor');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var At__namespace=/*#__PURE__*/_interopNamespace(At);var Fe__namespace=/*#__PURE__*/_interopNamespace(Fe);var Bf={version:"2.32.0"};var AT=Bf.version;function Wf(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((g,p)=>t.get(g[0])-t.get(p[0])),d=()=>{r++;for(let g of o)g();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,g])=>g));}));},u=(g,p)=>g.match?.(p)??true;return {register(g,p){t.has(g)||t.set(g,n++),e.set(g,p),m();},unregister(g){e.delete(g)&&m();},connect(g){i=g,g&&m();},current:()=>c().map(([,g])=>g),setContainer(g){l?.();for(let p of a)p.setCustomized(false);a=[],l=g?editor.observeUnsupportedElements(g,p=>{a=p,d();}):void 0,d();},subscribe(g){return o.add(g),()=>o.delete(g)},snapshot:()=>r,hosts(g){let p=c();return a.filter(f=>p.find(([,h])=>u(h,f.unsupported))?.[0]===g)}}}var mr=At.createContext(null);function Zf(e){return At.Children.toArray(e).some(t=>At.isValidElement(t)&&t.type===At.Fragment?Zf(t.props.children):typeof t!="string"||t.trim().length>0)}function qf({host:e,children:t}){let o=Zf(t);return At.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function ld({match:e,layout:t,children:o}){let n=At.useContext(mr);if(!n)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let r=At.useRef(Symbol("unsupported-element-declaration")).current;return At.useSyncExternalStore(n.subscribe,n.snapshot,n.snapshot),At.useLayoutEffect(()=>{n.register(r,{...e?{match:e}:{},...t?{layout:t}:{}});},[n,r,e,t]),At.useLayoutEffect(()=>()=>n.unregister(r),[n,r]),n.hosts(r).map(i=>jsxRuntime.jsx(qf,{host:i,children:o({element:i.unsupported})},i.key))}var sd=At.createContext(i18n.en),cd=At.createContext("en");function fr({i18n:e,children:t}){let o=At.useContext(sd),n=At.useContext(cd),r=typeof e?._lang=="string"?e._lang:n,i=At.useMemo(()=>i18n.deepMerge(o,e),[o,e]);return jsxRuntime.jsx(cd.Provider,{value:r,children:jsxRuntime.jsx(sd.Provider,{value:i,children:t})})}function L(){let e=At.useContext(sd),t=At.useContext(cd);return {t:At.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t}}function Vf(e){let{t}=L();return At.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var dd=At.createContext(null);function H(){return At.useContext(dd)}function gl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var _t=At.createContext(null);var ud=0,pd=false,md=false,bl=[],hl=null;function jf(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}hl||(hl=new MessageChannel,hl.port1.onmessage=()=>{let t=bl;bl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),bl.push(e),bl.length===1&&hl.port2.postMessage(null);}function Yf(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(pd||(pd=true,ud+=1,queueMicrotask(()=>{pd=false;}),md||(md=true,jf(()=>{md=false,ud=0;}))),ud>16)}function Xf(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};Yf()?jf(o):queueMicrotask(o);}}var oE=()=>{},gd=0;function nE(){return gd}function Sa(e){return Xf(e)}function W(e,t=Object.is,o){let n=H(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=At.useCallback(d=>{if(!n)return oE;let m=false;gd++,r?.();let u=Sa(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,gd--,i?.();for(let p of g)p();}},[n,r,i]),l=At.useMemo(()=>{let d=false,m,u;return g=>{if(d&&g===m)return u;let p=e(g);return d&&t(u,p)?(m=g,u):(d=true,m=g,u=p,p)}},[n,e,t]),s=At.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=At.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return At.useSyncExternalStore(a,s,c)}function lE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function sE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=lE(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function j({children:e,...t}){let o=At.Children.only(e);if(!At.isValidElement(o))return null;let n=o.props,r=sE(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),At.cloneElement(o,r)}var eg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function Tt(){let e=At.createContext(null),t=new Map,o=b=>{let v=t.get(b.type);return v==="field"?`field:${b.props.name}`:v};function n(b,v){At.Children.forEach(b,y=>{At.isValidElement(y)&&(v(y),n(y.props.children,v));});}function r(){let b=At.useContext(e);if(!b)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return b.state}function i(b,v){return At.Children.map(b,y=>{if(!At.isValidElement(y))return y;let T=eg(y.props);return T&&v.has(T)?v.get(T):y.props.children===void 0?y:At.cloneElement(y,{children:i(y.props.children,v)})})}function a(b){function v(y){let T=At.useContext(e);if(!T||y.hidden)return null;let x=b==="field"?`field:${y.name}`:b,C=T.defaults.get(x);if(!C)return y.children??null;let{children:E,asChild:S,className:D,style:w,hidden:k,name:F,...I}=y,N={...I,...C.props,className:[C.props.className,D].filter(Boolean).join(" "),style:{...C.props.style,...w}};if(S){let{children:A,className:P,style:M,...$}=N;return jsxRuntime.jsx(j,{...$,...D?{className:D}:{},...w?{style:w}:{},children:E})}return At.cloneElement(C,N,E===void 0?i(C.props.children,T.overrides):E)}return t.set(v,b),v}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),m=a("apply"),u=a("cancel"),g=a("reset"),p=a("error"),f=a("field");function h({defaults:b,children:v,preset:y=true,state:T}){let x=new Map;n(b,D=>{let w=eg(D.props);w&&x.set(w,D);});let C=new Map;n(v,D=>{let w=o(D);w&&C.set(w,D);});let E=D=>At.Children.toArray(D).flatMap(w=>At.isValidElement(w)&&w.type===At.Fragment?E(w.props.children):[w]),S=E(v).filter(D=>!At.isValidElement(D)||!o(D));return jsxRuntime.jsx(e.Provider,{value:{defaults:x,overrides:C,state:T},children:y?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(b,C),S]}):v})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:h,useState:r,part:b=>a(b)}}function Be({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:m=true,describedBy:u}){let g=At.useRef(null),p=l??g,f=At.useRef(i);f.current=i;let[h,b]=At.useState(false);return At.useLayoutEffect(()=>{let v=p.current;if(!v)return;b(!v.parentElement?.closest(".docx-editor"));let y=v.ownerDocument.activeElement,T=()=>{v.open&&v.close?.();};return d?.addEventListener("abort",T),typeof v.showModal=="function"?v.showModal():v.setAttribute("open",""),(v.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??v.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",T),typeof v.close=="function"&&v.open&&v.close(),m&&y?.isConnected&&y.focus({preventScroll:true});}},[p,d,m]),jsxRuntime.jsx("dialog",{ref:p,role:t,"aria-modal":"true","aria-label":r,"aria-describedby":u,className:`docx-dialog${h?" docx-editor":""}${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:v=>{v.preventDefault(),f.current();},onMouseDown:v=>v.stopPropagation(),onClick:v=>{if(c&&v.target===v.currentTarget){let y=v.currentTarget.getBoundingClientRect();(v.clientX<y.left||v.clientX>y.right||v.clientY<y.top||v.clientY>y.bottom)&&f.current();}v.stopPropagation();},onKeyDown:v=>{v.key==="Escape"&&!v.nativeEvent.isComposing?(v.preventDefault(),f.current()):editor.trapTabWithin(v.currentTarget,v.nativeEvent)?v.preventDefault():!v.nativeEvent.isComposing&&!v.defaultPrevented&&a?.(v),v.stopPropagation();},children:s})}function po(e,t){let o=H(),n=vd(),r=At.useRef(null);return At.useEffect(()=>{if(!e){r.current=null;return}o?.surface&&(r.current===null?r.current=o.mountGeneration:r.current!==o.mountGeneration&&t());},[e,o,n,t]),()=>!!o?.surface&&r.current===o.mountGeneration}function vd(){let e=H(),t=At.useCallback(o=>{if(!e)return ()=>{};let n=true,r=Sa(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return At.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function tg(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=l=>{for(let s of [...l])s();};return {getShift:()=>e,setShift(l){let s=Math.max(0,Math.round(l));s!==e&&(e=s,a(n));},subscribeShift(l){return n.add(l),()=>n.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Cd=At.createContext(null);function Mn(){return At.useContext(Cd)}var og=()=>0,Td=()=>()=>{};function _n(){let e=Mn(),t=At.useCallback(n=>e?e.subscribeShift(n):Td(),[e]),o=At.useCallback(()=>e?e.getShift():0,[e]);return At.useSyncExternalStore(t,o,og)}function ng(){let e=Mn(),t=At.useCallback(n=>e?e.subscribeReservation(n):Td(),[e]),o=At.useCallback(()=>e?e.getReservation():0,[e]);return At.useSyncExternalStore(t,o,og)}function ke(){let e=Mn(),t=At.useCallback(r=>e?e.subscribeViewport(r):Td(),[e]),o=At.useCallback(()=>e?e.getViewport():null,[e]),n=At.useCallback(()=>null,[]);return At.useSyncExternalStore(t,o,n)}function Fo(e,t,o){let n=ke(),r=At.useRef({close:o,viewport:n});r.current={close:o,viewport:n},At.useEffect(()=>{let i=e.current;if(!(!t||!i))return wE(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function wE(e,t,o){let n=l=>{if(l.defaultPrevented||l.altKey||l.ctrlKey||l.metaKey)return;let s=l.target;if(s.matches('input[role="combobox"]')||s.matches("input, textarea, select")&&l.key!=="ArrowDown"&&l.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let m=d.indexOf(s),u;if(l.key==="Home")u=0;else if(l.key==="End")u=d.length-1;else if(l.key==="ArrowDown")u=(m+1)%d.length;else if(l.key==="ArrowUp")u=m<0?d.length-1:(m-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),d[u]?.focus();},r=l=>{editor.isDomNode(l.relatedTarget)&&!e.contains(l.relatedTarget)&&t();},i=editor.listenForPopupEscape({popup:e,contains:l=>e.contains(l),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:l=>editor.isElementNode(l.target)&&e.contains(l.target)&&l.target.matches('input[role="combobox"]'),close:l=>{l&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=editor.listenForPopupFocusLeave({popup:e,contains:l=>e.contains(l),close:t});return e.addEventListener("keydown",n),e.addEventListener("focusout",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("focusout",r),i(),a();}}function LE(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Ed(e){return typeof e=="string"}function ie(e){let t=H(),{t:o}=L(),n=Ed(e)?e:editor.editorCommandKey(e),r=At.useRef(e);r.current=e;let i=At.useCallback(s=>{let c=r.current;if(Ed(c)){let m=editor.toolbarCommandState(t,c);return {active:m.active,enabled:m.enabled,disabledReason:i18n.localizeDisabledReason(m.disabledReason,o),value:m.value??null}}if(!t)return {active:false,enabled:false,disabledReason:null,value:null};let d=t.can(c);return {active:t.isActive(c),enabled:d.ok,disabledReason:d.ok?null:i18n.localizeDisabledReason(d.reason??null,o),value:null}},[t,n,o]),a=W(i,LE),l=At.useCallback(s=>{let c=editor.commandExecOptions(s),d=r.current;return Ed(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return At.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var In=At.createContext({t:void 0,onSave:void 0});function HE(){return At.useContext(In)}function vl(e){let{t}=L();return o=>e?.(o)??t(o)}function ee(){let{t:e}=At.useContext(In);return vl(e)}var WE=()=>()=>{},ZE=()=>true,qE=()=>false;function Ho(){let e=At.useSyncExternalStore(WE,ZE,qE);return At.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function KE(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function UE(){try{return undefined}catch{return}}function gt(){let e=typeof process<"u";return KE({viteEnv:UE(),nodeEnv:e?"production":void 0,hasProcess:e})}var lg=new Set;function en(e){!gt()||lg.has(e)||(lg.add(e),console.warn(`[docx-editor] ${e}`));}function sg(e){en(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function cg(e){en(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function dg(){en("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function ug(){en("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function pg(e){en(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function mg(){en("A Toolbar.Button has no slotId, so it renders nothing.");}function Q(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function te(e){return e?jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsxRuntime.jsx("path",{d:t,fill:"currentColor"},t))}):null}function q(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function GE(e){if(e.slotId)return e.slotId;if(e.slot)return pg(e.slot),e.slot;mg();}function Ao(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=GE(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=ie(a),u=ee(),g=Ho();if(i||!a)return null;let p=Q(a),f=g(u(p?.labelKey??a)),h=editor.chromeSlotIsToggle(a),b={onClick:()=>l(),onMouseDown:q,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...h?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsxRuntime.jsx(j,{...b,children:r}):jsxRuntime.jsx("button",{type:"button",...b,children:t??r??te(p?.paths)})}Ao.docxToolbarPart=true;var oS=[{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"}],fg=[{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"}],gg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Cl=["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"],tn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Wt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function nS(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[Wt(5),Wt(15),Wt(25),Wt(35),Wt(50)]:o===0?[tn(50),tn(35),tn(25),tn(15),tn(5)]:o>=.8?[Wt(10),Wt(25),Wt(50),Wt(75),Wt(90)]:[tn(80),tn(60),tn(40),Wt(25),Wt(50)]}var rS=/^[0-9A-Fa-f]{6}$/;function aS(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function iS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function br({value:e,css:t,title:o,selected:n,apply:r}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||iS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:q,onClick:()=>r(e)})}function lS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(nS),i=[0,1,2,3,4];return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[n.map((a,l)=>jsxRuntime.jsx(br,{value:a,css:`#${a.toLowerCase()}`,title:t(Cl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=aS(l,c.apply);return jsxRuntime.jsx(br,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Cl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function sS(e){let{apply:t,label:o,current:n}=e,[r,i]=At.useState(""),a=rS.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lS,{...e}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:oS.map(l=>jsxRuntime.jsx(br,{value:l.value,css:l.css,title:o(l.labelKey),selected:n===l.value,apply:t},l.value))})]}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsxRuntime.jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":o("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());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:q,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Pd({apply:e,current:t}){let o=H(),n=ee(),r=o?.getDocumentThemeColors()??[],i=r.length===Cl.length?r.map(l=>l.hex):gg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(sS,{apply:e,label:n,current:a,themeHexes:i})}var cS=fg.filter(e=>e.value!=="white");function dS({apply:e,label:t,current:o}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:cS.map(n=>jsxRuntime.jsx(br,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function bg(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let m=H(),{isEnabled:u,disabledReason:g}=ie(t),p=ee(),[f,h]=At.useState(false),[b,v]=At.useState(o),y=At.useRef(null);Fo(y,f,()=>h(false));let T=W(w=>{if(a){let k=w.formatting?.color;return k&&k.kind==="hex"?k.value.toUpperCase():null}return w.formatting?.highlight??null}),x=m?.getDocumentThemeColors()??[],C=x.length===Cl.length?x.map(w=>w.hex):gg;At.useEffect(()=>{if(!f)return;let w=F=>{let I=y.current;I&&editor.isDomNode(F.target)&&I.contains(F.target)||h(false);},k=editor.hostDocumentOf(y.current);return k.addEventListener("mousedown",w),()=>k.removeEventListener("mousedown",w)},[f]);let E=At.useCallback(w=>{if(h(false),!m)return;m.focus();let k=editor.commandForSlotValue(t,w);k&&m.can(k).ok&&(m.exec(k),w!==r.value&&v(w));},[m]),S=At.useMemo(()=>Q(t),[]);if(c)return null;let D=p(S?.labelKey??t);return jsxRuntime.jsxs("div",{ref:y,className:`docx-toolbar__colorsplit${s?` ${s}`:""}`,"data-slot":t,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!u,...u?{}:{"data-disabled":""},"aria-label":D,title:g??D,onMouseDown:q,onClick:()=>E(b),children:[d??te(S?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(b)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":f,"aria-label":D,title:g??D,onMouseDown:q,onClick:()=>h(w=>!w),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":D,onMouseDown:q,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:q,onClick:()=>E(r.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(r.labelKey)]}),i({apply:E,label:p,current:T,themeHexes:C})]}):null]})},{docxSlot:t})}var uS=new Map(fg.map(e=>[e.value,e.css])),kd=bg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Pd,{apply:e.apply,current:e.current})}),wd=bg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>uS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(dS,{...e})});var Rd=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function El({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=At.useId(),[l,s]=At.useState(false),c=At.useRef(null),d=At.useRef(null),m=At.useRef(null);At.useLayoutEffect(()=>{if(!l||!m.current||!d.current)return;let g=editor.observeContentControlPopup(m.current,d.current);return (m.current.querySelector("[data-selected]")??m.current.querySelector("button"))?.focus(),g},[l]),At.useEffect(()=>{if(n&&s(false),!l)return;let g=c.current?.ownerDocument,p=f=>{c.current?.contains(f.target)||s(false);};return g?.addEventListener("pointerdown",p),()=>g?.removeEventListener("pointerdown",p)},[l,n]);let u=()=>{s(false),d.current?.focus();};return jsxRuntime.jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||s(false);},children:[jsxRuntime.jsx("span",{id:`${a}-label`,children:e}),jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-revision-color-trigger",disabled:n,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!n,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Rd(t)}}),jsxRuntime.jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),jsxRuntime.jsxs("div",{ref:m,id:`${a}-options`,className:"docx-revision-color-options",hidden:!l||n,role:"group","aria-labelledby":`${a}-label`,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),u());let p=Array.from(g.currentTarget.querySelectorAll("button")),f=p.indexOf(g.target),h=g.key==="Home"?0:g.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(g.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(g.key)?(f-1+p.length)%p.length:null;h!==null&&(g.preventDefault(),g.stopPropagation(),p[h]?.focus());},children:[jsxRuntime.jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{r(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Rd(g)}}),i(`values.${g}`)]},g))}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsx(br,{value:g,css:Rd(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var hg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],yS=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function yg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...hg,"hidden","caret","pound"]:hg,s=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("div",{className:"docx-revision-markup-row",children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsxRuntime.jsx("select",{value:n[a].mark,disabled:s,onChange:c=>e.setValue(a,{...n[a],mark:c.target.value}),children:l.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(El,{label:t(`${a}Color`),value:n[a].color,values:yS,disabled:s,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(El,{label:t(`${a}Background`),value:n[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...n[a],background:c})})})]})},i=a=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n[a],"aria-describedby":`${o}-${a}`,onChange:l=>e.setValue(a,l.target.checked)}),t(a)]}),jsxRuntime.jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("markup")}),r("insertions"),r("deletions"),r("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),r("movedFrom"),r("movedTo")]}),jsxRuntime.jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsxRuntime.jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsxRuntime.jsx(El,{label:t(`${a}Cells`),value:n.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...n.cells,[a]:l})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),r("formatting")]})]})}var Gt=Tt();function PS(){return Gt.useState()}function kS({session:e,...t}){return e?jsxRuntime.jsx(wS,{session:e,...t}):null}function wS({session:e,children:t,preset:o,className:n,style:r}){let i=At.useId(),{t:a}=L(),l=f=>a(`revisionMarkup.${f}`),s=At.useCallback(f=>e.subscribe(f),[e]),c=At.useCallback(()=>e.get(),[e]),d=At.useSyncExternalStore(s,c,c),[m,u]=At.useState(e.signal.aborted),g=At.useRef(null);At.useEffect(()=>{g.current=e;let f=()=>u(true);return u(e.signal.aborted),e.signal.addEventListener("abort",f),()=>{e.signal.removeEventListener("abort",f),g.current=null,queueMicrotask(()=>{g.current!==e&&e.cancel();});}},[e]);let p={values:d,setValue(f,h){e.set({[f]:h});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsxRuntime.jsx(Be,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(Gt.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",children:jsxRuntime.jsx("h2",{"data-docx-part":"title",children:l("title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:yg(p,l,i)}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"reset",type:"button",onClick:p.reset,children:l("reset")}),jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",onClick:p.cancel,children:l("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!p.isEnabled,onClick:p.apply,children:l("ok")})]})]}),children:t})})}var Pa=Object.assign(kS,{Header:Gt.Header,Title:Gt.Title,Body:Gt.Body,Footer:Gt.Footer,Apply:Gt.Apply,Cancel:Gt.Cancel,Error:Gt.Error,Field:Gt.Field,Reset:Gt.Reset});function _d(e){let t=H(),o=At.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return At.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),At.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function ka({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(Be,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[o&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:n?"alert":"status",children:n||s("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(n?"common.close":"toolbar.exportContinueEditing")})})]})})}function wa({open:e,pending:t,error:o,url:n,onClose:r,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(o?"toolbar.printFailed":"toolbar.printPreparing"),d=n.startsWith("blob:")?n:"";return jsxRuntime.jsx(Be,{kind:"print",label:c,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,onKeyDown:m=>{editor.isChromePrintShortcut(m.nativeEvent)&&m.preventDefault();},children:l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[t&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),o&&jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[o&&d&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:s("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(o?"common.close":"common.cancel")})]})]})})}var vt={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function hr({text:e,x:t,y:o,className:n}){return jsxRuntime.jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:vt.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function yr({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=L();return jsxRuntime.jsxs("div",{role:"menu",className:p,onKeyDown:h=>{h.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:vt.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:q,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:n,children:f("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:f(e==="footnote"?"notes.convertToEndnote":"notes.convertToFootnote")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!d,title:g,onClick:i,children:f(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:f("dialogs.footnoteProperties.title")})]})}function FS(e){return t=>At.createElement(e,t)}var Eg=new WeakMap,HS=0;function Te(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=Eg.get(o);return r===void 0&&Eg.set(o,r=++HS),At.createElement(At.Fragment,{key:r},n)}var Nd=At.createContext(void 0),St=()=>At.useContext(Nd);function vr(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function Ra(e){return e.paragraphId===""}var Ln=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),$S=e=>e;function VS(e){let t=r=>!!r&&(r.width>0||r.height>0),o=editor.hostDocumentOf(e);if(o){let i=o.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom}}let n=o?o.getSelection():null;if(n&&n.rangeCount>0){let r=n.getRangeAt(0),i=r.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=r.startContainer,s=(editor.isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ma=At.createContext(null);function Fd(){let e=At.useContext(Ma),t=Pl(e===null);return e??t}function Pl(e=true){let t=H(),o=ke(),n=At.useRef(o);n.current=o;let[r,i]=At.useState(Ln),a=At.useRef(null),l=At.useRef(r);l.current=r;let s=W($S),c=t?t.can({type:"insertText",text:""}).ok:false,d=At.useCallback(()=>{let x=a.current;x&&(x.editor.releaseSelection(x.pin),a.current=null);},[]),m=At.useCallback((x,C)=>{d(),i({mode:x?"reading":"editing",link:x??null,anchor:C??null,text:x?.text??"",url:x?x.kind==="internal"?`#${x.anchor??""}`:x.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,d]),u=At.useCallback(()=>{d(),i(Ln);},[d]);At.useEffect(()=>d,[d]);let g=At.useCallback(()=>{let x=VS(n.current);d();let C=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(C&&Ra(C)){m(C,x);return}if(C){i({mode:"editing",link:C,anchor:x,text:C.text,url:C.kind==="internal"?`#${C.anchor??""}`:C.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let E=t?.query({type:"selectedText"})??"",S=t?.retainSelection()??null;t&&S&&(a.current={editor:t,pin:S}),i({mode:"editing",link:null,anchor:x,text:E,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,m,d]);At.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:x=>m(x.link,{left:x.rect.left,top:x.rect.bottom}),onRequest:g})},[t,e,m,g]),At.useEffect(()=>{let x=l.current;if(x.mode!=="reading"||!x.link)return;let C=Ra(x.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;C&&C.id===x.link.id||i(Ln);},[s,t]),At.useEffect(()=>{let x=l.current;if(x.mode!=="editing"||x.link)return;let C=t?.surface;!C||C.retainedSelection()||i(Ln);},[s,t]);let p=At.useCallback(async()=>{let x=l.current.link?.href;if(!x)return false;try{await editor.hostWindowOf(n.current).navigator.clipboard.writeText(x);}catch{return false}return i(C=>({...C,copied:true})),true},[]),f=At.useCallback(()=>{i(x=>({...x,mode:"editing",copied:false,error:false}));},[]),h=At.useCallback(x=>{i(C=>({...C,text:x,copied:false,error:false}));},[]),b=At.useCallback(x=>{i(C=>({...C,url:x,copied:false,error:false}));},[]),v=At.useCallback(()=>{let x=l.current,C=t?.surface?.hyperlinks;if(!C)return false;let E=x.url.trim();if(E.length===0)return i(w=>({...w,error:true})),false;let S=E.startsWith("#");return C.applyHyperlink({...S?{anchor:E.slice(1)}:{url:E},...x.text.trim().length>0?{text:x.text}:{}})?(u(),true):(i(w=>({...w,error:true})),false)},[t,u]),y=At.useCallback(()=>{let x=t?.surface?.hyperlinks,C=l.current.link;if(!x)return false;let E=x.removeHyperlink(C?.id);return E&&u(),E},[t,u]),T=At.useCallback(()=>{let x=t?.surface?.navigation,C=l.current.link;if(!x||!C)return false;if(C.kind==="internal"){let S=C.anchor?x.goToBookmark(C.anchor):false;return S&&i(Ln),S}let E=x.openExternal(C.href);return E&&i(Ln),E},[t]);return At.useMemo(()=>({state:r.mode==="closed"?Ln:{...r,canEdit:c},open:m,openAtCaret:g,close:u,copy:p,beginEdit:f,setText:h,setUrl:b,commitEdit:v,unlink:y,openTarget:T}),[r,c,m,g,u,p,f,h,b,v,y,T])}function Hn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var kl=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),oP="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",nP="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",rP="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",aP="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 iP({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=go(),a=At.useRef(null),{state:l,close:s}=i;At.useEffect(()=>{if(l.mode==="closed")return;let f=v=>{v.key==="Escape"&&(v.preventDefault(),s());},h=v=>{let y=a.current;y&&editor.isDomNode(v.target)&&y.contains(v.target)||s();},b=editor.hostDocumentOf(a.current);return b.addEventListener("keydown",f),b.addEventListener("mousedown",h,true),()=>{b.removeEventListener("keydown",f),b.removeEventListener("mousedown",h,true);}},[l.mode,s]);let[c,d]=At.useState(null);At.useLayoutEffect(()=>{let f=l.anchor,h=a.current;if(!f||!h){d(null);return}let b=h.offsetParent;if(!b){d(null);return}let{left:v,top:y}=vr(b,f.left,f.top),T=Math.max(0,b.scrollWidth-h.offsetWidth);d({left:Math.max(0,Math.min(v,T)),top:y});},[l.anchor]);let{t:m}=L(),u=l.mode==="editing"?m(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):m("hyperlinkPopup.editLink"),g=r?jsxRuntime.jsx(lP,{children:n}):n;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let p={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Hn,style:c??void 0,"aria-label":u};return l.mode==="closed"?null:t?jsxRuntime.jsx(j,{...p,children:n}):jsxRuntime.jsx("div",{...p,children:g})}function lP({children:e}){let{state:t}=go(),o=At.useMemo(()=>sP(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Fields",jsxRuntime.jsx(Zd,{})),n("Error",jsxRuntime.jsx(Kd,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(qd,{})),n("Cancel",jsxRuntime.jsx(Ud,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&Ra(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(Ad,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(Od,{})),r?n("Edit",jsxRuntime.jsx(Bd,{})):null,r?n("Unlink",jsxRuntime.jsx(Wd,{})):null]}),o.__extra]})}function sP(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===At.Fragment){n(r.props.children);return}let i=r.type.docxHyperLinkPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function go(){return At.useContext(Ma)??cP}var cP={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 Ad({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=go(),{t:a}=L();if(o||!r.link)return null;let l=!r.link.href,s=r.link.kind==="internal",c=s?`#${r.link.anchor??""}`:r.link.authored,d=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),m={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:Hn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(j,{...m,className:e,children:n}):l?jsxRuntime.jsxs("span",{...m,children:[n??c,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxRuntime.jsxs("button",{...m,children:[n??c,kl(aP)]})}Ad.docxHyperLinkPart="Url";function Od({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=go(),{t:l}=L();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:Hn,onClick:()=>{a();}};return t?jsxRuntime.jsx(j,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??kl(oP)})}Od.docxHyperLinkPart="Copy";function Bd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=go(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Hn,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??kl(nP)})}Bd.docxHyperLinkPart="Edit";function Wd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=go(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.removeLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:Hn,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??kl(rP)})}Wd.docxHyperLinkPart="Unlink";function Zd({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=go(),{t:l}=L(),s=At.useRef(null),c=At.useId(),d=At.useId();At.useEffect(()=>{o.mode==="editing"&&(s.current?.focus({preventScroll:true}),s.current?.select());},[o.mode]);let m=At.useCallback(u=>{if(u.key==="Enter"){u.preventDefault(),i();return}u.key==="Escape"&&(u.preventDefault(),a());},[i,a]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:l("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:c,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onChange:u=>n(u.target.value),onKeyDown:m}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:l("hyperlinkPopup.urlPlaceholder")}),jsxRuntime.jsx("input",{id:d,ref:s,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:m})]})}Zd.docxHyperLinkPart="Fields";function qd({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=go(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.apply"),s={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Hn,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}function Kd({className:e,hidden:t}){let{state:o}=go(),{t:n}=L();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:n("hyperlinkPopup.refused")})}Kd.docxHyperLinkPart="Error";qd.docxHyperLinkPart="Apply";function Ud({className:e,asChild:t,hidden:o,children:n}){let{close:r}=go(),{t:i}=L();if(o)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Hn,onClick:()=>r()};return t?jsxRuntime.jsx(j,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:n??a})}Ud.docxHyperLinkPart="Cancel";var _a=Object.assign(iP,{Url:Ad,Copy:Od,Edit:Bd,Unlink:Wd,Fields:Zd,Error:Kd,Apply:qd,Cancel:Ud});var Pt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function mP(e){return e==="sdtLocked"||e==="sdtContentLocked"}function fP(e){return e==="contentLocked"||e==="sdtContentLocked"}function $d(e,t){return !e.ok&&e.code===t}function bo(){let e=At.useContext(Vd),t=wl();return e??t}function wl(){let e=H(),[t,o]=At.useState(false),[n,r]=At.useState(false),[i,a]=At.useState(false),l=W(E=>E),s=e?.surface??null,c=s?.contentControls;At.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=At.useMemo(()=>{if(!e)return null;let E=c?.atCaret()??null;if(E){let P=c?.disabledReason(E.id,"edit")??null,M=c?.disabledReason(E.id,"remove")??null;return {id:E.id,tag:E.tag??null,alias:E.alias??null,controlType:E.controlType,locked:fP(E.effectiveLock)||P==="locked",removalLocked:mP(E.effectiveLock)||M==="locked",placeholder:E.placeholder,bound:E.bound||P==="bound",effectiveLock:E.effectiveLock}}let S=e.query({type:"contentControlAt"});if(!S)return null;let D=c?.disabledReason(S.id,"edit")??null,w=c?.disabledReason(S.id,"remove")??null,k=e.can({type:"setContentControlValue",value:""}),F=e.can({type:"removeContentControl"}),I=S.locked===true||D==="locked"||$d(k,"locked"),N=D==="bound"||$d(k,"bound"),A=w==="locked"||$d(F,"locked");return {id:S.id,tag:S.tag??null,alias:S.alias??null,controlType:S.controlType,locked:I,removalLocked:A,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=At.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=At.useCallback(E=>{c?.setShowAll(E),r(E);},[c]),g=At.useCallback(E=>{c?.setFormFill(E),a(E);},[c]),p=At.useCallback(()=>u(!n),[u,n]),f=At.useCallback(()=>g(!i),[g,i]),h=At.useCallback(()=>o(true),[]),b=At.useCallback(()=>o(false),[]),v=At.useCallback(()=>o(E=>!E),[]),y=At.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"edit");return S==="locked"?"the content control is locked":S==="bound"?"the content control is bound to external data":S==="notFound"?"the content control was not found":S}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 E=e.can({type:"setContentControlValue",value:""});return E.ok?null:E.reason},[d,c,e]),T=At.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"remove");return S==="locked"?"the content control is locked":S==="notFound"?"the content control was not found":S}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let E=e.can({type:"removeContentControl"});return E.ok?null:E.reason},[d,c,e]),x=At.useCallback(E=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let S=c.disabledReason(d.id,"edit");if(S)return {ok:false,code:S==="bound"?"bound":S==="locked"?"locked":"notFound",reason:S==="bound"?"the content control is bound to external data":S==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:E})},[e,c,d]),C=At.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let E=d?.id;if(!E)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let S=c.disabledReason(E,"remove");return S?{ok:false,code:S==="locked"?"locked":"notFound",reason:S==="locked"?"the content control is locked":"the content control was not found"}:c.remove(E)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return At.useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:y===null&&d!==null,canRemove:T===null&&d!==null,setValueDisabledReason:y,removeDisabledReason:T,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:b,toggleInspector:v,remove:C,setValue:x}),[d,m,n,i,t,y,T,u,p,g,f,h,b,v,C,x])}var Vd=At.createContext(null);function Gd(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Rg=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),vP="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",xP="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",CP={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},TP={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},EP={color:"var(--doc-text-muted)",flexShrink:0},SP={textAlign:"right",wordBreak:"break-word"},PP={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},kP={display:"flex",gap:8,marginTop:4},Mg={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 wP(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 "buildingBlockGallery":return "contentControl.types.buildingBlockGallery";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function DP(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 xr({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:TP,"data-testid":o,children:[jsxRuntime.jsx("span",{style:EP,children:e}),jsxRuntime.jsx("span",{style:SP,children:t})]})}function RP({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=bo(),a=At.useRef(null),l=At.useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(At.useEffect(()=>{if(!d)return;let f=v=>{v.key==="Escape"&&(v.preventDefault(),m());},h=v=>{let y=a.current;y&&editor.isDomNode(v.target)&&y.contains(v.target)||m();},b=editor.hostDocumentOf(a.current);return b.addEventListener("keydown",f),b.addEventListener("mousedown",h,true),()=>{b.removeEventListener("keydown",f),b.removeEventListener("mousedown",h,true);}},[d,m]),At.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_g,{}),jsxRuntime.jsx(Ig,{}),jsxRuntime.jsx("div",{style:kP,children:jsxRuntime.jsx(Ng,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:CP,onMouseDown:f=>{Gd(f),f.stopPropagation();}},p=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsxRuntime.jsx(j,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function _g({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=bo(),{t:i}=L();if(o)return null;let a={style:PP,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:n??i("contentControl.inspectorPanel.title")}),jsxRuntime.jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...Mg,padding:4,border:"none",background:"transparent"},onMouseDown:Gd,onClick:()=>r(),children:Rg(vP)})]});return t?jsxRuntime.jsx(j,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function Ig({className:e,asChild:t,hidden:o,children:n}){let{control:r}=bo(),{t:i}=L();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.type"),value:i(wP(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.lock"),value:i(DP(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(xr,{label:i("contentControl.inspectorPanel.bound"),value:r.bound?l:s,testId:"content-control-inspector-bound"}),r.bound?jsxRuntime.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?jsxRuntime.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?jsxRuntime.jsx(j,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function Ng({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=bo(),{t:c}=L();if(o)return null;let d=c("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:Mg,onMouseDown:Gd,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??Rg(xP),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(j,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var La=Object.assign(RP,{Header:_g,Fields:Ig,Remove:Ng});var LP=e=>e;function Qd(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Fa(){let e=H(),{t}=L(),[o,n]=At.useState(null),[r,i]=At.useState(null),a=At.useRef(null),l=At.useRef(null),s=At.useRef(null),c=At.useId(),d=At.useId(),m=At.useId(),u=o?.activation??null,g=W(LP),p=At.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let y=e.surface.equations.can(u.equation.id,"replace"),T=e.surface.equations.can(u.equation.id,"remove"),x=y.ok?T.ok?null:T.reason:y.reason;return {replaceEnabled:y.ok,removeEnabled:T.ok,reason:x?i18n.localizeDisabledReason(x,t):null}},[u,e,g,t]),f=At.useCallback((y=false)=>{s.current?.(),s.current=null,n(null),y&&e&&queueMicrotask(()=>e.focus());},[e]);At.useEffect(()=>{if(!e)return;let y=e.setEquationChrome({onPopover:T=>{s.current?.();let x=e.surface;if(x&&typeof x.retainSelection=="function"){let C=x.retainSelection();s.current=()=>x.releaseSelection(C);}else s.current=null;n({activation:T,mountGeneration:e.mountGeneration,draft:T.equation.linear,error:false});}});return ()=>{y(),s.current?.(),s.current=null,n(null);}},[e,f]),At.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),At.useEffect(()=>{if(!o)return;let y=a.current,T=y?.ownerDocument,x=T?.defaultView;if(!y||!T||!x)return;let C=S=>{S.key==="Escape"&&(S.preventDefault(),f(true));},E=S=>{editor.isDomNode(S.target)&&y.contains(S.target)||f();};return T.addEventListener("keydown",C),T.addEventListener("pointerdown",E,true),()=>{T.removeEventListener("keydown",C),T.removeEventListener("pointerdown",E,true);}},[o,f]),At.useLayoutEffect(()=>{if(!u){i(null);return}let y=a.current;if(!y)return;let T=y.offsetParent;if(!T){i(null);return}let x=u.rect,C=vr(T,x.left,x.bottom),E=Math.max(0,T.scrollWidth-y.offsetWidth);i({left:Math.max(0,Math.min(C.left,E)),top:C.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let h=At.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let y=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return y?f(true):n(T=>T&&{...T,error:true}),y},[e,o,f,p.replaceEnabled]),b=At.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let y=e.surface.equations.removeEquation(o.activation.equation.id);return y?f(true):n(T=>T&&{...T,error:true}),y},[e,o,f,p.removeEnabled]);if(!o)return null;let v=[o.error?d:null,p.reason?m:null].filter(Boolean).join(" ");return jsxRuntime.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:Qd,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":v||void 0,onChange:y=>n(T=>T&&{...T,draft:y.target.value,error:false}),onKeyDown:y=>{y.key!=="Enter"||y.nativeEvent.isComposing||(y.preventDefault(),h());}}),o.error?jsxRuntime.jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,p.reason?jsxRuntime.jsx("div",{id:m,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:p.reason}):null,jsxRuntime.jsxs("div",{className:"docx-equation-popup__actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!p.replaceEnabled,title:p.reason??void 0,onMouseDown:Qd,onClick:h,children:t("equationPopup.apply")}),jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!p.removeEnabled,title:p.reason??void 0,onMouseDown:Qd,onClick:b,children:t("equationPopup.delete")})]})]})}var Hg="review.comments",eu="review.addComment";function Ag(e){return e!==Hg?e:(en(`The context-menu row "${Hg}" is now "${eu}". The old id still works in this release; write "${eu}".`),eu)}function Er(e,t){if(!At.isValidElement(e)||e.type!==At.Fragment)return null;let n=At.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function Dl({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of At.Children.toArray(t)){let f=r(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,h)=>{let b=n(f,h);d.add(b);let v=a?.(f),y=v?m(v):void 0,T=s.get(b);return jsxRuntime.jsx(At.Fragment,{children:T??i(f,h,y)},b)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(At.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var OP="review.addComment",BP=e=>e.editingMode==="viewing";function Rl(e){let{isEnabled:t,disabledReason:o}=ie(OP),n=W(BP);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var Ha=At.createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onWatermarkDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),Sr="docx-menubar-more",Ml=At.createContext({measuring:false,overflow:new Set,inMore:false});function Zg(){return At.useContext(Ml)}function it(){return At.useContext(Ha)}function De(){let{t:e}=it(),{t}=L();return o=>e?.(o)??t(o)}var Pr=At.createContext(-1);var WP='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function An(e){return [...e.querySelectorAll(WP)].filter(t=>t.closest('[role="menu"]')===e)}function nu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function Yt(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function Xt(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function ru(e){let t=e?.ownerDocument.activeElement;((t&&e?.contains(t)?t.closest("[data-menu]"):null)?.querySelector(':scope > [role="menuitem"]')??e?.querySelector('.docx-menubar__trigger[aria-expanded="true"]'))?.focus({preventScroll:true});}function qg(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var rn="data-toolbar-group",On="data-toolbar-fixed",Oa="data-toolbar-more",QP=34,_l=new Set;function Il(e,t,o){let n=At.useRef(null),r=At.useRef(new Map),i=At.useRef(QP),[a,l]=At.useState(_l),s=At.useRef(a);s.current=a;let c=At.useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),m=o.join("\0"),u=At.useCallback(()=>{let p=n.current;if(!p||!e)return;let f=editor.hostWindowOf(p),h=f.getComputedStyle(p),b=editor.readColumnGap(h),v=editor.readAvailableWidth(p,h),y=p.querySelector(".docx-toolbar__separator"),T=b*2;if(y){let w=f.getComputedStyle(y),k=editor.readInlineMargins(w);T=editor.separatorLeadingCost(y.offsetWidth,k.start,k.end,b);}for(let w of p.querySelectorAll(`[${rn}]`)){let k=w.getAttribute(rn);k&&w.offsetWidth>0&&r.current.set(k,editor.collapsibleGroupCost(w.offsetWidth,T));}let x=0;for(let w of p.querySelectorAll(`[${On}]`))w.offsetWidth>0&&(x+=editor.trailingGapCost(w.offsetWidth,b));let C=p.querySelector(`[${Oa}]`);C&&C.offsetWidth>0&&(i.current=editor.trailingGapCost(C.offsetWidth,b));let E={available:v,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:x,more:i.current,previous:s.current,hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS},D=s.current.size===0&&editor.controlsOverflow(p,h)===false?_l:editor.toolbarOverflowGroups(E);editor.sameOverflow(D,s.current)||(s.current=D,l(D));},[e]),g=At.useCallback(p=>{n.current=p;},[]);return At.useLayoutEffect(()=>{if(!e){s.current.size>0&&(s.current=_l,l(_l));return}u();},[e,d,u,m]),At.useEffect(()=>{let p=n.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let h=0,b=new f.ResizeObserver(()=>{h===0&&(h=f.requestAnimationFrame(()=>{h=0,u();}));});b.observe(p),p.parentElement&&b.observe(p.parentElement);for(let v of p.querySelectorAll(`[${rn}], [${On}]`))b.observe(v);return ()=>{h!==0&&f.cancelAnimationFrame(h),b.disconnect();}},[e,d,u,m,a]),{attach:g,overflow:a}}function $g(e,t,o){let n=e.overflow.has(t),r=t===Sr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[rn]:t}:{},...r?{[Oa]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Vg(e,t,o){let[n,r]=At.useState(void 0);return At.useLayoutEffect(()=>{if(!e){r(void 0);return}let i=()=>{let l=t.current,s=o.current,c=l?.parentElement,d=l?.ownerDocument.defaultView;if(!l||!s||!c||!d)return;let m=l.getBoundingClientRect(),u=editor.toolbarPanelPlacement({triggerLeft:m.left,triggerRight:m.right,panelWidth:s.offsetWidth,viewportWidth:d.innerWidth});r({left:u.left-c.getBoundingClientRect().left,right:"auto",maxInlineSize:u.maxWidth});};i();let a=t.current?.ownerDocument.defaultView;return a?.addEventListener("resize",i),()=>a?.removeEventListener("resize",i)},[e,o,t]),n}var jg=12700,Gg=96;function ik(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function lk(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Nl(e){let t=editor.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 o=editor.sniffImageMime(e);if(!ik(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let n=editor.validateRasterHeader(e,o);if(!n)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(n.pixelWidth*n.pixelHeight>t.maxPixels||n.pixelWidth>t.maxDimension||n.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=lk(n.pixelWidth,n.pixelHeight,n.dpiX??Gg,n.dpiY??Gg);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function an(e){return Math.round(e/jg*100)/100}function Ba(e){return Math.round(e*jg)}function au({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=L();return jsxRuntime.jsx(Be,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:n,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:i("imageInsert.errors.title")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body","data-docx-part":"message",children:e}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:t,children:i("common.close")})})]})})}var Xg="image/png,image/jpeg,image/gif",lu=At.createContext(null);function Qg(){let e=At.useContext(lu);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Wa(){return At.useContext(lu)}function Fl({children:e}){let t=H(),{t:o}=L(),n=At.useRef(null),r=At.useRef(false),i=St(),[a,l]=At.useState(null),s=At.useRef(null),c=At.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=W(c,(y,T)=>y.enabled===T.enabled&&y.disabledReason===T.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=At.useCallback(async y=>{if(!t||r.current)return;let T=Nl(y);if(!T.ok){l(o(T.reasonKey));return}let x={type:"insertImage",data:T.bytes,mime:T.mime,widthPoints:T.widthPoints,heightPoints:T.heightPoints};r.current=true;try{let C=await editor.executeImageCommand(t,x);C.ok?t.focus():l(i18n.localizeDisabledReason(bk(C.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=At.useCallback(async y=>{let T=y?.[0];if(!T)return;let x=await T.arrayBuffer();await g(new Uint8Array(x));},[g]),f=At.useCallback(async y=>{if(!y)return;let T=[...y.files].find(x=>x.type.startsWith("image/"));if(T){await p([T]);return}for(let x of y.items){if(x.kind!=="file"||!x.type.startsWith("image/"))continue;let C=x.getAsFile();if(!C)continue;let E=await C.arrayBuffer();await g(new Uint8Array(E));return}},[g,p]),h=At.useCallback(()=>{if(!m)return;let y=n.current,T=t?editor.editorHostDocument(t):null;if(!T||!y||y.ownerDocument===T){y?.click();return}s.current?.remove();let x=T.createElement("input");x.type="file",x.accept=Xg,x.hidden=true,x.tabIndex=-1,x.setAttribute("aria-hidden","true");let C=()=>{x.remove(),s.current===x&&(s.current=null);};x.addEventListener("change",()=>{p(x.files).finally(C);},{once:true}),x.addEventListener("cancel",C,{once:true}),T.body.append(x),s.current=x,x.click();},[t,m,p]),b=At.useCallback(async y=>{let T=y.currentTarget;await p(T.files),T.value="";},[p]),v=At.useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:b}),[h,p,f,m,u,b]);return jsxRuntime.jsxs(lu.Provider,{value:v,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:Xg,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:b,onMouseDown:y=>y.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Te(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(au,{message:a,onClose:()=>l(null)}))]})}function Hl({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Qg(),l=ee();if(t)return null;let s=Q("image.insert"),c=l(s?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:q,onClick:r};return o?jsxRuntime.jsx(j,{...d,children:n}):jsxRuntime.jsx("button",{...d,children:n??te(s?.paths)})}Hl.docxSlot="image.insert";var Za=Object.assign(Hl,{docxSlot:"image.insert"});function bk(e){return e&&/\s/.test(e)?e:void 0}var su=6,ob=6;function Ol({slot:e,label:t,onInserted:o,className:n}){let r=H(),{isEnabled:i}=ie(e),[a,l]=At.useState(null),[s,c]=At.useState({rows:1,cols:1}),d=At.useRef(null),m=At.useCallback((p,f)=>{if(!r||!i)return;let h={type:"insertTable",rows:p,cols:f};r.can(h).ok&&(r.exec(h),o(),r.focus());},[r,i,o]),u=At.useCallback(p=>{c(f=>{let h={rows:Math.min(ob,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(su,Math.max(1,p.toCol??f.cols+(p.cols??0)))};return l(h),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${h.rows}x${h.cols}"]`)?.focus()),h});},[]),g=[];for(let p=1;p<=ob;p+=1){let f=[];for(let h=1;h<=su;h+=1){let b=!!a&&p<=a.rows&&h<=a.cols;f.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${h}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===h?0:-1,...b?{"data-filled":""}:{},"aria-label":`${h} \xD7 ${p}`,onMouseDown:q,onMouseEnter:()=>l({rows:p,cols:h}),onFocus:()=>l({rows:p,cols:h}),onClick:()=>m(p,h)},h));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":t,className:`docx-menubar__grid${n?` ${n}`:""}`,onMouseLeave:()=>l(null),onKeyDown:p=>{if(p.key==="ArrowRight")u({cols:1});else if(p.key==="ArrowLeft")u({cols:-1});else if(p.key==="ArrowDown")u({rows:1});else if(p.key==="ArrowUp")u({rows:-1});else if(p.key==="Home")u({toCol:1});else if(p.key==="End")u({toCol:su});else return;p.preventDefault(),p.stopPropagation();},children:[jsxRuntime.jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsxRuntime.jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function Dr({slot:e="table.insert",className:t}){let{setOpenMenu:o}=it(),n=De(),r=At.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(Ol,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Ek({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=ie(editor.chromeProbeForSlot("insert.watermark")),r=it(),i=De();if(t)return null;let a=Q("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsxRuntime.jsx(_e,{slot:"insert.watermark",icon:te(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Bl=Object.assign(Ek,{docxSlot:"insert.watermark"});var kk={type:"openGoTo",fromShortcut:true};function nb(){let e=ie(kk),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(Zt,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function wk({className:e,hidden:t}){return jsxRuntime.jsx(Zt,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var Wl=Object.assign(wk,{docxSlot:"insert.bookmark"});function _e(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,m=e["data-value"],u=Ho(),g=At.useId(),p=At.useContext(Pr),f=n&&r?g:void 0;return jsxRuntime.jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${c?` ${c}`:""}`,tabIndex:p,...l?{"data-slot":l}:{},...m!==void 0?{"data-value":m}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...r?{title:r}:{},onMouseDown:q,onClick:n?void 0:s,children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsxRuntime.jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,f?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function Ka({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=De();if(n)return null;let a=e??(t===void 0?void 0:i(t));return jsxRuntime.jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?jsxRuntime.jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function ql(e){if(e.slotId)return e.slotId;if(e.slot)return sg(e.slot),e.slot;dg();}function Zt(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=ql(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=ie(i),{setOpenMenu:m}=it(),u=De();if(r||!i)return null;let g=Q(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(_e,{slot:i,icon:te(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...h?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...n?{className:n}:{},children:p})}Zt.docxMenuRow=true;function Ua(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=it(),c=De(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=Q(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(_e,{slot:e,icon:te(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var du=Ua("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),uu=Ua("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),pu=Ua("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),mu=Ua("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),fu=Ua("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function Lk({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=ie(editor.chromeProbeForSlot("file.pageSetup")),r=it(),i=De();if(t)return null;let a=Q("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsxRuntime.jsx(_e,{slot:"file.pageSetup",icon:te(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function Fk({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=ie(editor.chromeProbeForSlot("paragraph.dialog")),r=it(),i=De();if(t)return null;let a=Q("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsxRuntime.jsx(_e,{slot:"paragraph.dialog",icon:te(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Hk=Object.assign(Fk,{docxSlot:"paragraph.dialog"}),gu=Object.assign(Lk,{docxSlot:"file.pageSetup"});function Ak({className:e,hidden:t}){let o=Wa(),n=it(),r=De();if(t)return null;let i=Q("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(_e,{slot:"image.insert",icon:te(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var bu=Object.assign(Ak,{docxSlot:"image.insert"}),qa=8;function Jt({labelKey:e,label:t,paths:o,className:n,children:r}){let i=De(),[a,l]=At.useState(false),s=At.useRef(null),c=At.useRef(null),d=At.useId();t===void 0&&e===void 0&&ug();let m=t??i(e??""),[u,g]=At.useState(null);return At.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;if(!p||!f||!h)return;let b=p.getBoundingClientRect(),v=f.offsetWidth,y=f.offsetHeight,T=b.right+v>h.innerWidth-qa;g({left:T?Math.max(qa,b.left-v):Math.min(b.right,h.innerWidth-v-qa),top:Math.max(qa,Math.min(b.top-4,h.innerHeight-y-qa))});},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{p.key==="ArrowRight"&&editor.hostDocumentOf(s.current).activeElement===s.current?(p.preventDefault(),l(true),queueMicrotask(()=>{c.current&&Xt(An(c.current),"first");})):(p.key==="ArrowLeft"||p.key==="Escape")&&a&&(p.preventDefault(),p.stopPropagation(),l(false),s.current?.focus());},onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||l(false);},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:q,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:te(o)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:m}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsxRuntime.jsx("div",{ref:c,id:d,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":m,style:u?{position:"fixed",left:u.left,top:u.top}:{position:"fixed",visibility:"hidden"},onKeyDown:p=>{let f=c.current;if(!f)return;let h=An(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),Yt(h,editor.hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),Yt(h,editor.hostDocumentOf(f).activeElement,-1));},children:jsxRuntime.jsx(Pr.Provider,{value:-1,children:r})}):null]})}function Ok({entry:e}){let{isEnabled:t}=ie(e.slot),o=Q(e.slot);return t?jsxRuntime.jsx(Jt,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(Dr,{slot:e.slot})}):jsxRuntime.jsx(Zt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Bn({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function za({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Bn,{}):e.kind==="submenu"?jsxRuntime.jsx(Jt,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsxRuntime.jsx(za,{entry:o},n))}):e.slot==="file.open"?jsxRuntime.jsx(du,{}):e.slot==="file.save"?jsxRuntime.jsx(uu,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(pu,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(mu,{}):e.slot==="file.print"?jsxRuntime.jsx(fu,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(gu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(Hk,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(Bl,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(Wl,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(nb,{}):e.slot==="image.insert"?jsxRuntime.jsx(bu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(Ok,{entry:e}):jsxRuntime.jsx(Zt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function sb(e){if(!At.isValidElement(e))return null;let t=Er(e,sb);if(t!==null)return t;let o=e.type;return typeof o!="function"&&typeof o!="object"?null:typeof o.docxSlot=="string"?o.docxSlot:o.docxMenuRow===true?ql(e.props)??null:null}function Bk(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function ib(e,t,o){return Dl({entries:e??[],children:t,preset:o,keyOfEntry:Bk,keyOfChild:sb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsxRuntime.jsx(za,{entry:n,children:i})})}function Qt({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d,opening:m}=it(),u=Zg(),g=De(),p=At.useId(),f=At.useRef(null),h=At.useRef(null),b=At.useRef(false),v=At.useRef(false),y=editor.CHROME_MENUS.find(k=>k.id===e),T=s===e,x=Vg(T&&e===Sr,f,h);if(i)return null;let C=o??g(t??y?.labelKey??e),E=$g(u,e,d);if(E.skip)return null;if(E.asSubmenu)return jsxRuntime.jsx(Jt,{labelKey:t??y?.labelKey??e,label:C,children:ib(y?.entries,l,a)});let S=ib(y?.entries,l,a),D=E.iconOnly,w=()=>{c(null),f.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...E.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":T,"aria-controls":T?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:E.tabStop?0:-1,...T?{"data-open":""}:{},...D?{"aria-label":C,title:C}:{},onMouseDown:q,onKeyDown:k=>{k.key==="ArrowDown"||k.key==="Enter"||k.key===" "||k.key==="ArrowUp"?(k.preventDefault(),b.current=true,c(e)):k.key==="Escape"&&T&&(k.preventDefault(),w());},onClick:()=>{if(v.current){v.current=false;return}c(T?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(v.current=true,c(e));},onMouseLeave:()=>{v.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,D?null:C]}),T?jsxRuntime.jsx("div",{ref:k=>{h.current=k,k&&b.current&&(b.current=false,Xt(An(k),"first"));},id:p,role:"menu","aria-label":C,style:x,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:k=>{let F=h.current;if(!F)return;let I=An(F),N=editor.hostDocumentOf(F).activeElement;k.key==="ArrowDown"?(k.preventDefault(),Yt(I,N,1)):k.key==="ArrowUp"?(k.preventDefault(),Yt(I,N,-1)):k.key==="Home"?(k.preventDefault(),Xt(I,"first")):k.key==="End"?(k.preventDefault(),Xt(I,"last")):k.key==="Escape"?(k.preventDefault(),k.stopPropagation(),w()):k.key==="Tab"&&c(null);},children:jsxRuntime.jsx(Pr.Provider,{value:-1,children:S})}):null]})}function hu(e){return Object.assign(o=>jsxRuntime.jsx(Qt,{id:e,...o}),{docxMenu:e})}var yu=hu("file"),vu=hu("format"),xu=hu("insert");var Kl=At.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Bo(){return At.useContext(Kl)}function db(){return At.useContext(Kl).target}var qk=e=>e.pageSetup??null,Kk=e=>e.editable;function Wn(){let e=H(),t=W(qk),o=W(Kk),n=At.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=At.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 At.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var Tu=[{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}],gb=1440,$k=e=>Math.round(e/gb*100)/100,Vk=e=>Math.round(e*gb);function Gk(e,t){let o=Math.min(e,t),n=Math.max(e,t);return Tu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var mb=12240,fb=15840,ln=1440;function jk({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=po(e,t),{pageSetup:s,isEnabled:c,apply:d}=Wn(),[m,u]=At.useState(mb),[g,p]=At.useState(fb),[f,h]=At.useState("portrait"),[b,v]=At.useState(ln),[y,T]=At.useState(ln),[x,C]=At.useState(ln),[E,S]=At.useState(ln),[D,w]=At.useState(false),[k,F]=At.useState("document"),I=At.useRef(null),N=At.useRef("no");At.useEffect(()=>{if(!e){N.current="no";return}if(N.current==="yes"&&s===null){N.current="no";return}N.current==="yes"||N.current==="loading"&&s===null||(w(false),u(s?.pageWidthTwips??mb),p(s?.pageHeightTwips??fb),h(s?.orientation??"portrait"),v(s?.marginsTwips.top??ln),T(s?.marginsTwips.bottom??ln),C(s?.marginsTwips.left??ln),S(s?.marginsTwips.right??ln),F("document"),N.current=s===null?"loading":"yes");},[e,s]);let A=At.useCallback(K=>{let X=Tu[K];X&&(u(f==="landscape"?X.height:X.width),p(f==="landscape"?X.width:X.height));},[f]),P=At.useCallback(K=>{K!==f&&(h(K),u(g),p(m));},[f,m,g]),M=At.useCallback(()=>{if(!c)return;if(!l()){t();return}let K=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:b,marginRightTwips:E,marginBottomTwips:y,marginLeftTwips:x,scope:k});w(!K),K&&t();},[c,l,d,m,g,f,b,E,y,x,k,t]);if(!e)return null;let $=Gk(m,g),U=(K,X,le)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${K[0].toUpperCase()}${K.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${K}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:$k(X),onChange:B=>le(Math.max(0,Vk(Number(B.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"in"})]}),oe={pageWidth:m,pageHeight:g,orientation:f,marginTop:b,marginBottom:y,marginLeft:x,marginRight:E,scope:k},Y={pageWidth:u,pageHeight:p,orientation:P,marginTop:v,marginBottom:T,marginLeft:C,marginRight:S,scope:F},ne={values:oe,setValue(K,X){Y[K](X);},errors:D?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:M,cancel:t};return jsxRuntime.jsx(Be,{kind:"pageSetup",className:o,style:n,panelRef:I,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:K=>{K.key==="Escape"&&t(),K.key==="Enter"&&editor.isHTMLElementNode(K.target)&&K.target.localName==="input"&&c&&(K.preventDefault(),M());},children:jsxRuntime.jsx(yo.Composition,{state:ne,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:$,onChange:K=>A(Number(K.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[Tu.map((K,X)=>jsxRuntime.jsx("option",{value:X,children:a(K.labelKey)},K.labelKey)),$<0&&jsxRuntime.jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:f,onChange:K=>P(K.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsxRuntime.jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsxRuntime.jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label docx-dialog__section-label--spaced",children:a("dialogs.pageSetup.margins")}),U("top",b,v),U("bottom",y,T),U("left",x,C),U("right",E,S),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:k,onChange:K=>F(K.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsxRuntime.jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsxRuntime.jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:D?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:M,children:a("common.apply")})]})]}),children:r})})}var yo=Tt();function Yk(){return yo.useState()}var Zn=Object.assign(jk,{Header:yo.Header,Title:yo.Title,Body:yo.Body,Footer:yo.Footer,Apply:yo.Apply,Cancel:yo.Cancel,Error:yo.Error,Field:yo.Field});var ew={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},tw=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??ew;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,direction:t.disagrees?.direction??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},ow=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],nw=(e,t)=>ow.every(o=>e.disagrees[o]===t.disagrees[o]),rw=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.direction===t.direction&&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&&nw(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),aw=e=>e.editable;function Eu(){let e=H(),t=W(tw,rw),o=W(aw),n=At.useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=At.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:n,apply:r}}function sw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=po(e,t),{format:s,isEnabled:c,apply:d}=Eu(),[m,u]=At.useState("left"),[g,p]=At.useState("ltr"),[f,h]=At.useState(0),[b,v]=At.useState(0),[y,T]=At.useState("none"),[x,C]=At.useState(0),[E,S]=At.useState(0),[D,w]=At.useState(0),[k,F]=At.useState("multiple"),[I,N]=At.useState(1.08),[A,P]=At.useState(false),[M,$]=At.useState(false),[U,oe]=At.useState(false),[Y,ne]=At.useState(true),[K,X]=At.useState(false),[le,B]=At.useState([]),[_,O]=At.useState(false),[ae,se]=At.useState(0),[he,Me]=At.useState("left"),[je,$e]=At.useState("none"),[Pe,Ct]=At.useState(editor.NO_MIXED_FIELDS),[Io,No]=At.useState(false),Xo=z=>a(Io&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),$t=At.useRef(editor.NO_MIXED_FIELDS),ce=At.useId(),[rt,Ee]=At.useState(false),Jo=At.useRef(null),co=At.useRef(false),Bt=At.useRef(null);At.useEffect(()=>{if(!e){co.current=false;return}if(co.current||s===null)return;let z=editor.seedFields(s);u(z.alignment),p(z.direction),h(z.indentLeft),v(z.indentRight),T(z.special),C(z.specialBy),S(z.spaceBefore),w(z.spaceAfter),F(z.lineRule),N(z.lineValue),P(z.contextualSpacing),$(z.keepNext),oe(z.keepLines),ne(z.widowControl),X(z.pageBreakBefore),B(z.tabStops),O(false);let xe=editor.mixedFieldsOf(s);Ct(xe),No(s.indentUnknown),se(0),Me("left"),$e("none"),$t.current=xe,Ee(false),Bt.current=z,co.current=true;},[e,s]);let Dn=At.useCallback(()=>{if(!c)return;if(!l()){t();return}let z=Bt.current,xe=z===null?null:editor.changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:b,special:y,specialBy:x,spaceBefore:E,spaceAfter:D,lineRule:k,lineValue:I,contextualSpacing:A,keepNext:M,keepLines:U,widowControl:Y,pageBreakBefore:K,tabStops:le,clearedAllTabStops:_},$t.current,Pe);if(xe===null){t();return}if(d(xe)){Ee(false),t();return}Ee(true);},[c,l,d,t,Pe,_,m,g,f,b,y,x,E,D,k,I,A,M,U,Y,K,le]),de=At.useCallback(()=>{let z=Math.round(ae);return z<=0?false:(Ct(xe=>({...xe,tabStops:false})),B(editor.withTabStop(le,{positionTwips:z,alignment:he,...je!=="none"?{leader:je}:{}})),se(0),Me("left"),$e("none"),true)},[le,ae,he,je]);if(!e)return null;let ue=z=>Ct(xe=>({...xe,[z]:false})),Ne=(z,xe,Qo,ft)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":ft,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${ce}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Pe[ft]?"":editor.twipsToInches(xe),placeholder:Pe[ft]?Xo(ft):void 0,onChange:Ea=>{ue(ft),Qo(editor.inchesToTwips(Number(Ea.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),ye=(z,xe,Qo,ft)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${ce}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Pe[ft]?"":xe,placeholder:Pe[ft]?Xo(ft):void 0,onChange:Ea=>{ue(ft),Qo(Math.max(0,Number(Ea.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),at=(z,xe,Qo)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:xe,ref:ft=>{ft&&(ft.indeterminate=Pe[z]);},onChange:ft=>{Ct(Ea=>({...Ea,[z]:false})),Qo(ft.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Lo={alignment:m,direction:g,indentLeft:f,indentRight:b,special:y,specialBy:x,spaceBefore:E,spaceAfter:D,lineRule:k,lineValue:I,contextualSpacing:A,keepNext:M,keepLines:U,widowControl:Y,pageBreakBefore:K,tabStops:le,clearedAllTabStops:_},uo=z=>{let xe=$t.current;z!==g&&!xe.direction&&!xe.alignment&&u(editor.alignmentAfterDirectionChange),p(z);},id={alignment:u,direction:uo,indentLeft:h,indentRight:v,special:T,specialBy:C,spaceBefore:S,spaceAfter:w,lineRule:F,lineValue:N,contextualSpacing:P,keepNext:$,keepLines:oe,widowControl:ne,pageBreakBefore:X,tabStops:B,clearedAllTabStops:O},Of={values:Lo,mixed:Pe,setValue(z,xe){id[z](xe),z==="lineRule"?(ue("lineSpacing"),N(xe===Bt.current?.lineRule?Bt.current.lineValue:xe==="multiple"?1.08:12)):z==="specialBy"?ue("special"):z in Pe&&ue(z);},errors:rt?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:Dn,cancel:t};return jsxRuntime.jsx(Be,{kind:"paragraph",className:o,style:n,panelRef:Jo,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let xe=editor.isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!xe){let Qo=z.target;if(editor.isHTMLElementNode(Qo)&&Qo.dataset.docxTabEntry!==void 0){de();return}c&&Dn();}},children:jsxRuntime.jsx(vo.Composition,{state:Of,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__columns",children:[jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${ce}-alignment`,className:"docx-dialog__input",value:Pe.alignment?"":m,onChange:z=>{ue("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Pe.alignment?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsxRuntime.jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${ce}-direction`,className:"docx-dialog__input",value:Pe.direction?"":g,onChange:z=>{ue("direction"),uo(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Pe.direction?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsxRuntime.jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),Ne("beforeText",f,h,"indentLeft"),Ne("afterText",b,v,"indentRight"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${ce}-special`,className:"docx-dialog__input",value:Pe.special?"":y,onChange:z=>{ue("special"),T(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Pe.special?jsxRuntime.jsx("option",{value:"",children:Xo("special")}):null,jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsxRuntime.jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsxRuntime.jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),y!=="none"?jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${ce}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Pe.special?"":editor.twipsToInches(x),placeholder:Pe.special?Xo("special"):void 0,onChange:z=>{ue("special"),C(Math.max(0,editor.inchesToTwips(Number(z.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),le.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(Pe.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):le.map(z=>jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:editor.formatInches(z.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[z.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>B(le.filter(xe=>xe!==z)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(z.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},z.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${ce}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(ae),onChange:z=>se(Math.max(0,editor.inchesToTwips(Number(z.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${ce}-tabAlignment`,className:"docx-dialog__input",value:he,onChange:z=>Me(z.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsxRuntime.jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${ce}-tabLeader`,className:"docx-dialog__input",value:je,onChange:z=>$e(z.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsxRuntime.jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsxRuntime.jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsxRuntime.jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:de,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Ct(z=>({...z,tabStops:false})),O(true),B([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),ye("spaceBefore",E,S,"spaceBefore"),ye("spaceAfter",D,w,"spaceAfter"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${ce}-lineSpacing`,className:"docx-dialog__input",value:Pe.lineSpacing?"":k,onChange:z=>{let xe=z.target.value;ue("lineSpacing"),F(xe),N(xe===Bt.current?.lineRule?Bt.current.lineValue:xe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Pe.lineSpacing?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsxRuntime.jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsxRuntime.jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ce}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${ce}-at`,type:"number",className:"docx-dialog__input",min:.01,step:k==="multiple"?.01:1,value:Pe.lineSpacing?"":I,disabled:Pe.lineSpacing,onChange:z=>{let xe=z.target.value.trim();N(xe===""?k==="multiple"?1.08:12:Number(xe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:k==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),at("contextualSpacing",A,P),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),at("keepNext",M,$),at("widowControl",Y,ne),at("keepLines",U,oe),at("pageBreakBefore",K,X)]})]})}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:rt?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:Dn,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var vo=Tt();function cw(){return vo.useState()}var Zo=Object.assign(sw,{Header:vo.Header,Title:vo.Title,Body:vo.Body,Footer:vo.Footer,Apply:vo.Apply,Cancel:vo.Cancel,Error:vo.Error,Field:vo.Field});var eo=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var ku=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],wu=[null,.5,1,1.5,2,5],Du=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],Db="image/png,image/jpeg,image/gif,image/bmp,image/webp",Ru={kind:"none",imageData:null,imageName:null,scale:null,washout:true,text:"DRAFT",fontFamily:"Calibri",fontSizePt:null,bold:false,italic:false,transparency:.5,color:"C0C0C0",layout:"diagonal"},Vl=/^[0-9A-Fa-f]{6}$/;function Rb(e,t){let o={...Ru};return e?e.kind==="image"?{...o,kind:t?.imageData?"picture":"none",imageData:t?.imageData??null,scale:t?.scale??null,washout:e.washout??t?.washout??true}:{...o,kind:"text",text:e.text??o.text,fontFamily:e.fontFamily??o.fontFamily,fontSizePt:e.fontSizePt??null,bold:e.bold??false,italic:e.italic??false,transparency:e.transparency??o.transparency,color:e.color&&Vl.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function Mb(e){if(e.kind==="none")return null;if(e.kind==="picture")return e.imageData?{imageData:e.imageData,scale:e.scale,washout:e.washout}:void 0;if(e.text.trim()!=="")return {text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,color:e.color,transparency:e.transparency,layout:e.layout}}var _b=e=>`#${Vl.test(e)?e.toLowerCase():"c0c0c0"}`;function Ib(e){let t=e.startsWith("#")?e.slice(1):e;return Vl.test(t)?t.toUpperCase():null}var Mu=e=>Math.round(Math.min(1,Math.max(0,e))*100);function _u(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Nb(e,t){return e===t?true:!e||!t?false:e.kind===t.kind&&e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color===t.color&&e.transparency===t.transparency&&e.layout===t.layout&&e.washout===t.washout}function Lb(e,t){return e!==null&&t.kind==="none"?null:t}function Fb(e,t){return e.kind!==t.kind?false:e.kind==="none"?true:e.kind==="picture"?e.imageData===t.imageData&&e.scale===t.scale&&e.washout===t.washout:e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color.toUpperCase()===t.color.toUpperCase()&&e.transparency===t.transparency&&e.layout===t.layout}var Hb=(e,t)=>t.includes(e)?e:"",uw={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Gl(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??uw,i=o/20,a=n/20,l=Math.max(72,(o-r.left-r.right)/20),s=Math.max(72,(n-r.top-r.bottom)/20);return {width:i,height:a,area:{x:r.left/20,y:r.top/20,width:l,height:s}}}var Sb=12,Pb=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function Ab(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+Sb<=t.y+t.height;r++){let a=Pb[r%Pb.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:Sb}),i+=o;}return n}var Ob="contrast(0.157068) brightness(1.91)",Iu=100,qo=e=>Math.round(e*100)/100,Bb=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function Wb(e,t=Gl(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let n=editor.watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!n)return null;let{cx:r,cy:i}=Bb(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Vl.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:qo(1-Math.min(1,Math.max(0,e.transparency))),box:{x:qo(r-n.width/2),y:qo(i-n.height/2),width:qo(n.width),height:qo(n.height)},rotation:e.layout==="diagonal"?-45:0}}var kb=new WeakMap;function pw(e){if(!e)return null;let t=kb.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}kb.set(e,t);}return t}function Zb(e,t){let o=Iu,n=pw(t);if(n){n.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let r=n.measureText(e.text),i=-(r.actualBoundingBoxLeft??0),a=r.actualBoundingBoxRight??r.width,l=-(r.actualBoundingBoxAscent??0),s=r.actualBoundingBoxDescent??0;if(a>i&&s>l)return {left:i,right:a,top:l,bottom:s}}return {left:0,right:.55*o*Array.from(e.text).length,top:-0.7*o,bottom:0}}function qb(e,t){let{x:o,y:n,width:r,height:i}=e.box,a=r>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(r-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=n+l-t.top*c,u=p=>String(Math.round(p*1e4)/1e4),g=`matrix(${u(s)} 0 0 ${u(c)} ${u(d)} ${u(m)})`;return e.rotation?`rotate(${e.rotation} ${u(o+r/2)} ${u(n+i/2)}) ${g}`:g}function Kb(e,t=Gl(null)){if(e.kind!=="picture"||!e.imageData)return null;let o=editor.watermarkShapeBox({imageData:e.imageData,scale:e.scale},t.area);if(!o)return null;let{cx:n,cy:r}=Bb(t);return {x:qo(n-o.width/2),y:qo(r-o.height/2),width:qo(o.width),height:qo(o.height)}}var mw=e=>e.editable,fw={ok:false,code:"unsupported",reason:"editor is not ready"};function Lu(){let e=H(),t=At.useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,Nb),n=W(mw),r=At.useMemo(()=>n&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,n]),i=At.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=At.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):fw,[e]);return At.useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var vw=e=>e.pageSetup??null,to=Tt(),xw=to.part("preview");function Vb(){return to.useState()}var zb=e=>`${Math.round(e*100)}%`;function Cw(e){let[t,o]=At.useState(null);return At.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let n=URL.createObjectURL(new Blob([e]));return o(n),()=>URL.revokeObjectURL(n)},[e]),t}function Tw({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Vb(),i=H(),a=W(vw),l=At.useMemo(()=>Gl(a),[a]),s=Cw(r.kind==="picture"?r.imageData:null),c=Wb(r,l),d=s?Kb(r,l):null;return jsxRuntime.jsx("div",{...n,"data-docx-part":"preview","aria-hidden":"true",className:["docx-dialog__preview",e].filter(Boolean).join(" "),style:t,children:jsxRuntime.jsxs("svg",{className:"docx-dialog__preview-page",viewBox:`0 0 ${l.width} ${l.height}`,focusable:"false",children:[jsxRuntime.jsx("rect",{className:"docx-dialog__preview-sheet",x:0,y:0,width:l.width,height:l.height}),c?jsxRuntime.jsx("text",{"data-docx-watermark-preview":"text",x:0,y:0,fontFamily:c.fontFamily,fontSize:Iu,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:qb(c,Zb(c,i?editor.editorHostDocument(i):null)),children:c.text}):null,s&&d?jsxRuntime.jsx("image",{"data-docx-watermark-preview":"picture",className:"docx-dialog__preview-picture",href:s,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:"none",style:r.washout?{filter:Ob}:void 0}):null,Ab(l).map(m=>jsxRuntime.jsx("rect",{className:"docx-dialog__preview-line",x:m.x,y:m.y,width:m.width,height:m.height},m.y))]})})}function Ew({open:e,onClose:t,presets:o=ku,className:n,style:r,children:i,preset:a=true}){let{t:l}=L(),s=H(),c=po(e,t),{isEnabled:d,read:m,apply:u}=Lu(),g=W(eo),[p,f]=At.useState({...Ru}),[h,b]=At.useState([]),[v,y]=At.useState(null),[T,x]=At.useState(false),[C,E]=At.useState(0),S=At.useRef(null),D=At.useRef(null),w=At.useRef(null),k=At.useId(),F=At.useRef(false);At.useEffect(()=>{if(!e||g||!s){F.current=false;return}if(F.current)return;F.current=true;let _=s.getWatermark(),O=Rb(_,m());S.current=Lb(_,O),f(O),b(s.getAvailableFonts()),y(null),x(false),E(ae=>ae+1);},[e,g,s,m]),At.useEffect(()=>{C!==0&&D.current?.querySelector(`input[name="${k}-kind"]:checked`)?.focus({preventScroll:true});},[C,k]);let I=At.useCallback((_,O)=>{y(null),f(ae=>({...ae,[_]:O}));},[]),N=Mb(p),A=d&&N!==void 0,P=At.useCallback(()=>{if(!A||N===void 0)return;if(!c()){t();return}if(S.current&&Fb(S.current,p)){t();return}let _=u(N);_.ok?t():y(_.reason);},[A,N,p,c,u,t]),M=At.useCallback(_=>{_&&(x(false),_.arrayBuffer().then(O=>{f(ae=>({...ae,kind:"picture",imageData:new Uint8Array(O),imageName:_.name})),y(null);}).catch(()=>x(true)));},[]);if(!e)return null;let $=p.kind==="picture",U=p.kind==="text",oe=h.includes(p.fontFamily)?h:[p.fontFamily,...h],Y=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),ne=v!==null?l("dialogs.watermark.refused"):null,K=(_,O,ae)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${k}-kind`,checked:p.kind===O,onChange:()=>I("kind",O)}),jsxRuntime.jsx("span",{id:`${k}-${_}-label`,children:ae})]}),X=(_,O,ae)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${k}-${_}`,children:O}),ae]}),le=(_,O,ae)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!ae,checked:p[_],onChange:se=>I(_,se.target.checked)}),jsxRuntime.jsx("span",{children:O})]}),B={values:p,setValue:I,errors:ne?{form:ne}:{},isEnabled:A,apply:P,cancel:t};return jsxRuntime.jsx(Be,{kind:"watermark",className:n,style:r,panelRef:D,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:_=>{let O=_.target;_.key==="Enter"&&editor.isHTMLElementNode(O)&&O.localName==="input"&&(O.type==="text"||O.type==="number")&&A&&(_.preventDefault(),P());},children:jsxRuntime.jsx(to.Composition,{state:B,preset:a,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:l("dialogs.watermark.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__watermark-layout",children:[jsxRuntime.jsx(Tw,{"data-docx-part":"preview"}),jsxRuntime.jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsxRuntime.jsx("legend",{className:"docx-editor-sr-only",children:l("dialogs.watermark.kind")}),K("noWatermark","none",l("dialogs.watermark.noWatermark")),K("pictureWatermark","picture",l("dialogs.watermark.picture")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${k}-pictureWatermark-label`,children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"picture",className:"docx-dialog__row",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{I("kind","picture"),w.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:T?l("dialogs.watermark.pictureFailed"):Y}),jsxRuntime.jsx("input",{ref:w,type:"file",accept:Db,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:_=>{let O=_.target.files?.[0];_.target.value="",M(O);}})]}),X("scale",l("dialogs.watermark.scale"),jsxRuntime.jsxs("select",{id:`${k}-scale`,className:"docx-dialog__select",disabled:!$,value:p.scale===null?"auto":String(p.scale),onChange:_=>I("scale",_.target.value==="auto"?null:Number(_.target.value)),children:[wu.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):zb(_)},String(_))),p.scale!==null&&!wu.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:zb(p.scale)}):null]})),le("washout",l("dialogs.watermark.washout"),$)]}),K("textWatermark","text",l("dialogs.watermark.text")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${k}-textWatermark-label`,children:[X("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${k}-preset`,className:"docx-dialog__select",disabled:!U,value:Hb(p.text,o),onChange:_=>{_.target.value!==""&&I("text",_.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))]})),X("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${k}-text`,type:"text",className:"docx-dialog__input",disabled:!U,maxLength:256,value:p.text,onChange:_=>I("text",_.target.value)})),X("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${k}-fontFamily`,className:"docx-dialog__select",disabled:!U,value:p.fontFamily,onChange:_=>I("fontFamily",_.target.value),children:oe.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))})),X("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${k}-fontSizePt`,className:"docx-dialog__select",disabled:!U,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:_=>I("fontSizePt",_.target.value==="auto"?null:Number(_.target.value)),children:[Du.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):String(_)},String(_))),p.fontSizePt!==null&&!Du.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[le("bold",l("dialogs.watermark.bold"),U),le("italic",l("dialogs.watermark.italic"),U)]}),X("transparency",l("dialogs.watermark.transparency"),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{type:"range",className:"docx-dialog__range",min:0,max:100,step:1,disabled:!U,"aria-label":l("dialogs.watermark.transparency"),value:Mu(p.transparency),onChange:_=>I("transparency",_u(_.target.value,p.transparency))}),jsxRuntime.jsx("input",{id:`${k}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!U,value:Mu(p.transparency),onChange:_=>I("transparency",_u(_.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),X("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${k}-color`,type:"color",className:"docx-dialog__color",disabled:!U,value:_b(p.color),onChange:_=>{let O=Ib(_.target.value);O&&I("color",O);}})),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"layout",className:"docx-dialog__row",role:"radiogroup","aria-label":l("dialogs.watermark.layout"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:l("dialogs.watermark.layout")}),["diagonal","horizontal"].map(_=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${k}-layout`,disabled:!U,checked:p.layout===_,onChange:()=>I("layout",_)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${_}`)})]},_))]})]})]})]})}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",...v?{title:v}:{},children:ne}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!A,"data-docx-part":"apply",onClick:P,children:l("common.apply")})]})]}),children:i})})}var qn=Object.assign(Ew,{Header:to.Header,Title:to.Title,Body:to.Body,Preview:xw,Footer:to.Footer,Apply:to.Apply,Cancel:to.Cancel,Error:to.Error,Field:to.Field});var Yl={ok:false,code:"unsupported",reason:"editor is not ready"},Pw=Object.freeze([]);function Au(e,t){return e.length===t.length&&e.every((o,n)=>o.name===t[n].name&&o.order===t[n].order&&o.story===t[n].story&&o.empty===t[n].empty&&o.atSelection===t[n].atSelection&&o.duplicates===t[n].duplicates&&o.hidden===t[n].hidden&&o.place===t[n].place)}function Ou(){let e=H(),t=At.useCallback(c=>e?.query({type:"bookmarks"})??Pw,[e]),o=W(t,Au),n=At.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=W(n),i=At.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):Yl,[e]),a=At.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):Yl,[e]),l=At.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):Yl,[e]),s=At.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):Yl,[e]);return At.useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var jb={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function _w(e){return e.open?jsxRuntime.jsx(Iw,{...e}):null}function Iw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=po(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=Ou(),[p,f]=At.useState(()=>editor.bookmarkDialogInitialName(s)),[h,b]=At.useState("name"),[v,y]=At.useState(false),[T,x]=At.useState(false),[C,E]=At.useState(false),[S,D]=At.useState(false),w=At.useRef(null),k=At.useRef(null),F=At.useId(),I=At.useId(),N=At.useId(),A=editor.bookmarkDialogRows(s,{sortBy:h,showHidden:v}),P=editor.bookmarkDialogNameState(s,p,c),M=P.problem&&!P.existing&&(C||p.length>0)?P.problem:null,$=P.existing?.duplicates??0,U=T?a("dialogs.bookmark.refused"):M?a(jb[M]):$>0?a("dialogs.bookmark.duplicates",{count:$}):P.existing&&P.canAdd?a("dialogs.bookmark.nameExists"):null,oe=At.useCallback(()=>{if(E(true),!P.canAdd)return;if(!l()){t();return}let B=d(p);x(!B.ok),B.ok&&t();},[P.canAdd,l,d,p,t]),Y=At.useCallback(()=>{if(!P.canDelete||!P.existing)return;let B=m(P.existing.name);x(!B.ok),B.ok&&f("");},[P,m]),ne=At.useCallback(()=>{if(!P.canGoTo||!P.existing)return;let B=u(P.existing.name);x(!B.ok),B.ok&&D(true);},[P,u]),K=At.useCallback(()=>{let B=P.existing;!B||!c||x(!g(B.name).ok);},[P.existing,c,g]),X=P.existing?.name??"";At.useLayoutEffect(()=>{!X&&k.current&&(k.current.selectedIndex=-1);});let le={values:{name:p,sortBy:h,showHidden:v},setValue(B,_){B==="name"?f(_):B==="sortBy"?b(_):y(_),x(false);},errors:M?{name:a(jb[M])}:T?{form:a("dialogs.bookmark.refused")}:{},isEnabled:P.canAdd,apply:oe,cancel:t,rows:A,canDelete:P.canDelete,canGoTo:P.canGoTo,duplicates:$,remove:Y,goTo:ne,keepFirst:K};return jsxRuntime.jsx(Be,{kind:"bookmark",className:o,style:n,panelRef:w,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:B=>{B.key==="Enter"&&!B.nativeEvent.isComposing&&B.keyCode!==229&&editor.isHTMLElementNode(B.target)&&B.target.localName==="input"&&B.target.getAttribute("type")==="text"&&(B.preventDefault(),oe());},children:jsxRuntime.jsx(It.Composition,{state:le,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.bookmark.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"name",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:F,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:F,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":M?true:void 0,"aria-describedby":I,onChange:B=>le.setValue("name",B.target.value)})]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children:jsxRuntime.jsx("select",{ref:k,className:"docx-dialog__input docx-dialog__input--full docx-bookmark-dialog__list",size:8,value:X,"aria-label":a("dialogs.bookmark.list"),onChange:B=>le.setValue("name",B.target.value),onDoubleClick:ne,children:A.map(B=>jsxRuntime.jsx("option",{value:B.name,children:B.name},B.name))})}),A.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__hint",children:a("dialogs.bookmark.empty")}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"sortBy",className:"docx-dialog__row",role:"radiogroup","aria-label":a("dialogs.bookmark.sortBy"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:a("dialogs.bookmark.sortBy")}),["name","location"].map(B=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:N,checked:h===B,onChange:()=>le.setValue("sortBy",B)}),a(B==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},B))]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"showHidden",className:"docx-dialog__row",children:jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:B=>le.setValue("showHidden",B.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:I,"data-docx-part":"error",role:"status",className:M||T?"docx-dialog__error":"docx-dialog__hint",children:U}),$>0?jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:K,children:a("dialogs.bookmark.keepFirst")}):null]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!P.canAdd,onClick:oe,children:a("dialogs.bookmark.add")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!P.canDelete,onClick:Y,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!P.canGoTo,onClick:ne,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(S?"common.close":"common.cancel")})]})]}),children:r})})}var It=Tt();function Nw(){return It.useState()}var $a=Object.assign(_w,{Header:It.Header,Title:It.Title,Body:It.Body,Footer:It.Footer,Apply:It.Apply,Cancel:It.Cancel,Error:It.Error,Field:It.Field,Delete:It.part("delete"),GoTo:It.part("goto"),KeepFirst:It.part("keepfirst")});var Xb=editor.SPLIT_CELL_FALLBACK_MAX;function Zw(e){return e.open?jsxRuntime.jsx(Kw,{...e}):null}var qw=e=>e;function Kw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=H(),s=po(e,t),c=At.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=At.useState(()=>editor.initialSplitCellCounts(c,P=>l?l.can(P):{ok:false,code:"unsupported",reason:""})),[m,u]=At.useState(d.columns),[g,p]=At.useState(d.rows),[f,h]=At.useState(null),b=At.useId(),v=At.useId(),y=At.useId(),{counts:T,problem:x}=editor.readSplitCellCounts(m,g,c),C=T?.cols??null,E=T?.rows??null;W(qw);let S=l&&T?l.can({type:"splitCell",...T}):null,D=x?.kind==="range"?a("dialogs.splitCell.range",{max:x.max}):x?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):S&&!S.ok?i18n.localizeDisabledReason(S.reason??null,a):null,w=S?.ok===true,k=f??D,F=x?.kind==="range"?x.field:null,I=At.useCallback(()=>{if(!w||!l)return;if(!s()){t();return}let P=l.exec({type:"splitCell",rows:E,cols:C});P.ok?t():h(i18n.localizeDisabledReason(P.reason??null,a));},[w,l,s,t,E,C,a]),N={values:{columns:m,rows:g},setValue(P,M){P==="columns"?u(M):p(M),h(null);},errors:k?{form:k}:{},isEnabled:w,apply:I,cancel:t,limits:c},A=(P,M,$,U,oe)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":P,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:M,children:a($)}),jsxRuntime.jsx("input",{id:M,type:"number",inputMode:"numeric",className:"docx-dialog__input",min:1,max:oe,step:1,value:U,"aria-invalid":F===P?true:void 0,"aria-describedby":y,onChange:Y=>N.setValue(P,Y.target.value)})]});return jsxRuntime.jsx(Be,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:P=>{P.key==="Enter"&&!P.nativeEvent.isComposing&&P.keyCode!==229&&editor.isHTMLElementNode(P.target)&&P.target.localName==="input"&&(P.preventDefault(),I());},children:jsxRuntime.jsx(xo.Composition,{state:N,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("table.splitCell")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[A("columns",b,"dialogs.splitCell.columns",m,c?.maxCols??Xb),A("rows",v,"dialogs.splitCell.rows",g,c?.maxRows??Xb),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:y,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:k})})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!w,onClick:I,children:a("dialogs.splitCell.submit")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")})]})]}),children:r})})}var xo=Tt();function Uw(){return xo.useState()}var Va=Object.assign(Zw,{Header:xo.Header,Title:xo.Title,Body:xo.Body,Footer:xo.Footer,Apply:xo.Apply,Cancel:xo.Cancel,Error:xo.Error,Field:xo.Field});var Jb=At.createContext(void 0),Qb=Jb.Provider;function Qe(){let e=At.useContext(Jb),{t}=L();return At.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Co=Tt();function Xw(){return Co.useState()}function Jw({session:e,...t}){let[o,n]=At.useState(e),[r,i]=At.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(Qw,{session:e,...t},r):null}function Qw({session:e,children:t,preset:o,className:n,style:r}){let i=Qe(),a=W(()=>e.canApply()),[l,s]=At.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=At.useState(e.signal.aborted),[m,u]=At.useState(false);At.useEffect(()=>{let v=()=>d(true);return e.signal.addEventListener("abort",v),e.signal.aborted&&v(),()=>e.signal.removeEventListener("abort",v)},[e]);let g=()=>{if(e.signal.aborted)return;let v=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!v);},p={values:l,setValue(v,y){s(T=>({...T,[v]:y,...v==="type"?{format:""}:{}})),u(false);},errors:m?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let f=editor.TEXT_FORM_FORMATS[l.type]??[],h={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},b=(v,y)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":v,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${v}`)}),y]});return jsxRuntime.jsx(Be,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),e.cancel()),v.key==="Enter"&&editor.isHTMLElementNode(v.target)&&v.target.localName==="input"&&(v.preventDefault(),g());},children:jsxRuntime.jsx(Co.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[b("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:v=>p.setValue("defaultText",v.target.value)})),b("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:v=>p.setValue("type",v.target.value),children:[["regular","number","date"].map(v=>jsxRuntime.jsx("option",{value:v,children:i(`textFormField.${v}`)},v)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),b("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:v=>p.setValue("maxLength",v.target.valueAsNumber)})),b("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:v=>p.setValue("format",v.target.value),children:[f.map(v=>jsxRuntime.jsx("option",{value:v,children:h[v]?i(h[v]):v||i("textFormField.noFormat")},v)),f.includes(l.format)?null:jsxRuntime.jsx("option",{value:l.format,disabled:true,children:l.format||i("textFormField.noFormat")})]})),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:l.enabled,onChange:v=>p.setValue("enabled",v.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var ja=Object.assign(Jw,{Header:Co.Header,Title:Co.Title,Body:Co.Body,Footer:Co.Footer,Apply:Co.Apply,Cancel:Co.Cancel,Error:Co.Error,Field:Co.Field});var oh=At.createContext(null),To=()=>At.useContext(oh);function nh({popups:e,children:t}){let o=H(),n=vd(),[r,i]=At.useState(null),[a,l]=At.useState(null),[s,c]=At.useState(null),[d,m]=At.useState(null),u=At.useRef(d);u.current=d;let g=At.useRef(e);g.current=e;let p=At.useRef(null),f=At.useRef(s);f.current=s;let h=()=>l(null);At.useEffect(()=>{if(a!==null)return;let x=p.current;p.current=null,x?.isConnected&&x.focus({preventScroll:true});},[a]),At.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(x){if(g.current?.textFormField===false){x.cancel();return}u.current?.cancel(),l(null),c(x),x.signal.addEventListener("abort",()=>c(C=>C===x?null:C),{once:true});}},{fallback:true})},[o]),At.useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let x=o.setRevisionMarkupChrome({onRequest(C){if(g.current?.revisionMarkup===false){C.cancel();return}f.current?.cancel(),l(null),m(C),C.signal.addEventListener("abort",()=>m(E=>E===C?null:E),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),x();}},[o,r,e?.revisionMarkup===false]),At.useEffect(()=>{l(null),c(null),m(null);},[o,n]);let b=e?.bookmark===false;At.useEffect(()=>{if(!(!o||!r||b))return o.setBookmarkChrome({onRequest(){f.current?.cancel(),u.current?.cancel(),p.current=rD(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,b]),At.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let v=At.useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(x,C){f.current?.cancel(),u.current?.cancel(),g.current?.[x]!==false&&(p.current=C??r?.ownerDocument.activeElement,l(x));}}),[r,e?.pageSetup]),y={open:true,onClose:h},T=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Te(e.pageSetup,y):jsxRuntime.jsx(Zn,{...y}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Te(e.paragraph,y):jsxRuntime.jsx(Zo,{...y}):a==="watermark"&&e?.watermark!==false?e?.watermark?Te(e.watermark,y):jsxRuntime.jsx(qn,{...y}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Te(e.bookmark,y):jsxRuntime.jsx($a,{...y}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Te(e.splitCell,y):jsxRuntime.jsx(Va,{...y}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Te(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Pa,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Te(e.textFormField,{session:s},s):jsxRuntime.jsx(ja,{session:s}):null;return jsxRuntime.jsxs(oh.Provider,{value:v,children:[t,r?reactDom.createPortal(T,r):null]})}function rD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function rh(){let e=To();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer})}function ah({children:e}){let t=To();return t?.container?reactDom.createPortal(e,t.container):e}var ih=["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"],lh=["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"],Zu=["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"],sh=["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"],ch=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],dh=["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"],uh=["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 Fr(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=H(),{close:d}=Bo(),m=De(),{isEnabled:u,disabledReason:g}=ie(t);return s?null:jsxRuntime.jsx(_e,{slot:e,icon:r??te(o.paths),shortcut:m(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:m(i??o.labelKey)})},{docxRow:e})}var Ya=Fr("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:ih}),Xa=Fr("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:lh}),Ja=Fr("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:sh}),Qa=Fr("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:uh});function Hr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=ke(),d=De(),m=At.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=ie(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(_e,{slot:"edit.paste",icon:e??te(Zu),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:h}=await lD(c);(f||h)&&i?.exec({type:"paste",text:f,...h?{html:h}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.paste")})}Hr.docxRow="edit.paste";async function lD(e){let t=editor.hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let n=await o.read(),r="",i=null;for(let a of n)a.types.includes("text/plain")&&(r=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(r||i)return {text:r,html:i}}catch{}return {text:await o.readText(),html:null}}function Ar({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=ke(),d=De(),m=At.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=ie(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(_e,{slot:"edit.pasteWithoutFormatting",icon:e??te(Zu),shortcut:d(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let f=await editor.hostWindowOf(c).navigator.clipboard.readText();f&&i?.exec({type:"pasteWithoutFormatting",text:f});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}Ar.docxRow="edit.pasteWithoutFormatting";var mh=Q("format.painter")?.paths??[],os=Fr("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:mh}),ns=Fr("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:mh});function dn(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=Bo(),d=De(),m=ei(),{isEnabled:u,disabledReason:g,execute:p}=ie(t);return l||!m?null:jsxRuntime.jsx(_e,{slot:e,icon:r??te(o.paths),disabled:!u,...g?{title:g}:{},className:`${s??o.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{p()&&c(true);},children:d(i??o.labelKey)})},{docxRow:e})}var Or=dn("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),Br=dn("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),Wr=dn("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),Zr=dn("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),qr=dn("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),Kr=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=Bo(),i=De(),a=ei(),l=To(),{isEnabled:s,disabledReason:c}=ie("table.splitCell");return n||!a||!l?null:jsxRuntime.jsx(_e,{slot:"table.splitCell",icon:e??te(editor.tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{r(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),Ur=dn("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),zr=dn("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),$r=dn("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),sD=[{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 Un({hidden:e}){let{close:t}=Bo(),o=De(),n=ei(),r=ie({type:"setTableCellVerticalAlignment",alignment:"top"}),i=ie({type:"setTableCellVerticalAlignment",alignment:"center"}),a=ie({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];return e||!n?null:jsxRuntime.jsxs("div",{className:"docx-contextmenu__table-align",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":o("tableAdvanced.verticalAlignment"),children:sD.map((s,c)=>{let d=l[c];return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":o(s.labelKey),title:d.disabledReason??o(s.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:m=>{m.preventDefault(),m.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:te(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}Un.docxRow="table.cellVerticalAlignment";function fh(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=H(),{close:c,tocId:d}=Bo(),m=De(),u=At.useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=ie(u);return l||d===null?null:jsxRuntime.jsx(_e,{slot:e,icon:r??te(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:m(i??o.labelKey)})},{docxRow:e})}var Vr=fh("toc.refresh","entire",{labelKey:"toc.refresh",paths:ch}),Gr=fh("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:dh});function ei(){return W(At.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function rs({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=Bo();return jsxRuntime.jsx(_e,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var zn=At.createContext(false);function Nt(){return At.useContext(zn)?"":"docx-editor "}var ls=8;function gD(){let e=At.useContext(_t),t=it(),o=De(),{isEnabled:n,reason:r}=Rl(o);if((e?.mounted??0)===0)return null;let i=Q("review.addComment");return jsxRuntime.jsx(_e,{icon:te(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function bD(){let e=H(),t=it(),o=De();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(_e,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var hD=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(bD,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(Ya,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(Xa,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(Hr,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(Ar,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(os,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(ns,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(Ja,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(Qa,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(Zt,{slotId:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(gD,{})}];function yD(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Or.docxRow,render:()=>jsxRuntime.jsx(Or,{})},{kind:"row",id:Br.docxRow,render:()=>jsxRuntime.jsx(Br,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Wr.docxRow,render:()=>jsxRuntime.jsx(Wr,{})},{kind:"row",id:Zr.docxRow,render:()=>jsxRuntime.jsx(Zr,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:qr.docxRow,render:()=>jsxRuntime.jsx(qr,{})},{kind:"row",id:Kr.docxRow,render:()=>jsxRuntime.jsx(Kr,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:Ur.docxRow,render:()=>jsxRuntime.jsx(Ur,{})},{kind:"row",id:zr.docxRow,render:()=>jsxRuntime.jsx(zr,{})},{kind:"row",id:$r.docxRow,render:()=>jsxRuntime.jsx($r,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Un.docxRow,render:()=>jsxRuntime.jsx(Un,{})}]}function vD(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Vr.docxRow,render:()=>jsxRuntime.jsx(Vr,{})},{kind:"row",id:Gr.docxRow,render:()=>jsxRuntime.jsx(Gr,{})}]}function xD(e,t=false){return [...hD,...e?yD():[],...t?vD():[]]}function xh(e){if(!At.isValidElement(e))return null;let t=Er(e,xh);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=ql(e.props);if(n)return n}return null}function yh(e){if(!At.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function CD(e){return e?.closest(".docx-editor__scroll-container")??null}function oi({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=Nt(),l=H(),{t:s}=L(),c=ei(),d=At.useRef(null),m=At.useRef(null),[u,g]=At.useState(null),[p,f]=At.useState(null),[h,b]=At.useState(null),v=At.useMemo(()=>xD(c,p!==null),[c,p]),[y,T]=At.useState(null),x=At.useCallback((I=false)=>{g(null),T(null),f(null),b(null),I&&l?.focus();},[l]);At.useEffect(()=>{if(n)return;let I=CD(d.current);if(!I)return;let N=A=>{A.preventDefault();let P=A.button===-1||A.clientX===0&&A.clientY===0,M=I.getBoundingClientRect();f(l?.snapshot().tocContext?.id??null),b(P||!editor.isHTMLElementNode(A.target)?null:A.target),g(P?{x:M.left+16,y:M.top+16}:{x:A.clientX,y:A.clientY});};return I.addEventListener("contextmenu",N),()=>I.removeEventListener("contextmenu",N)},[n,l]),At.useEffect(()=>{n&&x();},[n,x]),At.useEffect(()=>{if(!u)return;let I=$=>{m.current?.contains($.target)||x();},N=$=>{$.key==="Escape"?($.preventDefault(),x(true)):$.key==="Tab"&&x();},A=()=>x(),P=editor.hostDocumentOf(d.current??m.current),M=editor.hostWindowOf(d.current??m.current);return P.addEventListener("pointerdown",I,true),P.addEventListener("keydown",N),P.addEventListener("scroll",A,{capture:true,passive:true}),M.addEventListener("blur",A),M.addEventListener("resize",A),()=>{P.removeEventListener("pointerdown",I,true),P.removeEventListener("keydown",N),P.removeEventListener("scroll",A,true),M.removeEventListener("blur",A),M.removeEventListener("resize",A);}},[u,x]),At.useLayoutEffect(()=>{let I=m.current;if(!u||!I)return;let{width:N,height:A}=I.getBoundingClientRect(),P=editor.hostWindowOf(I),M=P.innerWidth-N-ls,$=P.innerHeight-A-ls,U=Math.max(ls,u.x>M?u.x-N:u.x),oe=Math.max(ls,u.y>$?u.y-A:u.y);T({x:U,y:oe});},[u]),At.useLayoutEffect(()=>{y&&m.current?.focus({preventScroll:true});},[y]);let C=At.useRef(r);C.current=r;let E=At.useRef(false);At.useEffect(()=>{let I=u!==null;I!==E.current&&(E.current=I,C.current?.(I));},[u]);let S=At.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>x(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,x]),[D,w]=At.useState(null),k=At.useMemo(()=>({close:x,anchor:u,tocId:p,target:h,clipboardRefusal:D,reportClipboardRefusal:w}),[x,u,p,h,D]),F={position:"fixed",left:(y??u)?.x??0,top:(y??u)?.y??0,visibility:y?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:d,style:{display:"contents"},children:u?jsxRuntime.jsx(Ha.Provider,{value:S,children:jsxRuntime.jsx(Kl.Provider,{value:k,children:jsxRuntime.jsxs("div",{ref:m,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??s("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:F,onKeyDown:I=>{let N=m.current;if(!N)return;let A=An(N);I.key==="ArrowDown"?(I.preventDefault(),Yt(A,editor.hostDocumentOf(N).activeElement,1)):I.key==="ArrowUp"?(I.preventDefault(),Yt(A,editor.hostDocumentOf(N).activeElement,-1)):I.key==="Home"?(I.preventDefault(),Xt(A,"first")):I.key==="End"&&(I.preventDefault(),Xt(A,"last"));},children:[At.Children.toArray(i).filter(yh),Dl({entries:v,children:At.Children.toArray(i).filter(I=>!yh(I)),preset:o,keyOfEntry:I=>I.id,keyOfChild:I=>Ag(xh(I)),renderEntry:I=>I.kind==="separator"?jsxRuntime.jsx(Bn,{}):I.render(),onUnmatched:(I,N)=>{N.props.hidden&&cg(I);}})]})})}):null})}var zu=Object.assign(oi,{Cut:Ya,Copy:Xa,Paste:Hr,PasteWithoutFormatting:Ar,Delete:Ja,SelectAll:Qa,InsertRowAbove:Or,InsertRowBelow:Br,InsertColumnLeft:Wr,InsertColumnRight:Zr,MergeCells:qr,SplitCell:Kr,DeleteTableRow:Ur,DeleteTableColumn:zr,DeleteTable:$r,CellVerticalAlignment:Un,RefreshToc:Vr,RefreshTocPageNumbers:Gr,Item:rs,Slot:Zt,Row:_e,Group:Ka,Separator:Bn,Submenu:Jt});var Ch=Nd.Provider;function Th(){let e=St(),{t}=L();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Te(e.hyperlink,{}),e?.contentControl&&Te(e.contentControl,{}),e?.equation&&Te(e.equation,{}),e?.contextMenu&&Te(e.contextMenu,{t:o=>t(o)})]})}function Eh(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(_a,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(La,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(Fa,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Te(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(oi,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function PD(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 $u(){let e=H(),t=At.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=W(t,PD);return o?.kind==="note"?o:null}function Sh(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 Ph(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&&Sh(e.documentAuthored,t.documentAuthored)&&Sh(e.sectionAuthored,t.sectionAuthored)}function kD(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Ph(e.footnote,t.footnote)&&Ph(e.endnote,t.endnote)}function Vu(){let e=H(),t=At.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,kD)}function ni(e,t){let[o,n]=At.useState(null),r=At.useCallback(l=>n(l),[]),[i,a]=At.useState({visibility:"hidden"});return At.useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=editor.hostWindowOf(s),d=0,m=null,u=new c.ResizeObserver(()=>p()),g=()=>{d=0;let h=e(s);if(h!==m&&(u.disconnect(),u.observe(s),u.observe(o),h&&u.observe(h),m=h),!h||!h.isConnected){a({visibility:"hidden"});return}let b=h.getBoundingClientRect(),v=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,y=t==="story-label"?6:4,T=l===s,x=t==="after"?b.bottom+6:b.top-v-y,C=T?vr(s,b.left,x):{left:b.left,top:x},E=C.left,S=C.top,D=T?s.scrollLeft+8:8;a({position:T?"absolute":"fixed",left:t==="story-label"?E:Math.max(D,E+8),top:t==="story-label"?S:Math.max(T?s.scrollTop+8:8,S),...t==="story-label"?{width:Math.max(240,Math.min(b.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(b.width-16,s.clientWidth-16))},visibility:"visible"});},p=()=>{d||(d=c.requestAnimationFrame(g));};u.observe(s),u.observe(o);let f=new c.MutationObserver(p);return f.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",p,{passive:true}),c.addEventListener("resize",p),g(),()=>{d&&c.cancelAnimationFrame(d),u.disconnect(),f.disconnect(),s.removeEventListener("scroll",p),c.removeEventListener("resize",p);}},[o,e,t]),{ref:r,style:i}}var _D=/^(footnote|endnote):(-?\d{1,10})$/;function Dh(e){let t=_D.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function ID(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function ju(e){let t=H();return At.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function ND(e){let{t}=L(),[o,n]=At.useState(false),r=At.useRef(null);return At.useEffect(()=>{if(!o)return;let i=l=>{r.current?.contains(l.target)||n(false);},a=editor.hostDocumentOf(r.current);return a.addEventListener("mousedown",i),()=>a.removeEventListener("mousedown",i)},[o]),jsxRuntime.jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":o,"aria-haspopup":"menu",onMouseDown:q,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:q,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),n(false);},children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),n(false);},children:t("common.close")})]}):null]})}function ds({className:e}){let t=St(),o=At.useRef(null),{t:n}=L(),r=H(),i=$u(),[a,l]=At.useState(null),[s,c]=At.useState(null),[d,m]=At.useState(false),u=At.useRef(null),g=At.useCallback(F=>{if(!i)return null;let N=[...F.querySelectorAll("[data-docx-note-scope]")].find(A=>A.matches("[data-docx-note]")&&A.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=ni(g,"story-label"),f=At.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);At.useEffect(()=>{if(!r)return;let F=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!F)return;let I=P=>{let M=P.target;if(!M)return;let $=M.closest("[data-docx-note-ref]");if($?.dataset.docxNoteScope){P.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:$.dataset.docxNoteScope});return}M.closest("[data-docx-note-mark-back]")&&(P.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},N=P=>{let M=P,U=M.target?.closest("[data-docx-note-scope]");U?.dataset.docxNoteScope&&(M.preventDefault(),c({scopeId:U.dataset.docxNoteScope,x:M.clientX,y:M.clientY}));},A=P=>{let M=P.target;if(ID(M))return;let $=M?.closest("[data-docx-note-ref]");if(!$?.dataset.docxNoteScope){f();return}let U=$.dataset.docxNoteScope,Y=r.getNotePreviewText(U)??$.getAttribute("aria-description")??n("notes.previewFallback"),ne=$.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let K=editor.hostWindowOf($),X=K.setTimeout(()=>{l({scopeId:U,text:Y,x:ne.left,y:ne.bottom+4});},400);u.current={win:K,handle:X};};return F.addEventListener("click",I),F.addEventListener("contextmenu",N),F.addEventListener("pointerover",A),F.addEventListener("scroll",f,true),()=>{F.removeEventListener("click",I),F.removeEventListener("contextmenu",N),F.removeEventListener("pointerover",A),F.removeEventListener("scroll",f,true),f();}},[r,f,n]);let h=At.useCallback(F=>{r&&(r.exec(F),c(null));},[r]),b=s?Dh(s.scopeId):null,v=At.useMemo(()=>b?{type:"deleteNote",noteKind:b.noteKind,noteId:b.noteId}:null,[b]),y=At.useMemo(()=>b?{type:"convertNote",fromKind:b.noteKind,noteId:b.noteId}:null,[b]),T=At.useMemo(()=>b?{type:"convertAllNotes",fromKind:b.noteKind}:null,[b]),x=ju(v??{type:"deleteNote",noteKind:"footnote",noteId:0}),C=ju(y??{type:"convertNote",fromKind:"footnote",noteId:0}),E=ju(T??{type:"convertAllNotes",fromKind:"footnote"}),S=i?Dh(i.id):null,D=S?n("notes.editingRegion",{kind:S.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:S.noteId}):null,w=s&&b?{...s,...b,onDelete:()=>{v&&h(v);},onConvert:()=>{y&&h(y);},onConvertAll:()=>{T&&h(T);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:x.enabled,convertEnabled:C.enabled,convertAllEnabled:E.enabled,deleteDisabledReason:x.reason??void 0,convertDisabledReason:C.reason??void 0,convertAllDisabledReason:E.reason??void 0}:null,k={onClose:()=>m(false),onApply:F=>{h(F),m(false);}};return r?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&S?jsxRuntime.jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:vt.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:D}),jsxRuntime.jsx(ND,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Te(t.notePreview,a):jsxRuntime.jsx(hr,{...a}):null,w&&t?.notesContextMenu!==false?t?.notesContextMenu?Te(t.notesContextMenu,w):jsxRuntime.jsx(yr,{...w}):null,d&&t?.noteProperties!==false?t?.noteProperties?Te(t.noteProperties,k):jsxRuntime.jsx(us,{...k}):null]}):null}function us(e){let{t}=L(),o=H(),n=Vu(),[r,i]=At.useState("document"),[a,l]=At.useState("decimal"),[s,c]=At.useState("continuous"),[d,m]=At.useState("pageBottom"),[u,g]=At.useState("decimal"),[p,f]=At.useState("continuous"),[h,b]=At.useState("docEnd");At.useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),m(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),f(n.endnote.resolved.numRestart),b(n.endnote.resolved.pos));},[n]);let v=!n?.footnote.documentAuthored&&!n?.footnote.sectionAuthored,y=!n?.endnote.documentAuthored&&!n?.endnote.sectionAuthored;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","data-docx-modal":"","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:vt.modal},onClick:e.onClose,onKeyDown:T=>{T.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),children:[jsxRuntime.jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-note-properties__body",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__scope",children:[jsxRuntime.jsx("span",{children:t("notes.scope")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:r,onChange:T=>i(T.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),v?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:T=>l(T.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:s,onChange:T=>c(T.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:d,onChange:T=>m(T.target.value),children:[jsxRuntime.jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsxRuntime.jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),y?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:u,onChange:T=>g(T.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:p,onChange:T=>f(T.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:h,"data-testid":"docx-notes-endnote-position",onChange:T=>b(T.target.value),children:[jsxRuntime.jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsxRuntime.jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__footer",children:[jsxRuntime.jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsxRuntime.jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!o)return;let T={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:h}};o.can(T).ok&&e.onApply(T);},children:t("common.apply")})]})]})})}var Ih=e=>e.image;function _h(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===editor.hostDocumentOf(e).activeElement)}function WD(e){e&&!e.closest(".docx-editor")&&e.classList.add("docx-editor");}function ZD(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function op(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(an(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(an(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(an(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(an(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function qD(e,t){let o=op(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function ps(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=Ba(t);return Number.isInteger(o)?o:null}function KD(e,t){let o=op(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?ps(e.horizontalPoints):t.position?.horizontalEmu,u=d?ps(e.verticalPoints):t.position?.verticalEmu;return c&&m===null?{ok:false}:d&&u===null?{ok:false}:m===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=n?ps(e.horizontalPoints):t.position?.horizontalEmu,s=r?ps(e.verticalPoints):t.position?.verticalEmu;return n&&l===null?{ok:false}:r&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function ms(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function fs(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function ai({open:e,onClose:t,className:o,triggerRef:n}){let r=H(),{t:i}=L(),a=W(Ih),l=At.useId(),s=At.useId(),c=At.useId(),d=At.useRef(null),m=At.useRef(null),u=At.useRef(null),g=At.useRef(null),[p,f]=At.useState(null),[h,b]=At.useState(null),v=m.current,y=v?.canCrop===false,T=v?.canResize===false,x=v?.locks.changeAspect===true,C=v?.kind==="anchored"&&v.canMove===true,E=v?.kind==="inline",S=v?.kind==="anchored"&&v.canMove===false;At.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:$}=r.surface.state().selection;u.current={paragraphId:$.paragraphId,offset:$.offset},g.current=r.surface.session.packageRevision();}b(null);let P=op(a),M=a.crop;f({widthPoints:String(an(a.widthEmu)),heightPoints:String(an(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,...P});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let D=At.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=At.useCallback(()=>{t(),D();},[t,D]);At.useEffect(()=>{if(!e)return;let P=d.current;if(!P)return;let M=_h(P);(M.find(Y=>Y.id==="image-prop-width"&&!Y.hasAttribute("disabled"))??M.find(Y=>!Y.hasAttribute("disabled"))??P).focus();let U=Y=>{if(Y.key==="Escape"){Y.preventDefault(),w();return}if(Y.key!=="Tab")return;let ne=_h(P);if(ne.length===0)return;let K=editor.hostDocumentOf(P).activeElement,X=ne.findIndex(B=>B===K);if(X===-1)return;Y.preventDefault();let le=Y.shiftKey?(X-1+ne.length)%ne.length:(X+1)%ne.length;ne[le]?.focus();},oe=editor.hostDocumentOf(P);return oe.addEventListener("keydown",U),()=>oe.removeEventListener("keydown",U)},[e,w]);let k=At.useMemo(()=>{let P=v??a;return !P||P.widthEmu<=0?1:P.widthEmu/P.heightEmu},[a,v]),F=At.useCallback(P=>{f(M=>{if(!M)return M;if(!M.lockAspect)return {...M,widthPoints:P};let $=fs(P);if($===null)return {...M,widthPoints:P};let U=Math.round($/k*100)/100;return {...M,widthPoints:P,heightPoints:String(U)}});},[k]),I=At.useCallback(P=>{f(M=>{if(!M)return M;if(!M.lockAspect)return {...M,heightPoints:P};let $=fs(P);if($===null)return {...M,heightPoints:P};let U=Math.round($*k*100)/100;return {...M,widthPoints:String(U),heightPoints:P}});},[k]),N=At.useCallback(()=>{let P=m.current;if(!P?.intrinsic)return;let M=P.intrinsic.pixelWidth*72/P.intrinsic.dpiX,$=P.intrinsic.pixelHeight*72/P.intrinsic.dpiY;f(U=>U&&{...U,widthPoints:String(Math.round(M*100)/100),heightPoints:String(Math.round($*100)/100)});},[a]),A=At.useCallback(()=>{let P=m.current,M=u.current,$=g.current;if(!r||!P||!p||!M||$===null)return;let U={type:"setImageProperties",drawingNodeId:P.id,expectedPackageRevision:$,selectionParagraphId:M.paragraphId,selectionOffset:M.offset};if(!T){let le=fs(p.widthPoints),B=fs(p.heightPoints);if(le===null||B===null){b("imageProperties.errors.invalidDimensions");return}let _=Ba(le),O=Ba(B);_!==P.widthEmu&&(U.widthEmu=_),O!==P.heightEmu&&(U.heightEmu=O);}if(P.canCrop&&!y){let le=ms(p.cropLeft),B=ms(p.cropTop),_=ms(p.cropRight),O=ms(p.cropBottom);if(le===null||B===null||_===null||O===null){b("imageProperties.errors.invalidCrop");return}let ae=P.crop;(le!==ae.left||B!==ae.top||_!==ae.right||O!==ae.bottom)&&(U.crop={left:le,top:B,right:_,bottom:O});}p.title!==P.title&&(U.title=p.title),p.description!==P.description&&(U.description=p.description);let oe=p.hyperlink.trim();if(oe!==(P.hyperlink??"")&&(U.hyperlink=oe===""?null:oe),P.canChangeWrap&&p.wrap!==P.wrap&&(U.wrap=p.wrap),P.kind==="anchored"&&P.canMove&&qD(p,P)){let le=KD(p,P);if(!le.ok){b("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(le.value,P))){b("imageProperties.errors.invalidPosition");return}Object.assign(U,le.value);}if(!(U.widthEmu!==void 0||U.heightEmu!==void 0||U.title!==void 0||U.description!==void 0||U.hyperlink!==void 0||U.crop!==void 0||U.wrap!==void 0||U.horizontalEmu!==void 0||U.verticalEmu!==void 0||U.relativeToH!==void 0||U.relativeToV!==void 0)){w();return}if(!r.can(U).ok){b("imageProperties.errors.refused");return}if(!r.exec(U).ok){b("imageProperties.errors.refused");return}w();},[r,p,y,T,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:WD,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:P=>{P.stopPropagation(),ZD(P);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","data-docx-modal":"","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),children:[jsxRuntime.jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[h?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(h)}):null,jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsxRuntime.jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:T,onChange:P=>F(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsxRuntime.jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:T,onChange:P=>I(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:x,onChange:P=>f(M=>M&&{...M,lockAspect:P.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:y||!v?.intrinsic,onClick:N,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),E?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange:P=>f(M=>M&&{...M,relativeToH:P.target.value}),children:editor.DRAWING_REL_FROM_H.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsxRuntime.jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:p.relativeToV??"line",onChange:P=>f(M=>M&&{...M,relativeToV:P.target.value}),children:editor.DRAWING_REL_FROM_V.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]})]}):null,jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:P=>f(M=>M&&{...M,horizontalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:P=>f(M=>M&&{...M,verticalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsxRuntime.jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:P=>f(M=>M&&{...M,title:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:p.description,onChange:P=>f(M=>M&&{...M,description:P.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:c,className:"docx-dialog__input docx-dialog__input--full",value:p.hyperlink,onChange:P=>f(M=>M&&{...M,hyperlink:P.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("formattingBar.imageWrap")}),jsxRuntime.jsx("select",{id:s,className:"docx-dialog__select docx-dialog__input--full",value:p.wrap,disabled:v?.canChangeWrap===false,onChange:P=>f(M=>M&&{...M,wrap:P.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`imageWrap.targets.${P}`)},P))})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsxRuntime.jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:y,value:p.cropLeft,onChange:P=>f(M=>M&&{...M,cropLeft:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsxRuntime.jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:y,value:p.cropTop,onChange:P=>f(M=>M&&{...M,cropTop:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsxRuntime.jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:y,value:p.cropRight,onChange:P=>f(M=>M&&{...M,cropRight:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsxRuntime.jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:y,value:p.cropBottom,onChange:P=>f(M=>M&&{...M,cropBottom:P.target.value})})]}),y?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:A,children:i("common.apply")})]})]})})}function gs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=H(),{t:a}=L(),l=W(Ih),[s,c]=At.useState(false),d=At.useRef(null),m={type:"setImageProperties",description:"probe"},u=i&&l?i.can(m):null,g=u?.ok===true,p=u&&!u.ok?u.reason:null;if(t)return null;let f=Q("image.properties"),h={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:p??a("formattingBar.imagePropertiesShortcut"),onMouseDown:q,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(j,{...h,children:n}):jsxRuntime.jsx("button",{...h,children:n??te(f?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Te(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(ai,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}gs.docxSlot="image.properties";var Yr=Object.assign(gs,{docxSlot:"image.properties"});function ii(e){let t=H(),o=At.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=W(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return At.useMemo(()=>({execute:(r,i)=>editor.runToolbarCommand(t,e,r,i),value:n.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(n.value):n.value,options:e==="image.wrap"?editor.IMAGE_WRAP_TARGETS:[],isEnabled:n.enabled,disabledReason:n.disabledReason}),[t,e,n])}function bs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=ii("image.altText"),[d,m]=At.useState(false),[u,g]=At.useState(""),p=At.useRef(null),f=At.useRef(null),h=At.useId();At.useEffect(()=>{d&&g(l??"");},[d,l]),At.useEffect(()=>{if(!d)return;let C=D=>{let w=p.current;editor.isDomNode(D.target)&&(w?.contains(D.target)||w?.ownerDocument.getElementById(h)?.contains(D.target))||m(false);},E=D=>{D.key==="Escape"&&(D.preventDefault(),m(false),f.current?.focus());},S=editor.hostDocumentOf(p.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",E),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",E);}},[d,h]);let b=At.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let v=Q("image.altText"),y=i(v?.labelKey??"formattingBar.altText"),T={type:"button",ref:f,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?h:void 0,"aria-label":y,title:c??y,onMouseDown:q,onClick:()=>m(C=>!C)},x={id:h,value:u,onValueChange:g,onApply:b,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(j,{...T,children:n}):jsxRuntime.jsx("button",{...T,children:n??y}),d&&r?.imageAltText!==false?r?.imageAltText?Te(r.imageAltText,x):jsxRuntime.jsx(hs,{...x}):null]})}bs.docxSlot="image.altText";var li=Object.assign(bs,{docxSlot:"image.altText"});function hs({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=L();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:n,children:l("common.apply")})]})]})}function ap(e){let[t,o]=At.useState(e.session),[n,r]=At.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(tR,{...e},n)}function tR({session:e,className:t,style:o,children:n}){let r=Qe(),[i,a]=At.useState(e.signal.aborted),l=At.useRef(null);return At.useEffect(()=>{let s=()=>a(true);return e.signal.addEventListener("abort",s,{once:true}),e.signal.aborted&&s(),()=>e.signal.removeEventListener("abort",s)},[e]),i?null:jsxRuntime.jsx(Be,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:l,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&(s.preventDefault(),e.acknowledge());},children:n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:r("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:r(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:r("textFormField.apply")})})]})})}var Oh=At.createContext(null),Bh=Oh.Provider;function st(){let e=At.useContext(Oh);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function mR(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function Wh(e){let t=`docx-cc-list-${At.useId()}`,[o,n]=At.useState(()=>mR(e)),[r,i]=At.useState(()=>editor.calendarDateText(e.value,e.locale)),a=At.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=At.useState(false),c=At.useCallback(k=>{i(k),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=At.useState(()=>{let k=m??new Date;return {year:k.getFullYear(),month:k.getMonth()}}),p=At.useCallback(k=>{let F=e.apply(k??o);return s(!F),F},[e,o]),f=At.useCallback(()=>e.cancel(),[e]),h=At.useCallback(async k=>{if(!e.replaceImage)return s(true),false;try{let F=k instanceof Uint8Array?k.byteLength:k.size;if(!e.canApply()||F>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let I=k instanceof Uint8Array?k:new Uint8Array(await k.arrayBuffer()),N=await e.replaceImage(I);return s(!N),N}catch{return s(true),false}},[e]),b=At.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),v=At.useCallback(()=>{g(k=>editor.shiftMonth(k.year,k.month,-1)),E(null);},[]),y=At.useCallback(()=>{g(k=>editor.shiftMonth(k.year,k.month,1)),E(null);},[]),T=At.useCallback(k=>p(k),[p]),x=At.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[C,E]=At.useState(null),S=At.useCallback(k=>{let F=editor.parseIsoDate(k);F&&(g({year:F.getFullYear(),month:F.getMonth()}),E(editor.isoDateOf(F)));},[]),D=At.useCallback(()=>{let k=editor.calendarDateFromText(r,e.locale);return k?p(k):(s(true),false)},[r,e.locale,p]),w=At.useCallback((k,F)=>{!Number.isInteger(k)||k<100||k>9999||!Number.isInteger(F)||F<0||F>11||(g({year:k,month:F}),E(null));},[]);return At.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:b,previousMonth:v,nextMonth:y,selectDay:T,selectToday:x,focusIso:C,focusDay:S,dateText:r,setDateText:c,applyDateText:D,showMonth:w,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:h}),[e,h,o,d,l,p,f,b,v,y,T,x,C,S,r,c,D,w,a,t])}function et(e,t,o,n){if(t.hidden)return null;let{children:r,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":m,...u}=t,g=r===void 0?n:r,{key:p,...f}=o,h={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:v,style:y,...T}=f;return jsxRuntime.jsx(j,{...u,...T,...h,...a?{className:a}:{},style:{...y,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...f,...h,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var Gn=e=>e.stopPropagation();function cp(e){return et("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(dp,{}),jsxRuntime.jsx(xp,{}),jsxRuntime.jsx(up,{}),jsxRuntime.jsx(pp,{className:"docx-content-control-calendar-announcement"})]}))}function dp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:Gn,onClick:t.previousMonth},"\u2039")}function up(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:Gn,onClick:t.nextMonth},"\u203A")}function pp(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function mp(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,n)=>jsxRuntime.jsx("span",{children:o},n)))}function fp({day:e,...t}){let o=st(),n=o.calendar.days.find(i=>i.iso===o.focusIso)??o.calendar.days.find(i=>i.selected)??o.calendar.days.find(i=>i.today&&!i.otherMonth)??o.calendar.days.find(i=>!i.otherMonth),r=i=>{if(i.nativeEvent.isComposing||i.altKey||i.ctrlKey||i.metaKey)return;let a=editor.calendarDateForKey(e.iso,i.key,o.session.locale,i.shiftKey);a&&(i.preventDefault(),o.focusDay(a));};return et("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===n?.iso?0:-1,"aria-label":e.label,...e.selected?{"data-selected":"","aria-selected":true}:{},"aria-current":e.today?"date":void 0,"aria-selected":e.selected,...e.today?{"data-today":""}:{},...e.otherMonth?{"data-other-month":""}:{},disabled:!o.isEnabled,onMouseDown:Gn,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function gp(e){let t=st(),o=At.useRef(null);return At.useLayoutEffect(()=>{let n=o.current;if(!n||n.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?n.querySelector(`[data-iso="${t.focusIso}"]`):null)??n.querySelector("[data-selected]")??n.querySelector("[data-today]:not([data-other-month])")??n.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),et("div",e,{ref:o,className:"docx-content-control-calendar-grid","data-docx-part":"grid",role:"grid","aria-label":t.calendar.title},Array.from({length:6},(n,r)=>jsxRuntime.jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(r*7,r*7+7).map(i=>jsxRuntime.jsx(fp,{day:i},i.iso))},r)))}function bp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:Gn,onClick:t.selectToday},o("contentControl.calendar.today"))}function hp(e){return et("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(cp,{}),jsxRuntime.jsx(mp,{}),jsxRuntime.jsx(gp,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(bp,{}),jsxRuntime.jsx(vs,{})]}),jsxRuntime.jsx(Xr,{}),jsxRuntime.jsx(Cs,{})]}))}function yp({item:e,...t}){let o=st();return et("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(n=>n.value===o.value)<0?o.items[0]===e?0:-1:o.value===e.value?0:-1,"aria-selected":o.value===e.value,disabled:!o.isEnabled,onMouseDown:Gn,onClick:()=>o.apply(e.value)},e.displayText)}function ys(e){let t=st(),o=Qe();return et("div",e,{className:"docx-content-control-menu-list","data-docx-part":"list",role:"listbox",id:t.listId,"aria-label":o(`contentControl.types.${t.kind}`)},t.kind==="buildingBlockGallery"&&t.items.length===0?jsxRuntime.jsx("div",{className:"docx-content-control-menu-empty","data-docx-part":"empty",role:"note",tabIndex:0,children:o("contentControl.gallery.empty")}):t.items.map((n,r)=>jsxRuntime.jsx(yp,{item:n},r)))}function vs(e){let t=st(),o=Qe();return et("input",e,{type:"text",className:"docx-content-control-menu-input","data-docx-part":"input","aria-label":o(`contentControl.types.${t.kind}`),value:t.kind==="date"?t.dateText:t.value,placeholder:t.kind==="date"?editor.calendarDateText("2006-11-22",t.session.locale):void 0,"aria-invalid":t.refused||void 0,role:t.kind==="comboBox"?"combobox":void 0,"aria-expanded":t.kind==="comboBox"?true:void 0,"aria-controls":t.kind==="comboBox"?t.listId:void 0,"aria-autocomplete":t.kind==="comboBox"?"list":void 0,onKeyDown:n=>{n.key!=="Enter"||n.nativeEvent.isComposing||(n.preventDefault(),n.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:Gn,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function Xr(e){let t=st(),o=Qe();return t.refused?et("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function vp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-dialog__button docx-dialog__button--primary","data-docx-part":"apply",disabled:!t.isEnabled,onClick:()=>t.kind==="date"?t.applyDateText():t.apply()},o("common.apply"))}function xs(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Cs(e){return et("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xs,{}),jsxRuntime.jsx(vp,{})]}))}function xp(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Cp,{}),jsxRuntime.jsx(Tp,{})]}))}function Cp(e){let t=st(),o=Qe();return et("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:n=>t.showMonth(t.calendar.year,Number(n.target.value))},editor.calendarMonthNames(t.session.locale).map((n,r)=>jsxRuntime.jsx("option",{value:r,children:n},r)))}function Tp(e){let t=st(),o=Qe();return et("input",e,{type:"number",min:100,max:9999,className:"docx-content-control-calendar-year","data-docx-part":"year","aria-label":o("contentControl.calendar.year"),key:t.calendar.year,defaultValue:t.calendar.year,onBlur:n=>{let r=Number(n.target.value);if(!Number.isInteger(r)||r<100||r>9999){n.target.value=String(t.calendar.year);return}t.showMonth(r,t.calendar.month);},onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),n.currentTarget.blur());}},void 0)}function Ep({autoOpen:e,...t}){let o=st(),n=Qe(),r=At.useRef(null),i=At.useRef(false);return At.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),et("input",t,{ref:r,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":n("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:Gn,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function TR(e){let[t,o]=At.useState(e.session),[n,r]=At.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(ER,{...e},n)}function ER({session:e,className:t,style:o,children:n}){let r=Qe(),i=Wh(e),[a,l]=At.useState(e.signal.aborted),s=At.useRef(null),[c]=At.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(At.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),At.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),At.useLayoutEffect(()=>{if(a||d)return;let u=s.current,g=u?.ownerDocument,p=u&&e.anchor?editor.observeContentControlPopup(u,e.anchor):void 0;return u?.querySelector('[data-docx-part="grid"]')||(u?.querySelector("input")??u?.querySelector('[role=option][tabindex="0"]')??u?.querySelector("select,button,[data-docx-part=empty]"))?.focus({preventScroll:true}),()=>{p?.();let f=g?.activeElement;c?.isConnected&&(f===g?.body||f&&u?.contains(f))&&c.focus({preventScroll:true});}},[e,a,d,c]),At.useEffect(()=>{let u=s.current;if(!u||a||d)return;let g=p=>{u.contains(p.target)||e.cancel();};return u.ownerDocument.addEventListener("pointerdown",g,true),()=>u.ownerDocument.removeEventListener("pointerdown",g,true)},[e,a,d]),a||d)return null;let m=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(Bh,{value:i,children:jsxRuntime.jsx("div",{ref:s,role:"dialog","aria-label":m,className:`docx-content-control-widget-popup${t?` ${t}`:""}`,style:o,"data-docx-popup":"contentControlWidget","data-docx-part":"popup","data-kind":e.kind,onPointerDown:u=>u.stopPropagation(),onKeyDown:u=>{editor.contentControlPopupKeyDown(u.currentTarget,u.nativeEvent,e.cancel),i.listNavigation.keyDown(u.nativeEvent,u.currentTarget);},children:n??SR(i)})})}function SR(e){return e.kind==="date"?jsxRuntime.jsx(hp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ep,{}),jsxRuntime.jsx(Xr,{}),jsxRuntime.jsx(xs,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(vs,{}),jsxRuntime.jsx(ys,{}),jsxRuntime.jsx(Xr,{}),jsxRuntime.jsx(Cs,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ys,{}),jsxRuntime.jsx(Xr,{})]})}var wp=Object.assign(TR,{Navigation:xp,Month:Cp,Year:Tp,Calendar:hp,Header:cp,PreviousMonth:dp,Title:pp,NextMonth:up,Weekdays:mp,Grid:gp,Day:fp,Today:bp,List:ys,Item:yp,Input:vs,Picture:Ep,Error:Xr,Footer:Cs,Apply:vp,Cancel:xs});var qh="(prefers-color-scheme: dark)";function Kh(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function Uh(){return Kh()?globalThis.window.matchMedia(qh).matches:false}function zh(e,t){return e==="dark"||e==="system"&&t}function $h(e){if(!Kh())return ()=>{};let t=globalThis.window.matchMedia(qh);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function Rp(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function Gh(){let e=H(),t=St(),o=At.useRef(t);o.current=t;let[n,r]=At.useState(null),[i,a]=At.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;At.useEffect(()=>{if(!e||!l&&!s&&!c)return;let u=true,g=[...l?["dropdown","comboBox","date","buildingBlockGallery"]:[],...s?["checkbox"]:[],...c?["picture"]:[]],p=e.setContentControlWidgetChrome({kinds:g,onRequest(f){if(o.current?.[Rp(f.kind)]===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{u&&r(h=>h===f?null:h);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),At.useEffect(()=>{if(!e||!d)return;let u=true,g=e.setInvalidTextFormFieldChrome({onRequest(p){if(o.current?.invalidTextFormField===false)return p.cancel();a(p),p.signal.addEventListener("abort",()=>{u&&a(f=>f===p?null:f);},{once:true});}},{fallback:true});return ()=>{u=false,g(),a(null);}},[e,d]),At.useEffect(()=>{n&&t?.[Rp(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[Rp(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&m&&Te(m,{session:n},n),i&&t?.invalidTextFormField&&Te(t.invalidTextFormField,{session:i},i)]})}var ZR=["nw","n","ne","e","se","s","sw","w"],Qh=40,e0=12;function qR(e){return `imageOverlay.handle.${e}`}function KR(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 UR(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 zR(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 _p({containerRef:e,portalRef:t,scrollPort:o}){let n=H(),{t:r}=L(),[i,a]=At.useState(null),[l,s]=At.useState(null),[c,d]=At.useState({left:0,top:0}),m=At.useRef(null);m.current=l;let u=At.useRef(null),g=At.useRef(null),p=At.useRef(null),f=At.useRef(null),h=At.useRef(null);At.useEffect(()=>{let S=e.current;if(!S)return;let D=w=>{let k=editor.isElementNode(w.target)?w.target:null;if(k?.closest(".docx-drawing-textbox-content")){f.current=null;return}let F=k?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=F??null,F&&F===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return S.addEventListener("pointerdown",D,{capture:true}),()=>S.removeEventListener("pointerdown",D,{capture:true})},[e,i?.id]),At.useEffect(()=>{if(!n){a(null);return}let S=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},D=()=>{queueMicrotask(S);};S();let w=[n.on("change",D),n.on("selectionChange",S)];return ()=>{for(let k of w)k();}},[n]);let b=At.useCallback(()=>{d(S=>{let D=editor.overlayHostOrigin(e.current);return D.left===S.left&&D.top===S.top?S:D});},[e]);At.useEffect(()=>{b();let S=t.current,D=editor.hostWindowOf(S).ResizeObserver;if(!S||typeof D!="function")return;let w=new D(b);w.observe(S);let k=e.current;return k&&w.observe(k),()=>w.disconnect()},[e,t,b,i]),At.useEffect(()=>{if(o){h.current=o;return}let S=e.current;if(!S||!n?.surface)return;let D=S.closest(".docx-editor__scroll-container");if(!D)return;let w=n.surface.overlayCoordinates();return h.current=editor.createImageOverlayScrollPort(D,w.paintScale),()=>{h.current=null;}},[e,n,o]);let v=At.useCallback(()=>{s(null),u.current=null;let S=g.current;if(g.current=null,S)try{S.releasePointerCapture(S._lastPointerId??0);}catch{}},[]),y=At.useCallback((S,D,w,k,F,I,N)=>{if(!n?.surface)return;let A=n.surface.activeScope();if(A.kind==="frame"&&!n.surface.selectDrawing(w.id,A.hostParagraphId))return;let P=n.surface.layout(),M=editor.captureImageMutationPreconditions(n);if(M){u.current=Object.freeze({x:k,y:F}),g.current=I,I._lastPointerId=N;try{I.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:w.id,startBounds:Object.freeze({x:w.x,y:w.y,width:w.width,height:w.height}),startWidthEmu:w.widthEmu,startHeightEmu:w.heightEmu,startPosition:w.position,anchorFrameOrigin:w.anchorFrameOrigin,transform:w.transform,mode:S,handle:D,preconditions:M,layoutRevision:P.revision,packageRevision:n.surface.session.packageRevision(),kind:w.kind}),bounds:w,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),T=At.useCallback((S,D,w,k,F)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,S)){v();return}S.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:D,heightEmu:w,...F?.mode==="simple"?{horizontalEmu:F.horizontalEmu,verticalEmu:F.verticalEmu}:{},...F?.mode==="frame"?{...F.horizontalEmu!==void 0?{horizontalEmu:F.horizontalEmu}:{},...F.verticalEmu!==void 0?{verticalEmu:F.verticalEmu}:{}}:{}}):S.mode==="move"&&F&&n.exec({type:"setImagePosition",...F}),v();},[v,n]),x=At.useCallback(S=>{if(!n)return;let D=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!D)return;if(m.current&&S.key==="Escape"){S.preventDefault(),S.stopPropagation(),v();return}if(m.current)return;let w=editor.historyShortcutOf(S);if(w){S.preventDefault(),S.stopPropagation(),n.exec({type:w});return}let k=S.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(S.key==="Delete"||S.key==="Backspace"){S.preventDefault(),S.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(S.key))return;S.preventDefault(),S.stopPropagation();let F=S.key==="ArrowLeft"?-k:S.key==="ArrowRight"?k:0,I=S.key==="ArrowUp"?-k:S.key==="ArrowDown"?k:0;if(S.altKey){if(!D.canResize)return;let A=zR(F,I),P=editor.computeImageResizeResult({handle:A,startWidthEmu:D.widthEmu,startHeightEmu:D.heightEmu,startBounds:{x:D.x,y:D.y,width:D.width,height:D.height},startPosition:D.position,anchorFrameOrigin:D.anchorFrameOrigin,deltaXPt:F,deltaYPt:I,transform:D.transform,preserveAspect:editor.resizePreservesAspect(A,D.aspectLocked,S.shiftKey,D.textbox),kind:D.kind});n.exec({type:"setImageProperties",widthEmu:P.widthEmu,heightEmu:P.heightEmu,...P.position?.mode==="simple"?{horizontalEmu:P.position.horizontalEmu,verticalEmu:P.position.verticalEmu}:{},...P.position?.mode==="frame"?{...P.position.horizontalEmu!==void 0?{horizontalEmu:P.position.horizontalEmu}:{},...P.position.verticalEmu!==void 0?{verticalEmu:P.position.verticalEmu}:{}}:{}});return}if(D.kind!=="anchored"||!D.canMove||!D.position)return;let N=editor.computeMovedImagePosition(D.position,F,I);n.exec({type:"setImagePosition",...N});},[v,n]);At.useEffect(()=>{if(!l||!n?.surface)return;let S=n.surface.overlayCoordinates(),D=F=>{let I=m.current,N=u.current;if(!I||!N)return;let A=editor.cssPixelsToLayoutPoints(F.clientX-N.x,S.paintScale),P=editor.cssPixelsToLayoutPoints(F.clientY-N.y,S.paintScale);if(I.session.mode==="move"){let $=0,U=h.current,oe=e.current?.closest(".docx-editor__scroll-container");if(U&&oe){let ne=oe.getBoundingClientRect();F.clientY>ne.bottom-Qh?$=e0:F.clientY<ne.top+Qh&&($=-e0),$!==0&&($=U.scrollBy($));}let Y=I.accumulatedScrollPt+$;s({...I,accumulatedScrollPt:Y,bounds:Object.freeze({...I.bounds,x:I.session.startBounds.x+A,y:I.session.startBounds.y+P+Y})});return}if(!I.session.handle)return;let M=editor.computeImageResizeResult({handle:I.session.handle,startWidthEmu:I.session.startWidthEmu,startHeightEmu:I.session.startHeightEmu,startBounds:I.session.startBounds,startPosition:I.session.startPosition,anchorFrameOrigin:I.session.anchorFrameOrigin,deltaXPt:A,deltaYPt:P,transform:I.session.transform,preserveAspect:editor.resizePreservesAspect(I.session.handle,I.bounds.aspectLocked,F.shiftKey,I.bounds.textbox),kind:I.session.kind});s({...I,bounds:Object.freeze({...I.bounds,x:M.previewBounds.x,y:M.previewBounds.y,width:M.previewBounds.width,height:M.previewBounds.height,widthEmu:M.widthEmu,heightEmu:M.heightEmu})});},w=F=>{let I=m.current;if(I)if(F.type==="pointerup"){let N=editor.cssPixelsToLayoutPoints(F.clientX-(u.current?.x??F.clientX),S.paintScale),A=editor.cssPixelsToLayoutPoints(F.clientY-(u.current?.y??F.clientY),S.paintScale),P=editor.finalizeImageOverlayInteraction({session:I.session,deltaXPt:N,deltaYPt:A,accumulatedScrollPt:I.accumulatedScrollPt,aspectLocked:I.bounds.aspectLocked,textbox:I.bounds.textbox,shiftKey:F.shiftKey,anchorFrameOrigin:I.session.anchorFrameOrigin});T(I.session,P.widthEmu,P.heightEmu,P.previewBounds,P.position);}else v();},k=editor.hostWindowOf(e.current);return k.addEventListener("pointermove",D),k.addEventListener("pointerup",w),k.addEventListener("pointercancel",w),()=>{k.removeEventListener("pointermove",D),k.removeEventListener("pointerup",w),k.removeEventListener("pointercancel",w);}},[v,T,e,n,l]),At.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let C=l?.bounds??i,E=At.useMemo(()=>{if(!n?.surface||!C)return null;let S=n.surface.publishedLayout(),D=n.surface.overlayCoordinates(),w=editor.overlayFrameToSheetCssPixels(S,{pageIndex:C.pageIndex,x:C.x,y:C.y,width:C.width,height:C.height},D),k={left:w.left+c.left,top:w.top+c.top,width:w.width,height:w.height},F=C.canResize,I=C.kind==="anchored"&&C.canMove;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":C.id,tabIndex:0,onKeyDown:x,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${I?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":C.textbox?"true":void 0,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`,height:`${k.height}px`,cursor:I?"move":"default"},onPointerDown:N=>{q(N),!(!I||!C.position)&&N.button===0&&(N.preventDefault(),N.stopPropagation(),y("move",null,C,N.clientX,N.clientY,N.currentTarget,N.pointerId));}}),F?ZR.map(N=>{let A=UR(N);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(qR(N)),tabIndex:0,style:{left:`calc(${k.left}px + ${k.width}px * ${parseFloat(A.x)/100} - 5px)`,top:`calc(${k.top}px + ${k.height}px * ${parseFloat(A.y)/100} - 5px)`,cursor:KR(N)},onPointerDown:P=>{q(P),P.button===0&&(P.preventDefault(),P.stopPropagation(),y("resize",N,C,P.clientX,P.clientY,P.currentTarget,P.pointerId));}},N)}):null]})},[C,y,n,x,c.left,c.top,r]);return !E||!t.current?null:reactDom.createPortal(E,t.current)}function Ip(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function ks({className:e}){let t=H(),o=Wa(),n=At.useRef(null),r=At.useContext(mr),i=At.useCallback(d=>{n.current=d,r?.setContainer(d);},[r]),a=At.useRef(null);At.useLayoutEffect(()=>{let d=n.current;if(!(!t||!d)){try{t.attach(d);}catch(m){if(t.snapshot().openFailure?.code!=="open.failed")throw m;console.error("[docx-editor] The document failed to open.",m);}return ()=>{t.detach();}}},[t]);let l=At.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Ip(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=At.useCallback(d=>{!o?.isEnabled||!Ip(d.dataTransfer)||d.preventDefault();},[o]),c=At.useCallback(d=>{if(o?.isEnabled&&Ip(d.dataTransfer)){if(editor.clipboardDropLandsText(d.dataTransfer)){if((editor.isElementNode(d.target)?d.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;d.preventDefault();return}d.preventDefault(),o.insertFromDataTransfer(d.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:a,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:i,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:l,onDragOver:s,onDrop:c}),jsxRuntime.jsx(rh,{}),jsxRuntime.jsx(Th,{}),jsxRuntime.jsx(Gh,{}),t?jsxRuntime.jsx(_p,{containerRef:n,portalRef:a}):null]})}function Lp({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=At.useState(null),d=At.useRef(t);d.current=t;let m=At.useRef({url:n,name:r,features:i,title:a,styles:l});m.current={url:n,name:r,features:i,title:a,styles:l};let u=At.useRef(null);return At.useEffect(()=>{if(!e)return;let g=u.current;if(g)g.claimed=true;else {let{url:b,name:v,features:y,title:T,styles:x}=m.current;g={claimed:true,promise:editor.openEditorWindow({...b!==void 0?{url:b}:{},...v!==void 0?{name:v}:{},...y!==void 0?{features:y}:{},...T!==void 0?{title:T}:{},...x!==void 0?{styles:x}:{}})},u.current=g;}let p=g,f=true,h;return p.promise.then(b=>{if(f){if(!b){u.current=null,d.current?.();return}h=b.onClose(()=>{f&&(u.current=null,reactDom.flushSync(()=>c(null)),d.current?.());}),c(b);}}),()=>{f=false,h?.(),p.claimed=false,c(null),queueMicrotask(()=>{p.claimed||(u.current===p&&(u.current=null),p.promise.then(b=>b?.close()));});}},[e]),!s||!e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:o}):reactDom.createPortal(jsxRuntime.jsx("div",{className:"docx-editor",style:{height:"100%"},children:o}),s.element)}function We(e){return e/1440*96}function ws(e){return e/96*1440}function kt(e){return `${Math.round(e*100)/100}px`}function Fp(e){return e/2}var sM=e=>e.isLoading||e.isOpening===true,cM=e=>({width:We(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:We(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),dM=(e,t)=>e.width===t.width&&e.height===t.height;function Hp({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var r0=false;function a0(){r0||!gt()||(r0=true,console.warn("[docx-editor] loadingIndicator is ignored with chrome={false}, which renders no loading screen. Compose <DocxEditor.Loading overlay indicator={...} /> in a positioned box instead."));}function uM(e){let t=H(),[o,n]=At.useState(null);return At.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function pM({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=W(sM),l=W(cM,dM),s=uM(t),{t:c}=L(),d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hp,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:c("loading.label")})]});if(s)return reactDom.createPortal(d,s);if(!e&&!a)return null;let m=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:m,style:n,role:"status","aria-live":"polite",children:i??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:l.width,height:l.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsx("div",{className:"docx-editor__loading-page-status",children:d})})})})})}var Ds=Object.assign(pM,{Spinner:Hp});function i0(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((p,f)=>(o.get(p[0])??0)-(o.get(f[0])??0));for(let[,{author:p,style:f}]of g)u[p]=f;return {authors:u,others:e.size>0?"kind":"author"}}let l=null,s=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([p,f])=>`${p}\0${JSON.stringify(f)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(u),i=true,l=g;}}function m(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var pi=At.createContext(null);function c0(){let e=At.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function Ap(){let e=At.useContext(pi),t=c0();return At.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function Op(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=At.useContext(pi),s=c0();return At.useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...n!==void 0?{background:n}:{},...r!==void 0?{activeBackground:r}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,n,r,i,a]),null}var d0=false;function u0(e,t){e===t||d0||!gt()||(d0=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var p0=false,m0=e=>e?.allowFormattingInLockedContent===true;function f0(e,t){m0(e)===m0(t)||p0||!gt()||(p0=true,console.warn("[docx-editor] contentLockPolicy changed after the editor was created, so the change is ignored. The editor reads contentLockPolicy once; create a new editor to change it."));}var g0=false;function b0(e){return e===void 0?"characters":e}function h0(e,t){b0(e)===b0(t)||g0||!gt()||(g0=true,console.warn("[docx-editor] lockedControlNavigation changed after the editor was created, so the change is ignored. The editor reads lockedControlNavigation once; create a new editor to change it."));}function EM(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),n=editor.resolveZoomMode(t);return o!==null&&n!==null&&editor.sameZoomMode(o,n)}function SM(e){let t=At.useRef(e);t.current=e;let[o,n]=At.useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=At.useMemo(()=>({onReady:d=>{n(d),t.current.onReady?.(d);},onChange:d=>t.current.onChange?.(d),onFontError:d=>t.current.onFontError?.(d),onRevisionMarkupChange:d=>t.current.onRevisionMarkupChange?.(d)}),[]);return {DocxEditorRoot:mi,rootProps:s,rootListeners:c,editorRef:o}}function mi(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,children:u}=e,{t:g}=L(),p=At.useCallback((O,ae)=>g(O,ae),[g]),f=At.useRef(p);f.current=p;let h=At.useRef(false),[b,v]=At.useState(0),y=At.useRef(e);y.current=e;let T=n?.maxFontBytes,[x,C]=At.useState(null),E=At.useRef(e.fieldResults),S=At.useRef(e.contentLockPolicy),D=At.useRef(e.lockedControlNavigation),w=At.useRef(e.fonts),k=At.useRef(null);k.current??=i0();let F=k.current,I=At.useRef(null);I.current??=Wf();let N=I.current;At.useEffect(()=>{let O=y.current,ae=O.translate??f.current,se=F.current();E.current=O.fieldResults,S.current=O.contentLockPolicy,D.current=O.lockedControlNavigation;let he=editor.createDocxEditor({unsupportedElementRules:N.current(),...O.document!==void 0?{document:O.document}:{},...O.fonts?{fonts:O.fonts}:{},...O.fontShaping?{fontShaping:O.fontShaping}:{},...O.author!==void 0?{author:O.author}:{},...O.locale!==void 0?{locale:O.locale}:{},translate:ae,...O.revisionMarkup!==void 0?{revisionMarkup:O.revisionMarkup}:{},...O.reviewDisplayMode!==void 0?{reviewDisplayMode:O.reviewDisplayMode}:{},...O.fieldResults!==void 0?{fieldResults:O.fieldResults}:{},...O.contentLockPolicy!==void 0?{contentLockPolicy:O.contentLockPolicy}:{},...O.lockedControlNavigation!==void 0?{lockedControlNavigation:O.lockedControlNavigation}:{},...O.mode!==void 0?{mode:O.mode}:{},...se!==void 0?{revisionStyles:se}:{},...O.modules!==void 0?{modules:O.modules}:{},...O.zoom!==void 0?{zoom:O.zoom}:{},...O.zoomMode!==void 0?{zoomMode:O.zoomMode}:{},...O.tableInteractionLabel?{tableInteractionLabel:O.tableInteractionLabel}:{},...O.imageDecodePort?{imageDecodePort:O.imageDecodePort}:{},onFontError:$e=>y.current.onFontError?.($e)});w.current=O.fonts;let Me=he.on("revisionMarkupChange",$e=>{h.current||(y.current.onRevisionMarkupChange?.($e),v(Pe=>Pe+1));}),je=he.on("change",$e=>y.current.onChange?.($e));return C(he),()=>{Me(),je(),he.destroy(),C($e=>$e===he?null:$e);}},[t,T,m,F,N]),At.useEffect(()=>{!x||w.current===o||(w.current=o,x.setFonts(o).catch(()=>{}));},[x,o]),At.useEffect(()=>{if(!x)return;if(!x.snapshot().isOpening){y.current.onReady?.(x);return}let O=x.on("change",()=>{O(),y.current.onReady?.(x);});return O},[x]);let A=At.useRef({editor:null,zoom:void 0,mode:void 0});At.useEffect(()=>{if(!x)return;A.current.editor!==x&&(A.current={editor:x,zoom:void 0,mode:void 0});let ae=false;s!==void 0&&s!==A.current.zoom&&(A.current.zoom=s,x.setZoom(s),ae=true);let se=A.current.mode,he=c!==void 0&&(se===void 0||!EM(se,c)),Me=c===void 0?null:editor.resolveZoomMode(c),je=ae&&c!==void 0&&Me!==null&&Me.type==="fit";(he||je)&&(A.current.mode=c,x.setZoomMode(c));},[x,s,c]),At.useEffect(()=>{if(!x||e.revisionMarkup===void 0)return;let O=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(O)!==JSON.stringify(x.snapshot().revisionMarkup)){h.current=true;try{x.setRevisionMarkup(O);}finally{h.current=false;}}},[x,e.revisionMarkup,b]),At.useEffect(()=>{x&&x.setAuthor(r);},[x,r]);let P=At.useRef({editor:null,value:void 0});At.useEffect(()=>{if(x){if(P.current.editor!==x){P.current={editor:x,value:l};return}P.current.value!==l&&(P.current.value=l,x.setMode(l));}},[x,l]),At.useEffect(()=>{x&&x.setTranslate(a??p);},[x,a,p]),At.useEffect(()=>{x&&x.setLocale(i);},[x,i]),At.useEffect(()=>{x&&u0(E.current,e.fieldResults);},[x,e.fieldResults]),At.useEffect(()=>{x&&f0(S.current,e.contentLockPolicy);},[x,e.contentLockPolicy]),At.useEffect(()=>{x&&h0(D.current,e.lockedControlNavigation);},[x,e.lockedControlNavigation]),At.useEffect(()=>{x&&x.setTableInteractionLabel(d??editor.defaultTableLabel);},[x,d]);let[M,$]=At.useState(0),[U,oe]=At.useState(0),Y=At.useRef([]),[ne,K]=At.useState(0),X=ne>0,le=At.useRef(x);le.current=x,At.useEffect(()=>{if(!(!x||!X))return x.setCommentDraftChrome({onRequest:()=>Y.current.at(-1)?.()})},[x,X]);let B=At.useMemo(()=>({mounted:M,register:()=>($(O=>O+1),()=>$(O=>Math.max(0,O-1))),gutters:U,reserveGutter:()=>(oe(O=>O+1),()=>oe(O=>Math.max(0,O-1))),registerCommentDraft:O=>(Y.current.push(O),K(ae=>ae+1),()=>{let ae=Y.current.indexOf(O);ae!==-1&&(Y.current.splice(ae,1),K(se=>Math.max(0,se-1)));}),requestCommentDraft:()=>{let O=le.current;return O!==null&&editor.runToolbarCommand(O,"review.addComment").ok}}),[M,U]),_=At.useMemo(tg,[]);return At.useEffect(()=>(F.connect(x),()=>F.connect(null)),[F,x]),At.useEffect(()=>(N.connect(x),()=>N.connect(null)),[N,x]),jsxRuntime.jsx(mr.Provider,{value:N,children:jsxRuntime.jsx(Qb,{value:a??p,children:jsxRuntime.jsx(_t.Provider,{value:B,children:jsxRuntime.jsx(dd.Provider,{value:x,children:jsxRuntime.jsx(Cd.Provider,{value:_,children:jsxRuntime.jsx(pi.Provider,{value:F,children:jsxRuntime.jsx(PM,{children:jsxRuntime.jsx(kM,{children:jsxRuntime.jsx(Ch,{value:e.popups,children:jsxRuntime.jsx(Fl,{children:jsxRuntime.jsx(nh,{popups:e.popups,children:u})})})})})})})})})})})}function PM({children:e}){let t=Pl(true);return jsxRuntime.jsx(Ma.Provider,{value:t,children:e})}function kM({children:e}){let t=wl();return jsxRuntime.jsx(Vd.Provider,{value:t,children:e})}var fi=316,ta=editor.REVIEW_MARKERS_GUTTER_PX,T0=24,Rs={inlineStart:0,inlineEnd:fi},y0={inlineStart:ta,inlineEnd:ta},IM={inlineStart:0,inlineEnd:0},Zp={inlineStart:T0,inlineEnd:fi};function NM(e){return e.inlineStart===Zp.inlineStart&&e.inlineEnd===Zp.inlineEnd}function E0(e,t){return NM(e)?Math.max(0,t-(fi-ta)):t}function S0({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return y0;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Rs;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*T0>=fi?Rs:i?Zp:y0}var LM=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:editor.reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},FM=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function P0(){let e=ke(),[t,o]=At.useState(null);return At.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);n();let r=editor.hostWindowOf(e).ResizeObserver;if(typeof r>"u")return;let i=new r(n);return i.observe(e),()=>i.disconnect()},[e]),t}function pn(){let e=At.useContext(_t),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=W(LM,FM),i=ke(),a=ng(),l=At.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=gl(e),d=At.useCallback(g=>c?S0({open:o,viewportWidth:g??0,pageWidthPx:s===null||n===null?0:We(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):IM,[c,o,s,n,a,r]),[m,u]=At.useState(()=>d(i?i.clientWidth:null));return At.useEffect(()=>{let g=()=>u(d(i?i.clientWidth:null));g();let p=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof p>"u")return;let f=new p(g);return f.observe(i),()=>f.disconnect()},[i,d]),m}var Ms=[.25,.5,.75,1,1.25,1.5,2];function gi(e,t){return t==="in"?Ms.find(n=>n>e+.001)??null:[...Ms].reverse().find(n=>n<e-.001)??null}function k0(e,t){return e==="0"?1:e==="+"||e==="="?gi(t,"in")??t:e==="-"?gi(t,"out")??t:null}var qp=At.createContext(false);function w0(e){let t=At.useContext(qp),[o,n]=At.useState(null);return At.useLayoutEffect(()=>{let r=t?e?.parentElement??null:null;n(r?{host:r,scoped:r.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var qM=e=>e.reviewPaneOpen??true,KM=e=>e.zoomMode?.type==="fit";function _s({className:e,style:t,children:o}){let{t:n}=L(),r=Nt(),i=H(),a=W(qM),l=pn(),s=W(KM),c=At.useContext(_t),d=gl(c),m=Mn(),u=_n(),g=At.useCallback(f=>m?.setViewport(f),[m]),p=At.useCallback(f=>{if(!i||!(f.metaKey||f.ctrlKey)||f.altKey)return;let h=f.target;if(editor.isElementNode(h)&&h.closest('input, textarea, select, [role="dialog"]'))return;let b=k0(f.key,i.getZoom());b!==null&&(f.preventDefault(),i.setZoom(b));},[i]);return jsxRuntime.jsx("div",{ref:g,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:p,...d?{"data-review-pane":a?"open":"closed"}:{},...s?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${u}px`,...d?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*ta}px`}:{}},children:jsxRuntime.jsx(zn.Provider,{value:true,children:jsxRuntime.jsx(qp.Provider,{value:true,children:o})})})}var zM=editor.LOADING_SNAPSHOT;function R0({ref:e,editorRef:t}){At.useImperativeHandle(e,()=>({load:o=>t.current?.load(o),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(o,n)=>t.current?.exec(o,n)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??zM}),[t]);}function oa(e,t,o,n){let r=ke(),i=At.useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},At.useEffect(()=>{let a=t.current;if(!e||!a)return;let l=d=>a.contains(d),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current.viewport],skip:d=>i.current.skip?.(d)===true,close:d=>i.current.close(d)}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>i.current.close(false)});return ()=>{s(),c();}},[e,t]);}var t1=e=>e.editingMode??"editing",zp='[role="menuitemradio"]:not([disabled])',o1=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),n1=e=>e.isLoading||e.isOpening===true,bi=[{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"}],r1=Object.freeze(bi.map(()=>null));function a1(e){return e?bi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):r1}var i1="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function Ns({className:e,hidden:t}){let o=H(),n=W(t1),r=W(n1),i=ee(),{t:a}=L(),[l,s]=At.useState(false),c=At.useRef(null),d=At.useRef(null),m=At.useRef(null);At.useEffect(()=>{if(!l)return;let y=m.current?.querySelectorAll(zp);(m.current?.querySelector(`${zp}[aria-checked="true"]`)??y?.[0]??void 0)?.focus();},[l]);let u=At.useCallback(y=>{let T=[...m.current?.querySelectorAll(zp)??[]],x=T.indexOf(editor.hostDocumentOf(m.current).activeElement),C=E=>{y.preventDefault(),T[(E+T.length)%T.length]?.focus();};y.key==="ArrowDown"?C(x+1):y.key==="ArrowUp"?C(x-1):y.key==="Home"?C(0):y.key==="End"&&C(T.length-1);},[]);At.useEffect(()=>{if(!l)return;let y=x=>{let C=c.current;C&&editor.isDomNode(x.target)&&C.contains(x.target)||s(false);},T=editor.hostDocumentOf(c.current);return T.addEventListener("mousedown",y,true),()=>{T.removeEventListener("mousedown",y,true);}},[l]),oa(l,c,y=>{s(false),y&&d.current?.focus();});let g=At.useCallback(y=>{s(false),editor.runToolbarCommand(o,"review.editingMode",y),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),f=i18n.localizeDisabledReason(p.disabledReason,a),h=W(()=>a1(o),o1),b=At.useMemo(()=>bi.find(y=>y.mode===n)??bi[0],[n]);if(t)return null;let v=Q("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":n,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(v?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:q,onClick:()=>s(y=>!y),children:[$p(b.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(b.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(v?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:bi.map((y,T)=>{let x=i18n.localizeDisabledReason(h[T]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":y.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${y.mode}`,disabled:x!==null,...x?{title:x}:{},onMouseDown:q,onClick:()=>g(y.mode),children:[$p(y.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(y.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(y.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:y.mode===n?$p(i1):null})]},y.mode)})}):null]})}Ns.docxSlot="review.editingMode";function $p(e){return jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})})}var L0=[],c1=()=>{};function hi(){let e=H(),t=At.useCallback(o=>{if(!e)return c1;let n=Sa(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return At.useSyncExternalStore(t,()=>e?.getReviewAuthors()??L0,()=>L0)}var g1=e=>e.hiddenReviewAuthors??[];function Fs({className:e,hidden:t,icon:o}){let n=H(),r=hi(),i=W(g1),a=new Set(i),l=r.every(T=>!a.has(T.author)),[s,c]=At.useState(false),d=At.useRef(null),m=At.useRef(null),u=At.useRef(null),g=ee(),{t:p}=L();At.useEffect(()=>{if(!s)return;u.current?.querySelector('[role="menuitemcheckbox"]')?.focus();let T=C=>{d.current?.contains(C.target)||c(false);},x=editor.hostDocumentOf(d.current);return x.addEventListener("mousedown",T,true),()=>{x.removeEventListener("mousedown",T,true);}},[s]),oa(s,d,T=>{c(false),T&&m.current?.focus();});let f=At.useCallback(T=>{let x=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],C=x.indexOf(editor.hostDocumentOf(u.current).activeElement),E=S=>{T.preventDefault(),x[(S+x.length)%x.length]?.focus();};T.key==="ArrowDown"?E(C+1):T.key==="ArrowUp"?E(C-1):T.key==="Home"?E(0):T.key==="End"?E(x.length-1):T.key==="Tab"&&c(false);},[]);if(t)return null;let h=Q("review.authors"),b=editor.toolbarCommandState(n,"review.authors"),v=i18n.localizeDisabledReason(b.disabledReason,p),y=g(h?.labelKey??"reviewers.label");return jsxRuntime.jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[jsxRuntime.jsxs("button",{ref:m,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":y,disabled:!b.enabled,title:v??y,onMouseDown:q,onClick:()=>c(T=>!T),children:[o??te(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:y}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":y,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsxRuntime.jsx(H0,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!l)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(T=>jsxRuntime.jsx(H0,{checked:!a.has(T.author),label:T.author||"\u2014",testId:`reviewer-${T.slot}`,color:T.color,onChoose:()=>n?.setReviewAuthorVisible(T.author,a.has(T.author))},T.author))]}):null]})}Fs.docxSlot="review.authors";function H0(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:q,onClick:e.onChoose,children:[jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var O0=At.createContext(null);function B0({children:e}){let t=To(),[o,n]=At.useState(false),r=At.useRef(null),i=ke(),a=At.useRef(i);a.current=i;let l=At.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}r.current=c??editor.hostDocumentOf(a.current).activeElement,n(true);}}),[t]),s=At.useCallback(()=>{n(false);let c=r.current;r.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(O0.Provider,{value:l,children:[e,jsxRuntime.jsx(Zo,{open:o,onClose:s})]})}function W0(){return At.useContext(O0)}var Gp=["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"],jp=At.createContext({close:()=>{}});function na(){return At.useContext(jp).close}function A1(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function U0({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__more-control",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function z0({slot:e}){let t=ee(),o=Ho(),{close:n}=At.useContext(jp),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=ie(e),c=Q(e),d=editor.chromeSlotIsToggle(e),m=o(t(c?.labelKey??e));return jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...l?{title:l}:{},...d?{"aria-pressed":i}:{},...i?{"data-active":""}:{},...s!==null?{"data-value":s}:{},onMouseDown:q,onClick:u=>{r(),n(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:te(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function $0({sections:e,className:t}){let o=ee(),[n,r]=At.useState(false),i=At.useRef(null),a=At.useRef(null),l=At.useRef(null),s=At.useRef(false),c=At.useId(),d=ke(),m=At.useRef(d);m.current=d;let u=o("formattingBar.more"),g=At.useCallback(v=>{r(false),v&&a.current?.focus();},[]),p=At.useMemo(()=>({close:g}),[g]);At.useEffect(()=>{if(!n)return;let v=S=>{let D=S.target;editor.isDomNode(D)&&i.current?.contains(D)||r(false);},y=i.current,T=S=>i.current?.contains(S)===true||l.current?.contains(S)===true,x=y?editor.listenForPopupEscape({popup:y,contains:T,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,C=y?editor.listenForPopupFocusLeave({popup:y,contains:T,close:()=>r(false)}):void 0,E=editor.hostDocumentOf(y);return E.addEventListener("mousedown",v,true),()=>{E.removeEventListener("mousedown",v,true),x?.(),C?.();}},[n,g]);let[f,h]=At.useState(null);At.useLayoutEffect(()=>{if(!n){h(null);return}let v=()=>{let T=i.current,x=l.current,C=a.current,E=T?.ownerDocument.defaultView;if(!T||!x||!C||!E)return;let S=C.getBoundingClientRect(),D=editor.toolbarPanelPlacement({triggerLeft:S.left,triggerRight:S.right,panelWidth:x.offsetWidth,viewportWidth:E.innerWidth}),w=D.left-T.getBoundingClientRect().left;h(k=>k&&k.left===w&&k.maxWidth===D.maxWidth&&k.anchor===D.anchor?k:{...D,left:w});};v();let y=i.current?.ownerDocument.defaultView;return y?.addEventListener("resize",v),()=>y?.removeEventListener("resize",v)},[n]),At.useEffect(()=>{if(!n||!s.current)return;s.current=false;let v=l.current;v&&A1(v);},[n]);let b=v=>{v.key!=="Escape"||v.defaultPrevented||(v.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Oa]:"",children:[jsxRuntime.jsx("button",{ref:a,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?c:void 0,"aria-label":u,title:u,...n?{"data-active":""}:{},onMouseDown:q,onClick:()=>r(v=>!v),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),s.current=true,r(true));},children:te(Gp)}),n?jsxRuntime.jsx(jp.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:l,id:c,role:"dialog","aria-label":u,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",...f?{"data-anchor":f.anchor}:{},style:f?{left:f.left,right:"auto",maxInlineSize:f.maxWidth}:void 0,onKeyDown:b,children:e.map(v=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":v.label??o(v.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:v.label??o(v.labelKey)}),v.children]},v.id))})}):null]})}function B1(e){if(!At.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function G0(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of At.Children.toArray(e)){if(B1(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))r.set(c,s);else if(c&&n(c))i.set(c,s);else {if(c&&At.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}function As(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function Yp(e){let t=ee();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":As(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}Yp.docxToolbarGroup=true;function vi(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}vi.docxToolbarSlot=true;var Xp=At.createContext("bar");function j0(){return At.useContext(Xp)}var Os="review.addComment";function U1({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=At.useContext(_t),a=ee(),{isEnabled:l,reason:s}=Rl(a),c=na();if(t||(i?.mounted??0)===0)return null;let d=Q(Os),m=a(d?.labelKey??Os),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Os,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:q,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsxRuntime.jsx(j,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??te(d?.paths)})}var Jp=Object.assign(U1,{docxSlot:Os});var J0=new Set;function Bs(e){!gt()||J0.has(e)||(J0.add(e),console.warn(`[docx-editor] ${e}`));}function Q0(e,t,o){Bs(`Toolbar.Group "${e}" has after="${t}", but no group has that id. The group is placed after every other group. Known ids: ${o.join(", ")}.`);}function ey(e,t){Bs(`Toolbar.Group "${e}" is a built-in group, so its ${t} is ignored. A built-in group keeps its own label and place in the bar.`);}function ty(e){Bs(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function oy(e,t){Bs(t?`Toolbar slot "${e}" is not part of the preset arrangement, so its content is appended after the groups. Put it in a Toolbar.Group to give it a place.`:`"${e}" is not a toolbar slot id. Its content is appended after the groups. Use a ChromeSlotId such as "text.bold".`);}var em=[{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 Zs({className:e,hidden:t,asChild:o,children:n}){let{t:r}=L(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=ii("image.wrap"),[d,m]=At.useState(false),u=At.useRef(null),g=At.useRef(null),p=At.useRef(null),f=At.useId(),h=At.useMemo(()=>em.find(C=>C.value===l)??em[0],[l]),b=Q("image.wrap"),v=i(b?.labelKey??"formattingBar.imageWrap");At.useEffect(()=>{if(!d)return;let C=D=>{let w=u.current;w&&editor.isDomNode(D.target)&&w.contains(D.target)||m(false);},E=D=>{D.key==="Escape"&&(D.preventDefault(),m(false),g.current?.focus());},S=editor.hostDocumentOf(u.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",E),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",E);}},[d]);let y=At.useCallback(C=>{m(false),a(C);},[a]);if(t)return null;let T=r("imageWrap.tooltipPrefix",{label:r(h.labelKey)}),x={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":v,title:c??T,onMouseDown:q,onClick:()=>m(C=>!C)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(j,{...x,children:n}):jsxRuntime.jsx("button",{...x,children:n??te(b?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:C=>C.stopPropagation(),children:em.map(C=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===C.value,...l===C.value?{"data-active":""}:{},onMouseDown:q,onClick:()=>y(C.value),children:r(C.labelKey)},C.value))}):null]})}Zs.docxSlot="image.wrap";var xi=Object.assign(Zs,{docxSlot:"image.wrap"});var ra="table.insert";function r2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=H(),{isEnabled:a,disabledReason:l}=ie(ra),s=ee(),[c,d]=At.useState(false),m=At.useRef(null),u=At.useRef(null),g=At.useRef(null),p=At.useId(),f=na();At.useEffect(()=>{let x=m.current?.ownerDocument;if(!c||!x)return;let C=E=>{let S=m.current;S&&editor.isDomNode(E.target)&&S.contains(E.target)||d(false);};return x.addEventListener("mousedown",C,true),()=>x.removeEventListener("mousedown",C,true)},[c]),At.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;At.useLayoutEffect(()=>{let x=g.current,C=m.current,E=C?.ownerDocument.defaultView;if(!h||!x||!C||!E||C.closest(".docx-toolbar__more-panel"))return;let S=C.getBoundingClientRect(),D=editor.toolbarPopupLeft({anchorLeft:S.left,popupWidth:x.offsetWidth,viewportWidth:E.innerWidth});x.style.left=`${D-S.left}px`;},[h]);let b=At.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let v=Q(ra),y=s(v?.labelKey??ra),T={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":ra,disabled:!a,...a?{}:{"data-disabled":""},...h?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":h,"aria-controls":h?p:void 0,"aria-label":y,title:l??y,onMouseDown:q,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:x=>{x.key==="ArrowDown"&&(x.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsxRuntime.jsx(j,{...T,children:r}):jsxRuntime.jsx("button",{...T,children:o??r??te(v?.paths)}),h?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:x=>{let C=x.relatedTarget;editor.isDomNode(C)&&!m.current?.contains(C)&&d(false);},onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(Ol,{slot:ra,label:s("toolbar.insertTable"),onInserted:b})}):null]})}var om=Object.assign(r2,{docxSlot:ra});function tt(e){return Object.assign(o=>jsxRuntime.jsx(Ao,{slotId:e,...o}),{docxSlot:e})}var ay=tt("history.undo"),iy=tt("history.redo"),ly=tt("text.bold"),sy=tt("text.italic"),cy=tt("text.underline"),dy=tt("text.strike"),uy=tt("format.clear"),py=tt("script.super"),my=tt("script.sub"),fy=tt("alignment.left"),gy=tt("alignment.center"),by=tt("alignment.right"),hy=tt("alignment.justify"),yy=tt("direction.ltr"),vy=tt("direction.rtl"),xy=tt("list.bullet"),Cy=tt("list.numbered"),Ty=tt("list.outdent"),Ey=tt("list.indent");var Sy=tt("review.comments");function c2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=H(),{openAtCaret:a}=Fd(),l=editor.chromeProbeForSlot("text.link"),s=i&&l?i.can(l):null,c=s?.ok===true,{t:d}=L(),m=i18n.localizeDisabledReason(s&&!s.ok?s.reason:null,d),u=ee();if(t)return null;let g=Q("text.link"),p=u(g?.labelKey??"text.link"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!c,...c?{}:{"data-disabled":""},"aria-label":p,title:m??p,onMouseDown:q,onClick:()=>a()};return n?jsxRuntime.jsx(j,{...f,children:r}):jsxRuntime.jsx("button",{...f,children:o??r??te(g?.paths)})}var nm=Object.assign(c2,{docxSlot:"text.link"});function d2({className:e,hidden:t}){let o=H(),{onSave:n}=At.useContext(In),r=ee();if(t)return null;let i=Q("file.save"),a=r(i?.labelKey??"file.save"),l=!o||!n;return jsxRuntime.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:q,onClick:()=>n?.(),children:te(i?.paths)})}var rm=Object.assign(d2,{docxSlot:"file.save"});function jn({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var m2=e=>({zoom:e.zoom,mode:e.zoomMode}),f2=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,ky={type:"fixed"};function am(){let e=H(),{zoom:t,mode:o}=W(m2,f2),n=At.useCallback(i=>{e?.setZoom(i);},[e]),r=At.useCallback(i=>{e?.setZoomMode(i);},[e]);return At.useMemo(()=>{let i=o??ky,a=gi(t,"out"),l=gi(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(ky),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Ms}},[e,t,o,n,r])}var Ei=2,Si=3276,Ti=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],y2=e=>e.formatting?.fontSizePt??null;function Ry(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function My(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function Ly(e){return jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:q,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:q,onClick:e.onIncrease,children:"+"})]})}function v2(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<Ei||n>Si?null:n}function x2({className:e,hidden:t}){let o=H(),n=W(y2),{isEnabled:r,disabledReason:i}=ie("font.size"),a=ee(),[l,s]=At.useState(false),[c,d]=At.useState(null),m=At.useRef(null);Fo(m,l,()=>s(false));let u=At.useRef(null),g=At.useId(),p=At.useCallback(C=>{if(!o)return;let E=editor.commandForSlotValue("font.size",C);E&&o.can(E).ok&&o.exec(E);},[o]),f=At.useCallback(C=>{p(Math.min(Si,Math.max(Ei,Math.round(C*2))));},[p]),h=At.useCallback(C=>{s(false),d(null),u.current?.blur(),C&&o?.focus();},[o]);if(At.useEffect(()=>{if(!l)return;let C=S=>{let D=m.current;D&&editor.isDomNode(S.target)&&D.contains(S.target)||(s(false),d(null));},E=editor.hostDocumentOf(m.current);return E.addEventListener("mousedown",C),()=>E.removeEventListener("mousedown",C)},[l]),t)return null;let b=r&&n!==null,v=n===null?"\u2014":String(Math.round(n*2)/2),y=c??v,T=n===null?null:Math.round(n*2)/2,x=()=>{if(c===null)return;let C=v2(c);C!==null&&p(C);};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(Ly,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsxRuntime.jsx("input",{ref:u,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:y,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:C=>{d(C.target.value),s(true);},onFocus:C=>{C.target.select(),s(true);},onClick:()=>s(true),onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),x(),h(true)):C.key==="Escape"?(C.preventDefault(),h(true)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),s(true),n!==null&&f(C.key==="ArrowDown"?My(n,Ti,Ei/2):Ry(n,Ti,Si/2)));},onBlur:()=>{x(),d(null);}}),canDecrease:b&&Math.round(n*2)>Ei,canIncrease:b&&Math.round(n*2)<Si,onDecrease:()=>f(My(n??0,Ti,Ei/2)),onIncrease:()=>f(Ry(n??0,Ti,Si/2))}),l&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:Ti.map(C=>{let E=T===C;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>{f(C),h(true);},children:C},C)})}):null]})}var sm=Object.assign(x2,{docxSlot:"font.size"});function C2({className:e,hidden:t}){let o=H(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=am(),g=ee(),[p,f]=At.useState(false),h=At.useRef(null);Fo(h,p,()=>f(false)),At.useEffect(()=>{if(!p)return;let C=S=>{let D=h.current;D&&editor.isDomNode(S.target)&&D.contains(S.target)||f(false);},E=editor.hostDocumentOf(h.current);return E.addEventListener("mousedown",C),()=>E.removeEventListener("mousedown",C)},[p]);let b=At.useCallback(C=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(C);},[a]),v=At.useCallback(C=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(C==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let y=`${Math.round(n*100)}%`,T=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),x=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(Ly,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle:jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!o,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":`${g("zoom.zoomLevel")}: ${y}`,onMouseDown:q,onClick:()=>f(C=>!C),children:[y,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>v("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":x,...x?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>v("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(C=>{let E=!r&&Math.abs(C-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>b(C),children:`${Math.round(C*100)}%`},C)})]}):null]})}var cm=Object.assign(C2,{docxSlot:"zoom.level"});function Yn(e,t,o,n=false){let r=ke(),i=At.useRef(r);i.current=r,At.useEffect(()=>{e&&n&&t(false);},[e,n,t]),At.useEffect(()=>{let a=o.current;if(!e||n||!a)return;let l=a.ownerDocument,s=u=>a.contains(u),c=u=>{u.composedPath().includes(a)||t(false);},d=editor.listenForPopupEscape({popup:a,contains:s,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:u=>{t(false),u&&a.querySelector("[aria-haspopup]")?.focus();}}),m=editor.listenForPopupFocusLeave({popup:a,contains:s,close:()=>t(false)});return l.addEventListener("mousedown",c),()=>{l.removeEventListener("mousedown",c),d(),m();}},[e,n,t,o]);}var Oy=10,By=0,D2=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),R2=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function M2({className:e,hidden:t}){let o=H(),n=W(D2,R2),{isEnabled:r,disabledReason:i}=ie("list.lineSpacing"),a=ie("paragraph.dialog"),l=W0(),s=ee(),{lang:c}=L(),[d,m]=At.useState(false),u=At.useRef(null),g=At.useRef(null);Yn(d,m,u,t);let p=At.useCallback(T=>{m(false),!(!o||!T.command)&&o.can(T.command).ok&&o.exec(T.command);},[o]),f=At.useCallback((T,x)=>{if(m(false),!o)return;let C={type:"setParagraphSpacing",[T]:x};o.can(C).ok&&o.exec(C);},[o]);if(t)return null;let h=Q("list.lineSpacing"),b=(n.spaceBeforePt??0)>0,v=(n.spaceAfterPt??0)>0,y=editor.lineSpacingMenuRows(n.lineSpacing);return jsxRuntime.jsxs("span",{ref:u,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:g,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:q,onClick:()=>m(T=>!T),children:[te(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[y.map(T=>{let x=T.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x,...x?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>p(T),children:[editor.lineSpacingMenuRowLabel(T,s,c),x?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${T.spacing.rule}:${T.spacing.value}`)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:q,onClick:()=>{m(false),l?.open(g.current);},children:s("lineSpacing.options")}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>f("beforePt",b?By:Oy),children:s(b?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:q,onClick:()=>f("afterPt",v?By:Oy),children:s(v?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var dm=Object.assign(M2,{docxSlot:"list.lineSpacing"});var N2=["alignment.left","alignment.center","alignment.right","alignment.justify"];function L2({className:e,hidden:t}){let o=ie("alignment.left"),n=ie("alignment.center"),r=ie("alignment.right"),i=ie("alignment.justify"),a=ee(),[l,s]=At.useState(false),c=At.useRef(null);if(Yn(l,s,c,t),t)return null;let d=[o,n,r,i],m=N2.map((f,h)=>({slot:f,control:Q(f),state:d[h]})),u=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.state.isEnabled),p=a(u.control?.labelKey??u.slot);return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!g,...g?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":l,"aria-label":p,title:g?p:u.state.disabledReason??p,onMouseDown:q,onClick:()=>s(f=>!f),children:[te(u.control?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:m.map(f=>{let h=a(f.control?.labelKey??f.slot);return jsxRuntime.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:q,onClick:()=>{f.state.execute(),s(false);},children:te(f.control?.paths)},f.slot)})}):null]})}var Us=Object.assign(L2,{docxSlot:"alignment"});function pm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=j0(),m=na();if(d==="panel"&&!l)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>q(g),onClick:g=>{a?.(),m(g.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]});let u={type:"button",className:`docx-toolbar__button${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...r?{"data-disabled":""}:{},...n!==void 0?{"aria-pressed":n}:{},"aria-label":t,title:r?i??t:t,onMouseDown:g=>q(g),onClick:r?void 0:a};return l?jsxRuntime.jsx(j,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var K2=Object.freeze([]),U2=e=>e.formatting?.fontFamily??null,z2=e=>e;function Vs(){let e=H(),t=W(U2),o=W(z2),n=At.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():K2,[e,o]),{isEnabled:r}=ie("font.family"),i=At.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return At.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Ky=At.createContext(null);function fm(){return At.useContext(Ky)}function gm({asChild:e,className:t,children:o}){let n=fm(),r=ee();if(!n)return null;let i=r(Q("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:q,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},l=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(j,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}gm.docxToolbarPart=true;var $2=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"]]),V2=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Uy({asChild:e,className:t,children:o}){let n=fm(),r=ee(),[i,a]=At.useState("");if(At.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=V2.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&($2.get(m.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,m)=>jsxRuntime.jsxs("div",{role:"group",children:[m>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(zy,{value:u},u))]},d.category)),e?jsxRuntime.jsx(j,{...l,children:s}):o!==void 0?jsxRuntime.jsx("div",{...l,children:s}):jsxRuntime.jsxs("div",{className:l.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":r("font.search"),placeholder:r("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function zy({value:e,asChild:t,className:o,children:n}){let r=H(),i=fm();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:q,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=n??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(j,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function G2({hidden:e,asChild:t,className:o,children:n}){let r=Vs(),[i,a]=At.useState(false),l=At.useRef(null);Fo(l,i,()=>a(false)),At.useEffect(()=>{if(!i)return;let m=g=>{let p=l.current;p&&editor.isDomNode(g.target)&&p.contains(g.target)||a(false);},u=editor.hostDocumentOf(l.current);return u.addEventListener("mousedown",m),()=>u.removeEventListener("mousedown",m)},[i]);let s=At.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(gm,{}),jsxRuntime.jsx(Uy,{})]});return jsxRuntime.jsx(Ky.Provider,{value:s,children:t?jsxRuntime.jsx(j,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var bm=Object.assign(G2,{docxSlot:"font.family",Trigger:gm,Content:Uy,Item:zy});var Y2={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},X2=new Set(["Title","Heading1","Heading2","Heading3"]),J2={Subtitle:"666666"},Q2="#4a6c8c";function $y(e){let t=Y2[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??X2.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??J2[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=Q2),n}var e_=/^heading ([1-9])$/;function hm(e,t){let o=e||t,n=e_.exec(o);return n?`Heading ${n[1]}`:o}function Vy(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:hm(t.name,t.styleId),priority:99}))}function d_(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 u_=Object.freeze([]),p_=e=>e.formatting?.styleId??null,m_=e=>e;function Gs(){let e=H(),t=W(p_),o=W(m_),n=At.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:hm(a.name,a.styleId),preview:a.preview})):u_,[e,o]),{isEnabled:r}=ie("styles.style"),i=At.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return At.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Gy=At.createContext(null);function vm(){return At.useContext(Gy)}function xm({asChild:e,className:t,children:o}){let n=vm(),r=ee();if(!n)return null;let i=Q("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:q,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,title:a},s=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:s?.name??n.value}));return e?jsxRuntime.jsx(j,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}xm.docxToolbarPart=true;function jy({asChild:e,className:t,children:o}){let n=ee(),r=vm();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(l=>jsxRuntime.jsx(Yy,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(j,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function Yy({value:e,asChild:t,className:o,children:n}){let r=H(),i=vm();if(!i)return null;let a=i.value===e,l=i.options.find(d=>d.styleId===e),s={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:q,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsxRuntime.jsx("span",{style:l?d_(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(j,{...s,children:c}):jsxRuntime.jsxs("button",{type:"button",...s,children:[c,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function f_({hidden:e,asChild:t,className:o,children:n}){let r=Gs(),[i,a]=At.useState(false),l=At.useRef(null);Fo(l,i,()=>a(false)),At.useEffect(()=>{if(!i)return;let m=g=>{let p=l.current;p&&editor.isDomNode(g.target)&&p.contains(g.target)||a(false);},u=editor.hostDocumentOf(l.current);return u.addEventListener("mousedown",m),()=>u.removeEventListener("mousedown",m)},[i]);let s=At.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xm,{}),jsxRuntime.jsx(jy,{})]});return jsxRuntime.jsx(Gy.Provider,{value:s,children:t?jsxRuntime.jsx(j,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Cm=Object.assign(f_,{docxSlot:"styles.style",Trigger:xm,Content:jy,Item:Yy});function Jy(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=ie(o),m=bo(),u=t==="showAll"?m.showAll:m.formFill,g=ee();if(i)return null;let p=Q(o),f=g(p?.labelKey??e),h={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":f,title:d??f,onMouseDown:q,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(j,{...h,children:s}):jsxRuntime.jsx("button",{...h,children:a??s??te(p?.paths)})},{docxSlot:o})}function b_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Pt.inspector,{isEnabled:a,disabledReason:l}=ie(i),{inspectorOpen:s,openInspector:c}=bo(),d=ee();if(t)return null;let m=Q(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Pt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:q,onClick:()=>c()};return n?jsxRuntime.jsx(j,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??te(m?.paths)})}function h_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=bo(),s=ee();if(t)return null;let c=Pt.remove,d=Q(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Pt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:q,onClick:()=>{l();}};return n?jsxRuntime.jsx(j,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??te(d?.paths)})}var js=Jy(Pt.showAll,"showAll"),Ys=Jy(Pt.formFill,"formFill"),Xs=Object.assign(h_,{docxSlot:Pt.remove}),Js=Object.assign(b_,{docxSlot:Pt.inspector}),Qy={[Pt.showAll]:js,[Pt.formFill]:Ys,[Pt.inspector]:Js,[Pt.remove]:Xs};var ia=Object.assign(e=>jsxRuntime.jsx(Ao,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function y_({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=ie("table.splitCell"),a=To(),l=ee();if(n||!a)return null;let s=l(Q("table.splitCell")?.labelKey??"table.splitCell");return jsxRuntime.jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:q,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??te(Q("table.splitCell")?.paths)})}var la=Object.assign(y_,{docxSlot:"table.splitCell"});function Tm(e,t){let o=H(),n=At.useRef(t);n.current=t,At.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var P_=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],Sm=At.createContext(null);function lv(){let e=At.useContext(Sm);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function w_(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.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}`:"",s=e?.getTableCellSelection()??null,c=s?`${s.tableId}|${s.rows.from}-${s.rows.to}|${s.columns.from}-${s.columns.to}|${s.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:l,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function D_(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function R_(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var av={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function M_(e,t){let o={};for(let n of P_){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function Pm({children:e}){let t=H(),[o,n]=At.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=At.useState(av);At.useEffect(()=>(()=>{}),[]);let a=W(At.useCallback(u=>({table:u.table,editable:u.editable,editingMode:u.editingMode??"editing",headParagraphId:u.selection?.to&&"paraId"in u.selection.to?u.selection.to.paraId:u.selection?.from&&"paraId"in u.selection.from?u.selection.from.paraId:""}),[]),D_,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=At.useCallback(()=>{if(!t){i(av);return}let u=w_(t,t.snapshot());i(g=>R_(g,u)?g:u);},[t]);At.useEffect(()=>{l();},[l,a]),Tm("selectionChange",At.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=At.useMemo(()=>t?M_(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=At.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=editor.runTableChromeCommand(t,u,g,o);p.ok&&f&&n(f);},[t,o]),m=At.useMemo(()=>({visible:s,draft:o,setDraft:n,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsxRuntime.jsx(Sm.Provider,{value:m,children:e})}function __(){let e=At.useContext(Sm);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function ec(e){let t=__(),o=t.slotState(e);return At.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function oc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function nc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=L(),r=i18n.localizeDisabledReason(t,n),i=At.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:q,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var H_='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function dv(e,t,o,n){At.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(H_)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),Yt(d,editor.hostDocumentOf(r).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Yt(d,editor.hostDocumentOf(r).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),Xt(d,"first");return}if(c.key==="End"){c.preventDefault(),Xt(d,"last");return}if(c.key==="Enter"||c.key===" "){let m=editor.hostDocumentOf(c.target).activeElement;editor.isHTMLElementNode(m)&&d.includes(m)&&(c.preventDefault(),m.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function uv(e,t,o,n){At.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=s=>{if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="Enter"||s.key===" "){let c=editor.hostDocumentOf(s.target).activeElement,d=a();editor.isHTMLElementNode(c)&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function hv(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function q_(e){return te(editor.tableChromeIconPaths(e))}function yv(){return At.createContext(null)}function Ko(e){let t=At.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function wm(e,t,o){let n=yv();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=ec(e),[h,b]=At.useState(false),v=At.useRef(null),y=At.useRef(null);Yn(h,b,v,l||!m);let T=At.useMemo(()=>({open:h,setOpen:b,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:y}),[h,u,g,f,p]);if(l||!m)return null;let x={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},C=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:T,children:s?jsxRuntime.jsx(j,{...x,ref:v,children:C}):jsxRuntime.jsx("div",{ref:v,...x,children:C})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=Ko(n),f=ee(),h=Q(e),b=f(h?.labelKey??o),{shared:v,reasonNode:y}=nc({enabled:u,disabledReason:g,ariaLabel:b}),T={...v,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>m(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:hv(u,d,m)}:{}},x=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[te(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...T,children:x}),y]}):jsxRuntime.jsxs("button",{...T,children:[x,y]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=Ko(n),p=ee(),f=At.useRef(null);if(dv(d&&u,m,f,g),!d||!u)return null;let h=Q(e),b=p(h?.labelKey??o),v={ref:f,role:"menu","aria-label":b,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:q};return l?jsxRuntime.jsx(j,{...v,children:c}):jsxRuntime.jsx("div",{...v,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var wi=wm("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function vv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Ko(wi.Ctx),l=ee(),s=editor.TABLE_BORDER_TARGET_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value==="none"?false:s.value===a.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":c,"data-value":s.value,className:`docx-table-chrome__target-btn${o?` ${o}`:""}`,...c?{"data-active":""}:{},"aria-label":l(s.labelKey),title:l(s.labelKey),onMouseDown:q,onClick:()=>{i(false),r(s.value);}},m=n??q_(s.icon);return t?jsxRuntime.jsx(j,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function xv(e){let{children:t}=e;return jsxRuntime.jsx(wi.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(vv,{value:o.value},o.value))})})}function K_(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wi.Trigger,{}),jsxRuntime.jsx(xv,{})]});return jsxRuntime.jsx(wi.Root,{...e,children:o})}var Ii=Object.assign(K_,{docxSlot:"table.borderTarget",Trigger:wi.Trigger,Content:xv,Item:vv}),Di=wm("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function Cv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Ko(Di.Ctx),l=ee(),s=editor.TABLE_BORDER_STYLE_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":c,...c?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:q,onClick:()=>{i(false),r(s.value);}},m=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(s.labelKey)})]});return t?jsxRuntime.jsx(j,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Tv(e){let{children:t}=e;return jsxRuntime.jsx(Di.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(Cv,{value:o.value},o.value))})}function U_(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Di.Trigger,{}),jsxRuntime.jsx(Tv,{})]});return jsxRuntime.jsx(Di.Root,{...e,children:t})}var Ni=Object.assign(U_,{docxSlot:"table.borderStyle",Trigger:Di.Trigger,Content:Tv,Item:Cv}),Ri=wm("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function Ev({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Ko(Ri.Ctx),l=ee(),s=Number(e),c=editor.TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===s);if(!c)return null;let d=c.size===a.spec.size,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:q,onClick:()=>{i(false),r(c.size);}},u=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(c.labelKey)})]});return t?jsxRuntime.jsx(j,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function Sv(e){let{children:t}=e;return jsxRuntime.jsx(Ri.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(Ev,{value:String(o.size)},o.size))})}function z_(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ri.Trigger,{}),jsxRuntime.jsx(Sv,{})]});return jsxRuntime.jsx(Ri.Root,{...e,children:t})}var Li=Object.assign(z_,{docxSlot:"table.borderWidth",Trigger:Ri.Trigger,Content:Sv,Item:Ev});function Pv(e,t,o){let n=o?.defaultHex??"FF0000",r=yv();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:h,draft:b,apply:v}=ec(e),[y,T]=At.useState(false),[x,C]=At.useState(n),E=At.useRef(null),S=At.useRef(null);Yn(y,T,E,d||!p);let D=At.useMemo(()=>({open:y,setOpen:T,enabled:f,disabledReason:h,apply:v,draft:b,triggerRef:S,lastHex:x,setLastHex:C}),[y,f,h,v,b,x]);if(d||!p)return null;let w={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},k=g??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(a,{}),jsxRuntime.jsx(l,{}),jsxRuntime.jsx(s,{clearFill:o?.clearFill??false})]});return jsxRuntime.jsx(r.Provider,{value:D,children:m?jsxRuntime.jsx(j,{...w,ref:E,children:k}):jsxRuntime.jsx("div",{ref:E,...w,children:k})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:h,lastHex:b}=Ko(r),v=ee(),y=Q(e),T=v(y?.labelKey??t),{shared:x,reasonNode:C}=nc({enabled:g,disabledReason:p,ariaLabel:T}),E=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:b??n,S={...x,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:E}):void 0},D=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[te(y?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${E.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...S,children:D}),C]}):jsxRuntime.jsxs("button",{...S,children:[D,C]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:h,triggerRef:b}=Ko(r),v=ee(),y=Q(e),T=v(y?.labelKey??t),{shared:x,reasonNode:C}=nc({enabled:f,disabledReason:h,ariaLabel:T}),E={...x,ref:b,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>p(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:hv(f,g,p)}:{}},S=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...E,children:S}),C]}):jsxRuntime.jsxs("button",{...E,children:[S,C]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:h,apply:b,draft:v,triggerRef:y,lastHex:T,setLastHex:x}=Ko(r),C=ee(),E=At.useRef(null);if(uv(p&&h,f,E,y),!p||!h)return null;let S=C(t),D=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:T??n,w={ref:E,role:"dialog","aria-label":S,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:q},k=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:q,onClick:()=>{f(false),b(null),oc(y.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),C("table.clearCellFill")]}):null,jsxRuntime.jsx(Pd,{apply:F=>{f(false),x?.(F),b({kind:"hex",value:F}),oc(y.current);},current:D})]});return d?jsxRuntime.jsx(j,{...w,children:k}):jsxRuntime.jsx("div",{...w,children:k})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:h,setOpen:b,setLastHex:v,triggerRef:y}=Ko(r),T=ee(),x=m??`#${d.toLowerCase()}`,C=u?T(u):d,E={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:x},"data-value":d,"aria-label":C,title:C,onMouseDown:q,onClick:()=>{b(false),v?.(d),h({kind:"hex",value:d}),oc(y.current);}};return g?jsxRuntime.jsx(j,{...E,children:f}):jsxRuntime.jsx("button",{...E,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var Mi=Pv("table.borderColor","table.borderColor",{defaultHex:"000000"});function $_(e){return jsxRuntime.jsx(Mi.Content,{...e,clearFill:false})}function V_(e){return jsxRuntime.jsx(Mi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function G_(e){return jsxRuntime.jsx(Mi.Root,{...e})}var Fi=Object.assign(G_,{docxSlot:"table.borderColor",Trigger:Mi.Trigger,Content:$_,Item:V_,Main:Mi.Main}),_i=Pv("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function j_(e){return jsxRuntime.jsx(_i.Content,{...e,clearFill:true})}function Y_(e){return jsxRuntime.jsx(_i.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function X_(e){return jsxRuntime.jsx(_i.Root,{...e})}var Hi=Object.assign(X_,{docxSlot:"table.cellFill",Trigger:_i.Trigger,Content:j_,Item:Y_,Main:_i.Main});function kv({overrides:e=new Map,separator:t=true}){return lv()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(jn,{}):null,[Ii,Fi,Ni,Li,Hi].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(At.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)}),[ia,la].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(At.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function wv(){let e=ee(),{draft:t}=ec("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var Rm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],da="contextual-table",Mm={"zoom.level":cm,"styles.style":Cm,"font.family":bm,"font.size":sm,"text.color":kd,"text.highlight":wd,"text.link":nm,"list.lineSpacing":dm,"review.editingMode":Ns,"review.authors":Fs,"file.save":rm,...Qy,"table.borderTarget":Ii,"table.borderColor":Fi,"table.borderStyle":Ni,"table.borderWidth":Li,"table.cellFill":Hi,"table.splitCell":la,"image.insert":Za,"image.properties":Yr,"image.wrap":xi,"image.altText":li},rc={id:da,labelKey:"formattingBar.groups.table",entries:Rm.map(e=>({slot:e,Part:e==="table.mergeCells"?ia:Mm[e]}))},Dv=new Map;function rI(e){let t=Dv.get(e);return t||(t=o=>jsxRuntime.jsx(Ao,{slotId:e,...o}),Dv.set(e,t)),t}function aI(e){return editor.formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:Us}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(o=>{let n=editor.chromeSlotId(t,o);return {slot:n,Part:Mm[n]??rI(n)}})})}var iI=e=>e.image,lI=e=>e.isLoading||e.isOpening===true,sI=e=>e.table!==null;function cI(e){return e==="alignment"||e in Mm}function ic(e){let t=Er(e,ic);if(t!==null)return t;if(!At.isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function Dm(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Dm);let t=ic(e);return t!=null&&Rm.includes(t)?true:At.isValidElement(e)?At.Children.toArray(e.props.children).some(Dm):false}function dI(e,t){return t?true:At.Children.toArray(e).some(Dm)}function uI(e){let t=Nt(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=At.useMemo(()=>({t:n,onSave:r}),[n,r]),c=vl(n),d=W(iI),m=W(lI),u=W(sI),g=At.useMemo(()=>aI(d),[d]),p=At.useMemo(()=>new Set(g.flatMap(E=>E.entries.map(S=>S.slot))),[g]),f=At.useMemo(()=>i?G0(l,ic,E=>p.has(E),E=>Rm.includes(E)):null,[i,l,p]),h=At.useMemo(()=>f?pI(g,f):[],[g,f]),b=At.useMemo(()=>[...h.filter(E=>!E.pinned).map(E=>E.id),...u?[da]:[]],[h,u]),v=At.useMemo(()=>{let E=new Map;for(let S of h)S.priority!==void 0&&E.set(S.id,S.priority);return editor.collapseOrder(b,editor.TOOLBAR_COLLAPSE_ORDER,E)},[h,b]),y=i&&a,{attach:T,overflow:x}=Il(y,b,v),C;if(!f)C=l;else {let{overrides:E,tableOverrides:S,appended:D}=f,w=P=>{let M=E.get(P.slot);if(M)return M;let $=P.Part;return jsxRuntime.jsx($,{})},k=P=>{let M=S.get(P.slot);if(M)return M;let $=P.Part;return jsxRuntime.jsx($,{})},F=[],I=[],N=0;for(let P of h){if(x.has(P.id)){let M=P.entries.flatMap(U=>{let oe=Rv(U,E,c,P.labelKey,w);return oe===null?[]:[jsxRuntime.jsx(At.Fragment,{children:oe},U.slot)]}),$=fI(P);if($!==null&&M.push(jsxRuntime.jsx(At.Fragment,{children:$},"host")),M.length===0)continue;I.push({id:P.id,labelKey:P.labelKey,...P.heading?{label:As(P.heading,c)}:{},children:M});continue}N>0&&F.push(jsxRuntime.jsx(jn,{},`separator-${P.id}`)),N+=1,F.push(jsxRuntime.jsxs("div",{className:`docx-toolbar__group${P.className?` ${P.className}`:""}`,...P.heading?{role:"group","aria-label":As(P.heading,c)}:{},...P.pinned?{[On]:""}:{[rn]:P.id},children:[P.entries.map(M=>jsxRuntime.jsx(At.Fragment,{children:w(M)},M.slot)),P.extras.length>0?jsxRuntime.jsx(At.Fragment,{children:P.extras},"host"):null]},P.id));}let A=x.has(da);if(u&&A){let P=rc.entries.flatMap(M=>{let $=Rv(M,S,c,rc.labelKey,k);return $===null?[]:[jsxRuntime.jsx(At.Fragment,{children:$},M.slot)]});P.length>0&&I.unshift({id:rc.id,labelKey:rc.labelKey,children:P});}C=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[F,u&&!A?jsxRuntime.jsx(jn,{},"separator-contextual-table"):null,A?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[rn]:da,children:jsxRuntime.jsx(kv,{overrides:S,separator:false})}),D.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[On]:"",children:D}):null,I.length>0?jsxRuntime.jsx($0,{sections:I}):null]});}return jsxRuntime.jsx(In.Provider,{value:s,children:jsxRuntime.jsx(B0,{children:jsxRuntime.jsx("fieldset",{ref:T,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,...y?{"data-overflow":""}:{},onMouseDown:q,children:dI(l,i)?jsxRuntime.jsx(Pm,{children:C}):C})})})}function _m(e){if(!e)return false;if(e.type===At.Fragment){let t=At.Children.toArray(e.props.children).find(o=>ic(o)!==null);return At.isValidElement(t)?_m(t):false}return !!e.props.hidden}function pI(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),n=new Set(e.map(s=>s.id)),r=new Map;for(let s of e){let c=o.get(s.id);if(c&&mI(c),c?.hidden)continue;let d=At.Children.toArray(c?.children);!s.entries.some(u=>!_m(t.overrides.get(u.slot)))&&d.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey,heading:void 0,entries:s.entries,extras:d,pinned:c?.pinned??editor.TOOLBAR_PINNED_GROUPS.has(s.id),priority:c?.priority,overflowContent:c?.overflowContent,className:c?.className,host:false});}for(let s of t.groups)s.id===da&&ty(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==da);for(let s of i){let c=At.Children.toArray(s.children);s.hidden||c.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey??s.id,heading:{id:s.id,label:s.label,labelKey:s.labelKey},entries:[],extras:c,pinned:s.pinned===true,priority:s.priority,overflowContent:s.overflowContent,className:s.className,host:true});}let a=[...n,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Q0(s.id,s.after,a);for(let s of t.appended){if(!At.isValidElement(s)||s.type!==vi)continue;let c=s.props.slotId;oy(c,Q(c)!==null);}return editor.arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=r.get(s);return c?[c]:[]})}function mI(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&ey(e.id,t);}function fI(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(Xp.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function Rv(e,t,o,n,r){let i=t.get(e.slot);if(_m(i))return null;let a=i?.type===vi?i.props.overflowContent:void 0;return i||cI(e.slot)?jsxRuntime.jsx(U0,{label:gI(o,e,n),children:a?a():r(e)}):jsxRuntime.jsx(z0,{slot:e.slot})}function gI(e,t,o){let n=t.slot==="alignment"?null:Q(t.slot);return e(n?.labelKey??o)}var Oi=Object.assign(uI,{Button:Ao,Action:pm,Separator:jn,Group:Yp,Slot:vi,AddComment:Jp,Undo:ay,Redo:iy,Bold:ly,Italic:sy,Underline:cy,Strike:dy,Link:nm,ClearFormatting:uy,Superscript:py,Subscript:my,Alignment:Us,AlignLeft:fy,AlignCenter:gy,AlignRight:by,AlignJustify:hy,LeftToRight:yy,RightToLeft:vy,LineSpacing:dm,BulletList:xy,NumberedList:Cy,Outdent:Ty,Indent:Ey,ImageInsert:Za,ImageProperties:Yr,ImageWrap:xi,ImageAltText:li,TableInsert:om,TableBorderTarget:Ii,TableBorderColor:Fi,TableBorderStyle:Ni,TableBorderWidth:Li,TableCellFill:Hi,TableMergeCells:ia,TableSplitCell:la,Comments:Sy,FontFamily:bm,FontSize:sm,FontColor:kd,Highlight:wd,Zoom:cm,StylePicker:Cm,EditingMode:Ns,Reviewers:Fs,Save:rm,ContentControlShowAll:js,ContentControlFormFill:Ys,ContentControlInspector:Js,ContentControlRemove:Xs});var _v=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,vI=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,xI=200,Iv=new TextEncoder;function CI(e,t){if(Iv.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=Iv.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function Nv(e){let t=e.length;for(;t>0;){let o=e.charCodeAt(t-1);if(o!==46&&o!==32)break;t-=1;}return e.slice(0,t)}function Lv(e){return Nv(Nv(e).replace(/\.docx$/i,""))}function lc(e){let t=(e??"").replace(vI," ").replace(/\s+/g," ").trim(),o=Lv(t).replace(/^[. ]+/,""),n=CI(o,xI),r=n===o?o:Lv(n);return !r||_v.test(r)?"document.docx":_v.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function sc(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",n){let r=URL.createObjectURL(new Blob([e],{type:o})),i=editor.hostDocumentOf(n).createElement("a");i.href=r,i.download=t,i.click(),editor.hostWindowOf(n).setTimeout(()=>URL.revokeObjectURL(r),0);}function Fv(e,t,o){let{t:n}=L(),r=At.useRef(false),[i,a]=At.useState(false),[l,s]=At.useState(""),[c,d]=At.useState("pdf"),[m,u]=At.useState(false),[g,p]=At.useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async h=>{if(!(!e||r.current)){r.current=true,p({}),d(h),u(true),a(true),s("");try{let b=await editor.runChromeExport(e,h,t);sc(b.bytes.slice().buffer,lc(o).replace(/\.docx$/,`.${b.extension}`),b.mimeType),u(!1);}catch(b){u(true),s(b instanceof editor.ChromeExportError?n(b.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:b instanceof Error?b.message:String(b)}));}finally{r.current=false,a(false);}}}}}function Av(e,t,o){let{t:n}=L(),r=At.useRef({editor:e,exporters:t,feedback:o,t:n});r.current={editor:e,exporters:t,feedback:o,t:n};let i=At.useRef(null),a=At.useRef(null),[l,s]=At.useState(false),[c,d]=At.useState(""),[m,u]=At.useState(""),[g,p]=At.useState(false),[f,h]=At.useState(false),[b,v]=At.useState({}),y=At.useCallback(C=>{let{t:E}=r.current;if(C instanceof editor.ChromeExportError)return E("toolbar.printPdfMissing");if(C instanceof editor.ChromePrintError){if(C.code==="pdf-viewer-unavailable")return E("toolbar.printNoViewer");if(C.code==="pdf-load-failed")return E("toolbar.printLoadFailed");if(C.code==="print-refused")return E("toolbar.printRefused")}return E("toolbar.printFailedMessage",{message:C instanceof Error?C.message:String(C)})},[]),T=At.useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),x=At.useCallback(async C=>{let{editor:E,exporters:S}=r.current;if(!E||i.current)return;let D={};i.current=D,a.current?.dispose(),a.current=null,v(D),h(true),p(true),s(true),d(""),u("");try{let w=await editor.runChromePrint(E,S,C??editor.hostDocumentOf(null));if(i.current!==D){w.dispose();return}a.current=w,await w.print({beforePrint:()=>{if(i.current!==D)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>p(!1));}}),i.current===D&&T();}catch(w){if(i.current!==D)return;if(!r.current.feedback){console.error("[docx-editor] print failed",w),T();return}s(false),u(a.current?.url??""),d(y(w)),p(true);}},[T,y]);return At.useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:l,error:c,url:m,visible:g,active:f,session:b,execute:x,close:T}}var II=()=>{};function Lm(){let e=H(),t=At.useCallback(n=>e?e.on("hostChange",n):II,[e]),o=At.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return At.useSyncExternalStore(t,o,()=>null)}var NI="https://github.com/eigenpal/docx-editor/issues/new";function LI(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Bv(e={}){let t=e.userAgent??(typeof globalThis.navigator<"u"?globalThis.navigator.userAgent:"unknown"),o=e.viewport??(typeof globalThis.window<"u"?{width:globalThis.window.innerWidth,height:globalThis.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??LI()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
+
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${NI}?${i.toString()}`}function Wi(e){typeof globalThis.window>"u"||globalThis.window.open(Bv(e),"_blank","noopener,noreferrer");}function FI({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=it(),a=De();if(t||i===false)return null;let l=o??r??Wi;return jsxRuntime.jsx(_e,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var cc=Object.assign(FI,{docxSlot:"help.reportIssue"});function HI({children:e,...t}){let{reportIssue:o}=it();return e===void 0&&o===false?null:jsxRuntime.jsxs(Qt,{id:"help",...t,children:[jsxRuntime.jsx(cc,{}),e]})}var Fm=Object.assign(HI,{docxMenu:"help"});var WI=e=>e.hiddenReviewAuthors??[];function dc({className:e,hidden:t}){let o=H(),n=hi(),r=W(WI),i=De(),{t:a}=L();if(t)return null;let l=i("reviewers.label"),s=editor.toolbarCommandState(o,"review.authors"),c=i18n.localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsxRuntime.jsx(_e,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(r),m=n.every(u=>!d.has(u.author));return jsxRuntime.jsxs(Jt,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(Zv,{checked:m,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!m)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsxRuntime.jsx(Zv,{checked:!d.has(u.author),label:u.author||"\u2014",slot:`reviewer-${u.slot}`,onChoose:()=>o?.setReviewAuthorVisible(u.author,d.has(u.author))},u.author))]})}function Zv(e){return jsxRuntime.jsx(_e,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsxRuntime.jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function ZI({children:e,...t}){return jsxRuntime.jsxs(Qt,{id:"review",...t,children:[jsxRuntime.jsx(Jt,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(dc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var uc=Object.assign(ZI,{docxMenu:"review"});var UI={file:yu,format:vu,insert:xu,review:uc,help:Fm};function Zi(e,t=false){if(!At.isValidElement(e))return null;if(e.type===At.Fragment){let i=At.Children.toArray(e.props.children).map(a=>Zi(a,t)).filter(a=>a!==null);return i.length===1?i[0]:null}let o=e.props;if(o.hidden===true&&!t)return null;let n=e.type;return (typeof n=="function"||typeof n=="object")&&typeof n.docxMenu=="string"?n.docxMenu:e.type===Qt&&typeof o.id=="string"?o.id:null}var zI=new Set(editor.CHROME_MENUS.map(e=>e.id));function bc(e){if(!At.isValidElement(e))return null;if(e.type===At.Fragment){let n=At.Children.toArray(e.props.children).map(bc).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===Qt){let o=e.props.id;if(typeof o=="string"&&zI.has(o))return o}return null}var $I=e=>e.isOpening===true;function VI(e){let t=To(),o=St(),n=Nt(),{className:r,t:i,fileName:a,exporters:l,onOpen:s,onOpenFile:c,onSave:d,onPageSetup:m,onReportIssue:u,reportIssue:g,preset:p=true,overflow:f=true,children:h}=e,b=H(),{t:v}=L(),[y,T]=At.useState(null),x=W($I);At.useEffect(()=>{x&&T(null);},[x]);let[C,E]=At.useState(null),S=Fv(b,l,a??C??void 0),{pending:D,execute:w}=S,k=Av(b,l,o?.print!==false),{active:F,execute:I}=k,N=k.visible&&o?.print!==false,[A,P]=At.useState(null),[M,$]=At.useState(false),[U,oe]=At.useState(false),[Y,ne]=At.useState(false),K=At.useRef(null),X=At.useRef(null);At.useEffect(()=>{if(y===null)return;let de=Ne=>{let ye=K.current;ye&&editor.isDomNode(Ne.target)&&ye.contains(Ne.target)||T(null);},ue=editor.hostDocumentOf(K.current);return ue.addEventListener("mousedown",de),()=>{ue.removeEventListener("mousedown",de);}},[y]),oa(y!==null,K,()=>T(null),de=>editor.isDomNode(de.target)&&K.current?.contains(de.target)===true);let le=At.useCallback(de=>{T(de),de!==null&&P(de);},[]),B=At.useCallback(()=>X.current?.click(),[]),_=At.useCallback(()=>{b&&b.save().then(de=>sc(de,lc(a??C??void 0),void 0,K.current)).catch(de=>{console.error("[docx-editor] save failed",de);});},[b,a,C]),O=At.useCallback(()=>t?t.open("pageSetup",K.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):$(true),[t]),ae=b?s??B:void 0,se=b?d??_:void 0,he=!!l?.pdf,Me=At.useMemo(()=>b&&!F?()=>{ru(K.current),I(editor.editorInstanceScope(K.current)??K.current??void 0);}:void 0,[b,F,I]),je=b?t?.ownsPageSetup?O:m??O:void 0,$e=Lm();At.useEffect(()=>{let de=ye=>{if(!(ye.metaKey||ye.ctrlKey)||ye.altKey||ye.shiftKey)return;let at=ye.key.toLowerCase(),Lo=editor.isChromePrintShortcut(ye);if(at!=="s"&&at!=="o"&&!Lo)return;let uo=ye.target,id=editor.editorInstanceScope(K.current)??K.current;if(!(!uo||!((id?.contains(uo)??false)||qg(uo,editor.hostDocumentOf(K.current),b?editor.editorHostElement(b):null))))if(Lo){if(!he||!b||!Me&&!N)return;ye.preventDefault(),Me?.();}else at==="s"&&se?(ye.preventDefault(),se()):at==="o"&&ae&&(ye.preventDefault(),ae());},ue=editor.hostDocumentOf(K.current),Ne=$e&&$e!==ue?[ue,$e]:[ue];for(let ye of Ne)ye.addEventListener("keydown",de);return ()=>{for(let ye of Ne)ye.removeEventListener("keydown",de);}},[ae,se,Me,N,he,b,$e]);let Pe=At.useMemo(()=>({t:i,openMenu:y,setOpenMenu:le,activeMenu:A,onOpen:ae,onSave:se,onExport:b&&!D?de=>(ru(K.current),w(de)):void 0,onPrint:Me,printShortcut:he,onPageSetup:je,onParagraphDialog:()=>t?t.open("paragraph",K.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):oe(true),onWatermarkDialog:b?()=>t?t.open("watermark",K.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):ne(true):void 0,onReportIssue:u,reportIssue:g,opening:x}),[x,b,D,w,Me,he,i,y,le,A,ae,se,je,t,u,g]),Ct=At.Children.toArray(h),Io=[];if(p){let de=new Map(Ct.map(ue=>[bc(ue),ue]));for(let ue of editor.CHROME_MENUS){let Ne=de.get(ue.id);(Ne===void 0||Zi(Ne)!==null)&&Io.push(ue.id);}for(let ue of Ct){if(bc(ue)!==null)continue;let Ne=Zi(ue);Ne!==null&&Io.push(Ne);}}else for(let de of Ct){let ue=Zi(de);ue!==null&&Io.push(ue);}let No=[...Io].reverse(),{attach:Xo,overflow:$t}=Il(f,Io,No),ce=At.useMemo(()=>({measuring:f,overflow:$t,inMore:false}),[f,$t]),rt=At.useMemo(()=>({measuring:false,overflow:$t,inMore:true}),[$t]),Ee=de=>Zi(de,true)!==null,Jo=(de,ue)=>jsxRuntime.jsx("div",{role:"none",className:"docx-menubar__host",[On]:"",children:de},ue),co,Bt;if(!p)co=Ct.filter(Ee),Bt=f?Ct.map((de,ue)=>Ee(de)?de:Jo([de],`host-${ue}`)):h;else {let de=new Map,ue=[];for(let ye of Ct){let at=bc(ye);at?de.set(at,ye):ue.push(ye);}co=[...editor.CHROME_MENUS.map(ye=>{let at=de.get(ye.id);if(at)return jsxRuntime.jsx(At.Fragment,{children:at},ye.id);let Lo=UI[ye.id];return jsxRuntime.jsx(Lo,{},ye.id)}),...ue.filter(Ee)];let Ne=ue.filter(ye=>!Ee(ye));Bt=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[co,Ne.length>0?Jo(Ne,"host"):null]});}let Dn=i?.("formattingBar.more")??v("formattingBar.more");return jsxRuntime.jsxs(Ha.Provider,{value:Pe,children:[jsxRuntime.jsx("div",{ref:de=>{if(K.current=de,Xo(de),de&&A===null){let ue=nu(de)[0]?.closest("[data-menu]")?.getAttribute("data-menu");ue&&P(ue);}},role:"menubar","aria-label":i?.("titleBar.menuBarAriaLabel")??v("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...f?{"data-overflow":""}:{},className:`${n}docx-menubar${r?` ${r}`:""}`,onMouseDown:q,onKeyDown:de=>{if(de.key!=="ArrowLeft"&&de.key!=="ArrowRight")return;let ue=K.current;if(!ue)return;let Ne=nu(ue),ye=Ne.indexOf(editor.hostDocumentOf(ue).activeElement);if(ye===-1)return;de.preventDefault();let at=de.key==="ArrowRight"?1:-1,Lo=Ne[(ye+at+Ne.length)%Ne.length],uo=Lo?.closest("[data-menu]")?.getAttribute("data-menu");uo&&(P(uo),Lo?.focus(),y!==null&&T(uo));},children:jsxRuntime.jsxs(Ml.Provider,{value:ce,children:[jsxRuntime.jsx(Pr.Provider,{value:0,children:Bt}),$t.size>0?jsxRuntime.jsx(Qt,{id:Sr,label:Dn,icon:te(Gp),preset:false,children:jsxRuntime.jsx(Ml.Provider,{value:rt,children:co})}):null]})}),jsxRuntime.jsxs(ah,{children:[S.visible&&o?.export!==false?o?.export?Te(o.export,{open:true,format:S.format,pending:S.pending,error:S.error,onClose:S.dismiss},S.session):jsxRuntime.jsx(ka,{open:true,format:S.format,pending:S.pending,error:S.error,onClose:S.dismiss}):null,k.visible&&o?.print!==false?o?.print?Te(o.print,{open:true,pending:k.pending,error:k.error,url:k.url,onClose:k.close},k.session):jsxRuntime.jsx(wa,{open:true,pending:k.pending,error:k.error,url:k.url,onClose:k.close}):null]}),jsxRuntime.jsx("input",{ref:X,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:de=>{let ue=de.target.files?.[0];de.target.value="",!(!ue||!b)&&(E(ue.name),c?.(ue),ue.arrayBuffer().then(Ne=>b.load(new Uint8Array(Ne))).catch(Ne=>{console.error("[docx-editor] could not open the file",Ne);}));}}),jsxRuntime.jsx(Zn,{open:M,onClose:()=>$(false)}),jsxRuntime.jsx(Zo,{open:U,onClose:()=>oe(false)}),jsxRuntime.jsx(qn,{open:Y,onClose:()=>ne(false)})]})}var qi=Object.assign(VI,{Menu:Qt,File:yu,Format:vu,Insert:xu,Review:uc,Help:Fm,Item:Zt,Row:_e,Group:Ka,Separator:Bn,Submenu:Jt,TableGrid:Dr,Entry:za,Open:du,Save:uu,ExportMarkdown:pu,ExportPdf:mu,Print:fu,PageSetup:gu,ImageInsert:bu,Watermark:Bl,Bookmark:Wl,Reviewers:dc,ReportIssue:cc});var JI=12240,jv=1440,Jv=1440,Qv=567,Qn=20,Zm=6,Km=Qn+Zm+2,QI="var(--doc-text-muted)",e8="var(--doc-text-subtle)",Yv="var(--doc-shadow-subtle)",t8="var(--doc-primary)",o8="var(--doc-primary-hover)",n8="var(--doc-text-subtle)",Ui=5,Ki=7,r8={left:0,right:0,firstLine:0};function Xv(e,t){return t==="inch"?(e/Jv).toFixed(2)+'"':(e/Qv).toFixed(1)+" cm"}function a8(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function er({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:s=false,onIndentChange:c,onIndentDragEnd:d,unit:m="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:f}){let{t:h}=L(),[b,v]=At.useState(null),[y,T]=At.useState(null),[x,C]=At.useState(null),[E,S]=At.useState(null),D=At.useRef(null),w=e?.pageWidthTwips??JI,k=e?.marginsTwips.left??jv,F=e?.marginsTwips.right??jv,I=e?.gutterTwips??0,N={pageWidth:w,leftMargin:k,rightMargin:F},A=l??r8,P=We(w)*t,M=We(k)*t,$=We(F)*t,U=At.useCallback(_=>{let O=D.current?.getBoundingClientRect();return O?ws((_-O.left)/t):null},[t]),oe=At.useCallback((_,O,ae)=>{let se=U(O);if(se===null)return;if(S(We(se)*t),_==="leftMargin"||_==="rightMargin"){if(_==="leftMargin"){let Me=w-F-I-720,je=Math.round(Math.max(0,Math.min(se,Me)));C(je),n?.(je);}else {let Me=w-se,je=w-k-I-720,$e=Math.round(Math.max(0,Math.min(Me,je)));C($e),r?.($e);}return}let he=editor.dragIndent(_,se,A,N,{unit:m,precise:ae});C(_==="right"?he.right:_==="firstLine"?he.firstLine:he.left),c?.(he);},[U,t,w,k,F,I,n,r,c,A,N,m]),Y=At.useCallback(_=>{_==="leftMargin"||_==="rightMargin"?i?.():d?.(),v(null),C(null),S(null);},[i,d]),ne=At.useCallback((_,O,ae)=>{let se=editor.handlePosition(_,A,N),he=editor.dragIndent(_,se+O*a8(m,ae),A,N,{unit:m,precise:true});c?.(he),d?.();},[A,N,m,c,d]),K=u8(w,t,m),X=a&&s&&c!==void 0,le=_=>We(editor.handlePosition(_,A,N))*t,B=(_,O,ae)=>({positionPx:le(_),editable:X,isDragging:b===_,isHovered:y===_,onPointerEnter:()=>T(_),onPointerLeave:()=>T(null),onPointerDown:se=>{X&&(se.preventDefault(),se.stopPropagation(),se.currentTarget.setPointerCapture(se.pointerId),v(_));},onPointerMove:se=>{b===_&&oe(_,se.clientX,se.altKey);},onPointerUp:se=>{b===_&&(se.currentTarget.releasePointerCapture(se.pointerId),Y(_));},onKeyDown:se=>{X&&(se.key!=="ArrowLeft"&&se.key!=="ArrowRight"||(se.preventDefault(),ne(_,se.key==="ArrowLeft"?-1:1,se.shiftKey)));},label:h(O),valueNow:ae,valueText:Xv(ae,m),pageWidthTwips:w});return jsxRuntime.jsxs("div",{ref:D,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:kt(P),height:Km,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:b?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":h("ruler.horizontal"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:kt(M),height:Qn,backgroundColor:Yv,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?_=>{_.preventDefault(),_.currentTarget.setPointerCapture(_.pointerId),v("leftMargin");}:void 0,onPointerMove:_=>b==="leftMargin"&&oe("leftMargin",_.clientX,_.altKey),onPointerUp:_=>{b==="leftMargin"&&(_.currentTarget.releasePointerCapture(_.pointerId),Y("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:kt($),height:Qn,backgroundColor:Yv,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?_=>{_.preventDefault(),_.currentTarget.setPointerCapture(_.pointerId),v("rightMargin");}:void 0,onPointerMove:_=>b==="rightMargin"&&oe("rightMargin",_.clientX,_.altKey),onPointerUp:_=>{b==="rightMargin"&&(_.currentTarget.releasePointerCapture(_.pointerId),Y("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Qn,pointerEvents:"none"},children:K.map((_,O)=>jsxRuntime.jsx(i8,{tick:_},O))}),p?.map(_=>jsxRuntime.jsx(d8,{tabMark:_,positionPx:We(_.position)*t,onDoubleClick:()=>f?.(_.position)},_.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Wm,{direction:"down",anchor:"top",...B("firstLine","ruler.firstLineIndent",A.firstLine)}),jsxRuntime.jsx(Wm,{direction:"up",anchor:"strip",...B("hanging","ruler.hangingIndent",A.left)}),jsxRuntime.jsx(l8,{...B("left","ruler.leftIndent",A.left)}),jsxRuntime.jsx(Wm,{direction:"up",anchor:"strip",...B("right","ruler.rightIndent",A.right)})]}),b&&x!==null&&E!==null&&jsxRuntime.jsx(s8,{value:Xv(x,m),positionPx:E})]})}function i8({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:kt(e.position),bottom:0,width:1,height:e.height,backgroundColor:e8}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:kt(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:QI,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function ex(e){return e.editable?e.isDragging||e.isHovered?o8:t8:n8}function tx(e,t,o){return {position:"absolute",left:kt(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function ox(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 Wm({direction:e,anchor:t,...o}){let n=ex(o),r=t==="top"?{top:0,height:Ki+1}:{top:Qn-Ki,height:Ki};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:tx(o,Ui*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...ox(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Ui}px solid transparent`,borderRight:`${Ui}px solid transparent`,...e==="down"?{top:0,borderTop:`${Ki}px solid ${n}`}:{bottom:0,borderBottom:`${Ki}px solid ${n}`},transition:"border-color 0.1s"}})})}function l8(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:tx(e,Ui*2,{top:Qn+1,height:Zm}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...ox(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:Ui*2-2,height:Zm,backgroundColor:ex(e),borderRadius:1,transition:"background-color 0.1s"}})})}function s8({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:kt(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 c8={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function d8({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:kt(t-5),top:Qn-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:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:c8[e.alignment]||"L"})}function u8(e,t,o){let n=[];if(o==="inch"){let r=Jv/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=We(l)*t;a%8===0?n.push({position:s,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?n.push({position:s,height:5}):a%2===0?n.push({position:s,height:3}):n.push({position:s,height:2});}}else {let r=Qv/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=We(l)*t;a%10===0?n.push({position:s,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?n.push({position:s,height:5}):n.push({position:s,height:3});}}return n}var g8=15840,ax=1440,vc=1440,xc=567,ma=20,b8="var(--doc-text-muted)",h8="var(--doc-text-subtle)",y8="var(--doc-primary)",v8="var(--doc-primary)",x8="var(--doc-primary-hover)";function zi({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=L(),[d,m]=At.useState(null),[u,g]=At.useState(null),p=At.useRef(null),f=e?.pageHeightTwips??g8,h=e?.marginsTwips.top??ax,b=e?.marginsTwips.bottom??ax,v=(k,F)=>{if(!o||k.altKey||k.ctrlKey||k.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(k.key))return;k.preventDefault();let I=F==="topMargin"?h:b,A=Math.max(0,f-(F==="topMargin"?b:h)-720),P=k.shiftKey?1:Math.round(a==="cm"?xc/10:vc/8),M=k.key==="Home"?0:k.key==="End"?A:Math.max(0,Math.min(A,I+(k.key==="ArrowUp"?P:-P)));M!==I&&((F==="topMargin"?n:r)?.(M),i?.());},y=We(f)*t,T=We(h)*t,x=We(b)*t,C=At.useCallback((k,F)=>{o&&(k.preventDefault(),m(F));},[o]),E=At.useCallback(k=>{if(!d||!p.current)return;let F=p.current.getBoundingClientRect(),I=k.clientY-F.top,N=ws(I/t);if(d==="topMargin"){let A=f-b-720,P=Math.max(0,Math.min(N,A));n?.(Math.round(P));}else if(d==="bottomMargin"){let A=f-N,P=f-h-720,M=Math.max(0,Math.min(A,P));r?.(Math.round(M));}},[d,t,f,h,b,n,r]),S=At.useCallback(()=>{d!==null&&i?.(),m(null);},[d,i]);At.useEffect(()=>{if(d){let k=editor.hostDocumentOf(p.current);return k.addEventListener("mousemove",E),k.addEventListener("mouseup",S),()=>{k.removeEventListener("mousemove",E),k.removeEventListener("mouseup",S);}}},[d,E,S]);let D=T8(f,t,a),w={position:"relative",width:ma,height:kt(y),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${l}`,style:w,role:"group","aria-label":c("ruler.vertical"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:D.map((k,F)=>jsxRuntime.jsx(C8,{tick:k},F))}),jsxRuntime.jsx(ix,{type:"topMargin",value:h,maximum:Math.max(0,f-b-720),valueText:h/(a==="cm"?xc:vc),unit:a,onKeyDown:k=>v(k,"topMargin"),position:T,editable:o,isDragging:d==="topMargin",isHovered:u==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:k=>C(k,"topMargin")}),jsxRuntime.jsx(ix,{type:"bottomMargin",value:b,maximum:Math.max(0,f-h-720),valueText:b/(a==="cm"?xc:vc),unit:a,onKeyDown:k=>v(k,"bottomMargin"),position:y-x,editable:o,isDragging:d==="bottomMargin",isHovered:u==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:k=>C(k,"bottomMargin")})]})}function C8({tick:e}){let t={position:"absolute",top:kt(e.position),right:0,height:1,width:e.width,backgroundColor:h8},o={position:"absolute",top:kt(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:b8,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function ix({type:e,position:t,value:o,maximum:n,valueText:r,unit:i,onKeyDown:a,editable:l,isDragging:s,isHovered:c,onMouseEnter:d,onMouseLeave:m,onMouseDown:u}){let{t:g}=L(),p=s?x8:c?v8:y8,f={position:"absolute",top:kt(t-5),right:0,width:ma,height:10,cursor:l?"ns-resize":"default",zIndex:s?10:1},h={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${p}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:f,onMouseEnter:d,onMouseLeave:m,onMouseDown:u,role:"slider","aria-label":g(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":n,"aria-valuetext":`${r.toFixed(2)} ${i==="cm"?"cm":"in"}`,"aria-disabled":!l,onKeyDown:a,tabIndex:l?0:-1,children:jsxRuntime.jsx("div",{style:h})})}function T8(e,t,o){let n=[];if(o==="inch"){let r=vc/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=We(l)*t;if(a%8===0){let c=a/8;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:s,width:6}):a%2===0?n.push({position:s,width:4}):n.push({position:s,width:2});}}else {let r=xc/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=We(l)*t;if(a%10===0){let c=a/10;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:s,width:6}):n.push({position:s,width:3});}}return n}var P8=e=>e.formatting?.indent??null,k8=e=>e.editable;function zm(){let e=H(),t=W(P8),o=W(k8),n=At.useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=At.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 At.useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var ux=e=>e.zoom,D8=e=>e.isOpening===true;function px(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function mx(){let{apply:e}=Wn(),[t,o]=At.useState({}),n=At.useRef({}),r=At.useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=At.useCallback(()=>{let a=n.current;n.current={},o({}),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 dx(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function R8(){let e=H(),{indent:t,isEnabled:o,apply:n}=zm(),[r,i]=At.useState(null),a=At.useRef(null),l=At.useRef(null),s=At.useCallback(m=>{l.current===null&&(l.current=dx(e)),a.current=m,i(m);},[e]),c=At.useCallback(()=>{let m=a.current,u=l.current;a.current=null,l.current=null,i(null),m&&(u!==null&&u!==dx(e)||n({left:m.left,right:m.right,firstLine:m.firstLine}));},[e,n]),d=At.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[r,t]);return At.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function M8(){let e=ke(),[t,o]=At.useState(0);return At.useEffect(()=>{if(!e){o(0);return}let n=()=>o(e.scrollLeft);return n(),e.addEventListener("scroll",n,{passive:true}),()=>e.removeEventListener("scroll",n)},[e]),t}function Tc(e){let t=W(eo),o=W(D8),{pageSetup:n,isEnabled:r}=Wn(),i=W(ux),{pending:a,preview:l,commit:s}=mx(),c=R8(),d=_n(),m=pn(),u=M8();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+m.inlineStart,paddingRight:m.inlineEnd},children:jsxRuntime.jsx(er,{pageSetup:px(n,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-u}px)`,clipPath:d>0&&u>0?`inset(0 0 0 ${u}px)`:e.style?.clipPath}})})}function Ec(e){let t=W(eo),{pageSetup:o,isEnabled:n}=Wn(),r=W(ux),{pending:i,preview:a,commit:l}=mx(),s=_n(),c=pn(),d=P0();return t||d!==null&&d>0&&o&&We(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(zi,{pageSetup:px(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function Z({size:e=20,className:t="",style:o,children:n}){return jsxRuntime.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,...o},"aria-hidden":"true",children:n})}function fx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 gx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 bx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 hx(e){return jsxRuntime.jsxs(Z,{...e,children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function yx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function vx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 xx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Cx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Tx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Ex(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Sx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Px(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Zm-120 480v-400 400Z"})})}function N8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 L8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 F8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 H8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 A8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 O8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 B8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function W8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Z8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 q8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 K8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 U8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 z8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z"})})}function $8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M40-40v-240h80v-400H40v-240h240v80h400v-80h240v240h-80v400h80v240H680v-80H280v80H40Zm240-160h400v-80h80v-400h-80v-80H280v80h-80v400h80v80Zm32-120 136-360h64l136 360h-62l-32-92H408l-32 92h-64Zm114-144h108l-52-150h-4l-52 150ZM120-760h80v-80h-80v80Zm640 0h80v-80h-80v80Zm0 640h80v-80h-80v80Zm-640 0h80v-80h-80v80Zm80-640Zm560 0Zm0 560Zm-560 0Z"})})}function V8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function G8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function j8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function Y8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function X8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function jm(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 J8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 Q8(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 eN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function tN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function oN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function nN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 rN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 aN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function iN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 lN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 sN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 cN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 dN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 kx(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function uN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 pN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 mN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 fN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function gN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function bN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 hN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 yN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 vN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function xN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 CN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 TN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function EN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function SN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function PN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 kN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 wN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 DN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function RN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 MN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 _N(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 IN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 NN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 LN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 FN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function HN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function AN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 ON(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 BN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 WN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 ZN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 qN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 KN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 UN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 zN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 $N(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 VN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function GN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 jN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 YN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 XN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function JN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 QN(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function e5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function t5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function o5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function n5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function r5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function a5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 i5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 l5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 s5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function c5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 d5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function u5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-120v-640q0-33 23.5-56.5T280-840h400q33 0 56.5 23.5T760-760v640L480-240 200-120Zm80-122 200-86 200 86v-518H280v518Zm0-518h400-400Z"})})}function p5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-40v-640q0-33 23.5-56.5T200-760h400q33 0 56.5 23.5T680-680v640L400-160 120-40Zm80-122 200-86 200 86v-518H200v518Zm560 2v-680H240v-80h520q33 0 56.5 23.5T840-840v680h-80ZM200-680h400-400Z"})})}function m5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 f5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 g5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.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 b5={undo:N8,redo:L8,print:F8,file_download:H8,file_upload:A8,format_bold:O8,format_italic:B8,format_underlined:W8,strikethrough_s:Z8,superscript:q8,subscript:K8,link:U8,format_clear:V8,format_paragraph:z8,format_shapes:$8,lock:Px,format_align_left:G8,format_align_center:j8,format_align_right:Y8,format_align_justify:X8,format_line_spacing:jm,format_list_bulleted:J8,format_list_numbered:Q8,format_indent_increase:eN,format_indent_decrease:tN,format_color_text:oN,ink_highlighter:nN,format_color_reset:rN,arrow_drop_down:aN,table:iN,table_chart:lN,grid_on:sN,table_rows:cN,view_column:dN,border_all:kx,select_all:kx,border_outer:uN,border_inner:pN,border_clear:mN,add:fN,remove:gN,delete:bN,delete_sweep:hN,call_merge:yN,call_split:vN,drag_indicator:xN,image:CN,format_image_left:TN,format_image_right:EN,horizontal_rule:SN,flip_to_back:PN,flip_to_front:kN,open_with:wN,tune:DN,rotate_right:RN,rotate_left:MN,swap_horiz:_N,swap_vert:IN,shapes:NN,format_paint:LN,expand_more:FN,expand_less:HN,border_top:AN,border_bottom:ON,border_left:BN,border_right:WN,border_horizontal:ZN,border_vertical:qN,padding:KN,text_rotation_none:UN,wrap_text:zN,height:$N,fit_width:VN,settings:GN,border_color:jN,format_color_fill:YN,vertical_align_top:XN,vertical_align_center:JN,vertical_align_bottom:QN,line_weight:e5,keyboard_arrow_up:t5,keyboard_arrow_down:o5,keyboard_arrow_left:n5,keyboard_arrow_right:r5,more_vert:a5,page_break:i5,branding_watermark:l5,arrow_back:s5,search:c5,toc:d5,bookmark:u5,bookmarks:p5,done_all:fx,check_circle:gx,chat_bubble_outline:bx,chat_bubble_check:hx,check:yx,close:vx,add_comment:xx,comment:Cx,edit_note:Tx,rate_review:Ex,visibility:Sx,format_textdirection_l_to_r:m5,format_textdirection_r_to_l:f5,"agent-sparkle":g5};function V({name:e,size:t=20,className:o="",style:n}){let r=b5[e];return r?jsxRuntime.jsx(r,{size:t,className:o,style:n}):(console.warn(`Icon not found: ${e}`),jsxRuntime.jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...n},children:e}))}var $i=12,Ym=240,Dx=16,T5=24,E5=$i+Ym+Dx,fa=12,S5=36,P5=fa+S5+Dx,Vi=At__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=$i}){let{t:l}=L(),[s,c]=At.useState(false),d=At.useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return At.useEffect(()=>{editor.hostWindowOf(d.current).requestAnimationFrame(()=>c(true));},[]),jsxRuntime.jsxs("nav",{ref:d,className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:Ym,paddingTop:T5,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+Ym}px)`,transition:"transform 0.15s ease-out"},onMouseDown:u=>u.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsxRuntime.jsx("button",{onClick:n,"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:jsxRuntime.jsx(V,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((u,g)=>jsxRuntime.jsx("div",{style:{marginLeft:(u.level-m)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(u.blockId),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:u.text,children:u.text})},`${u.blockId}-${g}`))})]})});var D5=e=>e,R5=Object.freeze([]),M5=()=>{};function Xm(e){let t=H(),o=W(D5),n=At.useMemo(()=>t&&!o.isLoading?t.getOutline():R5,[t,o]),r=At.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 eo(o)?null:jsxRuntime.jsx(Vi,{headings:n,onHeadingClick:r,onClose:e.onClose??M5,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Jm=At.createContext(null);function Po(e){let t=At.useContext(Jm);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var H5={ok:false,code:"unsupported",reason:"editor is not ready"},Mx=Object.freeze([]);function Sc(e={}){let t=e.enabled??true,o=H(),n=At.useCallback(D=>t?o?.query({type:"bookmarks"})??Mx:Mx,[o,t]),r=W(n,Au),[i,a]=At.useState(""),[l,s]=At.useState("name"),[c,d]=At.useState(false),[m,u]=At.useState(null),[g,p]=At.useState(null),[f,h]=At.useState(""),b=At.useMemo(()=>editor.goToBookmarkRows(r,{query:i,sortBy:l,showHidden:c}),[r,i,l,c]),v=At.useMemo(()=>m===null?-1:b.findIndex(D=>D.name===m),[b,m]),y=At.useCallback(D=>{a(D),u(null),p(null);},[]),T=At.useCallback(D=>{s(D),u(null),p(null);},[]),x=At.useCallback(D=>{d(D),u(null),p(null);},[]),C=At.useCallback(D=>{if(b.length===0)return;let w=v<0?D>0?-1:0:v;u(b[(w+D+b.length)%b.length].name);},[b,v]),E=At.useCallback(D=>u(b[D]?.name??null),[b]),S=At.useCallback(D=>{if(!o)return H5;let w=D??b[v]?.name??editor.goToBookmarkTarget(r,i,b)?.name;if(w===void 0||w.trim().length===0){let F=i.trim();return p(F.length===0?"empty":"notFound"),h(F),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let k=o.exec({type:"goToBookmark",name:w});return p(k.ok?null:k.code==="notFound"?"notFound":"failed"),h(k.ok?"":w),k},[o,b,v,r,i]);return {query:i,setQuery:y,sortBy:l,setSortBy:T,showHidden:c,setShowHidden:x,rows:b,bookmarks:r,activeIndex:v,move:C,setActiveIndex:E,go:S,problem:g,problemName:f}}var _x=(...e)=>e.filter(Boolean).join(" "),q5={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},K5={body:"navigation.goTo.groups.body",header:"navigation.goTo.groups.header",footer:"navigation.goTo.groups.footer",footnote:"navigation.goTo.groups.footnote",endnote:"navigation.goTo.groups.endnote"};function U5(){return jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:"M5.5 2.5h5M5.5 13.5h5M8 2.5v11",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})}function z5({name:e,query:t}){let o=editor.goToBookmarkMatch(e,t);return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.slice(0,o.start),jsxRuntime.jsx("span",{className:"docx-nav__goto-match",children:e.slice(o.start,o.end)}),e.slice(o.end)]}):e}function Gi({className:e,style:t}){let{pane:o,intents:n,t:r}=Po("GoTo"),i=H(),a=o.tab!=="goto",l=Sc({enabled:o.open&&!a}),s=ie("insert.bookmark"),c=W(eo),d=At.useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=E=>`${d}-option-${E}`,f=At.useRef(null);At.useEffect(()=>{if(l.activeIndex<0)return;let E=`${d}-option-${l.activeIndex}`;f.current?.querySelector(`[id="${E}"]`)?.scrollIntoView?.({block:"nearest"});},[l.activeIndex,d]);let h=E=>{l.go(E).ok&&(n.picked(),i?.focus());},b=E=>{E.nativeEvent.isComposing||(E.key==="ArrowDown"||E.key==="ArrowUp"?(E.preventDefault(),l.move(E.key==="ArrowDown"?1:-1)):(E.key==="Home"||E.key==="End")&&l.activeIndex>=0?(E.preventDefault(),l.setActiveIndex(E.key==="Home"?0:l.rows.length-1)):E.key==="Enter"?(E.preventDefault(),h()):E.key==="Escape"&&l.query.length>0&&(E.preventDefault(),l.setQuery("")));},v=l.problem==="notFound"?r("navigation.goTo.notFound",{name:l.problemName}):l.problem==="failed"?r("navigation.goTo.failed"):l.problem==="empty"?r("navigation.goTo.typeName"):l.bookmarks.length>0&&l.rows.length===0?r("navigation.goTo.noMatches"):"",y=l.activeIndex>=0?p(l.activeIndex):void 0,T=l.sortBy==="location",x=l.bookmarks.length===0,C=(E,S)=>{let D=S===l.activeIndex;return jsxRuntime.jsxs("li",{id:p(S),role:"option","aria-selected":D,className:_x("docx-nav__goto-row",D&&"docx-nav__goto-row--active"),"data-point":E.empty||void 0,onMouseDown:w=>w.preventDefault(),onClick:()=>h(E.name),children:[jsxRuntime.jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:E.empty?jsxRuntime.jsx(U5,{}):jsxRuntime.jsx(V,{name:"bookmark",size:16})}),jsxRuntime.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsx(z5,{name:E.name,query:l.query})}),E.atSelection&&jsxRuntime.jsx("span",{className:"docx-nav__goto-here",title:r("navigation.goTo.atCaret"),children:jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:r("navigation.goTo.atCaret")})}),!T&&E.place!=="body"&&jsxRuntime.jsx("span",{className:"docx-nav__goto-place",children:r(q5[E.place])})]},E.name)};return jsxRuntime.jsxs("div",{className:_x("docx-nav__panel docx-nav__panel--goto",e),style:t,role:"tabpanel",id:"docx-nav-panel-goto","aria-labelledby":"docx-nav-tab-goto",hidden:a,children:[jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(V,{name:"bookmark",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{type:"text",role:"combobox",className:"docx-nav__search-input",value:l.query,placeholder:r("navigation.goTo.placeholder"),"aria-label":r("navigation.goTo.label"),"aria-describedby":y?g:void 0,"aria-expanded":l.rows.length>0,"aria-controls":l.rows.length>0?m:void 0,"aria-autocomplete":"list","aria-activedescendant":y,autoComplete:"off",spellCheck:false,onChange:E=>l.setQuery(E.target.value),onKeyDown:b}),y&&jsxRuntime.jsx("kbd",{className:"docx-nav__goto-enter","aria-hidden":"true",children:"\u21B5"}),jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r("navigation.goTo.enterHint")})]}),jsxRuntime.jsxs("div",{className:"docx-nav__goto-controls",children:[jsxRuntime.jsx("div",{className:"docx-nav__segmented",role:"radiogroup","aria-label":r("dialogs.bookmark.sortBy"),children:["name","location"].map(E=>jsxRuntime.jsxs("label",{className:"docx-nav__segment","data-checked":l.sortBy===E||void 0,children:[jsxRuntime.jsx("input",{type:"radio",className:"docx-nav__segment-input",name:`${d}-sort`,checked:l.sortBy===E,onChange:()=>l.setSortBy(E)}),r(E==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},E))}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:l.showHidden,onChange:E=>l.setShowHidden(E.target.checked)}),r("dialogs.bookmark.showHidden")]})]}),x&&!c&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-empty",children:[jsxRuntime.jsx(V,{name:"bookmark",size:24,className:"docx-nav__goto-empty-icon"}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-title",children:r("navigation.goTo.empty")}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-hint",children:r("navigation.goTo.emptyHint")}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__goto-add",disabled:!s.isEnabled,title:s.disabledReason??void 0,onClick:()=>s.execute(),children:r("navigation.goTo.add")})]}),!x&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-heading",children:[jsxRuntime.jsx("span",{id:u,children:r("navigation.goTo.listAriaLabel")}),jsxRuntime.jsx("span",{className:"docx-nav__goto-count",children:l.query.trim().length>0?r("navigation.goTo.countFiltered",{shown:l.rows.length,total:l.bookmarks.filter(E=>l.showHidden||!E.hidden).length}):l.rows.length})]}),jsxRuntime.jsx("p",{className:"docx-nav__goto-message",role:"status",children:v}),l.rows.length>0&&jsxRuntime.jsx("ul",{ref:f,id:m,className:"docx-nav__list docx-nav__goto-list",role:"listbox","aria-labelledby":u,children:T?editor.goToBookmarkGroups(l.rows).map(E=>jsxRuntime.jsxs("li",{role:"group","aria-labelledby":`${d}-group-${E.place}`,className:"docx-nav__goto-group",children:[jsxRuntime.jsx("div",{id:`${d}-group-${E.place}`,className:"docx-nav__goto-group-label",children:r(K5[E.place])}),jsxRuntime.jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:E.rows.map(({row:S,index:D})=>C(S,D))})]},E.place)):l.rows.map((E,S)=>C(E,S))})]})}var ba=280,Pc=32,Ix=16;function ha(e=280){return 32+e+16}function kc({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-r))}var Qm=320;function wc(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<Qm}var j5=Object.freeze([]),Y5=e=>e;function Dc(){let e=H(),t=W(Y5),[o,n]=At.useState(null),r=At.useMemo(()=>e&&!t.isLoading?e.getOutline():j5,[e,t]),i=At.useMemo(()=>{if(r.length===0)return [];let l=r[0].level;for(let s of r)s.level<l&&(l=s.level);return r.map(s=>({heading:s,depth:s.level-l}))},[r]),a=At.useCallback(l=>{if(!e||typeof l!="string"||l.length===0)return;e.focus();let s={paragraphId:l,offset:0};e.exec({type:"setSelection",range:{anchor:s,head:s}}),e.scrollToBlock(l),n(l);},[e]);return {headings:r,items:i,selectedBlockId:o,goTo:a,isEmpty:r.length===0}}var Bx=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),e6=()=>()=>{},Lx=()=>Bx;function Rc(e={}){let t=e.highlight??"all",o=H(),n=At.useMemo(()=>o?editor.createDocumentSearch(o):null,[o]),r=At.useSyncExternalStore(n?n.subscribe:e6,n?n.getState:Lx,n?n.getState:Lx);At.useEffect(()=>{if(!(!n||t==="none"))return n.showHighlights(t)},[n,t]);let i=At.useMemo(()=>({setQuery:a=>n?.setQuery(a),find:(a,l)=>n?.find(a,l)??Bx.matches,setMatchCase:a=>n?.setMatchCase(a),setWholeWord:a=>n?.setWholeWord(a),goTo:a=>n?.goTo(a)??false,next:()=>n?.next()??false,previous:()=>n?.previous()??false,clear:()=>n?.clear()}),[n]);return At.useMemo(()=>({...r,...i}),[r,i])}function Ux(e,t=i18n.isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:editor.chordLetter(e)==="f"}var zx=editor.isGoToChord;function $x(e=i18n.isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function Vx(e=i18n.isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function Gx(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function jx(e,t,o){if(e?.isConnected){o&&e.closest(".docx-pages")?o():e.focus({preventScroll:true});return}if(e&&o){o();return}t?t.focus({preventScroll:true}):o?.();}function Yx(e,t,o){if(!editor.isDomNode(e))return false;if(t?.contains(e))return true;if(!o)return false;if(o.contains(e))return true;let n=editor.isElementNode(e)?e:e.parentElement;if(!n)return false;let r=editor.editorInstanceScope(o);if(r&&r!==o&&r.contains(n))return true;if(!n.closest(".docx-editor")||editor.editorInstanceScope(n)!==null)return false;let i=o.ownerDocument.querySelectorAll(".docx-editor__scroll-container");return i.length===1&&i[0]===o}function of(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let n=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(n)return n}return o.querySelector(".docx-nav__search-input")}function nf(e){e.focus(),e.localName==="input"&&e.select();}function a6(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",r=of(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(r){nf(r);return}editor.isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function i6(e,t){let o=[];if(t.contains(e)){let i=e;for(;i!==t&&i.parentElement;){for(let a of i.parentElement.children)a!==i&&o.push(a);i=i.parentElement;}}else o.push(...t.children);let n=e.ownerDocument.activeElement;n&&o.some(i=>i.contains(n))&&a6(e);let r=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),r.push(i));return ()=>{for(let i of r)i.removeAttribute("inert");r.length=0;}}function Xx(e,t,o){let n=i6(e,t),r=i=>{editor.isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function qx(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Jx(e,t){let o=()=>{let i=editor.hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-qx(i.paddingTop)-qx(i.paddingBottom);e.style.setProperty("--docx-nav-block-size",`${Math.max(0,Math.round(a))}px`),e.style.setProperty("--docx-nav-inline-size",`${Math.round(t.clientWidth)}px`);};o();let n=editor.hostWindowOf(t).ResizeObserver;if(typeof n>"u")return ()=>{};let r=new n(o);return r.observe(t),()=>r.disconnect()}function eC(e,t=true,o=true){let n=H(),r=ke(),i=At.useRef(null),a=At.useRef(null),l=At.useRef(false),s=At.useRef(false),c=At.useRef(false),d=At.useRef(0),m=At.useCallback(()=>{let C=++d.current;editor.hostWindowOf(i.current).setTimeout(()=>{d.current===C&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=At.useRef(e);u.current=e;let g=At.useCallback(()=>{l.current=false;let C=of(i.current,u.current.tab);C&&nf(C);},[]),p=At.useCallback(()=>{s.current=false;let C=a.current;a.current=null;let E=i.current?.querySelector(".docx-nav__toggle")??null;jx(C,E,n?()=>n.focus():null);},[n]),f=At.useRef(p);f.current=p,At.useEffect(()=>()=>{s.current&&f.current();},[]);let h=At.useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),b=At.useCallback((C,E)=>{E&&!i.current?.contains(E)&&(a.current=E),s.current=false;let S=u.current;if(S.open&&S.tab===C){g();return}l.current=true,S.tab!==C&&S.setTab(C),S.open||S.setOpen(true),m();},[g,m]),v=At.useMemo(()=>({openTab:C=>{let E=i.current?.ownerDocument.activeElement;b(C,editor.isHTMLElementNode(E)?E:null);},toggle:()=>{if(u.current.open){h();return}a.current=null,s.current=false,l.current=true,u.current.setOpen(true),m();},close:h,picked:()=>{let C=u.current;if(!C.overlay)return;let E=i.current?.ownerDocument.activeElement;c.current=!!E&&!!i.current?.contains(E),C.setOpen(false),m();}}),[h,m,b]),y=At.useRef(v);y.current=v,At.useEffect(()=>{let C=i.current?.ownerDocument;if(!C||!t&&!o)return;let E=S=>{if(S.defaultPrevented)return;let D=t&&Ux(S)?"find":o&&zx(S)?"goto":null;if(!D||!Yx(S.target,i.current,r))return;if(D==="goto"&&n?.can({type:"openGoTo"}).ok){n.exec({type:"openGoTo",fromShortcut:true}).ok&&S.preventDefault();return}S.preventDefault();let w=C.activeElement;b(D,editor.isHTMLElementNode(w)?w:null);};return C.addEventListener("keydown",E),()=>C.removeEventListener("keydown",E)},[r,t,o,b,n]),At.useEffect(()=>{l.current&&(u.current.open?g():l.current=false),s.current&&(u.current.open?s.current=false:p()),c.current&&(c.current=false,u.current.open||n?.focus());});let T=e.open&&e.overlay;At.useEffect(()=>{let C=i.current;if(!(!T||!C||!r))return Xx(C,r,()=>y.current.close())},[T,r]),At.useEffect(()=>{let C=i.current;if(!(!C||!r||!r.contains(C)))return Jx(C,r)},[r]);let x=At.useCallback(C=>{C.key!=="Escape"||C.defaultPrevented||C.nativeEvent.isComposing||u.current.open&&(C.preventDefault(),h());},[h]);return {rootRef:i,intents:v,onKeyDown:x}}var d6=150;function u6(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function p6(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function tC(e,t,o=()=>null){let n=editor.hostTimers(o),r=null,i=false,a=()=>{r=null,i||t(p6(e.getPageGeometry()));},l=()=>{i||(n.clearTimeout(r),r=n.setTimeout(a,d6));},s=e.on("change",c=>{u6(c)&&l();});return a(),{nudge:l,dispose(){i=true,n.clearTimeout(r),r=null,s();}}}var h6=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??editor.ZOOM_MAX)&&e.zoom>(t.minZoom??editor.ZOOM_MIN)}},y6=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,v6=e=>e.page.total;function Mc(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=At.useState(t),[a,l]=At.useState(o),s=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:m}=e,u=e.open!==void 0,g=e.tab!==void 0,p=At.useCallback(B=>{u||i(B),d?.(B);},[u,d]),f=At.useCallback(()=>p(!s),[s,p]),h=At.useCallback(B=>{g||l(B),m?.(B);},[g,m]),b=Mn(),v=ke(),y=At.useContext(_t),{pageSetup:T,zoom:x,reviewPaneOpen:C,fitting:E}=W(h6,y6),S=H(),D=W(v6),[w,k]=At.useState(0),[F,I]=At.useState(null),[N,A]=At.useState(0),[P,M]=At.useState(0),$=pn();At.useEffect(()=>{if(!v){k(0),A(0),M(0);return}let B=()=>{k(v.clientWidth);let ae=editor.hostWindowOf(v).getComputedStyle(v),se=Number.parseFloat(ae.paddingInlineEnd);A(Number.isFinite(se)?se:0);let he=Number.parseFloat(ae.getPropertyValue("--docx-review-gutter-start"));M(Number.isFinite(he)?he:0);};B();let _=editor.hostWindowOf(v).ResizeObserver;if(typeof _>"u")return;let O=new _(B);return O.observe(v),()=>O.disconnect()},[v,s,C,y?.mounted,y?.gutters,$]);let U=At.useRef(null);T&&(U.current=T.pageWidthTwips);let oe=T?.pageWidthTwips??U.current,Y=At.useRef(null);At.useEffect(()=>{if(!s||!S)return;let B=tC(S,I,()=>v);return Y.current=B,()=>{B.dispose(),Y.current===B&&(Y.current=null);}},[s,S,v]),At.useEffect(()=>Y.current?.nudge(),[D,oe]);let ne=ha(n),K=E0($,N),X=s&&wc(w-K,ne),le=At.useMemo(()=>!s||X||oe===null?0:kc({viewportWidth:w,pageWidthPx:Math.max(F??0,We(oe))*x,reservation:ne,inlineEndReservation:N,inlineStartReservation:P,docked:E}),[s,X,oe,F,x,w,ne,N,P,E]);return At.useEffect(()=>{if(b)return b.setShift(le),()=>b.setShift(0)},[b,le]),At.useEffect(()=>{if(b)return b.setReservation(s&&!X?ne:0),()=>b.setReservation(0)},[b,s,X,ne]),{open:s,setOpen:p,toggle:f,tab:c,setTab:h,paneWidth:n,shift:le,overlay:X}}var Xi=["headings","find","goto"],Do=(...e)=>e.filter(Boolean).join(" ");function Ji({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:Do("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qi,{}),jsxRuntime.jsx(el,{})]})})}function Qi({className:e,style:t,children:o}){let{intents:n,t:r}=Po("Close");return jsxRuntime.jsx("button",{type:"button",className:Do("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:n.close,children:o??jsxRuntime.jsx(V,{name:"arrow_back",size:20})})}function el({className:e,style:t,children:o}){let{t:n}=Po("Title");return jsxRuntime.jsx("h2",{className:Do("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function tl({className:e,style:t,children:o}){let{pane:n,t:r}=Po("Tabs"),i=At.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=Xi.indexOf(n.tab);n.setTab(Xi[(s+l+Xi.length)%Xi.length]);},[n]);return jsxRuntime.jsx("div",{className:Do("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??Xi.map(a=>jsxRuntime.jsx(ol,{value:a},a))})}function ol({value:e,className:t,style:o,children:n}){let{pane:r,t:i,goToShortcut:a}=Po("Tab"),l=Ho(),s=r.tab===e,c=e==="goto"&&a?i("navigation.goTo.tabTitle",{shortcut:l($x())}):void 0;return jsxRuntime.jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":s,"aria-controls":`docx-nav-panel-${e}`,tabIndex:s?0:-1,className:Do("docx-nav__tab",s&&"docx-nav__tab--selected",t),style:o,...c?{title:c,"aria-keyshortcuts":Vx()}:{},onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function rC({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:l}){let s=At.useRef(null);return At.useEffect(()=>{a&&s.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(V,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:s,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:c=>t(c.target.value),onKeyDown:c=>{!l||c.key!=="Enter"||c.nativeEvent.isComposing||(c.preventDefault(),l(c.shiftKey));}}),e.length>0&&jsxRuntime.jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsxRuntime.jsx(V,{name:"close",size:16})})]})}function nl({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=Po("Headings"),[a,l]=At.useState(""),s=W(eo),c=At.useMemo(()=>{let m=a.trim().toLowerCase();return m.length===0?n.items:n.items.filter(u=>u.heading.text.toLowerCase().includes(m))},[n.items,a]),d=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:Do("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsxRuntime.jsx(rC,{value:a,onChange:l,onClear:()=>l(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),s?null:n.isEmpty?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.headings.noHeadings")}):c.length===0?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.find.noResults")}):jsxRuntime.jsx("ul",{className:"docx-nav__list",children:c.map((m,u)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Do("docx-nav__heading",n.selectedBlockId===m.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+m.depth*14}px`},title:m.heading.text,onClick:()=>{n.goTo(m.heading.blockId),r.picked();},children:m.heading.text})},`${m.heading.blockId}-${u}`))})]})}function P6({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Do("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsxRuntime.jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function rl({className:e,style:t}){let{pane:o,search:n,intents:r,t:i}=Po("Find"),a=o.tab!=="find",l=n.query.trim().length>0,s=o.open&&!a,c=n.matches.length===0?null:n.activeIndex<0?i(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):i(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxRuntime.jsxs("div",{className:Do("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsxRuntime.jsx(rC,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:s,onEnter:d=>{n.isPending&&n.find(n.query),d?n.previous():n.next();}}),jsxRuntime.jsxs("div",{className:"docx-nav__options",role:"group","aria-label":i("navigation.find.optionsAriaLabel"),children:[jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.matchCase,onChange:d=>n.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:d=>n.setWholeWord(d.target.checked)}),i("navigation.find.wholeWord")]})]}),jsxRuntime.jsxs("div",{className:"docx-nav__resultbar",children:[jsxRuntime.jsx("span",{className:"docx-nav__count","aria-live":"polite",children:l?n.isPending?i("navigation.find.searching"):c??i("navigation.find.noResults"):""}),jsxRuntime.jsxs("span",{className:"docx-nav__steppers",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsxRuntime.jsx(V,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsxRuntime.jsx(V,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:n.matches.map((d,m)=>jsxRuntime.jsx(P6,{match:d,active:m===n.activeIndex,onSelect:()=>{n.goTo(m),r.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function al({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=Po("Toggle"),s=Ho()("Ctrl+F"),c=i?Gx(s):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:s}):a("navigation.openTitle");return jsxRuntime.jsx("button",{type:"button",className:Do("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":n.open,"aria-keyshortcuts":c,title:d,onMouseDown:m=>m.preventDefault(),onClick:r.toggle,children:o??jsxRuntime.jsx(V,{name:"toc",size:20})})}function af(e){let t=Nt(),{t:o,toggle:n=true,searchHighlight:r="all",findShortcut:i=true,goToShortcut:a=true,className:l,style:s,children:c,...d}=e,m=Mc(d),u=Dc(),g=m.open&&m.tab==="find"?r:"none",p=Rc({highlight:g}),f=Qe(),h=At.useMemo(()=>o??((E,S)=>f(E,S)),[o,f]),b=eC(m,i,a),v=At.useMemo(()=>({pane:m,outline:u,search:p,t:h,intents:b.intents,findShortcut:i,goToShortcut:a}),[m,u,p,h,b.intents,i,a]),y=H(),T=At.useRef(b.intents);T.current=b.intents;let x=At.useRef(a);x.current=a,At.useEffect(()=>{if(y)return y.setGoToChrome({onRequest:()=>T.current.openTab("goto"),get shortcut(){return x.current}})},[y]);let C=e.paneWidth??280;return jsxRuntime.jsx(Jm.Provider,{value:v,children:jsxRuntime.jsxs("div",{ref:b.rootRef,className:`${t}docx-nav${m.open?" docx-nav--open":""}${m.overlay?" docx-nav--overlay":""}${l?` ${l}`:""}`,"data-open":m.open?"true":"false",onKeyDown:b.onKeyDown,style:{"--docx-nav-width":`${C}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${ha(C)}px`,...s},children:[n!==false&&!m.open&&jsxRuntime.jsx(al,{...typeof n=="object"?n:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":v.t("navigation.ariaLabel"),inert:!m.open,children:c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ji,{}),jsxRuntime.jsx(tl,{}),jsxRuntime.jsx(nl,{}),jsxRuntime.jsx(rl,{}),jsxRuntime.jsx(Gi,{})]})})]})})}var _c=Object.assign(af,{Header:Ji,Close:Qi,Title:el,Tabs:tl,Tab:ol,Headings:nl,Find:rl,GoTo:Gi,Toggle:al});var L6=600,F6=e=>e.isOpening===true?0:e.page.total,Ic=At.createContext(null);function Nc({className:e,style:t}){let o=Nt(),n=H(),r=ke(),{inside:i,host:a,hostScoped:l}=w0(r),s=W(F6),{t:c}=L(),d=At.useContext(Ic),[m,u]=At.useState(1),[g,p]=At.useState(false);if(At.useEffect(()=>{if(p(false),!n||!r||s<=1)return;u(n.getCurrentPage("viewport"));let v=editor.hostWindowOf(r),y=null,T=()=>{u(n.getCurrentPage("viewport")),p(true),y!==null&&v.clearTimeout(y),y=v.setTimeout(()=>p(false),L6);};return r.addEventListener("scroll",T,{passive:true}),()=>{r.removeEventListener("scroll",T),y!==null&&v.clearTimeout(y);}},[n,s,r]),s<=1)return null;let f=a?l?"":"docx-editor ":o,h=d?d("viewer.pageIndicator").replace(/\{current\}/g,String(m)).replace(/\{total\}/g,String(s)):c("viewer.pageIndicator",{current:m,total:s}),b=jsxRuntime.jsx("div",{className:`${f}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":g?"true":"false",role:"status","aria-live":"polite",children:h});return i?a?reactDom.createPortal(b,a):null:b}var O6=[],B6=e=>e.fontSubstitutions??O6;function Lc({className:e,style:t,t:o}){let n=W(B6),{t:r}=L(),i=o??r,[a,l]=At.useState(null);if(n.length===0)return null;let s=n.join("\0");return a===s?null:jsxRuntime.jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsxRuntime.jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:n.join(", ")}).replace("{fonts}",n.join(", "))}),jsxRuntime.jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(s),children:i("common.dismiss")})]})}var j6={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function Y6(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var X6=e=>e.openFailure??null;function uC(e={}){let t=W(X6),{t:o}=L(),n=e.t??o,[r,i]=At.useState(null),a=t!==null&&t!==r?t:null,l=At.useCallback(s=>{Y6(s,t)||i(t);},[t]);return {failure:a,message:a?n(j6[a.reason]):null,dismiss:l}}var pC=At.createContext(null);function sf({variant:e="secondary",dismiss:t=false,asChild:o=false,className:n,onClick:r,children:i,type:a,...l}){let s=At.useContext(pC),c=`docx-dialog__button${e==="primary"?" docx-dialog__button--primary":""}${n?` ${n}`:""}`,d=m=>{r?.(m),t&&!m.defaultPrevented&&s?.dismiss();};return o?jsxRuntime.jsx(j,{...l,className:c,onClick:d,children:i}):jsxRuntime.jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var dC=new Set;function mC(e,t){if(!t||!gt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||dC.has(o)||(dC.add(o),console.warn(o==="both"?"[docx-editor] renderOpenFailureActions replaces openFailure.actions. Pass only one.":"[docx-editor] renderOpenFailureActions is ignored with openFailure={false}, which renders no dialog."));}function fC(e){return At.Children.toArray(e).some(t=>At.isValidElement(t)&&t.type===At.Fragment?fC(t.props.children):true)}function J6({title:e,message:t,showCode:o=true,actions:n,closeLabel:r,showClose:i=true,onDismiss:a,children:l,className:s,style:c,t:d}){let{t:m}=L(),u=d??m,{failure:g,message:p,dismiss:f}=uC({t:u}),h=At.useId();if(!g||p===null)return null;let b=()=>{f(g),a?.(g);},v={failure:g,message:p,dismiss:b},y=e??u("openFailure.title"),T=typeof t=="function"?t(g):t??p,x=n?.(v),C=fC(x);return jsxRuntime.jsx(pC.Provider,{value:v,children:jsxRuntime.jsx(Be,{kind:"openFailure",role:"alertdialog",label:y,className:s,style:c,onClose:b,dismissOutside:false,...l?{}:{describedBy:h},children:l?l(v):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:y})}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{id:h,className:"docx-dialog__message",children:T}),o?jsxRuntime.jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),C||i?jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[x,i?jsxRuntime.jsx(sf,{variant:C?"secondary":"primary",dismiss:true,children:r??u("common.close")}):null]}):null]})})})}var Fc=Object.assign(J6,{Action:sf});function cf(e){return Math.round(e/1440*100)/100}function gC(e){return Math.round(e*1440)}function tL(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 df(){let e=H(),t=At.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return W(t,tL)}function aL(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 iL=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function il(e){let t=H();return At.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function lL(e){let{state:t,onMouseDown:o}=e,{t:n}=L(),r=H(),[i,a]=At.useState(false),l=At.useRef(null),[s,c]=At.useState(""),[d,m]=At.useState("");At.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(cf(t.headerDistanceTwips))),m(String(cf(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),At.useEffect(()=>{if(!i)return;let E=D=>{l.current?.contains(D.target)||a(false);},S=editor.hostDocumentOf(l.current);return S.addEventListener("mousedown",E),()=>S.removeEventListener("mousedown",E)},[i]);let u=At.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=At.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=At.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=At.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=At.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),b=il(u),v=il(g),y=il(p),T=il(f),x=il(h),C=(E,S)=>{if(!r)return;let D=Number.parseFloat(S);Number.isFinite(D)&&r.exec({type:"setHeaderFooterOptions",[E]:gC(D)});};return jsxRuntime.jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:o,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":i,"aria-haspopup":"menu",onClick:()=>a(E=>!E),onMouseDown:o,children:n("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[iL.map(E=>{let S={type:"insertPageField",field:E.field},D=r?.can(S);return jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!D?.ok,title:D&&!D.ok?D.reason:void 0,onClick:()=>{r?.exec(S),a(false);},onMouseDown:o,children:n(E.labelKey)},E.field)}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!b.enabled,title:b.reason??void 0,onChange:()=>r?.exec(u)}),jsxRuntime.jsx("span",{children:n("headerFooter.differentFirstPage")})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!v.enabled,title:v.reason??void 0,onChange:()=>r?.exec(g)}),jsxRuntime.jsxs("span",{children:[n("headerFooter.differentOddEven"),jsxRuntime.jsx("span",{className:"docx-hf-chrome__menu-hint",children:n("headerFooter.differentOddEvenHint")})]})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!T.enabled,title:T.reason??void 0,onClick:()=>r?.exec(f),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!y.enabled,title:y.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:o,children:n("headerFooter.linkToPrevious")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.headerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.headerDistance"),value:s,onChange:E=>c(E.target.value),onBlur:()=>C("headerDistanceTwips",s)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.footerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.footerDistance"),value:d,onChange:E=>m(E.target.value),onBlur:()=>C("footerDistanceTwips",d)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!x.enabled,title:x.reason??void 0,onClick:()=>r?.exec(h),onMouseDown:o,children:t.editing==="header"?n("headerFooter.removeHeader"):n("headerFooter.removeFooter")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.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:o,children:n("common.close")})]}):null]})}function Hc({className:e}){let{t}=L(),o=df(),n=At.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=ni(n,"story-label"),i=q;if(!o?.editing)return null;let a=aL(o.editing,o.variant);return jsxRuntime.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:vt.hfInlineEditor},children:[jsxRuntime.jsxs("div",{className:"docx-context-bar__label",children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsxRuntime.jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsxRuntime.jsx(lL,{state:o,onMouseDown:i})]})}var uL={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},pL={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},mL={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},fL={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},gL={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},bL={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:"var(--doc-z-overlay)",backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},hL={padding:"8px 12px"},yL={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},vL={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},xL={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function CL({forwardedRef:e}){let t=H(),o=At.useRef(null);return o.current=t,R0({ref:e,editorRef:o}),null}function TL(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var EL=At.forwardRef(function(t,o){let{document:n,fonts:r,fontShaping:i,imageDecodePort:a,className:l,t:s,chrome:c=true,title:d,onTitleChange:m,renderTitleBarLeft:u,renderTitleBarRight:g,renderOpenFailureActions:p,loadingIndicator:f,colorMode:h="light",author:b,locale:v,mode:y="edit",modules:T,zoom:x,zoomMode:C,revisionMarkup:E,onRevisionMarkupChange:S,reviewDisplayMode:D,fieldResults:w,contentLockPolicy:k,lockedControlNavigation:F,onReady:I,onChange:N,onFontError:A,onOpen:P,onSave:M,hyperlinkPopup:$,contextMenu:U=true,menu:oe=true,navigation:Y=true,openFailure:ne=true,rulers:K=true}=t;!c&&f!==void 0&&a0(),mC(ne,p!==void 0);let[X,le]=At.useState(Uh);At.useEffect(()=>{if(h==="system")return $h(le)},[h]);let B=zh(h,X),{t:_}=L(),O=At.useCallback((Me,je)=>s?s(Me,je):_(Me,je),[s,_]),ae=jsxRuntime.jsxs(_s,{className:c?B?"dark":void 0:l,style:c?pL:void 0,children:[c?jsxRuntime.jsx(Hc,{}):null,c?jsxRuntime.jsx(ds,{}):null,jsxRuntime.jsx(ks,{}),K&&c?jsxRuntime.jsx("div",{style:gL,children:jsxRuntime.jsx(Ec,{})}):null,t.children]}),se=c?jsxRuntime.jsxs("div",{className:`docx-editor${B?" dark":""}${l?` ${l}`:""}`,style:uL,children:[jsxRuntime.jsxs("div",{style:bL,children:[jsxRuntime.jsxs("div",{style:yL,children:[u?.(),jsxRuntime.jsxs("div",{style:vL,children:[m?jsxRuntime.jsx("input",{"aria-label":O("titleBar.documentNameAriaLabel"),value:d??"",placeholder:O("titleBar.untitled"),onChange:Me=>m(Me.target.value),style:xL}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??O("titleBar.untitled")}),oe!==false?jsxRuntime.jsx(qi,{t:O,...d!==void 0?{fileName:d}:{},...P?{onOpen:P}:{},...M?{onSave:M}:{},...typeof oe=="object"?oe:{}}):null]}),g?.()]}),jsxRuntime.jsx("div",{style:hL,children:jsxRuntime.jsx(Oi,{t:O})})]}),K?jsxRuntime.jsx("div",{style:fL,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(Tc,{})}):null,jsxRuntime.jsx(Lc,{t:O}),jsxRuntime.jsxs("div",{style:mL,children:[Y===false?null:jsxRuntime.jsx(_c,{t:O,...typeof Y=="object"?Y:{}}),ae,jsxRuntime.jsx(Ic.Provider,{value:O,children:jsxRuntime.jsx(Nc,{})}),jsxRuntime.jsx(Ds,{overlay:true,indicator:f})]})]}):ae,he=At.useCallback(Me=>O(Me),[O]);return jsxRuntime.jsxs(mi,{popups:Eh(t.popups,$,U,O),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...b!==void 0?{author:b}:{},...v!==void 0?{locale:v}:{},translate:O,mode:y,...T!==void 0?{modules:T}:{},...x!==void 0?{zoom:x}:{},revisionMarkup:E,onRevisionMarkupChange:S,reviewDisplayMode:D,...w!==void 0?{fieldResults:w}:{},...k!==void 0?{contentLockPolicy:k}:{},...F!==void 0?{lockedControlNavigation:F}:{},...C!==void 0?{zoomMode:C}:{},tableInteractionLabel:he,...I?{onReady:I}:{},...N?{onChange:N}:{},...A?{onFontError:A}:{},children:[jsxRuntime.jsx(CL,{forwardedRef:o}),jsxRuntime.jsx(zn.Provider,{value:c,children:se}),ne===false?null:jsxRuntime.jsx(Fc,{t:O,...typeof ne=="object"?ne:{},...p?{actions:p}:{},className:TL(B?"dark":void 0,typeof ne=="object"?ne.className:void 0)})]})}),SL=At.forwardRef(function(t,o){return jsxRuntime.jsx(fr,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(EL,{...t,ref:o})})}),PL=Object.assign(SL,{Root:mi,Viewport:_s,Content:ks,Window:Lp,Toolbar:Oi,Menu:qi,Loading:Ds,ColorByChangeType:Ap,RevisionMarkup:_d,RevisionMarkupDialog:Pa,UnsupportedElement:ld,AuthorStyle:Op,HorizontalRuler:Tc,VerticalRuler:Ec,DocumentOutline:Xm,Navigation:_c,ExportDialog:ka,PrintDialog:wa,PageSetupDialog:Zn,WatermarkDialog:qn,BookmarkDialog:$a,SplitCellDialog:Va,ParagraphDialog:Zo,TextFormFieldDialog:ja,PageNumber:Nc,FontNotice:Lc,OpenFailure:Fc,HeaderFooterChrome:Hc,NotesChrome:ds,Equation:Fa,HyperLink:_a,ContextMenu:zu,ContentControlWidget:wp,InvalidTextFormFieldDialog:ap,ImageAltTextPopup:hs,ImagePropertiesDialog:ai,NotePropertiesDialog:us,NotePreview:hr,NotesContextMenu:yr,ContentControl:La});function ML(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function pf(e){return Array.isArray(e)?e:[e]}function _L(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function xC(e){return e!==void 0&&pf(e).some(t=>editor.isFontResolver(t))}async function IL(e){return typeof e!="function"?await e:await e()}function NL(e,t={}){let[o,n]=At.useState(void 0),[r,i]=At.useState(void 0),[a,l]=At.useState(null),[s,c]=At.useState(e!=null),d=xC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=At.useState(t.fonts===void 0),p=At.useRef(t);p.current=t;let f=At.useMemo(()=>editor.defineFontResolver(h=>editor.composeFontOrigins(pf(p.current.fonts??[]).map(_L),h)),[]);return At.useEffect(()=>{let h=p.current.fonts;if(h===void 0){i(void 0),g(true);return}if(xC(h)){g(true);return}g(false);let b=true;return (async()=>{try{let v=await Promise.allSettled(pf(h).map(IL)),y=[];for(let T of v){if(T.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",T.reason);continue}T.value!==void 0&&y.push(T.value);}b&&y.length>0&&i(editor.composeFontConfiguration(y[0],...y.slice(1)));}catch(v){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",v);}finally{b&&g(true);}})(),()=>{b=false;}},[m]),At.useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let h=ML(e);if(h){n(h),l(null),c(false);return}let b=true,v=new AbortController;return c(true),l(null),(async()=>{try{let y=await fetch(String(e),{...p.current.fetchOptions,signal:v.signal});if(!y.ok)throw new Error(`could not open the document: ${y.status} ${y.statusText}`);let T=new Uint8Array(await y.arrayBuffer());if(!b)return;n(T),c(!1);}catch(y){if(!b||y instanceof Error&&y.name==="AbortError")return;l(y instanceof Error?y:new Error("could not open the document")),c(false);}})(),()=>{b=false,v.abort();}},[e]),{document:u?o:void 0,fonts:d?f:r,error:a,isLoading:s||!u}}function OL(...e){let t=At.useRef(e);return t.current=e,At.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function ZL(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function qL(){let e=H(),t=At.useRef(null),o=At.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=At.useCallback(()=>{let r=ZL(e),i=t.current;return (r===null?i===null:i!==null&&KL(i,r))?i:(t.current=r,r)},[e]);return At.useSyncExternalStore(o,n,()=>null)}function KL(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function $L(e){let t=H(),o=At.useRef(e);o.current=e;let n=typeof e=="function";At.useEffect(()=>{if(!(!t||!n))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,n]);}var PC=Object.freeze({applied:0,unavailable:0});function kC(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:n,className:r,priority:i}=e;return JSON.stringify([t,o,n,r,i])}function YL(e,t,o){let n=H(),[r,i]=At.useState(PC),a=At.useRef(null),l=At.useRef(o);l.current=o;let s=At.useRef(t);s.current=t;let c=kC(o);return At.useEffect(()=>{if(!n){i(PC);return}let d=editor.watchHighlights(n,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:kC(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),At.useEffect(()=>{let d=a.current;!d||d.source===t&&d.key===c||(d.source=t,d.key=c,d.watch.update(t,l.current??{}));},[t,c]),r}function oF(e,t){return e===t?true:!e||!t?false:e.name===t.name&&e.index===t.index&&e.range===t.range&&e.active===t.active&&e.rect.left===t.rect.left&&e.rect.top===t.rect.top&&e.rect.width===t.rect.width&&e.rect.height===t.rect.height}function nF(e){let t=H(),o=ke(),[n,r]=At.useState(null);return At.useEffect(()=>{if(!t){r(null);return}let i=editor.hostDocumentOf(o),a=editor.hostWindowOf(o),l=0,s=null,c=()=>{l=0;let p=s?t.getHighlightsAt(s.x,s.y).find(f=>e===void 0||f.name===e)??null:null;r(f=>oF(f,p)?f:p);},d=()=>{l===0&&(l=a.requestAnimationFrame(c));},m=p=>{let f=p.target;s=editor.isElementNode(f)&&f.closest("[data-page-index]")!==null?{x:p.clientX,y:p.clientY}:null,d();},u=p=>{p.relatedTarget||(s=null,d());};i.addEventListener("pointermove",m,{passive:true}),i.addEventListener("pointerout",u,{passive:true}),i.addEventListener("scroll",d,{passive:true,capture:true});let g=t.on("change",d);return ()=>{i.removeEventListener("pointermove",m),i.removeEventListener("pointerout",u),i.removeEventListener("scroll",d,{capture:true}),g(),l!==0&&a.cancelAnimationFrame(l);}},[t,e,o]),n}function ff({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=At.useRef(null),c=At.useRef(null),[d,m]=At.useState(null),u=At.useRef(n);u.current=n;let g=At.useRef(r);return g.current=r,At.useEffect(()=>{let p=s.current;if(!p)return;let f=editor.mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:b=>{m(b),u.current?.(b);}});if(!f.ok){g.current?.(f.reason,f.detail);return}c.current=f.surface;let h=f.surface.state();return m(h),u.current?.(h),()=>{f.surface.destroy(),c.current=null;}},[e,o]),At.useImperativeHandle(l,()=>({focus:()=>c.current?.focus(),type:p=>c.current?.type(p),undo:()=>c.current?.undo(),redo:()=>c.current?.redo(),selectAll:()=>c.current?.selectAll(),navigate:(p,f)=>c.current?.navigate(p,f),toggleRunProperty:(p,f)=>c.current?.toggleRunProperty(p,f),setRunProperty:(p,f)=>c.current?.setRunProperty(p,f),setParagraphProperty:(p,f,h)=>c.current?.setParagraphProperty(p,f,h),formatting:()=>c.current?.formatting()??null,sectionProperties:()=>c.current?.sectionProperties()??null,save:()=>c.current?.save()??null}),[]),jsxRuntime.jsx("div",{ref:s,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 sl=At.createContext(null);function wC(){let e=At.useContext(sl);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function fF(e){return "type"in e&&e.type==="separator"}var MC={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"},gF={...MC,background:"var(--doc-bg-hover)"},_C={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"},bF={..._C,opacity:.4,cursor:"default"},hF={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},yF={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},vF={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 cl({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=At.useState(false),[a,l]=At.useState(null),s=At.useRef(null),c=At.useRef(null),[d,m]=At.useState({top:0,left:0}),u=At.useCallback(()=>{i(false),l(null);},[]);At.useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[r]),At.useEffect(()=>{if(!r)return;function p(y){let T=y.target;s.current&&!s.current.contains(T)&&c.current&&!c.current.contains(T)&&u();}function f(y){y.key==="Escape"&&u();}function h(){u();}let b=editor.hostDocumentOf(s.current),v=editor.hostWindowOf(s.current);return b.addEventListener("mousedown",p),b.addEventListener("keydown",f),v.addEventListener("scroll",h,true),()=>{b.removeEventListener("mousedown",p),b.removeEventListener("keydown",f),v.removeEventListener("scroll",h,true);}},[r,u]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),u());};return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!r),onMouseDown:p=>p.preventDefault(),disabled:o,style:r?gF:MC,children:[e,n&&jsxRuntime.jsx(V,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:c,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:p=>p.preventDefault(),children:t.map((p,f)=>{if(fF(p))return jsxRuntime.jsx("div",{style:hF},`sep-${f}`);let h=p;if(h.customContent)return jsxRuntime.jsx("div",{onMouseDown:y=>y.preventDefault(),children:h.customContent},h.label);let b=!!h.submenuContent,v=a===h.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>b&&l(h.label),onMouseLeave:()=>b&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:h.disabled?bF:_C,onClick:()=>g(h),onMouseDown:y=>y.preventDefault(),onMouseOver:y=>{h.disabled||(y.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:y=>{y.currentTarget.style.backgroundColor="transparent";},disabled:h.disabled,children:[h.icon&&jsxRuntime.jsx(V,{name:h.icon,size:18}),jsxRuntime.jsx("span",{children:h.label}),h.shortcut&&jsxRuntime.jsx("span",{style:yF,children:h.shortcut}),b&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx(V,{name:"keyboard_arrow_right",size:16})})]}),b&&v&&jsxRuntime.jsx("div",{style:vF,onMouseDown:y=>y.preventDefault(),children:h.submenuContent(u)})]},h.label)})})]})}var hf=18,CF=2,NC={width:hf,height:hf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},TF={...NC,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},EF={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function LC({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=At.useState(0),[i,a]=At.useState(0),l=At.useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),s=[];for(let d=1;d<=t;d++)for(let m=1;m<=o;m++){let u=d<=n&&m<=i;s.push(jsxRuntime.jsx("div",{style:u?TF:NC,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${m}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:CF,gridTemplateColumns:`repeat(${o}, ${hf}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:EF,children:c})]})}function DF({items:e,closeMenu:t}){return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let n=!o.onClick;return jsxRuntime.jsxs("button",{type:"button",disabled:n,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:n?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:n?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{n||(o.onClick?.(),t());},onMouseOver:r=>{n||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsxRuntime.jsx(V,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function RF(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Bc({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function MF(e){return e.replace(/\.docx$/i,"")}function vf({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=L(),i=o??r("titleBar.untitled"),a=MF(e)??"";return n?jsxRuntime.jsx("input",{type:"text",value:a,onChange:l=>{let s=l.target.value;t?.(s.endsWith(".docx")?s:s+".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")}):jsxRuntime.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 Wc({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Zc(){let{t:e}=L(),t=wC(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:f,onWatermark:h,onRefocusEditor:b}=t,v=At.useCallback(C=>{!o&&n&&n(C);},[o,n]),y=At.useCallback((C,E)=>{!o&&c&&(c(C,E),editor.hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>b?.()));},[o,c,b,t.editorRef]),T=!!r||!!l,x=T||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[x&&jsxRuntime.jsx(cl,{label:e("toolbar.file"),disabled:o,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)&&T?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsxRuntime.jsx(cl,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>v("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>v("setRtl")}]}),jsxRuntime.jsx(cl,{label:e("toolbar.insert"),disabled:o,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:C=>jsxRuntime.jsx(LC,{onInsert:(E,S)=>{y(E,S),C();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:C=>jsxRuntime.jsx(DF,{closeMenu:C,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...h?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:h}]:[]]}),m&&jsxRuntime.jsx(cl,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>Wi()}]})]})}function xf({children:e}){let t=null,o=null,n=[],r=[];At.Children.forEach(e,a=>{At.isValidElement(a)&&(a.type===Bc?t=a:a.type===Wc?o=a:a.type===Zc?r.push(a):n.push(a));});let i=At.useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(RF,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[n.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:n}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),o&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var qc={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},LF={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:""},FC={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 FF(e,t){let o=FC[t]??FC[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:qc[o]??"000000"}function HC(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(o=>o+o).join("")}function Cf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${HC(e.value)??o}`;let n=Object.entries(t?.colorScheme??qc).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:FF(t,e.slot)}`}function Vo(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?HC(e.value):Cf(e,t).slice(1)}function AC(e){if(!e||e==="none")return "";let t=LF[e];return t?`#${t}`:""}var HF=[{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"}],AF=[{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 OC(e){let t=e??qc;return AF.map(o=>HF.map(n=>{let r=t[n.slot]??qc[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?editor.applyThemeTint(r,o.keep):editor.applyThemeShade(r,o.keep),themeSlot:n.slot,label:`${n.name}${o.labelSuffix}`};return o.type==="tint"?a.tint=o.keep:o.type==="shade"&&(a.shade=o.keep),a}))}function pe(...e){return clsx.clsx(e)}var WF=classVarianceAuthority.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"}}),nt=At__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:pe(WF({variant:t,size:o,className:e})),ref:r,...n}));nt.displayName="Button";function Kt({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=At__namespace.useState(false),[a,l]=At__namespace.useState({x:0,y:0}),s=At__namespace.useRef(null),c=At__namespace.useRef(null),d=At__namespace.useCallback(()=>{let p=editor.hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let h=s.current.getBoundingClientRect(),b=h.left+h.width/2,v=o==="top"?h.top-8:h.bottom+8;l({x:b,y:v});}i(true);},n);c.current={win:p,handle:f};},[n,o]),m=At__namespace.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);At__namespace.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=At__namespace.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{m(),u.onMouseLeave?.(p);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g,r&&jsxRuntime.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:o==="top"?"translate(-50%, -100%)":o==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var Tf=At__namespace.createContext(null);function vn(e){let[t,o]=At__namespace.useState(null),n=At__namespace.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsxRuntime.jsx(Tf.Provider,{value:n,children:jsxRuntime.jsx(Fe__namespace.Root,{...e})})}var xn=Fe__namespace.Group,Kc=Fe__namespace.Value;function Cn({className:e,children:t,onMouseDown:o,...n}){let r=At__namespace.useContext(Tf)?.setTrigger;return jsxRuntime.jsxs(Fe__namespace.Trigger,{ref:r,className:pe("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:i=>{i.preventDefault(),o?.(i);},...n,children:[t,jsxRuntime.jsx(Fe__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(jF,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Tn({className:e,children:t,position:o="popper",onCloseAutoFocus:n,onKeyDown:r,...i}){let a=At__namespace.useContext(Tf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:editor.hostDocumentOf(a),s=!!l?.querySelector(".docx-editor.dark");return jsxRuntime.jsx(Fe__namespace.Portal,{...l?.body?{container:l.body}:{},children:jsxRuntime.jsx("div",{className:pe("docx-editor",s&&"dark"),children:jsxRuntime.jsx(Fe__namespace.Content,{className:pe("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",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:o,onCloseAutoFocus:c=>{c.preventDefault(),n?.(c);},onKeyDown:c=>{r?.(c),c.defaultPrevented||GF(c);},...i,children:jsxRuntime.jsx(Fe__namespace.Viewport,{className:pe("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:c=>c.preventDefault(),children:t})})})})}var VF=new Set(["ArrowDown","ArrowUp","Home","End"]);function GF(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!VF.has(e.key))return;e.preventDefault();let o=Array.from(t.querySelectorAll('[role="option"]:not([data-disabled])'));if(o.length===0)return;let n=o.indexOf(t.ownerDocument.activeElement),r=n>=0?n:o.findIndex(a=>a.dataset.state==="checked"),i=e.key==="Home"?0:e.key==="End"?o.length-1:e.key==="ArrowDown"?Math.min(o.length-1,r+1):Math.max(0,r<0?0:r-1);o[i].focus({preventScroll:false});}function rr({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Label,{className:pe("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function Ut({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(Fe__namespace.Item,{className:pe("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(),o?.(r);},...n,children:[jsxRuntime.jsx(Fe__namespace.ItemText,{children:t}),jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(Fe__namespace.ItemIndicator,{children:jsxRuntime.jsx(YF,{className:"h-4 w-4"})})})]})}function ar({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Separator,{className:pe("-mx-1 my-1 h-px bg-muted",e),...t})}function jF({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.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 YF({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.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 Ef(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var XF=[{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 ZC({value:e,onChange:t,fonts:o=XF,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=L(),d=At__namespace.useMemo(()=>{if(!n)return [];let f=new Set(o.map(h=>h.name.toLowerCase()));return n.filter(h=>!f.has(h.name.toLowerCase()))},[n,o]),m=At__namespace.useMemo(()=>[...d,...o],[d,o]),u=At__namespace.useMemo(()=>e?m.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||Ef(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=At__namespace.useCallback(f=>{let h=m.find(b=>b.name===f);h&&t?.(Ef(h.fontFamily)||h.name);},[t,m]),p=At__namespace.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(h=>{let b=h.category||"other";f[b].push(h);}),f},[o]);return jsxRuntime.jsxs(vn,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(Cn,{className:pe("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(Kc,{placeholder:a,children:u})}),jsxRuntime.jsxs(Tn,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(xn,{children:[jsxRuntime.jsx(rr,{children:c("font.documentFonts")}),d.map(f=>jsxRuntime.jsx(Ut,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsxRuntime.jsx(ar,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(xn,{children:[jsxRuntime.jsx(rr,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsxRuntime.jsx(Ut,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{}),jsxRuntime.jsxs(xn,{children:[jsxRuntime.jsx(rr,{children:c("font.serif")}),p.serif.map(f=>jsxRuntime.jsx(Ut,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{}),jsxRuntime.jsxs(xn,{children:[jsxRuntime.jsx(rr,{children:c("font.monospace")}),p.monospace.map(f=>jsxRuntime.jsx(Ut,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ar,{}),jsxRuntime.jsx(xn,{children:p.other.map(f=>jsxRuntime.jsx(Ut,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function Sf(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);if(gt()){let o=new Set,n=new Set;for(let r of t)n.has(r.name)&&!o.has(r.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${r.name}"`),o.add(r.name)),n.add(r.name);}return t}function o4(e,t,o,n,r){let a=Math.max(8,e.innerWidth-n-8),l=Math.max(8,e.innerHeight-r-8);return {top:Math.min(Math.max(8,t),l),left:Math.min(Math.max(8,o),a)}}function Rt({isOpen:e,onClose:t,align:o="left"}){let n=At.useRef(null),r=At.useRef(null),[i,a]=At.useState({top:0,left:0});At.useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();if(o==="right"){let d=editor.hostWindowOf(n.current);d.requestAnimationFrame(()=>{if(r.current){let m=r.current.getBoundingClientRect(),u=o4(d,c.bottom+4,c.right-m.width,m.width,m.height);a(u);}else a({top:c.bottom+4,left:c.left});});}else a({top:c.bottom+4,left:c.left});},[e,o]),At.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=f=>{let h=f.target;n.current&&!n.current.contains(h)&&r.current&&!r.current.contains(h)&&t();},m=f=>{f.key==="Escape"&&t();},u=f=>{if(performance.now()<c)return;let h=f.target;h&&r.current&&r.current.contains(h)||editor.isElementNode(h)&&h!==h.ownerDocument.documentElement&&h!==h.ownerDocument.body&&n.current&&h.contains(n.current)||t();},g=editor.hostDocumentOf(n.current),p=editor.hostWindowOf(n.current);return g.addEventListener("mousedown",d),g.addEventListener("keydown",m),p.addEventListener("scroll",u,true),()=>{g.removeEventListener("mousedown",d),g.removeEventListener("keydown",m),p.removeEventListener("scroll",u,true);}},[e,t]);let l=At.useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:n,dropdownRef:r,dropdownStyle:s,handleMouseDown:l}}var i4=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],l4=1,s4=400;function zC(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function $C(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function VC({value:e,onChange:t,sizes:o=i4,disabled:n=false,className:r,placeholder:i="11",minSize:a=l4,maxSize:l=s4}){let{t:s}=L(),[c,d]=At.useState(false),[m,u]=At.useState(""),[g,p]=At.useState(false),f=At.useRef(null),h=At.useCallback(()=>{p(false),d(false);},[]),{containerRef:b,dropdownRef:v,dropdownStyle:y}=Rt({isOpen:g,onClose:h}),T=e??(parseInt(i,10)||11),x=e!==void 0?e.toString():i,C=At.useCallback(N=>{if(N.preventDefault(),n)return;let A=$C(T,o,a);t?.(A);},[T,o,a,n,t]),E=At.useCallback(N=>{if(N.preventDefault(),n)return;let A=zC(T,o,l);t?.(A);},[T,o,l,n,t]),S=At.useCallback(N=>{N.preventDefault(),!n&&(d(true),u(x),p(true),editor.hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[n,x]),D=At.useCallback(N=>{u(N.target.value);},[]),w=At.useCallback(()=>{d(false);let N=parseFloat(m);if(!isNaN(N)&&N>=a&&N<=l){let A=Math.round(N*2)/2;t?.(A);}},[m,a,l,t]),k=At.useCallback(N=>{if(N.key==="Enter")N.preventDefault(),w(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let A=zC(T,o,l);u(A.toString()),t?.(A);}else if(N.key==="ArrowDown"){N.preventDefault();let A=$C(T,o,a);u(A.toString()),t?.(A);}},[w,T,o,l,a,t]),F=At.useCallback(N=>{t?.(N),p(false),d(false);},[t]),I=At.useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:b,className:pe("flex items-center",r),onMouseDown:I,children:[jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:C,disabled:n||T<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx(V,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:f,type:"text",value:m,onChange:D,onBlur:w,onKeyDown:k,className:pe("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":s("fontSize.label"),"data-testid":"font-size-input"}):jsxRuntime.jsx("button",{type:"button",onClick:S,className:pe("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",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:x})}),g&&jsxRuntime.jsx("div",{ref:v,style:{...y,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":s("fontSize.listLabel"),children:o.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>F(N),className:pe("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===T&&"bg-muted font-medium"),role:"option","aria-selected":N===T,children:N},N))}),jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:E,disabled:n||T>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx(V,{name:"add",size:18})})]})}var u4=[{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"}],zc=18,p4=2,m4={position:"relative",display:"inline-block"},f4={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)"},g4={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},wf={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},Df={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},YC={display:"grid",gap:`${p4}px`},$c={width:`${zc}px`,height:`${zc}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},XC={...$c,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},JC={...$c,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},b4={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)"},h4={display:"flex",alignItems:"center",gap:"6px"},y4={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},v4={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},GC={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},x4={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},C4={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)"},T4={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 Rf(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=AC(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Cf(e,o)}function jC(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function QC(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Vo(e,o))===t.toUpperCase():false}function E4({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=At.useState(null);return jsxRuntime.jsx("div",{style:{...YC,gridTemplateColumns:`repeat(10, ${zc}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=r===d,u=QC(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?JC:m?XC:$c,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>n(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function S4({selectedColor:e,theme:t,onSelect:o}){let[n,r]=At.useState(null),{t:i}=L();return jsxRuntime.jsx("div",{style:{...YC,gridTemplateColumns:`repeat(10, ${zc}px)`},children:u4.map((a,l)=>{let s=n===l,c=QC(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?JC:s?XC:$c,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function sr({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:m}){let[u,g]=At.useState(false),[p,f]=At.useState(false),[h,b]=At.useState(false),[v,y]=At.useState(false),[T,x]=At.useState(""),[C,E]=At.useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:S}=L();At.useEffect(()=>{let B=Rf(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(B)&&x(B.toUpperCase());},[t,e,n]);let D=At.useCallback(()=>g(false),[]),{containerRef:w,dropdownRef:k,dropdownStyle:F}=Rt({isOpen:u,onClose:D}),I=n?.colorScheme??null,N=At.useMemo(()=>OC(I),[I]),A=At.useMemo(()=>Rf(t,e,n),[t,e,n]),P=At.useMemo(()=>Rf(C,e,n),[C,e,n]),M=At.useCallback(()=>{r||g(B=>!B);},[r]),$=At.useCallback(B=>{let _;e==="highlight"?_=B.hex:_={kind:"theme",slot:B.themeSlot,...B.tint!==void 0?{tint:B.tint}:{},...B.shade!==void 0?{shade:B.shade}:{}},E(_),o?.(_),g(false);},[e,o]),U=At.useCallback(B=>{let _=e==="highlight"?B:{kind:"hex",value:B};E(_),o?.(_),g(false);},[e,o]),oe=At.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),Y=At.useCallback(()=>{let B=T.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(B)){let _=e==="highlight"?B:{kind:"hex",value:B};E(_),o?.(_),g(false),x("");}},[e,T,o]),ne=At.useCallback(()=>{r||o?.(C);},[r,C,o]),K={...f4,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},X=S(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),le=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:w,className:`docx-color-picker ${i||""}`,style:{...m4,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...x4,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...C4,...r?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:ne,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),disabled:r,title:l||X,"aria-label":l||X,children:[jsxRuntime.jsx(V,{name:le,size:18}),jsxRuntime.jsx("div",{style:{...GC,backgroundColor:P==="transparent"?"#fff":P,outline:P==="transparent"||jC(P)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...T4,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:v?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:M,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx(V,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:K,onClick:M,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx(V,{name:le,size:18}),jsxRuntime.jsx("div",{style:{...GC,backgroundColor:A==="transparent"?"#fff":A,outline:A==="transparent"||jC(A)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx(V,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:k,className:"docx-color-picker-dropdown",style:{...F,...g4},role:"dialog","aria-label":`${X} picker`,onMouseDown:B=>{B.target.tagName!=="INPUT"&&B.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:b4,onClick:oe,onMouseDown:B=>B.preventDefault(),children:[e==="highlight"?jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsxRuntime.jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??S(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:Df}),jsxRuntime.jsx("div",{style:wf,children:S("colorPicker.themeColors")}),jsxRuntime.jsx(E4,{matrix:N,selectedColor:t,theme:n,onSelect:$}),jsxRuntime.jsx("div",{style:Df}),jsxRuntime.jsx("div",{style:wf,children:S("colorPicker.standardColors")}),jsxRuntime.jsx(S4,{selectedColor:t,theme:n,onSelect:U}),jsxRuntime.jsx("div",{style:Df}),jsxRuntime.jsx("div",{style:wf,children:S("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:h4,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:y4,value:T,onChange:B=>x(B.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:B=>{B.key==="Enter"&&Y();},onMouseDown:B=>{B.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...v4,opacity:/^[0-9A-Fa-f]{6}$/.test(T)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(T)?"pointer":"default"},onClick:Y,onMouseDown:B=>B.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(T),children:S("common.apply")})]})]})})]})}var ul=20,Mf=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx(V,{name:"format_align_left",size:ul}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx(V,{name:"format_align_center",size:ul}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx(V,{name:"format_align_right",size:ul}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx(V,{name:"format_align_justify",size:ul}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function oT({value:e="left",onChange:t,disabled:o=false}){let{t:n}=L(),[r,i]=At.useState(false),a=At.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=Rt({isOpen:r,onClose:a}),m=At.useCallback(b=>{o||t?.(b),i(false);},[o,t]),u=Mf.find(b=>b.value===e)||Mf[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,h=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:pe("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(b=>!b),disabled:o,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx(V,{name:u.iconName,size:ul}),jsxRuntime.jsx(V,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?h:jsxRuntime.jsx(Kt,{content:f,children:h}),r&&!o&&jsxRuntime.jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:b=>b.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:Mf.map(b=>{let v=e===b.value,y=n(b.labelKey),T=b.shortcutKey?n(b.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${y}${T?` (${T})`:""}`,"data-testid":`alignment-${b.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:v?"var(--doc-primary)":"var(--doc-text)"},onMouseDown: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:()=>m(b.value),children:jsxRuntime.jsx(V,{name:b.iconName,size:18})},b.value)})})})]})}function Vc(){return {type:"none",level:0,isInList:false}}var R4={display:"inline-flex",alignItems:"center",gap:"4px"},nT={display:"inline-flex",alignItems:"center",gap:"4px"},Xc={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)"},M4={...Xc,backgroundColor:"var(--doc-bg-hover)"},_4={...Xc,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},I4={...Xc,cursor:"default",opacity:.38},N4={width:"28px",height:"28px",padding:"2px"},L4={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Gc=20;function jc({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=At.useState(false),c={...t?I4:e?_4:l?M4:Xc,...a},d=m=>{m.preventDefault();};return jsxRuntime.jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:c,onMouseDown:d,onClick:t?void 0:n,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function rT({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:m}=L(),u=At.useCallback(()=>c?{...N4}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",h=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxRuntime.jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...R4,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:nT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsxRuntime.jsx(jc,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx(V,{name:"format_list_bulleted",size:Gc})}),jsxRuntime.jsx(jc,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx(V,{name:"format_list_numbered",size:Gc})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:L4,role:"separator"}),jsxRuntime.jsxs("div",{style:nT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(jc,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx(V,{name:"format_indent_decrease",size:Gc})}),jsxRuntime.jsx(jc,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx(V,{name:"format_indent_increase",size:Gc})})]})]})]})}var H4=[{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 iT({value:e,onChange:t,options:o=H4,disabled:n=false,className:r}){let{t:i}=L(),a=At__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=At__namespace.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxRuntime.jsxs(vn,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(Cn,{className:pe("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsxRuntime.jsx(jm,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Tn,{children:[o.map(c=>jsxRuntime.jsx(Ut,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(ar,{}),jsxRuntime.jsx(xn,{children:jsxRuntime.jsx(rr,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var lT=[{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 sT({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=L(),l=At__namespace.useMemo(()=>{let g=Vy(o);return g.length===0?lT:g.map(p=>({...p,type:"paragraph",nameKey:lT.find(f=>f.styleId===p.styleId)?.nameKey}))},[o]),s=At__namespace.useCallback(g=>{t?.(g);},[t]),c=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",m=l.find(g=>g.styleId===d),u=m?c(m):d;return jsxRuntime.jsxs(vn,{value:d,onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Cn,{className:pe("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsxRuntime.jsx("span",{className:"truncate",children:u})}),jsxRuntime.jsx(Tn,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(Ut,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:$y(g),children:c(g)})},g.styleId))})]})}var O4=[{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 dT({value:e=1,onChange:t,levels:o=O4,disabled:n=false,className:r,compact:i=false}){let{t:a}=L(),l=At__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=At__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=At__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=At__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=At__namespace.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsxRuntime.jsx(V,{name:"remove",size:18})}),jsxRuntime.jsxs(vn,{value:e.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Cn,{className:pe(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:jsxRuntime.jsx(Kc,{placeholder:"100%",children:l})}),jsxRuntime.jsx(Tn,{children:o.map(g=>jsxRuntime.jsx(Ut,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:n||!m,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx(V,{name:"add",size:18})})]})}var W4=[{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 mT({onAction:e,disabled:t=false}){let{t:o}=L(),[n,r]=At.useState(false),i=At.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:n,onClose:i}),d=At.useCallback(u=>{e(u),r(false);},[e]),m=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:pe("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsxRuntime.jsx(V,{name:"border_all",size:20}),jsxRuntime.jsx(V,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?m:jsxRuntime.jsx(Kt,{content:o("table.borders.tooltip"),children:m}),n&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:u=>u.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:W4.map(({action:u,icon:g,labelKey:p})=>jsxRuntime.jsx("button",{type:"button",title:o(p),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:f=>f.preventDefault(),onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsxRuntime.jsx(V,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function fT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=At.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Vo(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsxRuntime.jsx(sr,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var U4=[{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 bT({onAction:e,disabled:t=false}){let[o,n]=At.useState(false),{t:r}=L(),i=At.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:o,onClose:i}),d=At.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),m=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:pe("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsxRuntime.jsx(V,{name:"line_weight",size:20}),jsxRuntime.jsx(V,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsxRuntime.jsx(Kt,{content:r("table.borderWidth"),children:m}),o&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,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:u=>u.stopPropagation(),children:U4.map(({size:u,label:g,thickness:p})=>jsxRuntime.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(u),children:[jsxRuntime.jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsxRuntime.jsx("span",{children:g})]},u))})]})}function yT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=At.useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsxRuntime.jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsxRuntime.jsx(sr,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var $4={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"},ur={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},CT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function TT({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=L(),[r,i]=At.useState(false),[a,l]=At.useState(null),s=At.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:m,handleMouseDown:u}=Rt({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=At.useCallback(b=>{e(b),i(false);},[e]),f=(b,v,y,T,x)=>{let C=t||x?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...$4,backgroundColor:a===b&&!C?"var(--doc-bg-hover)":"transparent",color:C?"var(--doc-text-muted)":x?.danger?"var(--doc-error)":"var(--doc-text)",cursor:C?"not-allowed":"pointer"},onClick:()=>!C&&p(T),onMouseEnter:()=>l(b),onMouseLeave:()=>l(null),disabled:C,children:[jsxRuntime.jsx(V,{name:v,size:16,className:x?.danger&&!C?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:y})]},b)},h=jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(b=>!b),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx(V,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?h:jsxRuntime.jsx(Kt,{content:n("table.moreOptions"),children:h}),r&&!t&&jsxRuntime.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:b=>b.stopPropagation(),children:[f("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:ur,role:"separator"}),f("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),f("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:ur,role:"separator"}),f("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:ur,role:"separator"}),f("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),f("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),f("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:ur,role:"separator"}),jsxRuntime.jsx("div",{style:CT,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(b=>{let v={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsxRuntime.jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[b]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:T=>T.preventDefault(),onMouseEnter:T=>{T.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:b}),children:jsxRuntime.jsx(V,{name:v[b],size:16})},b)})}),jsxRuntime.jsx("div",{style:ur,role:"separator"}),jsxRuntime.jsx("div",{style:CT,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(b=>{let v={left:"format_align_left",center:"format_align_center",right:"format_align_right"},y=g===b;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[b]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:y?"var(--doc-primary-light)":"transparent",borderColor:y?"var(--doc-primary)":"var(--doc-border)",color:y?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:T=>T.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:b}}),children:jsxRuntime.jsx(V,{name:v[b],size:16})},b)})}),jsxRuntime.jsx("div",{style:ur,role:"separator"}),f("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:ur,role:"separator"}),f("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var G4=20;function ed({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=At.useState(false),m=At.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=Rt({isOpen:c,onClose:m}),h=At.useCallback(v=>{i||r(v),d(false);},[i,r]),b=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:pe("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(v=>!v),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx(V,{name:o,size:G4}),jsxRuntime.jsx(V,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?b:jsxRuntime.jsx(Kt,{content:n,children:b}),c&&!i&&jsxRuntime.jsx("div",{ref:g,style:{...p,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:v=>v.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(v=>{let y=t===v.value;return jsxRuntime.jsxs("button",{type:"button",title:v.label,"data-testid":l?`${l}-${v.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:y?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:y?"var(--doc-primary)":"var(--doc-text)",...s?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:T=>T.preventDefault(),onMouseEnter:T=>{y||(T.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=y?"var(--doc-primary-light)":"transparent";},onClick:()=>h(v.value),children:[jsxRuntime.jsx(V,{name:v.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:v.label})]},v.value)})})})]})}var j4=[{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 Y4(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function ST({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=L(),r=j4.map(l=>({...l,label:n(l.labelKey)})),i=Y4(e),a=r.find(l=>l.value===i)||r[0];return jsxRuntime.jsx(ed,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var J4=[{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 PT({onTransform:e,disabled:t=false}){let{t:o}=L(),n=J4.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(ed,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var io=18;function zt({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),s=d=>{d.preventDefault();},c=jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:pe("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:s,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":l?`toolbar-${l}`:void 0,children:r});return o?jsxRuntime.jsx(Kt,{content:o,children:c}):c}function lo({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:pe("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",o),role:"group","aria-label":e,children:t})}function n3(e){let t=At__namespace.default.useContext(sl);return t?{...t,...r3(e)}:e}function r3(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function Ff(e){let{t}=L(),o=n3(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:m,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:f=true,fontFamilies:h,documentFonts:b,showFontSizePicker:v=true,showTextColorPicker:y=true,showHighlightColorPicker:T=true,showAlignmentButtons:x=true,showListButtons:C=true,showLineSpacingPicker:E=true,showStylePicker:S=true,documentStyles:D,theme:w,showZoomControl:k=true,zoom:F,onZoomChange:I,onRefocusEditor:N,imageContext:A,onImageWrapType:P,onImageTransform:M,onOpenImageProperties:$,tableContext:U,onTableAction:oe,inline:Y=false}=o,ne=At.useRef(null),K=At.useCallback(ce=>{!c&&r&&r(ce);},[c,r]),X=At.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),le=At.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),B=At.useCallback(ce=>{!c&&r&&r({type:"fontFamily",value:ce});},[c,r]),_=At__namespace.default.useMemo(()=>Sf(h),[h]),O=At.useCallback(ce=>{!c&&r&&r({type:"fontSize",value:ce});},[c,r]),ae=At.useCallback(ce=>{!c&&r&&r({type:"textColor",value:ce});},[c,r]),se=At.useCallback(ce=>{!c&&r&&r({type:"highlightColor",value:typeof ce=="string"?ce:""});},[c,r]),he=At.useCallback(ce=>{!c&&r&&r({type:"alignment",value:ce});},[c,r]),Me=At.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),je=At.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),$e=At.useCallback(()=>{!c&&r&&r("indent");},[c,r]),Pe=At.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Ct=At.useCallback(ce=>{!c&&r&&(r({type:"lineSpacing",value:ce}),editor.hostWindowOf(ne.current).requestAnimationFrame(()=>N?.()));},[c,r,N]),Io=At.useCallback(ce=>{!c&&r&&r({type:"applyStyle",value:ce});},[c,r]),No=At.useCallback(ce=>{!c&&oe&&(oe(ce),editor.hostWindowOf(ne.current).requestAnimationFrame(()=>N?.()));},[c,oe,N]);At.useEffect(()=>{if(!u)return;let ce=Ee=>{if(Ee.defaultPrevented)return;let Jo=Ee.target,co=g?.current,Bt=ne.current,Dn=co?.contains(Jo),de=Bt?.contains(Jo);if(!Dn&&!de)return;if((Ee.ctrlKey||Ee.metaKey)&&!Ee.altKey)switch(Ee.key.toLowerCase()){case "b":Ee.preventDefault(),K("bold");break;case "i":Ee.preventDefault(),K("italic");break;case "u":Ee.preventDefault(),K("underline");break;case "=":Ee.shiftKey?(Ee.preventDefault(),K("superscript")):(Ee.preventDefault(),K("subscript"));break;case "l":Ee.preventDefault(),he("left");break;case "e":Ee.preventDefault(),he("center");break;case "r":Ee.preventDefault(),he("right");break;case "j":Ee.preventDefault(),he("both");break;case "k":Ee.preventDefault(),K("insertLink");break}},rt=editor.hostDocumentOf(g?.current??ne.current);return rt.addEventListener("keydown",ce),()=>{rt.removeEventListener("keydown",ce);}},[u,K,he,g]);let Xo=At.useCallback(ce=>{let rt=ce.target;rt.tagName==="INPUT"||rt.tagName==="TEXTAREA"||rt.tagName==="SELECT"||rt.tagName==="OPTION"||ce.preventDefault();},[]),$t=At.useCallback(ce=>{let rt=ce.target,Ee=editor.hostDocumentOf(rt).activeElement;rt.tagName==="SELECT"||rt.tagName==="OPTION"||Ee?.tagName==="SELECT"||editor.hostWindowOf(rt).requestAnimationFrame(()=>{N?.();});},[N]);return jsxRuntime.jsxs("div",{ref:ne,className:pe(!Y&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:Y?{display:"contents",...m}:m,role:Y?void 0:"toolbar","aria-label":Y?void 0:t("toolbar.ariaLabel"),"data-testid":Y?void 0:"formatting-bar",onMouseDown:Y?void 0:Xo,onMouseUp:Y?void 0:$t,children:[jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(zt,{onClick:X,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx(V,{name:"undo",size:io})}),jsxRuntime.jsx(zt,{onClick:le,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx(V,{name:"redo",size:io})})]}),k&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(dT,{value:F,onChange:I,disabled:c,compact:true})}),S&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(sT,{value:n.styleId||"Normal",onChange:Io,styles:D,theme:w,disabled:c,width:120})}),(f||v)&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.font"),children:[f&&jsxRuntime.jsx(ZC,{value:n.fontFamily||"Arial",onChange:B,fonts:_,documentFonts:b,disabled:c,width:60,placeholder:"Arial"}),v&&jsxRuntime.jsx(VC,{value:n.fontSize!==void 0?Fp(n.fontSize):11,onChange:O,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(zt,{onClick:()=>K("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx(V,{name:"format_bold",size:io})}),jsxRuntime.jsx(zt,{onClick:()=>K("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx(V,{name:"format_italic",size:io})}),jsxRuntime.jsx(zt,{onClick:()=>K("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx(V,{name:"format_underlined",size:io})}),jsxRuntime.jsx(zt,{onClick:()=>K("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx(V,{name:"strikethrough_s",size:io})}),y&&jsxRuntime.jsx(sr,{mode:"text",value:n.color?.replace(/^#/,""),onChange:ae,theme:w,disabled:c,title:t("formattingBar.fontColor")}),T&&jsxRuntime.jsx(sr,{mode:"highlight",value:n.highlight,onChange:se,theme:w,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx(zt,{onClick:()=>K("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx(V,{name:"link",size:io})})]}),jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(zt,{onClick:()=>K("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx(V,{name:"superscript",size:io})}),jsxRuntime.jsx(zt,{onClick:()=>K("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx(V,{name:"subscript",size:io})})]}),x&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(oT,{value:n.alignment||"left",onChange:he,disabled:c})}),(C||E)&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.listFormatting"),children:[C&&jsxRuntime.jsx(rT,{listState:n.listState||Vc(),onBulletList:Me,onNumberedList:je,onIndent:$e,onOutdent:Pe,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),E&&jsxRuntime.jsx(iT,{value:n.lineSpacing,onChange:Ct,disabled:c})]}),A&&P&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(ST,{imageContext:A,onChange:P,disabled:c}),M&&jsxRuntime.jsx(PT,{onTransform:M,disabled:c}),$&&jsxRuntime.jsx(zt,{onClick:$,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx(V,{name:"tune",size:io})})]}),U?.isInTable&&oe&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(mT,{onAction:No,disabled:c}),jsxRuntime.jsx(fT,{onAction:No,disabled:c,theme:w,value:Vo(U?.cellBorderColor,w)}),jsxRuntime.jsx(bT,{onAction:No,disabled:c}),jsxRuntime.jsx(yT,{onAction:No,disabled:c,theme:w,value:U?.cellBackgroundColor}),jsxRuntime.jsx(TT,{onAction:No,disabled:c,tableContext:U})]}),jsxRuntime.jsx(zt,{onClick:()=>K("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx(V,{name:"format_clear",size:io})}),p]})}function a3({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(sl.Provider,{value:n,children:jsxRuntime.jsx("div",{className:pe("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:vt.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var Mt=a3;Mt.TitleBar=xf;Mt.Logo=Bc;Mt.DocumentName=vf;Mt.MenuBar=Zc;Mt.TitleBarRight=Wc;Mt.Toolbar=Ff;var s3=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"]]),c3=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function d3({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:m,documentFontFamily:u,className:g}){let p=At.useRef(null),[f,h]=At.useState(null),[b,v]=At.useState({}),[y,T]=At.useState(null),x=At.useCallback(D=>{h(D);let w=p.current?.formatting();w&&v({bold:w.bold,italic:w.italic,underline:w.underline,strike:w.strikethrough,superscript:w.superscript,subscript:w.subscript,...w.fontFamily?{fontFamily:w.fontFamily}:{},...w.fontSizeHalfPoints?{fontSize:w.fontSizeHalfPoints}:{},...w.alignment?{alignment:w.alignment}:{},...w.styleId?{styleId:w.styleId}:{},...w.color?{color:`#${w.color}`}:{},...w.highlight?{highlight:w.highlight}:{}}),T(p.current?.sectionProperties()??null),r?.(D);},[r]),C=At.useCallback(D=>{let w=p.current;if(w){if(typeof D=="string")switch(D){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;case "setRtl":case "setLtr":return w.setParagraphProperty("bidi",void 0,{paragraphDirection:D==="setRtl"?"rtl":"ltr"});default:return}switch(D.type){case "fontFamily":return w.setRunProperty("rFonts",{ascii:D.value,hAnsi:D.value});case "fontSize":return w.setRunProperty("sz",{val:String(Math.round(D.value*2))});case "textColor":{let k=D.value,F=typeof k=="string"?c3(k):Vo(k,null)??null;return F?w.setRunProperty("color",{val:F}):void 0}case "highlightColor":{let k=D.value.trim().toLowerCase();if(k==="none"||k==="")return w.setRunProperty("highlight",{val:"none"});let F=s3.get(k.startsWith("#")?k:`#${k}`);return F?w.setRunProperty("highlight",{val:F}):void 0}case "alignment":return w.setParagraphProperty("jc",{val:String(D.value)},{physicalAlignment:true});case "lineSpacing":return w.setParagraphProperty("spacing",{line:String(Math.round(D.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return w.setParagraphProperty("pStyle",{val:D.value});default:return}}},[]);At.useImperativeHandle(c,()=>p.current,[]);let E=t===void 0?1:t/(96/72),S=y?{pageWidthTwips:y.pageSize.widthTwips,pageHeightTwips:y.pageSize.heightTwips,orientation:y.landscape?"landscape":"portrait",marginsTwips:{top:y.margins.topTwips,right:y.margins.rightTwips,bottom:y.margins.bottomTwips,left:y.margins.leftTwips}}:null;return jsxRuntime.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:[jsxRuntime.jsxs(Mt,{currentFormatting:b,onFormat:C,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:E,onZoomChange:m,onSave:()=>{let D=p.current?.save();D&&a?.(D);},children:[jsxRuntime.jsxs(Mt.TitleBar,{children:[l&&jsxRuntime.jsx(Mt.Logo,{children:l()}),jsxRuntime.jsx(Mt.DocumentName,{value:n??"Document",editable:false}),s&&jsxRuntime.jsx(Mt.TitleBarRight,{children:s()}),jsxRuntime.jsx(Mt.MenuBar,{})]}),jsxRuntime.jsx(Mt.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[S?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(er,{pageSetup:S,zoom:E})}):null,jsxRuntime.jsx(ff,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:x,...i?{onError:i}:{}})]})]})}var od=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 nd=class extends od{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=globalThis.setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=globalThis.setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var b3=At.createContext(null);function _T({children:e}){let t=At.useMemo(()=>new nd,[]),o=At.useSyncExternalStore(t.subscribe,t.getSnapshot),n=At.useCallback((c,d)=>{t.showError(c,d);},[t]),r=At.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=At.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=At.useCallback(c=>{t.dismiss(c);},[t]),l=At.useCallback(()=>{t.clearAll();},[t]),s=At.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxRuntime.jsxs(b3.Provider,{value:s,children:[e,jsxRuntime.jsx(h3,{notifications:o.notifications,onDismiss:a})]})}function h3({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(r=>jsxRuntime.jsx(y3,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function y3({notification:e,onDismiss:t}){let{t:o}=L(),[n,r]=At.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:"docx-notification-slide-in 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},c={color:a.icon,flexShrink:0},d={flex:1,minWidth:0},m={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},u={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},p=f=>{switch(f){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:c,children:p(e.severity)}),jsxRuntime.jsxs("div",{style:d,children:[jsxRuntime.jsx("div",{style:m,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>r(!n),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(n?"errors.hideDetails":"errors.showDetails")}),n&&jsxRuntime.jsx("div",{style:u,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var rd=class extends At.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",t,o),this.props.onError&&this.props.onError(t,o);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:o=true}=this.props,{error:n,errorInfo:r}=this.state;return t?typeof t=="function"?t(n,this.resetError):t:jsxRuntime.jsx(v3,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function v3({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=L(),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"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={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 jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:i,children:[jsxRuntime.jsx("div",{style:a,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:r("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:s,children:r("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
3
3
|
|
|
4
|
-
`,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function Vy({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=Hr}){let{t:r}=N();return jsxRuntime.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:n-o,top:t,zIndex:ct.outline},children:jsxRuntime.jsx($,{name:"format_list_bulleted",size:20})})}function pm({currentPage:e,totalPages:t,visible:o}){let{t:n}=N();return jsxRuntime.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:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:n("viewer.pageIndicator",{current:e,total:t})})}function A5({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:s,mainContentStyle:l,editorContainerStyle:c,showRuler:d,readOnlyProp:f,showOutline:u,showOutlineButton:g,sidebarOpen:m,minLayoutWidth:p,toolbarHeight:v,editorScrollLeft:y,onScrollContainerMouseDown:x,onEditorBgMouseDown:b,onEditorContextMenu:h,horizontalRulerProps:C,verticalRulerProps:T,outlineProps:S,onToggleOutline:P,scrollPageInfo:k,toolbar:w,pagedArea:E,overlays:D,dialogs:A,fileInputs:_}){let F=d&&!f;return jsxRuntime.jsx(vn.Provider,{value:true,children:jsxRuntime.jsx(Un,{i18n:e,children:jsxRuntime.jsx(zy,{children:jsxRuntime.jsx(sc,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:le("docx-editor",t&&"dark",a),style:s,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:l,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[w,jsxRuntime.jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:x,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:ct.ruler,paddingLeft:20,paddingRight:20+(m?352:0),minWidth:p,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(Dn,{...C})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:p},children:jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:b,onContextMenu:h,children:[F&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:ct.ruler,paddingTop:48},children:jsxRuntime.jsx(pi,{...T})}),E]})})]}),k.totalPages>1&&jsxRuntime.jsx(pm,{currentPage:k.currentPage,totalPages:k.totalPages,visible:k.visible}),u&&jsxRuntime.jsx(fi,{...S,leftOffset:mi+(F?Fr:0)}),g&&!u&&jsxRuntime.jsx(Vy,{onClick:P,topPx:v+(d?Sp+8:0)+48,scrollLeft:y,leftOffset:Hr+(F?Fr:0)})]})}),D,A,_]})})})})})}function z5(e){let[t,o]=Et.useState(0);return Et.useEffect(()=>{if(!e)return;let n=()=>o(a=>a+1),r=e.on("change",n),i=e.on("selectionChange",n);return n(),()=>{r(),i();}},[e]),t}function Y5({kind:e}){let t=H(),[o,n]=Et.useState(null),r=Et.useRef(null);Et.useLayoutEffect(()=>{if(!t||!o)return;let a=editor.bindHistoryGroup(t,o,{kind:e});return r.current=a,()=>{a.dispose(),r.current=null;}},[t,o,e]);let i=Et.useCallback(()=>{if(!r.current)throw new Error("history group control is not mounted");return r.current.options()},[]);return {ref:n,options:i}}Object.defineProperty(exports,"CHROME_GROUPS",{enumerable:true,get:function(){return editor.CHROME_GROUPS}});Object.defineProperty(exports,"CHROME_MENUS",{enumerable:true,get:function(){return editor.CHROME_MENUS}});Object.defineProperty(exports,"DEFAULT_FONT",{enumerable:true,get:function(){return editor.DEFAULT_FONT}});Object.defineProperty(exports,"DocumentRefreshError",{enumerable:true,get:function(){return editor.DocumentRefreshError}});Object.defineProperty(exports,"HIGHLIGHT_REFRESH_MS",{enumerable:true,get:function(){return editor.HIGHLIGHT_REFRESH_MS}});Object.defineProperty(exports,"LOADING_SNAPSHOT",{enumerable:true,get:function(){return editor.LOADING_SNAPSHOT}});Object.defineProperty(exports,"MAX_RESOLVER_FAMILIES",{enumerable:true,get:function(){return editor.MAX_RESOLVER_FAMILIES}});Object.defineProperty(exports,"PX_PER_CM",{enumerable:true,get:function(){return editor.PX_PER_CM}});Object.defineProperty(exports,"PX_PER_INCH",{enumerable:true,get:function(){return editor.PX_PER_INCH}});Object.defineProperty(exports,"SEARCH_DEBOUNCE_MS",{enumerable:true,get:function(){return editor.SEARCH_DEBOUNCE_MS}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_PRIORITY",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_PRIORITY}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_SET",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_SET}});Object.defineProperty(exports,"SEARCH_MATCH_LIMIT",{enumerable:true,get:function(){return editor.SEARCH_MATCH_LIMIT}});Object.defineProperty(exports,"WORD_DEFAULT_FONT",{enumerable:true,get:function(){return editor.WORD_DEFAULT_FONT}});Object.defineProperty(exports,"chromeMenuSlots",{enumerable:true,get:function(){return editor.chromeMenuSlots}});Object.defineProperty(exports,"commandForSlot",{enumerable:true,get:function(){return editor.commandForSlot}});Object.defineProperty(exports,"composeFontConfiguration",{enumerable:true,get:function(){return editor.composeFontConfiguration}});Object.defineProperty(exports,"composeFontOrigins",{enumerable:true,get:function(){return editor.composeFontOrigins}});Object.defineProperty(exports,"createDocumentRefresh",{enumerable:true,get:function(){return editor.createDocumentRefresh}});Object.defineProperty(exports,"createFontSource",{enumerable:true,get:function(){return editor.createFontSource}});Object.defineProperty(exports,"defineFontResolver",{enumerable:true,get:function(){return editor.defineFontResolver}});Object.defineProperty(exports,"generateRulerTicks",{enumerable:true,get:function(){return editor.generateRulerTicks}});Object.defineProperty(exports,"isFontResolver",{enumerable:true,get:function(){return editor.isFontResolver}});Object.defineProperty(exports,"loadFonts",{enumerable:true,get:function(){return editor.loadFonts}});Object.defineProperty(exports,"rulerPageBox",{enumerable:true,get:function(){return editor.rulerPageBox}});Object.defineProperty(exports,"runToolbarCommand",{enumerable:true,get:function(){return editor.runToolbarCommand}});Object.defineProperty(exports,"toolbarCommandState",{enumerable:true,get:function(){return editor.toolbarCommandState}});Object.defineProperty(exports,"EditorFontError",{enumerable:true,get:function(){return editor$1.EditorFontError}});exports.CONTENT_CONTROL_SLOTS=gt;exports.ContextMenuCellVerticalAlignment=bn;exports.ContextMenuCopy=fa;exports.ContextMenuCopyFormatting=al;exports.ContextMenuCut=ma;exports.ContextMenuDelete=ga;exports.ContextMenuDeleteTable=br;exports.ContextMenuDeleteTableColumn=hr;exports.ContextMenuDeleteTableRow=gr;exports.ContextMenuInsertColumnLeft=mr;exports.ContextMenuInsertColumnRight=fr;exports.ContextMenuInsertRowAbove=ur;exports.ContextMenuInsertRowBelow=pr;exports.ContextMenuItem=sl;exports.ContextMenuPaste=cr;exports.ContextMenuPasteFormatting=il;exports.ContextMenuPasteWithoutFormatting=dr;exports.ContextMenuRefreshToc=vr;exports.ContextMenuRefreshTocPageNumbers=yr;exports.ContextMenuSelectAll=ha;exports.DocumentName=Yp;exports.DocumentOutline=fi;exports.DocxEditor=nI;exports.DocxEditorAuthorStyle=yu;exports.DocxEditorColorByChangeType=vu;exports.DocxEditorContent=Ll;exports.DocxEditorContentControl=ta;exports.DocxEditorContentControlWidget=ru;exports.DocxEditorContextMenu=va;exports.DocxEditorDocumentOutline=_p;exports.DocxEditorEquation=oa;exports.DocxEditorExportDialog=Vr;exports.DocxEditorFontNotice=Bs;exports.DocxEditorHeaderFooterChrome=Zs;exports.DocxEditorHorizontalRuler=Rs;exports.DocxEditorHyperLink=Jr;exports.DocxEditorImageAltTextPopup=Cl;exports.DocxEditorImagePropertiesDialog=Ca;exports.DocxEditorInvalidTextFormFieldDialog=Hd;exports.DocxEditorLoading=Hl;exports.DocxEditorLoadingSpinner=bu;exports.DocxEditorMenu=ci;exports.DocxEditorNavigation=Bp;exports.DocxEditorNotePreview=jn;exports.DocxEditorNotePropertiesDialog=gl;exports.DocxEditorNotesChrome=fl;exports.DocxEditorNotesContextMenu=Yn;exports.DocxEditorPageNumber=Os;exports.DocxEditorPageSetupDialog=Sn;exports.DocxEditorParagraphDialog=xo;exports.DocxEditorPrintDialog=Gr;exports.DocxEditorRevisionMarkup=Nc;exports.DocxEditorRevisionMarkupDialog=Ur;exports.DocxEditorRoot=Na;exports.DocxEditorShell=A5;exports.DocxEditorTextFormFieldDialog=Ma;exports.DocxEditorToolbar=ri;exports.DocxEditorVerticalRuler=ks;exports.DocxEditorViewport=Zl;exports.HorizontalRuler=Dn;exports.ImageAltText=xl;exports.ImageInsertProvider=Qi;exports.ImageInsertTrigger=el;exports.ImagePropertiesTrigger=yl;exports.ImageWrap=Yl;exports.LocaleProvider=Un;exports.Logo=Ws;exports.MenuBar=$s;exports.NAVIGATION_PANE_GAP=iv;exports.NAVIGATION_PANE_INSET=Ds;exports.NAVIGATION_PANE_MIN_PAGE_ROOM=Lp;exports.NAVIGATION_PANE_WIDTH=Ar;exports.NavigationClose=xi;exports.NavigationFind=Ei;exports.NavigationHeader=yi;exports.NavigationHeadings=Si;exports.NavigationTab=Pi;exports.NavigationTabs=Ti;exports.NavigationTitle=Ci;exports.NavigationToggle=wi;exports.OUTLINE_BUTTON_LEFT_OFFSET=Hr;exports.OUTLINE_BUTTON_RESERVED_SPACE=O2;exports.OUTLINE_LEFT_OFFSET=mi;exports.OUTLINE_RESERVED_SPACE=H2;exports.PageIndicator=pm;exports.PageNumberTranslationContext=As;exports.PaginatedDocxEditor=$p;exports.PaginatedDocxEditorShell=w5;exports.REVIEW_MARKERS_GUTTER=wr;exports.REVIEW_PANE_GUTTER=La;exports.RULER_WIDTH=Fr;exports.ReviewRailContext=Ct;exports.Slot=G;exports.TitleBar=Xp;exports.TitleBarRight=zs;exports.Toolbar=dm;exports.ToolbarButton=Nt;exports.ToolbarContext=ln;exports.ToolbarGroup=Gt;exports.ToolbarImageProperties=Cr;exports.VERSION=Qy;exports.VerticalRuler=pi;exports.definePopup=FC;exports.editorStateActiveSubscriptionCount=sx;exports.isFieldLink=Yr;exports.navigationPaneOverlays=_s;exports.navigationPaneReservation=Or;exports.navigationShift=Is;exports.normalizeImageBytes=Ji;exports.notificationYieldsToTask=xm;exports.provideDocxEditor=lw;exports.reviewGutter=ph;exports.useChromeTranslate=vm;exports.useContentControl=eo;exports.useContentControlInstance=Ui;exports.useContentControlWidget=Qe;exports.useContextMenuTarget=_f;exports.useDocumentOutline=Ns;exports.useDocumentSearch=Ls;exports.useDocxEditor=H;exports.useDocxSource=uI;exports.useEditorCaret=xI;exports.useEditorCommand=se;exports.useEditorEvent=rp;exports.useEditorSnapshot=z5;exports.useEditorState=B;exports.useEditorValueCommand=Ta;exports.useFontFamily=ts;exports.useFonts=hI;exports.useHeaderFooterState=qp;exports.useHighlightAt=kI;exports.useHighlights=EI;exports.useHistoryGroup=Y5;exports.useHyperlinkPopup=Fc;exports.useHyperlinkPopupInstance=zi;exports.useNavigationPane=Fs;exports.useNavigationShift=an;exports.useNotePropertiesState=Ed;exports.useNoteScopeState=Sd;exports.usePageSetup=Pn;exports.usePageSetupDialog=nE;exports.useParagraphDialog=hE;exports.useParagraphFormat=cu;exports.useParagraphIndent=wp;exports.useParagraphStyle=os;exports.useReviewAuthors=Aa;exports.useReviewGutter=qo;exports.useRevisionMarkupDialog=EC;exports.useScopeClassName=Tt;exports.useScopedChromeAnchor=ya;exports.useTableBorderTargetLabel=ib;exports.useTextFormFieldDialog=KS;exports.useToolbarContext=Ox;exports.useToolbarLabel=Q;exports.useToolbarLabelFor=Oi;exports.useTranslation=N;exports.useZoom=Zu;
|
|
4
|
+
`,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function LT({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=fa}){let{t:r}=L();return jsxRuntime.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:n-o,top:t,zIndex:vt.outline},children:jsxRuntime.jsx(V,{name:"format_list_bulleted",size:20})})}function Af({currentPage:e,totalPages:t,visible:o}){let{t:n}=L();return jsxRuntime.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:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:n("viewer.pageIndicator",{current:e,total:t})})}function C3({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:m,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:h,editorScrollLeft:b,onScrollContainerMouseDown:v,onEditorBgMouseDown:y,onEditorContextMenu:T,horizontalRulerProps:x,verticalRulerProps:C,outlineProps:E,onToggleOutline:S,scrollPageInfo:D,toolbar:w,pagedArea:k,overlays:F,dialogs:I,fileInputs:N}){let A=d&&!m;return jsxRuntime.jsx(zn.Provider,{value:true,children:jsxRuntime.jsx(fr,{i18n:e,children:jsxRuntime.jsx(_T,{children:jsxRuntime.jsx(rd,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:pe("docx-editor",t&&"dark",a),style:l,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:s,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[w,jsxRuntime.jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:v,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:vt.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(er,{...x})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y,onContextMenu:T,children:[A&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:vt.ruler,paddingTop:48},children:jsxRuntime.jsx(zi,{...C})}),k]})})]}),D.totalPages>1&&jsxRuntime.jsx(Af,{currentPage:D.currentPage,totalPages:D.totalPages,visible:D.visible}),u&&jsxRuntime.jsx(Vi,{...E,leftOffset:$i+(A?ma:0)}),g&&!u&&jsxRuntime.jsx(LT,{onClick:S,topPx:h+(d?Km+8:0)+48,scrollLeft:b,leftOffset:fa+(A?ma:0)})]})}),F,I,N]})})})})})}function D3(e){let[t,o]=At.useState(0);return At.useEffect(()=>{if(!e)return;let n=()=>o(a=>a+1),r=e.on("change",n),i=e.on("selectionChange",n);return n(),()=>{r(),i();}},[e]),t}function L3({kind:e}){let t=H(),[o,n]=At.useState(null),r=At.useRef(null);At.useLayoutEffect(()=>{if(!t||!o)return;let a=editor.bindHistoryGroup(t,o,{kind:e});return r.current=a,()=>{a.dispose(),r.current=null;}},[t,o,e]);let i=At.useCallback(()=>{if(!r.current)throw new Error("history group control is not mounted");return r.current.options()},[]);return {ref:n,options:i}}Object.defineProperty(exports,"CHROME_GROUPS",{enumerable:true,get:function(){return editor.CHROME_GROUPS}});Object.defineProperty(exports,"CHROME_MENUS",{enumerable:true,get:function(){return editor.CHROME_MENUS}});Object.defineProperty(exports,"DEFAULT_FONT",{enumerable:true,get:function(){return editor.DEFAULT_FONT}});Object.defineProperty(exports,"DocumentRefreshError",{enumerable:true,get:function(){return editor.DocumentRefreshError}});Object.defineProperty(exports,"HIGHLIGHT_REFRESH_MS",{enumerable:true,get:function(){return editor.HIGHLIGHT_REFRESH_MS}});Object.defineProperty(exports,"LOADING_SNAPSHOT",{enumerable:true,get:function(){return editor.LOADING_SNAPSHOT}});Object.defineProperty(exports,"MAX_RESOLVER_FAMILIES",{enumerable:true,get:function(){return editor.MAX_RESOLVER_FAMILIES}});Object.defineProperty(exports,"PX_PER_CM",{enumerable:true,get:function(){return editor.PX_PER_CM}});Object.defineProperty(exports,"PX_PER_INCH",{enumerable:true,get:function(){return editor.PX_PER_INCH}});Object.defineProperty(exports,"SEARCH_DEBOUNCE_MS",{enumerable:true,get:function(){return editor.SEARCH_DEBOUNCE_MS}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_PRIORITY",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_PRIORITY}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_SET",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_SET}});Object.defineProperty(exports,"SEARCH_MATCH_LIMIT",{enumerable:true,get:function(){return editor.SEARCH_MATCH_LIMIT}});Object.defineProperty(exports,"WORD_DEFAULT_FONT",{enumerable:true,get:function(){return editor.WORD_DEFAULT_FONT}});Object.defineProperty(exports,"chromeMenuSlots",{enumerable:true,get:function(){return editor.chromeMenuSlots}});Object.defineProperty(exports,"commandForSlot",{enumerable:true,get:function(){return editor.commandForSlot}});Object.defineProperty(exports,"composeFontConfiguration",{enumerable:true,get:function(){return editor.composeFontConfiguration}});Object.defineProperty(exports,"composeFontOrigins",{enumerable:true,get:function(){return editor.composeFontOrigins}});Object.defineProperty(exports,"createDocumentRefresh",{enumerable:true,get:function(){return editor.createDocumentRefresh}});Object.defineProperty(exports,"createFontSource",{enumerable:true,get:function(){return editor.createFontSource}});Object.defineProperty(exports,"defineFontResolver",{enumerable:true,get:function(){return editor.defineFontResolver}});Object.defineProperty(exports,"generateRulerTicks",{enumerable:true,get:function(){return editor.generateRulerTicks}});Object.defineProperty(exports,"isFontResolver",{enumerable:true,get:function(){return editor.isFontResolver}});Object.defineProperty(exports,"loadFonts",{enumerable:true,get:function(){return editor.loadFonts}});Object.defineProperty(exports,"rulerPageBox",{enumerable:true,get:function(){return editor.rulerPageBox}});Object.defineProperty(exports,"runToolbarCommand",{enumerable:true,get:function(){return editor.runToolbarCommand}});Object.defineProperty(exports,"toolbarCommandState",{enumerable:true,get:function(){return editor.toolbarCommandState}});Object.defineProperty(exports,"EditorFontError",{enumerable:true,get:function(){return editor$1.EditorFontError}});exports.CONTENT_CONTROL_SLOTS=Pt;exports.ContextMenuCellVerticalAlignment=Un;exports.ContextMenuCopy=Xa;exports.ContextMenuCopyFormatting=os;exports.ContextMenuCut=Ya;exports.ContextMenuDelete=Ja;exports.ContextMenuDeleteTable=$r;exports.ContextMenuDeleteTableColumn=zr;exports.ContextMenuDeleteTableRow=Ur;exports.ContextMenuInsertColumnLeft=Wr;exports.ContextMenuInsertColumnRight=Zr;exports.ContextMenuInsertRowAbove=Or;exports.ContextMenuInsertRowBelow=Br;exports.ContextMenuItem=rs;exports.ContextMenuMergeCells=qr;exports.ContextMenuPaste=Hr;exports.ContextMenuPasteFormatting=ns;exports.ContextMenuPasteWithoutFormatting=Ar;exports.ContextMenuRefreshToc=Vr;exports.ContextMenuRefreshTocPageNumbers=Gr;exports.ContextMenuSelectAll=Qa;exports.ContextMenuSplitCell=Kr;exports.DEFAULT_WATERMARK_PRESETS=ku;exports.DocumentName=vf;exports.DocumentOutline=Vi;exports.DocxEditor=PL;exports.DocxEditorAuthorStyle=Op;exports.DocxEditorBookmarkDialog=$a;exports.DocxEditorColorByChangeType=Ap;exports.DocxEditorContent=ks;exports.DocxEditorContentControl=La;exports.DocxEditorContentControlWidget=wp;exports.DocxEditorContextMenu=oi;exports.DocxEditorDocumentOutline=Xm;exports.DocxEditorEquation=Fa;exports.DocxEditorExportDialog=ka;exports.DocxEditorFontNotice=Lc;exports.DocxEditorHeaderFooterChrome=Hc;exports.DocxEditorHorizontalRuler=Tc;exports.DocxEditorHyperLink=_a;exports.DocxEditorImageAltTextPopup=hs;exports.DocxEditorImageInsertErrorDialog=au;exports.DocxEditorImagePropertiesDialog=ai;exports.DocxEditorInvalidTextFormFieldDialog=ap;exports.DocxEditorLoading=Ds;exports.DocxEditorLoadingSpinner=Hp;exports.DocxEditorMenu=qi;exports.DocxEditorNavigation=af;exports.DocxEditorNotePreview=hr;exports.DocxEditorNotePropertiesDialog=us;exports.DocxEditorNotesChrome=ds;exports.DocxEditorNotesContextMenu=yr;exports.DocxEditorOpenFailure=Fc;exports.DocxEditorOpenFailureAction=sf;exports.DocxEditorPageNumber=Nc;exports.DocxEditorPageSetupDialog=Zn;exports.DocxEditorParagraphDialog=Zo;exports.DocxEditorPrintDialog=wa;exports.DocxEditorRevisionMarkup=_d;exports.DocxEditorRevisionMarkupDialog=Pa;exports.DocxEditorRoot=mi;exports.DocxEditorShell=C3;exports.DocxEditorSplitCellDialog=Va;exports.DocxEditorTextFormFieldDialog=ja;exports.DocxEditorToolbar=Oi;exports.DocxEditorUnsupportedElement=ld;exports.DocxEditorVerticalRuler=Ec;exports.DocxEditorViewport=_s;exports.DocxEditorWatermarkDialog=qn;exports.DocxEditorWindow=Lp;exports.HorizontalRuler=er;exports.ImageAltText=bs;exports.ImageInsertProvider=Fl;exports.ImageInsertTrigger=Hl;exports.ImagePropertiesTrigger=gs;exports.ImageWrap=Zs;exports.LocaleProvider=fr;exports.Logo=Bc;exports.MenuBar=Zc;exports.NAVIGATION_PANE_GAP=Ix;exports.NAVIGATION_PANE_INSET=Pc;exports.NAVIGATION_PANE_MIN_PAGE_ROOM=Qm;exports.NAVIGATION_PANE_WIDTH=ba;exports.NavigationClose=Qi;exports.NavigationFind=rl;exports.NavigationGoTo=Gi;exports.NavigationHeader=Ji;exports.NavigationHeadings=nl;exports.NavigationTab=ol;exports.NavigationTabs=tl;exports.NavigationTitle=el;exports.NavigationToggle=al;exports.OUTLINE_BUTTON_LEFT_OFFSET=fa;exports.OUTLINE_BUTTON_RESERVED_SPACE=P5;exports.OUTLINE_LEFT_OFFSET=$i;exports.OUTLINE_RESERVED_SPACE=E5;exports.PageIndicator=Af;exports.PageNumberTranslationContext=Ic;exports.PaginatedDocxEditor=ff;exports.PaginatedDocxEditorShell=d3;exports.REVIEW_MARKERS_GUTTER=ta;exports.REVIEW_PANE_GUTTER=fi;exports.RULER_WIDTH=ma;exports.ReviewRailContext=_t;exports.Slot=j;exports.TitleBar=xf;exports.TitleBarRight=Wc;exports.Toolbar=Ff;exports.ToolbarButton=zt;exports.ToolbarContext=In;exports.ToolbarGroup=lo;exports.ToolbarImageProperties=Yr;exports.VERSION=AT;exports.VerticalRuler=zi;exports.definePopup=FS;exports.editorStateActiveSubscriptionCount=nE;exports.isFieldLink=Ra;exports.navigationPaneOverlays=wc;exports.navigationPaneReservation=ha;exports.navigationShift=kc;exports.normalizeImageBytes=Nl;exports.notificationYieldsToTask=Yf;exports.provideDocxEditor=SM;exports.reviewGutter=S0;exports.useBookmarkDialog=Nw;exports.useBookmarks=Ou;exports.useChromeTranslate=Vf;exports.useCommentDraftRequest=$L;exports.useContentControl=bo;exports.useContentControlInstance=wl;exports.useContentControlWidget=st;exports.useContextMenuTarget=db;exports.useDocumentOutline=Dc;exports.useDocumentSearch=Rc;exports.useDocxEditor=H;exports.useDocxSource=NL;exports.useEditorCaret=qL;exports.useEditorCommand=ie;exports.useEditorEvent=Tm;exports.useEditorHostDocument=Lm;exports.useEditorSnapshot=D3;exports.useEditorState=W;exports.useEditorValueCommand=ii;exports.useFontFamily=Vs;exports.useFonts=OL;exports.useGoToBookmark=Sc;exports.useHeaderFooterState=df;exports.useHighlightAt=nF;exports.useHighlights=YL;exports.useHistoryGroup=L3;exports.useHyperlinkPopup=Fd;exports.useHyperlinkPopupInstance=Pl;exports.useNavigationPane=Mc;exports.useNavigationShift=_n;exports.useNotePropertiesState=Vu;exports.useNoteScopeState=$u;exports.useOpenFailure=uC;exports.usePageSetup=Wn;exports.usePageSetupDialog=Yk;exports.useParagraphDialog=cw;exports.useParagraphFormat=Eu;exports.useParagraphIndent=zm;exports.useParagraphStyle=Gs;exports.useReviewAuthors=hi;exports.useReviewGutter=pn;exports.useRevisionMarkupDialog=PS;exports.useScopeClassName=Nt;exports.useScopedChromeAnchor=ni;exports.useSplitCellDialog=Uw;exports.useTableBorderTargetLabel=wv;exports.useTextFormFieldDialog=Xw;exports.useToolbarContext=HE;exports.useToolbarLabel=ee;exports.useToolbarLabelFor=vl;exports.useTranslation=L;exports.useWatermark=Lu;exports.useWatermarkDialog=Vb;exports.useZoom=am;
|