@docx-editor.dev/react 2.32.0 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +47 -12
- package/dist/index.d.ts +47 -12
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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:[`
|
|
1
|
+
'use strict';var Bt=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 Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var Fe__namespace=/*#__PURE__*/_interopNamespace(Fe);var $f={version:"2.33.0"};var LT=$f.version;function Vf(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{r++;for(let u of o)u();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,u])=>u));}));};return {register(u,g){t.has(u)||t.set(u,n++),e.set(u,g),m();},unregister(u){e.delete(u)&&m();},connect(u){i=u,u&&m();},current:()=>c().map(([,u])=>u),setContainer(u){l?.();for(let g of a)g.setCustomized(false);a=[],l=u?editor.observeUnsupportedElements(u,g=>{a=g,d();}):void 0,d();},subscribe(u){return o.add(u),()=>o.delete(u)},snapshot:()=>r,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>editor.unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var hr=Bt.createContext(null);function Gf(e){return Bt.Children.toArray(e).some(t=>Bt.isValidElement(t)&&t.type===Bt.Fragment?Gf(t.props.children):typeof t!="string"||t.trim().length>0)}function jf({host:e,children:t}){let o=Gf(t);return Bt.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function dd({match:e,layout:t,includePartial:o,children:n}){let r=Bt.useContext(hr);if(!r)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=Bt.useRef(Symbol("unsupported-element-declaration")).current;return Bt.useSyncExternalStore(r.subscribe,r.snapshot,r.snapshot),Bt.useLayoutEffect(()=>{r.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[r,i,e,t,o]),Bt.useLayoutEffect(()=>()=>r.unregister(i),[r,i]),r.hosts(i).map(a=>jsxRuntime.jsx(jf,{host:a,children:n({element:a.unsupported})},a.key))}var ud=Bt.createContext(i18n.en),pd=Bt.createContext("en"),md=Bt.createContext("ltr"),fd=Bt.createContext(void 0);function yr({i18n:e,dir:t,children:o}){let n=Bt.useContext(ud),r=Bt.useContext(pd),i=Bt.useContext(md),a=Bt.useContext(fd),l=typeof e?._lang=="string"?e._lang:r,s=i18n.chromeDirection(t,e,a),c=s??i18n.catalogDirection(e)??i,d=Bt.useMemo(()=>i18n.deepMerge(n,e),[n,e]);return jsxRuntime.jsx(pd.Provider,{value:l,children:jsxRuntime.jsx(md.Provider,{value:c,children:jsxRuntime.jsx(fd.Provider,{value:s,children:jsxRuntime.jsx(ud.Provider,{value:d,children:o})})})})}function F(){let e=Bt.useContext(ud),t=Bt.useContext(pd),o=Bt.useContext(md);return {t:Bt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function at(){return Bt.useContext(fd)}function Jf(e){let{t}=F();return Bt.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var gd=Bt.createContext(null);function L(){return Bt.useContext(gd)}function vl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var Nt=Bt.createContext(null);var bd=0,hd=false,yd=false,Cl=[],Tl=null;function eg(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Tl||(Tl=new MessageChannel,Tl.port1.onmessage=()=>{let t=Cl;Cl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),Cl.push(e),Cl.length===1&&Tl.port2.postMessage(null);}function tg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(hd||(hd=true,bd+=1,queueMicrotask(()=>{hd=false;}),yd||(yd=true,eg(()=>{yd=false,bd=0;}))),bd>16)}function og(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};tg()?eg(o):queueMicrotask(o);}}var nE=()=>{},vd=0;function rE(){return vd}function Da(e){return og(e)}function K(e,t=Object.is,o){let n=L(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=Bt.useCallback(d=>{if(!n)return nE;let m=false;vd++,r?.();let u=Da(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,vd--,i?.();for(let p of g)p();}},[n,r,i]),l=Bt.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=Bt.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=Bt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return Bt.useSyncExternalStore(a,s,c)}function sE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function cE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=sE(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 X({children:e,...t}){let o=Bt.Children.only(e);if(!Bt.isValidElement(o))return null;let n=o.props,r=cE(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);}),Bt.cloneElement(o,r)}var ag=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function Tt(){let e=Bt.createContext(null),t=new Map,o=v=>{let b=t.get(v.type);return b==="field"?`field:${v.props.name}`:b};function n(v,b){Bt.Children.forEach(v,y=>{Bt.isValidElement(y)&&(b(y),n(y.props.children,b));});}function r(){let v=Bt.useContext(e);if(!v)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return v.state}function i(v,b){return Bt.Children.map(v,y=>{if(!Bt.isValidElement(y))return y;let C=ag(y.props);return C&&b.has(C)?b.get(C):y.props.children===void 0?y:Bt.cloneElement(y,{children:i(y.props.children,b)})})}function a(v){function b(y){let C=Bt.useContext(e);if(!C||y.hidden)return null;let T=v==="field"?`field:${y.name}`:v,x=C.defaults.get(T);if(!x)return y.children??null;let{children:E,asChild:P,className:k,style:w,hidden:D,name:M,...H}=y,I={...H,...x.props,className:[x.props.className,k].filter(Boolean).join(" "),style:{...x.props.style,...w}};if(P){let{children:A,className:S,style:_,...B}=I;return jsxRuntime.jsx(X,{...B,...k?{className:k}:{},...w?{style:w}:{},children:E})}return Bt.cloneElement(x,I,E===void 0?i(x.props.children,C.overrides):E)}return t.set(b,v),b}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:v,children:b,preset:y=true,state:C}){let T=new Map;n(v,k=>{let w=ag(k.props);w&&T.set(w,k);});let x=new Map;n(b,k=>{let w=o(k);w&&x.set(w,k);});let E=k=>Bt.Children.toArray(k).flatMap(w=>Bt.isValidElement(w)&&w.type===Bt.Fragment?E(w.props.children):[w]),P=E(b).filter(k=>!Bt.isValidElement(k)||!o(k));return jsxRuntime.jsx(e.Provider,{value:{defaults:T,overrides:x,state:C},children:y?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(v,x),P]}):b})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:h,useState:r,part:v=>a(v)}}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=Bt.useRef(null),p=l??g,f=Bt.useRef(i);f.current=i;let[h,v]=Bt.useState(false);return Bt.useLayoutEffect(()=>{let b=p.current;if(!b)return;v(!b.parentElement?.closest(".docx-editor"));let y=b.ownerDocument.activeElement,C=()=>{b.open&&b.close?.();};return d?.addEventListener("abort",C),typeof b.showModal=="function"?b.showModal():b.setAttribute("open",""),(b.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??b.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",C),typeof b.close=="function"&&b.open&&b.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:b=>{b.preventDefault(),f.current();},onMouseDown:b=>b.stopPropagation(),onClick:b=>{if(c&&b.target===b.currentTarget){let y=b.currentTarget.getBoundingClientRect();(b.clientX<y.left||b.clientX>y.right||b.clientY<y.top||b.clientY>y.bottom)&&f.current();}b.stopPropagation();},onKeyDown:b=>{b.key==="Escape"&&!b.nativeEvent.isComposing?(b.preventDefault(),f.current()):editor.trapTabWithin(b.currentTarget,b.nativeEvent)?b.preventDefault():!b.nativeEvent.isComposing&&!b.defaultPrevented&&a?.(b),b.stopPropagation();},children:s})}function po(e,t){let o=L(),n=Sd(),r=Bt.useRef(null);return Bt.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 Sd(){let e=L(),t=Bt.useCallback(o=>{if(!e)return ()=>{};let n=true,r=Da(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return Bt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function ig(){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 kd=Bt.createContext(null);function Nn(){return Bt.useContext(kd)}var lg=()=>0,wd=()=>()=>{};function Fn(){let e=Nn(),t=Bt.useCallback(n=>e?e.subscribeShift(n):wd(),[e]),o=Bt.useCallback(()=>e?e.getShift():0,[e]);return Bt.useSyncExternalStore(t,o,lg)}function sg(){let e=Nn(),t=Bt.useCallback(n=>e?e.subscribeReservation(n):wd(),[e]),o=Bt.useCallback(()=>e?e.getReservation():0,[e]);return Bt.useSyncExternalStore(t,o,lg)}function Se(){let e=Nn(),t=Bt.useCallback(r=>e?e.subscribeViewport(r):wd(),[e]),o=Bt.useCallback(()=>e?e.getViewport():null,[e]),n=Bt.useCallback(()=>null,[]);return Bt.useSyncExternalStore(t,o,n)}function Lo(e,t,o){let n=Se(),r=Bt.useRef({close:o,viewport:n});r.current={close:o,viewport:n},Bt.useEffect(()=>{let i=e.current;if(!(!t||!i))return DE(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function DE(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 Dd(e){return typeof e=="string"}function se(e){let t=L(),{t:o}=F(),n=Dd(e)?e:editor.editorCommandKey(e),r=Bt.useRef(e);r.current=e;let i=Bt.useCallback(s=>{let c=r.current;if(Dd(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=K(i,LE),l=Bt.useCallback(s=>{let c=editor.commandExecOptions(s),d=r.current;return Dd(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Bt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Ln=Bt.createContext({t:void 0,onSave:void 0});function AE(){return Bt.useContext(Ln)}function Sl(e){let{t}=F();return o=>e?.(o)??t(o)}function ne(){let{t:e}=Bt.useContext(Ln);return Sl(e)}var ZE=()=>()=>{},KE=()=>true,qE=()=>false;function Ho(){let e=Bt.useSyncExternalStore(ZE,KE,qE);return Bt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function UE(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function zE(){try{return undefined}catch{return}}function gt(){let e=typeof process<"u";return UE({viteEnv:zE(),nodeEnv:e?"production":void 0,hasProcess:e})}var pg=new Set;function on(e){!gt()||pg.has(e)||(pg.add(e),console.warn(`[docx-editor] ${e}`));}function mg(e){on(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function fg(e){on(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function gg(){on("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function bg(){on("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function hg(e){on(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function yg(){on("A Toolbar.Button has no slotId, so it renders nothing.");}function te(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 re(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 U(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function jE(e){if(e.slotId)return e.slotId;if(e.slot)return hg(e.slot),e.slot;yg();}function Ao(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=jE(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=se(a),u=ne(),g=Ho();if(i||!a)return null;let p=te(a),f=g(u(p?.labelKey??a)),h=editor.chromeSlotIsToggle(a),v={onClick:()=>l(),onMouseDown:U,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(X,{...v,children:r}):jsxRuntime.jsx("button",{type:"button",...v,children:t??r??re(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"}],xg=[{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"}],vg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],kl=["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"],nn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Zt=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?[Zt(5),Zt(15),Zt(25),Zt(35),Zt(50)]:o===0?[nn(50),nn(35),nn(25),nn(15),nn(5)]:o>=.8?[Zt(10),Zt(25),Zt(50),Zt(75),Zt(90)]:[nn(80),nn(60),nn(40),Zt(25),Zt(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 vr({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:U,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(vr,{value:a,css:`#${a.toLowerCase()}`,title:t(kl[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(vr,{value:d,css:`#${d.toLowerCase()}`,title:`${t(kl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function sS(e){let{apply:t,label:o,current:n}=e,[r,i]=Bt.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(vr,{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:U,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Md({apply:e,current:t}){let o=L(),n=ne(),r=o?.getDocumentThemeColors()??[],i=r.length===kl.length?r.map(l=>l.hex):vg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(sS,{apply:e,label:n,current:a,themeHexes:i})}var cS=xg.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(vr,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Cg(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=L(),{isEnabled:u,disabledReason:g}=se(t),p=ne(),[f,h]=Bt.useState(false),[v,b]=Bt.useState(o),y=Bt.useRef(null);Lo(y,f,()=>h(false));let C=K(w=>{if(a){let D=w.formatting?.color;return D&&D.kind==="hex"?D.value.toUpperCase():null}return w.formatting?.highlight??null}),T=m?.getDocumentThemeColors()??[],x=T.length===kl.length?T.map(w=>w.hex):vg;Bt.useEffect(()=>{if(f)return editor.listenForOutsidePress({popup:y.current,close:()=>h(false)})},[f]);let E=Bt.useCallback(w=>{if(h(false),!m)return;m.focus();let D=editor.commandForSlotValue(t,w);D&&m.can(D).ok&&(m.exec(D),w!==r.value&&b(w));},[m]),P=Bt.useMemo(()=>te(t),[]);if(c)return null;let k=p(P?.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":k,title:g??k,onMouseDown:U,onClick:()=>E(v),children:[d??re(P?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(v)},"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":k,title:g??k,onMouseDown:U,onClick:()=>h(w=>!w),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":k,onMouseDown:U,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,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:C,themeHexes:x})]}):null]})},{docxSlot:t})}var uS=new Map(xg.map(e=>[e.value,e.css])),_d=Cg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Md,{apply:e.apply,current:e.current})}),Id=Cg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>uS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(dS,{...e})});var Fd=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Dl({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=Bt.useId(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.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]),Bt.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:Fd(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:Fd(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(vr,{value:g,css:Fd(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var Tg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],yS=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Eg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Tg,"hidden","caret","pound"]:Tg,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(Dl,{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(Dl,{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(Dl,{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=Bt.useId(),{t:a}=F(),l=f=>a(`revisionMarkup.${f}`),s=Bt.useCallback(f=>e.subscribe(f),[e]),c=Bt.useCallback(()=>e.get(),[e]),d=Bt.useSyncExternalStore(s,c,c),[m,u]=Bt.useState(e.signal.aborted),g=Bt.useRef(null);Bt.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:Eg(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 Ra=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 Hd(e){let t=L(),o=Bt.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return Bt.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Bt.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Ma({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=F();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 _a({open:e,pending:t,error:o,url:n,onClose:r,className:i,style:a,children:l}){let{t:s}=F();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 xt={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Cr({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:xt.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 Tr({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}=F();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:xt.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:U,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 LS(e){return t=>Bt.createElement(e,t)}var Dg=new WeakMap,HS=0;function Ee(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=Dg.get(o);return r===void 0&&Dg.set(o,r=++HS),Bt.createElement(Bt.Fragment,{key:r},n)}var Od=Bt.createContext(void 0),St=()=>Bt.useContext(Od);function Er(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 Na(e){return e.paragraphId===""}var An=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 Fa=Bt.createContext(null);function Wd(){let e=Bt.useContext(Fa),t=Ml(e===null);return e??t}function Ml(e=true){let t=L(),o=Se(),n=Bt.useRef(o);n.current=o;let[r,i]=Bt.useState(An),a=Bt.useRef(null),l=Bt.useRef(r);l.current=r;let s=K($S),c=t?t.can({type:"insertText",text:""}).ok:false,d=Bt.useCallback(()=>{let T=a.current;T&&(T.editor.releaseSelection(T.pin),a.current=null);},[]),m=Bt.useCallback((T,x)=>{d(),i({mode:T?"reading":"editing",link:T??null,anchor:x??null,text:T?.text??"",url:T?T.kind==="internal"?`#${T.anchor??""}`:T.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,d]),u=Bt.useCallback(()=>{d(),i(An);},[d]);Bt.useEffect(()=>d,[d]);let g=Bt.useCallback(()=>{let T=VS(n.current);d();let x=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(x&&Na(x)){m(x,T);return}if(x){i({mode:"editing",link:x,anchor:T,text:x.text,url:x.kind==="internal"?`#${x.anchor??""}`:x.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let E=t?.query({type:"selectedText"})??"",P=t?.retainSelection()??null;t&&P&&(a.current={editor:t,pin:P}),i({mode:"editing",link:null,anchor:T,text:E,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,m,d]);Bt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:T=>m(T.link,{left:T.rect.left,top:T.rect.bottom}),onRequest:g})},[t,e,m,g]),Bt.useEffect(()=>{let T=l.current;if(T.mode!=="reading"||!T.link)return;let x=Na(T.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;x&&x.id===T.link.id||i(An);},[s,t]),Bt.useEffect(()=>{let T=l.current;if(T.mode!=="editing"||T.link)return;let x=t?.surface;!x||x.retainedSelection()||i(An);},[s,t]);let p=Bt.useCallback(async()=>{let T=l.current.link?.href;if(!T)return false;try{await editor.hostWindowOf(n.current).navigator.clipboard.writeText(T);}catch{return false}return i(x=>({...x,copied:true})),true},[]),f=Bt.useCallback(()=>{i(T=>({...T,mode:"editing",copied:false,error:false}));},[]),h=Bt.useCallback(T=>{i(x=>({...x,text:T,copied:false,error:false}));},[]),v=Bt.useCallback(T=>{i(x=>({...x,url:T,copied:false,error:false}));},[]),b=Bt.useCallback(()=>{let T=l.current,x=t?.surface?.hyperlinks;if(!x)return false;let E=T.url.trim();if(E.length===0)return i(w=>({...w,error:true})),false;let P=E.startsWith("#");return x.applyHyperlink({...P?{anchor:E.slice(1)}:{url:E},...T.text.trim().length>0?{text:T.text}:{}})?(u(),true):(i(w=>({...w,error:true})),false)},[t,u]),y=Bt.useCallback(()=>{let T=t?.surface?.hyperlinks,x=l.current.link;if(!T)return false;let E=T.removeHyperlink(x?.id);return E&&u(),E},[t,u]),C=Bt.useCallback(()=>{let T=t?.surface?.navigation,x=l.current.link;if(!T||!x)return false;if(x.kind==="internal"){let P=x.anchor?T.goToBookmark(x.anchor):false;return P&&i(An),P}let E=T.openExternal(x.href);return E&&i(An),E},[t]);return Bt.useMemo(()=>({state:r.mode==="closed"?An:{...r,canEdit:c},open:m,openAtCaret:g,close:u,copy:p,beginEdit:f,setText:h,setUrl:v,commitEdit:b,unlink:y,openTarget:C}),[r,c,m,g,u,p,f,h,v,b,y,C])}function Bn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var _l=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=Bt.useRef(null),{state:l,close:s}=i;Bt.useEffect(()=>{if(l.mode==="closed")return;let f=b=>{b.key==="Escape"&&(b.preventDefault(),s());},h=editor.hostDocumentOf(a.current);h.addEventListener("keydown",f);let v=editor.listenForOutsidePress({popup:h,contains:b=>a.current?.contains(b)===true,close:s});return ()=>{h.removeEventListener("keydown",f),v();}},[l.mode,s]);let[c,d]=Bt.useState(null);Bt.useLayoutEffect(()=>{let f=l.anchor,h=a.current;if(!f||!h){d(null);return}let v=h.offsetParent;if(!v){d(null);return}let{left:b,top:y}=Er(v,f.left,f.top),C=Math.max(0,v.scrollWidth-h.offsetWidth);d({left:Math.max(0,Math.min(b,C)),top:y});},[l.anchor]);let{t:m}=F(),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:Bn,style:c??void 0,"aria-label":u};return l.mode==="closed"?null:t?jsxRuntime.jsx(X,{...p,children:n}):jsxRuntime.jsx("div",{...p,children:g})}function lP({children:e}){let{state:t}=go(),o=Bt.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($d,{})),n("Error",jsxRuntime.jsx(Gd,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(Vd,{})),n("Cancel",jsxRuntime.jsx(jd,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&Na(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(Kd,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(qd,{})),r?n("Edit",jsxRuntime.jsx(Ud,{})):null,r?n("Unlink",jsxRuntime.jsx(zd,{})):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===Bt.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 Bt.useContext(Fa)??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 Kd({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=go(),{t:a}=F();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=jsxRuntime.jsx("bdi",{dir:s?void 0:"ltr",children:c}),m=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),u={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:m,onMouseDown:Bn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(X,{...u,className:e,children:n}):l?jsxRuntime.jsxs("span",{...u,children:[n??d,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxRuntime.jsxs("button",{...u,children:[n??d,_l(aP)]})}Kd.docxHyperLinkPart="Url";function qd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=go(),{t:l}=F();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:Bn,onClick:()=>{a();}};return t?jsxRuntime.jsx(X,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??_l(oP)})}qd.docxHyperLinkPart="Copy";function Ud({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=go(),{t:a}=F();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:Bn,onClick:()=>i()};return t?jsxRuntime.jsx(X,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??_l(nP)})}Ud.docxHyperLinkPart="Edit";function zd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=go(),{t:a}=F();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:Bn,onClick:()=>i()};return t?jsxRuntime.jsx(X,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??_l(rP)})}zd.docxHyperLinkPart="Unlink";function $d({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=go(),{t:l}=F(),s=Bt.useRef(null),c=Bt.useId(),d=Bt.useId();Bt.useEffect(()=>{o.mode==="editing"&&(s.current?.focus({preventScroll:true}),s.current?.select());},[o.mode]);let m=Bt.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,dir:o.text?"auto":void 0,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,dir:"ltr",placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:m})]})}$d.docxHyperLinkPart="Fields";function Vd({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=go(),{t:a}=F();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:Bn,onClick:()=>i()};return t?jsxRuntime.jsx(X,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}function Gd({className:e,hidden:t}){let{state:o}=go(),{t:n}=F();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")})}Gd.docxHyperLinkPart="Error";Vd.docxHyperLinkPart="Apply";function jd({className:e,asChild:t,hidden:o,children:n}){let{close:r}=go(),{t:i}=F();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:Bn,onClick:()=>r()};return t?jsxRuntime.jsx(X,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:n??a})}jd.docxHyperLinkPart="Cancel";var La=Object.assign(iP,{Url:Kd,Copy:qd,Edit:Ud,Unlink:zd,Fields:$d,Error:Gd,Apply:Vd,Cancel:jd});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 Xd(e,t){return !e.ok&&e.code===t}function bo(){let e=Bt.useContext(Jd),t=Il();return e??t}function Il(){let e=L(),[t,o]=Bt.useState(false),[n,r]=Bt.useState(false),[i,a]=Bt.useState(false),l=K(E=>E),s=e?.surface??null,c=s?.contentControls;Bt.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=Bt.useMemo(()=>{if(!e)return null;let E=c?.atCaret()??null;if(E){let S=c?.disabledReason(E.id,"edit")??null,_=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)||S==="locked",removalLocked:mP(E.effectiveLock)||_==="locked",placeholder:E.placeholder,bound:E.bound||S==="bound",effectiveLock:E.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,D=e.can({type:"setContentControlValue",value:""}),M=e.can({type:"removeContentControl"}),H=P.locked===true||k==="locked"||Xd(D,"locked"),I=k==="bound"||Xd(D,"bound"),A=w==="locked"||Xd(M,"locked");return {id:P.id,tag:P.tag??null,alias:P.alias??null,controlType:P.controlType,locked:H,removalLocked:A,placeholder:false,bound:I,effectiveLock:null}},[e,l,c]),m=Bt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=Bt.useCallback(E=>{c?.setShowAll(E),r(E);},[c]),g=Bt.useCallback(E=>{c?.setFormFill(E),a(E);},[c]),p=Bt.useCallback(()=>u(!n),[u,n]),f=Bt.useCallback(()=>g(!i),[g,i]),h=Bt.useCallback(()=>o(true),[]),v=Bt.useCallback(()=>o(false),[]),b=Bt.useCallback(()=>o(E=>!E),[]),y=Bt.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 E=e.can({type:"setContentControlValue",value:""});return E.ok?null:E.reason},[d,c,e]),C=Bt.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 E=e.can({type:"removeContentControl"});return E.ok?null:E.reason},[d,c,e]),T=Bt.useCallback(E=>{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:E})},[e,c,d]),x=Bt.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 P=c.disabledReason(E,"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(E)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return Bt.useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:y===null&&d!==null,canRemove:C===null&&d!==null,setValueDisabledReason:y,removeDisabledReason:C,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:v,toggleInspector:b,remove:x,setValue:T}),[d,m,n,i,t,y,C,u,p,g,f,h,v,b,x,T])}var Jd=Bt.createContext(null);function Qd(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Fg=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"})}),xP="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",vP="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},Lg={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 Sr({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=Bt.useRef(null),l=Bt.useId(),{t:s}=F(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(Bt.useEffect(()=>{if(!d)return;let f=b=>{b.key==="Escape"&&(b.preventDefault(),m());},h=editor.hostDocumentOf(a.current);h.addEventListener("keydown",f);let v=editor.listenForOutsidePress({popup:h,contains:b=>a.current?.contains(b)===true,close:m});return ()=>{h.removeEventListener("keydown",f),v();}},[d,m]),Bt.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hg,{}),jsxRuntime.jsx(Ag,{}),jsxRuntime.jsx("div",{style:kP,children:jsxRuntime.jsx(Og,{})}),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=>{Qd(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(X,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function Hg({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=bo(),{t:i}=F();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:{...Lg,padding:4,border:"none",background:"transparent"},onMouseDown:Qd,onClick:()=>r(),children:Fg(xP)})]});return t?jsxRuntime.jsx(X,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function Ag({className:e,asChild:t,hidden:o,children:n}){let{control:r}=bo(),{t:i}=F();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(Sr,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Sr,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Sr,{label:i("contentControl.inspectorPanel.type"),value:i(wP(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Sr,{label:i("contentControl.inspectorPanel.lock"),value:i(DP(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Sr,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Sr,{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(X,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function Og({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=bo(),{t:c}=F();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:Lg,onMouseDown:Qd,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??Fg(vP),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(X,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var Oa=Object.assign(RP,{Header:Hg,Fields:Ag,Remove:Og});var FP=e=>e;function ru(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Ba(){let e=L(),{t}=F(),[o,n]=Bt.useState(null),[r,i]=Bt.useState(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(null),c=Bt.useId(),d=Bt.useId(),m=Bt.useId(),u=o?.activation??null,g=K(FP),p=Bt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let y=e.surface.equations.can(u.equation.id,"replace"),C=e.surface.equations.can(u.equation.id,"remove"),T=y.ok?C.ok?null:C.reason:y.reason;return {replaceEnabled:y.ok,removeEnabled:C.ok,reason:T?i18n.localizeDisabledReason(T,t):null}},[u,e,g,t]),f=Bt.useCallback((y=false)=>{s.current?.(),s.current=null,n(null),y&&e&&queueMicrotask(()=>e.focus());},[e]);Bt.useEffect(()=>{if(!e)return;let y=e.setEquationChrome({onPopover:C=>{s.current?.();let T=e.surface;if(T&&typeof T.retainSelection=="function"){let x=T.retainSelection();s.current=()=>T.releaseSelection(x);}else s.current=null;n({activation:C,mountGeneration:e.mountGeneration,draft:C.equation.linear,error:false});}});return ()=>{y(),s.current?.(),s.current=null,n(null);}},[e,f]),Bt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),Bt.useEffect(()=>{if(!o)return;let y=a.current,C=y?.ownerDocument,T=C?.defaultView;if(!y||!C||!T)return;let x=P=>{P.key==="Escape"&&(P.preventDefault(),f(true));},E=P=>{editor.isDomNode(P.target)&&y.contains(P.target)||f();};return C.addEventListener("keydown",x),C.addEventListener("pointerdown",E,true),()=>{C.removeEventListener("keydown",x),C.removeEventListener("pointerdown",E,true);}},[o,f]),Bt.useLayoutEffect(()=>{if(!u){i(null);return}let y=a.current;if(!y)return;let C=y.offsetParent;if(!C){i(null);return}let T=u.rect,x=Er(C,T.left,T.bottom),E=Math.max(0,C.scrollWidth-y.offsetWidth);i({left:Math.max(0,Math.min(x.left,E)),top:x.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let h=Bt.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(C=>C&&{...C,error:true}),y},[e,o,f,p.replaceEnabled]),v=Bt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let y=e.surface.equations.removeEquation(o.activation.equation.id);return y?f(true):n(C=>C&&{...C,error:true}),y},[e,o,f,p.removeEnabled]);if(!o)return null;let b=[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:ru,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":b||void 0,onChange:y=>n(C=>C&&{...C,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:ru,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:ru,onClick:v,children:t("equationPopup.delete")})]})]})}var Zg="review.comments",au="review.addComment";function Kg(e){return e!==Zg?e:(on(`The context-menu row "${Zg}" is now "${au}". The old id still works in this release; write "${au}".`),au)}function wr(e,t){if(!Bt.isValidElement(e)||e.type!==Bt.Fragment)return null;let n=Bt.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function Nl({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 Bt.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 v=n(f,h);d.add(v);let b=a?.(f),y=b?m(b):void 0,C=s.get(v);return jsxRuntime.jsx(Bt.Fragment,{children:C??i(f,h,y)},v)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(Bt.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var OP="review.addComment",BP=e=>e.editingMode==="viewing";function Fl(e){let{isEnabled:t,disabledReason:o}=se(OP),n=K(BP);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var Wa=Bt.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}),Dr="docx-menubar-more",Ll=Bt.createContext({measuring:false,overflow:new Set,inMore:false});function $g(){return Bt.useContext(Ll)}function it(){return Bt.useContext(Wa)}function Re(){let{t:e}=it(),{t}=F();return o=>e?.(o)??t(o)}var Rr=Bt.createContext(-1);var WP='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Wn(e){return [...e.querySelectorAll(WP)].filter(t=>t.closest('[role="menu"]')===e)}function su(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 cu(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 Vg(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var ln="data-toolbar-group",Zn="data-toolbar-fixed",Ka="data-toolbar-more",QP=34,Hl=new Set;function Al(e,t,o){let n=Bt.useRef(null),r=Bt.useRef(new Map),i=Bt.useRef(QP),[a,l]=Bt.useState(Hl),s=Bt.useRef(a);s.current=a;let c=Bt.useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),m=o.join("\0"),u=Bt.useCallback(()=>{let p=n.current;if(!p||!e)return;let f=editor.hostWindowOf(p),h=f.getComputedStyle(p),v=editor.readColumnGap(h),b=editor.readAvailableWidth(p,h),y=p.querySelector(".docx-toolbar__separator"),C=v*2;if(y){let w=f.getComputedStyle(y),D=editor.readInlineMargins(w);C=editor.separatorLeadingCost(y.offsetWidth,D.start,D.end,v);}for(let w of p.querySelectorAll(`[${ln}]`)){let D=w.getAttribute(ln);D&&w.offsetWidth>0&&r.current.set(D,editor.collapsibleGroupCost(w.offsetWidth,C));}let T=0;for(let w of p.querySelectorAll(`[${Zn}]`))w.offsetWidth>0&&(T+=editor.trailingGapCost(w.offsetWidth,v));let x=p.querySelector(`[${Ka}]`);x&&x.offsetWidth>0&&(i.current=editor.trailingGapCost(x.offsetWidth,v));let E={available:b,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:T,more:i.current,previous:s.current,hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS},k=s.current.size===0&&editor.controlsOverflow(p,h)===false?Hl:editor.toolbarOverflowGroups(E);editor.sameOverflow(k,s.current)||(s.current=k,l(k));},[e]),g=Bt.useCallback(p=>{n.current=p;},[]);return Bt.useLayoutEffect(()=>{if(!e){s.current.size>0&&(s.current=Hl,l(Hl));return}u();},[e,d,u,m]),Bt.useEffect(()=>{let p=n.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let h=0,v=new f.ResizeObserver(()=>{h===0&&(h=f.requestAnimationFrame(()=>{h=0,u();}));});v.observe(p),p.parentElement&&v.observe(p.parentElement);for(let b of p.querySelectorAll(`[${ln}], [${Zn}]`))v.observe(b);return ()=>{h!==0&&f.cancelAnimationFrame(h),v.disconnect();}},[e,d,u,m,a]),{attach:g,overflow:a}}function Xg(e,t,o){let n=e.overflow.has(t),r=t===Dr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[ln]:t}:{},...r?{[Ka]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Jg(e,t,o){let[n,r]=Bt.useState(void 0);return Bt.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 eb=12700,Qg=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 Ol(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??Qg,n.dpiY??Qg);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function sn(e){return Math.round(e/eb*100)/100}function qa(e){return Math.round(e*eb)}function du({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=F();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 ob="image/png,image/jpeg,image/gif",pu=Bt.createContext(null);function rb(){let e=Bt.useContext(pu);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Ua(){return Bt.useContext(pu)}function Wl({children:e}){let t=L(),{t:o}=F(),n=Bt.useRef(null),r=Bt.useRef(false),i=St(),[a,l]=Bt.useState(null),s=Bt.useRef(null),c=Bt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=K(c,(y,C)=>y.enabled===C.enabled&&y.disabledReason===C.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=Bt.useCallback(async y=>{if(!t||r.current)return;let C=Ol(y);if(!C.ok){l(o(C.reasonKey));return}let T={type:"insertImage",data:C.bytes,mime:C.mime,widthPoints:C.widthPoints,heightPoints:C.heightPoints};r.current=true;try{let x=await editor.executeImageCommand(t,T);x.ok?t.focus():l(i18n.localizeDisabledReason(bk(x.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=Bt.useCallback(async y=>{let C=y?.[0];if(!C)return;let T=await C.arrayBuffer();await g(new Uint8Array(T));},[g]),f=Bt.useCallback(async y=>{if(!y)return;let C=[...y.files].find(T=>T.type.startsWith("image/"));if(C){await p([C]);return}for(let T of y.items){if(T.kind!=="file"||!T.type.startsWith("image/"))continue;let x=T.getAsFile();if(!x)continue;let E=await x.arrayBuffer();await g(new Uint8Array(E));return}},[g,p]),h=Bt.useCallback(()=>{if(!m)return;let y=n.current,C=t?editor.editorHostDocument(t):null;if(!C||!y||y.ownerDocument===C){y?.click();return}s.current?.remove();let T=C.createElement("input");T.type="file",T.accept=ob,T.hidden=true,T.tabIndex=-1,T.setAttribute("aria-hidden","true");let x=()=>{T.remove(),s.current===T&&(s.current=null);};T.addEventListener("change",()=>{p(T.files).finally(x);},{once:true}),T.addEventListener("cancel",x,{once:true}),C.body.append(T),s.current=T,T.click();},[t,m,p]),v=Bt.useCallback(async y=>{let C=y.currentTarget;await p(C.files),C.value="";},[p]),b=Bt.useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:v}),[h,p,f,m,u,v]);return jsxRuntime.jsxs(pu.Provider,{value:b,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:ob,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:v,onMouseDown:y=>y.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Ee(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(du,{message:a,onClose:()=>l(null)}))]})}function Zl({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=rb(),l=ne();if(t)return null;let s=te("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:U,onClick:r};return o?jsxRuntime.jsx(X,{...d,children:n}):jsxRuntime.jsx("button",{...d,children:n??re(s?.paths)})}Zl.docxSlot="image.insert";var za=Object.assign(Zl,{docxSlot:"image.insert"});function bk(e){return e&&/\s/.test(e)?e:void 0}var mu=6,lb=6;function ql({slot:e,label:t,onInserted:o,className:n}){let r=L(),{isEnabled:i}=se(e),[a,l]=Bt.useState(null),[s,c]=Bt.useState({rows:1,cols:1}),d=Bt.useRef(null),m=Bt.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=Bt.useCallback(p=>{c(f=>{let h={rows:Math.min(lb,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(mu,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<=lb;p+=1){let f=[];for(let h=1;h<=mu;h+=1){let v=!!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,...v?{"data-filled":""}:{},"aria-label":`${h} \xD7 ${p}`,onMouseDown:U,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:mu});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 Ir({slot:e="table.insert",className:t}){let{setOpenMenu:o}=it(),n=Re(),r=Bt.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(ql,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Ek({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(editor.chromeProbeForSlot("insert.watermark")),r=it(),i=Re();if(t)return null;let a=te("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsxRuntime.jsx(Me,{slot:"insert.watermark",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Ul=Object.assign(Ek,{docxSlot:"insert.watermark"});var kk={type:"openGoTo",fromShortcut:true};function sb(){let e=se(kk),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(Kt,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function wk({className:e,hidden:t}){return jsxRuntime.jsx(Kt,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var zl=Object.assign(wk,{docxSlot:"insert.bookmark"});function Me(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=Bt.useId(),p=Bt.useContext(Rr),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:U,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 $a({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=Re();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 Vl(e){if(e.slotId)return e.slotId;if(e.slot)return mg(e.slot),e.slot;gg();}function Kt(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=Vl(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=se(i),{setOpenMenu:m}=it(),u=Re();if(r||!i)return null;let g=te(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(Me,{slot:i,icon:re(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})}Kt.docxMenuRow=true;function Va(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=it(),c=Re(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=te(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(Me,{slot:e,icon:re(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var gu=Va("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),bu=Va("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),hu=Va("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),yu=Va("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),xu=Va("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function Ak({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(editor.chromeProbeForSlot("file.pageSetup")),r=it(),i=Re();if(t)return null;let a=te("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsxRuntime.jsx(Me,{slot:"file.pageSetup",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function Ok({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(editor.chromeProbeForSlot("paragraph.dialog")),r=it(),i=Re();if(t)return null;let a=te("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsxRuntime.jsx(Me,{slot:"paragraph.dialog",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Bk=Object.assign(Ok,{docxSlot:"paragraph.dialog"}),vu=Object.assign(Ak,{docxSlot:"file.pageSetup"});function Wk({className:e,hidden:t}){let o=Ua(),n=it(),r=Re();if(t)return null;let i=te("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(Me,{slot:"image.insert",icon:re(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Cu=Object.assign(Wk,{docxSlot:"image.insert"});function Jt({labelKey:e,label:t,paths:o,className:n,children:r}){let i=Re(),[a,l]=Bt.useState(false),s=Bt.useRef(null),c=Bt.useRef(null),d=Bt.useId();t===void 0&&e===void 0&&bg();let m=t??i(e??""),[u,g]=Bt.useState(null);return Bt.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;!p||!f||!h||g(editor.placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:h.innerWidth,height:h.innerHeight},h.getComputedStyle(p).direction==="rtl"));},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{let f=editor.submenuKeys(editor.hostWindowOf(p.currentTarget).getComputedStyle(p.currentTarget).direction==="rtl");p.key===f.open&&editor.hostDocumentOf(s.current).activeElement===s.current?(p.preventDefault(),l(true),queueMicrotask(()=>{c.current&&Xt(Wn(c.current),"first");})):(p.key===f.close||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:U,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(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=Wn(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(Rr.Provider,{value:-1,children:r})}):null]})}function Zk({entry:e}){let{isEnabled:t}=se(e.slot),o=te(e.slot);return t?jsxRuntime.jsx(Jt,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(Ir,{slot:e.slot})}):jsxRuntime.jsx(Kt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Kn({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Ga({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Kn,{}):e.kind==="submenu"?jsxRuntime.jsx(Jt,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsxRuntime.jsx(Ga,{entry:o},n))}):e.slot==="file.open"?jsxRuntime.jsx(gu,{}):e.slot==="file.save"?jsxRuntime.jsx(bu,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(hu,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(yu,{}):e.slot==="file.print"?jsxRuntime.jsx(xu,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(vu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(Bk,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(Ul,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(zl,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(sb,{}):e.slot==="image.insert"?jsxRuntime.jsx(Cu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(Zk,{entry:e}):jsxRuntime.jsx(Kt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function mb(e){if(!Bt.isValidElement(e))return null;let t=wr(e,mb);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?Vl(e.props)??null:null}function Kk(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function ub(e,t,o){return Nl({entries:e??[],children:t,preset:o,keyOfEntry:Kk,keyOfChild:mb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsxRuntime.jsx(Ga,{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=$g(),g=Re(),p=Bt.useId(),f=Bt.useRef(null),h=Bt.useRef(null),v=Bt.useRef(false),b=Bt.useRef(false),y=editor.CHROME_MENUS.find(D=>D.id===e),C=s===e,T=Jg(C&&e===Dr,f,h);if(i)return null;let x=o??g(t??y?.labelKey??e),E=Xg(u,e,d);if(E.skip)return null;if(E.asSubmenu)return jsxRuntime.jsx(Jt,{labelKey:t??y?.labelKey??e,label:x,children:ub(y?.entries,l,a)});let P=ub(y?.entries,l,a),k=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":C,"aria-controls":C?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:E.tabStop?0:-1,...C?{"data-open":""}:{},...k?{"aria-label":x,title:x}:{},onMouseDown:U,onKeyDown:D=>{D.key==="ArrowDown"||D.key==="Enter"||D.key===" "||D.key==="ArrowUp"?(D.preventDefault(),v.current=true,c(e)):D.key==="Escape"&&C&&(D.preventDefault(),w());},onClick:()=>{if(b.current){b.current=false;return}c(C?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(b.current=true,c(e));},onMouseLeave:()=>{b.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,k?null:x]}),C?jsxRuntime.jsx("div",{ref:D=>{h.current=D,D&&v.current&&(v.current=false,Xt(Wn(D),"first"));},id:p,role:"menu","aria-label":x,style:T,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:D=>{let M=h.current;if(!M)return;let H=Wn(M),I=editor.hostDocumentOf(M).activeElement;D.key==="ArrowDown"?(D.preventDefault(),Yt(H,I,1)):D.key==="ArrowUp"?(D.preventDefault(),Yt(H,I,-1)):D.key==="Home"?(D.preventDefault(),Xt(H,"first")):D.key==="End"?(D.preventDefault(),Xt(H,"last")):D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),w()):D.key==="Tab"&&c(null);},children:jsxRuntime.jsx(Rr.Provider,{value:-1,children:P})}):null]})}function Tu(e){return Object.assign(o=>jsxRuntime.jsx(Qt,{id:e,...o}),{docxMenu:e})}var Eu=Tu("file"),Su=Tu("format"),Pu=Tu("insert");var Gl=Bt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Bo(){return Bt.useContext(Gl)}function gb(){return Bt.useContext(Gl).target}var zk=e=>e.pageSetup??null,$k=e=>e.editable;function qn(){let e=L(),t=K(zk),o=K($k),n=Bt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=Bt.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 Bt.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var wu=[{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}],vb=1440,jk=e=>Math.round(e/vb*100)/100,Yk=e=>Math.round(e*vb);function Xk(e,t){let o=Math.min(e,t),n=Math.max(e,t);return wu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var yb=12240,xb=15840,cn=1440;function Jk({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{pageSetup:s,isEnabled:c,apply:d}=qn(),[m,u]=Bt.useState(yb),[g,p]=Bt.useState(xb),[f,h]=Bt.useState("portrait"),[v,b]=Bt.useState(cn),[y,C]=Bt.useState(cn),[T,x]=Bt.useState(cn),[E,P]=Bt.useState(cn),[k,w]=Bt.useState(false),[D,M]=Bt.useState("document"),H=Bt.useRef(null),I=Bt.useRef("no");Bt.useEffect(()=>{if(!e){I.current="no";return}if(I.current==="yes"&&s===null){I.current="no";return}I.current==="yes"||I.current==="loading"&&s===null||(w(false),u(s?.pageWidthTwips??yb),p(s?.pageHeightTwips??xb),h(s?.orientation??"portrait"),b(s?.marginsTwips.top??cn),C(s?.marginsTwips.bottom??cn),x(s?.marginsTwips.left??cn),P(s?.marginsTwips.right??cn),M("document"),I.current=s===null?"loading":"yes");},[e,s]);let A=Bt.useCallback($=>{let V=wu[$];V&&(u(f==="landscape"?V.height:V.width),p(f==="landscape"?V.width:V.height));},[f]),S=Bt.useCallback($=>{$!==f&&(h($),u(g),p(m));},[f,m,g]),_=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let $=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:v,marginRightTwips:E,marginBottomTwips:y,marginLeftTwips:T,scope:D});w(!$),$&&t();},[c,l,d,m,g,f,v,E,y,T,D,t]);if(!e)return null;let B=Xk(m,g),Z=($,V,ce)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${$[0].toUpperCase()}${$.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${$}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:jk(V),onChange:O=>ce(Math.max(0,Yk(Number(O.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${$}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),ee={pageWidth:m,pageHeight:g,orientation:f,marginTop:v,marginBottom:y,marginLeft:T,marginRight:E,scope:D},j={pageWidth:u,pageHeight:p,orientation:S,marginTop:b,marginBottom:C,marginLeft:x,marginRight:P,scope:M},oe={values:ee,setValue($,V){j[$](V);},errors:k?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:_,cancel:t};return jsxRuntime.jsx(Be,{kind:"pageSetup",className:o,style:n,panelRef:H,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:$=>{$.key==="Escape"&&t(),$.key==="Enter"&&editor.isHTMLElementNode($.target)&&$.target.localName==="input"&&c&&($.preventDefault(),_());},children:jsxRuntime.jsx(yo.Composition,{state:oe,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:B,onChange:$=>A(Number($.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[wu.map(($,V)=>jsxRuntime.jsx("option",{value:V,children:a($.labelKey)},$.labelKey)),B<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:$=>S($.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")}),Z("top",v,b),Z("bottom",y,C),Z("left",T,x),Z("right",E,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:D,onChange:$=>M($.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:_,children:a("common.apply")})]})]}),children:r})})}var yo=Tt();function Qk(){return yo.useState()}var Un=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 nw={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},rw=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??nw;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}}},aw=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],iw=(e,t)=>aw.every(o=>e.disagrees[o]===t.disagrees[o]),lw=(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&&iw(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")),sw=e=>e.editable;function Du(){let e=L(),t=K(rw,lw),o=K(sw),n=Bt.useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=Bt.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 uw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{format:s,isEnabled:c,apply:d}=Du(),[m,u]=Bt.useState("left"),[g,p]=Bt.useState("ltr"),[f,h]=Bt.useState(0),[v,b]=Bt.useState(0),[y,C]=Bt.useState("none"),[T,x]=Bt.useState(0),[E,P]=Bt.useState(0),[k,w]=Bt.useState(0),[D,M]=Bt.useState("multiple"),[H,I]=Bt.useState(1.08),[A,S]=Bt.useState(false),[_,B]=Bt.useState(false),[Z,ee]=Bt.useState(false),[j,oe]=Bt.useState(true),[$,V]=Bt.useState(false),[ce,O]=Bt.useState([]),[N,W]=Bt.useState(false),[J,de]=Bt.useState(0),[he,Oe]=Bt.useState("left"),[we,Ke]=Bt.useState("none"),[Te,Io]=Bt.useState(editor.NO_MIXED_FIELDS),[co,_t]=Bt.useState(false),Xo=z=>a(co&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Mn=Bt.useRef(editor.NO_MIXED_FIELDS),ae=Bt.useId(),[rt,Ie]=Bt.useState(false),uo=Bt.useRef(null),Jo=Bt.useRef(false),It=Bt.useRef(null);Bt.useEffect(()=>{if(!e){Jo.current=false;return}if(Jo.current||s===null)return;let z=editor.seedFields(s);u(z.alignment),p(z.direction),h(z.indentLeft),b(z.indentRight),C(z.special),x(z.specialBy),P(z.spaceBefore),w(z.spaceAfter),M(z.lineRule),I(z.lineValue),S(z.contextualSpacing),B(z.keepNext),ee(z.keepLines),oe(z.widowControl),V(z.pageBreakBefore),O(z.tabStops),W(false);let ve=editor.mixedFieldsOf(s);Io(ve),_t(s.indentUnknown),de(0),Oe("left"),Ke("none"),Mn.current=ve,Ie(false),It.current=z,Jo.current=true;},[e,s]);let No=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let z=It.current,ve=z===null?null:editor.changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:v,special:y,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:D,lineValue:H,contextualSpacing:A,keepNext:_,keepLines:Z,widowControl:j,pageBreakBefore:$,tabStops:ce,clearedAllTabStops:N},Mn.current,Te);if(ve===null){t();return}if(d(ve)){Ie(false),t();return}Ie(true);},[c,l,d,t,Te,N,m,g,f,v,y,T,E,k,D,H,A,_,Z,j,$,ce]),br=Bt.useCallback(()=>{let z=Math.round(J);return z<=0?false:(Io(ve=>({...ve,tabStops:false})),O(editor.withTabStop(ce,{positionTwips:z,alignment:he,...we!=="none"?{leader:we}:{}})),de(0),Oe("left"),Ke("none"),true)},[ce,J,he,we]);if(!e)return null;let ie=z=>Io(ve=>({...ve,[z]:false})),ge=(z,ve,en,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:`${ae}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${ae}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Te[ft]?"":editor.twipsToInches(ve),placeholder:Te[ft]?Xo(ft):void 0,onChange:wa=>{ie(ft),en(editor.inchesToTwips(Number(wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),qe=(z,ve,en,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:`${ae}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${ae}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Te[ft]?"":ve,placeholder:Te[ft]?Xo(ft):void 0,onChange:wa=>{ie(ft),en(Math.max(0,Number(wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),xe=(z,ve,en)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:ve,ref:ft=>{ft&&(ft.indeterminate=Te[z]);},onChange:ft=>{Io(wa=>({...wa,[z]:false})),en(ft.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Ct={alignment:m,direction:g,indentLeft:f,indentRight:v,special:y,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:D,lineValue:H,contextualSpacing:A,keepNext:_,keepLines:Z,widowControl:j,pageBreakBefore:$,tabStops:ce,clearedAllTabStops:N},Fo=z=>{let ve=Mn.current;z!==g&&!ve.direction&&!ve.alignment&&u(editor.alignmentAfterDirectionChange),p(z);},Qo={alignment:u,direction:Fo,indentLeft:h,indentRight:b,special:C,specialBy:x,spaceBefore:P,spaceAfter:w,lineRule:M,lineValue:I,contextualSpacing:S,keepNext:B,keepLines:ee,widowControl:oe,pageBreakBefore:V,tabStops:O,clearedAllTabStops:W},_n={values:Ct,mixed:Te,setValue(z,ve){Qo[z](ve),z==="lineRule"?(ie("lineSpacing"),I(ve===It.current?.lineRule?It.current.lineValue:ve==="multiple"?1.08:12)):z==="specialBy"?ie("special"):z in Te&&ie(z);},errors:rt?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:No,cancel:t};return jsxRuntime.jsx(Be,{kind:"paragraph",className:o,style:n,panelRef:uo,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let ve=editor.isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!ve){let en=z.target;if(editor.isHTMLElementNode(en)&&en.dataset.docxTabEntry!==void 0){br();return}c&&No();}},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("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:`${ae}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${ae}-alignment`,className:"docx-dialog__input",value:Te.alignment?"":m,onChange:z=>{ie("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Te.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:`${ae}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${ae}-direction`,className:"docx-dialog__input",value:Te.direction?"":g,onChange:z=>{ie("direction"),Fo(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Te.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")}),ge("beforeText",f,h,"indentLeft"),ge("afterText",v,b,"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:`${ae}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${ae}-special`,className:"docx-dialog__input",value:Te.special?"":y,onChange:z=>{ie("special"),C(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Te.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:`${ae}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${ae}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Te.special?"":editor.twipsToInches(T),placeholder:Te.special?Xo("special"):void 0,onChange:z=>{ie("special"),x(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")}),ce.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(Te.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ce.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:()=>O(ce.filter(ve=>ve!==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:`${ae}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${ae}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(J),onChange:z=>de(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:`${ae}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${ae}-tabAlignment`,className:"docx-dialog__input",value:he,onChange:z=>Oe(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:`${ae}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${ae}-tabLeader`,className:"docx-dialog__input",value:we,onChange:z=>Ke(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:br,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Io(z=>({...z,tabStops:false})),W(true),O([]);},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")}),qe("spaceBefore",E,P,"spaceBefore"),qe("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:`${ae}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${ae}-lineSpacing`,className:"docx-dialog__input",value:Te.lineSpacing?"":D,onChange:z=>{let ve=z.target.value;ie("lineSpacing"),M(ve),I(ve===It.current?.lineRule?It.current.lineValue:ve==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Te.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:`${ae}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${ae}-at`,type:"number",className:"docx-dialog__input",min:.01,step:D==="multiple"?.01:1,value:Te.lineSpacing?"":H,disabled:Te.lineSpacing,onChange:z=>{let ve=z.target.value.trim();I(ve===""?D==="multiple"?1.08:12:Number(ve)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:D==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),xe("contextualSpacing",A,S),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),xe("keepNext",_,B),xe("widowControl",j,oe),xe("keepLines",Z,ee),xe("pageBreakBefore",$,V)]})]})}),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:No,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var xo=Tt();function pw(){return xo.useState()}var Zo=Object.assign(uw,{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 eo=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var _u=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],Iu=[null,.5,1,1.5,2,5],Nu=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],Nb="image/png,image/jpeg,image/gif,image/bmp,image/webp",Fu={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"},Jl=/^[0-9A-Fa-f]{6}$/;function Fb(e,t){let o={...Fu};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&&Jl.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function Lb(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 Hb=e=>`#${Jl.test(e)?e.toLowerCase():"c0c0c0"}`;function Ab(e){let t=e.startsWith("#")?e.slice(1):e;return Jl.test(t)?t.toUpperCase():null}var Lu=e=>Math.round(Math.min(1,Math.max(0,e))*100);function Hu(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Ob(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 Bb(e,t){return e!==null&&t.kind==="none"?null:t}function Wb(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 Zb=(e,t)=>t.includes(e)?e:"",fw={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Ql(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??fw,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 Rb=12,Mb=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function Kb(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+Rb<=t.y+t.height;r++){let a=Mb[r%Mb.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:Rb}),i+=o;}return n}var qb="contrast(0.157068) brightness(1.91)",Au=100,Ko=e=>Math.round(e*100)/100,Ub=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function zb(e,t=Ql(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}=Ub(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Jl.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Ko(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Ko(r-n.width/2),y:Ko(i-n.height/2),width:Ko(n.width),height:Ko(n.height)},rotation:e.layout==="diagonal"?-45:0}}var _b=new WeakMap;function gw(e){if(!e)return null;let t=_b.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}_b.set(e,t);}return t}function $b(e,t){let o=Au,n=gw(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 Vb(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 Gb(e,t=Ql(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}=Ub(t);return {x:Ko(n-o.width/2),y:Ko(r-o.height/2),width:Ko(o.width),height:Ko(o.height)}}var bw=e=>e.editable,hw={ok:false,code:"unsupported",reason:"editor is not ready"};function Bu(){let e=L(),t=Bt.useCallback(l=>e?.getWatermark()??null,[e]),o=K(t,Ob),n=K(bw),r=Bt.useMemo(()=>n&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,n]),i=Bt.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=Bt.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):hw,[e]);return Bt.useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var Tw=e=>e.pageSetup??null,to=Tt(),Ew=to.part("preview");function Jb(){return to.useState()}var Yb=e=>`${Math.round(e*100)}%`;function Sw(e){let[t,o]=Bt.useState(null);return Bt.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 Pw({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Jb(),i=L(),a=K(Tw),l=Bt.useMemo(()=>Ql(a),[a]),s=Sw(r.kind==="picture"?r.imageData:null),c=zb(r,l),d=s?Gb(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:Au,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:Vb(c,$b(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:qb}:void 0}):null,Kb(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 kw({open:e,onClose:t,presets:o=_u,className:n,style:r,children:i,preset:a=true}){let{t:l}=F(),s=L(),c=po(e,t),{isEnabled:d,read:m,apply:u}=Bu(),g=K(eo),[p,f]=Bt.useState({...Fu}),[h,v]=Bt.useState([]),[b,y]=Bt.useState(null),[C,T]=Bt.useState(false),[x,E]=Bt.useState(0),P=Bt.useRef(null),k=Bt.useRef(null),w=Bt.useRef(null),D=Bt.useId(),M=Bt.useRef(false);Bt.useEffect(()=>{if(!e||g||!s){M.current=false;return}if(M.current)return;M.current=true;let N=s.getWatermark(),W=Fb(N,m());P.current=Bb(N,W),f(W),v(s.getAvailableFonts()),y(null),T(false),E(J=>J+1);},[e,g,s,m]),Bt.useEffect(()=>{x!==0&&k.current?.querySelector(`input[name="${D}-kind"]:checked`)?.focus({preventScroll:true});},[x,D]);let H=Bt.useCallback((N,W)=>{y(null),f(J=>({...J,[N]:W}));},[]),I=Lb(p),A=d&&I!==void 0,S=Bt.useCallback(()=>{if(!A||I===void 0)return;if(!c()){t();return}if(P.current&&Wb(P.current,p)){t();return}let N=u(I);N.ok?t():y(N.reason);},[A,I,p,c,u,t]),_=Bt.useCallback(N=>{N&&(T(false),N.arrayBuffer().then(W=>{f(J=>({...J,kind:"picture",imageData:new Uint8Array(W),imageName:N.name})),y(null);}).catch(()=>T(true)));},[]);if(!e)return null;let B=p.kind==="picture",Z=p.kind==="text",ee=h.includes(p.fontFamily)?h:[p.fontFamily,...h],j=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),oe=b!==null?l("dialogs.watermark.refused"):null,$=(N,W,J)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${D}-kind`,checked:p.kind===W,onChange:()=>H("kind",W)}),jsxRuntime.jsx("span",{id:`${D}-${N}-label`,children:J})]}),V=(N,W,J)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${D}-${N}`,children:W}),J]}),ce=(N,W,J)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!J,checked:p[N],onChange:de=>H(N,de.target.checked)}),jsxRuntime.jsx("span",{children:W})]}),O={values:p,setValue:H,errors:oe?{form:oe}:{},isEnabled:A,apply:S,cancel:t};return jsxRuntime.jsx(Be,{kind:"watermark",className:n,style:r,panelRef:k,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:N=>{let W=N.target;N.key==="Enter"&&editor.isHTMLElementNode(W)&&W.localName==="input"&&(W.type==="text"||W.type==="number")&&A&&(N.preventDefault(),S());},children:jsxRuntime.jsx(to.Composition,{state:O,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(Pw,{"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")}),$("noWatermark","none",l("dialogs.watermark.noWatermark")),$("pictureWatermark","picture",l("dialogs.watermark.picture")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${D}-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:()=>{H("kind","picture"),w.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:C?l("dialogs.watermark.pictureFailed"):j}),jsxRuntime.jsx("input",{ref:w,type:"file",accept:Nb,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:N=>{let W=N.target.files?.[0];N.target.value="",_(W);}})]}),V("scale",l("dialogs.watermark.scale"),jsxRuntime.jsxs("select",{id:`${D}-scale`,className:"docx-dialog__select",disabled:!B,value:p.scale===null?"auto":String(p.scale),onChange:N=>H("scale",N.target.value==="auto"?null:Number(N.target.value)),children:[Iu.map(N=>jsxRuntime.jsx("option",{value:N===null?"auto":String(N),children:N===null?l("dialogs.watermark.auto"):Yb(N)},String(N))),p.scale!==null&&!Iu.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:Yb(p.scale)}):null]})),ce("washout",l("dialogs.watermark.washout"),B)]}),$("textWatermark","text",l("dialogs.watermark.text")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${D}-textWatermark-label`,children:[V("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${D}-preset`,className:"docx-dialog__select",disabled:!Z,value:Zb(p.text,o),onChange:N=>{N.target.value!==""&&H("text",N.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(N=>jsxRuntime.jsx("option",{value:N,children:N},N))]})),V("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${D}-text`,type:"text",className:"docx-dialog__input",disabled:!Z,maxLength:256,value:p.text,onChange:N=>H("text",N.target.value)})),V("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${D}-fontFamily`,className:"docx-dialog__select",disabled:!Z,value:p.fontFamily,onChange:N=>H("fontFamily",N.target.value),children:ee.map(N=>jsxRuntime.jsx("option",{value:N,children:N},N))})),V("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${D}-fontSizePt`,className:"docx-dialog__select",disabled:!Z,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:N=>H("fontSizePt",N.target.value==="auto"?null:Number(N.target.value)),children:[Nu.map(N=>jsxRuntime.jsx("option",{value:N===null?"auto":String(N),children:N===null?l("dialogs.watermark.auto"):String(N)},String(N))),p.fontSizePt!==null&&!Nu.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[ce("bold",l("dialogs.watermark.bold"),Z),ce("italic",l("dialogs.watermark.italic"),Z)]}),V("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:!Z,"aria-label":l("dialogs.watermark.transparency"),value:Lu(p.transparency),onChange:N=>H("transparency",Hu(N.target.value,p.transparency))}),jsxRuntime.jsx("input",{id:`${D}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!Z,value:Lu(p.transparency),onChange:N=>H("transparency",Hu(N.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),V("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${D}-color`,type:"color",className:"docx-dialog__color",disabled:!Z,value:Hb(p.color),onChange:N=>{let W=Ab(N.target.value);W&&H("color",W);}})),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(N=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${D}-layout`,disabled:!Z,checked:p.layout===N,onChange:()=>H("layout",N)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${N}`)})]},N))]})]})]})]})}),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",...b?{title:b}:{},children:oe}),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:S,children:l("common.apply")})]})]}),children:i})})}var zn=Object.assign(kw,{Header:to.Header,Title:to.Title,Body:to.Body,Preview:Ew,Footer:to.Footer,Apply:to.Apply,Cancel:to.Cancel,Error:to.Error,Field:to.Field});var ts={ok:false,code:"unsupported",reason:"editor is not ready"},Dw=Object.freeze([]);function Ku(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 qu(){let e=L(),t=Bt.useCallback(c=>e?.query({type:"bookmarks"})??Dw,[e]),o=K(t,Ku),n=Bt.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=K(n),i=Bt.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):ts,[e]),a=Bt.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):ts,[e]),l=Bt.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):ts,[e]),s=Bt.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):ts,[e]);return Bt.useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var eh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function Fw(e){return e.open?jsxRuntime.jsx(Lw,{...e}):null}function Lw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=qu(),[p,f]=Bt.useState(()=>editor.bookmarkDialogInitialName(s)),[h,v]=Bt.useState("name"),[b,y]=Bt.useState(false),[C,T]=Bt.useState(false),[x,E]=Bt.useState(false),[P,k]=Bt.useState(false),w=Bt.useRef(null),D=Bt.useRef(null),M=Bt.useId(),H=Bt.useId(),I=Bt.useId(),A=editor.bookmarkDialogRows(s,{sortBy:h,showHidden:b}),S=editor.bookmarkDialogNameState(s,p,c),_=S.problem&&!S.existing&&(x||p.length>0)?S.problem:null,B=S.existing?.duplicates??0,Z=C?a("dialogs.bookmark.refused"):_?a(eh[_]):B>0?a("dialogs.bookmark.duplicates",{count:B}):S.existing&&S.canAdd?a("dialogs.bookmark.nameExists"):null,ee=Bt.useCallback(()=>{if(E(true),!S.canAdd)return;if(!l()){t();return}let O=d(p);T(!O.ok),O.ok&&t();},[S.canAdd,l,d,p,t]),j=Bt.useCallback(()=>{if(!S.canDelete||!S.existing)return;let O=m(S.existing.name);T(!O.ok),O.ok&&f("");},[S,m]),oe=Bt.useCallback(()=>{if(!S.canGoTo||!S.existing)return;let O=u(S.existing.name);T(!O.ok),O.ok&&k(true);},[S,u]),$=Bt.useCallback(()=>{let O=S.existing;!O||!c||T(!g(O.name).ok);},[S.existing,c,g]),V=S.existing?.name??"";Bt.useLayoutEffect(()=>{!V&&D.current&&(D.current.selectedIndex=-1);});let ce={values:{name:p,sortBy:h,showHidden:b},setValue(O,N){O==="name"?f(N):O==="sortBy"?v(N):y(N),T(false);},errors:_?{name:a(eh[_])}:C?{form:a("dialogs.bookmark.refused")}:{},isEnabled:S.canAdd,apply:ee,cancel:t,rows:A,canDelete:S.canDelete,canGoTo:S.canGoTo,duplicates:B,remove:j,goTo:oe,keepFirst:$};return jsxRuntime.jsx(Be,{kind:"bookmark",className:o,style:n,panelRef:w,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&O.keyCode!==229&&editor.isHTMLElementNode(O.target)&&O.target.localName==="input"&&O.target.getAttribute("type")==="text"&&(O.preventDefault(),ee());},children:jsxRuntime.jsx(Ft.Composition,{state:ce,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:M,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:M,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":_?true:void 0,"aria-describedby":H,onChange:O=>ce.setValue("name",O.target.value)})]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children:jsxRuntime.jsx("select",{ref:D,className:"docx-dialog__input docx-dialog__input--full docx-bookmark-dialog__list",size:8,value:V,"aria-label":a("dialogs.bookmark.list"),onChange:O=>ce.setValue("name",O.target.value),onDoubleClick:oe,children:A.map(O=>jsxRuntime.jsx("option",{value:O.name,children:O.name},O.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(O=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:I,checked:h===O,onChange:()=>ce.setValue("sortBy",O)}),a(O==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},O))]}),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:b,onChange:O=>ce.setValue("showHidden",O.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:H,"data-docx-part":"error",role:"status",className:_||C?"docx-dialog__error":"docx-dialog__hint",children:Z}),B>0?jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:$,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:!S.canAdd,onClick:ee,children:a("dialogs.bookmark.add")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!S.canDelete,onClick:j,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!S.canGoTo,onClick:oe,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(P?"common.close":"common.cancel")})]})]}),children:r})})}var Ft=Tt();function Hw(){return Ft.useState()}var ja=Object.assign(Fw,{Header:Ft.Header,Title:Ft.Title,Body:Ft.Body,Footer:Ft.Footer,Apply:Ft.Apply,Cancel:Ft.Cancel,Error:Ft.Error,Field:Ft.Field,Delete:Ft.part("delete"),GoTo:Ft.part("goto"),KeepFirst:Ft.part("keepfirst")});var oh=editor.SPLIT_CELL_FALLBACK_MAX;function Uw(e){return e.open?jsxRuntime.jsx($w,{...e}):null}var zw=e=>e;function $w({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=L(),s=po(e,t),c=Bt.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=Bt.useState(()=>editor.initialSplitCellCounts(c,S=>l?l.can(S):{ok:false,code:"unsupported",reason:""})),[m,u]=Bt.useState(d.columns),[g,p]=Bt.useState(d.rows),[f,h]=Bt.useState(null),v=Bt.useId(),b=Bt.useId(),y=Bt.useId(),{counts:C,problem:T}=editor.readSplitCellCounts(m,g,c),x=C?.cols??null,E=C?.rows??null;K(zw);let P=l&&C?l.can({type:"splitCell",...C}):null,k=T?.kind==="range"?a("dialogs.splitCell.range",{max:T.max}):T?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):P&&!P.ok?i18n.localizeDisabledReason(P.reason??null,a):null,w=P?.ok===true,D=f??k,M=T?.kind==="range"?T.field:null,H=Bt.useCallback(()=>{if(!w||!l)return;if(!s()){t();return}let S=l.exec({type:"splitCell",rows:E,cols:x});S.ok?t():h(i18n.localizeDisabledReason(S.reason??null,a));},[w,l,s,t,E,x,a]),I={values:{columns:m,rows:g},setValue(S,_){S==="columns"?u(_):p(_),h(null);},errors:D?{form:D}:{},isEnabled:w,apply:H,cancel:t,limits:c},A=(S,_,B,Z,ee)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":S,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:_,children:a(B)}),jsxRuntime.jsx("input",{id:_,type:"number",inputMode:"numeric",className:"docx-dialog__input",min:1,max:ee,step:1,value:Z,"aria-invalid":M===S?true:void 0,"aria-describedby":y,onChange:j=>I.setValue(S,j.target.value)})]});return jsxRuntime.jsx(Be,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:S=>{S.key==="Enter"&&!S.nativeEvent.isComposing&&S.keyCode!==229&&editor.isHTMLElementNode(S.target)&&S.target.localName==="input"&&(S.preventDefault(),H());},children:jsxRuntime.jsx(vo.Composition,{state:I,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",v,"dialogs.splitCell.columns",m,c?.maxCols??oh),A("rows",b,"dialogs.splitCell.rows",g,c?.maxRows??oh),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:y,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:D})})]}),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:H,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 vo=Tt();function Vw(){return vo.useState()}var Ya=Object.assign(Uw,{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 nh=Bt.createContext(void 0),rh=nh.Provider;function Qe(){let e=Bt.useContext(nh),{t}=F();return Bt.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Co=Tt();function eD(){return Co.useState()}function tD({session:e,...t}){let[o,n]=Bt.useState(e),[r,i]=Bt.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(oD,{session:e,...t},r):null}function oD({session:e,children:t,preset:o,className:n,style:r}){let i=Qe(),a=K(()=>e.canApply()),[l,s]=Bt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Bt.useState(e.signal.aborted),[m,u]=Bt.useState(false);Bt.useEffect(()=>{let b=()=>d(true);return e.signal.addEventListener("abort",b),e.signal.aborted&&b(),()=>e.signal.removeEventListener("abort",b)},[e]);let g=()=>{if(e.signal.aborted)return;let b=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(!b);},p={values:l,setValue(b,y){s(C=>({...C,[b]:y,...b==="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"},v=(b,y)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":b,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${b}`)}),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:b=>{b.key==="Escape"&&(b.preventDefault(),e.cancel()),b.key==="Enter"&&editor.isHTMLElementNode(b.target)&&b.target.localName==="input"&&(b.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:[v("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:b=>p.setValue("defaultText",b.target.value)})),v("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:b=>p.setValue("type",b.target.value),children:[["regular","number","date"].map(b=>jsxRuntime.jsx("option",{value:b,children:i(`textFormField.${b}`)},b)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),v("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:b=>p.setValue("maxLength",b.target.valueAsNumber)})),v("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:b=>p.setValue("format",b.target.value),children:[f.map(b=>jsxRuntime.jsx("option",{value:b,children:h[b]?i(h[b]):b||i("textFormField.noFormat")},b)),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:b=>p.setValue("enabled",b.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(tD,{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 lh=Bt.createContext(null),To=()=>Bt.useContext(lh);function sh({popups:e,children:t}){let o=L(),n=Sd(),[r,i]=Bt.useState(null),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(null),u=Bt.useRef(d);u.current=d;let g=Bt.useRef(e);g.current=e;let p=Bt.useRef(null),f=Bt.useRef(s);f.current=s;let h=()=>l(null);Bt.useEffect(()=>{if(a!==null)return;let T=p.current;p.current=null,T?.isConnected&&T.focus({preventScroll:true});},[a]),Bt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(T){if(g.current?.textFormField===false){T.cancel();return}u.current?.cancel(),l(null),c(T),T.signal.addEventListener("abort",()=>c(x=>x===T?null:x),{once:true});}},{fallback:true})},[o]),Bt.useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let T=o.setRevisionMarkupChrome({onRequest(x){if(g.current?.revisionMarkup===false){x.cancel();return}f.current?.cancel(),l(null),m(x),x.signal.addEventListener("abort",()=>m(E=>E===x?null:E),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),T();}},[o,r,e?.revisionMarkup===false]),Bt.useEffect(()=>{l(null),c(null),m(null);},[o,n]);let v=e?.bookmark===false;Bt.useEffect(()=>{if(!(!o||!r||v))return o.setBookmarkChrome({onRequest(){f.current?.cancel(),u.current?.cancel(),p.current=lD(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,v]),Bt.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let b=Bt.useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(T,x){f.current?.cancel(),u.current?.cancel(),g.current?.[T]!==false&&(p.current=x??r?.ownerDocument.activeElement,l(T));}}),[r,e?.pageSetup]),y={open:true,onClose:h},C=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Ee(e.pageSetup,y):jsxRuntime.jsx(Un,{...y}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Ee(e.paragraph,y):jsxRuntime.jsx(Zo,{...y}):a==="watermark"&&e?.watermark!==false?e?.watermark?Ee(e.watermark,y):jsxRuntime.jsx(zn,{...y}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Ee(e.bookmark,y):jsxRuntime.jsx(ja,{...y}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Ee(e.splitCell,y):jsxRuntime.jsx(Ya,{...y}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Ee(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ra,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Ee(e.textFormField,{session:s},s):jsxRuntime.jsx(Ja,{session:s}):null;return jsxRuntime.jsxs(lh.Provider,{value:b,children:[t,r?reactDom.createPortal(C,r):null]})}function lD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function ch(){let e=To();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:at()})}function dh({children:e}){let t=To();return t?.container?reactDom.createPortal(e,t.container):e}var uh=["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"],ph=["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"],$u=["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"],mh=["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"],fh=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],gh=["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"],bh=["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 Br(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=L(),{close:d}=Bo(),m=Re(),{isEnabled:u,disabledReason:g}=se(t);return s?null:jsxRuntime.jsx(Me,{slot:e,icon:r??re(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 Qa=Br("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:uh}),ei=Br("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:ph}),ti=Br("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:mh}),oi=Br("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:bh});function Wr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=L(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=Se(),d=Re(),m=Bt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=se(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(Me,{slot:"edit.paste",icon:e??re($u),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:h}=await dD(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")})}Wr.docxRow="edit.paste";async function dD(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 Zr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=L(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=Se(),d=Re(),m=Bt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=se(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(Me,{slot:"edit.pasteWithoutFormatting",icon:e??re($u),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")})}Zr.docxRow="edit.pasteWithoutFormatting";var yh=te("format.painter")?.paths??[],ls=Br("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:yh}),ss=Br("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:yh});function pn(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=Bo(),d=Re(),m=ni(),{isEnabled:u,disabledReason:g,execute:p}=se(t);return l||!m?null:jsxRuntime.jsx(Me,{slot:e,icon:r??re(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 Kr=pn("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),qr=pn("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),Ur=pn("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),zr=pn("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),$r=pn("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),Vr=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=Bo(),i=Re(),a=ni(),l=To(),{isEnabled:s,disabledReason:c}=se("table.splitCell");return n||!a||!l?null:jsxRuntime.jsx(Me,{slot:"table.splitCell",icon:e??re(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"}),Gr=pn("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),jr=pn("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),Yr=pn("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),uD=[{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 Vn({hidden:e}){let{close:t}=Bo(),o=Re(),n=ni(),r=se({type:"setTableCellVerticalAlignment",alignment:"top"}),i=se({type:"setTableCellVerticalAlignment",alignment:"center"}),a=se({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:uD.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:re(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}Vn.docxRow="table.cellVerticalAlignment";function xh(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=L(),{close:c,tocId:d}=Bo(),m=Re(),u=Bt.useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=se(u);return l||d===null?null:jsxRuntime.jsx(Me,{slot:e,icon:r??re(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:m(i??o.labelKey)})},{docxRow:e})}var Xr=xh("toc.refresh","entire",{labelKey:"toc.refresh",paths:fh}),Jr=xh("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:gh});function ni(){return K(Bt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function cs({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=Bo();return jsxRuntime.jsx(Me,{...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 Gn=Bt.createContext(false);function Lt(){return Bt.useContext(Gn)?"":"docx-editor "}var ai=8;function yD(){let e=Bt.useContext(Nt),t=it(),o=Re(),{isEnabled:n,reason:r}=Fl(o);if((e?.mounted??0)===0)return null;let i=te("review.addComment");return jsxRuntime.jsx(Me,{icon:re(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function xD(){let e=L(),t=it(),o=Re();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(Me,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var vD=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(xD,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(Qa,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(ei,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(Wr,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(Zr,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(ls,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(ss,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(ti,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(oi,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(Kt,{slotId:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(yD,{})}];function CD(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Kr.docxRow,render:()=>jsxRuntime.jsx(Kr,{})},{kind:"row",id:qr.docxRow,render:()=>jsxRuntime.jsx(qr,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Ur.docxRow,render:()=>jsxRuntime.jsx(Ur,{})},{kind:"row",id:zr.docxRow,render:()=>jsxRuntime.jsx(zr,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:$r.docxRow,render:()=>jsxRuntime.jsx($r,{})},{kind:"row",id:Vr.docxRow,render:()=>jsxRuntime.jsx(Vr,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:Gr.docxRow,render:()=>jsxRuntime.jsx(Gr,{})},{kind:"row",id:jr.docxRow,render:()=>jsxRuntime.jsx(jr,{})},{kind:"row",id:Yr.docxRow,render:()=>jsxRuntime.jsx(Yr,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Vn.docxRow,render:()=>jsxRuntime.jsx(Vn,{})}]}function TD(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Xr.docxRow,render:()=>jsxRuntime.jsx(Xr,{})},{kind:"row",id:Jr.docxRow,render:()=>jsxRuntime.jsx(Jr,{})}]}function ED(e,t=false){return [...vD,...e?CD():[],...t?TD():[]]}function Ph(e){if(!Bt.isValidElement(e))return null;let t=wr(e,Ph);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=Vl(e.props);if(n)return n}return null}function Eh(e){if(!Bt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function SD(e){return e?.closest(".docx-editor__scroll-container")??null}function ii({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=Lt(),l=at(),s=L(),{t:c}=F(),d=ni(),m=Bt.useRef(null),u=Bt.useRef(null),[g,p]=Bt.useState(null),[f,h]=Bt.useState(null),[v,b]=Bt.useState(null),y=Bt.useMemo(()=>ED(d,f!==null),[d,f]),[C,T]=Bt.useState(null),x=Bt.useCallback((I=false)=>{p(null),T(null),h(null),b(null),I&&s?.focus();},[s]);Bt.useEffect(()=>{if(n)return;let I=SD(m.current);if(!I)return;let A=S=>{S.preventDefault();let _=S.button===-1||S.clientX===0&&S.clientY===0,B=I.getBoundingClientRect();h(s?.snapshot().tocContext?.id??null),b(_||!editor.isHTMLElementNode(S.target)?null:S.target),p(_?{x:B.left+16,y:B.top+16}:{x:S.clientX,y:S.clientY});};return I.addEventListener("contextmenu",A),()=>I.removeEventListener("contextmenu",A)},[n,s]),Bt.useEffect(()=>{n&&x();},[n,x]),Bt.useEffect(()=>{if(!g)return;let I=Z=>{u.current?.contains(Z.target)||x();},A=Z=>{Z.key==="Escape"?(Z.preventDefault(),x(true)):Z.key==="Tab"&&x();},S=()=>x(),_=editor.hostDocumentOf(m.current??u.current),B=editor.hostWindowOf(m.current??u.current);return _.addEventListener("pointerdown",I,true),_.addEventListener("keydown",A),_.addEventListener("scroll",S,{capture:true,passive:true}),B.addEventListener("blur",S),B.addEventListener("resize",S),()=>{_.removeEventListener("pointerdown",I,true),_.removeEventListener("keydown",A),_.removeEventListener("scroll",S,true),B.removeEventListener("blur",S),B.removeEventListener("resize",S);}},[g,x]),Bt.useLayoutEffect(()=>{let I=u.current;if(!g||!I)return;let{width:A,height:S}=I.getBoundingClientRect(),_=editor.hostWindowOf(I),B=_.innerWidth-A-ai,Z=_.innerHeight-S-ai,j=_.getComputedStyle(I).direction==="rtl"?g.x-A>=ai:g.x>B,oe=Math.max(ai,Math.min(j?g.x-A:g.x,B)),$=Math.max(ai,g.y>Z?g.y-S:g.y);T({x:oe,y:$});},[g]),Bt.useLayoutEffect(()=>{C&&u.current?.focus({preventScroll:true});},[C]);let E=Bt.useRef(r);E.current=r;let P=Bt.useRef(false);Bt.useEffect(()=>{let I=g!==null;I!==P.current&&(P.current=I,E.current?.(I));},[g]);let k=Bt.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]),[w,D]=Bt.useState(null),M=Bt.useMemo(()=>({close:x,anchor:g,tocId:f,target:v,clipboardRefusal:w,reportClipboardRefusal:D}),[x,g,f,v,w]),H={position:"fixed",left:(C??g)?.x??0,top:(C??g)?.y??0,visibility:C?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:m,style:{display:"contents"},children:g?jsxRuntime.jsx(Wa.Provider,{value:k,children:jsxRuntime.jsx(Gl.Provider,{value:M,children:jsxRuntime.jsxs("div",{ref:u,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,dir:l,style:H,onKeyDown:I=>{let A=u.current;if(!A)return;let S=Wn(A);I.key==="ArrowDown"?(I.preventDefault(),Yt(S,editor.hostDocumentOf(A).activeElement,1)):I.key==="ArrowUp"?(I.preventDefault(),Yt(S,editor.hostDocumentOf(A).activeElement,-1)):I.key==="Home"?(I.preventDefault(),Xt(S,"first")):I.key==="End"&&(I.preventDefault(),Xt(S,"last"));},children:[Bt.Children.toArray(i).filter(Eh),Nl({entries:y,children:Bt.Children.toArray(i).filter(I=>!Eh(I)),preset:o,keyOfEntry:I=>I.id,keyOfChild:I=>Kg(Ph(I)),renderEntry:I=>I.kind==="separator"?jsxRuntime.jsx(Kn,{}):I.render(),onUnmatched:(I,A)=>{A.props.hidden&&fg(I);}})]})})}):null})}var Yu=Object.assign(ii,{Cut:Qa,Copy:ei,Paste:Wr,PasteWithoutFormatting:Zr,Delete:ti,SelectAll:oi,InsertRowAbove:Kr,InsertRowBelow:qr,InsertColumnLeft:Ur,InsertColumnRight:zr,MergeCells:$r,SplitCell:Vr,DeleteTableRow:Gr,DeleteTableColumn:jr,DeleteTable:Yr,CellVerticalAlignment:Vn,RefreshToc:Xr,RefreshTocPageNumbers:Jr,Item:cs,Slot:Kt,Row:Me,Group:$a,Separator:Kn,Submenu:Jt});var kh=Od.Provider;function wh(){let e=St(),{t}=F();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Ee(e.hyperlink,{}),e?.contentControl&&Ee(e.contentControl,{}),e?.equation&&Ee(e.equation,{}),e?.contextMenu&&Ee(e.contextMenu,{t:o=>t(o)})]})}function Dh(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(La,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(Oa,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(Ba,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Ee(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(ii,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function DD(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 Xu(){let e=L(),t=Bt.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=K(t,DD);return o?.kind==="note"?o:null}function Rh(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 Mh(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&&Rh(e.documentAuthored,t.documentAuthored)&&Rh(e.sectionAuthored,t.sectionAuthored)}function RD(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Mh(e.footnote,t.footnote)&&Mh(e.endnote,t.endnote)}function Ju(){let e=L(),t=Bt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return K(t,RD)}function li(e,t){let[o,n]=Bt.useState(null),r=Bt.useCallback(l=>n(l),[]),[i,a]=Bt.useState({visibility:"hidden"});return Bt.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 v=h.getBoundingClientRect(),b=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,y=t==="story-label"?6:4,C=l===s,T=t==="after"?v.bottom+6:t==="story-label"?editor.storyLabelTop(v,h.closest(".docx-page")?.getBoundingClientRect().top,b,y):v.top-b-y,x=C?Er(s,v.left,T):{left:v.left,top:T},E=x.left,P=x.top,k=C?s.scrollLeft+8:8;a({position:C?"absolute":"fixed",left:t==="story-label"?E:Math.max(k,E+8),top:t==="story-label"?P:Math.max(C?s.scrollTop+8:8,P),...t==="story-label"?{width:Math.max(240,Math.min(v.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(v.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 LD=/^(footnote|endnote):(-?\d{1,10})$/;function Nh(e){let t=LD.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function HD(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function ep(e){let t=L();return Bt.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 AD(e){let{t}=F(),[o,n]=Bt.useState(false),r=Bt.useRef(null);return Bt.useEffect(()=>{if(o)return editor.listenForOutsidePress({popup:r.current,close:()=>n(false)})},[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:U,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:U,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 fs({className:e}){let t=St(),o=Bt.useRef(null),{t:n}=F(),r=L(),i=Xu(),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useCallback(M=>{if(!i)return null;let I=[...M.querySelectorAll("[data-docx-note-scope]")].find(A=>A.matches("[data-docx-note]")&&A.dataset.docxNoteScope===i.id)??null;return I?.closest("[data-docx-notes]")??I},[i]),p=li(g,"story-label"),f=Bt.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);Bt.useEffect(()=>{if(!r)return;let M=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!M)return;let H=S=>{let _=S.target;if(!_)return;let B=_.closest("[data-docx-note-ref]");if(B?.dataset.docxNoteScope){S.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:B.dataset.docxNoteScope});return}_.closest("[data-docx-note-mark-back]")&&(S.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},I=S=>{let _=S,Z=_.target?.closest("[data-docx-note-scope]");Z?.dataset.docxNoteScope&&(_.preventDefault(),c({scopeId:Z.dataset.docxNoteScope,x:_.clientX,y:_.clientY}));},A=S=>{let _=S.target;if(HD(_))return;let B=_?.closest("[data-docx-note-ref]");if(!B?.dataset.docxNoteScope){f();return}let Z=B.dataset.docxNoteScope,j=r.getNotePreviewText(Z)??B.getAttribute("aria-description")??n("notes.previewFallback"),oe=B.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let $=editor.hostWindowOf(B),V=$.setTimeout(()=>{l({scopeId:Z,text:j,x:oe.left,y:oe.bottom+4});},400);u.current={win:$,handle:V};};return M.addEventListener("click",H),M.addEventListener("contextmenu",I),M.addEventListener("pointerover",A),M.addEventListener("scroll",f,true),()=>{M.removeEventListener("click",H),M.removeEventListener("contextmenu",I),M.removeEventListener("pointerover",A),M.removeEventListener("scroll",f,true),f();}},[r,f,n]);let h=Bt.useCallback(M=>{r&&(r.exec(M),c(null));},[r]),v=s?Nh(s.scopeId):null,b=Bt.useMemo(()=>v?{type:"deleteNote",noteKind:v.noteKind,noteId:v.noteId}:null,[v]),y=Bt.useMemo(()=>v?{type:"convertNote",fromKind:v.noteKind,noteId:v.noteId}:null,[v]),C=Bt.useMemo(()=>v?{type:"convertAllNotes",fromKind:v.noteKind}:null,[v]),T=ep(b??{type:"deleteNote",noteKind:"footnote",noteId:0}),x=ep(y??{type:"convertNote",fromKind:"footnote",noteId:0}),E=ep(C??{type:"convertAllNotes",fromKind:"footnote"}),P=i?Nh(i.id):null,k=P?n("notes.editingRegion",{kind:P.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:P.noteId}):null,w=s&&v?{...s,...v,onDelete:()=>{b&&h(b);},onConvert:()=>{y&&h(y);},onConvertAll:()=>{C&&h(C);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:T.enabled,convertEnabled:x.enabled,convertAllEnabled:E.enabled,deleteDisabledReason:T.reason??void 0,convertDisabledReason:x.reason??void 0,convertAllDisabledReason:E.reason??void 0}:null,D={onClose:()=>m(false),onApply:M=>{h(M),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&&P?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:xt.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:k}),jsxRuntime.jsx(AD,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Ee(t.notePreview,a):jsxRuntime.jsx(Cr,{...a}):null,w&&t?.notesContextMenu!==false?t?.notesContextMenu?Ee(t.notesContextMenu,w):jsxRuntime.jsx(Tr,{...w}):null,d&&t?.noteProperties!==false?t?.noteProperties?Ee(t.noteProperties,D):jsxRuntime.jsx(gs,{...D}):null]}):null}function gs(e){let{t}=F(),o=L(),n=Ju(),[r,i]=Bt.useState("document"),[a,l]=Bt.useState("decimal"),[s,c]=Bt.useState("continuous"),[d,m]=Bt.useState("pageBottom"),[u,g]=Bt.useState("decimal"),[p,f]=Bt.useState("continuous"),[h,v]=Bt.useState("docEnd");Bt.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),v(n.endnote.resolved.pos));},[n]);let b=!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:xt.modal},onClick:e.onClose,onKeyDown:C=>{C.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:C=>C.stopPropagation(),onMouseDown:C=>C.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:C=>i(C.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")}),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:a,onChange:C=>l(C.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:C=>c(C.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:C=>m(C.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:C=>g(C.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:C=>f(C.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:C=>v(C.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 C={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(C).ok&&e.onApply(C);},children:t("common.apply")})]})]})})}var Ah=e=>e.image;function Hh(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 UD(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 lp(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(sn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(sn(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(sn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(sn(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function $D(e,t){let o=lp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function bs(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=qa(t);return Number.isInteger(o)?o:null}function VD(e,t){let o=lp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?bs(e.horizontalPoints):t.position?.horizontalEmu,u=d?bs(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?bs(e.horizontalPoints):t.position?.horizontalEmu,s=r?bs(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 hs(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function ys(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function ci({open:e,onClose:t,className:o,triggerRef:n}){let r=L(),{t:i}=F(),a=K(Ah),l=Bt.useId(),s=Bt.useId(),c=Bt.useId(),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),[p,f]=Bt.useState(null),[h,v]=Bt.useState(null),b=m.current,y=b?.canCrop===false,C=b?.canResize===false,T=b?.locks.changeAspect===true,x=b?.kind==="anchored"&&b.canMove===true,E=b?.kind==="inline",P=b?.kind==="anchored"&&b.canMove===false;Bt.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:B}=r.surface.state().selection;u.current={paragraphId:B.paragraphId,offset:B.offset},g.current=r.surface.session.packageRevision();}v(null);let S=lp(a),_=a.crop;f({widthPoints:String(sn(a.widthEmu)),heightPoints:String(sn(a.heightEmu)),cropLeft:String(_.left),cropTop:String(_.top),cropRight:String(_.right),cropBottom:String(_.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...S});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let k=Bt.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=Bt.useCallback(()=>{t(),k();},[t,k]);Bt.useEffect(()=>{if(!e)return;let S=d.current;if(!S)return;let _=Hh(S);(_.find(j=>j.id==="image-prop-width"&&!j.hasAttribute("disabled"))??_.find(j=>!j.hasAttribute("disabled"))??S).focus();let Z=j=>{if(j.key==="Escape"){j.preventDefault(),w();return}if(j.key!=="Tab")return;let oe=Hh(S);if(oe.length===0)return;let $=editor.hostDocumentOf(S).activeElement,V=oe.findIndex(O=>O===$);if(V===-1)return;j.preventDefault();let ce=j.shiftKey?(V-1+oe.length)%oe.length:(V+1)%oe.length;oe[ce]?.focus();},ee=editor.hostDocumentOf(S);return ee.addEventListener("keydown",Z),()=>ee.removeEventListener("keydown",Z)},[e,w]);let D=Bt.useMemo(()=>{let S=b??a;return !S||S.widthEmu<=0?1:S.widthEmu/S.heightEmu},[a,b]),M=Bt.useCallback(S=>{f(_=>{if(!_)return _;if(!_.lockAspect)return {..._,widthPoints:S};let B=ys(S);if(B===null)return {..._,widthPoints:S};let Z=Math.round(B/D*100)/100;return {..._,widthPoints:S,heightPoints:String(Z)}});},[D]),H=Bt.useCallback(S=>{f(_=>{if(!_)return _;if(!_.lockAspect)return {..._,heightPoints:S};let B=ys(S);if(B===null)return {..._,heightPoints:S};let Z=Math.round(B*D*100)/100;return {..._,widthPoints:String(Z),heightPoints:S}});},[D]),I=Bt.useCallback(()=>{let S=m.current;if(!S?.intrinsic)return;let _=S.intrinsic.pixelWidth*72/S.intrinsic.dpiX,B=S.intrinsic.pixelHeight*72/S.intrinsic.dpiY;f(Z=>Z&&{...Z,widthPoints:String(Math.round(_*100)/100),heightPoints:String(Math.round(B*100)/100)});},[a]),A=Bt.useCallback(()=>{let S=m.current,_=u.current,B=g.current;if(!r||!S||!p||!_||B===null)return;let Z={type:"setImageProperties",drawingNodeId:S.id,expectedPackageRevision:B,selectionParagraphId:_.paragraphId,selectionOffset:_.offset};if(!C){let ce=ys(p.widthPoints),O=ys(p.heightPoints);if(ce===null||O===null){v("imageProperties.errors.invalidDimensions");return}let N=qa(ce),W=qa(O);N!==S.widthEmu&&(Z.widthEmu=N),W!==S.heightEmu&&(Z.heightEmu=W);}if(S.canCrop&&!y){let ce=hs(p.cropLeft),O=hs(p.cropTop),N=hs(p.cropRight),W=hs(p.cropBottom);if(ce===null||O===null||N===null||W===null){v("imageProperties.errors.invalidCrop");return}let J=S.crop;(ce!==J.left||O!==J.top||N!==J.right||W!==J.bottom)&&(Z.crop={left:ce,top:O,right:N,bottom:W});}p.title!==S.title&&(Z.title=p.title),p.description!==S.description&&(Z.description=p.description);let ee=p.hyperlink.trim();if(ee!==(S.hyperlink??"")&&(Z.hyperlink=ee===""?null:ee),S.canChangeWrap&&p.wrap!==S.wrap&&(Z.wrap=p.wrap),S.kind==="anchored"&&S.canMove&&$D(p,S)){let ce=VD(p,S);if(!ce.ok){v("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(ce.value,S))){v("imageProperties.errors.invalidPosition");return}Object.assign(Z,ce.value);}if(!(Z.widthEmu!==void 0||Z.heightEmu!==void 0||Z.title!==void 0||Z.description!==void 0||Z.hyperlink!==void 0||Z.crop!==void 0||Z.wrap!==void 0||Z.horizontalEmu!==void 0||Z.verticalEmu!==void 0||Z.relativeToH!==void 0||Z.relativeToV!==void 0)){w();return}if(!r.can(Z).ok){v("imageProperties.errors.refused");return}if(!r.exec(Z).ok){v("imageProperties.errors.refused");return}w();},[r,p,y,C,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:UD,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:S=>{S.stopPropagation(),zD(S);},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:S=>S.stopPropagation(),onMouseDown:S=>S.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:C,onChange:S=>M(S.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:C,onChange:S=>H(S.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:T,onChange:S=>f(_=>_&&{..._,lockAspect:S.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:y||!b?.intrinsic,onClick:I,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,P?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,x?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:S=>f(_=>_&&{..._,relativeToH:S.target.value}),children:editor.DRAWING_REL_FROM_H.map(S=>jsxRuntime.jsx("option",{value:S,children:i(`dialogs.imagePosition.relativeOptions.${S}`)},S))})]}),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:S=>f(_=>_&&{..._,relativeToV:S.target.value}),children:editor.DRAWING_REL_FROM_V.map(S=>jsxRuntime.jsx("option",{value:S,children:i(`dialogs.imagePosition.relativeOptions.${S}`)},S))})]})]}):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:S=>f(_=>_&&{..._,horizontalPoints:S.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:S=>f(_=>_&&{..._,verticalPoints:S.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:S=>f(_=>_&&{..._,title:S.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:S=>f(_=>_&&{..._,description:S.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:S=>f(_=>_&&{..._,hyperlink:S.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder"),dir:"ltr"})]}),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:b?.canChangeWrap===false,onChange:S=>f(_=>_&&{..._,wrap:S.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(S=>jsxRuntime.jsx("option",{value:S,children:i(`imageWrap.targets.${S}`)},S))})]}),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:S=>f(_=>_&&{..._,cropLeft:S.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:S=>f(_=>_&&{..._,cropTop:S.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:S=>f(_=>_&&{..._,cropRight:S.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:S=>f(_=>_&&{..._,cropBottom:S.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 xs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=L(),{t:a}=F(),l=K(Ah),[s,c]=Bt.useState(false),d=Bt.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=te("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:U,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(X,{...h,children:n}):jsxRuntime.jsx("button",{...h,children:n??re(f?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Ee(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(ci,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}xs.docxSlot="image.properties";var ea=Object.assign(xs,{docxSlot:"image.properties"});function di(e){let t=L(),o=Bt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=K(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return Bt.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 vs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=di("image.altText"),[d,m]=Bt.useState(false),[u,g]=Bt.useState(""),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useId();Bt.useEffect(()=>{d&&g(l??"");},[d,l]),Bt.useEffect(()=>{if(!d)return;let x=k=>{let w=p.current;editor.isDomNode(k.target)&&(w?.contains(k.target)||w?.ownerDocument.getElementById(h)?.contains(k.target))||m(false);},E=k=>{k.key==="Escape"&&(k.preventDefault(),m(false),f.current?.focus());},P=editor.hostDocumentOf(p.current);return P.addEventListener("mousedown",x,true),P.addEventListener("keydown",E),()=>{P.removeEventListener("mousedown",x,true),P.removeEventListener("keydown",E);}},[d,h]);let v=Bt.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let b=te("image.altText"),y=i(b?.labelKey??"formattingBar.altText"),C={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:U,onClick:()=>m(x=>!x)},T={id:h,value:u,onValueChange:g,onApply:v,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(X,{...C,children:n}):jsxRuntime.jsx("button",{...C,children:n??y}),d&&r?.imageAltText!==false?r?.imageAltText?Ee(r.imageAltText,T):jsxRuntime.jsx(Cs,{...T}):null]})}vs.docxSlot="image.altText";var ui=Object.assign(vs,{docxSlot:"image.altText"});function Cs({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=F();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 dp(e){let[t,o]=Bt.useState(e.session),[n,r]=Bt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(aR,{...e},n)}function aR({session:e,className:t,style:o,children:n}){let r=Qe(),[i,a]=Bt.useState(e.signal.aborted),l=Bt.useRef(null);return Bt.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 qh=Bt.createContext(null),Uh=qh.Provider;function st(){let e=Bt.useContext(qh);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function hR(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function zh(e){let t=`docx-cc-list-${Bt.useId()}`,[o,n]=Bt.useState(()=>hR(e)),[r,i]=Bt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Bt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=Bt.useState(false),c=Bt.useCallback(D=>{i(D),s(false);},[]),d=K(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Bt.useState(()=>{let D=m??new Date;return {year:D.getFullYear(),month:D.getMonth()}}),p=Bt.useCallback(D=>{let M=e.apply(D??o);return s(!M),M},[e,o]),f=Bt.useCallback(()=>e.cancel(),[e]),h=Bt.useCallback(async D=>{if(!e.replaceImage)return s(true),false;try{let M=D instanceof Uint8Array?D.byteLength:D.size;if(!e.canApply()||M>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let H=D instanceof Uint8Array?D:new Uint8Array(await D.arrayBuffer()),I=await e.replaceImage(H);return s(!I),I}catch{return s(true),false}},[e]),v=Bt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),b=Bt.useCallback(()=>{g(D=>editor.shiftMonth(D.year,D.month,-1)),E(null);},[]),y=Bt.useCallback(()=>{g(D=>editor.shiftMonth(D.year,D.month,1)),E(null);},[]),C=Bt.useCallback(D=>p(D),[p]),T=Bt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[x,E]=Bt.useState(null),P=Bt.useCallback(D=>{let M=editor.parseIsoDate(D);M&&(g({year:M.getFullYear(),month:M.getMonth()}),E(editor.isoDateOf(M)));},[]),k=Bt.useCallback(()=>{let D=editor.calendarDateFromText(r,e.locale);return D?p(D):(s(true),false)},[r,e.locale,p]),w=Bt.useCallback((D,M)=>{!Number.isInteger(D)||D<100||D>9999||!Number.isInteger(M)||M<0||M>11||(g({year:D,month:M}),E(null));},[]);return Bt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:v,previousMonth:b,nextMonth:y,selectDay:C,selectToday:T,focusIso:x,focusDay:P,dateText:r,setDateText:c,applyDateText:k,showMonth:w,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:h}),[e,h,o,d,l,p,f,v,b,y,C,T,x,P,r,c,k,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:b,style:y,...C}=f;return jsxRuntime.jsx(X,{...u,...C,...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 Xn=e=>e.stopPropagation();function fp(e){return et("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(gp,{}),jsxRuntime.jsx(Pp,{}),jsxRuntime.jsx(bp,{}),jsxRuntime.jsx(hp,{className:"docx-content-control-calendar-announcement"})]}))}function gp(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:Xn,onClick:t.previousMonth},"\u2039")}function bp(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:Xn,onClick:t.nextMonth},"\u203A")}function hp(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 yp(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 xp({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:Xn,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function vp(e){let t=st(),o=Bt.useRef(null);return Bt.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(xp,{day:i},i.iso))},r)))}function Cp(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:Xn,onClick:t.selectToday},o("contentControl.calendar.today"))}function Tp(e){return et("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(fp,{}),jsxRuntime.jsx(yp,{}),jsxRuntime.jsx(vp,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Cp,{}),jsxRuntime.jsx(Es,{})]}),jsxRuntime.jsx(ta,{}),jsxRuntime.jsx(Ps,{})]}))}function Ep({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:Xn,onClick:()=>o.apply(e.value)},e.displayText)}function Ts(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(Ep,{item:n},r)))}function Es(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:Xn,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function ta(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 Sp(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 Ss(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 Ps(e){return et("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ss,{}),jsxRuntime.jsx(Sp,{})]}))}function Pp(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(kp,{}),jsxRuntime.jsx(wp,{})]}))}function kp(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 wp(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 Dp({autoOpen:e,...t}){let o=st(),n=Qe(),r=Bt.useRef(null),i=Bt.useRef(false);return Bt.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:Xn,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function kR(e){let[t,o]=Bt.useState(e.session),[n,r]=Bt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(wR,{...e},n)}function wR({session:e,className:t,style:o,children:n}){let r=Qe(),i=zh(e),[a,l]=Bt.useState(e.signal.aborted),s=Bt.useRef(null),[c]=Bt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(Bt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Bt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Bt.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]),Bt.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(Uh,{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??DR(i)})})}function DR(e){return e.kind==="date"?jsxRuntime.jsx(Tp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dp,{}),jsxRuntime.jsx(ta,{}),jsxRuntime.jsx(Ss,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Es,{}),jsxRuntime.jsx(Ts,{}),jsxRuntime.jsx(ta,{}),jsxRuntime.jsx(Ps,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ts,{}),jsxRuntime.jsx(ta,{})]})}var Ip=Object.assign(kR,{Navigation:Pp,Month:kp,Year:wp,Calendar:Tp,Header:fp,PreviousMonth:gp,Title:hp,NextMonth:bp,Weekdays:yp,Grid:vp,Day:xp,Today:Cp,List:Ts,Item:Ep,Input:Es,Picture:Dp,Error:ta,Footer:Ps,Apply:Sp,Cancel:Ss});var Vh="(prefers-color-scheme: dark)";function Gh(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function jh(){return Gh()?globalThis.window.matchMedia(Vh).matches:false}function Yh(e,t){return e==="dark"||e==="system"&&t}function Xh(e){if(!Gh())return ()=>{};let t=globalThis.window.matchMedia(Vh);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function Fp(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function Qh(){let e=L(),t=St(),o=Bt.useRef(t);o.current=t;let[n,r]=Bt.useState(null),[i,a]=Bt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Bt.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?.[Fp(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]),Bt.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]),Bt.useEffect(()=>{n&&t?.[Fp(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[Fp(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&m&&Ee(m,{session:n},n),i&&t?.invalidTextFormField&&Ee(t.invalidTextFormField,{session:i},i)]})}var $R=["nw","n","ne","e","se","s","sw","w"],r0=40,a0=12;function VR(e){return `imageOverlay.handle.${e}`}function GR(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 jR(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 YR(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 Hp({containerRef:e,portalRef:t,scrollPort:o}){let n=L(),{t:r}=F(),[i,a]=Bt.useState(null),[l,s]=Bt.useState(null),[c,d]=Bt.useState({left:0,top:0}),m=Bt.useRef(null);m.current=l;let u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useRef(null);Bt.useEffect(()=>{let P=e.current;if(!P)return;let k=w=>{let D=editor.isElementNode(w.target)?w.target:null;if(D?.closest(".docx-drawing-textbox-content")){f.current=null;return}let M=D?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=M??null,M&&M===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return P.addEventListener("pointerdown",k,{capture:true}),()=>P.removeEventListener("pointerdown",k,{capture:true})},[e,i?.id]),Bt.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 D of w)D();}},[n]);let v=Bt.useCallback(()=>{d(P=>{let k=editor.overlayHostOrigin(e.current);return k.left===P.left&&k.top===P.top?P:k});},[e]);Bt.useEffect(()=>{v();let P=t.current,k=editor.hostWindowOf(P).ResizeObserver;if(!P||typeof k!="function")return;let w=new k(v);w.observe(P);let D=e.current;return D&&w.observe(D),()=>w.disconnect()},[e,t,v,i]),Bt.useEffect(()=>{if(o){h.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 h.current=editor.createImageOverlayScrollPort(k,w.paintScale),()=>{h.current=null;}},[e,n,o]);let b=Bt.useCallback(()=>{s(null),u.current=null;let P=g.current;if(g.current=null,P)try{P.releasePointerCapture(P._lastPointerId??0);}catch{}},[]),y=Bt.useCallback((P,k,w,D,M,H,I)=>{if(!n?.surface)return;let A=n.surface.activeScope();if(A.kind==="frame"&&!n.surface.selectDrawing(w.id,A.hostParagraphId))return;let S=n.surface.layout(),_=editor.captureImageMutationPreconditions(n);if(_){u.current=Object.freeze({x:D,y:M}),g.current=H,H._lastPointerId=I;try{H.setPointerCapture(I);}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:P,handle:k,preconditions:_,layoutRevision:S.revision,packageRevision:n.surface.session.packageRevision(),kind:w.kind}),bounds:w,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),C=Bt.useCallback((P,k,w,D,M)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,P)){b();return}P.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:k,heightEmu:w,...M?.mode==="simple"?{horizontalEmu:M.horizontalEmu,verticalEmu:M.verticalEmu}:{},...M?.mode==="frame"?{...M.horizontalEmu!==void 0?{horizontalEmu:M.horizontalEmu}:{},...M.verticalEmu!==void 0?{verticalEmu:M.verticalEmu}:{}}:{}}):P.mode==="move"&&M&&n.exec({type:"setImagePosition",...M}),b();},[b,n]),T=Bt.useCallback(P=>{if(!n)return;let k=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!k)return;if(m.current&&P.key==="Escape"){P.preventDefault(),P.stopPropagation(),b();return}if(m.current)return;let w=editor.historyShortcutOf(P);if(w){P.preventDefault(),P.stopPropagation(),n.exec({type:w});return}let D=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 M=P.key==="ArrowLeft"?-D:P.key==="ArrowRight"?D:0,H=P.key==="ArrowUp"?-D:P.key==="ArrowDown"?D:0;if(P.altKey){if(!k.canResize)return;let A=YR(M,H),S=editor.computeImageResizeResult({handle:A,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:M,deltaYPt:H,transform:k.transform,preserveAspect:editor.resizePreservesAspect(A,k.aspectLocked,P.shiftKey,k.textbox),kind:k.kind});n.exec({type:"setImageProperties",widthEmu:S.widthEmu,heightEmu:S.heightEmu,...S.position?.mode==="simple"?{horizontalEmu:S.position.horizontalEmu,verticalEmu:S.position.verticalEmu}:{},...S.position?.mode==="frame"?{...S.position.horizontalEmu!==void 0?{horizontalEmu:S.position.horizontalEmu}:{},...S.position.verticalEmu!==void 0?{verticalEmu:S.position.verticalEmu}:{}}:{}});return}if(k.kind!=="anchored"||!k.canMove||!k.position)return;let I=editor.computeMovedImagePosition(k.position,M,H);n.exec({type:"setImagePosition",...I});},[b,n]);Bt.useEffect(()=>{if(!l||!n?.surface)return;let P=n.surface.overlayCoordinates(),k=M=>{let H=m.current,I=u.current;if(!H||!I)return;let A=editor.cssPixelsToLayoutPoints(M.clientX-I.x,P.paintScale),S=editor.cssPixelsToLayoutPoints(M.clientY-I.y,P.paintScale);if(H.session.mode==="move"){let B=0,Z=h.current,ee=e.current?.closest(".docx-editor__scroll-container");if(Z&&ee){let oe=ee.getBoundingClientRect();M.clientY>oe.bottom-r0?B=a0:M.clientY<oe.top+r0&&(B=-a0),B!==0&&(B=Z.scrollBy(B));}let j=H.accumulatedScrollPt+B;s({...H,accumulatedScrollPt:j,bounds:Object.freeze({...H.bounds,x:H.session.startBounds.x+A,y:H.session.startBounds.y+S+j})});return}if(!H.session.handle)return;let _=editor.computeImageResizeResult({handle:H.session.handle,startWidthEmu:H.session.startWidthEmu,startHeightEmu:H.session.startHeightEmu,startBounds:H.session.startBounds,startPosition:H.session.startPosition,anchorFrameOrigin:H.session.anchorFrameOrigin,deltaXPt:A,deltaYPt:S,transform:H.session.transform,preserveAspect:editor.resizePreservesAspect(H.session.handle,H.bounds.aspectLocked,M.shiftKey,H.bounds.textbox),kind:H.session.kind});s({...H,bounds:Object.freeze({...H.bounds,x:_.previewBounds.x,y:_.previewBounds.y,width:_.previewBounds.width,height:_.previewBounds.height,widthEmu:_.widthEmu,heightEmu:_.heightEmu})});},w=M=>{let H=m.current;if(H)if(M.type==="pointerup"){let I=editor.cssPixelsToLayoutPoints(M.clientX-(u.current?.x??M.clientX),P.paintScale),A=editor.cssPixelsToLayoutPoints(M.clientY-(u.current?.y??M.clientY),P.paintScale),S=editor.finalizeImageOverlayInteraction({session:H.session,deltaXPt:I,deltaYPt:A,accumulatedScrollPt:H.accumulatedScrollPt,aspectLocked:H.bounds.aspectLocked,textbox:H.bounds.textbox,shiftKey:M.shiftKey,anchorFrameOrigin:H.session.anchorFrameOrigin});C(H.session,S.widthEmu,S.heightEmu,S.previewBounds,S.position);}else b();},D=editor.hostWindowOf(e.current);return D.addEventListener("pointermove",k),D.addEventListener("pointerup",w),D.addEventListener("pointercancel",w),()=>{D.removeEventListener("pointermove",k),D.removeEventListener("pointerup",w),D.removeEventListener("pointercancel",w);}},[b,C,e,n,l]),Bt.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let x=l?.bounds??i,E=Bt.useMemo(()=>{if(!n?.surface||!x)return null;let P=n.surface.publishedLayout(),k=n.surface.overlayCoordinates(),w=editor.overlayFrameToSheetCssPixels(P,{pageIndex:x.pageIndex,x:x.x,y:x.y,width:x.width,height:x.height},k),D={left:w.left+c.left,top:w.top+c.top,width:w.width,height:w.height},M=x.canResize,H=x.kind==="anchored"&&x.canMove,I=editor.textboxFrameReason(x,n.surface.editingMode()),A=I?r(I):void 0;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":x.id,tabIndex:0,onKeyDown:T,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${H?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":x.textbox?"true":void 0,title:A,"aria-description":A,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${D.left}px`,top:`${D.top}px`,width:`${D.width}px`,height:`${D.height}px`,cursor:H?"move":"default"},onPointerDown:S=>{U(S),!(!H||!x.position)&&S.button===0&&(S.preventDefault(),S.stopPropagation(),y("move",null,x,S.clientX,S.clientY,S.currentTarget,S.pointerId));}}),M?$R.map(S=>{let _=jR(S);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(VR(S)),tabIndex:0,style:{left:`calc(${D.left}px + ${D.width}px * ${parseFloat(_.x)/100} - 5px)`,top:`calc(${D.top}px + ${D.height}px * ${parseFloat(_.y)/100} - 5px)`,cursor:GR(S)},onPointerDown:B=>{U(B),B.button===0&&(B.preventDefault(),B.stopPropagation(),y("resize",S,x,B.clientX,B.clientY,B.currentTarget,B.pointerId));}},S)}):null]})},[x,y,n,T,c.left,c.top,r]);return !E||!t.current?null:reactDom.createPortal(E,t.current)}function Ap(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Ms({className:e}){let t=L(),o=Ua(),n=Bt.useRef(null),r=Bt.useContext(hr),i=Bt.useCallback(d=>{n.current=d,r?.setContainer(d);},[r]),a=Bt.useRef(null);Bt.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=Bt.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Ap(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=Bt.useCallback(d=>{!o?.isEnabled||!Ap(d.dataTransfer)||d.preventDefault();},[o]),c=Bt.useCallback(d=>{if(o?.isEnabled&&Ap(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(ch,{}),jsxRuntime.jsx(wh,{}),jsxRuntime.jsx(Qh,{}),t?jsxRuntime.jsx(Hp,{containerRef:n,portalRef:a}):null]})}function Bp({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=Bt.useState(null),{dir:d}=F(),m=Bt.useRef(t);m.current=t;let u=Bt.useRef({url:n,name:r,features:i,title:a,styles:l});u.current={url:n,name:r,features:i,title:a,styles:l};let g=Bt.useRef(null);return Bt.useEffect(()=>{if(!e)return;let p=g.current;if(p)p.claimed=true;else {let{url:b,name:y,features:C,title:T,styles:x}=u.current;p={claimed:true,promise:editor.openEditorWindow({...b!==void 0?{url:b}:{},...y!==void 0?{name:y}:{},...C!==void 0?{features:C}:{},...T!==void 0?{title:T}:{},...x!==void 0?{styles:x}:{}})},g.current=p;}let f=p,h=true,v;return f.promise.then(b=>{if(h){if(!b){g.current=null,m.current?.();return}v=b.onClose(()=>{h&&(g.current=null,reactDom.flushSync(()=>c(null)),m.current?.());}),c(b);}}),()=>{h=false,v?.(),f.claimed=false,c(null),queueMicrotask(()=>{f.claimed||(g.current===f&&(g.current=null),f.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%"},dir:d,children:o}),s.element)}function $e(e){return e/1440*96}function _s(e){return e/96*1440}function kt(e){return `${Math.round(e*100)/100}px`}function Wp(e){return e/2}var bM=e=>e.isLoading||e.isOpening===true,hM=e=>({width:$e(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:$e(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),yM=(e,t)=>e.width===t.width&&e.height===t.height;function Zp({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var c0=false;function d0(){c0||!gt()||(c0=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 xM(e){let t=L(),[o,n]=Bt.useState(null);return Bt.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function vM({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=K(bM),l=K(hM,yM),s=xM(t),c=L(),d=Bt.useRef({visible:false,editor:null}),[,m]=Bt.useReducer(v=>v+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);Bt.useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=F(),f=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zp,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return reactDom.createPortal(f,s);if(!g)return null;let h=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:h,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:f})})})})})}var Is=Object.assign(vM,{Spinner:Zp});function u0(){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 bi=Bt.createContext(null);function f0(){let e=Bt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function Kp(){let e=Bt.useContext(bi),t=f0();return Bt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function qp(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=Bt.useContext(bi),s=f0();return Bt.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 g0=false;function b0(e,t){e===t||g0||!gt()||(g0=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 h0=false,y0=e=>e?.allowFormattingInLockedContent===true;function x0(e,t){y0(e)===y0(t)||h0||!gt()||(h0=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 v0=false;function C0(e){return e===void 0?"characters":e}function T0(e,t){C0(e)===C0(t)||v0||!gt()||(v0=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 _M(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 IM(e){let t=Bt.useRef(e);t.current=e;let[o,n]=Bt.useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=Bt.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:hi,rootProps:s,rootListeners:c,editorRef:o}}function hi(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}=F(),p=Bt.useCallback((W,J)=>g(W,J),[g]),f=Bt.useRef(p);f.current=p;let h=Bt.useRef(false),[v,b]=Bt.useState(0),y=Bt.useRef(e);y.current=e;let C=n?.maxFontBytes,[T,x]=Bt.useState(null),E=Bt.useRef(e.fieldResults),P=Bt.useRef(e.contentLockPolicy),k=Bt.useRef(e.lockedControlNavigation),w=Bt.useRef(e.fonts),D=Bt.useRef(null);D.current??=u0();let M=D.current,H=Bt.useRef(null);H.current??=Vf();let I=H.current;Bt.useEffect(()=>{let W=y.current,J=W.translate??f.current,de=M.current();E.current=W.fieldResults,P.current=W.contentLockPolicy,k.current=W.lockedControlNavigation;let he=editor.createDocxEditor({unsupportedElementRules:I.current(),...W.document!==void 0?{document:W.document}:{},...W.fonts?{fonts:W.fonts}:{},...W.fontShaping?{fontShaping:W.fontShaping}:{},...W.author!==void 0?{author:W.author}:{},...W.locale!==void 0?{locale:W.locale}:{},translate:J,...W.revisionMarkup!==void 0?{revisionMarkup:W.revisionMarkup}:{},...W.reviewDisplayMode!==void 0?{reviewDisplayMode:W.reviewDisplayMode}:{},...W.fieldResults!==void 0?{fieldResults:W.fieldResults}:{},...W.contentLockPolicy!==void 0?{contentLockPolicy:W.contentLockPolicy}:{},...W.lockedControlNavigation!==void 0?{lockedControlNavigation:W.lockedControlNavigation}:{},...W.mode!==void 0?{mode:W.mode}:{},...de!==void 0?{revisionStyles:de}:{},...W.modules!==void 0?{modules:W.modules}:{},...W.zoom!==void 0?{zoom:W.zoom}:{},...W.zoomMode!==void 0?{zoomMode:W.zoomMode}:{},...W.tableInteractionLabel?{tableInteractionLabel:W.tableInteractionLabel}:{},...W.imageDecodePort?{imageDecodePort:W.imageDecodePort}:{},onFontError:Ke=>y.current.onFontError?.(Ke)});w.current=W.fonts;let Oe=he.on("revisionMarkupChange",Ke=>{h.current||(y.current.onRevisionMarkupChange?.(Ke),b(Te=>Te+1));}),we=he.on("change",Ke=>y.current.onChange?.(Ke));return x(he),()=>{Oe(),we(),he.destroy(),x(Ke=>Ke===he?null:Ke);}},[t,C,m,M,I]),Bt.useEffect(()=>{!T||w.current===o||(w.current=o,T.setFonts(o).catch(()=>{}));},[T,o]),Bt.useEffect(()=>{if(!T)return;if(!T.snapshot().isOpening){y.current.onReady?.(T);return}let W=T.on("change",()=>{W(),y.current.onReady?.(T);});return W},[T]);let A=Bt.useRef({editor:null,zoom:void 0,mode:void 0});Bt.useEffect(()=>{if(!T)return;A.current.editor!==T&&(A.current={editor:T,zoom:void 0,mode:void 0});let J=false;s!==void 0&&s!==A.current.zoom&&(A.current.zoom=s,T.setZoom(s),J=true);let de=A.current.mode,he=c!==void 0&&(de===void 0||!_M(de,c)),Oe=c===void 0?null:editor.resolveZoomMode(c),we=J&&c!==void 0&&Oe!==null&&Oe.type==="fit";(he||we)&&(A.current.mode=c,T.setZoomMode(c));},[T,s,c]),Bt.useEffect(()=>{if(!T||e.revisionMarkup===void 0)return;let W=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(W)!==JSON.stringify(T.snapshot().revisionMarkup)){h.current=true;try{T.setRevisionMarkup(W);}finally{h.current=false;}}},[T,e.revisionMarkup,v]),Bt.useEffect(()=>{T&&T.setAuthor(r);},[T,r]);let S=Bt.useRef({editor:null,value:void 0});Bt.useEffect(()=>{if(T){if(S.current.editor!==T){S.current={editor:T,value:l};return}S.current.value!==l&&(S.current.value=l,T.setMode(l));}},[T,l]),Bt.useEffect(()=>{T&&T.setTranslate(a??p);},[T,a,p]),Bt.useEffect(()=>{T&&T.setLocale(i);},[T,i]),Bt.useEffect(()=>{T&&b0(E.current,e.fieldResults);},[T,e.fieldResults]),Bt.useEffect(()=>{T&&x0(P.current,e.contentLockPolicy);},[T,e.contentLockPolicy]),Bt.useEffect(()=>{T&&T0(k.current,e.lockedControlNavigation);},[T,e.lockedControlNavigation]),Bt.useEffect(()=>{T&&T.setTableInteractionLabel(d??editor.defaultTableLabel);},[T,d]);let[_,B]=Bt.useState(0),[Z,ee]=Bt.useState(0),j=Bt.useRef([]),[oe,$]=Bt.useState(0),V=oe>0,ce=Bt.useRef(T);ce.current=T,Bt.useEffect(()=>{if(!(!T||!V))return T.setCommentDraftChrome({onRequest:()=>j.current.at(-1)?.()})},[T,V]);let O=Bt.useMemo(()=>({mounted:_,register:()=>(B(W=>W+1),()=>B(W=>Math.max(0,W-1))),gutters:Z,reserveGutter:()=>(ee(W=>W+1),()=>ee(W=>Math.max(0,W-1))),registerCommentDraft:W=>(j.current.push(W),$(J=>J+1),()=>{let J=j.current.indexOf(W);J!==-1&&(j.current.splice(J,1),$(de=>Math.max(0,de-1)));}),requestCommentDraft:()=>{let W=ce.current;return W!==null&&editor.runToolbarCommand(W,"review.addComment").ok}}),[_,Z]),N=Bt.useMemo(ig,[]);return Bt.useEffect(()=>(M.connect(T),()=>M.connect(null)),[M,T]),Bt.useEffect(()=>(I.connect(T),()=>I.connect(null)),[I,T]),jsxRuntime.jsx(hr.Provider,{value:I,children:jsxRuntime.jsx(rh,{value:a??p,children:jsxRuntime.jsx(Nt.Provider,{value:O,children:jsxRuntime.jsx(gd.Provider,{value:T,children:jsxRuntime.jsx(kd.Provider,{value:N,children:jsxRuntime.jsx(bi.Provider,{value:M,children:jsxRuntime.jsx(NM,{children:jsxRuntime.jsx(FM,{children:jsxRuntime.jsx(kh,{value:e.popups,children:jsxRuntime.jsx(Wl,{children:jsxRuntime.jsx(sh,{popups:e.popups,children:u})})})})})})})})})})})}function NM({children:e}){let t=Ml(true);return jsxRuntime.jsx(Fa.Provider,{value:t,children:e})}function FM({children:e}){let t=Il();return jsxRuntime.jsx(Jd.Provider,{value:t,children:e})}var yi=316,aa=editor.REVIEW_MARKERS_GUTTER_PX,k0=24,Ns={inlineStart:0,inlineEnd:yi},E0={inlineStart:aa,inlineEnd:aa},qM={inlineStart:0,inlineEnd:0},$p={inlineStart:k0,inlineEnd:yi};function Gp(e){return e.inlineStart===$p.inlineStart&&e.inlineEnd===$p.inlineEnd}function w0(e,t){return Gp(e)?Math.max(0,t-(yi-aa)):t}function Fs(){let e=at(),t=Se(),[o,n]=Bt.useState("ltr");return Bt.useLayoutEffect(()=>{let r=t?.parentElement;if(e||!r)return;let i=()=>n(editor.hostDirectionOf(r));return i(),editor.observeHostDirection(r,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function D0(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function R0({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return E0;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Ns;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*k0>=yi?Ns:i?$p:E0}var UM=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"}},zM=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function M0(){let e=Se(),[t,o]=Bt.useState(null);return Bt.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 fn(){let e=Bt.useContext(Nt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=K(UM,zM),i=Se(),a=sg(),l=Bt.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=vl(e),d=Bt.useCallback(f=>c?R0({open:o,viewportWidth:f??0,pageWidthPx:s===null||n===null?0:$e(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):qM,[c,o,s,n,a,r]),m=()=>d(i?i.clientWidth:null),[u,g]=Bt.useState(()=>({compute:d,viewport:i,gutter:m()})),p=u;return (u.compute!==d||u.viewport!==i)&&(p={compute:d,viewport:i,gutter:m()},g(p)),Bt.useEffect(()=>{let f=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let h=()=>g(b=>{let y=d(i.clientWidth);return y===b.gutter?b:{compute:d,viewport:i,gutter:y}}),v=new f(h);return v.observe(i),()=>v.disconnect()},[i,d]),p.gutter}var Ls=[.25,.5,.75,1,1.25,1.5,2];function xi(e,t){return t==="in"?Ls.find(n=>n>e+.001)??null:[...Ls].reverse().find(n=>n<e-.001)??null}function _0(e,t){return e==="0"?1:e==="+"||e==="="?xi(t,"in")??t:e==="-"?xi(t,"out")??t:null}var jp=Bt.createContext(false);function I0(e){let t=Bt.useContext(jp),[o,n]=Bt.useState(null);return Bt.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 t1=e=>e.reviewPaneOpen??true,o1=e=>e.zoomMode?.type==="fit";function Hs({className:e,style:t,children:o}){let{t:n}=F(),r=Lt(),i=L(),a=K(t1),l=fn(),s=Fs(),c=K(o1),d=Bt.useContext(Nt),m=vl(d),u=Nn(),g=Fn(),p=Bt.useRef(null),f=Bt.useCallback(b=>{p.current=b,u?.setViewport(b);},[u]),h=s==="left"&&m&&Gp(l);Bt.useLayoutEffect(()=>{let b=p.current;return h&&b?editor.keepScrollAtInlineEnd(b):void 0},[h]);let v=Bt.useCallback(b=>{if(!i||!(b.metaKey||b.ctrlKey)||b.altKey)return;let y=b.target;if(editor.isElementNode(y)&&y.closest('input, textarea, select, [role="dialog"]'))return;let C=_0(b.key,i.getZoom());C!==null&&(b.preventDefault(),i.setZoom(C));},[i]);return jsxRuntime.jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:v,...m?{"data-review-pane":a?"open":"closed"}:{},...s==="left"?{"data-chrome-dir":"rtl"}:{},...m&&s==="left"?{"data-review-side":"left"}:{},...c?{"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":`${g}px`,...m?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*aa}px`}:{}},children:jsxRuntime.jsx(Gn.Provider,{value:true,children:jsxRuntime.jsx(jp.Provider,{value:true,children:o})})})}var r1=editor.LOADING_SNAPSHOT;function F0({ref:e,editorRef:t}){Bt.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)??r1}),[t]);}function ia(e,t,o,n){let r=Se(),i=Bt.useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},Bt.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 g1=e=>e.editingMode??"editing",Jp='[role="menuitemradio"]:not([disabled])',b1=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),h1=e=>e.isLoading||e.isOpening===true,vi=[{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"}],y1=Object.freeze(vi.map(()=>null));function x1(e){return e?vi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):y1}var v1="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function Os({className:e,hidden:t}){let o=L(),n=K(g1),r=K(h1),i=ne(),{t:a}=F(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.useEffect(()=>{if(!l)return;let y=m.current?.querySelectorAll(Jp);(m.current?.querySelector(`${Jp}[aria-checked="true"]`)??y?.[0]??void 0)?.focus();},[l]);let u=Bt.useCallback(y=>{let C=[...m.current?.querySelectorAll(Jp)??[]],T=C.indexOf(editor.hostDocumentOf(m.current).activeElement),x=E=>{y.preventDefault(),C[(E+C.length)%C.length]?.focus();};y.key==="ArrowDown"?x(T+1):y.key==="ArrowUp"?x(T-1):y.key==="Home"?x(0):y.key==="End"&&x(C.length-1);},[]);Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),ia(l,c,y=>{s(false),y&&d.current?.focus();});let g=Bt.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=K(()=>x1(o),b1),v=Bt.useMemo(()=>vi.find(y=>y.mode===n)??vi[0],[n]);if(t)return null;let b=te("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(b?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:U,onClick:()=>s(y=>!y),children:[Qp(v.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(v.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(b?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:vi.map((y,C)=>{let T=i18n.localizeDisabledReason(h[C]??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:T!==null,...T?{title:T}:{},onMouseDown:U,onClick:()=>g(y.mode),children:[Qp(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?Qp(v1):null})]},y.mode)})}):null]})}Os.docxSlot="review.editingMode";function Qp(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 O0=[],E1=()=>{};function Ci(){let e=L(),t=Bt.useCallback(o=>{if(!e)return E1;let n=Da(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return Bt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??O0,()=>O0)}var _1=e=>e.hiddenReviewAuthors??[];function Ws({className:e,hidden:t,icon:o}){let n=L(),r=Ci(),i=K(_1),a=new Set(i),l=r.every(C=>!a.has(C.author)),[s,c]=Bt.useState(false),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=ne(),{t:p}=F();Bt.useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),editor.listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),ia(s,d,C=>{c(false),C&&m.current?.focus();});let f=Bt.useCallback(C=>{let T=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],x=T.indexOf(editor.hostDocumentOf(u.current).activeElement),E=P=>{C.preventDefault(),T[(P+T.length)%T.length]?.focus();};C.key==="ArrowDown"?E(x+1):C.key==="ArrowUp"?E(x-1):C.key==="Home"?E(0):C.key==="End"?E(T.length-1):C.key==="Tab"&&c(false);},[]);if(t)return null;let h=te("review.authors"),v=editor.toolbarCommandState(n,"review.authors"),b=i18n.localizeDisabledReason(v.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:!v.enabled,title:b??y,onMouseDown:U,onClick:()=>c(C=>!C),children:[o??re(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(B0,{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(C=>jsxRuntime.jsx(B0,{checked:!a.has(C.author),label:C.author||"\u2014",testId:`reviewer-${C.slot}`,color:C.color,onChoose:()=>n?.setReviewAuthorVisible(C.author,a.has(C.author))},C.author))]}):null]})}Ws.docxSlot="review.authors";function B0(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:U,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 Z0=Bt.createContext(null);function K0({children:e}){let t=To(),[o,n]=Bt.useState(false),r=Bt.useRef(null),i=Se(),a=Bt.useRef(i);a.current=i;let l=Bt.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}r.current=c??editor.hostDocumentOf(a.current).activeElement,n(true);}}),[t]),s=Bt.useCallback(()=>{n(false);let c=r.current;r.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(Z0.Provider,{value:l,children:[e,jsxRuntime.jsx(Zo,{open:o,onClose:s})]})}function q0(){return Bt.useContext(Z0)}var tm=["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"],om=Bt.createContext({close:()=>{}});function la(){return Bt.useContext(om).close}function J1(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function V0({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 G0({slot:e}){let t=ne(),o=Ho(),{close:n}=Bt.useContext(om),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=se(e),c=te(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:U,onClick:u=>{r(),n(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function j0({sections:e,className:t}){let o=ne(),[n,r]=Bt.useState(false),i=Bt.useRef(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(false),c=Bt.useId(),d=Se(),m=Bt.useRef(d);m.current=d;let u=o("formattingBar.more"),g=Bt.useCallback(b=>{r(false),b&&a.current?.focus();},[]),p=Bt.useMemo(()=>({close:g}),[g]);Bt.useEffect(()=>{if(!n)return;let b=i.current,y=E=>i.current?.contains(E)===true||l.current?.contains(E)===true,C=b?editor.listenForPopupEscape({popup:b,contains:y,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,T=b?editor.listenForPopupFocusLeave({popup:b,contains:y,close:()=>r(false)}):void 0,x=editor.listenForOutsidePress({popup:b,close:()=>r(false)});return ()=>{x(),C?.(),T?.();}},[n,g]);let[f,h]=Bt.useState(null);Bt.useLayoutEffect(()=>{if(!n){h(null);return}let b=()=>{let C=i.current,T=l.current,x=a.current,E=C?.ownerDocument.defaultView;if(!C||!T||!x||!E)return;let P=x.getBoundingClientRect(),k=editor.toolbarPanelPlacement({triggerLeft:P.left,triggerRight:P.right,panelWidth:T.offsetWidth,viewportWidth:E.innerWidth}),w=k.left-C.getBoundingClientRect().left;h(D=>D&&D.left===w&&D.maxWidth===k.maxWidth&&D.anchor===k.anchor?D:{...k,left:w});};b();let y=i.current?.ownerDocument.defaultView;return y?.addEventListener("resize",b),()=>y?.removeEventListener("resize",b)},[n]),Bt.useEffect(()=>{if(!n||!s.current)return;s.current=false;let b=l.current;b&&J1(b);},[n]);let v=b=>{b.key!=="Escape"||b.defaultPrevented||(b.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Ka]:"",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:U,onClick:()=>r(b=>!b),onKeyDown:b=>{b.key==="ArrowDown"&&(b.preventDefault(),s.current=true,r(true));},children:re(tm)}),n?jsxRuntime.jsx(om.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:v,children:e.map(b=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":b.label??o(b.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:b.label??o(b.labelKey)}),b.children]},b.id))})}):null]})}function e2(e){if(!Bt.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function X0(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of Bt.Children.toArray(e)){if(e2(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&&Bt.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}function Ks(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function nm(e){let t=ne();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":Ks(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}nm.docxToolbarGroup=true;function Ei(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}Ei.docxToolbarSlot=true;var rm=Bt.createContext("bar");function J0(){return Bt.useContext(rm)}var qs="review.addComment";function a2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Bt.useContext(Nt),a=ne(),{isEnabled:l,reason:s}=Fl(a),c=la();if(t||(i?.mounted??0)===0)return null;let d=te(qs),m=a(d?.labelKey??qs),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":qs,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:U,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsxRuntime.jsx(X,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??re(d?.paths)})}var am=Object.assign(a2,{docxSlot:qs});var ty=new Set;function Us(e){!gt()||ty.has(e)||(ty.add(e),console.warn(`[docx-editor] ${e}`));}function oy(e,t,o){Us(`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 ny(e,t){Us(`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 ry(e){Us(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function ay(e,t){Us(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 lm=[{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 $s({className:e,hidden:t,asChild:o,children:n}){let{t:r}=F(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=di("image.wrap"),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useId(),h=Bt.useMemo(()=>lm.find(x=>x.value===l)??lm[0],[l]),v=te("image.wrap"),b=i(v?.labelKey??"formattingBar.imageWrap");Bt.useEffect(()=>{if(!d)return;let x=k=>{let w=u.current;w&&editor.isDomNode(k.target)&&w.contains(k.target)||m(false);},E=k=>{k.key==="Escape"&&(k.preventDefault(),m(false),g.current?.focus());},P=editor.hostDocumentOf(u.current);return P.addEventListener("mousedown",x,true),P.addEventListener("keydown",E),()=>{P.removeEventListener("mousedown",x,true),P.removeEventListener("keydown",E);}},[d]);let y=Bt.useCallback(x=>{m(false),a(x);},[a]);if(t)return null;let C=r("imageWrap.tooltipPrefix",{label:r(h.labelKey)}),T={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":b,title:c??C,onMouseDown:U,onClick:()=>m(x=>!x)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(X,{...T,children:n}):jsxRuntime.jsx("button",{...T,children:n??re(v?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:x=>x.stopPropagation(),children:lm.map(x=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===x.value,...l===x.value?{"data-active":""}:{},onMouseDown:U,onClick:()=>y(x.value),children:r(x.labelKey)},x.value))}):null]})}$s.docxSlot="image.wrap";var Si=Object.assign($s,{docxSlot:"image.wrap"});var sa="table.insert";function C2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=L(),{isEnabled:a,disabledReason:l}=se(sa),s=ne(),[c,d]=Bt.useState(false),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useId(),f=la();Bt.useEffect(()=>{if(!(!c||!m.current))return editor.listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),Bt.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;Bt.useLayoutEffect(()=>{let T=g.current,x=m.current,E=x?.ownerDocument.defaultView;if(!h||!T||!x||!E||x.closest(".docx-toolbar__more-panel"))return;let P=x.getBoundingClientRect(),k=editor.toolbarPopupLeft({anchorLeft:P.left,popupWidth:T.offsetWidth,viewportWidth:E.innerWidth});T.style.left=`${k-P.left}px`;},[h]);let v=Bt.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let b=te(sa),y=s(b?.labelKey??sa),C={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":sa,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:U,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:T=>{T.key==="ArrowDown"&&(T.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsxRuntime.jsx(X,{...C,children:r}):jsxRuntime.jsx("button",{...C,children:o??r??re(b?.paths)}),h?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:T=>{let x=T.relatedTarget;editor.isDomNode(x)&&!m.current?.contains(x)&&d(false);},onKeyDown:T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(ql,{slot:sa,label:s("toolbar.insertTable"),onInserted:v})}):null]})}var cm=Object.assign(C2,{docxSlot:sa});function tt(e){return Object.assign(o=>jsxRuntime.jsx(Ao,{slotId:e,...o}),{docxSlot:e})}var ly=tt("history.undo"),sy=tt("history.redo"),cy=tt("text.bold"),dy=tt("text.italic"),uy=tt("text.underline"),py=tt("text.strike"),my=tt("format.clear"),fy=tt("script.super"),gy=tt("script.sub"),by=tt("alignment.left"),hy=tt("alignment.center"),yy=tt("alignment.right"),xy=tt("alignment.justify"),vy=tt("direction.ltr"),Cy=tt("direction.rtl"),Ty=tt("list.bullet"),Ey=tt("list.numbered"),Sy=tt("list.outdent"),Py=tt("list.indent");var ky=tt("review.comments");function k2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=L(),{openAtCaret:a}=Wd(),l=editor.chromeProbeForSlot("text.link"),s=i&&l?i.can(l):null,c=s?.ok===true,{t:d}=F(),m=i18n.localizeDisabledReason(s&&!s.ok?s.reason:null,d),u=ne();if(t)return null;let g=te("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:U,onClick:()=>a()};return n?jsxRuntime.jsx(X,{...f,children:r}):jsxRuntime.jsx("button",{...f,children:o??r??re(g?.paths)})}var dm=Object.assign(k2,{docxSlot:"text.link"});function w2({className:e,hidden:t}){let o=L(),{onSave:n}=Bt.useContext(Ln),r=ne();if(t)return null;let i=te("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:U,onClick:()=>n?.(),children:re(i?.paths)})}var um=Object.assign(w2,{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}),_2=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,Dy={type:"fixed"};function pm(){let e=L(),{zoom:t,mode:o}=K(M2,_2),n=Bt.useCallback(i=>{e?.setZoom(i);},[e]),r=Bt.useCallback(i=>{e?.setZoomMode(i);},[e]);return Bt.useMemo(()=>{let i=o??Dy,a=xi(t,"out"),l=xi(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(Dy),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Ls}},[e,t,o,n,r])}var wi=2,Di=3276,ki=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],L2=e=>e.formatting?.fontSizePt??null;function _y(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-=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:U,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:U,onClick:e.onIncrease,children:"+"})]})}function H2(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<wi||n>Di?null:n}function A2({className:e,hidden:t}){let o=L(),n=K(L2),{isEnabled:r,disabledReason:i}=se("font.size"),a=ne(),[l,s]=Bt.useState(false),[c,d]=Bt.useState(null),m=Bt.useRef(null);Lo(m,l,()=>s(false));let u=Bt.useRef(null),g=Bt.useId(),p=Bt.useCallback(x=>{if(!o)return;let E=editor.commandForSlotValue("font.size",x);E&&o.can(E).ok&&o.exec(E);},[o]),f=Bt.useCallback(x=>{p(Math.min(Di,Math.max(wi,Math.round(x*2))));},[p]),h=Bt.useCallback(x=>{s(false),d(null),u.current?.blur(),x&&o?.focus();},[o]);if(Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let v=r&&n!==null,b=n===null?"\u2014":String(Math.round(n*2)/2),y=c??b,C=n===null?null:Math.round(n*2)/2,T=()=>{if(c===null)return;let x=H2(c);x!==null&&p(x);};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:x=>{d(x.target.value),s(true);},onFocus:x=>{x.target.select(),s(true);},onClick:()=>s(true),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),T(),h(true)):x.key==="Escape"?(x.preventDefault(),h(true)):(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),s(true),n!==null&&f(x.key==="ArrowDown"?Iy(n,ki,wi/2):_y(n,ki,Di/2)));},onBlur:()=>{T(),d(null);}}),canDecrease:v&&Math.round(n*2)>wi,canIncrease:v&&Math.round(n*2)<Di,onDecrease:()=>f(Iy(n??0,ki,wi/2)),onIncrease:()=>f(_y(n??0,ki,Di/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:ki.map(x=>{let E=C===x;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>{f(x),h(true);},children:x},x)})}):null]})}var gm=Object.assign(A2,{docxSlot:"font.size"});function O2({className:e,hidden:t}){let o=L(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=pm(),g=ne(),[p,f]=Bt.useState(false),h=Bt.useRef(null);Lo(h,p,()=>f(false)),Bt.useEffect(()=>{if(p)return editor.listenForOutsidePress({popup:h.current,close:()=>f(false)})},[p]);let v=Bt.useCallback(x=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(x);},[a]),b=Bt.useCallback(x=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(x==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let y=`${Math.round(n*100)}%`,C=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),T=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:U,onClick:()=>f(x=>!x),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":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>b("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>b("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(x=>{let E=!r&&Math.abs(x-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>v(x),children:`${Math.round(x*100)}%`},x)})]}):null]})}var bm=Object.assign(O2,{docxSlot:"zoom.level"});function Qn(e,t,o,n=false){let r=Se(),i=Bt.useRef(r);i.current=r,Bt.useEffect(()=>{e&&n&&t(false);},[e,n,t]),Bt.useEffect(()=>{let a=o.current;if(!e||n||!a)return;let l=m=>a.contains(m),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:m=>{t(false),m&&a.querySelector("[aria-haspopup]")?.focus();}}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)}),d=editor.listenForOutsidePress({popup:a,contains:l,close:()=>t(false)});return ()=>{d(),s(),c();}},[e,n,t,o]);}var By=10,Wy=0,$2=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),V2=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function G2({className:e,hidden:t}){let o=L(),n=K($2,V2),{isEnabled:r,disabledReason:i}=se("list.lineSpacing"),a=se("paragraph.dialog"),l=q0(),s=ne(),{lang:c}=F(),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null);Qn(d,m,u,t);let p=Bt.useCallback(C=>{m(false),!(!o||!C.command)&&o.can(C.command).ok&&o.exec(C.command);},[o]),f=Bt.useCallback((C,T)=>{if(m(false),!o)return;let x={type:"setParagraphSpacing",[C]:T};o.can(x).ok&&o.exec(x);},[o]);if(t)return null;let h=te("list.lineSpacing"),v=(n.spaceBeforePt??0)>0,b=(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:U,onClick:()=>m(C=>!C),children:[re(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(C=>{let T=C.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>p(C),children:[editor.lineSpacingMenuRowLabel(C,s,c),T?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${C.spacing.rule}:${C.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:U,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:U,onClick:()=>f("beforePt",v?Wy:By),children:s(v?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>f("afterPt",b?Wy:By),children:s(b?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var hm=Object.assign(G2,{docxSlot:"list.lineSpacing"});var X2=["alignment.left","alignment.center","alignment.right","alignment.justify"];function J2({className:e,hidden:t}){let o=se("alignment.left"),n=se("alignment.center"),r=se("alignment.right"),i=se("alignment.justify"),a=ne(),[l,s]=Bt.useState(false),c=Bt.useRef(null);if(Qn(l,s,c,t),t)return null;let d=[o,n,r,i],m=X2.map((f,h)=>({slot:f,control:te(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:U,onClick:()=>s(f=>!f),children:[re(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:U,onClick:()=>{f.state.execute(),s(false);},children:re(f.control?.paths)},f.slot)})}):null]})}var js=Object.assign(J2,{docxSlot:"alignment"});function xm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=J0(),m=la();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=>U(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=>U(g),onClick:r?void 0:a};return l?jsxRuntime.jsx(X,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var i_=Object.freeze([]),l_=e=>e.formatting?.fontFamily??null,s_=e=>e;function Js(){let e=L(),t=K(l_),o=K(s_),n=Bt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():i_,[e,o]),{isEnabled:r}=se("font.family"),i=Bt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Bt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Uy=Bt.createContext(null);function Cm(){return Bt.useContext(Uy)}function Tm({asChild:e,className:t,children:o}){let n=Cm(),r=ne();if(!n)return null;let i=r(te("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:U,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(X,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}Tm.docxToolbarPart=true;var c_=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"]]),d_=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function zy({asChild:e,className:t,children:o}){let n=Cm(),r=ne(),[i,a]=Bt.useState("");if(Bt.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=d_.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(c_.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($y,{value:u},u))]},d.category)),e?jsxRuntime.jsx(X,{...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 $y({value:e,asChild:t,className:o,children:n}){let r=L(),i=Cm();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:U,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(X,{...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 u_({hidden:e,asChild:t,className:o,children:n}){let r=Js(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Lo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.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(Tm,{}),jsxRuntime.jsx(zy,{})]});return jsxRuntime.jsx(Uy.Provider,{value:s,children:t?jsxRuntime.jsx(X,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Em=Object.assign(u_,{docxSlot:"font.family",Trigger:Tm,Content:zy,Item:$y});var m_={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},f_=new Set(["Title","Heading1","Heading2","Heading3"]),g_={Subtitle:"666666"},b_="#4a6c8c";function Vy(e){let t=m_[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??f_.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??g_[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=b_),n}var h_=/^heading ([1-9])$/;function Sm(e,t){let o=e||t,n=h_.exec(o);return n?`Heading ${n[1]}`:o}function Gy(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Sm(t.name,t.styleId),priority:99}))}function k_(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 w_=Object.freeze([]),D_=e=>e.formatting?.styleId??null,R_=e=>e;function Qs(){let e=L(),t=K(D_),o=K(R_),n=Bt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:Sm(a.name,a.styleId),preview:a.preview})):w_,[e,o]),{isEnabled:r}=se("styles.style"),i=Bt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Bt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var jy=Bt.createContext(null);function km(){return Bt.useContext(jy)}function wm({asChild:e,className:t,children:o}){let n=km(),r=ne();if(!n)return null;let i=te("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:U,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(X,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}wm.docxToolbarPart=true;function Yy({asChild:e,className:t,children:o}){let n=ne(),r=km();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(Xy,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(X,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function Xy({value:e,asChild:t,className:o,children:n}){let r=L(),i=km();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:U,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsxRuntime.jsx("span",{style:l?k_(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(X,{...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 M_({hidden:e,asChild:t,className:o,children:n}){let r=Qs(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Lo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.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(wm,{}),jsxRuntime.jsx(Yy,{})]});return jsxRuntime.jsx(jy.Provider,{value:s,children:t?jsxRuntime.jsx(X,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Dm=Object.assign(M_,{docxSlot:"styles.style",Trigger:wm,Content:Yy,Item:Xy});function Qy(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=se(o),m=bo(),u=t==="showAll"?m.showAll:m.formFill,g=ne();if(i)return null;let p=te(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:U,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(X,{...h,children:s}):jsxRuntime.jsx("button",{...h,children:a??s??re(p?.paths)})},{docxSlot:o})}function I_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Pt.inspector,{isEnabled:a,disabledReason:l}=se(i),{inspectorOpen:s,openInspector:c}=bo(),d=ne();if(t)return null;let m=te(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:U,onClick:()=>c()};return n?jsxRuntime.jsx(X,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??re(m?.paths)})}function N_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=bo(),s=ne();if(t)return null;let c=Pt.remove,d=te(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:U,onClick:()=>{l();}};return n?jsxRuntime.jsx(X,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??re(d?.paths)})}var ec=Qy(Pt.showAll,"showAll"),tc=Qy(Pt.formFill,"formFill"),oc=Object.assign(N_,{docxSlot:Pt.remove}),nc=Object.assign(I_,{docxSlot:Pt.inspector}),ex={[Pt.showAll]:ec,[Pt.formFill]:tc,[Pt.inspector]:nc,[Pt.remove]:oc};var da=Object.assign(e=>jsxRuntime.jsx(Ao,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function F_({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=se("table.splitCell"),a=To(),l=ne();if(n||!a)return null;let s=l(te("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:U,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??re(te("table.splitCell")?.paths)})}var ua=Object.assign(F_,{docxSlot:"table.splitCell"});function Rm(e,t){let o=L(),n=Bt.useRef(t);n.current=t,Bt.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var Z_=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],_m=Bt.createContext(null);function sx(){let e=Bt.useContext(_m);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function q_(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 U_(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function z_(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var ix={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function $_(e,t){let o={};for(let n of Z_){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function Im({children:e}){let t=L(),[o,n]=Bt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=Bt.useState(ix);Bt.useEffect(()=>(()=>{}),[]);let a=K(Bt.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:""}),[]),U_,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=Bt.useCallback(()=>{if(!t){i(ix);return}let u=q_(t,t.snapshot());i(g=>z_(g,u)?g:u);},[t]);Bt.useEffect(()=>{l();},[l,a]),Rm("selectionChange",Bt.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=Bt.useMemo(()=>t?$_(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=Bt.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=Bt.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(_m.Provider,{value:m,children:e})}function V_(){let e=Bt.useContext(_m);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function ac(e){let t=V_(),o=t.slotState(e);return Bt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function lc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function sc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=F(),r=i18n.localizeDisabledReason(t,n),i=Bt.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:U,"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 J_='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function ux(e,t,o,n){Bt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(J_)].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 px(e,t,o,n){Bt.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 yx(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function rI(e){return re(editor.tableChromeIconPaths(e))}function xx(){return Bt.createContext(null)}function qo(e){let t=Bt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function Fm(e,t,o){let n=xx();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=ac(e),[h,v]=Bt.useState(false),b=Bt.useRef(null),y=Bt.useRef(null);Qn(h,v,b,l||!m);let C=Bt.useMemo(()=>({open:h,setOpen:v,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:y}),[h,u,g,f,p]);if(l||!m)return null;let T={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},x=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:C,children:s?jsxRuntime.jsx(X,{...T,ref:b,children:x}):jsxRuntime.jsx("div",{ref:b,...T,children:x})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=qo(n),f=ne(),h=te(e),v=f(h?.labelKey??o),{shared:b,reasonNode:y}=sc({enabled:u,disabledReason:g,ariaLabel:v}),C={...b,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:yx(u,d,m)}:{}},T=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{...C,children:T}),y]}):jsxRuntime.jsxs("button",{...C,children:[T,y]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=qo(n),p=ne(),f=Bt.useRef(null);if(ux(d&&u,m,f,g),!d||!u)return null;let h=te(e),v=p(h?.labelKey??o),b={ref:f,role:"menu","aria-label":v,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:U};return l?jsxRuntime.jsx(X,{...b,children:c}):jsxRuntime.jsx("div",{...b,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var _i=Fm("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function vx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(_i.Ctx),l=ne(),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:U,onClick:()=>{i(false),r(s.value);}},m=n??rI(s.icon);return t?jsxRuntime.jsx(X,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Cx(e){let{children:t}=e;return jsxRuntime.jsx(_i.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(vx,{value:o.value},o.value))})})}function aI(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_i.Trigger,{}),jsxRuntime.jsx(Cx,{})]});return jsxRuntime.jsx(_i.Root,{...e,children:o})}var Hi=Object.assign(aI,{docxSlot:"table.borderTarget",Trigger:_i.Trigger,Content:Cx,Item:vx}),Ii=Fm("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function Tx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(Ii.Ctx),l=ne(),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:U,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(X,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Ex(e){let{children:t}=e;return jsxRuntime.jsx(Ii.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(Tx,{value:o.value},o.value))})}function iI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ii.Trigger,{}),jsxRuntime.jsx(Ex,{})]});return jsxRuntime.jsx(Ii.Root,{...e,children:t})}var Ai=Object.assign(iI,{docxSlot:"table.borderStyle",Trigger:Ii.Trigger,Content:Ex,Item:Tx}),Ni=Fm("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function Sx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(Ni.Ctx),l=ne(),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:U,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(X,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function Px(e){let{children:t}=e;return jsxRuntime.jsx(Ni.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(Sx,{value:String(o.size)},o.size))})}function lI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ni.Trigger,{}),jsxRuntime.jsx(Px,{})]});return jsxRuntime.jsx(Ni.Root,{...e,children:t})}var Oi=Object.assign(lI,{docxSlot:"table.borderWidth",Trigger:Ni.Trigger,Content:Px,Item:Sx});function kx(e,t,o){let n=o?.defaultHex??"FF0000",r=xx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:h,draft:v,apply:b}=ac(e),[y,C]=Bt.useState(false),[T,x]=Bt.useState(n),E=Bt.useRef(null),P=Bt.useRef(null);Qn(y,C,E,d||!p);let k=Bt.useMemo(()=>({open:y,setOpen:C,enabled:f,disabledReason:h,apply:b,draft:v,triggerRef:P,lastHex:T,setLastHex:x}),[y,f,h,b,v,T]);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"}},D=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:k,children:m?jsxRuntime.jsx(X,{...w,ref:E,children:D}):jsxRuntime.jsx("div",{ref:E,...w,children:D})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:h,lastHex:v}=qo(r),b=ne(),y=te(e),C=b(y?.labelKey??t),{shared:T,reasonNode:x}=sc({enabled:g,disabledReason:p,ariaLabel:C}),E=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:v??n,P={...T,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:E}):void 0},k=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[re(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(X,{...P,children:k}),x]}):jsxRuntime.jsxs("button",{...P,children:[k,x]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:h,triggerRef:v}=qo(r),b=ne(),y=te(e),C=b(y?.labelKey??t),{shared:T,reasonNode:x}=sc({enabled:f,disabledReason:h,ariaLabel:C}),E={...T,ref:v,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:yx(f,g,p)}:{}},P=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{...E,children:P}),x]}):jsxRuntime.jsxs("button",{...E,children:[P,x]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:h,apply:v,draft:b,triggerRef:y,lastHex:C,setLastHex:T}=qo(r),x=ne(),E=Bt.useRef(null);if(px(p&&h,f,E,y),!p||!h)return null;let P=x(t),k=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:C??n,w={ref:E,role:"dialog","aria-label":P,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:U},D=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>{f(false),v(null),lc(y.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),x("table.clearCellFill")]}):null,jsxRuntime.jsx(Md,{apply:M=>{f(false),T?.(M),v({kind:"hex",value:M}),lc(y.current);},current:k})]});return d?jsxRuntime.jsx(X,{...w,children:D}):jsxRuntime.jsx("div",{...w,children:D})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:h,setOpen:v,setLastHex:b,triggerRef:y}=qo(r),C=ne(),T=m??`#${d.toLowerCase()}`,x=u?C(u):d,E={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:T},"data-value":d,"aria-label":x,title:x,onMouseDown:U,onClick:()=>{v(false),b?.(d),h({kind:"hex",value:d}),lc(y.current);}};return g?jsxRuntime.jsx(X,{...E,children:f}):jsxRuntime.jsx("button",{...E,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var Fi=kx("table.borderColor","table.borderColor",{defaultHex:"000000"});function sI(e){return jsxRuntime.jsx(Fi.Content,{...e,clearFill:false})}function cI(e){return jsxRuntime.jsx(Fi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function dI(e){return jsxRuntime.jsx(Fi.Root,{...e})}var Bi=Object.assign(dI,{docxSlot:"table.borderColor",Trigger:Fi.Trigger,Content:sI,Item:cI,Main:Fi.Main}),Li=kx("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function uI(e){return jsxRuntime.jsx(Li.Content,{...e,clearFill:true})}function pI(e){return jsxRuntime.jsx(Li.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function mI(e){return jsxRuntime.jsx(Li.Root,{...e})}var Wi=Object.assign(mI,{docxSlot:"table.cellFill",Trigger:Li.Trigger,Content:uI,Item:pI,Main:Li.Main});function wx({overrides:e=new Map,separator:t=true}){return sx()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(Jn,{}):null,[Hi,Bi,Ai,Oi,Wi].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)}),[da,ua].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function Dx(){let e=ne(),{draft:t}=ac("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var Hm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],fa="contextual-table",Am={"zoom.level":bm,"styles.style":Dm,"font.family":Em,"font.size":gm,"text.color":_d,"text.highlight":Id,"text.link":dm,"list.lineSpacing":hm,"review.editingMode":Os,"review.authors":Ws,"file.save":um,...ex,"table.borderTarget":Hi,"table.borderColor":Bi,"table.borderStyle":Ai,"table.borderWidth":Oi,"table.cellFill":Wi,"table.splitCell":ua,"image.insert":za,"image.properties":ea,"image.wrap":Si,"image.altText":ui},cc={id:fa,labelKey:"formattingBar.groups.table",entries:Hm.map(e=>({slot:e,Part:e==="table.mergeCells"?da:Am[e]}))},Rx=new Map;function vI(e){let t=Rx.get(e);return t||(t=o=>jsxRuntime.jsx(Ao,{slotId:e,...o}),Rx.set(e,t)),t}function CI(e,t){return editor.formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:js}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(n=>{let r=editor.chromeSlotId(o,n);return {slot:r,Part:Am[r]??vI(r)}})})}var TI=e=>e.image,EI=e=>e.isLoading||e.isOpening===true,SI=e=>e.table!==null;function PI(e){return e==="alignment"||e in Am}function uc(e){let t=wr(e,uc);if(t!==null)return t;if(!Bt.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 Lm(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Lm);let t=uc(e);return t!=null&&Hm.includes(t)?true:Bt.isValidElement(e)?Bt.Children.toArray(e.props.children).some(Lm):false}function kI(e,t){return t?true:Bt.Children.toArray(e).some(Lm)}function wI(e){let t=Lt(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=Bt.useMemo(()=>({t:n,onSave:r}),[n,r]),c=Sl(n),d=K(TI),m=K(EI),u=K(SI),g=at(),p=g==="rtl",f=Bt.useMemo(()=>CI(d,p),[d,p]),h=Bt.useMemo(()=>new Set(f.flatMap(k=>k.entries.map(w=>w.slot))),[f]),v=Bt.useMemo(()=>i?X0(l,uc,k=>h.has(k),k=>Hm.includes(k)):null,[i,l,h]),b=Bt.useMemo(()=>v?DI(f,v):[],[f,v]),y=Bt.useMemo(()=>[...b.filter(k=>!k.pinned).map(k=>k.id),...u?[fa]:[]],[b,u]),C=Bt.useMemo(()=>{let k=new Map;for(let w of b)w.priority!==void 0&&k.set(w.id,w.priority);return editor.collapseOrder(y,editor.TOOLBAR_COLLAPSE_ORDER,k)},[b,y]),T=i&&a,{attach:x,overflow:E}=Al(T,y,C),P;if(!v)P=l;else {let{overrides:k,tableOverrides:w,appended:D}=v,M=B=>{let Z=k.get(B.slot);if(Z)return Z;let ee=B.Part;return jsxRuntime.jsx(ee,{})},H=B=>{let Z=w.get(B.slot);if(Z)return Z;let ee=B.Part;return jsxRuntime.jsx(ee,{})},I=[],A=[],S=0;for(let B of b){if(E.has(B.id)){let Z=B.entries.flatMap(j=>{let oe=Mx(j,k,c,B.labelKey,M);return oe===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:oe},j.slot)]}),ee=MI(B);if(ee!==null&&Z.push(jsxRuntime.jsx(Bt.Fragment,{children:ee},"host")),Z.length===0)continue;A.push({id:B.id,labelKey:B.labelKey,...B.heading?{label:Ks(B.heading,c)}:{},children:Z});continue}S>0&&I.push(jsxRuntime.jsx(Jn,{},`separator-${B.id}`)),S+=1,I.push(jsxRuntime.jsxs("div",{className:`docx-toolbar__group${B.className?` ${B.className}`:""}`,...B.heading?{role:"group","aria-label":Ks(B.heading,c)}:{},...B.pinned?{[Zn]:""}:{[ln]:B.id},children:[B.entries.map(Z=>jsxRuntime.jsx(Bt.Fragment,{children:M(Z)},Z.slot)),B.extras.length>0?jsxRuntime.jsx(Bt.Fragment,{children:B.extras},"host"):null]},B.id));}let _=E.has(fa);if(u&&_){let B=cc.entries.flatMap(Z=>{let ee=Mx(Z,w,c,cc.labelKey,H);return ee===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:ee},Z.slot)]});B.length>0&&A.unshift({id:cc.id,labelKey:cc.labelKey,children:B});}P=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I,u&&!_?jsxRuntime.jsx(Jn,{},"separator-contextual-table"):null,_?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[ln]:fa,children:jsxRuntime.jsx(wx,{overrides:w,separator:false})}),D.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Zn]:"",children:D}):null,A.length>0?jsxRuntime.jsx(j0,{sections:A}):null]});}return jsxRuntime.jsx(Ln.Provider,{value:s,children:jsxRuntime.jsx(K0,{children:jsxRuntime.jsx("fieldset",{ref:x,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...T?{"data-overflow":""}:{},onMouseDown:U,children:kI(l,i)?jsxRuntime.jsx(Im,{children:P}):P})})})}function Om(e){if(!e)return false;if(e.type===Bt.Fragment){let t=Bt.Children.toArray(e.props.children).find(o=>uc(o)!==null);return Bt.isValidElement(t)?Om(t):false}return !!e.props.hidden}function DI(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&&RI(c),c?.hidden)continue;let d=Bt.Children.toArray(c?.children);!s.entries.some(u=>!Om(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===fa&&ry(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==fa);for(let s of i){let c=Bt.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)&&oy(s.id,s.after,a);for(let s of t.appended){if(!Bt.isValidElement(s)||s.type!==Ei)continue;let c=s.props.slotId;ay(c,te(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 RI(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&ny(e.id,t);}function MI(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(rm.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function Mx(e,t,o,n,r){let i=t.get(e.slot);if(Om(i))return null;let a=i?.type===Ei?i.props.overflowContent:void 0;return i||PI(e.slot)?jsxRuntime.jsx(V0,{label:_I(o,e,n),children:a?a():r(e)}):jsxRuntime.jsx(G0,{slot:e.slot})}function _I(e,t,o){let n=t.slot==="alignment"?null:te(t.slot);return e(n?.labelKey??o)}var Ki=Object.assign(wI,{Button:Ao,Action:xm,Separator:Jn,Group:nm,Slot:Ei,AddComment:am,Undo:ly,Redo:sy,Bold:cy,Italic:dy,Underline:uy,Strike:py,Link:dm,ClearFormatting:my,Superscript:fy,Subscript:gy,Alignment:js,AlignLeft:by,AlignCenter:hy,AlignRight:yy,AlignJustify:xy,LeftToRight:vy,RightToLeft:Cy,LineSpacing:hm,BulletList:Ty,NumberedList:Ey,Outdent:Sy,Indent:Py,ImageInsert:za,ImageProperties:ea,ImageWrap:Si,ImageAltText:ui,TableInsert:cm,TableBorderTarget:Hi,TableBorderColor:Bi,TableBorderStyle:Ai,TableBorderWidth:Oi,TableCellFill:Wi,TableMergeCells:da,TableSplitCell:ua,Comments:ky,FontFamily:Em,FontSize:gm,FontColor:_d,Highlight:Id,Zoom:bm,StylePicker:Dm,EditingMode:Os,Reviewers:Ws,Save:um,ContentControlShowAll:ec,ContentControlFormFill:tc,ContentControlInspector:nc,ContentControlRemove:oc});var Ix=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,LI=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,HI=200,Nx=new TextEncoder;function AI(e,t){if(Nx.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=Nx.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function Fx(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 Lx(e){return Fx(Fx(e).replace(/\.docx$/i,""))}function pc(e){let t=(e??"").replace(LI," ").replace(/\s+/g," ").trim(),o=Lx(t).replace(/^[. ]+/,""),n=AI(o,HI),r=n===o?o:Lx(n);return !r||Ix.test(r)?"document.docx":Ix.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function mc(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 Hx(e,t,o){let{t:n}=F(),r=Bt.useRef(false),[i,a]=Bt.useState(false),[l,s]=Bt.useState(""),[c,d]=Bt.useState("pdf"),[m,u]=Bt.useState(false),[g,p]=Bt.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 v=await editor.runChromeExport(e,h,t);mc(v.bytes.slice().buffer,pc(o).replace(/\.docx$/,`.${v.extension}`),v.mimeType),u(!1);}catch(v){u(true),s(v instanceof editor.ChromeExportError?n(v.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:v instanceof Error?v.message:String(v)}));}finally{r.current=false,a(false);}}}}}function Ox(e,t,o){let{t:n}=F(),r=Bt.useRef({editor:e,exporters:t,feedback:o,t:n});r.current={editor:e,exporters:t,feedback:o,t:n};let i=Bt.useRef(null),a=Bt.useRef(null),[l,s]=Bt.useState(false),[c,d]=Bt.useState(""),[m,u]=Bt.useState(""),[g,p]=Bt.useState(false),[f,h]=Bt.useState(false),[v,b]=Bt.useState({}),y=Bt.useCallback(x=>{let{t:E}=r.current;if(x instanceof editor.ChromeExportError)return E("toolbar.printPdfMissing");if(x instanceof editor.ChromePrintError){if(x.code==="pdf-viewer-unavailable")return E("toolbar.printNoViewer");if(x.code==="pdf-load-failed")return E("toolbar.printLoadFailed");if(x.code==="print-refused")return E("toolbar.printRefused")}return E("toolbar.printFailedMessage",{message:x instanceof Error?x.message:String(x)})},[]),C=Bt.useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),T=Bt.useCallback(async x=>{let{editor:E,exporters:P}=r.current;if(!E||i.current)return;let k={};i.current=k,a.current?.dispose(),a.current=null,b(k),h(true),p(true),s(true),d(""),u("");try{let w=await editor.runChromePrint(E,P,x??editor.hostDocumentOf(null));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(()=>p(!1));}}),i.current===k&&C();}catch(w){if(i.current!==k)return;if(!r.current.feedback){console.error("[docx-editor] print failed",w),C();return}s(false),u(a.current?.url??""),d(y(w)),p(true);}},[C,y]);return Bt.useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:l,error:c,url:m,visible:g,active:f,session:v,execute:T,close:C}}var GI=()=>{};function Zm(){let e=L(),t=Bt.useCallback(n=>e?e.on("hostChange",n):GI,[e]),o=Bt.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return Bt.useSyncExternalStore(t,o,()=>null)}var jI="https://github.com/eigenpal/docx-editor/issues/new";function YI(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Wx(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??YI()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
+
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${jI}?${i.toString()}`}function Ui(e){typeof globalThis.window>"u"||globalThis.window.open(Wx(e),"_blank","noopener,noreferrer");}function XI({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=it(),a=Re();if(t||i===false)return null;let l=o??r??Ui;return jsxRuntime.jsx(Me,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var fc=Object.assign(XI,{docxSlot:"help.reportIssue"});function JI({children:e,...t}){let{reportIssue:o}=it();return e===void 0&&o===false?null:jsxRuntime.jsxs(Qt,{id:"help",...t,children:[jsxRuntime.jsx(fc,{}),e]})}var Km=Object.assign(JI,{docxMenu:"help"});var o8=e=>e.hiddenReviewAuthors??[];function gc({className:e,hidden:t}){let o=L(),n=Ci(),r=K(o8),i=Re(),{t:a}=F();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(Me,{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(Kx,{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(Kx,{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 Kx(e){return jsxRuntime.jsx(Me,{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 n8({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(gc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var bc=Object.assign(n8,{docxMenu:"review"});var c8={file:Eu,format:Su,insert:Pu,review:bc,help:Km};function zi(e,t=false){if(!Bt.isValidElement(e))return null;if(e.type===Bt.Fragment){let i=Bt.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 d8=new Set(editor.CHROME_MENUS.map(e=>e.id));function vc(e){if(!Bt.isValidElement(e))return null;if(e.type===Bt.Fragment){let n=Bt.Children.toArray(e.props.children).map(vc).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"&&d8.has(o))return o}return null}var u8=e=>e.isOpening===true;function p8(e){let t=To(),o=St(),n=Lt(),r=at(),{className:i,t:a,fileName:l,exporters:s,onOpen:c,onOpenFile:d,onSave:m,onPageSetup:u,onReportIssue:g,reportIssue:p,preset:f=true,overflow:h=true,children:v}=e,b=L(),{t:y}=F(),[C,T]=Bt.useState(null),x=K(u8);Bt.useEffect(()=>{x&&T(null);},[x]);let[E,P]=Bt.useState(null),k=Hx(b,s,l??E??void 0),{pending:w,execute:D}=k,M=Ox(b,s,o?.print!==false),{active:H,execute:I}=M,A=M.visible&&o?.print!==false,[S,_]=Bt.useState(null),[B,Z]=Bt.useState(false),[ee,j]=Bt.useState(false),[oe,$]=Bt.useState(false),V=Bt.useRef(null),ce=Bt.useRef(null);Bt.useEffect(()=>{if(C!==null)return editor.listenForOutsidePress({popup:V.current,close:()=>T(null)})},[C]),ia(C!==null,V,()=>T(null),ie=>editor.isDomNode(ie.target)&&V.current?.contains(ie.target)===true);let O=Bt.useCallback(ie=>{T(ie),ie!==null&&_(ie);},[]),N=Bt.useCallback(()=>ce.current?.click(),[]),W=Bt.useCallback(()=>{b&&b.save().then(ie=>mc(ie,pc(l??E??void 0),void 0,V.current)).catch(ie=>{console.error("[docx-editor] save failed",ie);});},[b,l,E]),J=Bt.useCallback(()=>t?t.open("pageSetup",V.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):Z(true),[t]),de=b?c??N:void 0,he=b?m??W:void 0,Oe=!!s?.pdf,we=Bt.useMemo(()=>b&&!H?()=>{cu(V.current),I(editor.editorInstanceScope(V.current)??V.current??void 0);}:void 0,[b,H,I]),Ke=b?t?.ownsPageSetup?J:u??J:void 0,Te=Zm();Bt.useEffect(()=>{let ie=xe=>{if(!(xe.metaKey||xe.ctrlKey)||xe.altKey||xe.shiftKey)return;let Ct=xe.key.toLowerCase(),Fo=editor.isChromePrintShortcut(xe);if(Ct!=="s"&&Ct!=="o"&&!Fo)return;let Qo=xe.target,_n=editor.editorInstanceScope(V.current)??V.current;if(!(!Qo||!((_n?.contains(Qo)??false)||Vg(Qo,editor.hostDocumentOf(V.current),b?editor.editorHostElement(b):null))))if(Fo){if(!Oe||!b||!we&&!A)return;xe.preventDefault(),we?.();}else Ct==="s"&&he?(xe.preventDefault(),he()):Ct==="o"&&de&&(xe.preventDefault(),de());},ge=editor.hostDocumentOf(V.current),qe=Te&&Te!==ge?[ge,Te]:[ge];for(let xe of qe)xe.addEventListener("keydown",ie);return ()=>{for(let xe of qe)xe.removeEventListener("keydown",ie);}},[de,he,we,A,Oe,b,Te]);let Io=Bt.useMemo(()=>({t:a,openMenu:C,setOpenMenu:O,activeMenu:S,onOpen:de,onSave:he,onExport:b&&!w?ie=>(cu(V.current),D(ie)):void 0,onPrint:we,printShortcut:Oe,onPageSetup:Ke,onParagraphDialog:()=>t?t.open("paragraph",V.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):j(true),onWatermarkDialog:b?()=>t?t.open("watermark",V.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):$(true):void 0,onReportIssue:g,reportIssue:p,opening:x}),[x,b,w,D,we,Oe,a,C,O,S,de,he,Ke,t,g,p]),co=Bt.Children.toArray(v),_t=[];if(f){let ie=new Map(co.map(ge=>[vc(ge),ge]));for(let ge of editor.CHROME_MENUS){let qe=ie.get(ge.id);(qe===void 0||zi(qe)!==null)&&_t.push(ge.id);}for(let ge of co){if(vc(ge)!==null)continue;let qe=zi(ge);qe!==null&&_t.push(qe);}}else for(let ie of co){let ge=zi(ie);ge!==null&&_t.push(ge);}let Xo=[..._t].reverse(),{attach:Mn,overflow:ae}=Al(h,_t,Xo),rt=Bt.useMemo(()=>({measuring:h,overflow:ae,inMore:false}),[h,ae]),Ie=Bt.useMemo(()=>({measuring:false,overflow:ae,inMore:true}),[ae]),uo=ie=>zi(ie,true)!==null,Jo=(ie,ge)=>jsxRuntime.jsx("div",{role:"none",className:"docx-menubar__host",[Zn]:"",children:ie},ge),It,No;if(!f)It=co.filter(uo),No=h?co.map((ie,ge)=>uo(ie)?ie:Jo([ie],`host-${ge}`)):v;else {let ie=new Map,ge=[];for(let xe of co){let Ct=vc(xe);Ct?ie.set(Ct,xe):ge.push(xe);}It=[...editor.CHROME_MENUS.map(xe=>{let Ct=ie.get(xe.id);if(Ct)return jsxRuntime.jsx(Bt.Fragment,{children:Ct},xe.id);let Fo=c8[xe.id];return jsxRuntime.jsx(Fo,{},xe.id)}),...ge.filter(uo)];let qe=ge.filter(xe=>!uo(xe));No=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[It,qe.length>0?Jo(qe,"host"):null]});}let br=a?.("formattingBar.more")??y("formattingBar.more");return jsxRuntime.jsxs(Wa.Provider,{value:Io,children:[jsxRuntime.jsx("div",{ref:ie=>{if(V.current=ie,Mn(ie),ie&&S===null){let ge=su(ie)[0]?.closest("[data-menu]")?.getAttribute("data-menu");ge&&_(ge);}},role:"menubar","aria-label":a?.("titleBar.menuBarAriaLabel")??y("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...h?{"data-overflow":""}:{},className:`${n}docx-menubar${i?` ${i}`:""}`,dir:r,onMouseDown:U,onKeyDown:ie=>{if(ie.key!=="ArrowLeft"&&ie.key!=="ArrowRight")return;let ge=V.current;if(!ge)return;let qe=su(ge),xe=qe.indexOf(editor.hostDocumentOf(ge).activeElement);if(xe===-1)return;ie.preventDefault();let Ct=editor.hostWindowOf(ge).getComputedStyle(ge).direction==="rtl",Fo=(ie.key==="ArrowRight"?1:-1)*(Ct?-1:1),Qo=qe[(xe+Fo+qe.length)%qe.length],_n=Qo?.closest("[data-menu]")?.getAttribute("data-menu");_n&&(_(_n),Qo?.focus(),C!==null&&T(_n));},children:jsxRuntime.jsxs(Ll.Provider,{value:rt,children:[jsxRuntime.jsx(Rr.Provider,{value:0,children:No}),ae.size>0?jsxRuntime.jsx(Qt,{id:Dr,label:br,icon:re(tm),preset:false,children:jsxRuntime.jsx(Ll.Provider,{value:Ie,children:It})}):null]})}),jsxRuntime.jsxs(dh,{children:[k.visible&&o?.export!==false?o?.export?Ee(o.export,{open:true,format:k.format,pending:k.pending,error:k.error,onClose:k.dismiss},k.session):jsxRuntime.jsx(Ma,{open:true,format:k.format,pending:k.pending,error:k.error,onClose:k.dismiss}):null,M.visible&&o?.print!==false?o?.print?Ee(o.print,{open:true,pending:M.pending,error:M.error,url:M.url,onClose:M.close},M.session):jsxRuntime.jsx(_a,{open:true,pending:M.pending,error:M.error,url:M.url,onClose:M.close}):null]}),jsxRuntime.jsx("input",{ref:ce,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:ie=>{let ge=ie.target.files?.[0];ie.target.value="",!(!ge||!b)&&(P(ge.name),d?.(ge),ge.arrayBuffer().then(qe=>b.load(new Uint8Array(qe))).catch(qe=>{console.error("[docx-editor] could not open the file",qe);}));}}),jsxRuntime.jsx(Un,{open:B,onClose:()=>Z(false)}),jsxRuntime.jsx(Zo,{open:ee,onClose:()=>j(false)}),jsxRuntime.jsx(zn,{open:oe,onClose:()=>$(false)})]})}var $i=Object.assign(p8,{Menu:Qt,File:Eu,Format:Su,Insert:Pu,Review:bc,Help:Km,Item:Kt,Row:Me,Group:$a,Separator:Kn,Submenu:Jt,TableGrid:Ir,Entry:Ga,Open:gu,Save:bu,ExportMarkdown:hu,ExportPdf:yu,Print:xu,PageSetup:vu,ImageInsert:Cu,Watermark:Ul,Bookmark:zl,Reviewers:gc,ReportIssue:fc});var x8=12240,jx=1440,v8=1440,C8=567,or=20,jm=6,Xm=or+jm+2,T8="var(--doc-text-muted)",E8="var(--doc-text-subtle)",Yx="var(--doc-shadow-subtle)",S8="var(--doc-primary)",P8="var(--doc-primary-hover)",k8="var(--doc-text-subtle)",Gi=5,Vi=7,w8={left:0,right:0,firstLine:0};function Xx(e,t){return t==="inch"?(e/v8).toFixed(2)+'"':(e/C8).toFixed(1)+" cm"}function D8(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function nr({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}=F(),[v,b]=Bt.useState(null),[y,C]=Bt.useState(null),[T,x]=Bt.useState(null),[E,P]=Bt.useState(null),k=Bt.useRef(null),w=e?.pageWidthTwips??x8,D=e?.marginsTwips.left??jx,M=e?.marginsTwips.right??jx,H=e?.gutterTwips??0,I={pageWidth:w,leftMargin:D,rightMargin:M},A=l??w8,S=$e(w)*t,_=$e(D)*t,B=$e(M)*t,Z=Bt.useCallback(N=>{let W=k.current?.getBoundingClientRect();return W?_s((N-W.left)/t):null},[t]),ee=Bt.useCallback((N,W,J)=>{let de=Z(W);if(de===null)return;if(P($e(de)*t),N==="leftMargin"||N==="rightMargin"){if(N==="leftMargin"){let Oe=w-M-H-720,we=Math.round(Math.max(0,Math.min(de,Oe)));x(we),n?.(we);}else {let Oe=w-de,we=w-D-H-720,Ke=Math.round(Math.max(0,Math.min(Oe,we)));x(Ke),r?.(Ke);}return}let he=editor.dragIndent(N,de,A,I,{unit:m,precise:J});x(N==="right"?he.right:N==="firstLine"?he.firstLine:he.left),c?.(he);},[Z,t,w,D,M,H,n,r,c,A,I,m]),j=Bt.useCallback(N=>{N==="leftMargin"||N==="rightMargin"?i?.():d?.(),b(null),x(null),P(null);},[i,d]),oe=Bt.useCallback((N,W,J)=>{let de=editor.handlePosition(N,A,I),he=editor.dragIndent(N,de+W*D8(m,J),A,I,{unit:m,precise:true});c?.(he),d?.();},[A,I,m,c,d]),$=editor.rulerMarginTicks(I,A,m).map(N=>({...N,position:$e(N.position)*t})),V=a&&s&&c!==void 0,ce=N=>$e(editor.handlePosition(N,A,I))*t,O=(N,W,J)=>({positionPx:ce(N),editable:V,isDragging:v===N,isHovered:y===N,onPointerEnter:()=>C(N),onPointerLeave:()=>C(null),onPointerDown:de=>{V&&(de.preventDefault(),de.stopPropagation(),de.currentTarget.setPointerCapture(de.pointerId),b(N));},onPointerMove:de=>{v===N&&ee(N,de.clientX,de.altKey);},onPointerUp:de=>{v===N&&(de.currentTarget.releasePointerCapture(de.pointerId),j(N));},onKeyDown:de=>{V&&(de.key!=="ArrowLeft"&&de.key!=="ArrowRight"||(de.preventDefault(),oe(N,de.key==="ArrowLeft"?-1:1,de.shiftKey)));},label:h(W),valueNow:J,valueText:Xx(J,m),pageWidthTwips:w});return jsxRuntime.jsxs("div",{ref:k,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:kt(S),height:Xm,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:v?"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(_),height:or,backgroundColor:Yx,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?N=>{N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId),b("leftMargin");}:void 0,onPointerMove:N=>v==="leftMargin"&&ee("leftMargin",N.clientX,N.altKey),onPointerUp:N=>{v==="leftMargin"&&(N.currentTarget.releasePointerCapture(N.pointerId),j("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:kt(B),height:or,backgroundColor:Yx,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?N=>{N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId),b("rightMargin");}:void 0,onPointerMove:N=>v==="rightMargin"&&ee("rightMargin",N.clientX,N.altKey),onPointerUp:N=>{v==="rightMargin"&&(N.currentTarget.releasePointerCapture(N.pointerId),j("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:or,pointerEvents:"none"},children:$.map((N,W)=>jsxRuntime.jsx(R8,{tick:N},W))}),p?.map(N=>jsxRuntime.jsx(N8,{tabMark:N,positionPx:$e(editor.rulerTabPosition(N.position,I,A))*t,onDoubleClick:()=>f?.(N.position)},N.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gm,{direction:"down",anchor:"top",...O("firstLine","ruler.firstLineIndent",A.firstLine)}),jsxRuntime.jsx(Gm,{direction:"up",anchor:"strip",...O("hanging","ruler.hangingIndent",A.left)}),jsxRuntime.jsx(M8,{...O("left","ruler.leftIndent",A.left)}),jsxRuntime.jsx(Gm,{direction:"up",anchor:"strip",...O("right","ruler.rightIndent",A.right)})]}),v&&T!==null&&E!==null&&jsxRuntime.jsx(_8,{value:Xx(T,m),positionPx:E})]})}function R8({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:T8,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Jx(e){return e.editable?e.isDragging||e.isHovered?P8:S8:k8}function Qx(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 ev(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 Gm({direction:e,anchor:t,...o}){let n=Jx(o),r=t==="top"?{top:0,height:Vi+1}:{top:or-Vi,height:Vi};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:Qx(o,Gi*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...ev(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Gi}px solid transparent`,borderRight:`${Gi}px solid transparent`,...e==="down"?{top:0,borderTop:`${Vi}px solid ${n}`}:{bottom:0,borderBottom:`${Vi}px solid ${n}`},transition:"border-color 0.1s"}})})}function M8(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Qx(e,Gi*2,{top:or+1,height:jm}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...ev(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:Gi*2-2,height:jm,backgroundColor:Jx(e),borderRadius:1,transition:"background-color 0.1s"}})})}function _8({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 I8={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function N8({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:kt(t-5),top:or-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:I8[e.alignment]||"L"})}var A8=15840,nv=1440,Ec=1440,Sc=567,ha=20,O8="var(--doc-text-muted)",B8="var(--doc-text-subtle)",W8="var(--doc-primary)",Z8="var(--doc-primary)",K8="var(--doc-primary-hover)";function ji({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=F(),d=at(),[m,u]=Bt.useState(null),[g,p]=Bt.useState(null),f=Bt.useRef(null),h=e?.pageHeightTwips??A8,v=e?.marginsTwips.top??nv,b=e?.marginsTwips.bottom??nv,y=(M,H)=>{if(!o||M.altKey||M.ctrlKey||M.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(M.key))return;M.preventDefault();let I=H==="topMargin"?v:b,S=Math.max(0,h-(H==="topMargin"?b:v)-720),_=M.shiftKey?1:Math.round(a==="cm"?Sc/10:Ec/8),B=M.key==="Home"?0:M.key==="End"?S:Math.max(0,Math.min(S,I+(M.key==="ArrowUp"?_:-_)));B!==I&&((H==="topMargin"?n:r)?.(B),i?.());},C=$e(h)*t,T=$e(v)*t,x=$e(b)*t,E=Bt.useCallback((M,H)=>{o&&(M.preventDefault(),u(H));},[o]),P=Bt.useCallback(M=>{if(!m||!f.current)return;let H=f.current.getBoundingClientRect(),I=M.clientY-H.top,A=_s(I/t);if(m==="topMargin"){let S=h-b-720,_=Math.max(0,Math.min(A,S));n?.(Math.round(_));}else if(m==="bottomMargin"){let S=h-A,_=h-v-720,B=Math.max(0,Math.min(S,_));r?.(Math.round(B));}},[m,t,h,v,b,n,r]),k=Bt.useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);Bt.useEffect(()=>{if(m){let M=editor.hostDocumentOf(f.current);return M.addEventListener("mousemove",P),M.addEventListener("mouseup",k),()=>{M.removeEventListener("mousemove",P),M.removeEventListener("mouseup",k);}}},[m,P,k]);let w=U8(h,t,a),D={position:"relative",width:ha,height:kt(C),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:m?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:f,className:`docx-vertical-ruler ${l}`,style:D,dir:d,role:"group","aria-label":c("ruler.vertical"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,insetInlineStart:0,insetInlineEnd:0,bottom:0,pointerEvents:"none"},children:w.map((M,H)=>jsxRuntime.jsx(q8,{tick:M},H))}),jsxRuntime.jsx(rv,{type:"topMargin",value:v,maximum:Math.max(0,h-b-720),valueText:v/(a==="cm"?Sc:Ec),unit:a,onKeyDown:M=>y(M,"topMargin"),position:T,editable:o,isDragging:m==="topMargin",isHovered:g==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:M=>E(M,"topMargin")}),jsxRuntime.jsx(rv,{type:"bottomMargin",value:b,maximum:Math.max(0,h-v-720),valueText:b/(a==="cm"?Sc:Ec),unit:a,onKeyDown:M=>y(M,"bottomMargin"),position:C-x,editable:o,isDragging:m==="bottomMargin",isHovered:g==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:M=>E(M,"bottomMargin")})]})}function q8({tick:e}){let t={position:"absolute",top:kt(e.position),insetInlineEnd:0,height:1,width:e.width,backgroundColor:B8},o={position:"absolute",top:kt(e.position),insetInlineStart:2,transform:"translateY(-50%)",fontSize:"9px",color:O8,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 rv({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}=F(),p=s?K8:c?Z8:W8,f={position:"absolute",top:kt(t-5),insetInlineEnd:0,width:ha,height:10,cursor:l?"ns-resize":"default",zIndex:s?10:1},h={position:"absolute",top:0,insetInlineEnd:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderInlineEnd:`8px solid ${p}`,transition:"border-inline-end-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 U8(e,t,o){let n=[];if(o==="inch"){let r=Ec/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(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=Sc/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(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 V8=e=>e.formatting?.indent??null,G8=e=>e.editable;function Qm(){let e=L(),t=K(V8),o=K(G8),n=Bt.useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=Bt.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 Bt.useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var cv=e=>e.zoom,Y8=e=>e.isOpening===true;function dv(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function uv(){let{apply:e}=qn(),[t,o]=Bt.useState({}),n=Bt.useRef({}),r=Bt.useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=Bt.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 sv(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function X8(){let e=L(),{indent:t,isEnabled:o,apply:n}=Qm(),[r,i]=Bt.useState(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useCallback(m=>{l.current===null&&(l.current=sv(e)),a.current=m,i(m);},[e]),c=Bt.useCallback(()=>{let m=a.current,u=l.current;a.current=null,l.current=null,i(null),m&&(u!==null&&u!==sv(e)||n({left:m.left,right:m.right,firstLine:m.firstLine}));},[e,n]),d=Bt.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[r,t]);return Bt.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function J8(){let e=Se(),[t,o]=Bt.useState(0);return Bt.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 kc(e){let t=K(eo),o=K(Y8),{pageSetup:n,isEnabled:r}=qn(),i=K(cv),{pending:a,preview:l,commit:s}=uv(),c=X8(),d=Fn(),m=Fs(),u=m==="left",g=D0(fn(),m),p=J8();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,...u?{"data-chrome-dir":"rtl"}:{},style:{paddingLeft:(u?0:d)+g.left,paddingRight:(u?d:0)+g.right},children:jsxRuntime.jsx(nr,{pageSetup:dv(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(${-p}px)`,clipPath:d>0&&p>0?`inset(0 0 0 ${p}px)`:e.style?.clipPath}})})}function wc(e){let t=K(eo),{pageSetup:o,isEnabled:n}=qn(),r=K(cv),{pending:i,preview:a,commit:l}=uv(),s=Fn(),c=fn(),d=M0();return t||d!==null&&d>0&&o&&$e(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(ji,{pageSetup:dv(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 q({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 pv(e){return jsxRuntime.jsx(q,{...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 mv(e){return jsxRuntime.jsx(q,{...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 fv(e){return jsxRuntime.jsx(q,{...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 gv(e){return jsxRuntime.jsxs(q,{...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 bv(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function hv(e){return jsxRuntime.jsx(q,{...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 yv(e){return jsxRuntime.jsx(q,{...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 xv(e){return jsxRuntime.jsx(q,{...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 vv(e){return jsxRuntime.jsx(q,{...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 Cv(e){return jsxRuntime.jsx(q,{...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(q,{...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 Ev(e){return jsxRuntime.jsx(q,{...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 tN(e){return jsxRuntime.jsx(q,{...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 oN(e){return jsxRuntime.jsx(q,{...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 nN(e){return jsxRuntime.jsx(q,{...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 rN(e){return jsxRuntime.jsx(q,{...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 aN(e){return jsxRuntime.jsx(q,{...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 iN(e){return jsxRuntime.jsx(q,{...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 lN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function sN(e){return jsxRuntime.jsx(q,{...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 cN(e){return jsxRuntime.jsx(q,{...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 dN(e){return jsxRuntime.jsx(q,{...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 uN(e){return jsxRuntime.jsx(q,{...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 pN(e){return jsxRuntime.jsx(q,{...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 mN(e){return jsxRuntime.jsx(q,{...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 fN(e){return jsxRuntime.jsx(q,{...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 gN(e){return jsxRuntime.jsx(q,{...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 bN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function hN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function yN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function xN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function nf(e){return jsxRuntime.jsx(q,{...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 vN(e){return jsxRuntime.jsx(q,{...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 CN(e){return jsxRuntime.jsx(q,{...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 TN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function EN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function SN(e){return jsxRuntime.jsx(q,{...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 PN(e){return jsxRuntime.jsx(q,{...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 kN(e){return jsxRuntime.jsx(q,{...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 wN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function DN(e){return jsxRuntime.jsx(q,{...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 RN(e){return jsxRuntime.jsx(q,{...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 MN(e){return jsxRuntime.jsx(q,{...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 _N(e){return jsxRuntime.jsx(q,{...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 IN(e){return jsxRuntime.jsx(q,{...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 Sv(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function NN(e){return jsxRuntime.jsx(q,{...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 FN(e){return jsxRuntime.jsx(q,{...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 LN(e){return jsxRuntime.jsx(q,{...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 HN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function AN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function ON(e){return jsxRuntime.jsx(q,{...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 BN(e){return jsxRuntime.jsx(q,{...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 WN(e){return jsxRuntime.jsx(q,{...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 ZN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function KN(e){return jsxRuntime.jsx(q,{...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 qN(e){return jsxRuntime.jsx(q,{...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 UN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function zN(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function $N(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function VN(e){return jsxRuntime.jsx(q,{...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 GN(e){return jsxRuntime.jsx(q,{...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 jN(e){return jsxRuntime.jsx(q,{...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 YN(e){return jsxRuntime.jsx(q,{...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 XN(e){return jsxRuntime.jsx(q,{...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 JN(e){return jsxRuntime.jsx(q,{...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 QN(e){return jsxRuntime.jsx(q,{...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 e5(e){return jsxRuntime.jsx(q,{...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 t5(e){return jsxRuntime.jsx(q,{...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 o5(e){return jsxRuntime.jsx(q,{...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 n5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function r5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function a5(e){return jsxRuntime.jsx(q,{...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 i5(e){return jsxRuntime.jsx(q,{...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 l5(e){return jsxRuntime.jsx(q,{...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 s5(e){return jsxRuntime.jsx(q,{...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 c5(e){return jsxRuntime.jsx(q,{...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 d5(e){return jsxRuntime.jsx(q,{...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 u5(e){return jsxRuntime.jsx(q,{...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 p5(e){return jsxRuntime.jsx(q,{...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 m5(e){return jsxRuntime.jsx(q,{...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 f5(e){return jsxRuntime.jsx(q,{...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 g5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function b5(e){return jsxRuntime.jsx(q,{...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 h5(e){return jsxRuntime.jsx(q,{...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 y5(e){return jsxRuntime.jsx(q,{...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 x5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function v5(e){return jsxRuntime.jsx(q,{...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 C5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function T5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function E5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function S5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function P5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function k5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function w5(e){return jsxRuntime.jsx(q,{...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 D5(e){return jsxRuntime.jsx(q,{...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 R5(e){return jsxRuntime.jsx(q,{...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 M5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function _5(e){return jsxRuntime.jsx(q,{...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 I5(e){return jsxRuntime.jsx(q,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function N5(e){return jsxRuntime.jsx(q,{...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 F5(e){return jsxRuntime.jsx(q,{...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 L5(e){return jsxRuntime.jsx(q,{...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 H5(e){return jsxRuntime.jsx(q,{...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 A5(e){return jsxRuntime.jsx(q,{...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 O5={undo:tN,redo:oN,print:nN,file_download:rN,file_upload:aN,format_bold:iN,format_italic:lN,format_underlined:sN,strikethrough_s:cN,superscript:dN,subscript:uN,link:pN,format_clear:gN,format_paragraph:mN,format_shapes:fN,lock:Ev,format_align_left:bN,format_align_center:hN,format_align_right:yN,format_align_justify:xN,format_line_spacing:nf,format_list_bulleted:vN,format_list_numbered:CN,format_indent_increase:TN,format_indent_decrease:EN,format_color_text:SN,ink_highlighter:PN,format_color_reset:kN,arrow_drop_down:wN,table:DN,table_chart:RN,grid_on:MN,table_rows:_N,view_column:IN,border_all:Sv,select_all:Sv,border_outer:NN,border_inner:FN,border_clear:LN,add:HN,remove:AN,delete:ON,delete_sweep:BN,call_merge:WN,call_split:ZN,drag_indicator:KN,image:qN,format_image_left:UN,format_image_right:zN,horizontal_rule:$N,flip_to_back:VN,flip_to_front:GN,open_with:jN,tune:YN,rotate_right:XN,rotate_left:JN,swap_horiz:QN,swap_vert:e5,shapes:t5,format_paint:o5,expand_more:n5,expand_less:r5,border_top:a5,border_bottom:i5,border_left:l5,border_right:s5,border_horizontal:c5,border_vertical:d5,padding:u5,text_rotation_none:p5,wrap_text:m5,height:f5,fit_width:g5,settings:b5,border_color:h5,format_color_fill:y5,vertical_align_top:x5,vertical_align_center:v5,vertical_align_bottom:C5,line_weight:T5,keyboard_arrow_up:E5,keyboard_arrow_down:S5,keyboard_arrow_left:P5,keyboard_arrow_right:k5,more_vert:w5,page_break:D5,branding_watermark:R5,arrow_back:M5,search:_5,toc:I5,bookmark:N5,bookmarks:F5,done_all:pv,check_circle:mv,chat_bubble_outline:fv,chat_bubble_check:gv,check:bv,close:hv,add_comment:yv,comment:xv,edit_note:vv,rate_review:Cv,visibility:Tv,format_textdirection_l_to_r:L5,format_textdirection_r_to_l:H5,"agent-sparkle":A5};function G({name:e,size:t=20,className:o="",style:n}){let r=O5[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 Yi=12,rf=240,kv=16,U5=24,z5=Yi+rf+kv,ya=12,$5=36,V5=ya+$5+kv,Xi=Bt__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=Yi}){let{t:l}=F(),[s,c]=Bt.useState(false),d=Bt.useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return Bt.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:rf,paddingTop:U5,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+rf}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(G,{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 Y5=e=>e,X5=Object.freeze([]),J5=()=>{};function af(e){let t=L(),o=K(Y5),n=Bt.useMemo(()=>t&&!o.isLoading?t.getOutline():X5,[t,o]),r=Bt.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(Xi,{headings:n,onHeadingClick:r,onClose:e.onClose??J5,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var lf=Bt.createContext(null);function Po(e){let t=Bt.useContext(lf);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var r6={ok:false,code:"unsupported",reason:"editor is not ready"},Dv=Object.freeze([]);function Dc(e={}){let t=e.enabled??true,o=L(),n=Bt.useCallback(k=>t?o?.query({type:"bookmarks"})??Dv:Dv,[o,t]),r=K(n,Ku),[i,a]=Bt.useState(""),[l,s]=Bt.useState("name"),[c,d]=Bt.useState(false),[m,u]=Bt.useState(null),[g,p]=Bt.useState(null),[f,h]=Bt.useState(""),v=Bt.useMemo(()=>editor.goToBookmarkRows(r,{query:i,sortBy:l,showHidden:c}),[r,i,l,c]),b=Bt.useMemo(()=>m===null?-1:v.findIndex(k=>k.name===m),[v,m]),y=Bt.useCallback(k=>{a(k),u(null),p(null);},[]),C=Bt.useCallback(k=>{s(k),u(null),p(null);},[]),T=Bt.useCallback(k=>{d(k),u(null),p(null);},[]),x=Bt.useCallback(k=>{if(v.length===0)return;let w=b<0?k>0?-1:0:b;u(v[(w+k+v.length)%v.length].name);},[v,b]),E=Bt.useCallback(k=>u(v[k]?.name??null),[v]),P=Bt.useCallback(k=>{if(!o)return r6;let w=k??v[b]?.name??editor.goToBookmarkTarget(r,i,v)?.name;if(w===void 0||w.trim().length===0){let M=i.trim();return p(M.length===0?"empty":"notFound"),h(M),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let D=o.exec({type:"goToBookmark",name:w});return p(D.ok?null:D.code==="notFound"?"notFound":"failed"),h(D.ok?"":w),D},[o,v,b,r,i]);return {query:i,setQuery:y,sortBy:l,setSortBy:C,showHidden:c,setShowHidden:T,rows:v,bookmarks:r,activeIndex:b,move:x,setActiveIndex:E,go:P,problem:g,problemName:f}}var Rv=(...e)=>e.filter(Boolean).join(" "),d6={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},u6={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 p6(){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 m6({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 Ji({className:e,style:t}){let{pane:o,intents:n,t:r}=Po("GoTo"),i=L(),a=o.tab!=="goto",l=Dc({enabled:o.open&&!a}),s=se("insert.bookmark"),c=K(eo),d=Bt.useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=E=>`${d}-option-${E}`,f=Bt.useRef(null);Bt.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());},v=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("")));},b=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,C=l.sortBy==="location",T=l.bookmarks.length===0,x=(E,P)=>{let k=P===l.activeIndex;return jsxRuntime.jsxs("li",{id:p(P),role:"option","aria-selected":k,className:Rv("docx-nav__goto-row",k&&"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(p6,{}):jsxRuntime.jsx(G,{name:"bookmark",size:16})}),jsxRuntime.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsx("bdi",{children:jsxRuntime.jsx(m6,{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")})}),!C&&E.place!=="body"&&jsxRuntime.jsx("span",{className:"docx-nav__goto-place",children:r(d6[E.place])})]},E.name)};return jsxRuntime.jsxs("div",{className:Rv("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(G,{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:v}),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")]})]}),T&&!c&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-empty",children:[jsxRuntime.jsx(G,{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")})]}),!T&&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:b}),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:C?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(u6[E.place])}),jsxRuntime.jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:E.rows.map(({row:P,index:k})=>x(P,k))})]},E.place)):l.rows.map((E,P)=>x(E,P))})]})}var va=280,Rc=32,Mv=16;function Ca(e=280){return 32+e+16}function Mc({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 sf=320;function _c(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<sf}var h6=Object.freeze([]),y6=e=>e;function Ic(){let e=L(),t=K(y6),[o,n]=Bt.useState(null),r=Bt.useMemo(()=>e&&!t.isLoading?e.getOutline():h6,[e,t]),i=Bt.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=Bt.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 Av=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),T6=()=>()=>{},Iv=()=>Av;function Nc(e={}){let t=e.highlight??"all",o=L(),n=Bt.useMemo(()=>o?editor.createDocumentSearch(o):null,[o]),r=Bt.useSyncExternalStore(n?n.subscribe:T6,n?n.getState:Iv,n?n.getState:Iv);Bt.useEffect(()=>{if(!(!n||t==="none"))return n.showHighlights(t)},[n,t]);let i=Bt.useMemo(()=>({setQuery:a=>n?.setQuery(a),find:(a,l)=>n?.find(a,l)??Av.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 Bt.useMemo(()=>({...r,...i}),[r,i])}function Kv(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 qv=editor.isGoToChord;function Uv(e=i18n.isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function zv(e=i18n.isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function $v(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}if(e&&o){o();return}t?t.focus({preventScroll:true}):o?.();}function Gv(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 uf(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 pf(e){e.focus(),e.localName==="input"&&e.select();}function w6(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",r=uf(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(r){pf(r);return}editor.isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function D6(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))&&w6(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 jv(e,t,o){let n=D6(e,t),r=i=>{editor.isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function Wv(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Yv(e,t){let o=()=>{let i=editor.hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-Wv(i.paddingTop)-Wv(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 Jv(e,t=true,o=true){let n=L(),r=Se(),i=Bt.useRef(null),a=Bt.useRef(null),l=Bt.useRef(false),s=Bt.useRef(false),c=Bt.useRef(false),d=Bt.useRef(0),m=Bt.useCallback(()=>{let x=++d.current;editor.hostWindowOf(i.current).setTimeout(()=>{d.current===x&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=Bt.useRef(e);u.current=e;let g=Bt.useCallback(()=>{l.current=false;let x=uf(i.current,u.current.tab);x&&pf(x);},[]),p=Bt.useCallback(()=>{s.current=false;let x=a.current;a.current=null;let E=i.current?.querySelector(".docx-nav__toggle")??null;Vv(x,E,n?()=>n.focus():null);},[n]),f=Bt.useRef(p);f.current=p,Bt.useEffect(()=>()=>{s.current&&f.current();},[]);let h=Bt.useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),v=Bt.useCallback((x,E)=>{E&&!i.current?.contains(E)&&(a.current=E),s.current=false;let P=u.current;if(P.open&&P.tab===x){g();return}l.current=true,P.tab!==x&&P.setTab(x),P.open||P.setOpen(true),m();},[g,m]),b=Bt.useMemo(()=>({openTab:x=>{let E=i.current?.ownerDocument.activeElement;v(x,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 x=u.current;if(!x.overlay)return;let E=i.current?.ownerDocument.activeElement;c.current=!!E&&!!i.current?.contains(E),x.setOpen(false),m();}}),[h,m,v]),y=Bt.useRef(b);y.current=b,Bt.useEffect(()=>{let x=i.current?.ownerDocument;if(!x||!t&&!o)return;let E=P=>{if(P.defaultPrevented)return;let k=t&&Kv(P)?"find":o&&qv(P)?"goto":null;if(!k||!Gv(P.target,i.current,r))return;if(k==="goto"&&n?.can({type:"openGoTo"}).ok){n.exec({type:"openGoTo",fromShortcut:true}).ok&&P.preventDefault();return}P.preventDefault();let w=x.activeElement;v(k,editor.isHTMLElementNode(w)?w:null);};return x.addEventListener("keydown",E),()=>x.removeEventListener("keydown",E)},[r,t,o,v,n]),Bt.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 C=e.open&&e.overlay;Bt.useEffect(()=>{let x=i.current;if(!(!C||!x||!r))return jv(x,r,()=>y.current.close())},[C,r]),Bt.useEffect(()=>{let x=i.current;if(!(!x||!r||!r.contains(x)))return Yv(x,r)},[r]);let T=Bt.useCallback(x=>{x.key!=="Escape"||x.defaultPrevented||x.nativeEvent.isComposing||u.current.open&&(x.preventDefault(),h());},[h]);return {rootRef:i,intents:b,onKeyDown:T}}var I6=150;function N6(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function F6(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function Qv(e,t,o=()=>null){let n=editor.hostTimers(o),r=null,i=false,a=()=>{r=null,i||t(F6(e.getPageGeometry()));},l=()=>{i||(n.clearTimeout(r),r=n.setTimeout(a,I6));},s=e.on("change",c=>{N6(c)&&l();});return a(),{nudge:l,dispose(){i=true,n.clearTimeout(r),r=null,s();}}}var B6=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)}},W6=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,Z6=e=>e.page.total;function Fc(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=Bt.useState(t),[a,l]=Bt.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=Bt.useCallback(O=>{u||i(O),d?.(O);},[u,d]),f=Bt.useCallback(()=>p(!s),[s,p]),h=Bt.useCallback(O=>{g||l(O),m?.(O);},[g,m]),v=Nn(),b=Se(),y=Bt.useContext(Nt),{pageSetup:C,zoom:T,reviewPaneOpen:x,fitting:E}=K(B6,W6),P=L(),k=K(Z6),[w,D]=Bt.useState(0),[M,H]=Bt.useState(null),[I,A]=Bt.useState(0),[S,_]=Bt.useState(0),B=fn();Bt.useEffect(()=>{if(!b){D(0),A(0),_(0);return}let O=()=>{D(b.clientWidth);let J=editor.hostWindowOf(b).getComputedStyle(b),de=b.getAttribute("data-chrome-dir")==="rtl",he=Number.parseFloat(de?J.paddingLeft:J.paddingInlineEnd);A(Number.isFinite(he)?he:0);let Oe=Number.parseFloat(J.getPropertyValue("--docx-review-gutter-start"));_(Number.isFinite(Oe)?Oe:0);};O();let N=editor.hostWindowOf(b).ResizeObserver;if(typeof N>"u")return;let W=new N(O);return W.observe(b),()=>W.disconnect()},[b,s,x,y?.mounted,y?.gutters,B]);let Z=Bt.useRef(null);C&&(Z.current=C.pageWidthTwips);let ee=C?.pageWidthTwips??Z.current,j=Bt.useRef(null);Bt.useEffect(()=>{if(!s||!P)return;let O=Qv(P,H,()=>b);return j.current=O,()=>{O.dispose(),j.current===O&&(j.current=null);}},[s,P,b]),Bt.useEffect(()=>j.current?.nudge(),[k,ee]);let oe=Ca(n),$=w0(B,I),V=s&&_c(w-$,oe),ce=Bt.useMemo(()=>!s||V||ee===null?0:Mc({viewportWidth:w,pageWidthPx:Math.max(M??0,$e(ee))*T,reservation:oe,inlineEndReservation:I,inlineStartReservation:S,docked:E}),[s,V,ee,M,T,w,oe,I,S,E]);return Bt.useEffect(()=>{if(v)return v.setShift(ce),()=>v.setShift(0)},[v,ce]),Bt.useEffect(()=>{if(v)return v.setReservation(s&&!V?oe:0),()=>v.setReservation(0)},[v,s,V,oe]),{open:s,setOpen:p,toggle:f,tab:c,setTab:h,paneWidth:n,shift:ce,overlay:V}}var tl=["headings","find","goto"],Do=(...e)=>e.filter(Boolean).join(" ");function ol({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(nl,{}),jsxRuntime.jsx(rl,{})]})})}function nl({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(G,{name:"arrow_back",size:20})})}function rl({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 al({className:e,style:t,children:o}){let{pane:n,t:r}=Po("Tabs"),i=Bt.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=tl.indexOf(n.tab);n.setTab(tl[(s+l+tl.length)%tl.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??tl.map(a=>jsxRuntime.jsx(il,{value:a},a))})}function il({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(Uv())}):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":zv()}:{},onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function oC({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:l}){let s=Bt.useRef(null);return Bt.useEffect(()=>{a&&s.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(G,{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(G,{name:"close",size:16})})]})}function ll({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=Po("Headings"),[a,l]=Bt.useState(""),s=K(eo),c=Bt.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(oC,{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:jsxRuntime.jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function V6({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.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsxs("bdi",{children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})})}function sl({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(oC,{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(G,{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(G,{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(V6,{match:d,active:m===n.activeIndex,onSelect:()=>{n.goTo(m),r.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function cl({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=Po("Toggle"),s=Ho()("Ctrl+F"),c=i?$v(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(G,{name:"toc",size:20})})}function ff(e){let t=Lt(),o=at(),{t:n,toggle:r=true,searchHighlight:i="all",findShortcut:a=true,goToShortcut:l=true,className:s,style:c,children:d,...m}=e,u=Fc(m),g=Ic(),p=u.open&&u.tab==="find"?i:"none",f=Nc({highlight:p}),h=Qe(),v=Bt.useMemo(()=>n??((P,k)=>h(P,k)),[n,h]),b=Jv(u,a,l),y=Bt.useMemo(()=>({pane:u,outline:g,search:f,t:v,intents:b.intents,findShortcut:a,goToShortcut:l}),[u,g,f,v,b.intents,a,l]),C=L(),T=Bt.useRef(b.intents);T.current=b.intents;let x=Bt.useRef(l);x.current=l,Bt.useEffect(()=>{if(C)return C.setGoToChrome({onRequest:()=>T.current.openTab("goto"),get shortcut(){return x.current}})},[C]);let E=e.paneWidth??280;return jsxRuntime.jsx(lf.Provider,{value:y,children:jsxRuntime.jsxs("div",{ref:b.rootRef,className:`${t}docx-nav${u.open?" docx-nav--open":""}${u.overlay?" docx-nav--overlay":""}${s?` ${s}`:""}`,"data-open":u.open?"true":"false",dir:o,onKeyDown:b.onKeyDown,style:{"--docx-nav-width":`${E}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Ca(E)}px`,...c},children:[r!==false&&!u.open&&jsxRuntime.jsx(cl,{...typeof r=="object"?r:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":y.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ol,{}),jsxRuntime.jsx(al,{}),jsxRuntime.jsx(ll,{}),jsxRuntime.jsx(sl,{}),jsxRuntime.jsx(Ji,{})]})})]})})}var Lc=Object.assign(ff,{Header:ol,Close:nl,Title:rl,Tabs:al,Tab:il,Headings:ll,Find:sl,GoTo:Ji,Toggle:cl});var oF=600,nF=e=>e.isOpening===true?0:e.page.total,Hc=Bt.createContext(null);function Ac({className:e,style:t}){let o=Lt(),n=L(),r=Se(),{inside:i,host:a,hostScoped:l}=I0(r),s=K(nF),{t:c}=F(),d=Bt.useContext(Hc),[m,u]=Bt.useState(1),[g,p]=Bt.useState(false);if(Bt.useEffect(()=>{if(p(false),!n||!r||s<=1)return;u(n.getCurrentPage("viewport"));let b=editor.hostWindowOf(r),y=null,C=()=>{u(n.getCurrentPage("viewport")),p(true),y!==null&&b.clearTimeout(y),y=b.setTimeout(()=>p(false),oF);};return r.addEventListener("scroll",C,{passive:true}),()=>{r.removeEventListener("scroll",C),y!==null&&b.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}),v=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(v,a):null:v}var iF=[],lF=e=>e.fontSubstitutions??iF;function Oc({className:e,style:t,t:o}){let n=K(lF),{t:r}=F(),i=o??r,[a,l]=Bt.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 hF={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function yF(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var xF=e=>e.openFailure??null;function cC(e={}){let t=K(xF),{t:o}=F(),n=e.t??o,[r,i]=Bt.useState(null),a=t!==null&&t!==r?t:null,l=Bt.useCallback(s=>{yF(s,t)||i(t);},[t]);return {failure:a,message:a?n(hF[a.reason]):null,dismiss:l}}var dC=Bt.createContext(null);function bf({variant:e="secondary",dismiss:t=false,asChild:o=false,className:n,onClick:r,children:i,type:a,...l}){let s=Bt.useContext(dC),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(X,{...l,className:c,onClick:d,children:i}):jsxRuntime.jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var sC=new Set;function uC(e,t){if(!t||!gt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||sC.has(o)||(sC.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 pC(e){return Bt.Children.toArray(e).some(t=>Bt.isValidElement(t)&&t.type===Bt.Fragment?pC(t.props.children):true)}function vF({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}=F(),u=d??m,{failure:g,message:p,dismiss:f}=cC({t:u}),h=Bt.useId();if(!g||p===null)return null;let v=()=>{f(g),a?.(g);},b={failure:g,message:p,dismiss:v},y=e??u("openFailure.title"),C=typeof t=="function"?t(g):t??p,T=n?.(b),x=pC(T);return jsxRuntime.jsx(dC.Provider,{value:b,children:jsxRuntime.jsx(Be,{kind:"openFailure",role:"alertdialog",label:y,className:s,style:c,onClose:v,dismissOutside:false,...l?{}:{describedBy:h},children:l?l(b):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:C}),o?jsxRuntime.jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),x||i?jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[T,i?jsxRuntime.jsx(bf,{variant:x?"secondary":"primary",dismiss:true,children:r??u("common.close")}):null]}):null]})})})}var Bc=Object.assign(vF,{Action:bf});function hf(e){return Math.round(e/1440*100)/100}function mC(e){return Math.round(e*1440)}function EF(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 yf(){let e=L(),t=Bt.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return K(t,EF)}function wF(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 DF=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function dl(e){let t=L();return Bt.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 RF(e){let{state:t,onMouseDown:o}=e,{t:n}=F(),r=L(),[i,a]=Bt.useState(false),l=Bt.useRef(null),[s,c]=Bt.useState(""),[d,m]=Bt.useState("");Bt.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(hf(t.headerDistanceTwips))),m(String(hf(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let u=Bt.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=Bt.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=Bt.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=Bt.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=Bt.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),v=dl(u),b=dl(g),y=dl(p),C=dl(f),T=dl(h),x=(E,P)=>{if(!r)return;let k=Number.parseFloat(P);Number.isFinite(k)&&r.exec({type:"setHeaderFooterOptions",[E]:mC(k)});};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:[DF.map(E=>{let P={type:"insertPageField",field:E.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(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:!v.enabled,title:v.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:!b.enabled,title:b.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:!C.enabled,title:C.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:()=>x("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:()=>x("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:!T.enabled,title:T.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 Wc({className:e}){let{t}=F(),o=yf(),n=Bt.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=li(n,"story-label"),i=U;if(!o?.editing)return null;let a=wF(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:xt.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(RF,{state:o,onMouseDown:i})]})}var NF={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},FF={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},LF={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},HF={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},AF={position:"absolute",top:40,insetInlineStart:0,zIndex:10,pointerEvents:"none"},OF={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)"},BF={padding:"8px 12px"},WF={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},ZF={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},KF={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function qF({forwardedRef:e}){let t=L(),o=Bt.useRef(null);return o.current=t,F0({ref:e,editorRef:o}),null}function UF(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var zF=Bt.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:v,locale:b,mode:y="edit",modules:C,zoom:T,zoomMode:x,revisionMarkup:E,onRevisionMarkupChange:P,reviewDisplayMode:k,fieldResults:w,contentLockPolicy:D,lockedControlNavigation:M,onReady:H,onChange:I,onFontError:A,onOpen:S,onSave:_,hyperlinkPopup:B,contextMenu:Z=true,menu:ee=true,navigation:j=true,openFailure:oe=true,rulers:$=true}=t;!c&&f!==void 0&&d0(),uC(oe,p!==void 0);let[V,ce]=Bt.useState(jh);Bt.useEffect(()=>{if(h==="system")return Xh(ce)},[h]);let O=Yh(h,V),{t:N}=F(),W=at(),J=Bt.useCallback((we,Ke)=>s?s(we,Ke):N(we,Ke),[s,N]),de=jsxRuntime.jsxs(Hs,{className:c?O?"dark":void 0:l,style:c?FF:void 0,children:[c?jsxRuntime.jsx(Wc,{}):null,c?jsxRuntime.jsx(fs,{}):null,jsxRuntime.jsx(Ms,{}),$&&c?jsxRuntime.jsx("div",{style:AF,dir:W,children:jsxRuntime.jsx(wc,{})}):null,t.children]}),he=c?jsxRuntime.jsxs("div",{className:`docx-editor${O?" dark":""}${l?` ${l}`:""}`,style:NF,dir:W,children:[jsxRuntime.jsxs("div",{style:OF,children:[jsxRuntime.jsxs("div",{style:WF,children:[u?.(),jsxRuntime.jsxs("div",{style:ZF,children:[m?jsxRuntime.jsx("input",{"aria-label":J("titleBar.documentNameAriaLabel"),value:d??"",placeholder:J("titleBar.untitled"),onChange:we=>m(we.target.value),style:KF}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??J("titleBar.untitled")}),ee!==false?jsxRuntime.jsx($i,{t:J,...d!==void 0?{fileName:d}:{},...S?{onOpen:S}:{},..._?{onSave:_}:{},...typeof ee=="object"?ee:{}}):null]}),g?.()]}),jsxRuntime.jsx("div",{style:BF,children:jsxRuntime.jsx(Ki,{t:J})})]}),$?jsxRuntime.jsx("div",{style:HF,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(kc,{})}):null,jsxRuntime.jsx(Oc,{t:J}),jsxRuntime.jsxs("div",{style:LF,children:[j===false?null:jsxRuntime.jsx(Lc,{t:J,...typeof j=="object"?j:{}}),de,jsxRuntime.jsx(Hc.Provider,{value:J,children:jsxRuntime.jsx(Ac,{})}),jsxRuntime.jsx(Is,{overlay:true,indicator:f})]})]}):de,Oe=Bt.useCallback(we=>J(we),[J]);return jsxRuntime.jsxs(hi,{popups:Dh(t.popups,B,Z,J),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...v!==void 0?{author:v}:{},...b!==void 0?{locale:b}:{},translate:J,mode:y,...C!==void 0?{modules:C}:{},...T!==void 0?{zoom:T}:{},revisionMarkup:E,onRevisionMarkupChange:P,reviewDisplayMode:k,...w!==void 0?{fieldResults:w}:{},...D!==void 0?{contentLockPolicy:D}:{},...M!==void 0?{lockedControlNavigation:M}:{},...x!==void 0?{zoomMode:x}:{},tableInteractionLabel:Oe,...H?{onReady:H}:{},...I?{onChange:I}:{},...A?{onFontError:A}:{},children:[jsxRuntime.jsx(qF,{forwardedRef:o}),jsxRuntime.jsx(Gn.Provider,{value:c,children:he}),oe===false?null:jsxRuntime.jsx(Bc,{t:J,...typeof oe=="object"?oe:{},...p?{actions:p}:{},className:UF(O?"dark":void 0,typeof oe=="object"?oe.className:void 0)})]})}),$F=Bt.forwardRef(function(t,o){return jsxRuntime.jsx(yr,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(zF,{...t,ref:o})})}),VF=Object.assign($F,{Root:hi,Viewport:Hs,Content:Ms,Window:Bp,Toolbar:Ki,Menu:$i,Loading:Is,ColorByChangeType:Kp,RevisionMarkup:Hd,RevisionMarkupDialog:Ra,UnsupportedElement:dd,AuthorStyle:qp,HorizontalRuler:kc,VerticalRuler:wc,DocumentOutline:af,Navigation:Lc,ExportDialog:Ma,PrintDialog:_a,PageSetupDialog:Un,WatermarkDialog:zn,BookmarkDialog:ja,SplitCellDialog:Ya,ParagraphDialog:Zo,TextFormFieldDialog:Ja,PageNumber:Ac,FontNotice:Oc,OpenFailure:Bc,HeaderFooterChrome:Wc,NotesChrome:fs,Equation:Ba,HyperLink:La,ContextMenu:Yu,ContentControlWidget:Ip,InvalidTextFormFieldDialog:dp,ImageAltTextPopup:Cs,ImagePropertiesDialog:ci,NotePropertiesDialog:gs,NotePreview:Cr,NotesContextMenu:Tr,ContentControl:Oa});function JF(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function vf(e){return Array.isArray(e)?e:[e]}function QF(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function yC(e){return e!==void 0&&vf(e).some(t=>editor.isFontResolver(t))}async function eL(e){return typeof e!="function"?await e:await e()}function tL(e,t={}){let[o,n]=Bt.useState(void 0),[r,i]=Bt.useState(void 0),[a,l]=Bt.useState(null),[s,c]=Bt.useState(e!=null),d=yC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=Bt.useState(t.fonts===void 0),p=Bt.useRef(t);p.current=t;let f=Bt.useMemo(()=>editor.defineFontResolver(h=>editor.composeFontOrigins(vf(p.current.fonts??[]).map(QF),h)),[]);return Bt.useEffect(()=>{let h=p.current.fonts;if(h===void 0){i(void 0),g(true);return}if(yC(h)){g(true);return}g(false);let v=true;return (async()=>{try{let b=await Promise.allSettled(vf(h).map(eL)),y=[];for(let C of b){if(C.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",C.reason);continue}C.value!==void 0&&y.push(C.value);}v&&y.length>0&&i(editor.composeFontConfiguration(y[0],...y.slice(1)));}catch(b){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",b);}finally{v&&g(true);}})(),()=>{v=false;}},[m]),Bt.useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let h=JF(e);if(h){n(h),l(null),c(false);return}let v=true,b=new AbortController;return c(true),l(null),(async()=>{try{let y=await fetch(String(e),{...p.current.fetchOptions,signal:b.signal});if(!y.ok)throw new Error(`could not open the document: ${y.status} ${y.statusText}`);let C=new Uint8Array(await y.arrayBuffer());if(!v)return;n(C),c(!1);}catch(y){if(!v||y instanceof Error&&y.name==="AbortError")return;l(y instanceof Error?y:new Error("could not open the document")),c(false);}})(),()=>{v=false,b.abort();}},[e]),{document:u?o:void 0,fonts:d?f:r,error:a,isLoading:s||!u}}function iL(...e){let t=Bt.useRef(e);return t.current=e,Bt.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function cL(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function dL(){let e=L(),t=Bt.useRef(null),o=Bt.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=Bt.useCallback(()=>{let r=cL(e),i=t.current;return (r===null?i===null:i!==null&&uL(i,r))?i:(t.current=r,r)},[e]);return Bt.useSyncExternalStore(o,n,()=>null)}function uL(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function fL(e){let t=L(),o=Bt.useRef(e);o.current=e;let n=typeof e=="function";Bt.useEffect(()=>{if(!(!t||!n))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,n]);}var EC=Object.freeze({applied:0,unavailable:0});function SC(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=L(),[r,i]=Bt.useState(EC),a=Bt.useRef(null),l=Bt.useRef(o);l.current=o;let s=Bt.useRef(t);s.current=t;let c=SC(o);return Bt.useEffect(()=>{if(!n){i(EC);return}let d=editor.watchHighlights(n,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:SC(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),Bt.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 SL(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 PL(e){let t=L(),o=Se(),[n,r]=Bt.useState(null);return Bt.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=>SL(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 Tf({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=Bt.useRef(null),c=Bt.useRef(null),[d,m]=Bt.useState(null),u=Bt.useRef(n);u.current=n;let g=Bt.useRef(r);return g.current=r,Bt.useEffect(()=>{let p=s.current;if(!p)return;let f=editor.mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:v=>{m(v),u.current?.(v);}});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]),Bt.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 pl=Bt.createContext(null);function PC(){let e=Bt.useContext(pl);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function AL(e){return "type"in e&&e.type==="separator"}var DC={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"},OL={...DC,background:"var(--doc-bg-hover)"},RC={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"},BL={...RC,opacity:.4,cursor:"default"},WL={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},ZL={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},KL={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 ml({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=Bt.useState(false),[a,l]=Bt.useState(null),s=Bt.useRef(null),c=Bt.useRef(null),[d,m]=Bt.useState({top:0,left:0}),u=Bt.useCallback(()=>{i(false),l(null);},[]);Bt.useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[r]),Bt.useEffect(()=>{if(!r)return;function p(y){y.key==="Escape"&&u();}function f(){u();}let h=editor.hostDocumentOf(s.current),v=editor.hostWindowOf(s.current),b=editor.listenForOutsidePress({popup:s.current,contains:y=>!s.current||!c.current||s.current.contains(y)||c.current.contains(y),close:u});return h.addEventListener("keydown",p),v.addEventListener("scroll",f,true),()=>{b(),h.removeEventListener("keydown",p),v.removeEventListener("scroll",f,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?OL:DC,children:[e,n&&jsxRuntime.jsx(G,{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(AL(p))return jsxRuntime.jsx("div",{style:WL},`sep-${f}`);let h=p;if(h.customContent)return jsxRuntime.jsx("div",{onMouseDown:y=>y.preventDefault(),children:h.customContent},h.label);let v=!!h.submenuContent,b=a===h.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>v&&l(h.label),onMouseLeave:()=>v&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:h.disabled?BL:RC,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(G,{name:h.icon,size:18}),jsxRuntime.jsx("span",{children:h.label}),h.shortcut&&jsxRuntime.jsx("span",{style:ZL,children:h.shortcut}),v&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx(G,{name:"keyboard_arrow_right",size:16})})]}),v&&b&&jsxRuntime.jsx("div",{style:KL,onMouseDown:y=>y.preventDefault(),children:h.submenuContent(u)})]},h.label)})})]})}var Pf=18,UL=2,_C={width:Pf,height:Pf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},zL={..._C,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},$L={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function IC({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=Bt.useState(0),[i,a]=Bt.useState(0),l=Bt.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?zL:_C,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:UL,gridTemplateColumns:`repeat(${o}, ${Pf}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:$L,children:c})]})}function XL({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(G,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function JL(){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 qc({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function QL(e){return e.replace(/\.docx$/i,"")}function wf({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=F(),i=o??r("titleBar.untitled"),a=QL(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 Uc({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function zc(){let{t:e}=F(),t=PC(),{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:v}=t,b=Bt.useCallback(x=>{!o&&n&&n(x);},[o,n]),y=Bt.useCallback((x,E)=>{!o&&c&&(c(x,E),editor.hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>v?.()));},[o,c,v,t.editorRef]),C=!!r||!!l,T=C||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[T&&jsxRuntime.jsx(ml,{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)&&C?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsxRuntime.jsx(ml,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>b("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>b("setRtl")}]}),jsxRuntime.jsx(ml,{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:x=>jsxRuntime.jsx(IC,{onInsert:(E,P)=>{y(E,P),x();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:x=>jsxRuntime.jsx(XL,{closeMenu:x,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(ml,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>Ui()}]})]})}function Df({children:e}){let t=null,o=null,n=[],r=[];Bt.Children.forEach(e,a=>{Bt.isValidElement(a)&&(a.type===qc?t=a:a.type===Uc?o=a:a.type===zc?r.push(a):n.push(a));});let i=Bt.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(JL,{})}),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 $c={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},n4={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:""},NC={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 r4(e,t){let o=NC[t]??NC[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:$c[o]??"000000"}function FC(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 Rf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${FC(e.value)??o}`;let n=Object.entries(t?.colorScheme??$c).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:r4(t,e.slot)}`}function Vo(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?FC(e.value):Rf(e,t).slice(1)}function LC(e){if(!e||e==="none")return "";let t=n4[e];return t?`#${t}`:""}var a4=[{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"}],i4=[{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 HC(e){let t=e??$c;return i4.map(o=>a4.map(n=>{let r=t[n.slot]??$c[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 ue(...e){return clsx.clsx(e)}var c4=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=Bt__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:ue(c4({variant:t,size:o,className:e})),ref:r,...n}));nt.displayName="Button";function Ut({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=Bt__namespace.useState(false),[a,l]=Bt__namespace.useState({x:0,y:0}),s=Bt__namespace.useRef(null),c=Bt__namespace.useRef(null),d=Bt__namespace.useCallback(()=>{let p=editor.hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let h=s.current.getBoundingClientRect(),v=h.left+h.width/2,b=o==="top"?h.top-8:h.bottom+8;l({x:v,y:b});}i(true);},n);c.current={win:p,handle:f};},[n,o]),m=Bt__namespace.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Bt__namespace.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Bt__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 Mf=Bt__namespace.createContext(null);function Cn(e){let[t,o]=Bt__namespace.useState(null),n=Bt__namespace.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsxRuntime.jsx(Mf.Provider,{value:n,children:jsxRuntime.jsx(Fe__namespace.Root,{...e})})}var Tn=Fe__namespace.Group,Vc=Fe__namespace.Value;function En({className:e,children:t,onMouseDown:o,...n}){let r=Bt__namespace.useContext(Mf)?.setTrigger;return jsxRuntime.jsxs(Fe__namespace.Trigger,{ref:r,className:ue("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(y4,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Sn({className:e,children:t,position:o="popper",onCloseAutoFocus:n,onKeyDown:r,...i}){let a=Bt__namespace.useContext(Mf)?.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:ue("docx-editor",s&&"dark"),children:jsxRuntime.jsx(Fe__namespace.Content,{className:ue("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||h4(c);},...i,children:jsxRuntime.jsx(Fe__namespace.Viewport,{className:ue("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 b4=new Set(["ArrowDown","ArrowUp","Home","End"]);function h4(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!b4.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 lr({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Label,{className:ue("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function zt({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(Fe__namespace.Item,{className:ue("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(x4,{className:"h-4 w-4"})})})]})}function sr({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function y4({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 x4({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 _f(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 v4=[{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 BC({value:e,onChange:t,fonts:o=v4,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=F(),d=Bt__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=Bt__namespace.useMemo(()=>[...d,...o],[d,o]),u=Bt__namespace.useMemo(()=>e?m.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||_f(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=Bt__namespace.useCallback(f=>{let h=m.find(v=>v.name===f);h&&t?.(_f(h.fontFamily)||h.name);},[t,m]),p=Bt__namespace.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(h=>{let v=h.category||"other";f[v].push(h);}),f},[o]);return jsxRuntime.jsxs(Cn,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(En,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(Vc,{placeholder:a,children:u})}),jsxRuntime.jsxs(Sn,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Tn,{children:[jsxRuntime.jsx(lr,{children:c("font.documentFonts")}),d.map(f=>jsxRuntime.jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsxRuntime.jsx(sr,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(Tn,{children:[jsxRuntime.jsx(lr,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsxRuntime.jsx(zt,{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(sr,{}),jsxRuntime.jsxs(Tn,{children:[jsxRuntime.jsx(lr,{children:c("font.serif")}),p.serif.map(f=>jsxRuntime.jsx(zt,{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(sr,{}),jsxRuntime.jsxs(Tn,{children:[jsxRuntime.jsx(lr,{children:c("font.monospace")}),p.monospace.map(f=>jsxRuntime.jsx(zt,{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(sr,{}),jsxRuntime.jsx(Tn,{children:p.other.map(f=>jsxRuntime.jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function If(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 k4(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=Bt.useRef(null),r=Bt.useRef(null),[i,a]=Bt.useState({top:0,left:0});Bt.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=k4(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]),Bt.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=f=>{f.key==="Escape"&&t();},m=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();},u=editor.hostDocumentOf(n.current),g=editor.hostWindowOf(n.current),p=editor.listenForOutsidePress({popup:n.current,contains:f=>!n.current||!r.current||n.current.contains(f)||r.current.contains(f),close:()=>t()});return u.addEventListener("keydown",d),g.addEventListener("scroll",m,true),()=>{p(),u.removeEventListener("keydown",d),g.removeEventListener("scroll",m,true);}},[e,t]);let l=Bt.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 M4=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],_4=1,I4=400;function qC(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function UC(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 zC({value:e,onChange:t,sizes:o=M4,disabled:n=false,className:r,placeholder:i="11",minSize:a=_4,maxSize:l=I4}){let{t:s}=F(),[c,d]=Bt.useState(false),[m,u]=Bt.useState(""),[g,p]=Bt.useState(false),f=Bt.useRef(null),h=Bt.useCallback(()=>{p(false),d(false);},[]),{containerRef:v,dropdownRef:b,dropdownStyle:y}=Rt({isOpen:g,onClose:h}),C=e??(parseInt(i,10)||11),T=e!==void 0?e.toString():i,x=Bt.useCallback(I=>{if(I.preventDefault(),n)return;let A=UC(C,o,a);t?.(A);},[C,o,a,n,t]),E=Bt.useCallback(I=>{if(I.preventDefault(),n)return;let A=qC(C,o,l);t?.(A);},[C,o,l,n,t]),P=Bt.useCallback(I=>{I.preventDefault(),!n&&(d(true),u(T),p(true),editor.hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[n,T]),k=Bt.useCallback(I=>{u(I.target.value);},[]),w=Bt.useCallback(()=>{d(false);let I=parseFloat(m);if(!isNaN(I)&&I>=a&&I<=l){let A=Math.round(I*2)/2;t?.(A);}},[m,a,l,t]),D=Bt.useCallback(I=>{if(I.key==="Enter")I.preventDefault(),w(),p(false);else if(I.key==="Escape")d(false),p(false);else if(I.key==="ArrowUp"){I.preventDefault();let A=qC(C,o,l);u(A.toString()),t?.(A);}else if(I.key==="ArrowDown"){I.preventDefault();let A=UC(C,o,a);u(A.toString()),t?.(A);}},[w,C,o,l,a,t]),M=Bt.useCallback(I=>{t?.(I),p(false),d(false);},[t]),H=Bt.useCallback(I=>{I.target.tagName!=="INPUT"&&I.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:v,className:ue("flex items-center",r),onMouseDown:H,children:[jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:x,disabled:n||C<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx(G,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:f,type:"text",value:m,onChange:k,onBlur:w,onKeyDown:D,className:ue("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:P,className:ue("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:T})}),g&&jsxRuntime.jsx("div",{ref:b,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(I=>jsxRuntime.jsx("button",{type:"button",onClick:()=>M(I),className:ue("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",I===C&&"bg-muted font-medium"),role:"option","aria-selected":I===C,children:I},I))}),jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("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||C>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx(G,{name:"add",size:18})})]})}var L4=[{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"}],jc=18,H4=2,A4={position:"relative",display:"inline-block"},O4={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)"},B4={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},Lf={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},Hf={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},GC={display:"grid",gap:`${H4}px`},Yc={width:`${jc}px`,height:`${jc}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},jC={...Yc,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},YC={...Yc,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},W4={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)"},Z4={display:"flex",alignItems:"center",gap:"6px"},K4={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},q4={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},$C={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},U4={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},z4={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)"},$4={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 Af(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=LC(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Rf(e,o)}function VC(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 XC(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Vo(e,o))===t.toUpperCase():false}function V4({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=Bt.useState(null);return jsxRuntime.jsx("div",{style:{...GC,gridTemplateColumns:`repeat(10, ${jc}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=r===d,u=XC(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?YC:m?jC:Yc,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 G4({selectedColor:e,theme:t,onSelect:o}){let[n,r]=Bt.useState(null),{t:i}=F();return jsxRuntime.jsx("div",{style:{...GC,gridTemplateColumns:`repeat(10, ${jc}px)`},children:L4.map((a,l)=>{let s=n===l,c=XC(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?YC:s?jC:Yc,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 ur({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]=Bt.useState(false),[p,f]=Bt.useState(false),[h,v]=Bt.useState(false),[b,y]=Bt.useState(false),[C,T]=Bt.useState(""),[x,E]=Bt.useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:P}=F();Bt.useEffect(()=>{let O=Af(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(O)&&T(O.toUpperCase());},[t,e,n]);let k=Bt.useCallback(()=>g(false),[]),{containerRef:w,dropdownRef:D,dropdownStyle:M}=Rt({isOpen:u,onClose:k}),H=n?.colorScheme??null,I=Bt.useMemo(()=>HC(H),[H]),A=Bt.useMemo(()=>Af(t,e,n),[t,e,n]),S=Bt.useMemo(()=>Af(x,e,n),[x,e,n]),_=Bt.useCallback(()=>{r||g(O=>!O);},[r]),B=Bt.useCallback(O=>{let N;e==="highlight"?N=O.hex:N={kind:"theme",slot:O.themeSlot,...O.tint!==void 0?{tint:O.tint}:{},...O.shade!==void 0?{shade:O.shade}:{}},E(N),o?.(N),g(false);},[e,o]),Z=Bt.useCallback(O=>{let N=e==="highlight"?O:{kind:"hex",value:O};E(N),o?.(N),g(false);},[e,o]),ee=Bt.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),j=Bt.useCallback(()=>{let O=C.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(O)){let N=e==="highlight"?O:{kind:"hex",value:O};E(N),o?.(N),g(false),T("");}},[e,C,o]),oe=Bt.useCallback(()=>{r||o?.(x);},[r,x,o]),$={...O4,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},V=P(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),ce=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:w,className:`docx-color-picker ${i||""}`,style:{...A4,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...U4,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...z4,...r?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:oe,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>v(true),onMouseLeave:()=>v(false),disabled:r,title:l||V,"aria-label":l||V,children:[jsxRuntime.jsx(G,{name:ce,size:18}),jsxRuntime.jsx("div",{style:{...$C,backgroundColor:S==="transparent"?"#fff":S,outline:S==="transparent"||VC(S)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...$4,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:_,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:l||V,"aria-label":l||V,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx(G,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:$,onClick:_,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||V,"aria-label":l||V,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx(G,{name:ce,size:18}),jsxRuntime.jsx("div",{style:{...$C,backgroundColor:A==="transparent"?"#fff":A,outline:A==="transparent"||VC(A)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:D,className:"docx-color-picker-dropdown",style:{...M,...B4},role:"dialog","aria-label":`${V} picker`,onMouseDown:O=>{O.target.tagName!=="INPUT"&&O.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:W4,onClick:ee,onMouseDown:O=>O.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:Hf}),jsxRuntime.jsx("div",{style:Lf,children:P("colorPicker.themeColors")}),jsxRuntime.jsx(V4,{matrix:I,selectedColor:t,theme:n,onSelect:B}),jsxRuntime.jsx("div",{style:Hf}),jsxRuntime.jsx("div",{style:Lf,children:P("colorPicker.standardColors")}),jsxRuntime.jsx(G4,{selectedColor:t,theme:n,onSelect:Z}),jsxRuntime.jsx("div",{style:Hf}),jsxRuntime.jsx("div",{style:Lf,children:P("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:Z4,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:K4,value:C,onChange:O=>T(O.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:O=>{O.key==="Enter"&&j();},onMouseDown:O=>{O.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...q4,opacity:/^[0-9A-Fa-f]{6}$/.test(C)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(C)?"pointer":"default"},onClick:j,onMouseDown:O=>O.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(C),children:P("common.apply")})]})]})})]})}var gl=20,Of=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_left",size:gl}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_center",size:gl}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_right",size:gl}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_justify",size:gl}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function eT({value:e="left",onChange:t,disabled:o=false}){let{t:n}=F(),[r,i]=Bt.useState(false),a=Bt.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=Rt({isOpen:r,onClose:a}),m=Bt.useCallback(v=>{o||t?.(v),i(false);},[o,t]),u=Of.find(v=>v.value===e)||Of[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:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(v=>!v),disabled:o,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx(G,{name:u.iconName,size:gl}),jsxRuntime.jsx(G,{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(Ut,{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:v=>v.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:Of.map(v=>{let b=e===v.value,y=n(v.labelKey),C=v.shortcutKey?n(v.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${y}${C?` (${C})`:""}`,"data-testid":`alignment-${v.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,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)"},onMouseDown:T=>T.preventDefault(),onMouseEnter:T=>{b||(T.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=b?"var(--doc-primary-light)":"transparent";},onClick:()=>m(v.value),children:jsxRuntime.jsx(G,{name:v.iconName,size:18})},v.value)})})})]})}function Xc(){return {type:"none",level:0,isInList:false}}var Q4={display:"inline-flex",alignItems:"center",gap:"4px"},tT={display:"inline-flex",alignItems:"center",gap:"4px"},td={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)"},e3={...td,backgroundColor:"var(--doc-bg-hover)"},t3={...td,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},o3={...td,cursor:"default",opacity:.38},n3={width:"28px",height:"28px",padding:"2px"},r3={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Jc=20;function Qc({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=Bt.useState(false),c={...t?o3:e?t3:l?e3:td,...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 oT({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}=F(),u=Bt.useCallback(()=>c?{...n3}:{},[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:{...Q4,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:tT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsxRuntime.jsx(Qc,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx(G,{name:"format_list_bulleted",size:Jc})}),jsxRuntime.jsx(Qc,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx(G,{name:"format_list_numbered",size:Jc})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:r3,role:"separator"}),jsxRuntime.jsxs("div",{style:tT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(Qc,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx(G,{name:"format_indent_decrease",size:Jc})}),jsxRuntime.jsx(Qc,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx(G,{name:"format_indent_increase",size:Jc})})]})]})]})}var i3=[{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 rT({value:e,onChange:t,options:o=i3,disabled:n=false,className:r}){let{t:i}=F(),a=Bt__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Bt__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(Cn,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(En,{className:ue("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(nf,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Sn,{children:[o.map(c=>jsxRuntime.jsx(zt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(sr,{}),jsxRuntime.jsx(Tn,{children:jsxRuntime.jsx(lr,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var aT=[{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 iT({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=F(),l=Bt__namespace.useMemo(()=>{let g=Gy(o);return g.length===0?aT:g.map(p=>({...p,type:"paragraph",nameKey:aT.find(f=>f.styleId===p.styleId)?.nameKey}))},[o]),s=Bt__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(Cn,{value:d,onValueChange:s,disabled:n,children:[jsxRuntime.jsx(En,{className:ue("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(Sn,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(zt,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:Vy(g),children:c(g)})},g.styleId))})]})}var s3=[{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 sT({value:e=1,onChange:t,levels:o=s3,disabled:n=false,className:r,compact:i=false}){let{t:a}=F(),l=Bt__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Bt__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Bt__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Bt__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Bt__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:ue(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(G,{name:"remove",size:18})}),jsxRuntime.jsxs(Cn,{value:e.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(En,{className:ue(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(Vc,{placeholder:"100%",children:l})}),jsxRuntime.jsx(Sn,{children:o.map(g=>jsxRuntime.jsx(zt,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:ue(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(G,{name:"add",size:18})})]})}var d3=[{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 uT({onAction:e,disabled:t=false}){let{t:o}=F(),[n,r]=Bt.useState(false),i=Bt.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:n,onClose:i}),d=Bt.useCallback(u=>{e(u),r(false);},[e]),m=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("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(G,{name:"border_all",size:20}),jsxRuntime.jsx(G,{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(Ut,{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:d3.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(G,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function pT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=F(),i=Bt.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(ur,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var f3=[{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 fT({onAction:e,disabled:t=false}){let[o,n]=Bt.useState(false),{t:r}=F(),i=Bt.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:o,onClose:i}),d=Bt.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),m=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("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(G,{name:"line_weight",size:20}),jsxRuntime.jsx(G,{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(Ut,{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:f3.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 bT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=F(),i=Bt.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(ur,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var b3={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"},fr={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},xT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function vT({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=F(),[r,i]=Bt.useState(false),[a,l]=Bt.useState(null),s=Bt.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=Bt.useCallback(v=>{e(v),i(false);},[e]),f=(v,b,y,C,T)=>{let x=t||T?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...b3,backgroundColor:a===v&&!x?"var(--doc-bg-hover)":"transparent",color:x?"var(--doc-text-muted)":T?.danger?"var(--doc-error)":"var(--doc-text)",cursor:x?"not-allowed":"pointer"},onClick:()=>!x&&p(C),onMouseEnter:()=>l(v),onMouseLeave:()=>l(null),disabled:x,children:[jsxRuntime.jsx(G,{name:b,size:16,className:T?.danger&&!x?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:y})]},v)},h=jsxRuntime.jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(v=>!v),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx(G,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?h:jsxRuntime.jsx(Ut,{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:v=>v.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:fr,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:fr,role:"separator"}),f("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:fr,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:fr,role:"separator"}),jsxRuntime.jsx("div",{style:xT,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(v=>{let b={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"}[v]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:v}),children:jsxRuntime.jsx(G,{name:b[v],size:16})},v)})}),jsxRuntime.jsx("div",{style:fr,role:"separator"}),jsxRuntime.jsx("div",{style:xT,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(v=>{let b={left:"format_align_left",center:"format_align_center",right:"format_align_right"},y=g===v;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[v]),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:C=>C.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:v}}),children:jsxRuntime.jsx(G,{name:b[v],size:16})},v)})}),jsxRuntime.jsx("div",{style:fr,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:fr,role:"separator"}),f("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var y3=20;function rd({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=Bt.useState(false),m=Bt.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=Rt({isOpen:c,onClose:m}),h=Bt.useCallback(b=>{i||r(b),d(false);},[i,r]),v=jsxRuntime.jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(b=>!b),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx(G,{name:o,size:y3}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?v:jsxRuntime.jsx(Ut,{content:n,children:v}),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:b=>b.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(b=>{let y=t===b.value;return jsxRuntime.jsxs("button",{type:"button",title:b.label,"data-testid":l?`${l}-${b.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:C=>C.preventDefault(),onMouseEnter:C=>{y||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:C=>{C.currentTarget.style.backgroundColor=y?"var(--doc-primary-light)":"transparent";},onClick:()=>h(b.value),children:[jsxRuntime.jsx(G,{name:b.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:b.label})]},b.value)})})})]})}var x3=[{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 v3(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function TT({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=F(),r=x3.map(l=>({...l,label:n(l.labelKey)})),i=v3(e),a=r.find(l=>l.value===i)||r[0];return jsxRuntime.jsx(rd,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var T3=[{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 ET({onTransform:e,disabled:t=false}){let{t:o}=F(),n=T3.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(rd,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var io=18;function $t({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:ue("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(Ut,{content:o,children:c}):c}function lo({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:ue("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 w3(e){let t=Bt__namespace.default.useContext(pl);return t?{...t,...D3(e)}:e}function D3(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function qf(e){let{t}=F(),o=w3(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:v,showFontSizePicker:b=true,showTextColorPicker:y=true,showHighlightColorPicker:C=true,showAlignmentButtons:T=true,showListButtons:x=true,showLineSpacingPicker:E=true,showStylePicker:P=true,documentStyles:k,theme:w,showZoomControl:D=true,zoom:M,onZoomChange:H,onRefocusEditor:I,imageContext:A,onImageWrapType:S,onImageTransform:_,onOpenImageProperties:B,tableContext:Z,onTableAction:ee,inline:j=false}=o,oe=Bt.useRef(null),$=Bt.useCallback(ae=>{!c&&r&&r(ae);},[c,r]),V=Bt.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ce=Bt.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),O=Bt.useCallback(ae=>{!c&&r&&r({type:"fontFamily",value:ae});},[c,r]),N=Bt__namespace.default.useMemo(()=>If(h),[h]),W=Bt.useCallback(ae=>{!c&&r&&r({type:"fontSize",value:ae});},[c,r]),J=Bt.useCallback(ae=>{!c&&r&&r({type:"textColor",value:ae});},[c,r]),de=Bt.useCallback(ae=>{!c&&r&&r({type:"highlightColor",value:typeof ae=="string"?ae:""});},[c,r]),he=Bt.useCallback(ae=>{!c&&r&&r({type:"alignment",value:ae});},[c,r]),Oe=Bt.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),we=Bt.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),Ke=Bt.useCallback(()=>{!c&&r&&r("indent");},[c,r]),Te=Bt.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Io=Bt.useCallback(ae=>{!c&&r&&(r({type:"lineSpacing",value:ae}),editor.hostWindowOf(oe.current).requestAnimationFrame(()=>I?.()));},[c,r,I]),co=Bt.useCallback(ae=>{!c&&r&&r({type:"applyStyle",value:ae});},[c,r]),_t=Bt.useCallback(ae=>{!c&&ee&&(ee(ae),editor.hostWindowOf(oe.current).requestAnimationFrame(()=>I?.()));},[c,ee,I]);Bt.useEffect(()=>{if(!u)return;let ae=Ie=>{if(Ie.defaultPrevented)return;let uo=Ie.target,Jo=g?.current,It=oe.current,No=Jo?.contains(uo),br=It?.contains(uo);if(!No&&!br)return;if((Ie.ctrlKey||Ie.metaKey)&&!Ie.altKey)switch(Ie.key.toLowerCase()){case "b":Ie.preventDefault(),$("bold");break;case "i":Ie.preventDefault(),$("italic");break;case "u":Ie.preventDefault(),$("underline");break;case "=":Ie.shiftKey?(Ie.preventDefault(),$("superscript")):(Ie.preventDefault(),$("subscript"));break;case "l":Ie.preventDefault(),he("left");break;case "e":Ie.preventDefault(),he("center");break;case "r":Ie.preventDefault(),he("right");break;case "j":Ie.preventDefault(),he("both");break;case "k":Ie.preventDefault(),$("insertLink");break}},rt=editor.hostDocumentOf(g?.current??oe.current);return rt.addEventListener("keydown",ae),()=>{rt.removeEventListener("keydown",ae);}},[u,$,he,g]);let Xo=Bt.useCallback(ae=>{let rt=ae.target;rt.tagName==="INPUT"||rt.tagName==="TEXTAREA"||rt.tagName==="SELECT"||rt.tagName==="OPTION"||ae.preventDefault();},[]),Mn=Bt.useCallback(ae=>{let rt=ae.target,Ie=editor.hostDocumentOf(rt).activeElement;rt.tagName==="SELECT"||rt.tagName==="OPTION"||Ie?.tagName==="SELECT"||editor.hostWindowOf(rt).requestAnimationFrame(()=>{I?.();});},[I]);return jsxRuntime.jsxs("div",{ref:oe,className:ue(!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",...m}:m,role:j?void 0:"toolbar","aria-label":j?void 0:t("toolbar.ariaLabel"),"data-testid":j?void 0:"formatting-bar",onMouseDown:j?void 0:Xo,onMouseUp:j?void 0:Mn,children:[jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx($t,{onClick:V,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx(G,{name:"undo",size:io})}),jsxRuntime.jsx($t,{onClick:ce,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx(G,{name:"redo",size:io})})]}),D&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(sT,{value:M,onChange:H,disabled:c,compact:true})}),P&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(iT,{value:n.styleId||"Normal",onChange:co,styles:k,theme:w,disabled:c,width:120})}),(f||b)&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.font"),children:[f&&jsxRuntime.jsx(BC,{value:n.fontFamily||"Arial",onChange:O,fonts:N,documentFonts:v,disabled:c,width:60,placeholder:"Arial"}),b&&jsxRuntime.jsx(zC,{value:n.fontSize!==void 0?Wp(n.fontSize):11,onChange:W,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx($t,{onClick:()=>$("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx(G,{name:"format_bold",size:io})}),jsxRuntime.jsx($t,{onClick:()=>$("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx(G,{name:"format_italic",size:io})}),jsxRuntime.jsx($t,{onClick:()=>$("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx(G,{name:"format_underlined",size:io})}),jsxRuntime.jsx($t,{onClick:()=>$("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx(G,{name:"strikethrough_s",size:io})}),y&&jsxRuntime.jsx(ur,{mode:"text",value:n.color?.replace(/^#/,""),onChange:J,theme:w,disabled:c,title:t("formattingBar.fontColor")}),C&&jsxRuntime.jsx(ur,{mode:"highlight",value:n.highlight,onChange:de,theme:w,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx($t,{onClick:()=>$("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx(G,{name:"link",size:io})})]}),jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx($t,{onClick:()=>$("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx(G,{name:"superscript",size:io})}),jsxRuntime.jsx($t,{onClick:()=>$("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx(G,{name:"subscript",size:io})})]}),T&&jsxRuntime.jsx(lo,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(eT,{value:n.alignment||"left",onChange:he,disabled:c})}),(x||E)&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.listFormatting"),children:[x&&jsxRuntime.jsx(oT,{listState:n.listState||Xc(),onBulletList:Oe,onNumberedList:we,onIndent:Ke,onOutdent:Te,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),E&&jsxRuntime.jsx(rT,{value:n.lineSpacing,onChange:Io,disabled:c})]}),A&&S&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(TT,{imageContext:A,onChange:S,disabled:c}),_&&jsxRuntime.jsx(ET,{onTransform:_,disabled:c}),B&&jsxRuntime.jsx($t,{onClick:B,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx(G,{name:"tune",size:io})})]}),Z?.isInTable&&ee&&jsxRuntime.jsxs(lo,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(uT,{onAction:_t,disabled:c}),jsxRuntime.jsx(pT,{onAction:_t,disabled:c,theme:w,value:Vo(Z?.cellBorderColor,w)}),jsxRuntime.jsx(fT,{onAction:_t,disabled:c}),jsxRuntime.jsx(bT,{onAction:_t,disabled:c,theme:w,value:Z?.cellBackgroundColor}),jsxRuntime.jsx(vT,{onAction:_t,disabled:c,tableContext:Z})]}),jsxRuntime.jsx($t,{onClick:()=>$("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx(G,{name:"format_clear",size:io})}),p]})}function R3({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(pl.Provider,{value:n,children:jsxRuntime.jsx("div",{className:ue("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:xt.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var Mt=R3;Mt.TitleBar=Df;Mt.Logo=qc;Mt.DocumentName=wf;Mt.MenuBar=zc;Mt.TitleBarRight=Uc;Mt.Toolbar=qf;var I3=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"]]),N3=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function F3({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=Bt.useRef(null),[f,h]=Bt.useState(null),[v,b]=Bt.useState({}),[y,C]=Bt.useState(null),T=Bt.useCallback(k=>{h(k);let w=p.current?.formatting();w&&b({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}:{}}),C(p.current?.sectionProperties()??null),r?.(k);},[r]),x=Bt.useCallback(k=>{let w=p.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 D=k.value,M=typeof D=="string"?N3(D):Vo(D,null)??null;return M?w.setRunProperty("color",{val:M}):void 0}case "highlightColor":{let D=k.value.trim().toLowerCase();if(D==="none"||D==="")return w.setRunProperty("highlight",{val:"none"});let M=I3.get(D.startsWith("#")?D:`#${D}`);return M?w.setRunProperty("highlight",{val:M}):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}}},[]);Bt.useImperativeHandle(c,()=>p.current,[]);let E=t===void 0?1:t/(96/72),P=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:v,onFormat:x,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:E,onZoomChange:m,onSave:()=>{let k=p.current?.save();k&&a?.(k);},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:[P?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(nr,{pageSetup:P,zoom:E})}):null,jsxRuntime.jsx(Tf,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:T,...i?{onError:i}:{}})]})]})}var id=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 ld=class extends id{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 W3=Bt.createContext(null);function RT({children:e}){let t=Bt.useMemo(()=>new ld,[]),o=Bt.useSyncExternalStore(t.subscribe,t.getSnapshot),n=Bt.useCallback((c,d)=>{t.showError(c,d);},[t]),r=Bt.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=Bt.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=Bt.useCallback(c=>{t.dismiss(c);},[t]),l=Bt.useCallback(()=>{t.clearAll();},[t]),s=Bt.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxRuntime.jsxs(W3.Provider,{value:s,children:[e,jsxRuntime.jsx(Z3,{notifications:o.notifications,onDismiss:a})]})}function Z3({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(K3,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function K3({notification:e,onDismiss:t}){let{t:o}=F(),[n,r]=Bt.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 sd=class extends Bt.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(q3,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function q3({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=F(),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 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;
|
|
4
|
+
`,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function IT({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=ya}){let{t:r}=F();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:xt.outline},children:jsxRuntime.jsx(G,{name:"format_list_bulleted",size:20})})}function zf({currentPage:e,totalPages:t,visible:o}){let{t:n}=F();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 z3({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:v,onScrollContainerMouseDown:b,onEditorBgMouseDown:y,onEditorContextMenu:C,horizontalRulerProps:T,verticalRulerProps:x,outlineProps:E,onToggleOutline:P,scrollPageInfo:k,toolbar:w,pagedArea:D,overlays:M,dialogs:H,fileInputs:I}){let A=d&&!m;return jsxRuntime.jsx(Gn.Provider,{value:true,children:jsxRuntime.jsx(yr,{i18n:e,children:jsxRuntime.jsx(RT,{children:jsxRuntime.jsx(sd,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:ue("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:b,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:xt.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(nr,{...T})}),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:C,children:[A&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:xt.ruler,paddingTop:48},children:jsxRuntime.jsx(ji,{...x})}),D]})})]}),k.totalPages>1&&jsxRuntime.jsx(zf,{currentPage:k.currentPage,totalPages:k.totalPages,visible:k.visible}),u&&jsxRuntime.jsx(Xi,{...E,leftOffset:Yi+(A?ha:0)}),g&&!u&&jsxRuntime.jsx(IT,{onClick:P,topPx:h+(d?Xm+8:0)+48,scrollLeft:v,leftOffset:ya+(A?ha:0)})]})}),M,H,I]})})})})})}function J3(e){let[t,o]=Bt.useState(0);return Bt.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 rH({kind:e}){let t=L(),[o,n]=Bt.useState(null),r=Bt.useRef(null);Bt.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=Bt.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,"deferFonts",{enumerable:true,get:function(){return editor.deferFonts}});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=Vn;exports.ContextMenuCopy=ei;exports.ContextMenuCopyFormatting=ls;exports.ContextMenuCut=Qa;exports.ContextMenuDelete=ti;exports.ContextMenuDeleteTable=Yr;exports.ContextMenuDeleteTableColumn=jr;exports.ContextMenuDeleteTableRow=Gr;exports.ContextMenuInsertColumnLeft=Ur;exports.ContextMenuInsertColumnRight=zr;exports.ContextMenuInsertRowAbove=Kr;exports.ContextMenuInsertRowBelow=qr;exports.ContextMenuItem=cs;exports.ContextMenuMergeCells=$r;exports.ContextMenuPaste=Wr;exports.ContextMenuPasteFormatting=ss;exports.ContextMenuPasteWithoutFormatting=Zr;exports.ContextMenuRefreshToc=Xr;exports.ContextMenuRefreshTocPageNumbers=Jr;exports.ContextMenuSelectAll=oi;exports.ContextMenuSplitCell=Vr;exports.DEFAULT_WATERMARK_PRESETS=_u;exports.DocumentName=wf;exports.DocumentOutline=Xi;exports.DocxEditor=VF;exports.DocxEditorAuthorStyle=qp;exports.DocxEditorBookmarkDialog=ja;exports.DocxEditorColorByChangeType=Kp;exports.DocxEditorContent=Ms;exports.DocxEditorContentControl=Oa;exports.DocxEditorContentControlWidget=Ip;exports.DocxEditorContextMenu=ii;exports.DocxEditorDocumentOutline=af;exports.DocxEditorEquation=Ba;exports.DocxEditorExportDialog=Ma;exports.DocxEditorFontNotice=Oc;exports.DocxEditorHeaderFooterChrome=Wc;exports.DocxEditorHorizontalRuler=kc;exports.DocxEditorHyperLink=La;exports.DocxEditorImageAltTextPopup=Cs;exports.DocxEditorImageInsertErrorDialog=du;exports.DocxEditorImagePropertiesDialog=ci;exports.DocxEditorInvalidTextFormFieldDialog=dp;exports.DocxEditorLoading=Is;exports.DocxEditorLoadingSpinner=Zp;exports.DocxEditorMenu=$i;exports.DocxEditorNavigation=ff;exports.DocxEditorNotePreview=Cr;exports.DocxEditorNotePropertiesDialog=gs;exports.DocxEditorNotesChrome=fs;exports.DocxEditorNotesContextMenu=Tr;exports.DocxEditorOpenFailure=Bc;exports.DocxEditorOpenFailureAction=bf;exports.DocxEditorPageNumber=Ac;exports.DocxEditorPageSetupDialog=Un;exports.DocxEditorParagraphDialog=Zo;exports.DocxEditorPrintDialog=_a;exports.DocxEditorRevisionMarkup=Hd;exports.DocxEditorRevisionMarkupDialog=Ra;exports.DocxEditorRoot=hi;exports.DocxEditorShell=z3;exports.DocxEditorSplitCellDialog=Ya;exports.DocxEditorTextFormFieldDialog=Ja;exports.DocxEditorToolbar=Ki;exports.DocxEditorUnsupportedElement=dd;exports.DocxEditorVerticalRuler=wc;exports.DocxEditorViewport=Hs;exports.DocxEditorWatermarkDialog=zn;exports.DocxEditorWindow=Bp;exports.HorizontalRuler=nr;exports.ImageAltText=vs;exports.ImageInsertProvider=Wl;exports.ImageInsertTrigger=Zl;exports.ImagePropertiesTrigger=xs;exports.ImageWrap=$s;exports.LocaleProvider=yr;exports.Logo=qc;exports.MenuBar=zc;exports.NAVIGATION_PANE_GAP=Mv;exports.NAVIGATION_PANE_INSET=Rc;exports.NAVIGATION_PANE_MIN_PAGE_ROOM=sf;exports.NAVIGATION_PANE_WIDTH=va;exports.NavigationClose=nl;exports.NavigationFind=sl;exports.NavigationGoTo=Ji;exports.NavigationHeader=ol;exports.NavigationHeadings=ll;exports.NavigationTab=il;exports.NavigationTabs=al;exports.NavigationTitle=rl;exports.NavigationToggle=cl;exports.OUTLINE_BUTTON_LEFT_OFFSET=ya;exports.OUTLINE_BUTTON_RESERVED_SPACE=V5;exports.OUTLINE_LEFT_OFFSET=Yi;exports.OUTLINE_RESERVED_SPACE=z5;exports.PageIndicator=zf;exports.PageNumberTranslationContext=Hc;exports.PaginatedDocxEditor=Tf;exports.PaginatedDocxEditorShell=F3;exports.REVIEW_MARKERS_GUTTER=aa;exports.REVIEW_PANE_GUTTER=yi;exports.RULER_WIDTH=ha;exports.ReviewRailContext=Nt;exports.Slot=X;exports.TitleBar=Df;exports.TitleBarRight=Uc;exports.Toolbar=qf;exports.ToolbarButton=$t;exports.ToolbarContext=Ln;exports.ToolbarGroup=lo;exports.ToolbarImageProperties=ea;exports.VERSION=LT;exports.VerticalRuler=ji;exports.definePopup=LS;exports.editorStateActiveSubscriptionCount=rE;exports.isFieldLink=Na;exports.navigationPaneOverlays=_c;exports.navigationPaneReservation=Ca;exports.navigationShift=Mc;exports.normalizeImageBytes=Ol;exports.notificationYieldsToTask=tg;exports.provideDocxEditor=IM;exports.reviewGutter=R0;exports.useBookmarkDialog=Hw;exports.useBookmarks=qu;exports.useChromeDir=at;exports.useChromeTranslate=Jf;exports.useCommentDraftRequest=fL;exports.useContentControl=bo;exports.useContentControlInstance=Il;exports.useContentControlWidget=st;exports.useContextMenuTarget=gb;exports.useDocumentOutline=Ic;exports.useDocumentSearch=Nc;exports.useDocxEditor=L;exports.useDocxSource=tL;exports.useEditorCaret=dL;exports.useEditorCommand=se;exports.useEditorEvent=Rm;exports.useEditorHostDocument=Zm;exports.useEditorSnapshot=J3;exports.useEditorState=K;exports.useEditorValueCommand=di;exports.useFontFamily=Js;exports.useFonts=iL;exports.useGoToBookmark=Dc;exports.useHeaderFooterState=yf;exports.useHighlightAt=PL;exports.useHighlights=yL;exports.useHistoryGroup=rH;exports.useHyperlinkPopup=Wd;exports.useHyperlinkPopupInstance=Ml;exports.useNavigationPane=Fc;exports.useNavigationShift=Fn;exports.useNotePropertiesState=Ju;exports.useNoteScopeState=Xu;exports.useOpenFailure=cC;exports.usePageSetup=qn;exports.usePageSetupDialog=Qk;exports.useParagraphDialog=pw;exports.useParagraphFormat=Du;exports.useParagraphIndent=Qm;exports.useParagraphStyle=Qs;exports.useReviewAuthors=Ci;exports.useReviewGutter=fn;exports.useRevisionMarkupDialog=PS;exports.useScopeClassName=Lt;exports.useScopedChromeAnchor=li;exports.useSplitCellDialog=Vw;exports.useTableBorderTargetLabel=Dx;exports.useTextFormFieldDialog=eD;exports.useToolbarContext=AE;exports.useToolbarLabel=ne;exports.useToolbarLabelFor=Sl;exports.useTranslation=F;exports.useWatermark=Bu;exports.useWatermarkDialog=Jb;exports.useZoom=pm;
|