oasis-editor 0.0.231 → 0.0.232
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/OasisEditorApp-QuRS1JVm.js +1 -0
- package/dist/app/controllers/useEditorClipboard.d.ts +3 -0
- package/dist/defaultToolbar-BLpx6Q1W.js +1 -0
- package/dist/i18n/locales/en.d.ts +7 -0
- package/dist/i18n/locales/pt-BR.d.ts +7 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +1 -1
- package/dist/ui/app/clipboardPaste.d.ts +2 -0
- package/dist/ui/app/clipboardWrite.d.ts +2 -2
- package/dist/ui/app/createEditorChrome.d.ts +2 -0
- package/dist/ui/app/createEditorClipboardActions.d.ts +19 -0
- package/dist/ui/app/createEditorCommandRuntime.d.ts +2 -0
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +2 -0
- package/dist/ui/app/essentials/browser.d.ts +2 -6
- package/dist/ui/app/essentials/types.d.ts +2 -0
- package/dist/ui/app/useEditorContextMenuClipboard.d.ts +5 -3
- package/dist/ui/app/useEditorInteractionWiring.d.ts +2 -0
- package/dist/ui/components/ClipboardFeedback.d.ts +6 -0
- package/dist/ui/components/Toolbar/primitives/popoverBranch.d.ts +2 -0
- package/package.json +3 -2
- package/dist/OasisEditorApp-IDmEjhGJ.js +0 -1
- package/dist/defaultToolbar-D9PBASVE.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,$a as t,$n as n,$t as o,A as r,Aa as a,Ai as i,An as l,Ao as s,Ar as c,B as d,Ba as u,Bi as p,Bn as g,Bo as f,Br as m,Bt as h,C as b,Ca as y,Ci as v,Cn as x,Co as w,Cr as S,Ct as I,D as C,Da as T,Dn as P,Do as k,Dr as R,Dt as B,E as M,Ea as F,En as A,Er as O,Et as D,F as E,Fa as L,Fi as N,Fn as $,Fo as z,Fr as H,Ft as W,G as U,Ga as j,Gi as V,Gn as K,Go as _,Gr as X,Gt as G,H as Y,Ha as q,Hi as Z,Hn as J,Ho as Q,Hr as ee,Ht as te,I as ne,Ia as oe,Ii as re,In as ae,Io as ie,Ir as le,It as se,J as ce,Ja as de,Jn as ue,Jo as pe,Jr as ge,Jt as fe,K as me,Ka as he,Ki as be,Kn as ye,Kr as ve,Kt as xe,L as we,La as Se,Li as Ie,Ln as Ce,Lo as Te,Lr as Pe,Lt as ke,M as Re,Ma as Be,Mn as Me,Mo as Fe,Mr as Ae,N as Oe,Na as De,Ni as Ee,Nn as Le,No as Ne,Nr as $e,Nt as ze,O as He,Oa as We,Oi as Ue,On as je,Oo as Ve,Or as Ke,P as _e,Pa as Xe,Pi as Ge,Pn as Ye,Pr as qe,Pt as Ze,Q as Je,Qa as Qe,Qn as et,Qt as tt,R as nt,Ra as ot,Ri as rt,Rn as at,Ro as it,Rr as lt,Rt as st,S as ct,Sa as dt,Si as ut,Sn as pt,So as gt,Sr as ft,St as mt,T as ht,Ta as bt,Ti as yt,Tn as vt,To as xt,Tr as wt,Tt as St,U as It,Ua as Ct,Ui as Tt,Un as Pt,Uo as kt,Ur as Rt,Ut as Bt,V as Mt,Va as Ft,Vi as At,Vn as Ot,Vo as Dt,Vr as Et,Vt as Lt,W as Nt,Wa as $t,Wi as zt,Wn as Ht,Wo as Wt,Wr as Ut,Wt as jt,X as Vt,Xa as Kt,Xn as _t,Xr as Xt,Xt as Gt,Y as Yt,Ya as qt,Yn as Zt,Yo as Jt,Yr as Qt,Yt as en,Z as tn,Za as nn,Zn as on,Zo as rn,Zr as an,Zt as ln,_ as sn,_a as cn,_i as dn,_n as un,_o as pn,_r as gn,_t as fn,a as mn,aa as hn,an as bn,ao as yn,ar as vn,at as xn,b as wn,ba as Sn,bi as In,bn as Cn,bo as Tn,br as Pn,bt as kn,c as Rn,ca as Bn,cn as Mn,co as Fn,cr as An,ct as On,d as Dn,da as En,dn as Ln,do as Nn,dr as $n,dt as zn,en as Hn,eo as Wn,er as Un,et as jn,f as Vn,fa as Kn,fi as _n,fn as Xn,fo as Gn,fr as Yn,ft as qn,g as Zn,ga as Jn,gi as Qn,gn as eo,go as to,gr as no,gt as oo,h as ro,ha as ao,hi as io,hn as lo,ho as so,hr as co,ht as uo,i as po,ia as go,in as fo,io as mo,ir as ho,it as bo,j as yo,ja as vo,ji as xo,jn as wo,jr as So,k as Io,ka as Co,ki as To,kn as Po,ko,kr as Ro,l as Bo,la as Mo,ln as Fo,lo as Ao,lr as Oo,lt as Do,m as Eo,ma as Lo,mi as No,mn as $o,mo as zo,mr as Ho,mt as Wo,n as Uo,na as jo,nn as Vo,no as Ko,nr as _o,nt as Xo,o as Go,oa as Yo,on as qo,oo as Zo,or as Jo,ot as Qo,p as er,pa as tr,pi as nr,pn as or,po as rr,pr as ar,pt as ir,q as lr,qa as sr,qn as cr,qo as dr,qr as ur,qt as pr,r as gr,ra as fr,rn as mr,ro as hr,rr as br,s as yr,sa as vr,sn as xr,so as wr,sr as Sr,st as Ir,t as Cr,ta as Tr,ti as Pr,tn as kr,to as Rr,tr as Br,u as Mr,ua as Fr,un as Ar,uo as Or,ur as Dr,ut as Er,v as Lr,va as Nr,vi as $r,vn as zr,vo as Hr,vr as Wr,vt as Ur,w as jr,wa as Vr,wi as Kr,wn as _r,wo as Xr,wr as Gr,wt as Yr,x as qr,xa as Zr,xi as Jr,xn as Qr,xo as ea,xr as ta,xt as na,y as oa,ya as ra,yi as aa,yn as ia,yo as la,yr as sa,yt as ca,z as da,za as ua,zi as pa,zn as ga,zo as fa,zr as ma,zt as ha}from"./defaultToolbar-BLpx6Q1W.js";function ba(e,t){return{document:e.document,selection:t}}function ya(e,t){if(!vr(e.selection))return Oe(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=E(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return ba(e,nt(ua(i,Math.min(r,Se(i)))))}function va(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=E(e),i=Se(o);if(t<0&&a>0)return ba(e,{anchor:e.selection.anchor,focus:ua(o,a-1)});if(t>0&&a<i)return ba(e,{anchor:e.selection.anchor,focus:ua(o,a+1)});if(t<0&&r>0){const t=n[r-1];return ba(e,{anchor:e.selection.anchor,focus:ua(t,Se(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return ba(e,{anchor:e.selection.anchor,focus:ua(t,0)})}return e}function xa(e,t){const{paragraphs:n,index:o,offset:r}=E(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return ba(e,{anchor:e.selection.anchor,focus:ua(i,Math.min(r,Se(i)))})}function wa(e){const t=Bn(e);if(t.isCollapsed)return"";const n=ao(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return ot(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(ot(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(ot(n[i]));return o.push(ot(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Sa(e,t){return{...e,selection:{anchor:fr(e,t.anchor),focus:fr(e,t.focus)}}}function Ia(e){if(!vr(e.selection))return Oe(e,"start");const{paragraph:t,index:n,offset:o}=E(e),r=ao(e);if(o>0)return{document:e.document,selection:nt(ua(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:nt(ua(a,Se(a)))}}function Ca(e){if(!vr(e.selection))return Oe(e,"end");const{paragraph:t,index:n,offset:o}=E(e),r=ao(e);if(o<Se(t))return{document:e.document,selection:nt(ua(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:nt(ua(a,0))}}function Ta(e){const t=Bn(e);if(t.isCollapsed)return"";const n=ao(e),o=[];let r=null;const a=()=>{r&&(o.push("bullet"===r?"</ul>":"</ol>"),r=null)};for(let i=t.startIndex;i<=t.endIndex;i+=1){const l=n[i];if(!l)continue;const s=i===t.startIndex?t.startParagraphOffset:0,c=i===t.endIndex?t.endParagraphOffset:Se(l),d=U(l,s,c),u=Ge(l.style),p=u.length>0?` style="${u}"`:"",g=Ee(d,e.document);if(l.list?.kind){const e="bullet"===l.list.kind?"ul":"ol";r!==l.list.kind&&(a(),o.push(`<${e}>`),r=l.list.kind),o.push(`<li${p}>${g}</li>`);continue}a(),o.push(`<p${p}>${g}</p>`)}return a(),o.join("")}function Pa(e,t){if(0===t.length)return e;const n=vr(e.selection)?e:_e(e),{paragraph:r,index:a,offset:i}=E(n),l=ao(n),s=U(r,0,i),c=U(r,i,Se(r)),d=t.map(e=>{const t=Nn(e.runs.map(e=>({text:e.text,styles:kr(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let u,p=nt(ua(r,i));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=me(r,[...s,...e.runs.map(o),...c],Nt(r,i));n.style=r.style?{...r.style}:e.style?{...e.style}:void 0,n.list=r.list?{...r.list}:e.list?{...e.list}:void 0,u=[...tt(l.slice(0,a)),n,...tt(l.slice(a+1))],p=nt(ua(n,s.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=d[0],t=d[d.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),g=me(r,[...s,...e.runs.map(o)],Nt(r,i));g.style=r.style?{...r.style}:e.style?{...e.style}:void 0,g.list=r.list?{...r.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(Gt),m=me(t,[...t.runs.map(o),...c],void 0);m.list=t.list?{...t.list}:void 0,u=[...tt(l.slice(0,a)),g,...f,m,...tt(l.slice(a+1))],p=nt(ua(m,n))}return da(n,u,p)}function ka(e){return e.map(o)}function Ra(e){return e.reduce((e,t)=>e+t.text.length,0)}function Ba(e,t,n){if(0===n.length)return e;const o=ao(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=u(a,t),l=ka(n[0].runs);if(1===n.length){const t=Y(a,i,l),n=o.map((e,n)=>n===r?t:e),s=Ra(l),c=ua(t,i),d=ua(t,i+s);return da(e,n,{anchor:c,focus:d})}const s=U(a,0,i),c=U(a,i,Se(a)),d=n[n.length-1],p=n.slice(1,-1),g=me(Gt(n[0].paragraphTemplate),[...s,...l],Nt(a,i)),f=p.map(e=>me(Gt(e.paragraphTemplate),ka(e.runs))),m=me(Gt(d.paragraphTemplate),[...ka(d.runs),...c],Nt(a,i)),h=[...o.slice(0,r),g,...f,m,...o.slice(r+1)],b=ua(g,Ra(s)),y=ua(m,Ra(d.runs));return da(e,h,{anchor:b,focus:y})}function Ma(e,t,n={}){if(Bn(e).isCollapsed)return e;if(function(e,t){const n=Bn(e);if(n.isCollapsed)return!1;const o=ao(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return!1;if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r],i=u(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,t))return e;const o=function(e){const t=Bn(e);if(t.isCollapsed)return[];const n=ao(e),o=[];for(let r=t.startIndex;r<=t.endIndex;r+=1){const e=n[r],a=r===t.startIndex?t.startParagraphOffset:0,i=r===t.endIndex?t.endParagraphOffset:Se(e),l=U(e,a,i);o.push({paragraphTemplate:Gt(e),runs:l})}return o}(e);if(0===o.length)return e;if(n.copy)return Ba(e,t,o);const r=function(e,t){const n=Bn(e),o=ao(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=u(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return ua(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,t);return Ba(_e(e),r,o)}function Fa(e,t,n){if(0===t.length)return e;const o=vr(e.selection)?e:_e(e),{paragraph:r,index:a,offset:i}=E(o),l=n?{...n}:Nt(r,i),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:l,kind:"text"};o.trackChangesEnabled&&(s.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=Y(r,i,[s]),d=ao(o).map((e,t)=>t===a?c:e);return da(o,d,nt(ua(c,i+t.length)))}function Aa(e){return Fa(e,"\v")}function Oa(e,t,n){if(0===t.length)return e;const o=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");if(!o.includes("\n"))return Fa(e,o,n);const r=vr(e.selection)?e:_e(e),{paragraph:a,index:i,offset:l}=E(r),s=o.split("\n"),c=n?{...n}:Nt(a,l),d=U(a,0,l),u=me(a,[...d,rr(s[0],c)],c),p=U(a,l,Se(a)),g=s.slice(1,-1).map(e=>Yt([{text:e,styles:c}])),f=Yt([{text:s[s.length-1],styles:c},...p.map(e=>({text:e.text,styles:e.styles}))]),m=ao(r),h=[...m.slice(0,i),u,...g,f,...m.slice(i+1)];return da(r,h,nt(ua(f,s[s.length-1].length)))}function Da(e){if(!vr(e.selection))return _e(e);const{paragraph:t,index:n,offset:r}=E(e),a=ao(e);if(r>0){if(e.trackChangesEnabled){const o=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<o.length;e+=1){const t=i+o[e].text.length;if(r<=t){l=e,s=r-i;break}i=t}if(-1!==l){const i=o[l];if("insert"===i.revision?.type){const o=[...U(t,0,r-1),...U(t,r,Se(t))],i=me(t,o),l=a.map((e,t)=>t===n?i:e);return da(e,l,nt(ua(i,r-1)))}const c=i.text[s-1],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},u=[...U(t,0,r-1),d,...U(t,r,Se(t))],p=me(t,u),g=a.map((e,t)=>t===n?p:e);return da(e,g,nt(ua(p,r-1)))}}const o=me(t,[...U(t,0,r-1),...U(t,r,Se(t))],Nt(t,r-1)),i=a.map((e,t)=>t===n?o:e);return da(e,i,nt(ua(o,r-1)))}if(0===n)return e;const i=a[n-1],l=me(i,[...i.runs.map(o),...t.runs.map(o)]),s=[...a.slice(0,n-1),l,...a.slice(n+1)];return da(e,s,nt(ua(l,Se(i))))}function Ea(e){if(!vr(e.selection))return _e(e);const{paragraph:t,index:n,offset:r}=E(e),a=ao(e);if(r<Se(t)){if(e.trackChangesEnabled){const o=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<o.length;e+=1){const t=i+o[e].text.length;if(r<t){l=e,s=r-i;break}i=t}if(-1!==l){const i=o[l];if("insert"===i.revision?.type){const o=[...U(t,0,r),...U(t,r+1,Se(t))],i=me(t,o),l=a.map((e,t)=>t===n?i:e);return da(e,l,nt(ua(i,r)))}const c=i.text[s],d={id:`run:${Math.random().toString(36).slice(2,9)}`,text:c,kind:"text",styles:{...i.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},u=[...U(t,0,r),d,...U(t,r+1,Se(t))],p=me(t,u),g=a.map((e,t)=>t===n?p:e);return da(e,g,nt(ua(p,r)))}}const o=me(t,[...U(t,0,r),...U(t,r+1,Se(t))],Nt(t,r)),i=a.map((e,t)=>t===n?o:e);return da(e,i,nt(ua(o,r)))}if(n>=a.length-1)return e;const i=a[n+1],l=me(t,[...t.runs.map(o),...i.runs.map(o)]),s=[...a.slice(0,n),l,...a.slice(n+2)];return da(e,s,nt(ua(l,r)))}function La(e,t){const n=Bn(e);if(n.isCollapsed)return e;const o=ao(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((e,t)=>{const o=n.startIndex+t,r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:Se(e);return U(e,r,a)}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.[t])),i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:Se(e);return ne(e,r,i,e=>({...e,styles:Vo(e.styles,t,a)}))});return da(e,i,we(i,n))}function Na(e,t,n){const o=Bn(e);if(o.isCollapsed)return e;const r=ao(e).map((e,r)=>{if(r<o.startIndex||r>o.endIndex)return e;const a=r===o.startIndex?o.startParagraphOffset:0,i=r===o.endIndex?o.endParagraphOffset:Se(e);return ne(e,a,i,e=>({...e,styles:mr(e.styles,t,n)}))});return da(e,r,we(r,o))}function $a(e,t){const n=Bn(e);if(n.isCollapsed)return e;const o=ao(e),r=e.document.styles,a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=o===n.startIndex?n.startParagraphOffset:0,i=o===n.endIndex?n.endParagraphOffset:Se(e);return ne(e,a,i,n=>{const o=(Xe(n.styles,e.style?.styleId,r).fontSize??14.6667)*hr,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:mr(n.styles,"fontSize",a/hr)}})});return da(e,a,we(a,n))}var za={width:.5,type:"solid",color:"#000000"};function Ha(e,t){const n={...e??{}};return t?n.textBorder=za:delete n.textBorder,Object.keys(n).length>0?n:void 0}function Wa(e){return/\p{L}/u.test(e)}function Ua(e,t){switch(t){case"lower":return e.toLowerCase();case"upper":return e.toUpperCase();case"capitalize":return function(e){let t="",n=!1;for(const o of e){const e=Wa(o);t+=e&&!n?o.toUpperCase():o,n=e}return t}(e);case"toggle":return function(e){let t="";for(const n of e){const e=n.toUpperCase(),o=n.toLowerCase();t+=n===o&&n!==e?e:n===e&&n!==o?o:n}return t}(e);default:return function(e){let t="",n=!0;for(const o of e.toLowerCase())n&&Wa(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function ja(e,t){return function(e,t){const n=Bn(e);if(n.isCollapsed)return e;const o=ao(e).map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:Se(e),i=t(U(e,r,a).map(e=>e.text).join(""));let l=0;return ne(e,r,a,e=>{const t=e.text.length,n=i.slice(l,l+t);return l+=t,{...e,text:n}})});return da(e,o,we(o,n))}(e,e=>Ua(e,t))}var Va=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function Ka(e,t){const n=kr(e)??{};delete n.link;for(const o of Va)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function _a(e,t){if(0===t.length)return[];const n=Bn(e),o=ao(e)[n.startIndex];if(!o)return t;const r=Nt(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:Ka(r,e.styles)})),style:Hn(o.style),list:o.list?{...o.list}:void 0}))}function Xa(e){if("undefined"==typeof document||0===e.trim().length)return[];const t=document.createElement("template");t.innerHTML=e;const n=[],o=Array.from(t.content.childNodes),r=(e,t,o)=>{const r=t.length>0?t:[rr("")];n.push({runs:r.map(e=>{const t=nn(e);return{text:e.text,styles:kr(e.styles),image:t?{...t}:void 0}}),style:e?Tt(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,zt(n,void 0),{kind:t,level:0})};for(const i of o){if(i.nodeType===Node.TEXT_NODE){const e=i.textContent??"";e.trim().length>0&&r(null,[rr(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=be(e.tagName);if(t){a(e,t);continue}if(V(e.tagName)){r(e,zt(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=zt(e,void 0);n.length>0&&r(null,n)}return n}async function Ga(e,t){if(e.isReadOnly())return!1;if("undefined"==typeof navigator||!Boolean(navigator.clipboard?.read||navigator.clipboard?.readText))return e.onIssue?.("access-denied"),!1;const n=e.state(),o={anchor:{...n.selection.anchor},focus:{...n.selection.focus}};let r;try{r=await async function(e){const t=navigator.clipboard;let n=/* @__PURE__ */new Error("Clipboard access unavailable"),o=!1,r=!1;const a="text"===e&&Boolean(t?.readText);if(a)try{const e=await t.readText();return e?{kind:"content",text:e,html:""}:{kind:"empty"}}catch(i){n=i}if(t?.read)try{const n=await t.read();let a="",i="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(a=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(i=await(await t.getType("text/plain")).text());if(a||i)return{kind:"content",html:a,text:i};o=!0,r=n.length>0}catch(i){n=i}if(!a&&t?.readText)try{const e=await t.readText();if(e)return{kind:"content",text:e,html:""};o=!0}catch(i){n=i}if(o)return{kind:r?"unsupported":"empty"};throw n}(t)}catch(s){return e.onError?.(s),e.onIssue?.("access-denied"),!1}if(e.isReadOnly())return!1;if(e.state().document!==n.document)return e.onIssue?.("document-changed"),!1;if("content"!==r.kind)return e.onIssue?.(r.kind),!1;const a="text"!==t?Xa(r.html):[],i="merge"===t?_a({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return e.onIssue?.("unsupported"),!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let l=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},s=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Pa(e,i):Oa(e,r.text));return l=s.document!==t.document,s}),l&&e.focusInput(),l}function Ya(e){if("undefined"==typeof document||"function"!=typeof document.execCommand)return!1;const t=document.activeElement,n=document.createElement("textarea");n.value=e,n.readOnly=!0,n.setAttribute("aria-hidden","true"),n.style.cssText="position:fixed;opacity:0;left:-9999px;top:0",document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),document.execCommand("copy")}catch{return!1}finally{n.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}}function qa(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>Ya(e))}catch{}return Promise.resolve(Ya(e))}async function Za(e,t){const n=await function(e){const t=wa(e);if(!t)return Promise.resolve(!1);const n="undefined"!=typeof navigator?navigator.clipboard:void 0;if(n?.write&&"undefined"!=typeof ClipboardItem)try{const o=Ta(e),r=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})});return n.write([r]).then(()=>!0,()=>qa(t))}catch{}return qa(t)}(e);return!n&&wa(e)&&t?.("access-denied"),n}function Ja(e){return function(e){const[t,n]=Wt();let o,r=0;_()&&pe(()=>{r++});const a=()=>{n(void 0),o=void 0},i=()=>{r++,a()},l=async(t,i="rich")=>{const l=++r;a();const s=e.state(),c=a=>{l===r&&(n({action:t,issue:a,..."paste"===t?{mode:i}:{}}),"access-denied"!==a&&"unsupported"!==a||("paste"!==t||"unsupported"===a&&"rich"!==i||(o={document:s.document,mode:i}),e.focusInput()),e.onIssue?.(a))};if("copy"===t)return Za(s,c);const d={...e,onIssue:c,isReadOnly:()=>l!==r||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.state();if(!wa(t))return!1;if(!(await Za(t,e.onIssue))||e.isReadOnly())return!1;if(e.state().document!==t.document)return e.onIssue?.("document-changed"),!1;const n={anchor:{...t.selection.anchor},focus:{...t.selection.focus}};let o=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==t.document)return r;const a={...r,selection:n},i=e.applyTableAwareParagraphEdit(a,e=>Da(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):Ga(d,i)},s=()=>{const t=o;return i(),t?.document===e.state().document?t.mode:void 0};return{notice:t,dismiss:i,consumePasteMode:s,copy:()=>l("copy"),cut:()=>l("cut"),paste:(e="rich")=>l("paste",e),hasSelection:()=>wa(e.state()).length>0}}(e)}var Qa=/*#__PURE__*/ie("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),ei=/*#__PURE__*/ie("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function ti(e){const t=Xr();let n;const[o,r]=Wt(12);Dt(()=>{if(!e.notice())return;const t=n?.parentElement;if(!t)return;const o=()=>{const e=t.getBoundingClientRect(),o=t.querySelector(".oasis-editor-toolbar"),a=o?o.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),l=window.innerHeight-e.top-(n?.offsetHeight??0)-12;r(Math.max(i,Math.min(a,l)))};queueMicrotask(o);const a=new ResizeObserver(o);a.observe(t),n&&a.observe(n);const i=t.querySelector(".oasis-editor-toolbar");i&&a.observe(i),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),pe(()=>{a.disconnect(),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)})});return a=Qa(),"function"==typeof n?Te(n,a):n=a,ko(a,f(fa,{get when(){return e.notice()},children:n=>{return o=ei(),ko(o,f(Jr,{name:"clipboard"}),null),ko(o,f($r,{get children(){return(e=>{const n=`${/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+"}${"copy"===e.action?"C":"cut"===e.action?"X":"V"}`,o="access-denied"===e.issue?`clipboard.${e.action}Denied`:"empty"===e.issue?"clipboard.empty":"document-changed"===e.issue?"clipboard.documentChanged":e.mode&&"rich"!==e.mode?"clipboard.unsupportedOption":"clipboard.unsupported";return t(o,[n])})(n())}}),null),ko(o,f(B,{variant:"ghost",size:"sm",icon:"x",get label(){return t("generic.close")},get onClick(){return e.onDismiss},"data-testid":"editor-clipboard-feedback-close"}),null),o;var o}})),kt(e=>Ne(a,"top",`${o()}px`)),a;var a}var ni=!1,oi=null,ri=null,ai=null,ii=[];function li(){"undefined"!=typeof window&&(!function(){const e={BASE_URL:"./",DEV:!1,MODE:"lib",PROD:!0,SSR:!1},t=globalThis.process?.env??{};return!0===e.DEV||"test"===e.MODE||"test"===t.NODE_ENV||"1"===e.VITE_OASIS_CANVAS_DEBUG}()?ni&&(delete window.__oasisCanvasDebug,ni=!1):ni||(window.__oasisCanvasDebug={getLastHit:()=>oi?{...oi}:null,getLayoutSnapshot:()=>ri?{...ri,surfaceRect:{...ri.surfaceRect},pages:ri.pages.map(e=>({...e})),paragraphs:ri.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:ri.inlineImages.map(e=>({...e})),inlineTextBoxes:ri.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:ri.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>ai?{anchor:{...ai.anchor},focus:{...ai.focus},activeZone:ai.activeZone,activeSectionIndex:ai.activeSectionIndex}:null,getMissEvents:()=>ii.map(e=>({...e})),clearMissEvents:()=>{ii=[]}},ni=!0))}function si(e){ni&&e&&(oi={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var ci=["Aptos, sans-serif","Aptos Display, sans-serif","Arial","Arial Black","Bahnschrift, sans-serif","Book Antiqua, serif","Calibri, sans-serif","Calibri Light, sans-serif","Cambria, serif","Candara, sans-serif","Century Gothic, sans-serif","Comic Sans MS","Consolas, monospace","Constantia, serif","Corbel, sans-serif","Courier New","Franklin Gothic Medium, sans-serif","Garamond, serif","Georgia","Gill Sans, sans-serif","Helvetica, sans-serif","Impact","Inter","Lucida Console, monospace","Lucida Sans Unicode, sans-serif","Open Sans, sans-serif","Palatino Linotype, serif","Segoe UI, sans-serif","Tahoma, sans-serif","Times New Roman","Trebuchet MS, sans-serif","Verdana, sans-serif","Wingdings"];function di(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function ui(e){return function(e){const[t,n]=Wt([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))di(r,o,i.textStyle?.fontFamily);di(r,o,t.fontFamily);for(const i of n)di(a,o,i);for(const i of ci)di(a,o,i);return[...r.sort((e,t)=>e.localeCompare(t)),...a.sort((e,t)=>e.localeCompare(t))]}(e.state().document,e.toolbarStyleState(),t()),r=()=>function(e,t){const n=new Set(Uo);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(po(e))}const o=po(Number(t.fontSize));return Number.isFinite(o)&&o>0&&n.add(o),Array.from(n).sort((e,t)=>e-t)}(e.state().document,e.toolbarStyleState());return{computeFontFamilyOptions:o,computeFontSizeOptions:r,loadLocalFontFamilyOptions:async()=>{if(t().length>0)return;const e=await g();e.length>0&&n(e)}}}(e)}var pi="insertText",gi="composition",fi="insertImage",mi="insertTable",hi="moveImage",bi="splitListItem",yi="link",vi="imageAlt",xi="imageCaption",wi="imageResize",Si="imageCrop",Ii="imageFlip",Ci="imageRotate",Ti="imageTransparency",Pi="imageReset",ki="layoutWrapPolygon",Ri="specialIndent",Bi="paraBorders",Mi="paragraphMoveUp",Fi="paragraphMoveDown",Ai="findReplace",Oi="findReplaceAll",Di="tableProperties",Ei="paragraph-dialog",Li="font-dialog",Ni="copyTextByDrag",$i="moveTextByDrag",zi="collapseSelectionByClick",Hi="mergeTable",Wi="splitTable",Ui="insertTableColumn",ji="deleteTableColumn",Vi="insertTableRow",Ki="deleteTableRow",_i="tableShading",Xi="tableBorders",Gi="tableWidth",Yi="tableAlign",qi="tableCellVerticalAlign",Zi="tableCellTextDirection",Ji="tableCellWidth",Qi="tableColumnWidth",el="tableToText",tl="textToTable",nl="tableSplitAtRow",ol="tableSortAscending",rl="tableSortDescending",al="tableDelete",il="deleteTableCell",ll="tableAutoFit",sl="tableRepeatHeaderRows",cl="tableCellMargins",dl="tableFormula",ul="tableRowHeight",pl="tableStyleOptions",gl="tableStyleGallery",fl="tableDistribute",ml="layoutWrapPreset",hl="layoutFixedPosition",bl="shapeFill",yl="shapeOutline",vl="shapeOutlineWidth",xl="floatingAlign",wl="floatingReorder",Sl="floatingNudge",Il="floatingFixedPosition",Cl="floatingRotation",Tl="floatingWrap",Pl="floatingWrapText",kl="floatingPositionPreset",Rl="shapePreset",Bl="textBoxTextDirection",Ml="textBoxVerticalAlign",Fl="textBoxAlt",Al="textBoxRotate",Ol="textBoxWidthCm",Dl="textBoxHeightCm";function El(e,t){const n={...e},o=(e,t)=>{null==t?delete n[e]:n[e]=t};return o("align",t.align),o("indentLeft",t.indentLeft),o("indentRight",t.indentRight),o("indentFirstLine",t.indentFirstLine),o("indentHanging",t.indentHanging),n.mirrorIndents=t.mirrorIndents,o("spacingBefore",t.spacingBefore),o("spacingAfter",t.spacingAfter),o("lineHeight",t.lineHeight),o("lineRule",t.lineRule),n.contextualSpacing=t.contextualSpacing,o("outlineLevel",t.outlineLevel),o("shading",t.shading),o("borderTop",t.borders.top),o("borderRight",t.borders.right),o("borderBottom",t.borders.bottom),o("borderLeft",t.borders.left),n.pageBreakBefore=t.pageBreakBefore,n.keepWithNext=t.keepWithNext,n.keepLinesTogether=t.keepLinesTogether,n.widowControl=t.widowControl,o("tabs",t.tabs.length>0?t.tabs:null),n}function Ll(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function Nl(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function $l(e,t){const n=Co(e.document).map(e=>({...e,blocks:t(e.blocks),header:e.header?t(e.header):void 0,firstPageHeader:e.firstPageHeader?t(e.firstPageHeader):void 0,evenPageHeader:e.evenPageHeader?t(e.evenPageHeader):void 0,footer:e.footer?t(e.footer):void 0,firstPageFooter:e.firstPageFooter?t(e.firstPageFooter):void 0,evenPageFooter:e.evenPageFooter?t(e.evenPageFooter):void 0})),o=e.document.footnotes?{...e.document.footnotes,items:Object.fromEntries(Object.entries(e.document.footnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0,r=e.document.endnotes?{...e.document.endnotes,items:Object.fromEntries(Object.entries(e.document.endnotes.items).map(([e,n])=>[e,{...n,blocks:t(n.blocks)}]))}:void 0;return{...e,document:{...e.document,sections:n,footnotes:o,endnotes:r}}}function zl(e,t){return e.map(e=>{if("paragraph"===e.type)return e;const n=t(e);return{...n,rows:n.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:zl(e.blocks,t)}))}))}})}function Hl(e,t,n){const o=Co(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function Wl(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Ul(e){const t=Kn(e),n=y(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:Wl(n)}:null}function jl(e,t,n){const o=t[0];if(!o)return e;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return e;if(1===t.length){const t=n(r);if(t===r)return e;const a=[...e];return a[o.tableBlockIndex]=t,a}const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return e;const l=jl(i.blocks,t.slice(1),n);if(l===i.blocks)return e;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function Vl(e,t){return Boolean(e?.some(e=>We(e).some(e=>e.id===t)))}function Kl(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?Vl(e.firstPageHeader,n)?"firstPage":Vl(e.evenPageHeader,n)?"evenPage":"default":Vl(e.firstPageFooter,n)?"firstPage":Vl(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[cn(t,o)]??null}return null}function _l(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?Vl(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:Vl(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?Vl(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:Vl(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function Xl(e,t){const n=t[0];if(!n||!e)return null;const o=e[n.tableBlockIndex];if(!o||"table"!==o.type)return null;if(1===t.length)return o;const r=o.rows[n.rowIndex],a=r?.cells[n.cellIndex];return r&&a?Xl(a.blocks,t.slice(1)):null}function Gl(e,t,n){const o=t[0];if(!o)return null;const r=e[o.tableBlockIndex];if(!r||"table"!==r.type)return null;if(1===t.length)return[...e.slice(0,o.tableBlockIndex),...n,...e.slice(o.tableBlockIndex+1)];const a=r.rows[o.rowIndex],i=a?.cells[o.cellIndex];if(!a||!i)return null;const l=Gl(i.blocks,t.slice(1),n);if(!l)return null;const s=[...a.cells];s[o.cellIndex]={...i,blocks:l};const c=[...r.rows];c[o.rowIndex]={...a,cells:s};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function Yl(e){const t=Ul(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return Zl(e,r);const a=Co(e.document)[n];return a?Kl(a,o.zone,r):null}function ql(e){const t=e.selection.focus.paragraphId,n=tr(e);if("footnote"===n)return Zl(e,t);const o=Kn(e),r=Co(e.document)[o];return r?Kl(r,n,t):null}function Zl(e,t){const n=Zr(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function Jl(e,t){const n=Ul(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>Gl(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Zr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Co(e.document).map((e,t)=>t===o?_l(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function Ql(e,t){const n=Ul(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>jl(e,r.tablePath,t);if("footnote"===r.zone){const t=Zr(e.document,a)?.footnoteId??e.activeFootnoteId,n=e.document.footnotes,o=t?n?.items[t]:void 0;return t&&n&&o?{...e,document:{...e.document,footnotes:{...n,items:{...n.items,[t]:{...o,blocks:i(o.blocks)}}}}}:e}const l=Co(e.document).map((e,t)=>t===o?_l(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var es={width:.5,type:"solid",color:"#000000"},ts={width:0,type:"none",color:"transparent"};function ns(e){const t=Kn(e),n=y(e.document,e.selection.anchor.paragraphId,t),o=y(e.document,e.selection.focus.paragraphId,t);if(!n||!o||n.zone!==o.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(n.tablePath,o.tablePath))return null;const r=Hl(e.document,t,n.zone);if(!r)return null;const a=T(r,n.tablePath),i=T(r,o.tablePath),l=a?.[a.length-1],s=i?.[i.length-1];if(!l||!s||l.table!==s.table)return null;const c=n.tablePath[n.tablePath.length-1],d=o.tablePath[o.tablePath.length-1];if(!c||!d)return null;const u=Xt(l.table),p=u.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex),g=u.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex);if(!p||!g)return null;const f=Math.min(p.visualRowIndex,g.visualRowIndex),m=Math.max(p.visualRowIndex+p.rowSpan-1,g.visualRowIndex+g.rowSpan-1),h=Math.min(p.visualColumnIndex,g.visualColumnIndex),b=Math.max(p.visualColumnIndex+p.colSpan-1,g.visualColumnIndex+g.colSpan-1);return{entries:u,selectedEntries:u.filter(e=>e.visualRowIndex<=m&&e.visualRowIndex+e.rowSpan-1>=f&&e.visualColumnIndex<=b&&e.visualColumnIndex+e.colSpan-1>=h),startRow:f,endRow:m,startCol:h,endCol:b}}function os(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=ns(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of We(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=Bn(e),o=ao(e);for(let r=n.startIndex;r<=n.endIndex;r+=1)t.add(o[r].id);return t}(e))o.add(i);const r=o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...Ll(),type:"property",previous:{...r??{}}}}),{...o,style:Nl(r,t,n)}},a=Co(e.document).map(e=>({...e,blocks:Mt(e.blocks,o,r),header:e.header?Mt(e.header,o,r):void 0,footer:e.footer?Mt(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function rs(e,t){let n=os(e,"borderTop",t);return n=os(n,"borderRight",t),n=os(n,"borderBottom",t),n=os(n,"borderLeft",t),n}function as(e,t,n){const o=function(e){const t=Bn(e),n=ao(e),o=/* @__PURE__ */new Set;for(let r=t.startIndex;r<=t.endIndex;r+=1)o.add(n[r].id);return o}(e),r=a=>a.map(a=>{if("paragraph"===a.type)return a;const i=a.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:r(e.blocks)}))})),l={...a,rows:i};return function(e,t){return e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>"paragraph"===e.type&&t.has(e.id))))}(a,o)?(o=>{let r=o.style;return e.trackChangesEnabled&&"revision"!==t&&!r?.revision&&(r={...r??{},revision:{...Ll(),type:"property",previous:{...r??{}}}}),{...o,style:Nl(r,t,n)}})(l):l});return $l(e,r)}function is(e,t,n,o){const r=r=>{if(r.id!==t)return r;let a=r.style;return e.trackChangesEnabled&&"revision"!==n&&!a?.revision&&(a={...a??{},revision:{...Ll(),type:"property",previous:{...a??{}}}}),{...r,style:Nl(a,n,o)}};return $l(e,e=>zl(e,r))}function ls(e,t,n){const o=Ul(e);if(!o)return e;return Ql(e,r=>{const a=r.rows.map((r,a)=>a===o.loc.rowIndex?(()=>{let o=r.style;return e.trackChangesEnabled&&"revision"!==t&&"propertyRevision"!==t&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...Ll(),type:"property",previous:{...o??{}}}}),{...r,style:Nl(o,t,n)}})():r);return{...r,rows:a}})}function ss(e,t){const n=Ul(e);if(!n)return e;return Ql(e,o=>({...o,rows:o.rows.map((o,r)=>{if(r!==n.loc.rowIndex)return o;let a=o.style;e.trackChangesEnabled&&!a?.propertyRevision&&(a={...a??{},propertyRevision:{...Ll(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:Nl(a,"isHeader",i??null)}})}))}function cs(e,t,n){const o=o=>{if(o.id!==t)return o;const r=o.rows.map((t,o)=>{if(!Object.prototype.hasOwnProperty.call(n,o))return t;let r=t.style;return e.trackChangesEnabled&&!r?.propertyRevision&&(r={...r??{},propertyRevision:{...Ll(),type:"property",previous:{...r??{}}}}),{...t,style:Nl(r,"height",n[o])}});return{...o,rows:r}};return $l(e,e=>zl(e,o))}function ds(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"!=typeof e)return null;const t=e.trim().toLowerCase();if(!t||t.includes("%"))return null;if(t.endsWith("pt")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}if(t.endsWith("px")){const e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e*hr:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function us(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=Xt(a),l=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),s=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(s);let d=!1,u=!0;for(let e=0;e<s;e+=1){const t=ds(n[e]);if(null!==t){c[e]=Math.max(1,t),d=!0;continue}const o=a.gridCols?.[e];if(!("number"==typeof o&&Number.isFinite(o)&&o>0)){u=!1;break}c[e]=o}const p=a.rows.map((t,o)=>{const r=t.cells.map((t,r)=>{const a=l.get(`${o}:${r}`);if(!a)return t;const i=n[a.visualColumnIndex+a.colSpan-1];if(void 0!==i&&1===a.colSpan){const n=e.trackChangesEnabled&&!t.style?.propertyRevision?{...Ll(),type:"property",previous:{...t.style??{}}}:t.style?.propertyRevision;return{...t,style:{...t.style??{},width:i,...n?{propertyRevision:n}:{}}}}return t});return{...t,cells:r}}),g={...a.style??{}};return!e.trackChangesEnabled||g.revision||void 0===o&&void 0===r||(g.revision={...Ll(),type:"property",previous:{...a.style??{}}}),void 0!==o&&(g.width=o),void 0!==r&&(g.indentLeft="number"==typeof r?r:Number(r)),{...a,rows:p,gridCols:d&&u?c:a.gridCols,gridRevision:e.trackChangesEnabled&&d&&u&&!a.gridRevision?{...Ll(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return $l(e,e=>zl(e,a))}function ps(e){const t=Ul(e);if(!t)return e;const n=Yl(e);if(!n)return e;const o=Xl(n,t.loc.tablePath);if(!o)return e;const r=function(e){const t=[];for(const n of e.rows)for(const e of n.cells)for(const n of e.blocks)"paragraph"===n.type&&t.push(Gt(n));return t}(o);if(0===r.length)return e;const a=Jl(e,r);if(a===e)return e;const i=r[0];return{...a,selection:nt(ua(i,0))}}function gs(e){if(Ul(e))return e;if(!ql(e))return e;const t=ao(e);if(0===t.length)return e;const n=Bn(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(fs),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>to(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:Ao("paragraph"),type:"paragraph",runs:o.length>0?o:[Gn("")]};return so([r])})));return zo(o)}(o),a=o[0].id,i=o[o.length-1].id;let l=null,s=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=tr(e),r=Kn(e);if("footnote"===o){const o=Zr(e.document,n)?.footnoteId??e.activeFootnoteId,r=e.document.footnotes,a=o?r?.items[o]:void 0;return o&&r&&a?{...e,document:{...e.document,footnotes:{...r,items:{...r.items,[o]:{...a,blocks:t(a.blocks)}}}}}:e}const a=Co(e.document).map((e,a)=>a===r?_l(e,o,n,t):e);return{...e,document:{...e.document,sections:a}}}(e,e=>{const{nextBlocks:t,cell:n}=function(e,t,n,o){let r=-1,a=-1;for(let l=0;l<e.length;l+=1){const o=e[l];"paragraph"===o.type&&(o.id===t&&(r=l),o.id===n&&(a=l))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let l=r;l<=a;l+=1)if("paragraph"!==e[l].type)return{nextBlocks:null,cell:null};const i=o.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return{nextBlocks:[...e.slice(0,r),o,...e.slice(a+1)],cell:i??null}}(e,a,i,r);return t&&n?(l=n,s=!0,t):e});return s&&l?{...c,selection:nt(ua(l,0))}:e}function fs(e){const t=[];let n=[];const r=()=>{n.length>0&&t.push(n),n=[]};for(const a of e.runs){const e=a.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&r();const i=e[t];if(i.length>0){const e=o(a);e.id=`run:${Math.random().toString(36).slice(2,9)}`,e.text=i,n.push(e)}}}return n.length>0&&t.push(n),t}function ms(e,t){const n=Ul(e);if(!n)return e;const o=n.loc.cellIndex;return Ql(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const s of e.rows)s.isHeader?o.push(s):r.push(s);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=hs(e.cells[t]),r=hs(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),l=[...o,...i];return l.length===e.rows.length&&l.every((t,n)=>t===e.rows[n])?e.rows:l}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function hs(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:We(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function bs(e){return!0===e.isHeader}function ys(e){return null!==Ul(e)}function vs(e){return null!==Ul(e)}var xs=/* @__PURE__ */new Set(["left","center","right"]);function ws(e,t){const n=Ul(e);if(!n)return e;if(null!==t&&!xs.has(t))return e;const o=function(e,t){const n=Ul(e);if(!n)return null;const o=T(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,Hl(e.document,n.activeSectionIndex,n.loc.zone)??[]);if(!o)return e;const r=o.style?.align,a=null===t?void 0:t;return r===a?e:as(e,"align",a)}function Ss(e){return null!==Ul(e)}var Is=["SUM","AVERAGE","COUNT","MIN","MAX"];function Cs(e,t){const n=function(e){const t=/^\s*=\s*([A-Z]+)\s*\(\s*([A-Z]+)\s*\)\s*$/i.exec(e);if(!t)return null;const n=t[1].toUpperCase(),o=t[2].toUpperCase();return Is.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=Ul(e);if(!o)return e;const r=Yl(e);if(!r)return e;const a=Xl(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=Xt(e),r=o.find(e=>e.rowIndex===n.rowIndex&&e.cellIndex===n.cellIndex);if(!r)return[];const a=[];for(const i of o){if(i.rowIndex===n.rowIndex&&i.cellIndex===n.cellIndex)continue;if(!Ps(r,i,t))continue;if(!ks(r,i,t))continue;const e=Rs(Ts(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const l=function(e){if(Number.isInteger(e)||!Number.isFinite(e))return String(e);const t=Math.round(1e6*e)/1e6;return String(t)}(function(e,t){switch(e){case"SUM":return t.reduce((e,t)=>e+t,0);case"AVERAGE":return t.length>0?t.reduce((e,t)=>e+t,0)/t.length:0;case"COUNT":return t.length;case"MIN":return t.length>0?Math.min(...t):0;case"MAX":return t.length>0?Math.max(...t):0}}(n.function,i)),s=o.loc.rowIndex,c=o.loc.cellIndex,d=Ql(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Or(l)]})})}));if(d===e)return e;const u=Or(l);return{...d,selection:nt(ua(u,l.length))}}function Ts(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:We(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Ps(e,t,n){if("LEFT"===n||"RIGHT"===n){const n=e.visualRowIndex+e.rowSpan,o=t.visualRowIndex+t.rowSpan;return e.visualRowIndex<o&&t.visualRowIndex<n}const o=e.visualColumnIndex+e.colSpan,r=t.visualColumnIndex+t.colSpan;return e.visualColumnIndex<r&&t.visualColumnIndex<o}function ks(e,t,n){switch(n){case"ABOVE":return t.visualRowIndex+t.rowSpan<=e.visualRowIndex;case"BELOW":return t.visualRowIndex>=e.visualRowIndex+e.rowSpan;case"LEFT":return t.visualColumnIndex+t.colSpan<=e.visualColumnIndex;case"RIGHT":return t.visualColumnIndex>=e.visualColumnIndex+e.colSpan}}function Rs(e){const t=/\d+(?:[.,]\d+)?/.exec(e);if(!t)return null;const n=t[0].replace(",","."),o=Number(n);return Number.isFinite(o)?o:null}function Bs(e,t){const n=function(e){const t=Ul(e);if(!t)return null;const n=Yl(e);if(!n)return null;const o=Xl(n,t.loc.tablePath);if(!o)return null;const r=Xt(o),a=r.find(e=>e.rowIndex===t.loc.rowIndex&&e.cellIndex===t.loc.cellIndex);return a?{table:o,entries:r,active:a}:null}(e);if(!n)return e;const{table:o,entries:r,active:a}=n,i=function(e,t,n,o){switch(o){case"cell":return[n];case"row":{const e=n.visualRowIndex,o=n.visualRowIndex+n.rowSpan;return t.filter(t=>{const n=t.visualRowIndex,r=t.visualRowIndex+t.rowSpan;return n<o&&e<r})}case"column":{const e=n.visualColumnIndex,o=n.visualColumnIndex+n.colSpan;return t.filter(t=>{const n=t.visualColumnIndex,r=t.visualColumnIndex+t.colSpan;return n<o&&e<r})}case"table":return[...t]}}(0,r,a,t);if(0===i.length)return e;const l=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),s=l[0].cell,c=l[l.length-1].cell,d=Ms(s),u=Ms(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:ua(p,0),focus:ua(g,ot(g).length)}}:e}function Ms(e){return e.blocks.flatMap(We)}function Fs(e){const t=function(e){const t=Ul(e);if(!t)return null;const n=Yl(e);if(!n)return null;const o=Xl(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function As(e){const t=Ul(e);if(!t)return e;const n=Yl(e);if(!n)return e;const o=Xl(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex,a=t.loc.cellIndex,i=o.rows[r];if(!i||i.cells.length<=1||a>=i.cells.length)return e;const l=Ql(e,e=>{const t=e.rows.map((e,t)=>{if(t!==r)return e;const n=e.cells.filter((e,t)=>t!==a);return{...e,cells:n}});return{...e,rows:t}});if(l===e)return e;const s=i.cells[Math.min(a,i.cells.length-2)],c=s?s.blocks.flatMap(We)[0]??null:null;return c?{...l,selection:nt(ua(c,0))}:l}var Os={activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""};function Ds(e){const t=Kn(e),n=y(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=T(function(e,t){const n=Co(e.document)[Kn(e)];return n?"header"===t?n.header??[]:"footer"===t?n.footer??[]:n.blocks:[]}(e,n.zone),n.tablePath),a=r?.[r.length-1]?.table;if(!a)return null;const i=Xt(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:i?.visualColumnIndex??o.cellIndex}}function Es(e){if("number"==typeof e&&Number.isFinite(e))return{value:String(e),unit:"points"};if("string"==typeof e){const t=e.trim();if(t.endsWith("%"))return{value:t.slice(0,-1),unit:"percent"};const n=t.match(/^([0-9.]+)(pt)?$/i);if(n?.[1])return{value:n[1],unit:"points"}}return{value:"",unit:"points"}}function Ls(e){return!!e&&"none"!==e.type&&e.width>0}function Ns(e,t="table"){const n=Es(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=Es(o?.style?.height),i=Es(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=Es(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(Ls)[0],u=function(e){const t=e.style?.floating;return t&&0!==Object.keys(t).length?Object.entries(t).map(([e,t])=>`${e}=${t}`).join(", "):""}(e.table);return{...Os,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:Es(e.table.style?.indentLeft).value,tableWrapping:u?"around":"none",floatingSummary:u,floatingHorizontalAnchor:e.table.style?.floating?.horizontalAnchor??"margin",floatingVerticalAnchor:e.table.style?.floating?.verticalAnchor??"text",floatingX:null!=e.table.style?.floating?.x?String(e.table.style.floating.x):"0",floatingY:null!=e.table.style?.floating?.y?String(e.table.style.floating.y):"0",floatingXAlign:e.table.style?.floating?.xAlign??"",floatingYAlign:e.table.style?.floating?.yAlign??"",floatingDistanceTop:String(e.table.style?.floating?.distanceTop??0),floatingDistanceRight:String(e.table.style?.floating?.distanceRight??0),floatingDistanceBottom:String(e.table.style?.floating?.distanceBottom??0),floatingDistanceLeft:String(e.table.style?.floating?.distanceLeft??0),floatingOverlap:e.table.style?.tblOverlap??"overlap",rowHeight:a.value,rowHeightRule:o?.style?.heightRule??"",repeatHeader:Boolean(o?.isHeader),allowBreakAcrossPages:!0!==o?.style?.cantSplit,hiddenRow:!0===o?.style?.hidden,columnWidth:s.value,cellWidth:i.value,cellVerticalAlign:c.verticalAlign??"",cellTextDirection:c.textDirection??"",cellNoWrap:!0===c.noWrap,cellFitText:!0===c.fitText,cellHideMark:!0===c.hideMark,marginTop:null!=c.paddingTop?String(c.paddingTop):"",marginRight:null!=c.paddingRight?String(c.paddingRight):"",marginBottom:null!=c.paddingBottom?String(c.paddingBottom):"",marginLeft:null!=c.paddingLeft?String(c.paddingLeft):"",borderStyle:d?.type??"none",borderWidth:d?String(d.width):"",borderColor:d?.color??"",borderTop:Ls(c.borderTop),borderRight:Ls(c.borderRight),borderBottom:Ls(c.borderBottom),borderLeft:Ls(c.borderLeft),borderStart:Ls(c.borderStart),borderEnd:Ls(c.borderEnd),borderTopLeftToBottomRight:Ls(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:Ls(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function $s(e,t,n){return os(e,t,n)}function zs(e){return Boolean(Ds(e))}function Hs(e,t="table"){const n=Ds(e);return n?Ns(n,t):null}function Ws(e){const t=()=>zs(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=Hs(e.state(),t);n&&(e.setContextMenu({isOpen:!1,x:0,y:0}),e.setTablePropertiesDialog({isOpen:!0,initial:n}))},applyTablePropertiesDialogValues:n=>{e.isReadOnly()||t()&&(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>function(e,t){const n=Ds(e);if(!n)return e;let o=e;return o=is(o,n.tableId,"width",t.tableWidth),o=is(o,n.tableId,"align",t.tableAlign),o=is(o,n.tableId,"indentLeft",t.tableIndentLeft),o=is(o,n.tableId,"floating",t.tableFloating),o=is(o,n.tableId,"tblOverlap",t.tableOverlap),o=is(o,n.tableId,"altTitle",t.altTitle),o=is(o,n.tableId,"altDescription",t.altDescription),o=ss(o,t.repeatHeader),o=ls(o,"height",t.rowHeight),o=ls(o,"heightRule",t.rowHeightRule),o=ls(o,"cantSplit",t.cantSplit),o=ls(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=us(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=$s(o,"width",t.cellWidth),o=$s(o,"verticalAlign",t.cellVerticalAlign),o=$s(o,"textDirection",t.cellTextDirection),o=$s(o,"noWrap",t.cellNoWrap),o=$s(o,"fitText",t.cellFitText),o=$s(o,"hideMark",t.cellHideMark),o=$s(o,"paddingTop",t.margins.top),o=$s(o,"paddingRight",t.margins.right),o=$s(o,"paddingBottom",t.margins.bottom),o=$s(o,"paddingLeft",t.margins.left),o=$s(o,"borderTop",t.borders.top),o=$s(o,"borderRight",t.borders.right),o=$s(o,"borderBottom",t.borders.bottom),o=$s(o,"borderLeft",t.borders.left),o=$s(o,"borderStart",t.borders.start),o=$s(o,"borderEnd",t.borders.end),o=$s(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=$s(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=$s(o,"shading",t.shading),o}(e,n),{mergeKey:Di}),e.focusInput())}}}function Us(e){return function(e){const t=e.t,n=e.clipboardActions??Ja({...e,onIssue:t=>e.logger.warn("contextMenu:clipboard:not-completed",{issue:t})}),o=n.copy,r=n.cut,a=()=>n.paste("rich"),i=()=>{const n=!vr(e.state().selection),i=e.isReadOnly(),l=[{id:"cut",label:t("contextmenu.cut"),icon:"scissors",shortcut:"Ctrl+X",disabled:i||!n,testId:"editor-context-menu-cut",onSelect:()=>{r()}},{id:"copy",label:t("contextmenu.copy"),icon:"copy",shortcut:"Ctrl+C",disabled:!n,testId:"editor-context-menu-copy",onSelect:()=>{o()}},{id:"paste",label:t("contextmenu.paste"),icon:"clipboard",shortcut:"Ctrl+V",disabled:i,testId:"editor-context-menu-paste",onSelect:()=>{a()}},{id:"sep1",type:"separator"},{id:"link",label:t("contextmenu.link"),icon:"link",disabled:i||!n,testId:"editor-context-menu-link",onSelect:e.promptForLink},{id:"font",label:t("contextmenu.font"),icon:"type",disabled:i||!n,testId:"editor-context-menu-font",onSelect:e.openFontDialog},{id:"paragraph",label:t("contextmenu.paragraph"),icon:"pilcrow",disabled:i,testId:"editor-context-menu-paragraph",onSelect:e.openParagraphDialog}],s=e.table;return s?.isInsideTable()&&l.push({id:"sep-table",type:"separator"},{id:"table-properties",label:t("contextmenu.tableProperties"),icon:"table-properties",disabled:i,testId:"editor-context-menu-table-properties",onSelect:s.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:s.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:s.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:s.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:s.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!s.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:s.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!s.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:s.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!s.canMerge(),testId:"editor-context-menu-table-merge",onSelect:s.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!s.canSplit(),testId:"editor-context-menu-table-split",onSelect:s.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:s.openBordersAndShading}),l},l=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},s=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:i,closeContextMenu:s,handleEditorContextMenu:l,programmaticCopy:o,programmaticCut:r,programmaticPaste:a}}(e)}function js(e){const{state:t,tableOps:n,applyTableContextCommand:o}=e;return{isInsideTable:e.isInsideTable,canMerge:()=>n.canMergeSelectedTable(t()),canSplit:()=>n.canSplitSelectedTable(t()),canEditColumn:()=>n.canEditSelectedTableColumn(t()),canEditRow:()=>n.canEditSelectedTableRow(t()),openProperties:()=>e.openTablePropertiesDialog("table"),openBordersAndShading:()=>e.openTablePropertiesDialog("cell"),merge:()=>o(e=>n.mergeSelectedTable(e),Hi),split:()=>o(e=>n.splitSelectedTable(e),Wi),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),Ui),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),Ui),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),ji),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),Vi),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),Vi),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),Ki)}}function Vs(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=ui({state:e.state,toolbarStyleState:e.toolbarStyleState}),a=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:mn(t.fontSize),color:t.color??"",colorMode:t.color?"custom":"automatic",highlight:t.highlight??"",shading:t.textShading??"",bold:Boolean(t.bold),italic:Boolean(t.italic),underline:Boolean(t.underline),underlineStyle:t.underlineStyle?t.underlineStyle:null,underlineColor:t.underlineColor??"",strike:Boolean(t.strike),doubleStrike:Boolean(t.doubleStrike),superscript:Boolean(t.superscript),subscript:Boolean(t.subscript),smallCaps:Boolean(t.smallCaps),allCaps:Boolean(t.allCaps),hidden:Boolean(t.hidden),characterScale:t.characterScale??"",characterSpacing:t.characterSpacing??"",baselineShift:t.baselineShift??"",kerningThreshold:t.kerningThreshold??"",ligatures:t.ligatures??"",numberSpacing:t.numberSpacing??"",numberForm:t.numberForm??"",stylisticSet:t.stylisticSet??"",contextualAlternates:Boolean(t.contextualAlternates)})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyFontDialogValues:(t,n)=>{e.isReadOnly()||(vr(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=Na(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=Na(o,"fontSize",yr(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=Na(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=Na(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=Na(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=La(o,"bold")),t.italic!==Boolean(n.italic)&&(o=La(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=Na(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=Na(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=La(o,"underline")),t.strike!==Boolean(n.strike)&&(o=La(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=La(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=La(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=La(o,"subscript")),t.superscript&&t.subscript&&(o=La(o,"subscript")),t.strike&&t.doubleStrike&&(o=La(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=La(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=La(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=La(o,"hidden"));const l=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(l??null)&&(o=Na(o,"characterScale",t.characterScale));const s=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(s??null)&&(o=Na(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=Na(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=Na(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=Na(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=Na(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=Na(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=Na(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=La(o,"contextualAlternates")),o},{mergeKey:Li})),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,selection:e.selection,isReadOnly:e.isReadOnly,loadLocalFontFamilyOptions:o,setFontDialog:e.setFontDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),i=a.openFontDialog,l=function(e){return{openParagraphDialog:()=>{var t;e.setParagraphDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{align:t.align??"",indentLeft:t.indentLeft??"",indentRight:t.indentRight??"",indentFirstLine:t.indentFirstLine??"",indentHanging:t.indentHanging??"",mirrorIndents:t.mirrorIndents??!1,spacingBefore:t.spacingBefore??"",spacingAfter:t.spacingAfter??"",lineHeight:t.lineHeight??"",lineRule:t.lineRule??"",contextualSpacing:t.contextualSpacing??!1,outlineLevel:t.outlineLevel??"",shading:t.shading??"",borderStyle:t.borderStyle??"",borderWidth:t.borderWidth??"",borderColor:t.borderColor??"",borderSideTop:t.borderSideTop??!1,borderSideRight:t.borderSideRight??!1,borderSideBottom:t.borderSideBottom??!1,borderSideLeft:t.borderSideLeft??!1,pageBreakBefore:t.pageBreakBefore??!1,keepWithNext:t.keepWithNext??!1,keepLinesTogether:t.keepLinesTogether??!1,widowControl:t.widowControl??!0,tabs:t.tabs??[]})}),e.setContextMenu({isOpen:!1,x:0,y:0})},applyParagraphDialogValues:(t,n)=>{if(e.isReadOnly())return;e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e=>{if(""===e.trim())return null;const t=Number(e);return Number.isFinite(t)?t:null};e.applyTransactionalState(e=>{let a=e;t.align!==(n.align||null)&&(a=r(a,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(a=r(a,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(a=r(a,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(a=r(a,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(a=r(a,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(a=r(a,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(a=r(a,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(a=r(a,"lineHeight",t.lineHeight));const i=n.lineRule||null;t.lineRule!==i&&(a=r(a,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(a=r(a,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(a=r(a,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(a=r(a,"contextualSpacing",t.contextualSpacing));const l=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==l&&(a=r(a,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(a=r(a,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(a=r(a,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(a=r(a,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(a=r(a,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(a=r(a,"tabs",t.tabs.length>0?t.tabs:null));const s="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,c={borderTop:n.borderSideTop?s:null,borderRight:n.borderSideRight?s:null,borderBottom:n.borderSideBottom?s:null,borderLeft:n.borderSideLeft?s:null},d={borderTop:t.borders.top,borderRight:t.borders.right,borderBottom:t.borders.bottom,borderLeft:t.borders.left};for(const t of["borderTop","borderRight","borderBottom","borderLeft"])JSON.stringify(d[t])!==JSON.stringify(c[t])&&(a=r(a,t,d[t]));return a},{mergeKey:Ei}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=Be(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:El(r.paragraphStyle??{},t)}}}}}),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,isReadOnly:e.isReadOnly,setParagraphDialog:e.setParagraphDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),s=l.openParagraphDialog,c=Ws({state:e.state,isReadOnly:e.isReadOnly,setTablePropertiesDialog:e.setTablePropertiesDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),d=c.openTablePropertiesDialog,u=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},p=Us({clipboardActions:e.clipboardActions,state:e.state,isReadOnly:e.isReadOnly,t:e.t,logger:e.logger,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.applyTableAwareParagraphEdit,focusInput:e.focusInput,promptForLink:e.promptForLink,openFontDialog:i,openParagraphDialog:s,table:js({state:e.state,tableOps:e.tableOps,isInsideTable:c.isInsideTable,openTablePropertiesDialog:d,applyTableContextCommand:u})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:a.applyFontDialogValues,applyParagraphDialogValues:l.applyParagraphDialogValues,setParagraphDialogDefault:l.setParagraphDialogDefault,applyTablePropertiesDialogValues:c.applyTablePropertiesDialogValues,buildContextMenuItems:p.buildContextMenuItems,handleEditorContextMenu:p.handleEditorContextMenu,closeContextMenu:p.closeContextMenu}}(e)}function Ks(e){const t=Q(()=>{const t=e.targetPos(),n=e.surfaceRef;if(!n)return null;const o=e.snapshotProvider.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});let r=0,a=0,i=28;if(o){const n=ao(e.state).find(e=>e.id===t.paragraphId),r=n?u(n,t):0,a=_n(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=No(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const l=e.caretViewport?.()??null;if(l)return r=l.left,a=l.top,i=Math.max(12,Math.min(36,l.height)),{viewportLeft:r,viewportTop:a,height:i};const s=e.pointerPos?.()??null;return s?(r=s.x,a=s.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return f(fa,{get when(){return t()},children:e=>f(Ye,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var _s=/*#__PURE__*/ie("<div class=oasis-editor-table-resize-guide>"),Xs=/*#__PURE__*/ie("<div class=oasis-editor-table-resize-outline>"),Gs=/*#__PURE__*/ie("<img class=oasis-editor-image-ghost>"),Ys=/*#__PURE__*/ie("<div class=oasis-editor-table-ghost>");function qs(e){return[f(fa,{get when(){return e.tableResize.resizing()},children:e=>{return t=_s(),kt(n=>{var o=!("column"!==e().type),r=!("row"!==e().type),a={..."column"===e().type?{left:`${e().currentPos}px`,top:`${e().guideBounds.top}px`,width:"0px",height:`${e().guideBounds.height}px`}:{left:`${e().guideBounds.left}px`,top:`${e().currentPos}px`,width:`${e().guideBounds.width}px`,height:"0px"}};return o!==n.e&&t.classList.toggle("oasis-editor-table-resize-guide-column",n.e=o),r!==n.t&&t.classList.toggle("oasis-editor-table-resize-guide-row",n.t=r),n.a=z(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),f(fa,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=Xs(),kt(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&Ne(t,"left",n.e=o),r!==n.t&&Ne(t,"top",n.t=r),a!==n.a&&Ne(t,"width",n.a=a),i!==n.o&&Ne(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),f(fa,{get when(){return s(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=Gs(),kt(o=>{var r=t().src,a=`${t().width}px`,i=`${t().height}px`,l=e.imageOps.mousePos().x-t().offsetX+"px",s=e.imageOps.mousePos().y-t().offsetY+"px";return r!==o.e&&Fe(n,"src",o.e=r),a!==o.t&&Ne(n,"width",o.t=a),i!==o.a&&Ne(n,"height",o.a=i),l!==o.o&&Ne(n,"left",o.o=l),s!==o.i&&Ne(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),f(fa,{get when(){return s(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=Ys(),kt(o=>{var r=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",l=e.tableDrag.mousePos().y-t().offsetY+"px";return r!==o.e&&Ne(n,"width",o.e=r),a!==o.t&&Ne(n,"height",o.t=a),i!==o.a&&Ne(n,"left",o.a=i),l!==o.o&&Ne(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),f(fa,{get when(){return s(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>f(Ks,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),f(fa,{get when(){return s(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>f(Ks,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t})}),f(fa,{get when(){return s(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>f(Ks,{get surfaceRef(){return e.surfaceRef},get state(){return e.state},get documentLayout(){return e.documentLayout},get snapshotProvider(){return e.snapshotProvider},get zoomFactor(){return e.zoomFactor},targetPos:t,get pointerPos(){return e.textDrag.pointerPos},get caretViewport(){return e.textDrag.caretViewport}})})]}function Zs(e){return[f(Le,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),f(Le,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function Js(e){const t=Xr(),[n,o]=Wt(e.initialValue);let r;Dt(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return f(mt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return f(Zs,{get onCancel(){return e.onClose},onConfirm:a,get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return e.confirmLabel},get cancelTestId(){return e.testIds?.cancel},get confirmTestId(){return e.testIds?.confirm}})},get children(){return f(oo,{ref(e){"function"==typeof r?r(e):r=e},get label(){return e.label},get value(){return n()},onChange:o,onKeyDown:e=>"Enter"===e.key&&a(),get placeholder(){return e.placeholder},get"data-testid"(){return e.testIds?.input}})}})}function Qs(e){const t=Xr();return f(Js,{get isOpen(){return e.isOpen},get title(){return t("dialog.link.title")},get label(){return t("dialog.link.label")},get placeholder(){return t("dialog.link.placeholder")},get initialValue(){return e.initialHref},get confirmLabel(){return t("generic.apply")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm},testIds:{input:"editor-link-dialog-input",cancel:"editor-link-dialog-cancel",confirm:"editor-link-dialog-apply"}})}function ec(e){const t=Xr();return f(Js,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageAlt.title")},get label(){return t("dialog.imageAlt.label")},get placeholder(){return t("dialog.imageAlt.placeholder")},get initialValue(){return e.initialAlt},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}function tc(e){const t=Xr();return f(Js,{get isOpen(){return e.isOpen},get title(){return t("dialog.imageCaption.title")},get label(){return t("dialog.imageCaption.label")},get placeholder(){return t("dialog.imageCaption.placeholder")},get initialValue(){return e.initialCaption},get confirmLabel(){return t("generic.save")},get onClose(){return e.onClose},get onConfirm(){return e.onConfirm}})}var nc=/*#__PURE__*/ie("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),oc=/*#__PURE__*/ie("<div class=oasis-editor-comment-composer>");function rc(e){const t=Xr(),[n,o]=Wt(""),[r,a]=Wt("");let i;const l=e.composer.draft,c=()=>("edit"===l()?.mode||n().trim().length>0)&&r().trim().length>0,d=()=>{c()&&e.composer.submit(n(),r())};return Dt(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),f(mt,{get isOpen(){return null!==l()},get title(){return t("edit"===l()?.mode?"toolbar.editComment":"reply"===l()?.mode?"toolbar.replyComment":"toolbar.newComment")},get onClose(){return e.composer.close},get footer(){return[f(Le,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),f(Le,{variant:"primary",get disabled(){return!c()},onClick:d,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var c=oc();return ko(c,f(fa,{get when(){return"reply"===l()?.mode},get children(){var e=nc();return ko(e,f($r,{as:"strong",get children(){return[s(()=>t("comment.replyTo"))," ",s(()=>l()?.parentAuthor)]}}),null),ko(e,f($r,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),ko(c,f(oo,{get label(){return t("comment.author")},get value(){return n()},onChange:o,maxLength:150,required:!0,get disabled(){return"edit"===l()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),ko(c,f(uo,{ref(e){"function"==typeof i?i(e):i=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return r()},onChange:a,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),d())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),c}})}var ac=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],ic=[33,50,66,75,90,100,105,110,115,120,150,200];function lc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function sc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function cc(e){return null==e||""===e?"":String(e)}function dc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function uc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function pc(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function gc(e){switch(e){case"none":return"none";case"standard":return"common-ligatures";case"contextual":return"contextual";case"historical":return"historical-ligatures";case"standardContextual":return"common-ligatures contextual";default:return}}function fc(e,t){const n=[];return"proportional"===e&&n.push("proportional-nums"),"tabular"===e&&n.push("tabular-nums"),"lining"===t&&n.push("lining-nums"),"oldStyle"===t&&n.push("oldstyle-nums"),n.join(" ")||void 0}function mc(e,t){const n=[],o=pc(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function hc(e){return{familyFilter:"",fontFamily:e.fontFamily??"",fontSize:e.fontSize??"",colorMode:e.colorMode,color:e.color||"#111827",highlight:e.highlight||"",shading:e.shading||"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underline?e.underlineStyle??"single":"none",underlineColor:e.underlineColor||"#111827",strike:Boolean(e.strike),doubleStrike:Boolean(e.doubleStrike),superscript:Boolean(e.superscript),subscript:Boolean(e.subscript),smallCaps:Boolean(e.smallCaps),allCaps:Boolean(e.allCaps),hidden:Boolean(e.hidden)}}function bc(e){return{characterScale:cc(e.characterScale),spacingMode:dc(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:uc(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:cc(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:cc(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function yc(e){const t=Xr(),[n,o]=Wt("font"),[r,a]=Wt(hc(e.initial)),[i,l]=Wt(bc(e.initial));Dt(()=>{e.isOpen&&(o("font"),a(hc(e.initial)),l(bc(e.initial)))});const s=Q(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=Q(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=Q(()=>{const t=new Set(ac);for(const o of e.sizeOptions)t.add(o);const n=Number(r().fontSize);return Number.isFinite(n)&&n>0&&t.add(n),Array.from(t).sort((e,t)=>e-t)}),u=Q(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=Q(()=>{const e=i();return e.characterScale.trim()&&null===lc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===sc(e.spacingAmount)||"normal"!==e.positionMode&&null===sc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===sc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===pc(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=Q(()=>function(e,t){const n=Number(e.fontSize),o=lc(t.characterScale)??100,r="normal"===t.spacingMode?null:sc(t.spacingAmount),a="normal"===t.positionMode?null:sc(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,l=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,s=[];return e.underline&&"none"!==e.underlineStyle&&s.push("underline"),e.strike&&s.push("line-through"),e.doubleStrike&&s.push("line-through"),{"font-family":e.fontFamily||"inherit","font-size":Number.isFinite(n)&&n>0?`${n}pt`:void 0,"font-weight":e.bold?700:400,"font-style":e.italic?"italic":"normal","text-decoration":s.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":l??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":gc(t.ligatures),"font-variant-numeric":fc(t.numberSpacing,t.numberForm),"font-feature-settings":mc(t.stylisticSet,t.contextualAlternates)}}(r(),i()));return{activeTab:n,setActiveTab:e=>o(e),fontTabValues:r,setFontTabValues:a,advancedTabValues:i,setAdvancedTabValues:l,updateFontTab:(e,t)=>{a(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{l(n=>({...n,[e]:t}))},selectedFontStyle:s,visibleFamilyOptions:c,effectiveSizeOptions:d,customSizeError:u,advancedValidationError:p,previewStyle:g,applyFontStylePreset:e=>{a(t=>({...t,bold:"bold"===e||"boldItalic"===e,italic:"italic"===e||"boldItalic"===e}))},handleApply:()=>{if(p())return;const t=function(e,t){const n=Number(e.fontSize),o=Number.isFinite(n)&&n>0,r="none"===e.underlineStyle?null:e.underlineStyle,a=null!==r,i=t.characterScale.trim()?lc(t.characterScale):null,l="normal"===t.spacingMode?null:sc(t.spacingAmount),s="normal"===t.positionMode?null:sc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?sc(t.kerningThreshold):null,d=pc(t.stylisticSet);return{fontFamily:e.fontFamily.trim()?e.fontFamily.trim():null,fontSize:o?n:null,colorMode:e.colorMode,color:"automatic"===e.colorMode?null:e.color||null,highlight:e.highlight||null,shading:e.shading||null,bold:e.bold,italic:e.italic,underline:a,underlineStyle:r,underlineColor:a&&e.underlineColor||null,strike:e.strike,doubleStrike:e.doubleStrike,superscript:e.superscript,subscript:e.subscript,smallCaps:e.smallCaps,allCaps:e.allCaps,hidden:e.hidden,characterScale:i,characterSpacing:null===l?null:"condensed"===t.spacingMode?-l:l,baselineShift:null===s?null:"lowered"===t.positionMode?-s:s,kerningThreshold:c,ligatures:t.ligatures||null,numberSpacing:t.numberSpacing||null,numberForm:t.numberForm||null,stylisticSet:d,contextualAlternates:t.contextualAlternates}}(r(),i());e.onApply(t,e.initial),e.onClose()}}}var vc=/*#__PURE__*/ie("<div>");function xc(e){const t=Xr();return n=vc(),ko(n,()=>t("dialog.font.previewText")),kt(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&k(n,t.e=o),r!==t.t&&Fe(n,"data-testid",t.t=r),t.a=z(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var wc=/*#__PURE__*/ie('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Sc(e){const t=Xr(),{ctrl:n}=e;return o=wc(),ko(o,f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:12,get children(){return f(oo,{get label(){return t("dialog.font.familyFilter")},get value(){return n.fontTabValues().familyFilter},onChange:e=>n.updateFontTab("familyFilter",e),"data-testid":"editor-font-dialog-family-filter"})}}),f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("dialog.font.family")},get value(){return n.fontTabValues().fontFamily},onChange:e=>n.updateFontTab("fontFamily",e),"data-testid":"editor-font-dialog-family",get options(){return[{value:"",label:"—"},...n.visibleFamilyOptions().map(e=>({value:e,label:e}))]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(qn,{get label(){return t("dialog.font.size")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-size",get options(){return[{value:"",label:"—"},...n.effectiveSizeOptions().map(e=>({value:String(e),label:String(e)}))]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return[f(oo,{get label(){return t("dialog.font.customSize")},get value(){return n.fontTabValues().fontSize},onChange:e=>n.updateFontTab("fontSize",e),"data-testid":"editor-font-dialog-custom-size"}),f(kn,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("dialog.font.styleList")},get value(){return n.selectedFontStyle()},onChange:e=>n.applyFontStylePreset(e),"data-testid":"editor-font-dialog-style-list",get options(){return[{value:"regular",label:t("dialog.font.styleRegular")},{value:"italic",label:t("dialog.font.styleItalic")},{value:"bold",label:t("dialog.font.styleBold")},{value:"boldItalic",label:t("dialog.font.styleBoldItalic")}]}})}})]}}),null),ko(o,f(Ur,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[f(Ur,{size:{xs:12,md:4},get children(){return f(qn,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().colorMode},onChange:e=>n.updateFontTab("colorMode",e),"data-testid":"editor-font-dialog-color-mode",get options(){return[{value:"automatic",label:t("toolbar.colorAutomatic")},{value:"custom",label:t("dialog.font.customColor")}]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(Wo,{get label(){return t("dialog.font.color")},get value(){return n.fontTabValues().color},get disabled(){return"automatic"===n.fontTabValues().colorMode},onChange:e=>n.setFontTabValues(t=>({...t,color:e,colorMode:"custom"})),"data-testid":"editor-font-dialog-color"})}}),f(Ur,{size:{xs:12,md:2},get children(){return f(Wo,{get label(){return t("dialog.font.highlight")},get value(){return n.fontTabValues().highlight||"#fef08a"},onChange:e=>n.updateFontTab("highlight",e),"data-testid":"editor-font-dialog-highlight"})}}),f(Ur,{size:{xs:12,md:2},get children(){return f(Wo,{get label(){return t("dialog.font.shading")},get value(){return n.fontTabValues().shading||"#fef3c7"},onChange:e=>n.updateFontTab("shading",e),"data-testid":"editor-font-dialog-shading"})}})]}}),null),ko(o,f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("dialog.font.underlineStyle")},get value(){return n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineStyle:e,underline:"none"!==e})),"data-testid":"editor-font-dialog-underline-style",get options(){return[{value:"none",label:t("toolbar.underlineRemove")},...Je.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(Wo,{get label(){return t("dialog.font.underlineColor")},get value(){return n.fontTabValues().underlineColor||"#111827"},get disabled(){return"none"===n.fontTabValues().underlineStyle},onChange:e=>n.setFontTabValues(t=>({...t,underlineColor:e,underline:"none"!==t.underlineStyle})),"data-testid":"editor-font-dialog-underline-color"})}})]}}),null),ko(o,f(fn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return f(it,{get each(){return[{testId:"editor-font-dialog-bold",label:t("dialog.font.bold"),labelStyle:{"font-weight":700},checked:()=>n.fontTabValues().bold,onChange:e=>n.updateFontTab("bold",e)},{testId:"editor-font-dialog-italic",label:t("dialog.font.italic"),labelStyle:{"font-style":"italic"},checked:()=>n.fontTabValues().italic,onChange:e=>n.updateFontTab("italic",e)},{testId:"editor-font-dialog-underline",label:t("dialog.font.underline"),labelStyle:{"text-decoration":"underline"},checked:()=>n.fontTabValues().underline,onChange:e=>n.setFontTabValues(t=>({...t,underline:e,underlineStyle:e?"none"===t.underlineStyle?"single":t.underlineStyle:"none"}))},{testId:"editor-font-dialog-strike",label:t("dialog.font.strike"),labelStyle:{"text-decoration":"line-through"},checked:()=>n.fontTabValues().strike,onChange:e=>n.setFontTabValues(t=>({...t,strike:e,doubleStrike:!e&&t.doubleStrike}))},{testId:"editor-font-dialog-double-strike",label:t("dialog.font.doubleStrike"),checked:()=>n.fontTabValues().doubleStrike,onChange:e=>n.setFontTabValues(t=>({...t,doubleStrike:e,strike:!e&&t.strike}))},{testId:"editor-font-dialog-superscript",label:t("toolbar.superscript"),checked:()=>n.fontTabValues().superscript,onChange:e=>n.setFontTabValues(t=>({...t,superscript:e,subscript:!e&&t.subscript}))},{testId:"editor-font-dialog-subscript",label:t("toolbar.subscript"),checked:()=>n.fontTabValues().subscript,onChange:e=>n.setFontTabValues(t=>({...t,subscript:e,superscript:!e&&t.superscript}))},{testId:"editor-font-dialog-small-caps",label:t("dialog.font.smallCaps"),checked:()=>n.fontTabValues().smallCaps,onChange:e=>n.updateFontTab("smallCaps",e)},{testId:"editor-font-dialog-all-caps",label:t("dialog.font.allCaps"),checked:()=>n.fontTabValues().allCaps,onChange:e=>n.updateFontTab("allCaps",e)},{testId:"editor-font-dialog-hidden",label:t("dialog.font.hidden"),checked:()=>n.fontTabValues().hidden,onChange:e=>n.updateFontTab("hidden",e)}]},children:e=>f(Ir,{get label(){return e.label},get labelStyle(){return e.labelStyle},get checked(){return e.checked()},get onChange(){return e.onChange},get"data-testid"(){return e.testId}})})}})}}),null),ko(o,f(fn,{get label(){return t("dialog.font.preview")},get children(){return f(xc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var Ic=/*#__PURE__*/ie("<div class=oasis-editor-font-dialog-kerning-line>"),Cc=/*#__PURE__*/ie('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function Tc(e){const t=Xr(),{ctrl:n}=e;return o=Cc(),ko(o,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:4},get children(){return f(qn,{get label(){return t("dialog.font.advancedScale")},get value(){return n.advancedTabValues().characterScale||"100"},onChange:e=>n.updateAdvancedTab("characterScale",e),"data-testid":"editor-font-dialog-advanced-scale",get options(){return ic.map(e=>({value:String(e),label:`${e}%`}))}})}}),f(Ur,{size:{xs:12,md:8},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("dialog.font.advancedSpacing")},get value(){return n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingMode",e),"data-testid":"editor-font-dialog-advanced-spacing-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"expanded",label:t("dialog.font.advancedExpanded")},{value:"condensed",label:t("dialog.font.advancedCondensed")}]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(oo,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().spacingAmount},get disabled(){return"normal"===n.advancedTabValues().spacingMode},onChange:e=>n.updateAdvancedTab("spacingAmount",e),"data-testid":"editor-font-dialog-advanced-spacing-amount"})}})]}})}}),f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("dialog.font.advancedPosition")},get value(){return n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionMode",e),"data-testid":"editor-font-dialog-advanced-position-mode",get options(){return[{value:"normal",label:t("dialog.font.advancedNormal")},{value:"raised",label:t("dialog.font.advancedRaised")},{value:"lowered",label:t("dialog.font.advancedLowered")}]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(oo,{class:"oasis-editor-font-dialog-small-input",get label(){return t("dialog.font.advancedBy")},get value(){return n.advancedTabValues().positionAmount},get disabled(){return"normal"===n.advancedTabValues().positionMode},onChange:e=>n.updateAdvancedTab("positionAmount",e),"data-testid":"editor-font-dialog-advanced-position-amount"})}}),f(Ur,{size:12,get children(){var e=Ic();return ko(e,f(ir,{class:"oasis-editor-font-dialog-kerning-toggle",get label(){return t("dialog.font.advancedKerning")},get checked(){return n.advancedTabValues().kerningEnabled},onChange:e=>n.setAdvancedTabValues(t=>({...t,kerningEnabled:e,kerningThreshold:e?t.kerningThreshold||"1":t.kerningThreshold})),"data-testid":"editor-font-dialog-advanced-kerning-enabled"}),null),ko(e,f(oo,{class:"oasis-editor-font-dialog-kerning-input",get value(){return n.advancedTabValues().kerningThreshold},get disabled(){return!n.advancedTabValues().kerningEnabled},onChange:e=>n.updateAdvancedTab("kerningThreshold",e),"data-testid":"editor-font-dialog-advanced-kerning"}),null),ko(e,f(kn,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),ko(o,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("dialog.font.advancedLigatures")},get value(){return n.advancedTabValues().ligatures},onChange:e=>n.updateAdvancedTab("ligatures",e),"data-testid":"editor-font-dialog-advanced-ligatures",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"none",label:t("dialog.font.advancedLigaturesNone")},{value:"standard",label:t("dialog.font.advancedLigaturesStandard")},{value:"contextual",label:t("dialog.font.advancedLigaturesContextual")},{value:"historical",label:t("dialog.font.advancedLigaturesHistorical")},{value:"standardContextual",label:t("dialog.font.advancedLigaturesStandardContextual")}]}})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("dialog.font.advancedNumberSpacing")},get value(){return n.advancedTabValues().numberSpacing},onChange:e=>n.updateAdvancedTab("numberSpacing",e),"data-testid":"editor-font-dialog-advanced-number-spacing",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"proportional",label:t("dialog.font.advancedNumberSpacingProportional")},{value:"tabular",label:t("dialog.font.advancedNumberSpacingTabular")}]}})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("dialog.font.advancedNumberForm")},get value(){return n.advancedTabValues().numberForm},onChange:e=>n.updateAdvancedTab("numberForm",e),"data-testid":"editor-font-dialog-advanced-number-form",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},{value:"lining",label:t("dialog.font.advancedNumberFormLining")},{value:"oldStyle",label:t("dialog.font.advancedNumberFormOldStyle")}]}})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("dialog.font.advancedStylisticSet")},get value(){return n.advancedTabValues().stylisticSet},onChange:e=>n.updateAdvancedTab("stylisticSet",e),"data-testid":"editor-font-dialog-advanced-stylistic-set",get options(){return[{value:"",label:t("dialog.font.advancedDefault")},...Array.from({length:20},(e,t)=>t+1).map(e=>({value:String(e),label:String(e)}))]}})}})]}}),f(ir,{class:"oasis-editor-font-dialog-contextual-toggle",get label(){return t("dialog.font.advancedContextualAlternates")},get checked(){return n.advancedTabValues().contextualAlternates},onChange:e=>n.updateAdvancedTab("contextualAlternates",e),"data-testid":"editor-font-dialog-advanced-contextual-alternates"})]}}),null),ko(o,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return f(xc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),ko(o,f(kn,{as:"p",class:"oasis-editor-dialog-help-text","data-testid":"editor-font-dialog-advanced-placeholder",get children(){return n.advancedValidationError()||t("dialog.font.advancedPlaceholder")}}),null),o;var o}function Pc(e){const t=Xr(),n=yc(e);return f(mt,{get isOpen(){return e.isOpen},get title(){return t("dialog.font.title")},get onClose(){return e.onClose},class:"oasis-editor-font-dialog",bodyClass:"oasis-editor-font-dialog-body",size:"font",get footer(){return f(Zs,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-font-dialog-cancel",confirmTestId:"editor-font-dialog-apply"})},get children(){return f(na,{class:"oasis-editor-font-dialog-tabs",get ariaLabel(){return t("dialog.font.title")},get value(){return n.activeTab()},onChange:e=>n.setActiveTab(e),get items(){return[{id:"font",label:t("dialog.font.tabFont"),testId:"editor-font-dialog-tab-font",panel:f(Sc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:f(Tc,{ctrl:n})}]}})}})}var kc=/*#__PURE__*/ie("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),Rc=/*#__PURE__*/ie("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Bc(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function Mc(e){const t=Xr(),[n,o]=Wt([]);Dt(()=>{e.isOpen&&o(e.initial.map(Bc))});const r=(e,t)=>{o(n=>n.map((n,o)=>o===e?{...n,...t}:n))},a=()=>{o(e=>[...e,{position:null,type:"left",leader:"none"}])},i=()=>{const t=n().filter(e=>null!==e.position).map(e=>({position:e.position,type:e.type,..."none"!==e.leader?{leader:e.leader}:{}})).sort((e,t)=>e.position-t.position);e.onApply(t),e.onClose()};return f(mt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=Rc(),r=n.firstChild,a=r.nextSibling,ko(r,f(Le,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),ko(a,f(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),ko(a,f(Le,{variant:"primary",onClick:i,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){var e=kc(),i=e.firstChild;return ko(e,f(it,{get each(){return n()},get fallback(){return f(kn,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>f(Ur,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[f(Ur,{size:{xs:12,md:4},get children(){return f(zn,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),f(Ur,{size:{xs:6,md:3},get children(){return f(qn,{get label(){return t("paragraph.tabsAlignment")},get value(){return e.type},onChange:e=>r(n(),{type:e}),get options(){return[{value:"left",label:t("paragraph.tabAlignLeft")},{value:"center",label:t("paragraph.tabAlignCenter")},{value:"right",label:t("paragraph.tabAlignRight")},{value:"decimal",label:t("paragraph.tabAlignDecimal")},{value:"bar",label:t("paragraph.tabAlignBar")}]}})}}),f(Ur,{size:{xs:6,md:3},get children(){return f(qn,{get label(){return t("paragraph.tabsLeader")},get value(){return e.leader},onChange:e=>r(n(),{leader:e}),get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:t("paragraph.tabLeaderDot")},{value:"hyphen",label:t("paragraph.tabLeaderHyphen")},{value:"underscore",label:t("paragraph.tabLeaderUnderscore")}]}})}}),f(Ur,{size:{xs:12,md:2},get children(){return f(Le,{variant:"ghost",onClick:()=>(e=>{o(t=>t.filter((t,n)=>n!==e))})(n()),"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsRemove")}})}})]}})}),i),ko(i,f(Le,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var Fc=96/72;function Ac(e){const[t,n]=Wt(""),[o,r]=Wt(""),[a,i]=Wt(null),[l,s]=Wt(null),[c,d]=Wt("none"),[u,p]=Wt(null),[g,f]=Wt(!1),[m,h]=Wt(null),[b,y]=Wt(null),[v,x]=Wt("multiple"),[w,S]=Wt(null),[I,C]=Wt(!1),[T,P]=Wt(""),[k,R]=Wt("none"),[B,M]=Wt(null),[F,A]=Wt(""),[O,D]=Wt(!1),[E,L]=Wt(!1),[N,$]=Wt(!1),[z,H]=Wt(!1),[W,U]=Wt(!1),[j,V]=Wt(!1),[K,_]=Wt(!1),[X,G]=Wt(!0),[Y,q]=Wt([]);Dt(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(tn(e.initial.indentLeft??"")),s(tn(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(tn(e.initial.spacingBefore??"")),y(tn(e.initial.spacingAfter??"")),C(e.initial.contextualSpacing??!1),P(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=tn(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/Fc):null}:null===o?{mode:"multiple",at:null}:1===o?{mode:"single",at:null}:1.5===o?{mode:"onePointFive",at:null}:2===o?{mode:"double",at:null}:{mode:"multiple",at:o});x(a),S(l);const c=e.initial.borderStyle;R("solid"===c||"dashed"===c||"dotted"===c?c:"none"),M(tn(e.initial.borderWidth??"")),A(e.initial.borderColor??""),D(e.initial.borderSideTop??!1),L(e.initial.borderSideRight??!1),$(e.initial.borderSideBottom??!1),H(e.initial.borderSideLeft??!1),U(e.initial.pageBreakBefore??!1),V(e.initial.keepWithNext??!1),_(e.initial.keepLinesTogether??!1),G(e.initial.widowControl??!0),q(e.initial.tabs??[]);const u=tn(e.initial.indentFirstLine??""),g=tn(e.initial.indentHanging??"");null!==g&&g>0?(d("hanging"),p(g)):null!==u&&u>0?(d("firstLine"),p(u)):(d("none"),p(null))}var t,o});const Z=()=>{switch(v()){case"single":return{lineHeight:1,lineRule:null};case"onePointFive":return{lineHeight:1.5,lineRule:null};case"double":return{lineHeight:2,lineRule:null};case"multiple":return{lineHeight:w(),lineRule:null};case"atLeast":return{lineHeight:null!==w()?w()*Fc:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*Fc:null,lineRule:"exact"}}},J=Q(()=>{const e=a(),n=l(),o="firstLine"===c()?u():null,r="hanging"===c()?u():null,i=null!==o?o:null!==r?-r:null,s="none"!==k()?`${B()??.5}pt ${k()} ${F().trim()||"#000000"}`:void 0,{lineHeight:d,lineRule:p}=Z(),g=null===d?void 0:"exact"===p||"atLeast"===p?`${d}px`:String(d);return{"text-align":t()||void 0,"line-height":g,"padding-left":null!==e?`${e+(r??0)}pt`:void 0,"padding-right":null!==n?`${n}pt`:void 0,"text-indent":null!==i?`${i}pt`:void 0,"background-color":T().trim()||void 0,"border-top":s&&O()?s:void 0,"border-right":s&&E()?s:void 0,"border-bottom":s&&N()?s:void 0,"border-left":s&&z()?s:void 0}}),ee=()=>{const e=k();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=B(),n={type:e,width:null!==t&&t>0?t:.5,color:F().trim()||"#000000"};return{top:O()?n:null,right:E()?n:null,bottom:N()?n:null,left:z()?n:null}},te=()=>{const e=u(),{lineHeight:n,lineRule:r}=Z(),i=o();return{align:t()||null,indentLeft:a(),indentRight:l(),indentFirstLine:"firstLine"===c()?e:null,indentHanging:"hanging"===c()?e:null,mirrorIndents:g(),spacingBefore:m(),spacingAfter:b(),lineHeight:n,lineRule:r,contextualSpacing:I(),outlineLevel:""===i?null:Number(i),shading:T().trim()||null,borders:ee(),pageBreakBefore:W(),keepWithNext:j(),keepLinesTogether:K(),widowControl:X(),tabs:Y()}};return{align:t,setAlign:n,outlineLevel:o,setOutlineLevel:r,indentLeft:a,setIndentLeft:i,indentRight:l,setIndentRight:s,special:c,setSpecial:d,specialBy:u,setSpecialBy:p,mirrorIndents:g,setMirrorIndents:f,spacingBefore:m,setSpacingBefore:h,spacingAfter:b,setSpacingAfter:y,lineMode:v,setLineMode:x,lineAt:w,setLineAt:S,contextualSpacing:I,setContextualSpacing:C,shading:T,setShading:P,borderStyle:k,setBorderStyle:R,borderWidth:B,setBorderWidth:M,borderColor:F,setBorderColor:A,sideTop:O,setSideTop:D,sideRight:E,setSideRight:L,sideBottom:N,setSideBottom:$,sideLeft:z,setSideLeft:H,pageBreakBefore:W,setPageBreakBefore:U,keepWithNext:j,setKeepWithNext:V,keepLinesTogether:K,setKeepLinesTogether:_,widowControl:X,setWidowControl:G,tabs:Y,setTabs:q,atEnabled:()=>"multiple"===v()||"atLeast"===v()||"exact"===v(),previewStyle:J,handleApply:()=>{e.onApply(te(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(te()),e.onClose()}}}var Oc=/*#__PURE__*/ie("<div class=oasis-editor-paragraph-dialog-panel>"),Dc=/*#__PURE__*/ie("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),Ec=/*#__PURE__*/ie("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Lc(e){const t=Xr(),[n,o]=Wt(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:l,indentLeft:s,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:g,specialBy:m,setSpecialBy:h,mirrorIndents:b,setMirrorIndents:y,spacingBefore:v,setSpacingBefore:x,spacingAfter:w,setSpacingAfter:S,lineMode:I,setLineMode:C,lineAt:T,setLineAt:P,contextualSpacing:k,setContextualSpacing:R,shading:B,setShading:M,borderStyle:F,setBorderStyle:A,borderWidth:O,setBorderWidth:D,borderColor:E,setBorderColor:L,sideTop:N,setSideTop:$,sideRight:H,setSideRight:W,sideBottom:U,setSideBottom:j,sideLeft:V,setSideLeft:K,pageBreakBefore:_,setPageBreakBefore:X,keepWithNext:G,setKeepWithNext:Y,keepLinesTogether:q,setKeepLinesTogether:Z,widowControl:J,setWidowControl:Q,tabs:ee,setTabs:te,atEnabled:ne,previewStyle:oe,handleApply:re,handleSetDefault:ae}=Ac(e),ie=f(qn,{get label(){return t("paragraph.alignLabel")},get value(){return r()},onChange:a,"data-testid":"editor-paragraph-dialog-align",get options(){return[{value:"left",label:t("paragraph.alignLeft")},{value:"center",label:t("paragraph.alignCenter")},{value:"right",label:t("paragraph.alignRight")},{value:"justify",label:t("paragraph.alignJustify")}]}}),le=f(qn,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:l,"data-testid":"editor-paragraph-dialog-outline-level",get options(){return[{value:"",label:t("paragraph.outlineBodyText")},...Array.from({length:9},(e,n)=>({value:String(n),label:t("paragraph.outlineLevelN",[n+1])}))]}}),se=(ce=Oc(),ko(ce,f(On,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},children:ie}),f(Ur,{size:{xs:12,md:6},children:le})]}})}}),null),ko(ce,f(On,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},get children(){return f(zn,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(zn,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("paragraph.specialLabel")},get value(){return p()},onChange:e=>{const t=e;g(t),"none"===t&&h(null)},"data-testid":"editor-paragraph-dialog-special",get options(){return[{value:"none",label:t("paragraph.specialNone")},{value:"firstLine",label:t("paragraph.specialFirstLine")},{value:"hanging",label:t("paragraph.specialHanging")}]}})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(zn,{get label(){return t("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===p()},get value(){return m()??""},onChange:h,"data-testid":"editor-paragraph-dialog-special-by"})}}),f(Ur,{size:12,get children(){return f(ir,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return b()},onChange:y,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),ko(ce,f(On,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:4},get children(){return f(zn,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return v()??""},onChange:x,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(zn,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return w()??""},onChange:S,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),f(Ur,{size:{xs:12,md:4}}),f(Ur,{size:{xs:12,md:8},get children(){return f(qn,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return I()},onChange:e=>{C(e)},"data-testid":"editor-paragraph-dialog-line-mode",get options(){return[{value:"single",label:t("paragraph.lineSpacingSingle")},{value:"onePointFive",label:t("paragraph.lineSpacingOnePointFive")},{value:"double",label:t("paragraph.lineSpacingDouble")},{value:"atLeast",label:t("paragraph.lineSpacingAtLeast")},{value:"exact",label:t("paragraph.lineSpacingExact")},{value:"multiple",label:t("paragraph.lineSpacingMultiple")}]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(zn,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===I()?"0.05":"1"},get disabled(){return!ne()},get value(){return T()??""},onChange:P,"data-testid":"editor-paragraph-dialog-line-at"})}}),f(Ur,{size:12,get children(){return f(ir,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return k()},onChange:R,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),ko(ce,f(On,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:3},get children(){return f(qn,{get label(){return t("paragraph.borderStyleLabel")},get value(){return F()},onChange:e=>{const t=e;A(t),"none"===t?($(!1),W(!1),j(!1),K(!1)):N()||H()||U()||V()||($(!0),W(!0),j(!0),K(!0))},"data-testid":"editor-paragraph-dialog-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),f(Ur,{size:{xs:12,md:3},get children(){return f(zn,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===F()},get value(){return O()??""},onChange:D,"data-testid":"editor-paragraph-dialog-border-width"})}}),f(Ur,{size:{xs:12,md:3},get children(){return f(Wo,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===F()},get value(){return E()||"#000000"},onChange:L,"data-testid":"editor-paragraph-dialog-border-color"})}}),f(Ur,{size:{xs:12,md:3},get children(){return f(Wo,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:M,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),f(fn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[f(ir,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===F()},get checked(){return N()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),f(ir,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===F()},get checked(){return H()},onChange:W,"data-testid":"editor-paragraph-dialog-border-side-right"}),f(ir,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===F()},get checked(){return U()},onChange:j,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),f(ir,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===F()},get checked(){return V()},onChange:K,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),ce);var ce;const de=(ue=Oc(),ko(ue,f(On,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return f(ca,{direction:"column",spacing:1,get children(){return[f(ir,{get label(){return t("paragraph.widowControlLabel")},get checked(){return J()},onChange:Q,"data-testid":"editor-paragraph-dialog-widow-control"}),f(ir,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return G()},onChange:Y,"data-testid":"editor-paragraph-dialog-keep-with-next"}),f(ir,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return q()},onChange:Z,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),f(ir,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return _()},onChange:X,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ue);var ue;return[f(mt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",get footer(){return n=Ec(),r=n.firstChild,a=r.nextSibling,ko(r,f(Le,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),ko(r,f(Le,{variant:"secondary",onClick:ae,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),ko(a,f(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),ko(a,f(Le,{variant:"primary",onClick:re,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[f(na,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:se,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:de,testId:"editor-paragraph-dialog-tab-breaks"}]}}),f(fn,{get label(){return t("paragraph.preview")},get children(){var e=Dc();return ko(e,()=>t("paragraph.previewText")),kt(t=>z(e,oe(),t)),e}})]}}),f(Mc,{get isOpen(){return n()},get initial(){return ee()},onClose:()=>{o(!1)},onApply:te})]}function Nc(e,t){const n=tn(e);return null===n?null:"percent"===t?`${n}%`:n}function $c(e,t,n){if("none"===e)return null;const o=tn(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function zc(e){const[t,n]=Ue({activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"",floatingY:"",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"",floatingDistanceRight:"",floatingDistanceBottom:"",floatingDistanceLeft:"",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTlBr:!1,borderTrBl:!1,shading:"",altTitle:"",altDescription:""});Dt(()=>{var t;e.isOpen&&n(To({activeTab:(t=e.initial).activeTab??"table",tableWidth:t.tableWidth,tableWidthUnit:t.tableWidthUnit,tableAlign:t.tableAlign,tableIndentLeft:t.tableIndentLeft,tableWrapping:t.tableWrapping,floatingHorizontalAnchor:t.floatingHorizontalAnchor,floatingVerticalAnchor:t.floatingVerticalAnchor,floatingX:t.floatingX,floatingY:t.floatingY,floatingXAlign:t.floatingXAlign,floatingYAlign:t.floatingYAlign,floatingDistanceTop:t.floatingDistanceTop,floatingDistanceRight:t.floatingDistanceRight,floatingDistanceBottom:t.floatingDistanceBottom,floatingDistanceLeft:t.floatingDistanceLeft,floatingOverlap:t.floatingOverlap,rowHeight:t.rowHeight,rowHeightRule:t.rowHeightRule,repeatHeader:t.repeatHeader,allowBreakAcrossPages:t.allowBreakAcrossPages,hiddenRow:t.hiddenRow,columnWidth:t.columnWidth,cellWidth:t.cellWidth,cellVerticalAlign:t.cellVerticalAlign,cellTextDirection:t.cellTextDirection,cellNoWrap:t.cellNoWrap,cellFitText:t.cellFitText,cellHideMark:t.cellHideMark,marginTop:t.marginTop,marginRight:t.marginRight,marginBottom:t.marginBottom,marginLeft:t.marginLeft,borderStyle:t.borderStyle,borderWidth:t.borderWidth,borderColor:t.borderColor,borderTop:t.borderTop,borderRight:t.borderRight,borderBottom:t.borderBottom,borderLeft:t.borderLeft,borderStart:t.borderStart,borderEnd:t.borderEnd,borderTlBr:t.borderTopLeftToBottomRight,borderTrBl:t.borderTopRightToBottomLeft,shading:t.shading,altTitle:t.altTitle,altDescription:t.altDescription}))});return{form:t,set:n,handleApply:()=>{e.onApply(function(e){const t=$c(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:Nc(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:Nc(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:tn(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:tn(e.floatingY)??0},distanceTop:tn(e.floatingDistanceTop)??0,distanceRight:tn(e.floatingDistanceRight)??0,distanceBottom:tn(e.floatingDistanceBottom)??0,distanceLeft:tn(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:Nc(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:Nc(e.columnWidth,"points"),cellWidth:Nc(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:tn(e.marginTop),right:tn(e.marginRight),bottom:tn(e.marginBottom),left:tn(e.marginLeft)},borders:{top:e.borderTop?t:null,right:e.borderRight?t:null,bottom:e.borderBottom?t:null,left:e.borderLeft?t:null,start:e.borderStart?t:null,end:e.borderEnd?t:null,topLeftToBottomRight:e.borderTlBr?t:null,topRightToBottomLeft:e.borderTrBl?t:null},shading:e.shading.trim()||null,altTitle:e.altTitle.trim()||null,altDescription:e.altDescription.trim()||null}}(t),e.initial),e.onClose()}}}function Hc(e,t,n,o,r=!1,a=!1){return f(oo,{class:"oasis-editor-dialog-input-group-grow",type:"number",label:e,min:a?void 0:"0",step:"1",get value(){return t()},disabled:r,onChange:n,"data-testid":o})}var Wc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-panel>");function Uc(e){const t=Xr(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=Wc(),ko(r,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},get children(){return Hc(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("table.measureIn")},get value(){return n().tableWidthUnit},onChange:e=>o("tableWidthUnit",e),"data-testid":"editor-table-properties-table-width-unit",get options(){return[{value:"points",label:t("table.points")},{value:"percent",label:t("table.percent")}]}})}})]}})}}),null),ko(r,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[f(Er,{class:"oasis-editor-dialog-style-row",name:"table-align",get value(){return n().tableAlign},onChange:e=>o("tableAlign",e),get children(){return["left","center","right"].map(e=>f(Do,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),f(Ur,{container:!0,spacing:1.5,get children(){return f(Ur,{size:{xs:12,md:6},get children(){return Hc(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),ko(r,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[f(ir,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),f(ir,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),f(fa,{get when(){return"around"===n().tableWrapping},get children(){return[f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("table.horizontalAnchor")},get value(){return n().floatingHorizontalAnchor},onChange:e=>o("floatingHorizontalAnchor",e),"data-testid":"editor-table-properties-floating-h-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("table.verticalAnchor")},get value(){return n().floatingVerticalAnchor},onChange:e=>o("floatingVerticalAnchor",e),"data-testid":"editor-table-properties-floating-v-anchor",get options(){return[{value:"margin",label:t("table.anchorMargin")},{value:"page",label:t("table.anchorPage")},{value:"text",label:t("table.anchorText")}]}})}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),f(Ur,{size:{xs:12,md:3},get children(){return f(qn,{get label(){return t("table.horizontalAlignment")},get value(){return n().floatingXAlign},onChange:e=>o("floatingXAlign",e),"data-testid":"editor-table-properties-floating-x-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["left","center","right","inside","outside"].map(e=>({value:e,label:e}))]}})}}),f(Ur,{size:{xs:12,md:3},get children(){return f(qn,{get label(){return t("table.verticalAlignment")},get value(){return n().floatingYAlign},onChange:e=>o("floatingYAlign",e),"data-testid":"editor-table-properties-floating-y-align",get options(){return[{value:"",label:t("table.explicitOffset")},...["top","center","bottom","inside","outside"].map(e=>({value:e,label:e}))]}})}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),f(ir,{get label(){return t("table.allowOverlap")},get checked(){return"overlap"===n().floatingOverlap},onChange:e=>o("floatingOverlap",e?"overlap":"never"),"data-testid":"editor-table-properties-floating-overlap"})]}})]}}),null),r;var r}var jc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-panel>");function Vc(e){const t=Xr(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=jc(),ko(r,f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:6},get children(){return Hc(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),f(Ur,{size:{xs:12,md:6},get children(){return f(qn,{get label(){return t("table.rowHeightRule")},get value(){return n().rowHeightRule},onChange:e=>o("rowHeightRule",e),"data-testid":"editor-table-properties-row-height-rule",get options(){return[{value:"",label:t("table.rowAuto")},{value:"atLeast",label:t("table.rowAtLeast")},{value:"exact",label:t("table.rowExactly")}]}})}})]}}),null),ko(r,f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[f(ir,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),f(ir,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),f(ir,{get label(){return t("table.hiddenRow")},get checked(){return n().hiddenRow},onChange:e=>o("hiddenRow",e),"data-testid":"editor-table-properties-hidden-row"})]}}),null),r;var r}var Kc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-panel>");function _c(e){const t=Xr(),n=e.ctrl.set;return o=Kc(),ko(o,f(Ur,{container:!0,spacing:1.5,get children(){return f(Ur,{size:{xs:12,md:6},get children(){return Hc(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var Xc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),Gc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-panel>");function Yc(e){const t=Xr(),n=()=>e.ctrl.form,o=e.ctrl.set,r=Q(()=>{const e=$c(n().borderStyle,n().borderWidth,n().borderColor),t=e?`${e.width}pt ${e.type} ${e.color}`:void 0;return{"background-color":n().shading.trim()||void 0,"border-top":t&&n().borderTop?t:"1px solid #dadce0","border-right":t&&n().borderRight?t:"1px solid #dadce0","border-bottom":t&&n().borderBottom?t:"1px solid #dadce0","border-left":t&&n().borderLeft?t:"1px solid #dadce0"}}),a=()=>"none"===n().borderStyle;return i=Gc(),ko(i,f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:4},get children(){return Hc(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),f(Ur,{size:{xs:12,md:4},get children(){return f(qn,{get label(){return t("table.verticalAlignment")},get value(){return n().cellVerticalAlign},onChange:e=>o("cellVerticalAlign",e),"data-testid":"editor-table-properties-cell-valign",get options(){return[{value:"",label:t("table.inherit")},{value:"top",label:t("table.valignTop")},{value:"middle",label:t("table.valignMiddle")},{value:"bottom",label:t("table.valignBottom")}]}})}}),f(Ur,{size:{xs:12,md:4},get children(){return f(qn,{get label(){return t("table.textDirection")},get value(){return n().cellTextDirection},onChange:e=>o("cellTextDirection",e),"data-testid":"editor-table-properties-cell-direction",get options(){return[{value:"",label:t("table.inherit")},{value:"lrTb",label:"lrTb"},{value:"tbRl",label:"tbRl"},{value:"btLr",label:"btLr"},{value:"lrTbV",label:"lrTbV"},{value:"tbRlV",label:"tbRlV"}]}})}})]}}),null),ko(i,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[f(ir,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),f(ir,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),f(ir,{get label(){return t("table.hideMark")},get checked(){return n().cellHideMark},onChange:e=>o("cellHideMark",e),"data-testid":"editor-table-properties-cell-hide-mark"})]}})}}),null),ko(i,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),ko(i,f(On,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[f(Ur,{container:!0,spacing:1.5,get children(){return[f(Ur,{size:{xs:12,md:3},get children(){return f(qn,{get label(){return t("paragraph.borderStyleLabel")},get value(){return n().borderStyle},onChange:e=>{const t=e;o("borderStyle",t),"none"===t?(o("borderTop",!1),o("borderRight",!1),o("borderBottom",!1),o("borderLeft",!1),o("borderStart",!1),o("borderEnd",!1),o("borderTlBr",!1),o("borderTrBl",!1)):n().borderTop||n().borderRight||n().borderBottom||n().borderLeft||(o("borderTop",!0),o("borderRight",!0),o("borderBottom",!0),o("borderLeft",!0))},"data-testid":"editor-table-properties-border-style",get options(){return[{value:"none",label:t("paragraph.borderNone")},{value:"solid",label:t("paragraph.borderSolid")},{value:"dashed",label:t("paragraph.borderDashed")},{value:"dotted",label:t("paragraph.borderDotted")}]}})}}),f(Ur,{size:{xs:12,md:3},get children(){return Hc(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),f(Ur,{size:{xs:12,md:3},get children(){return f(Wo,{get label(){return t("paragraph.borderColorLabel")},get value(){return n().borderColor||"#000000"},get disabled(){return a()},onChange:e=>o("borderColor",e),"data-testid":"editor-table-properties-border-color"})}}),f(Ur,{size:{xs:12,md:3},get children(){return f(Wo,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),f(ca,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[f(ir,{get label(){return t("paragraph.borderSideTop")},get checked(){return n().borderTop},get disabled(){return a()},onChange:e=>o("borderTop",e),"data-testid":"editor-table-properties-border-top"}),f(ir,{get label(){return t("paragraph.borderSideRight")},get checked(){return n().borderRight},get disabled(){return a()},onChange:e=>o("borderRight",e),"data-testid":"editor-table-properties-border-right"}),f(ir,{get label(){return t("paragraph.borderSideBottom")},get checked(){return n().borderBottom},get disabled(){return a()},onChange:e=>o("borderBottom",e),"data-testid":"editor-table-properties-border-bottom"}),f(ir,{get label(){return t("paragraph.borderSideLeft")},get checked(){return n().borderLeft},get disabled(){return a()},onChange:e=>o("borderLeft",e),"data-testid":"editor-table-properties-border-left"}),f(ir,{get label(){return t("table.borderStart")},get checked(){return n().borderStart},get disabled(){return a()},onChange:e=>o("borderStart",e),"data-testid":"editor-table-properties-border-start"}),f(ir,{get label(){return t("table.borderEnd")},get checked(){return n().borderEnd},get disabled(){return a()},onChange:e=>o("borderEnd",e),"data-testid":"editor-table-properties-border-end"}),f(ir,{get label(){return t("table.borderTlBr")},get checked(){return n().borderTlBr},get disabled(){return a()},onChange:e=>o("borderTlBr",e),"data-testid":"editor-table-properties-border-tlbr"}),f(ir,{get label(){return t("table.borderTrBl")},get checked(){return n().borderTrBl},get disabled(){return a()},onChange:e=>o("borderTrBl",e),"data-testid":"editor-table-properties-border-trbl"})]}}),(e=Xc(),kt(t=>z(e,r(),t)),e)];var e}}),null),i;var i}var qc=/*#__PURE__*/ie("<div class=oasis-editor-table-properties-panel>");function Zc(e){const t=Xr(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=qc(),ko(r,f(oo,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),ko(r,f(uo,{class:"oasis-editor-dialog-input-group",get label(){return t("table.altDescription")},controlClass:"oasis-editor-table-properties-textarea",get value(){return n().altDescription},onChange:e=>o("altDescription",e),"data-testid":"editor-table-properties-alt-description"}),null),r;var r}function Jc(e){const t=Xr(),n=zc(e);return f(mt,{get isOpen(){return e.isOpen},get title(){return t("table.propertiesTitle")},get onClose(){return e.onClose},size:"lg",class:"oasis-editor-table-properties-dialog",bodyClass:"oasis-editor-table-properties-body",get footer(){return f(Zs,{get onCancel(){return e.onClose},get onConfirm(){return n.handleApply},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("generic.ok")},cancelTestId:"editor-table-properties-cancel",confirmTestId:"editor-table-properties-apply"})},get children(){return f(na,{get value(){return n.form.activeTab},onChange:e=>n.set("activeTab",e),get ariaLabel(){return t("table.propertiesTitle")},class:"oasis-editor-table-properties-tabs",get items(){return[{id:"table",label:t("table.tabTable"),testId:"editor-table-properties-tab-table",panel:f(Uc,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:f(Vc,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:f(_c,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:f(Yc,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:f(Zc,{ctrl:n})}]}})}})}var Qc=/*#__PURE__*/ie("<p data-testid=editor-new-document-message>");function ed(e){const t=Xr();return f(mt,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return f(Zs,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t("dialog.newDocument.discard")},cancelTestId:"editor-new-document-cancel",confirmTestId:"editor-new-document-discard"})},get children(){var e=Qc();return ko(e,()=>t("dialog.newDocument.message")),e}})}var td=/*#__PURE__*/ie("<div class=oasis-editor-symbol-dialog-controls><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-font></select></label><label class=oasis-editor-symbol-dialog-field><span></span><select data-testid=editor-symbol-dialog-category><option value=all>"),nd=/*#__PURE__*/ie("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),od=/*#__PURE__*/ie("<div class=oasis-editor-symbol-dialog-layout><div class=oasis-editor-symbol-dialog-grid role=grid></div><aside class=oasis-editor-symbol-dialog-preview><span class=oasis-editor-symbol-dialog-preview-label></span><span class=oasis-editor-symbol-dialog-preview-character data-testid=editor-symbol-dialog-preview></span><label class=oasis-editor-symbol-dialog-field><span></span><input data-testid=editor-symbol-dialog-code></label><p class=oasis-editor-symbol-dialog-help>"),rd=/*#__PURE__*/ie("<option>"),ad=/*#__PURE__*/ie("<button type=button class=oasis-editor-symbol-dialog-tile>"),id=/*#__PURE__*/ie("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),ld=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function sd(e){const t=Xr(),[n,o]=Wt("common"),[r,a]=Wt(er[0]),[i,l]=Wt(ld[0]),[s,c]=Wt(er[0].codePoint),d=Q(()=>(e.isOpen,Dn())),u=Q(()=>"all"===n()?Eo.flatMap(e=>e.entries):Eo.find(e=>e.id===n())?.entries??er),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&(Vn(t),e.onInsert(t,i()),e.onClose())};return f(mt,{get isOpen(){return e.isOpen},get title(){return t("dialog.symbol.title")},get onClose(){return e.onClose},class:"oasis-editor-symbol-dialog",bodyClass:"oasis-editor-symbol-dialog-body",size:"lg",closeOnOverlayClick:!1,get footer(){return[f(Le,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),f(Le,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(S=td(),I=S.firstChild,C=I.firstChild,T=C.nextSibling,P=I.nextSibling.firstChild,k=P.nextSibling,R=k.firstChild,ko(C,()=>t("dialog.symbol.font")),T.addEventListener("change",e=>{l(e.currentTarget.value)}),ko(T,f(it,{each:ld,children:e=>{return(t=rd()).value=e,ko(t,e),t;var t}})),ko(P,()=>t("dialog.symbol.subset")),k.addEventListener("change",e=>{o(e.currentTarget.value)}),ko(R,()=>t("symbols.category.all")),ko(k,f(it,{each:Eo,children:e=>{return n=rd(),ko(n,()=>t(e.labelKey)),kt(()=>n.value=e.id),n;var n}}),null),kt(()=>T.value=i()),kt(()=>k.value=n()),S),(e=od(),m=e.firstChild,h=m.nextSibling.firstChild,b=h.nextSibling,y=b.nextSibling,v=y.firstChild,x=v.nextSibling,w=y.nextSibling,ko(m,f(fa,{get when(){return d().length>0},get children(){var e=nd(),n=e.firstChild,o=n.nextSibling;return ko(n,()=>t("dialog.symbol.recent")),ko(o,f(it,{get each(){return d()},children:e=>{return(t=ad()).$$click=()=>p(e),ko(t,()=>e.character),kt(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&Fe(t,"title",n.e=o),r!==n.t&&Fe(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),ko(m,f(it,{get each(){return u()},children:e=>{return(t=id()).$$dblclick=g,t.$$click=()=>p(e),ko(t,()=>e.character),kt(n=>{var o=!(r().character!==e.character),a=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,l=`editor-symbol-dialog-${e.codePoint.replace(/[^A-Z0-9]/g,"-")}`;return o!==n.e&&t.classList.toggle("oasis-editor-symbol-dialog-tile-active",n.e=o),a!==n.t&&Fe(t,"title",n.t=a),i!==n.a&&Fe(t,"aria-label",n.a=i),l!==n.o&&Fe(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),ko(h,()=>t("dialog.symbol.preview")),ko(b,()=>r().character),ko(v,()=>t("dialog.symbol.code")),x.$$input=e=>(e=>{c(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||a({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),Fe(x,"spellcheck",!1),ko(w,()=>t("dialog.symbol.doubleClickHelp")),kt(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&Fe(m,"aria-label",e.e=n),o!==e.t&&Ne(b,"font-family",e.t=o),e},{e:void 0,t:void 0}),kt(()=>x.value=s()),e)];var e,m,h,b,y,v,x,w,S,I,C,T,P,k,R}})}Ve(["input","click","dblclick"]);var cd=/*#__PURE__*/ie("<div class=oasis-editor-equation-editor><div class=oasis-editor-equation-palette></div><label class=oasis-editor-equation-linear><span></span><textarea data-testid=editor-equation-linear></textarea></label><div class=oasis-editor-equation-preview aria-live=polite data-testid=editor-equation-preview>"),dd=/*#__PURE__*/ie("<button type=button data-testid=editor-equation-template>"),ud=[["\\frac{□}{□}","\\frac{a}{b}"],["\\sqrt{□}","\\sqrt{x}"],["x^□","x^{2}"],["x_□","x_{i}"],["∑","\\sum_{i=1}^{n} i"],["∫","∫ f(x) dx"],["[ ]","(a+b)"],["[a b]","\\matrix{a & b \\ c & d}"]];function pd(e){const t=Xr(),[n,o]=Wt(""),[r,a]=Wt(Wn);Dt(()=>{if(!e.isOpen)return;const t=e.initial??Wn;a(t),o(R(t))});const i=e=>{o(e),a(O(e))};return f(mt,{get isOpen(){return e.isOpen},get title(){return t("dialog.equation.title")},get onClose(){return e.onClose},size:"lg",closeOnOverlayClick:!1,class:"oasis-editor-equation-dialog",get footer(){return[f(Le,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),f(Le,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=cd(),o=e.firstChild,a=o.nextSibling,l=a.firstChild,s=l.nextSibling,c=a.nextSibling;return ko(o,f(it,{each:ud,children:([e,t])=>{return(n=dd()).$$click=()=>i(t),ko(n,e),n;var n}})),ko(l,()=>t("dialog.equation.linear")),s.$$input=e=>i(e.currentTarget.value),Fe(s,"spellcheck",!1),ko(c,()=>R(r())||t("dialog.equation.empty")),kt(()=>Fe(o,"aria-label",t("dialog.equation.structures"))),kt(()=>s.value=n()),e}})}Ve(["input","click"]);var gd=/*#__PURE__*/ie("<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper></div></div><div class=oasis-editor-fr-input-group>");function fd(e){const t=Xr(),{fr:n}=e,o=e=>{"Enter"===e.key?(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext()):"Escape"===e.key&&n.setIsOpen(!1)};return f(fa,{get when(){return n.isOpen()},get children(){var e=gd(),r=e.firstChild,a=r.nextSibling,i=a.firstChild,l=i.firstChild,c=i.nextSibling;return e.$$keydown=o,ko(r,f($r,{get children(){return t("find.title")}}),null),ko(r,f(aa,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),ko(l,f(oo,{type:"text",get placeholder(){return t("find.placeholder")},get value(){return n.searchTerm()},onChange:e=>n.setSearchTerm(e),autofocus:!0,controlClass:"oasis-editor-fr-input"}),null),ko(l,f(kn,{class:"oasis-editor-fr-counter",get children(){return s(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),ko(i,f(ca,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[f(aa,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),f(aa,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),ko(c,f(oo,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),ko(c,f(ca,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[f(aa,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),f(aa,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replaceAll},get disabled(){return 0===n.matches().length},get children(){return t("replace.allBtn")}})]}}),null),ko(a,f(ca,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[f(ir,{class:"oasis-editor-fr-checkbox",get label(){return t("find.matchCase")},get checked(){return n.findOptions().matchCase},onChange:e=>n.setFindOptions({...n.findOptions(),matchCase:e})}),f(ir,{class:"oasis-editor-fr-checkbox",get label(){return t("find.wholeWord")},get checked(){return n.findOptions().wholeWord},onChange:e=>n.setFindOptions({...n.findOptions(),wholeWord:e})})]}}),null),e}})}Ve(["keydown"]);var md=/*#__PURE__*/ie("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),hd=/*#__PURE__*/ie("<i>"),bd=/*#__PURE__*/ie("<span class=oasis-editor-context-menu-shortcut>"),yd=/*#__PURE__*/ie("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),vd=/*#__PURE__*/ie("<div class=oasis-editor-context-menu-separator>"),xd=/*#__PURE__*/ie("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function wd(e){let t;const n=t=>{e.isOpen&&"Escape"===t.key&&(t.preventDefault(),e.onClose())},o=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},r=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},a=()=>{e.isOpen&&e.onClose()};return Jt(()=>{window.addEventListener("keydown",n,!0),window.addEventListener("mousedown",o,!0),window.addEventListener("contextmenu",r,!0),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a,!0)}),pe(()=>{window.removeEventListener("keydown",n,!0),window.removeEventListener("mousedown",o,!0),window.removeEventListener("contextmenu",r,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a,!0)}),Dt(()=>{if(!e.isOpen||!t)return;const n=t.getBoundingClientRect(),o=Math.max(4,window.innerWidth-n.width-4),r=Math.max(4,window.innerHeight-n.height-4),a=Math.min(e.x,o),i=Math.min(e.y,r);t.style.left=`${a}px`,t.style.top=`${i}px`}),f(fa,{get when(){return e.isOpen},get children(){var n=md();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?Te(t,n):t=n,ko(n,f(it,{get each(){return e.items},children:t=>f(fa,{get when(){return"separator"!==t.type},get fallback(){return vd()},get children(){var n=yd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},ko(n,f(fa,{get when(){return t.icon},get fallback(){return e=xd(),ko(e,f(In,{size:16})),e;var e},get children(){var e=hd();return kt(()=>Fe(e,"data-lucide",t.icon)),e}}),o),ko(o,()=>t.label),ko(n,f(fa,{get when(){return t.shortcut},get children(){var e=bd();return ko(e,()=>t.shortcut),e}}),null),kt(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&Fe(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),kt(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&Ne(n,"left",t.e=o),r!==t.t&&Ne(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function Sd(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:l,fontDialog:s,setFontDialog:c,paragraphDialog:d,setParagraphDialog:u,tablePropertiesDialog:p,setTablePropertiesDialog:g,newDocumentDialog:m,setNewDocumentDialog:h,symbolDialog:b,setSymbolDialog:y,equationDialog:v,setEquationDialog:x}=e.dialogs;return[f(ed,{get isOpen(){return m().isOpen},onClose:()=>{h({isOpen:!1}),e.focusInput()},onConfirm:()=>{h({isOpen:!1}),e.confirmNewDocument()}}),f(sd,{get isOpen(){return b().isOpen},onClose:()=>{y({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{y({isOpen:!1}),e.insertSymbol(t,n)}}),f(pd,{get isOpen(){return v().isOpen},get initial(){return v().initial},onClose:()=>{x({isOpen:!1}),e.focusInput()},onApply:t=>{x({isOpen:!1}),e.applyEquation(t,v().targetRunId)}}),f(Qs,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),f(ec,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),f(tc,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),f(rc,{get composer(){return e.commentComposer}}),f(fd,{get fr(){return e.findReplace}}),f(Pc,{get isOpen(){return s().isOpen},get initial(){return s().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...s(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),f(Lc,{get isOpen(){return d().isOpen},get initial(){return d().initial},onClose:()=>{u({...d(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyParagraphDialogValues},get onSetDefault(){return e.setParagraphDialogDefault}}),f(Jc,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),f(wd,{get isOpen(){return l().isOpen},get x(){return l().x},get y(){return l().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}Ve(["contextmenu","click"]);var Id=/*#__PURE__*/ie("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function Cd(e){return[f(fa,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return f(t,{get state(){return n.state()},get toolbarHost(){return n.toolbarHost},get runtimeEditor(){return n.runtimeEditor},get persistenceStatus(){return n.persistenceStatus},get toolbarRegistry(){return n.toolbarRegistry},get menuRegistry(){return n.menuRegistry},get showChrome(){return o.showChrome()},get showTitleBar(){return o.showTitleBar()},get showMenubar(){return o.showMenubar()},get showToolbar(){return o.showToolbar()},get showOutline(){return o.showOutline()},get toolbarView(){return o.toolbarView()},get toolbarLayout(){return o.toolbarLayout()},get isReadOnly(){return r.isReadOnly()},get measuredBlockHeights(){return r.measuredBlockHeights},get measuredParagraphLayouts(){return r.measuredParagraphLayouts},get documentLayout(){return r.documentLayout},get viewportHeight(){return r.viewportHeight},get layout(){return r.layout},get overlays(){return r.overlays},get refs(){return r.refs},get surfaceHandlers(){return r.surfaceHandlers},get inputHandlers(){return r.inputHandlers},get fileHandlers(){return r.fileHandlers}})})()}}),f(fa,{get when(){return!e.useComposedShell()},get children(){return f(D,{get editor(){return e.runtime.runtimeEditor},get children(){var t=Id(),n=t.firstChild;return ko(n,f(Ze,{get state(){return e.runtime.state},get layout(){return{...e.view.layout,documentLayout:e.view.documentLayout,measuredBlockHeights:e.view.measuredBlockHeights,measuredParagraphLayouts:e.view.measuredParagraphLayouts,readOnly:e.view.isReadOnly()}},get overlays(){return{...e.view.overlays,toolbarHost:e.runtime.toolbarHost,persistenceStatus:e.runtime.persistenceStatus}},get refs(){return e.view.refs},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),t}})}})]}var Td=/*#__PURE__*/ie("<div class=oasis-editor-welcome-overlay role=dialog aria-modal=true aria-labelledby=oasis-editor-welcome-title><div class=oasis-editor-welcome-card><h2 id=oasis-editor-welcome-title class=oasis-editor-welcome-title></h2><p class=oasis-editor-welcome-body></p><p class=oasis-editor-welcome-note></p><div class=oasis-editor-welcome-actions>");function Pd(e){const t=Xr(),n=()=>{at(),Ht(),e.onClose()},o=()=>{Pt(!1),Ht(),e.onClose()};return f(fa,{get when(){return e.isOpen},get children(){var e=Td(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return ko(r,f(gt,{height:72,class:"oasis-editor-welcome-mark"}),a),ko(a,()=>t("welcome.title")),ko(i,()=>t("welcome.body")),ko(l,()=>t("welcome.note")),ko(s,f(Le,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),ko(s,f(Le,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var kd=/* @__PURE__ */rn(_r(),1),Rd=x(),Bd="word/comments.xml";function Md(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Fd(e){return e.localName??e.tagName}function Ad(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Od(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function Dd(e){let t="";for(const n of Md(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===Fd(n)){t+=n.textContent??"";continue}if("tab"===Fd(n)){t+="\t";continue}if("br"===Fd(n)||"cr"===Fd(n)){t+="\n";continue}}t+=Dd(n)}return t}function Ed(e){return Md(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===Fd(e))}function Ld(e){return Ed(e).map(Dd).join("\n").trim()}function Nd(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===Fd(t)?t:void 0}function $d(e,t){const n=Ad(Ed(t)[0]??t,"paraId");for(;t.firstChild;)t.removeChild(t.firstChild);for(let r=0;r<e.childNodes.length;r+=1){const n=e.childNodes[r];n&&t.appendChild(n.cloneNode(!0))}const o=Ed(t)[0];n&&o&&o.setAttributeNS(Ln,"w14:paraId",n)}function zd(e,t){const n=Ed(e),o=Ed(t);n[0]&&o[0]&&Ar(n[0],o[0]);const r=new Set(Md(t).filter(e=>e.namespaceURI!==Xn).map(e=>`${e.namespaceURI??""}\0${Fd(e)}`));for(const a of Md(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${Fd(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function Hd(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/comments")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(Bd);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Nd(e),o=Nd(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Md(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Fd(i))continue;const e=Ad(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of Md(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Fd(i))continue;const e=Ad(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new Rd.XMLSerializer).serializeToString(t);Od(i,t),Ld(i)===Ld(t)?$d(i,t):zd(i,t),(new Rd.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new Rd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Bd,a),!0)}var Wd="http://schemas.microsoft.com/office/word/2012/wordml",Ud="word/commentsExtended.xml";function jd(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Vd(e){return e.localName??e.tagName}function Kd(e){return`${e.namespaceURI??""}\0${Vd(e)}`}function _d(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Xd(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function Gd(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function Yd(e){const t=/* @__PURE__ */new Map,n=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(Xn,"comment"))){const e=_d(o,"id"),n=o.getElementsByTagNameNS(Xn,"p").item(0),r=n?_d(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function qd(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===Wd&&"commentsEx"===Vd(t)?t:void 0}function Zd(e,t,n){for(let r=0;r<e.attributes.length;r+=1){const o=e.attributes.item(r);if(!o)continue;const a=o.localName??o.name;"paraId"!==a&&((o.namespaceURI?t.hasAttributeNS(o.namespaceURI,a):t.hasAttribute(o.name))||Xd(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(jd(t).map(Kd));for(const r of jd(e))o.has(Kd(r))||t.appendChild(r.cloneNode(!0))}function Jd(e,t,n,o){const r=qd(t),a=qd(o);if(!r||!a)return o;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||Xd(t,o,o.value)}}(r,a);const i=Yd(e),l=Yd(n),s=/* @__PURE__ */new Map;for(const[p,g]of i){const e=l.get(p);e&&s.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of jd(e)){if(n.namespaceURI!==Wd||"commentEx"!==Vd(n))continue;const e=_d(n,"paraId");e&&t.set(e,n)}return t}(a),d=jd(r),u=new Set(jd(a).filter(e=>!(e.namespaceURI===Wd&&"commentEx"===Vd(e))).map(Kd));for(const p of d){if(p.namespaceURI===Wd&&"commentEx"===Vd(p)){const e=_d(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&Zd(p,n,s);continue}u.has(Kd(p))||(a.appendChild(p.cloneNode(!0)),u.add(Kd(p)))}return(new Rd.XMLSerializer).serializeToString(a.ownerDocument)}var Qd="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function eu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function tu(e){return e.localName??e.tagName}function nu(e){return`${e.namespaceURI??""}\0${tu(e)}`}function ou(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function ru(e,t){return eu(e).find(e=>e.namespaceURI===Qd&&tu(e)===t)}function au(e,t){return e.filter(e=>e.namespaceURI===Qd&&t.has(tu(e)))}function iu(e){if(e.namespaceURI!==Qd)return;const t=tu(e);if("p"===t){const t=ou(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=ru(e,"sdtPr"),n=t?ru(t,"id"):void 0,o=n?ou(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function lu(e,t,n){const o=(new Rd.DOMParser).parseFromString(e,"application/xml"),r=(new Rd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==Qd||i.namespaceURI!==Qd||tu(a)!==n||tu(i)!==n)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(a,i);const l=eu(a),s=eu(i),c=new Set(s.map(nu));return l.forEach((e,t)=>{if(e.namespaceURI===Qd||c.has(nu(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>nu(t)===nu(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new Rd.XMLSerializer).serializeToString(r)}function su(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=lu(e,t,n),a=(new Rd.DOMParser).parseFromString(e,"application/xml"),i=(new Rd.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==Qd||s.namespaceURI!==Qd||tu(l)!==n||tu(s)!==n)return r;const c=eu(l),d=eu(s),u=function(e,t,n){const o=au(e,n),r=au(t,n);return o.length===r.length&&o.every((e,t)=>tu(e)===tu(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==Qd||o.has(tu(e)))return;const n=nu(e),r=p.get(n)??0;if(p.set(n,r+1),eu(s).filter(e=>nu(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===Qd&&o.has(tu(e)));if(!a)return;const i=iu(a);if(i){const e=au(n,o).find(e=>iu(e)===i);if(e)return e}if(!r)return;const l=au(e,o),s=au(n,o),c=l.indexOf(a);return c>=0?s[c]:void 0}(c,t,d,o,u);(a||u)&&s.insertBefore(e.cloneNode(!0),a??null)}),(new Rd.XMLSerializer).serializeToString(i)}var cu="word/document.xml",du=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function uu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function pu(e){return e.localName??e.tagName}function gu(e){return`${e.namespaceURI??""}\0${pu(e)}`}function fu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function mu(e,t){return uu(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&pu(e)===t)}function hu(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&du.has(pu(e))}function bu(e){return e.filter(hu)}function yu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=pu(e);if("p"===t){const t=fu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=mu(e,"sdtPr"),n=t?fu(mu(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function vu(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml"),o=(new Rd.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==r.namespaceURI||"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==a.namespaceURI||"document"!==pu(r)||"document"!==pu(a))return t;!function(e,t){const n=uu(e),o=mu(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===pu(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=uu(t).find(t=>!i.has(t)&&gu(t)===gu(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=mu(r,"body"),l=mu(a,"body");if(!i||!l)return t;!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(i,l);const s=uu(i),c=uu(l),d=function(e,t){const n=bu(e),o=bu(t);return n.length===o.length&&n.every((e,t)=>pu(e)===pu(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if(hu(e))return;const n=gu(e),o=u.get(n)??0;if(u.set(n,o+1),uu(l).filter(e=>gu(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(hu);if(!o)return;const r=yu(o);return r?bu(n).find(e=>yu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=bu(e),r=bu(n),a=e.slice(t+1).find(hu);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(s,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&l.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===pu(e))}(c)??null)}),(new Rd.XMLSerializer).serializeToString(o)}async function xu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(cu);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return vu(e,lu(e,t,"document"))}(n.data,r);return a!==r&&(t.file(cu,a),!0)}var wu="word/document.xml",Su="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Iu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Cu(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Su,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function Tu(e){const t=[];return Cu(e).forEach((e,n)=>{const o=/* @__PURE__ */new Map;for(const r of function(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}(e)){const e=r.namespaceURI===Su&&"headerReference"===r.localName?"header":r.namespaceURI===Su&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Iu(r,"id");if(!a)continue;const i=Iu(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),t.push({key:`${n}:${e}:${i}:${s}`,kind:e,relationshipId:a})}}),t}function Pu(e){return new Map(e.map(e=>[e.id,e]))}async function ku(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(wu)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=Cu(n.data),a=Cu(o);if(r.length!==a.length)return!1;const i=Tu(n.data),l=Tu(o),s=new Map(i.map(e=>[e.key,e])),c=Pu(n.relationships??[]),d=Pu(await async function(e){const t=await(e.file(function(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}(wu))?.async("string"));return ia(wu,zr(t))}(t));let u=!1;for(const p of l){const n=s.get(p.key);if(!n||n.kind!==p.kind)continue;const o=c.get(n.relationshipId),r=d.get(p.relationshipId);if("External"===o?.targetMode||"External"===r?.targetMode||!o?.resolvedTarget||!r?.resolvedTarget)continue;const a=e.parts[o.resolvedTarget];if("xml"!==a?.kind)continue;const i=r.resolvedTarget,l=await(t.file(i)?.async("string"));if(!l)continue;const g="header"===p.kind?"hdr":"ftr",f=su(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var Ru="word/document.xml",Bu={"/styles":"word/styles.xml","/numbering":"word/numbering.xml","/settings":"word/settings.xml","/fontTable":"word/fontTable.xml","/theme":"word/theme/theme1.xml","/footnotes":"word/footnotes.xml","/endnotes":"word/endnotes.xml","/comments":"word/comments.xml","/commentsExtended":"word/commentsExtended.xml"},Mu=["/officeDocument",...Object.keys(Bu)];function Fu(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function Au(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function Ou(e){for(const[t,n]of Object.entries(Bu))if(e.type.endsWith(t))return n}function Du(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=lo(e);return void 0===n?t.get(e)??e:null===n?e:Au(t.get(n)??n)}function Eu(e,t){for(const[n,o]of t)if(o===e)return n;return e}function Lu(e,t){if(null===e)return t;const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function Nu(e,t){const n=e.parts[t];return"xml"===n?.kind?zr(n.data):[]}function $u(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:Nu(e,$o):e.parts[t]?.relationships??Nu(e,Au(t));return ia(t,n)}function zu(e,t,n){return $u(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function Hu(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,Mu.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=ia(n,[e])[0]?.resolvedTarget,c=l?.resolvedTarget??(s?r.get(s)??s:void 0);return c?{...e,...l?{id:l.id,type:l.type}:{},target:Lu(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function Wu(e,t,n){const o=[...t],r=new Map(t.map(e=>[e.id,e]));for(const a of e){const e=r.get(a.id);if(e){if(Fu(e)===Fu(a))continue;throw new Error(`Cannot safely preserve ${n}: relationship id ${a.id} is used by both the source package and rebuilt document for different targets.`)}o.push(a)}return o}function Uu(e,t,n){const o=t.parts[n];o&&("base64"===o.encoding?e.file(n,o.data,{base64:!0}):e.file(n,o.data))}function ju(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===h(o))}async function Vu(e,t){const n=e.sourcePackage;if(!n)return t;const o=await kd.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>eo(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(Ru,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=Ou(o);e&&t.set(e,o.resolvedTarget)}return t}(n),i=function(e,t,n){const o=/* @__PURE__ */new Set;for(const[r,a]of t)r!==Ru&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new kd.default;for(const c of Object.keys(n.parts))Uu(l,n,c);for(const c of i)l.remove(c),l.remove(Au(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=lo(a);if(null==i)continue;const l=$u(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=Eu(i,n);o.has(Au(c))||(0===s.length?e.remove(a):e.file(a,Qr(s)))}}(l,n,a,r,i);let s=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=eo(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=Du(e,a),o=lo(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=zu(n,r,i),c=Wu(s,Hu(zr(await d.async("string")),s,e,r,a),t);l.file(t,Qr(c));continue}const r=await d.async("uint8array");ju(n,e,t,r)||l.file(t,r)}return s&&l.file(or,function(e,t,n,o){const r=un(t),a={};for(const[l,s]of Object.entries(r.overrides))a[n.get(l)??l]=s;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return Cn({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,s,a,i)),l.generateAsync({type:"arraybuffer"})}var Ku="word/document.xml",_u=["first","even","default"];function Xu(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t):"",o=t>=0?e.slice(t+1):e;return n?`${n}/_rels/${o}.rels`:`_rels/${o}.rels`}function Gu(e,t){const n=function(e){const t=e.lastIndexOf("/");return t<0?[]:e.slice(0,t).split("/")}(e),o=t.split("/");let r=0;for(;r<n.length&&r<o.length&&n[r]===o[r];)r+=1;return[...Array.from({length:n.length-r},()=>".."),...o.slice(r)].join("/")}function Yu(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function qu(e,t){const n=[],o=e=>{for(const r of Yu(e))r.localName===t&&n.push(r),o(r)};return o(e),n}function Zu(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Ju(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return r.value!==n&&(e.setAttribute(r.name,n),!0)}return!1}function Qu(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml"),n=[],o=qu(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of Yu(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Zu(r,"id");if(!a)continue;const i=Zu(r,"type")??"default",l=`${e}:${i}`,s=o.get(l)??0;o.set(l,s+1),n.push({key:`${t}:${e}:${i}:${s}`,sectionIndex:t,kind:e,type:i,occurrence:s,relationshipId:a})}}),{references:n,sectionCount:o.length}}function ep(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function tp(e,t){const n=e.parts[t]?.relationships??zr(ep(e,Xu(t)));return ia(t,n)}function np(e,t){const n=new Map(t.map(e=>[e.id,e]));return e.flatMap(e=>{const t=n.get(e.relationshipId);if(!t||"External"===t.targetMode||!t.resolvedTarget)return[];const o="header"===e.kind?"/header":"/footer";return t.type.endsWith(o)?[{...e,relationship:t,partPath:t.resolvedTarget}]:[]})}async function op(e,t){const n=ep(e,e.mainDocumentPart),o=await(t.file(Ku)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=Qu(n),a=Qu(o),i=np(r.references,tp(e,e.mainDocumentPart));!function(e){const t=[...e].sort((e,t)=>{if(e.sectionIndex!==t.sectionIndex)return e.sectionIndex-t.sectionIndex;if(e.kind!==t.kind)return"header"===e.kind?-1:1;const n=_u.indexOf(e.type),o=_u.indexOf(t.type),r=n<0?99:n,a=o<0?99:o;return r!==a?r-a:e.type!==t.type?e.type.localeCompare(t.type):e.occurrence-t.occurrence});let n=1,o=1;for(const r of t)"header"===r.kind?(r.baselinePath=`word/header${n}.xml`,n+=1):(r.baselinePath=`word/footer${o}.xml`,o+=1)}(i);const l=np(a.references,await async function(e,t){const n=await(e.file(Xu(t))?.async("string"));return ia(t,zr(n))}(t,Ku)),s=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of l){const e=s.get(p.key);e&&(c.push({current:p,source:e}),d.add(e.partPath),u.set(p.relationshipId,e.relationship))}return{matches:c,deletedSourcePartPaths:r.sectionCount===a.sectionCount?new Set(i.map(e=>e.partPath).filter(e=>!d.has(e))):/* @__PURE__ */new Set,sourceRelationshipByCurrentId:u}}function rp(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function ap(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===h(await a.async("uint8array")):void 0===r}async function ip(e,t,n,o){for(const r of n)if(!(await ap(e,t,o?Xu(r.current.partPath):r.current.partPath,r.source.baselinePath?o?Xu(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function lp(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?Xu(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?h(a):"<missing>")}if(o.size>1)throw new Error(`Cannot safely preserve shared header/footer part ${t[0].source.partPath}: its section projections diverged after editing.`)}async function sp(e,t,n){const o=await(e.file(Ku)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[Ku],a=h((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of qu(n,r)){const n=Zu(e,"id"),r=n?t.get(n):void 0;r&&(o=Ju(e,"id",r.id)||o)}return o?(new Rd.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(Ku,t)}}const r=Xu(Ku),a=zr(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:Gu(Ku,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,Qr(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(rp(e)===rp(r))continue;throw new Error(`Cannot safely preserve ${t}: relationship id ${r.id} is used for different targets.`)}o.set(r.id,r),n.push(r)}return n}(a,r)))}async function cp(e,t,n){const o=n[0],r=o.source.partPath;if(!(await ip(e,t,n,!1))){await lp(e,n,!1);const t=await(e.file(o.current.partPath)?.async("uint8array"));if(!t)throw new Error(`Cannot preserve ${r}: rebuilt header/footer part is missing.`);e.file(r,t)}for(const c of n)c.current.partPath!==r&&e.remove(c.current.partPath);const a=Xu(r);if(!(await ip(e,t,n,!0))){await lp(e,n,!0);const t=Xu(o.current.partPath),c=await(e.file(t)?.async("string"));c&&e.file(a,Qr((i=zr(c),l=o.current.partPath,s=r,i.map(e=>{if("External"===e.targetMode)return e;const t=ia(l,[e])[0]?.resolvedTarget;return t?{...e,target:Gu(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=Xu(c.current.partPath);t!==a&&e.remove(t)}}async function dp(e,t,n){for(const o of function(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=t.get(n.source.partPath)??[];e.push(n),t.set(n.source.partPath,e)}return t}(n.matches).values())await cp(e,t,o)}async function up(e,t){const n=e.sourcePackage;if(!n)return t;const o=await kd.default.loadAsync(t),r=await op(n,o);r.matches.length>0&&(await sp(o,n,r),await dp(o,n,r),await async function(e,t){const n=await(e.file(or)?.async("string"));if(!n)return;const o=un(n);for(const r of t.matches){const e=o.overrides[r.current.partPath];e&&(o.overrides[r.source.partPath]=e),r.current.partPath!==r.source.partPath&&delete o.overrides[r.current.partPath]}e.file(or,Cn(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return Vu(function(e,t){const n=e.sourcePackage;if(!n||0===t.size)return e;const o={defaults:{...n.contentTypes.defaults},overrides:Object.fromEntries(Object.entries(n.contentTypes.overrides).filter(([e])=>!t.has(e)))},r={...n.parts};for(const d of t)delete r[d],delete r[Xu(d)];const a=r[n.mainDocumentPart],i=tp(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=Xu(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:Qr(i)});const c=r[or];return c&&(r[or]={...c,data:Cn(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var pp=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],gp=/* @__PURE__ */new Set(["p","tbl"]),fp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function mp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function hp(e){return e.localName??e.tagName}function bp(e){return`${e.namespaceURI??""}\0${hp(e)}`}function yp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function vp(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}function xp(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&hp(n)===t?n:void 0}function wp(e){const t=yp(e,"type");if(t&&fp.has(t))return`type:${t}`;const n=yp(e,"id");return n?`id:${n}`:void 0}function Sp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&gp.has(hp(e))}function Ip(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==hp(e))return;const t=yp(e,"paraId");return t?`p:${t}`:void 0}function Cp(e,t){!function(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}(e,t);const n=mp(e),o=mp(t),r=function(e,t){const n=e.filter(Sp),o=t.filter(Sp);return n.length===o.length&&n.every((e,t)=>hp(e)===hp(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Sp(e))return;const l=bp(e),s=a.get(l)??0;if(a.set(l,s+1),mp(t).filter(e=>bp(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Sp);if(!r)return;const a=Ip(r);if(a){const e=n.filter(Sp).find(e=>Ip(e)===a);if(e)return e}if(!o)return;const i=e.filter(Sp),l=n.filter(Sp),s=i.indexOf(r);return s>=0?l[s]:void 0}(n,i,o,r);("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||c||r)&&t.insertBefore(e.cloneNode(!0),c??null)})}function Tp(e,t,n,o){const r=xp(t,o.rootName),a=xp(n,o.rootName);if(!r||!a)return n;const i=mp(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&hp(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of mp(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||hp(c)!==o.entryName)continue;const e=wp(c);e&&l.set(e,c)}const s=function(e,t){const n="footnote"===t?e.footnotes?.items:e.endnotes?.items,o=/* @__PURE__ */new Set;for(const r of Object.values(n??{}))void 0!==r.docxId&&Number.isSafeInteger(r.docxId)&&r.docxId>=1&&o.add(String(r.docxId));return o}(e,o.kind);for(const c of i){const e=wp(c);if(!e)continue;const t=l.get(e),n=yp(c,"type");if(t){n&&fp.has(n)?a.replaceChild(c.cloneNode(!0),t):Cp(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=yp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new Rd.XMLSerializer).serializeToString(a.ownerDocument)}var Pp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",kp="word/numbering.xml";function Rp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Bp(e){return e.localName??e.tagName}function Mp(e){return`${e.namespaceURI??""}\0${Bp(e)}`}function Fp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Ap(e,t,n){for(let o=0;o<e.attributes.length;o+=1){const r=e.attributes.item(o);if(r?.localName===t)return void e.setAttribute(r.name,n)}e.setAttributeNS(Pp,`w:${t}`,n)}function Op(e,t){return Rp(e).find(e=>e.namespaceURI===Pp&&Bp(e)===t)}function Dp(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function Ep(e,t){const n=new Set(Rp(t).map(Mp));for(const o of Rp(e))o.namespaceURI===Pp||n.has(Mp(o))||t.appendChild(o.cloneNode(!0))}function Lp(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}var Np=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function $p(e,t){Dp(e,t);const n=Rp(e),o=new Map(Rp(t).map(e=>[Mp(e),e]));n.forEach((e,r)=>{const a=Mp(e),i=o.get(a),l=Bp(e);if(i)return Dp(e,i),void(e.namespaceURI===Pp&&"rPr"===l?function(e,t){Dp(e,t);const n=Rp(e),o=new Map(Rp(t).map(e=>[Mp(e),e]));n.forEach((e,r)=>{const a=Mp(e),i=o.get(a);if(i)return Dp(e,i),void Ep(e,i);e.namespaceURI===Pp&&"rFonts"===Bp(e)||Lp(n,r,e,t,e=>o.get(Mp(e)))})}(e,i):Ep(e,i));if(e.namespaceURI!==Pp||!Np.has(l)){if(e.namespaceURI===Pp&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of Rp(e))o.namespaceURI===Pp&&"rFonts"===Bp(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}Lp(n,r,e,t,e=>o.get(Mp(e)))}})}function zp(e){return function(e){return e.namespaceURI===Pp&&"lvl"===Bp(e)?`${Mp(e)}\0${Fp(e,"ilvl")??"0"}`:Mp(e)}(e)}function Hp(e,t,n){const o=Op(t,"abstractNumId"),r=o?Fp(o,"val"):void 0;if(!r)return;const a=Rp(e).find(e=>e.namespaceURI===Pp&&"abstractNum"===Bp(e)&&Fp(e,"abstractNumId")===r);return a?Rp(a).find(e=>e.namespaceURI===Pp&&"lvl"===Bp(e)&&(Fp(e,"ilvl")??"0")===n):void 0}function Wp(e,t){const n=t.cloneNode(!0);$p(e,n);const o=Op(e,"pPr"),r=Op(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function Up(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=Fp(Op(t,"start")??t,"val")??"1";for(const r of Rp(e)){const e=Bp(r);if(r.namespaceURI===Pp&&"startOverride"===e){const e=r.cloneNode(!0);Ap(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==Pp||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(Wp(r,t))}return n}function jp(e){if(e.namespaceURI!==Pp)return Mp(e);const t=Bp(e);return"abstractNum"===t?`${Mp(e)}\0${Fp(e,"abstractNumId")??""}`:"num"===t?`${Mp(e)}\0${Fp(e,"numId")??""}`:Mp(e)}function Vp(e,t){const n=function(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new Rd.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===Pp&&o.namespaceURI===Pp&&"numbering"===Bp(n)&&"numbering"===Bp(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Dp(o,r);const a=Rp(o),i=new Map(Rp(r).map(e=>[jp(e),e]));return a.forEach((e,t)=>{const n=jp(e),o=i.get(n),l=Bp(e);if(o)return Dp(e,o),void(e.namespaceURI===Pp&&"abstractNum"===l?function(e,t){Dp(e,t);const n=Rp(e),o=new Map(Rp(t).map(e=>[zp(e),e]));n.forEach((e,r)=>{const a=zp(e),i=o.get(a);if(i)return Dp(e,i),void(e.namespaceURI===Pp&&"lvl"===Bp(e)?$p(e,i):Ep(e,i));Lp(n,r,e,t,e=>o.get(zp(e)))})}(e,o):e.namespaceURI===Pp&&"num"===l?function(e,t,n){Dp(e,t);const o=Op(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of Rp(t))a.namespaceURI===Pp&&"lvlOverride"===Bp(a)&&r.set(Fp(a,"ilvl")??"0",a);for(const a of Rp(e)){const e=Bp(a);if(a.namespaceURI!==Pp||"abstractNumId"!==e){if(a.namespaceURI===Pp&&"lvlOverride"===e){const e=Fp(a,"ilvl")??"0",o=Up(a,Hp(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===Pp||Rp(t).some(e=>Mp(e)===Mp(a))||t.appendChild(a.cloneNode(!0))}else o&&(Dp(a,o),Ep(a,o))}}(e,o,r):Ep(e,o));Lp(a,t,e,r,e=>i.get(jp(e)))}),(new Rd.XMLSerializer).serializeToString(r.ownerDocument)}async function Kp(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/numbering")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(kp);if(!n||!o)return!1;const r=await o.async("string"),a=Vp(n,r);return a!==r&&(t.file(kp,a),!0)}var _p=[{relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootLocalName:"footnotes"},{relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootLocalName:"endnotes"},{relationshipSuffix:"/comments",rebuiltPath:"word/comments.xml",rootLocalName:"comments"}];function Xp(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var Gp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Yp=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function qp(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Zp(e){return e.localName??e.tagName}function Jp(e){return`${e.namespaceURI??""}\0${Zp(e)}`}function Qp(e){const t=[],n=e=>{for(const o of qp(e))o.namespaceURI===Gp&&"sectPr"===Zp(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function eg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function tg(e){return e.namespaceURI===Gp&&Yp.has(Zp(e))}function ng(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml"),o=(new Rd.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=Qp(n),l=Qp(o);return 0===i.length||i.length!==l.length?t:(eg(r,a),i.forEach((e,t)=>{!function(e,t){eg(e,t);const n=qp(e),o=qp(t),r=/* @__PURE__ */new Map;for(const i of o){const e=Jp(i),t=r.get(e);t?t.push(i):r.set(e,[i])}const a=/* @__PURE__ */new Map;for(let i=0;i<n.length;i+=1){const e=n[i],o=Jp(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){eg(e,s);continue}if(tg(e))continue;const c=n.slice(i+1).map(e=>r.get(Jp(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new Rd.XMLSerializer).serializeToString(o))}var og="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function rg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function ag(e){return e.localName??e.tagName}function ig(e,t){const n=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===og&&ag(n)===t?n:void 0}function lg(e){return rg(e).length>0?(new Rd.XMLSerializer).serializeToString(e.ownerDocument):void 0}var sg=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),cg=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function dg(e){const t=ig(e,"settings");if(!t)return e;for(const n of[...rg(t)]){if(n.namespaceURI!==og)continue;const e=ag(n);if(sg.has(e)){t.removeChild(n);continue}const o=cg.get(e);if(o){for(const e of[...rg(n)])e.namespaceURI===og&&o.has(ag(e))&&n.removeChild(e);0===rg(n).length&&t.removeChild(n)}}return lg(t)}function ug(e){const t=ig(e,"styles");if(!t)return e;for(const n of[...rg(t)])n.namespaceURI===og&&"style"===ag(n)&&t.removeChild(n);return lg(t)}function pg(e){const t=ig(e,"fonts");if(!t)return e;for(const n of[...rg(t)])n.namespaceURI===og&&"font"===ag(n)&&t.removeChild(n);return lg(t)}async function gg(e,t,n){const o=e.file(t);if(!o)return!1;const r=await o.async("string"),a=n(r);return a!==r&&(void 0===a?e.remove(t):e.file(t,a),!0)}var fg="word/styles.xml";function mg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function hg(e){return e.localName??e.tagName}function bg(e){return`${e.namespaceURI??""}\0${hg(e)}`}function yg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function vg(e,t){return mg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&hg(e)===t)}function xg(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===hg(e)?`${bg(e)}\0${yg(e,"type")??""}`:bg(e)}function wg(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===hg(t)?t:void 0}function Sg(e,t){const n=vg(e,"pPr");if(!n)return!1;const o=vg(t,"pPr"),r=new Rd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=bn(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===hg(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=mg(e),a=r.indexOf(n),i=mg(t),l=new Map(i.map(e=>[xg(e),e])),s=r.slice(a+1).map(e=>l.get(xg(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function Ig(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(fg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=wg(e),o=wg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of mg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==hg(i))continue;const e=yg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of mg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==hg(i))continue;const e=yg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Sg(i,t)||a)}return a?(new Rd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(fg,a),!0)}function Cg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Tg(e){return e.localName??e.tagName}function Pg(e){for(let t=0;t<e.attributes.length;t+=1){const n=e.attributes[t];if(n&&"http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==n.namespaceURI&&"http://www.w3.org/2000/xmlns/"!==n.namespaceURI&&"xmlns"!==n.prefix&&"xmlns"!==n.name)return!0}return!1}function kg(e,t){const n=function(e){if(!e)return;const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Tg(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${Xn}" xmlns:w14="${Ln}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};pt(r,`<w:r xmlns:w="${Xn}" xmlns:w14="${Ln}">${e}<w:t/></w:r>`);const a=function(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===Tg(t)?t:void 0}(qo(r,o));if(!a)return t;let i=Cg(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===Tg(e));return!i&&Pg(n)&&(i=a.ownerDocument.createElementNS(Xn,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(Ar(n,i),0!==Cg(i).length||Pg(i)?(new Rd.XMLSerializer).serializeToString(i):""):""}var Rg="word/styles.xml";function Bg(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Mg(e){return e.localName??e.tagName}function Fg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Ag(e,t){return Bg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Mg(e)===t)}function Og(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Mg(t)?t:void 0}function Dg(e,t){const n=Ag(e,"rPr");if(!n)return!1;const o=Ag(t,"rPr"),r=new Rd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=kg(a,i);if(l===i)return!1;if(!l)return!!o&&(t.removeChild(o),!0);const s=function(e){if(!e)return;const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Mg(t)?t:void 0}(l);if(!s)return!1;const c=s.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=Bg(e),a=r.indexOf(n),i=Bg(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&Mg(t)===Mg(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function Eg(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(Rg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Og(e),o=Og(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Bg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Mg(i))continue;const e=Fg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Bg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Mg(i))continue;const e=Fg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Dg(i,t)||a)}return a?(new Rd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Rg,a),!0)}var Lg="word/styles.xml",Ng=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function $g(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function zg(e){return e.localName??e.tagName}function Hg(e){return`${e.namespaceURI??""}\0${zg(e)}`}function Wg(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function Ug(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function jg(e,t){return $g(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&zg(e)===t)}function Vg(e){return e?(new Rd.XMLSerializer).serializeToString(e):""}function Kg(e,t){if(!e)return;const n=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&zg(n)===t?n:void 0}function _g(e,t,n){switch(e){case"pPr":return bn(t,n);case"rPr":return kg(t,n);case"tblPr":return Mn(t,n);case"trPr":return Fo(t,n);case"tcPr":return xr(t,n);default:return n}}function Xg(e,t,n,o){const r=$g(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ng.has(zg(e)));return i?jg(t,zg(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===zg(e)&&Ng.has(o)?$g(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===zg(e))??null:null}function Gg(e,t,n){const o=jg(e,n);if(!o)return!1;const r=jg(t,n),a=Vg(r),i=_g(n,Vg(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=Kg(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,Xg(e,t,o,n)),!0)}function Yg(e,t){Ug(e,t);let n=!1;for(const r of Ng)n=Gg(e,t,r)||n;const o=new Set($g(t).map(Hg));for(const r of $g(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Ng.has(zg(r))||o.has(Hg(r))||(t.appendChild(r.cloneNode(!0)),o.add(Hg(r)),n=!0);return n}function qg(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(Xn,"w:tblStylePr");Ug(e,n);let o=!1;for(const r of $g(e)){const e=zg(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Ng.has(e)){const t=Kg(_g(e,Vg(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function Zg(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==zg(e))return;const t=Wg(e,"type");return t?`tblStylePr:${t}`:void 0}function Jg(e,t){let n=!1;n=Gg(e,t,"tblPr")||n;const o=$g(e).filter(e=>void 0!==Zg(e)),r=/* @__PURE__ */new Map;for(const a of $g(t)){const e=Zg(a);e&&r.set(e,a)}for(const a of o){const o=Zg(a),i=r.get(o);if(i){n=Yg(a,i)||n;continue}const l=qg(a);if(!l)continue;const s=$g(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==Zg(e)),u=d?r.get(Zg(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function Qg(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===zg(t)?t:void 0}async function ef(e,t){const n=function(e){const t=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/styles")&&Boolean(e.resolvedTarget)),n=t?.resolvedTarget?e.parts[t.resolvedTarget]:void 0;return"xml"===n?.kind?n.data:void 0}(e),o=t.file(Lg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Qg(e),o=Qg(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of $g(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===zg(i)){const e=Wg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of $g(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==zg(i))continue;if("table"!==Wg(i,"type"))continue;const e=Wg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Jg(i,t)||a)}return a?(new Rd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Lg,a),!0)}var tf="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function nf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function of(e){return e.localName??e.tagName}function rf(e){return`${e.namespaceURI??""}\0${of(e)}`}function af(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(o?.localName===t)return o.value}}function lf(e,t){for(let n=0;n<e.attributes.length;n+=1){const o=e.attributes.item(n);if(!o)continue;const r=o.localName??o.name;(o.namespaceURI?t.hasAttributeNS(o.namespaceURI,r):t.hasAttribute(o.name))||(o.namespaceURI?t.setAttributeNS(o.namespaceURI,o.name,o.value):t.setAttribute(o.name,o.value))}}function sf(e,t,n){const o=(new Rd.DOMParser).parseFromString(e,"application/xml"),r=(new Rd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===tf&&i.namespaceURI===tf&&of(a)===n&&of(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function cf(e,t,n,o,r){const a=e.slice(t+1).map(r).find(e=>Boolean(e));o.insertBefore(n.cloneNode(!0),a??null)}function df(e,t){const n=new Set(nf(t).map(rf));for(const o of nf(e))o.namespaceURI===tf||n.has(rf(o))||t.appendChild(o.cloneNode(!0))}var uf=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var pf=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function gf(e){return e.namespaceURI===tf&&"tblStylePr"===of(e)?`${rf(e)}\0${af(e,"type")??""}`:rf(e)}function ff(e){return e.namespaceURI===tf&&"style"===of(e)?`${rf(e)}\0${af(e,"styleId")??""}`:rf(e)}var mf=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function hf(e){return e.namespaceURI===tf&&"font"===of(e)?`${rf(e)}\0${af(e,"name")??""}`:rf(e)}var bf=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=sf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;lf(o,r);const a=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]),i=nf(o),l=new Map(nf(r).map(e=>[rf(e),e]));return i.forEach((e,t)=>{const n=rf(e),o=l.get(n),s=of(e),c=e.namespaceURI===tf?a.get(s):void 0;if(o)return lf(e,o),void(c?function(e,t,n){lf(e,t);const o=nf(t),r=new Map(o.map(e=>[rf(e),e])),a=nf(e);a.forEach((e,o)=>{const i=rf(e),l=r.get(i);if(l)return lf(e,l),void df(e,l);e.namespaceURI===tf&&n.has(of(e))||cf(a,o,e,t,e=>r.get(rf(e)))})}(e,o,c):df(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of nf(e))r.namespaceURI===tf&&t.has(of(r))||(n.appendChild(r.cloneNode(!0)),o=!0);return o?n:void 0}(e,c);if(n){const e=i.slice(t+1).map(e=>l.get(rf(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===tf&&uf.has(s)||cf(i,t,e,r,e=>l.get(rf(e)))}),(new Rd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=sf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;lf(o,r);const a=nf(o),i=new Map(nf(r).map(e=>[ff(e),e]));return a.forEach((e,t)=>{const n=ff(e),o=i.get(n);if(o)return lf(e,o),void(e.namespaceURI===tf&&"style"===of(e)?function(e,t){lf(e,t);const n=nf(e),o=new Map(nf(t).map(e=>[gf(e),e]));n.forEach((e,r)=>{const a=gf(e),i=o.get(a);if(i)return lf(e,i),void df(e,i);e.namespaceURI===tf&&pf.has(of(e))||cf(n,r,e,t,e=>o.get(gf(e)))})}(e,o):df(e,o));cf(a,t,e,r,e=>i.get(ff(e)))}),(new Rd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=sf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;lf(o,r);const a=nf(o),i=new Map(nf(r).map(e=>[hf(e),e]));return a.forEach((e,t)=>{const n=hf(e),o=i.get(n);if(o)return lf(e,o),void(e.namespaceURI===tf&&"font"===of(e)&&function(e,t){lf(e,t);const n=nf(e),o=new Map(nf(t).map(e=>[rf(e),e]));n.forEach((e,r)=>{const a=rf(e),i=o.get(a);i?lf(e,i):e.namespaceURI===tf&&mf.has(of(e))||cf(n,r,e,t,e=>o.get(rf(e)))})}(e,o));cf(a,t,e,r,e=>i.get(hf(e)))}),(new Rd.XMLSerializer).serializeToString(r.ownerDocument)}}];function yf(e,t){const n=e.parts[e.mainDocumentPart]?.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith(t)&&Boolean(e.resolvedTarget)),o=n?.resolvedTarget?e.parts[n.resolvedTarget]:void 0;return"xml"===o?.kind?o.data:void 0}var vf="word/document.xml";function xf(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS("*","sectPr");let n=0;for(let o=0;o<t.length;o+=1){const e=t.item(o),r=e?.parentNode;e&&"sectPrChange"!==r?.localName&&(n+=1)}return n}async function wf(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return Vu(e,t);const r=await kd.default.loadAsync(t),a=Boolean(r.file("word/numbering.xml")),i={settings:Boolean(r.file("word/settings.xml")),styles:Boolean(r.file("word/styles.xml")),fontTable:Boolean(r.file("word/fontTable.xml"))};let l=await async function(e,t){let n=!1;for(const o of bf){const r=yf(e,o.relationshipSuffix);if(!r)continue;const a=t.file(o.rebuiltPath);if(!a){t.file(o.rebuiltPath,r),n=!0;continue}if(!o.merge)continue;const i=await a.async("string"),l=o.merge(r,i);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r);a&&(l=await Kp(n,r)||l),i.styles&&(l=await Ig(n,r)||l,l=await Eg(n,r)||l,l=await ef(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await gg(e,"word/settings.xml",dg)||n),t.styles||(n=await gg(e,"word/styles.xml",ug)||n),t.fontTable||(n=await gg(e,"word/fontTable.xml",pg)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of _p){const r=Xp(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=lu(r,i,o.rootLocalName);l!==i&&(t.file(o.rebuiltPath,l),n=!0)}return n}(n,r)||l,l=await async function(e,t,n){let o=!1;for(const r of pp){const a=vp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=Tp(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await Hd(n,r)||l,l=await async function(e,t){const n=Gd(e,"/comments"),o=Gd(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(Ud);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=Jd(n,o,i,l);return s!==l&&(t.file(Ud,s),!0)}(n,r)||l,l=await ku(n,r)||l,l=await xu(n,r)||l;const s=await(r.file(vf)?.async("string"));if(!s||xf(o.data)!==xf(s)){return Vu(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=ng(o.data,s);c!==s&&(r.file(vf,c),l=!0);return up(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function Sf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function If(e){const t=(new Rd.DOMParser).parseFromString(e,"application/xml").documentElement;return t&&(t.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/customXml","itemID")??t.getAttribute("ds:itemID")??t.getAttribute("itemID"))?.trim()||null}function Cf(e){const t=/^(([^:[]+):)?([^[]+?)(?:\[(\d+)\])?$/.exec(e);if(!t)return null;const n=t[4]?Number.parseInt(t[4],10):1;return!Number.isFinite(n)||n<1?null:{...t[2]?{prefix:t[2]}:{},localName:t[3],index:n}}function Tf(e,t,n,o){if(e.localName!==n)return!1;if(!t)return!e.namespaceURI;const r=o.get(t);return void 0!==r&&e.namespaceURI===r}function Pf(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function kf(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=Sf(t);for(const o of Object.values(e.parts)){if("xml"!==o.kind||!/^customXml\/item\d+\.xml$/i.test(o.path))continue;const t=(o.relationships?.find(e=>"External"!==e.targetMode&&e.type.endsWith("/customXmlProps")&&e.resolvedTarget))?.resolvedTarget;if(!t)continue;const r=e.parts[t];if(!r||"xml"!==r.kind)continue;const a=If(r.data);if(a&&Sf(a)===n)return{storeItemId:a,itemPartPath:o.path,itemPropsPartPath:t,xml:o.data}}return null}(e,t.storeItemID);if(!o)return!1;const r=function(e,t,n){const o=(new Rd.DOMParser).parseFromString(e,"application/xml"),r=o.documentElement;if(!r)return null;const a=t.trim().replace(/\/text\(\)$/,"");if(!a.startsWith("/")||a.startsWith("//"))return null;const i=a.split("/").filter(Boolean);if(0===i.length)return null;const l=i.at(-1)?.startsWith("@")?i.pop():null,s=Cf(i[0]);if(!s||1!==s.index)return null;if(!Tf(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=Cf(i[m]);if(!e)return null;const t=Pf(c).filter(t=>Tf(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!l)return{document:o,element:c};const d=l.slice(1),u=d.indexOf(":");if(u<0)return{document:o,element:c,attribute:{localName:d,qualifiedName:d}};const p=d.slice(0,u),g=d.slice(u+1),f=n.get(p);return f?{document:o,element:c,attribute:{namespaceUri:f,localName:g,qualifiedName:`${p}:${g}`}}:null}(o.xml,t.xpath,function(e){const t=/* @__PURE__ */new Map;if(!e)return t;for(const n of e.matchAll(/xmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])(.*?)\2/g))t.set(n[1],n[3]);return t}(t.prefixMappings));if(!r)return!1;if(r.attribute)r.attribute.namespaceUri?r.element.setAttributeNS(r.attribute.namespaceUri,r.attribute.qualifiedName,n):r.element.setAttribute(r.attribute.localName,n);else{if(Pf(r.element).length>0)return!1;for(;r.element.firstChild;)r.element.removeChild(r.element.firstChild);r.element.appendChild(r.document.createTextNode(n))}const a=e.parts[o.itemPartPath];return!!a&&(a.data=(new Rd.XMLSerializer).serializeToString(r.document),!0)}function Rf(e,t,n,o){if(!t.sdtPr.dataBinding)return;const r=e.get(t.groupId);r?r.value+=`${o}${n}`:e.set(t.groupId,{wrapper:t,value:n})}function Bf(e){return e.blocks.map(Ff).filter(Boolean).join("\n")}function Mf(e){return e.cells.map(Bf).filter(Boolean).join("\t")}function Ff(e){return"paragraph"===e.type?ot(e):e.rows.map(Mf).filter(Boolean).join("\n")}function Af(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])Rf(t,e,n.text,"");"textBox"===n.kind&&Df(n.textBox.blocks,t)}}function Of(e,t){for(const n of e.rows){const e=Mf(n);for(const o of n.sdtWrappers??[])Rf(t,o,e,"\n");for(const o of n.cells){const e=Bf(o);for(const n of o.sdtWrappers??[])Rf(t,n,e,"\n");Df(o.blocks,t)}}}function Df(e,t){if(e)for(const n of e){const e=Ff(n);for(const o of n.sdtWrappers??[])Rf(t,o,e,"\n");"paragraph"===n.type?Af(n,t):Of(n,t)}}async function Ef(e){if(!e.sourcePackage)return Lt(e);const t={...e,sourcePackage:(n=e.sourcePackage,{...n,contentTypes:{defaults:{...n.contentTypes.defaults},overrides:{...n.contentTypes.overrides}},rootRelationships:n.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(n.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...n.diagnostics?{diagnostics:n.diagnostics.map(e=>({...e}))}:{},...n.rebuiltPartHashes?{rebuiltPartHashes:{...n.rebuiltPartHashes}}:{}})};var n;!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of a(e))Df(o.blocks,t),Df(o.header,t),Df(o.firstPageHeader,t),Df(o.evenPageHeader,t),Df(o.footer,t),Df(o.firstPageFooter,t),Df(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&kf(e.sourcePackage,t,r)&&(n+=1)}}(t);return wf(t,await Lt(t))}async function Lf(e){if(!e.sourcePackage)return te(e);const t=await Ef(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function Nf(e){switch(e){case"dashed":return[Bo(5),Bo(3)];case"dotted":return[Bo(1),Bo(3)];default:return}}async function $f(e,o,r,a,i,l,s,c){const d=o.rotation;d&&(e.saveGraphicsState(r.pageIndex),e.rotateAbout(r.pageIndex,Bo(a+l/2),Bo(i+s/2),d)),function(e,t,o,r,a,i,l){const s=n(o.shape?.preset,Bo(r),Bo(a),Bo(i),Bo(l)),c=o.shape?.fill,d=o.shape?.borderColor,u=o.shape?.borderWidthPt??(d?.75:0);e.drawPath(t,{segments:s,fill:c,stroke:d&&u>0?d:void 0,lineWidth:u})}(e,r.pageIndex,o,a,i,l,s),await async function(e,n,o,r,a,i,l,s){if(0===n.blocks.length)return;const c=function(e){return{left:e.body?.paddingLeft??0,top:e.body?.paddingTop??0,right:e.body?.paddingRight??0,bottom:e.body?.paddingBottom??0}}(n),d=r+c.left,u=a+c.top,p=Math.max(1,i-c.left-c.right),g=Math.max(1,l-c.top-c.bottom),f=Oo({blocks:n.blocks,pageSettings:{width:p,height:g,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:g,styles:o.document.styles,pageOffset:o.pageIndex})[0]?.blocks??[];if(0===f.length)return;const m=ra(o.document);e.saveGraphicsState(o.pageIndex),e.clipRect(o.pageIndex,Bo(d),Bo(u),Bo(p),Bo(g));let h=u;for(const b of f){switch(b.sourceBlock.type){case"paragraph":b.layout&&await s.drawParagraph(e,o.pageIndex,b.sourceBlock,b.layout.lines,o.document,d,h,o.fontRegistry,m,s);break;case"table":await s.drawTableBlock(e,o.pageIndex,b,o.document,d,h,p,o.fontRegistry,m,s);break;default:t(b.sourceBlock,"block")}h+=Math.max(0,b.estimatedHeight)}e.restoreGraphicsState(o.pageIndex)}(e,o,r,a,i,l,s,c),d&&e.restoreGraphicsState(r.pageIndex)}async function zf(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const p of a){const a=new Map(p.slots.map(e=>[e.offset,e]));for(const g of p.fragments){const f=g.textBox;if(!f?.floating)continue;const m=Boolean(f.floating.behindDoc);if(e.layer&&"behind"===e.layer!==m)continue;const h=l+(a.get(g.startOffset)?.left??0),b=d+p.top,y=ar({object:Yn(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await $f(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var Hf=/* @__PURE__ */new WeakMap;function Wf(e){const t=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(e);if(!t)return null;const n=t[1].toLowerCase(),o=Boolean(t[2]),r=t[3]??"";if(!o)return{mediaType:n,data:(new TextEncoder).encode(decodeURIComponent(r))};const a="function"==typeof atob?atob(r):Buffer.from(r,"base64").toString("binary");return{mediaType:n,data:Uint8Array.from(a,e=>e.charCodeAt(0))}}async function Uf(e,t,n){let o=e;o.startsWith("data:")||(o=await async function(e){if("function"!=typeof fetch)return null;const t=await fetch(e);if(!t.ok)return null;const n=await t.blob(),o=new Uint8Array(await n.arrayBuffer()),r=Array.from(o,e=>String.fromCharCode(e)).join(""),a="function"==typeof btoa?btoa(r):Buffer.from(o).toString("base64");return`data:${n.type||"application/octet-stream"};base64,${a}`}(o)??o);let r=Wf(o);if(!r)return null;const a="undefined"!=typeof Image?await async function(e){return"undefined"==typeof Image?null:await new Promise(t=>{const n=new Image;n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}(o):null,i=null!=a&&a.naturalWidth>0&&a.naturalHeight>0;if("image/jpeg"!==r.mediaType&&"image/jpg"!==r.mediaType){if(!i)return null;const e=function(e){if("undefined"==typeof document)return null;const t=document.createElement("canvas");t.width=e.naturalWidth,t.height=e.naturalHeight;const n=t.getContext("2d");return n?(n.fillStyle="#ffffff",n.fillRect(0,0,t.width,t.height),n.drawImage(e,0,0),t.toDataURL("image/jpeg",.92)):null}(a);if(r=e?Wf(e):null,!r)return null}const l=i?a.naturalWidth:t,s=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(l)),height:Math.max(1,Math.round(s)),data:r.data}}async function jf(e,t,n){const o=vo(t,n.src);if(!o)return null;let r=Hf.get(e);r||(r=/* @__PURE__ */new Map,Hf.set(e,r));const a=r.get(o);if(a)return a;const i=Uf(o,n.width,n.height).then(t=>t?e.registerImageResource({width:t.width,height:t.height,data:t.data,filter:"DCTDecode"}):null);return r.set(o,i),i}async function Vf(e,t,o,r,a,i,l,s){const c=await jf(e,o,r);if(!c)return;const d=r.intrinsicWidth??r.width,u=r.intrinsicHeight??r.height,p=d/Math.max(1,u),g=l/Math.max(1,s);let f=a,m=i,h=l,b=s;"fit"===r.cropFit&&p>0&&(p>g?(b=l/p,m+=(s-b)/2):(h=s*p,f+=(l-h)/2));const y="fill"!==r.cropFit||r.crop?r.crop:(()=>{if(p>g){const e=g/p,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(p<g){const e=p/g,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),v=r.cropShape?.preset,x=v?function(e,t,n,o,r,a){if(!a)return e;const i=t+o/2,l=n+r/2,s=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(s)-(t-l)*Math.sin(s),y:l+(e-i)*Math.sin(s)+(t-l)*Math.cos(s)});return e.map(e=>{if("close"===e.type)return e;if("cubic"===e.type){const t=c(e.x1,e.y1),n=c(e.x2,e.y2),o=c(e.x,e.y);return{type:"cubic",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:o.x,y:o.y}}const t=c(e.x,e.y);return{type:e.type,x:t.x,y:t.y}})}(n(v,a,i,l,s),a,i,l,s,r.rotation??0):null,w=r.transparency??0,S="fit"===r.cropFit&&Boolean(r.rotation);x&&(e.saveGraphicsState(t),e.clipPath(t,x)),S&&(e.saveGraphicsState(t),e.rotateAbout(t,a+l/2,i+s/2,r.rotation??0)),w>0&&e.saveGraphicsState(t),w>0&&e.setOpacity(t,1-Math.min(1,w)),e.drawImage(t,{resourceName:c,x:f,y:m,width:h,height:b,rotation:S?void 0:r.rotation,crop:y}),w>0&&e.restoreGraphicsState(t),S&&e.restoreGraphicsState(t),x&&e.restoreGraphicsState(t);const I=r.border;if(!I)return;const C=r.rotation;C&&!x&&(e.saveGraphicsState(t),e.rotateAbout(t,a+l/2,i+s/2,C));const T=Pr(I.dash);x?e.drawPath(t,{segments:x,stroke:I.color,lineWidth:I.widthPt??1}):e.drawRect(t,{x:a,y:i,width:l,height:s,stroke:I.color,lineWidth:I.widthPt??1,...T.length>0?{dashArray:T}:{}}),C&&!x&&e.restoreGraphicsState(t)}function Kf(e,t){const n=new Map(e.slots.map(e=>[e.offset,e])),o=[];for(const r of t.chars){if("\n"===r.char||"\t"===r.char)continue;const e=n.get(r.paragraphOffset);e&&o.push({char:r.char,left:e.left,offset:r.paragraphOffset})}return o}function _f(e,t,n){const o=Kf(e,t);if(0===o.length)return null;const r=new Map(e.slots.map(e=>[e.offset,e])),a=o[0],i=o[o.length-1],l=r.get(i.offset+1);return{left:a.left,right:l?.left??i.left+.55*n}}function Xf(e,t,n,o,r,a,i){const l=_f(e,t,n.fontSize??14.6667);return l?{x:Bo(o+l.left),y:Bo(r+e.top+a),width:Bo(Math.max(0,l.right-l.left)),height:Bo(Math.max(2,e.height-i))}:null}function Gf(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=_f(n,o,i.fontSize??14.6667);if(!s)return;const c=r+s.left,d=r+s.right,u=a+n.top,p=a+n.top+n.height,g=ue(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:Bo(g.x0),y0:Bo(g.y0),x1:Bo(g.x1),y1:Bo(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function Yf(e,t,n,o,r,a,i){const l=At(i),s=(r,i)=>{e.drawLine(t,{x1:Bo(n),y1:Bo(r),x2:Bo(o),y2:Bo(r),stroke:a,lineWidth:Bo(l),dashArray:i})};if(Ie(i))return s(r-ye),void s(r+ye);rt(i)?function(e,t,n,o,r,a,i){let l=n,s=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*re;e.drawLine(t,{x1:Bo(l),y1:Bo(s),x2:Bo(c),y2:Bo(o),stroke:a,lineWidth:Bo(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,p(i))}function qf(e,t){const n=Zt(e);if(!n)return e;const o=Math.max(0,Math.min(1,t));return _t(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function Zf(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=Bo(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:Bo(t)+u*e,y:Bo(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*Bo(e.radiusPt*yn),l=qf(e.color,.4*(e.alpha??.5)),s=[[i,0],[-i,0],[0,i],[0,-i],[.7*i,.7*i],[.7*-i,.7*i],[.7*i,.7*-i],[.7*-i,.7*-i]];for(const[c,u]of s)o.drawText(r,{...d,x:Bo(t)+c,y:Bo(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=Bo(e.distPt*yn);o.drawText(r,{...d,x:Bo(t)+Math.cos(i)*l,y:Bo(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:Bo(t)+u,y:Bo(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=qf(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:Bo(t),y:Bo(a)+Bo(e.distPt*yn)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:Bo(t),y:Bo(a),text:n,color:l,...s?{gradientShadingName:s}:p?{renderMode:2,strokeColor:p.color??l,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function Jf(e){for(const t of e.lines){const n=new Map(t.slots.map(e=>[e.offset,e]));for(const o of t.fragments){const r=o.image;if(!r?.floating)continue;const a=Boolean(r.floating.behindDoc);if("behind"===e.layer!==a)continue;const i=n.get(o.startOffset),l=ar({object:$n(r),pageSettings:e.pageSettings,contentLeft:e.contentLeft,contentTop:e.contentTop,contentWidth:e.contentWidth,paragraphTop:e.paragraphTop,lineTop:e.paragraphTop+t.top,anchorLeft:e.contentLeft+(i?.left??0)});await Vf(e.writer,e.pageIndex,e.document,r,Bo(l.x),Bo(l.y),Bo(l.width),Bo(l.height))}}}function Qf(e,t,n,o,r,a,i,l){const s=_f(n,o,i.fontSize??14.6667);if(!s)return;const c=a+cr(l,n.top,n.height),d=r+s.left,u=r+s.right,p="underline"===l?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==l)return"doubleStrike"===l?(e.drawLine(t,{x1:Bo(d),y1:Bo(c-K),x2:Bo(u),y2:Bo(c-K),stroke:p,lineWidth:Bo(1)}),void e.drawLine(t,{x1:Bo(d),y1:Bo(c+K),x2:Bo(u),y2:Bo(c+K),stroke:p,lineWidth:Bo(1)})):void Yf(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:Bo(d),y1:Bo(c),x2:Bo(u),y2:Bo(c),stroke:p,lineWidth:Bo(1)})}async function em(e,t,n,o,r,a,i,l,s,c){if(r.image){if(r.image.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await Vf(e,t,a,r.image,Bo(i+n.left),Bo(l+o.top+o.height-r.image.height),Bo(r.image.width),Bo(r.image.height)))}if(r.textBox){if(r.textBox.floating)return;const n=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!n)return;return void(await $f(e,r.textBox,{document:a,fontRegistry:s,pageIndex:t},i+n.left,l+o.top+o.height-r.textBox.height,r.textBox.width,r.textBox.height,c))}if(r.math){const c=o.slots.find(e=>e.offset===r.startOffset)??o.slots.find(e=>e.offset>=r.startOffset);if(!c)return;const d=Xe(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:Bo(i+c.left),y:Bo(l+o.top+o.height*qe),text:wt(r.math),fontSize:Mr(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=Xe(r.styles,n.style?.styleId,a.styles);if(d.hidden)return;const u=s.resolveFontFace({fontFamily:d.fontFamily,bold:d.bold,italic:d.italic}),p=Mr(d),g=(d.baselineShift??0)*yn,f=De(n.style,a.styles),m=le(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*qe-g+m,b=Kf(o,r),y=b.map(e=>Ro(e.char,d)).join("");if(!b[0]||0===y.length)return;!function(e,t,n,o,r,a,i){if(!i.link)return;const l=_f(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:Bo(r+l.left),y:Bo(a+n.top),width:Bo(l.right-l.left),height:Bo(n.height),...s?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.shading)return;const l=Xf(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.shading})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){if(!i.highlight)return;const l=Xf(n,o,i,r,a,2,4);l&&e.drawRect(t,{...l,fill:i.highlight})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i){const l=i.textBorder;if(!l||"none"===l.type||l.width<=0)return;const s=Xf(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:Bo(Math.max(.5,l.width*yn))})}(e,t,o,r,i,l,d),function(e,t,n,o,r,a,i,l,s){const c=new Map(o.slots.map(e=>[e.offset,e])),d=De(n.style,a.styles).tabs??[];for(const u of r.chars){if("\t"!==u.char)continue;const n=c.get(u.paragraphOffset),r=c.get(u.paragraphOffset+1);if(!n||!r)continue;const a=o.slots[0]?.left??0,p=n.left-a,g=d.filter(e=>"clear"!==e.type).map(e=>({...e,positionPx:e.position*yn})).filter(e=>e.positionPx>p+.01).sort((e,t)=>e.positionPx-t.positionPx)[0],f=g?.leader&&"none"!==g.leader?g.leader:void 0;if(!f)continue;const m="underscore"===f?l+2:l;e.drawLine(t,{x1:Bo(i+n.left),y1:Bo(m),x2:Bo(i+r.left),y2:Bo(m),stroke:s,lineWidth:Bo("heavy"===f?1.5:1),dashArray:"dot"===f||"middleDot"===f?[1,3]:"hyphen"===f?[5,3]:void 0})}}(e,t,n,o,r,a,i,h,d.color??"#000000");const v=De(n.style,a.styles).align??"left",x=pa(d,Mr(d)),w={fontSize:p,bold:d.bold,italic:d.italic,fontResourceName:u.writerResourceName,characterSpacing:d.characterSpacing??0,horizontalScale:d.characterScale??100,fontFeatures:x};!function(e,t,n,o,r,a,i){const l="justify"===i?function(e){const t=[];let n=[];for(const o of e)" "!==o.char?n.push(o):n.length>0&&(t.push(n),n=[]);return n.length>0&&t.push(n),t}(t):function(e){const t=[];let n=[];for(const o of e){const e=n[n.length-1];e&&o.offset>e.offset+1&&(t.push(n),n=[]),n.push(o)}return n.length>0&&t.push(n),t}(t);for(const s of l){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>Ro(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;Zf({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&Ke(e.char));t.length>0&&n!==r&&a(),r=n,t.push(e)}a()}if(r.trailingHyphen&&a.endOffset>=r.endOffset){const t=r.slots.find(e=>e.offset===r.endOffset)??r.slots[r.slots.length-1];t&&Zf(e,n+t.left,"-")}}({writer:e,pageIndex:t,baselineY:h,fontSizePt:p,mainColor:"solid"===d.textFill?.type?d.textFill.color:"gradient"===d.textFill?.type&&d.textFill.stops[0]?d.textFill.stops[0].color:d.color??"#000000",gradientShadingName:Gf(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&Qf(e,t,o,r,i,l,d,"underline"),d.strike&&Qf(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&Qf(e,t,o,r,i,l,d,"doubleStrike"),d.emphasisMark&&function(e,t,n,o,r,a,i){const l=i.emphasisMark;if(!l||"none"===l)return;const s=N[l];if(!s)return;const c=Kf(n,o),d="underDot"===l,u=Math.max(4,.35*n.height),p=d?a+n.top+n.height+u:a+n.top+u;for(let g=0;g<c.length;g+=1){const o=c[g];if(" "===o.char||"\t"===o.char||"\n"===o.char)continue;const a=c[g+1],l=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:Bo(r+l-.25*u),y:Bo(p),text:s,fontSize:Bo(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function tm(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=Sn(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=Xe(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=Gr(n,r.styles),f=Mr(u),m=c.length*f*.62*yn,h=S(n,r.styles,d.left,m);e.drawText(t,{x:Bo(a+Math.max(0,h||g)),y:Bo(i+o.top+o.height*qe),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function nm(e,t,n,o,r,a,i){const l=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],s=l.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!s)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=Pe(n),u=d.top+c+d.bottom,p=r+(n.indentLeft??0),g=r+i-(n.indentRight??0),f=a+u;n.shading&&e.drawRect(t,{x:Bo(p),y:Bo(a),width:Bo(Math.max(0,g-p)),height:Bo(u),fill:n.shading});for(const[h,b]of l){if(!h||"none"===h.type||h.width<=0)continue;const[n,o,r,i]="top"===b?[p,a,g,a]:"bottom"===b?[p,f,g,f]:"left"===b?[p,a,p,f]:[g,a,g,f];e.drawLine(t,{x1:Bo(n),y1:Bo(o),x2:Bo(r),y2:Bo(i),stroke:h.color,lineWidth:h.width,dashArray:Nf(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:Bo(p),y1:Bo(a),x2:Bo(p),y2:Bo(f),stroke:m.color,lineWidth:m.width,dashArray:Nf(m.type)})}async function om(e,t,n,o,r,a,i,l,s,c){for(const d of o){tm(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await em(e,t,n,d,o,r,a,i,l,c)}}function rm(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:Bo(o),y1:Bo(r),x2:Bo(a),y2:Bo(i),stroke:n.color,lineWidth:Bo(n.width),dashArray:Nf(n.type)})}function am(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;rm(e,t,n.borders.top,a,i,l,i),rm(e,t,n.borders.right,l,i,l,s),rm(e,t,n.borders.bottom,a,s,l,s),rm(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&rm(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&rm(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function im(e,t,n,o,r,a,i,l,s,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?Qt(d,n.tableSegment):d;if(0===u.rows.length)return;const p=Un({table:u,state:{document:o},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:n.estimatedHeight});for(const g of p.cells)g.shading&&e.drawRect(t,{x:Bo(r+g.left),y:Bo(a+g.top),width:Bo(g.width),height:Bo(g.height),fill:g.shading});for(const g of p.cells)if(am(e,t,g,r,a),g.revision){const n="insert"===g.revision.type?"#059669":"delete"===g.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:Bo(r+g.left+1),y:Bo(a+g.top+1),width:Bo(Math.max(0,g.width-2)),height:Bo(Math.max(0,g.height-2)),stroke:n,lineWidth:Bo(2)})}for(const g of p.cells)for(const n of g.paragraphs)await om(e,t,n.paragraph,n.lines,o,r+n.originX,a+n.originY,l,s,c)}var lm={drawParagraph:om,drawTableBlock:im};async function sm(e,n,o,r,a,i,l,s,c,d,u){if(!o||0===o.length)return;const p=i;let g=i;for(let f=0;f<o.length;f+=1){const m=o[f];switch(m.sourceBlock.type){case"paragraph":{if(!m.layout)break;const t=De(m.sourceBlock.style,r.styles),o=g+(0===m.layout.startOffset&&g>i?t.spacingBefore??0:0);u?.(m.sourceBlock.id,o);const f=o+Pe(t).top;nm(e,n,t,m.layout.lines,a,o,l),d&&(await Jf({writer:e,pageIndex:n,lines:m.layout.lines,document:r,pageSettings:d,contentLeft:a,contentTop:p,contentWidth:l,paragraphTop:f,layer:"behind"}),await zf({writer:e,document:r,fontRegistry:s,pageIndex:n,lines:m.layout.lines,pageSettings:d,contentLeft:a,contentTop:p,contentWidth:l,paragraphTop:o,drawers:lm,layer:"behind"})),await om(e,n,m.sourceBlock,m.layout.lines,r,a,f,s,c,lm),d&&(await Jf({writer:e,pageIndex:n,lines:m.layout.lines,document:r,pageSettings:d,contentLeft:a,contentTop:p,contentWidth:l,paragraphTop:f,layer:"front"}),await zf({writer:e,document:r,fontRegistry:s,pageIndex:n,lines:m.layout.lines,pageSettings:d,contentLeft:a,contentTop:p,contentWidth:l,paragraphTop:o,drawers:lm,layer:"front"}));break}case"table":if(m.sourceBlock.style?.floating&&d){const t=Br(m.sourceBlock,l),o=Ho({floating:m.sourceBlock.style.floating,pageSettings:d,contentLeft:a,contentTop:p,contentWidth:l,anchorTop:g,width:t,height:m.floatingTableHeight??1,pageIndex:n});o.y+=m.floatingTableOffsetY??0,await im(e,n,{...m,estimatedHeight:o.height},r,o.x,o.y,l,s,c,lm);break}await im(e,n,m,r,a,g,l,s,c,lm);break;default:t(m.sourceBlock,"block")}if("paragraph"===m.sourceBlock.type&&m.layout){const t=o[f+1];if("paragraph"===t?.sourceBlock.type&&t.layout&&t.sourceBlock.id!==m.sourceBlock.id){const o=De(m.sourceBlock.style,r.styles),s=De(t.sourceBlock.style,r.styles);if(lt(o,s)){const t=g+(0===m.layout.startOffset&&g>i?o.spacingBefore??0:0)+Pe(o).top;let r=0;for(const e of m.layout.lines)r=Math.max(r,e.top+e.height);const s=t+r,c=a+(o.indentLeft??0),d=a+l-(o.indentRight??0),u=o.borderBetween;e.drawLine(n,{x1:Bo(c),y1:Bo(s),x2:Bo(d),y2:Bo(s),stroke:u.color,lineWidth:u.width,dashArray:Nf(u.type)})}}}g+=Math.max(0,m.estimatedHeight)}}async function cm(e,t,n,o,r,a,i){if(e.drawRect(t,{x:0,y:0,width:n,height:o,fill:r?.pageColor||"#ffffff"}),a){const r=a.distance??12,i="dashed"===a.style?[6,4]:"dotted"===a.style?[1,3]:void 0;if(e.drawRect(t,{x:r,y:r,width:n-2*r,height:o-2*r,fill:void 0,stroke:a.color,lineWidth:a.width,...i?{dashArray:i}:{}}),"double"===a.style){const i=r+2*a.width;e.drawRect(t,{x:i,y:i,width:n-2*i,height:o-2*i,stroke:a.color,lineWidth:a.width})}}const l=r?.watermark;if("text"===l?.kind&&l.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:l.text,fontSize:l.fontSize??48,color:l.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===l?.kind&&l.src&&i){const r={src:l.src,width:360,height:180},a=await jf(e,i,r);if(a){const i=l.scale??1,s=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,l.rotation??-45),e.setOpacity(t,l.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-s)/2,y:(o-c)/2,width:s,height:c}),e.restoreGraphicsState(t)}}}var dm=[{key:"helvetica:regular",family:"Helvetica",bold:!1,italic:!1,writerResourceName:"F1",pdfResource:{kind:"base14",resourceName:"F1",baseFont:"Helvetica"}},{key:"helvetica:bold",family:"Helvetica",bold:!0,italic:!1,writerResourceName:"F2",pdfResource:{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"}},{key:"helvetica:italic",family:"Helvetica",bold:!1,italic:!0,writerResourceName:"F3",pdfResource:{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"}},{key:"helvetica:bolditalic",family:"Helvetica",bold:!0,italic:!0,writerResourceName:"F4",pdfResource:{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}}];function um(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function pm(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var gm=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of dm)this.registerFontFace(e)}registerFontFace(e){this.faces.set(um(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=X(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(um(t,n,o))??this.faces.get(um(this.fallbackFamily,n,o))??this.faces.get(um(this.fallbackFamily,!1,!1))}getPdfFontResources(){const e=/* @__PURE__ */new Map;for(const t of this.faces.values())e.set(t.pdfResource.resourceName,t.pdfResource);return Array.from(e.values())}async loadBundledUnicodeFaces(e={}){const t=e.families?new Set(Array.from(e.families).map(X).map(e=>e.toLowerCase())):null,n=await this.registerOfficeCompatibleFaces(t);if(!t||t.has("roboto")||Array.from(t).some(e=>"helvetica"!==e&&!n.has(e)))for(const[o,r]of Object.entries(Rt)){const e=await Ut(r);if(!e)continue;const t="bold"===o||"bolditalic"===o,n="italic"===o||"bolditalic"===o,a=`Roboto${o[0].toUpperCase()}${o.slice(1)}`;this.registerFontFace({key:`roboto:${o}`,family:"Roboto",bold:t,italic:n,writerResourceName:a,pdfResource:{kind:"unicode",resourceName:a,family:"Roboto",fontData:e}}),this.fallbackFamily="Roboto"}}async loadRemoteWebFontFaces(e={}){if(!e.families)return;const t=await c(e.families);for(const n of t){const e=`Remote${pm(n.postscriptName||n.family)}`;this.registerFontFace({key:um(n.family,n.bold,n.italic),family:n.family,bold:n.bold,italic:n.italic,writerResourceName:e,pdfResource:{kind:"unicode",resourceName:e,family:n.family,fontData:n.fontData,postscriptName:n.postscriptName}})}}async registerOfficeCompatibleFaces(e){const t=/* @__PURE__ */new Set;for(const n of ee){const o=[n.family,...n.aliases].map(e=>e.toLowerCase());if(e&&!o.some(t=>e.has(t)))continue;for(const e of o)t.add(e);const r=[];for(const[e,t]of Object.entries(n.files)){const o=await Ut(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${pm(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,s={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:l,pdfResource:{kind:"unicode",resourceName:l,family:n.family,fontData:o}};this.registerFontFace(s),r.push(s)}for(const e of n.aliases)for(const t of r)this.registerFontFace({...t,key:`${e.toLowerCase()}:${t.key.split(":")[1]}`,family:e})}return t}},fm="%PDF-1.4\n% Oasis PDF\n",mm=[{kind:"base14",resourceName:"F1",baseFont:"Helvetica"},{kind:"base14",resourceName:"F2",baseFont:"Helvetica-Bold"},{kind:"base14",resourceName:"F3",baseFont:"Helvetica-Oblique"},{kind:"base14",resourceName:"F4",baseFont:"Helvetica-BoldOblique"}];function hm(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function bm(e){return(new TextEncoder).encode(e).byteLength}function ym(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function vm(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function xm(e,t){if(!e)return t;const n=Zt(e);return n?[n[0]/255,n[1]/255,n[2]/255]:t}function wm(e,t,n){const[o,r,a]=xm(e,n);return`${hm(o)} ${hm(r)} ${hm(a)} ${t}`}function Sm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var Im=/* @__PURE__ */new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]);function Cm(e){return Array.from(e).map(e=>function(e){const t=e.codePointAt(0)??63;return t>=32&&t<=126||t>=160&&t<=255?t:Im.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function Tm(e){const t=[];for(let n of e)n>65535?(n-=65536,t.push(n>>>10&1023|55296),t.push(1023&n|56320)):t.push(n);return t.map(vm).join("")}function Pm(e){return vm(e)}function km(e){return`% OasisText ${Tm(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function Rm(e){return e&&0!==e.length?`[${e.map(e=>hm(e)).join(" ")}] 0 d`:null}var Bm=class{page;fonts;images;shadings;constructor(e,t,n,o){this.page=e,this.fonts=t,this.images=n,this.shadings=o}registerAxialGradient(e){const t=this.shadings.register({x0:e.x0,y0:this.page.height-e.y0,x1:e.x1,y1:this.page.height-e.y1,stops:e.stops});return this.page.shadingResourceNames.add(t),t}drawRect(e){const t=this.page;if(e.width<=0||e.height<=0)return;const n=["q"];if(e.fill&&n.push(wm(e.fill,"rg",[1,1,1])),e.stroke){n.push(wm(e.stroke,"RG",[0,0,0])),n.push(`${hm(e.lineWidth??1)} w`);const t=Rm(e.dashArray);t&&n.push(t)}n.push([hm(e.x),hm(t.height-e.y-e.height),hm(e.width),hm(e.height),"re"].join(" ")),e.fill&&e.stroke?n.push("B"):e.fill?n.push("f"):e.stroke&&n.push("S"),n.push("Q"),t.commands.push(n.join("\n"))}drawLine(e){const t=this.page,n=Rm(e.dashArray),o=["q",wm(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${hm(e.lineWidth??1)} w`,`${hm(e.x1)} ${hm(t.height-e.y1)} m`,`${hm(e.x2)} ${hm(t.height-e.y2)} l`,"S","Q"),t.commands.push(o.join("\n"))}drawPath(e){const t=this.page;if(0===e.segments.length)return;if(!e.fill&&!e.stroke)return;const n=e=>t.height-e,o=["q"];e.fill&&o.push(wm(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(wm(e.stroke,"RG",[0,0,0])),o.push(`${hm(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${hm(r.x)} ${hm(n(r.y))} m`);break;case"line":o.push(`${hm(r.x)} ${hm(n(r.y))} l`);break;case"cubic":o.push(`${hm(r.x1)} ${hm(n(r.y1))} ${hm(r.x2)} ${hm(n(r.y2))} ${hm(r.x)} ${hm(n(r.y))} c`);break;case"close":o.push("h")}e.fill&&e.stroke?o.push("B"):e.fill?o.push("f"):o.push("S"),o.push("Q"),t.commands.push(o.join("\n"))}saveGraphicsState(){this.page.commands.push("q")}restoreGraphicsState(){this.page.commands.push("Q")}setOpacity(e){const t=Math.max(0,Math.min(1,e)),n=`GSOpacity${Math.round(100*t)}`;(this.page.graphicsStateOpacities??=/* @__PURE__ */new Map).set(n,t),this.page.commands.push(`/${n} gs`)}rotateAbout(e,t,n){const o=this.page;if(!n)return;const r=o.height-t,a=-n*Math.PI/180,i=Math.cos(a),l=Math.sin(a),s=e-e*i+r*l,c=r-e*l-r*i;o.commands.push(`${hm(i)} ${hm(l)} ${hm(-l)} ${hm(i)} ${hm(s)} ${hm(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${hm(e)} ${hm(r.height-t-o)} ${hm(n)} ${hm(o)} re`,"W","n")}clipPath(e){const t=this.page;if(0===e.length)return;const n=e=>t.height-e,o=[];for(const r of e)switch(r.type){case"move":o.push(`${hm(r.x)} ${hm(n(r.y))} m`);break;case"line":o.push(`${hm(r.x)} ${hm(n(r.y))} l`);break;case"cubic":o.push(`${hm(r.x1)} ${hm(n(r.y1))} ${hm(r.x2)} ${hm(n(r.y2))} ${hm(r.x)} ${hm(n(r.y))} c`);break;case"close":o.push("h")}o.push("W","n"),t.commands.push(o.join("\n"))}drawText(e){if(0===e.text.length)return;const t=this.fonts.resolveAndMarkFontName(e),n=this.fonts.getUnicodeState(t),o=n?this.fonts.buildUnicodeShowCommand(n,e.text,e.fontFeatures):`<${Cm(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${hm(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${hm(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${hm(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([km(n.text),"BT",wm(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[wm(n.strokeColor??n.color,"RG",[0,0,0]),`${hm(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${hm(n.x)} ${hm(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([km(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${hm(n.x)} ${hm(r.height-n.y)} Td`,t,"ET",`/${o} sh`,"Q"].join("\n"))}drawImage(e){const t=this.page;if(e.width<=0||e.height<=0||!this.images.has(e.resourceName))return;t.imageResourceNames.add(e.resourceName);const n=t.height-e.y-e.height,o=Number.isFinite(e.rotation)?e.rotation??0:0,r=e.crop,a=r?.left??0,i=r?.top??0,l=r?.right??0,s=r?.bottom??0;if(r&&(a>0||i>0||l>0||s>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:l,bottom:s});if(0===o)return void t.commands.push(["q",[hm(e.width),"0","0",hm(e.height),hm(e.x),hm(n),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"));const c=-o*Math.PI/180,d=Math.cos(c),u=Math.sin(c),p=e.width*d,g=e.width*u,f=-e.height*u,m=e.height*d,h=e.x+e.width/2-.5*p-.5*f,b=n+e.height/2-.5*g-.5*m;t.commands.push(["q",[hm(p),hm(g),hm(f),hm(m),hm(h),hm(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,l=a/Math.max(1e-4,1-o.left-o.right),s=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*l,d=-o.bottom*s,u=-n*Math.PI/180,p=Math.cos(u),g=Math.sin(u),f=a/2,m=i/2,h=p,b=g,y=-g,v=p,x=e.x+a/2-(h*f+y*m),w=t+i/2-(b*f+v*m);r.commands.push(["q",[hm(h),hm(b),hm(y),hm(v),hm(x),hm(w),"cm"].join(" "),`0 0 ${hm(a)} ${hm(i)} re W n`,[hm(l),"0","0",hm(s),hm(c),hm(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function Mm(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function Fm(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function Am(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function Om(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=/* @__PURE__ */new Map;for(let o=0;o<t;o+=1)n.set(e.u16(),o);return e=>n.get(e)??-1}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,startIndex:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.startIndex+(e-t.start);return-1}}return()=>-1}function Dm(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=Fm(e,n);return e=>{const r=e-t;return r>=0&&r<n?o[r]:0}}if(2===n){const t=e.u16(),n=[];for(let o=0;o<t;o+=1){const t=e.u16(),o=e.u16(),r=e.u16();n.push({start:t,end:o,classValue:r})}return e=>{for(const t of n)if(e>=t.start&&e<=t.end)return t.classValue;return 0}}return()=>0}function Em(e){e.seek(0),e.skip(2),e.skip(2);const t=e.u16(),n=e.u16(),o=e.u16(),r=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let r=0;r<n;r+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}return o.map(({tag:t,offset:n})=>(e.seek(n),e.skip(2),{tag:t,lookupIndices:Fm(e,e.u16())}))}(e,n),a=function(e,t){e.seek(t);const n=e.u16(),o=[];for(let c=0;c<n;c+=1){const n=e.tag(),r=t+e.u16();o.push({tag:n,offset:r})}if(0===o.length)return[];const r=o.find(e=>"latn"===e.tag)??o.find(e=>"DFLT"===e.tag)??o[0];e.seek(r.offset);const a=e.u16();if(0===a)return[];e.seek(r.offset+a),e.skip(2);const i=e.u16(),l=e.u16(),s=[];65535!==i&&s.push(i);for(let c=0;c<l;c+=1)s.push(e.u16());return s}(e,t),i=/* @__PURE__ */new Map;for(const l of a){const e=r[l];if(!e)continue;const t=i.get(e.tag)??[];for(const n of e.lookupIndices)t.includes(n)||t.push(n);i.set(e.tag,t)}return{featureToLookups:i,lookupListOffset:o}}function Lm(e,t,n){return e.seek(t),Am(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=Am(e,e.u16(),t),a=[];for(const i of r)try{const t=n(e,i,o);t&&a.push(t)}catch{}return{lookupType:o,subtables:a}})}function Nm(e,t){const n=/* @__PURE__ */new Set;for(const o of t)for(const t of e.get(o)??[])n.add(t);return Array.from(n).sort((e,t)=>e-t)}function $m(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=Am(e,o,t).map(t=>(e.seek(t),Fm(e,e.u16())));return{coverage:Om(e,n),sets:r}}function zm(e,t){const n=new Array(t);for(let o=0;o<t;o+=1){const t=e.u16(),r=e.u16();n[o]={sequenceIndex:t,lookupListIndex:r}}return n}function Hm(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function Wm(e,t){e.seek(t);const n=e.u16();return Am(e,n,t).map(t=>(e.seek(t),{backtrack:Fm(e,e.u16()),input:Fm(e,Math.max(0,e.u16()-1)),lookahead:Fm(e,e.u16()),records:zm(e,e.u16())}))}function Um(e,t,n,o,r){const a=(e,n)=>{const o=t[e];return o?r?"b"===n?r.backtrack(o.id):"l"===n?r.lookahead(o.id):r.input(o.id):o.id:null};for(const i of e){const e=i.input.length+1;if(n+e>t.length)continue;let r=!0;for(let t=0;t<i.input.length;t+=1)if(a(n+1+t,"i")!==i.input[t]){r=!1;break}if(r){for(let e=0;e<i.backtrack.length;e+=1)if(a(n-1-e,"b")!==i.backtrack[e]){r=!1;break}if(r){for(let t=0;t<i.lookahead.length;t+=1)if(a(n+e+t,"l")!==i.lookahead[t]){r=!1;break}if(r)return Hm(t,n,i.records,o),e}}}return null}function jm(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=e.i16(),n=Om(e,o);return{apply(e,o){const r=e[o];return!r||n(r.id)<0?null:(r.id=r.id+t&65535,1)}}}if(2===n){const t=e.u16(),n=Fm(e,t),r=Om(e,o);return{apply(e,o){const a=e[o];if(!a)return null;const i=r(a.id);return i<0||i>=t?null:(a.id=n[i],1)}}}return null}(e,t);case 2:return function(e,t){const n=$m(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];if(0===i.length)return null;const l=n.codePoints,s=i.map((e,t)=>({id:e,codePoints:0===t?l:[]}));return e.splice(t,1,...s),i.length}}}(e,t);case 3:return function(e,t){const n=$m(e,t);if(!n)return null;const{coverage:o,sets:r}=n;return{apply(e,t){const n=e[t];if(!n)return null;const a=o(n.id);if(a<0||a>=r.length)return null;const i=r[a];return 0===i.length?null:(n.id=i[0],1)}}}(e,t);case 4:return function(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=Am(e,o,t).map(t=>(e.seek(t),Am(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:Fm(e,Math.max(0,o-1))}}))),a=Om(e,n);return{apply(e,t){const n=e[t];if(!n)return null;const o=a(n.id);if(o<0||o>=r.length)return null;for(const a of r[o]){const{components:n}=a;if(t+n.length>e.length-1)continue;let o=!0;for(let a=0;a<n.length;a+=1)if(e[t+1+a].id!==n[a]){o=!1;break}if(!o)continue;const r=n.length+1,i=[];for(let a=0;a<r;a+=1)i.push(...e[t+a].codePoints);return e.splice(t,r,{id:a.ligatureGlyph,codePoints:i}),1}return null}}}(e,t);case 6:return function(e,t){e.seek(t);const n=e.u16();if(3===n){const n=Am(e,e.u16(),t),o=Am(e,e.u16(),t),r=Am(e,e.u16(),t),a=zm(e,e.u16()),i=n.map(t=>Om(e,t)),l=o.map(t=>Om(e,t)),s=r.map(t=>Om(e,t));return{apply(e,t,n){if(0===l.length)return null;if(t+l.length>e.length)return null;for(let o=0;o<l.length;o+=1)if(l[o](e[t+o].id)<0)return null;for(let o=0;o<i.length;o+=1){const n=e[t-1-o];if(!n||i[o](n.id)<0)return null}for(let o=0;o<s.length;o+=1){const n=e[t+l.length+o];if(!n||s[o](n.id)<0)return null}return Hm(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=Am(e,o,t),a=Om(e,n),i=r.map(t=>Wm(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;const r=a(o.id);return r<0||r>=i.length?null:Um(i[r],e,t,n,null)}}}if(2===n){const n=t+e.u16(),o=t+e.u16(),r=t+e.u16(),a=t+e.u16(),i=e.u16(),l=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();l[g]=0===n?0:t+n}const s=Om(e,n),c=Dm(e,o),d=Dm(e,r),u=Dm(e,a),p=l.map(t=>0===t?[]:Wm(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(s(o.id)<0)return null;const r=d(o.id),a=p[r];return a?Um(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return Mm(e,t,jm);default:return null}}var Vm=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new $e(t),{featureToLookups:o,lookupListOffset:r}=Em(n),a=Lm(n,r,jm);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return Nm(this.featureToLookups,e)}applyLookupIndexAt(e,t,n){const o=this.lookups[e];if(!o||n<0||n>=t.length)return null;for(const r of o.subtables){const e=r.apply(t,n,this);if(null!==e)return e}return null}shape(e,t){const n=this.collectLookupIndices(t);for(const o of n){let t=0;for(;t<e.length;){const n=this.applyLookupIndexAt(o,e,t);t+=n&&n>0?n:1}}}};function Km(e,t){let n=0;return 1&t&&e.i16(),2&t&&e.i16(),4&t&&(n=e.i16()),8&t&&e.i16(),16&t&&e.u16(),32&t&&e.u16(),64&t&&e.u16(),128&t&&e.u16(),n}function _m(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function Xm(e,t,n){switch(n){case 1:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16();if(1===n){const t=Km(e,e.u16()),n=Om(e,o);return 0===t?null:{apply:(e,o,r)=>n(e[r])<0?null:(o[r]+=t,1)}}if(2===n){const t=e.u16(),n=e.u16(),r=_m(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=Km(e,t);const l=Om(e,o);return{apply(e,t,o){const r=l(e[o]);if(r<0||r>=n)return null;const a=i[r];return 0===a?null:(t[o]+=a,1)}}}return null}(e,t);case 2:return function(e,t){e.seek(t);const n=e.u16(),o=t+e.u16(),r=e.u16(),a=e.u16(),i=!!(4&a);if(1===n){const n=e.u16(),l=Am(e,n,t).map(t=>{e.seek(t);const n=e.u16(),o=/* @__PURE__ */new Map;for(let i=0;i<n;i+=1){const t=e.u16(),n=Km(e,r),i=Km(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=Om(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=s(e[n]);if(r<0||r>=l.length)return null;const a=l[r].get(o);return a?(t[n]+=a.value1XAdvance,t[n+1]+=a.value2XAdvance,i?2:1):null}}}if(2===n){const n=t+e.u16(),l=t+e.u16(),s=e.u16(),c=e.u16(),d=_m(r),u=d+_m(a),p=e.tell(),g=new Array(s*c),f=new Array(s*c);for(let t=0;t<s;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=Km(e,r),e.seek(p+o+d),f[t*c+n]=Km(e,a)}const m=Om(e,o),h=Dm(e,n),b=Dm(e,l);return{apply(e,t,n){const o=e[n],r=e[n+1];if(void 0===r)return null;if(m(o)<0)return null;const a=h(o),l=b(r);if(a>=s||l>=c)return null;const d=a*c+l,u=g[d],p=f[d];return 0===u&&0===p?null:(t[n]+=u,t[n+1]+=p,i?2:1)}}}return null}(e,t);case 9:return Mm(e,t,Xm);default:return null}}var Gm=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new $e(t),{featureToLookups:o,lookupListOffset:r}=Em(n),a=Lm(n,r,Xm);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=Nm(this.featureToLookups,n);for(const r of o){const n=this.lookups[r];if(!n)continue;let o=0;for(;o<e.length;){let r=null;for(const a of n.subtables)if(r=a.apply(e,t,o),null!==r)break;o+=r&&r>0?r:1}}}},Ym=/* @__PURE__ */new Set(["kern"]),qm=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?Vm.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?Gm.parse(n):null}get hasGsub(){return null!==this.gsub}get hasGpos(){return null!==this.gpos}get hasShaping(){return null!==this.gsub||null!==this.gpos}layout(e,t){const n=[];for(const c of e){const e=c.codePointAt(0)??65533,t=this.font.glyphForCodePoint(e);n.push({id:t,codePoints:0===t?[65533]:[e]})}const o=t?.filter(e=>!Ym.has(e))??[],r=t?.filter(e=>Ym.has(e))??[];this.gsub&&o.length>0&&this.gsub.shape(n,o);const a=n.map(e=>this.font.advanceWidthForGlyph(e.id));this.gpos&&r.length>0&&this.gpos.position(n.map(e=>e.id),a,r);const i=[],l=[];let s=0;for(let c=0;c<n.length;c+=1){const e=n[c],t=this.font.advanceWidthForGlyph(e.id),o=a[c];i.push({id:e.id,codePoints:e.codePoints,advanceWidth:t}),l.push({xAdvance:o}),s+=o}return{glyphs:i,positions:l,advanceWidth:s}}},Zm=class{font;constructor(e){this.font=e}layout(e){const t=[],n=[];let o=0;for(const r of e){const e=r.codePointAt(0)??65533,a=this.font.glyphForCodePoint(e),i=this.font.advanceWidthForGlyph(a);t.push({id:a,codePoints:0===a?[65533]:[e],advanceWidth:i}),n.push({xAdvance:i}),o+=i}return{glyphs:t,positions:n,advanceWidth:o}}};function Jm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Qm(e,t){return Jm(e).getUint16(t)}function eh(e,t,n){Jm(e).setUint16(t,n,!1)}function th(e,t,n){Jm(e).setUint32(t,n,!1)}function nh(e){return e+3&-4}function oh(e){const t=e.reduce((e,t)=>e+nh(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=nh(r.byteLength);return n}function rh(e,t){const n=[],o=Jm(e);if(0===t)for(let r=0;r+1<e.byteLength;r+=2)n.push(2*o.getUint16(r));else for(let r=0;r+3<e.byteLength;r+=4)n.push(o.getUint32(r));return n}function ah(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function ih(e,t){if(e.byteLength<10||function(e,t){return Jm(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=Qm(e,n),t(Qm(e,n+2)),n+=4,n+=1&o?4:2,8&o?n+=2:64&o?n+=4:128&o&&(n+=8)}while(32&o)}function lh(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>th(t,4*n,e)),t}function sh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)eh(n,4*o,e.advanceWidthForGlyph(o)),eh(n,4*o+2,0);return n}var ch=class{createSubset(e,t){const n=/* @__PURE__ */new Map,o=[];for(const d of t)o.push(d.id),n.has(d.id)||n.set(d.id,d.codePoints);const r=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head");if(!n||!o||!r)return Array.from(/* @__PURE__ */new Set([0,...t])).sort((e,t)=>e-t);const a=rh(o,Qm(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=ah(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||ih(n.slice(e.start,e.end),e=>{i.has(e)||(i.add(e),l.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=function(e,t){const n=e.getRawTableData("glyf"),o=e.getRawTableData("loca"),r=e.getRawTableData("head"),a=e.getRawTableData("hhea"),i=e.getRawTableData("maxp"),l=e.getRawTableData("cmap");if(!(n&&o&&r&&a&&i&&l))throw new Error("Missing required TrueType tables for subsetting");const s=Math.max(0,...t),c=new Set(t),d=rh(o,Qm(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=ah(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=nh(t.byteLength)}}u.push(g);const f=r.slice();th(f,8,0),eh(f,50,1);const m=a.slice();eh(m,34,s+1);const h=i.slice();eh(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:sh(e,s),loca:lh(u),maxp:h,glyf:oh(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=ur(65536,new Map(Object.entries(a).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,l=Math.max(0,...r),s=[],c=[];for(let d=0;d<=l;d+=1)s[d]=e.advanceWidthForGlyph(d)/e.unitsPerEm*1e3,c[d]=n.get(d)??[0];return{fontFile:i,widths:s,unicode:c,encodeGlyph:e=>e}}};var dh=class{fontResources=/* @__PURE__ */new Map;unicodeFontStates=/* @__PURE__ */new Map;usedFontResourceNames=/* @__PURE__ */new Set;constructor(e){for(const t of e)this.registerFontResource(t)}registerFontResource(e){if(this.fontResources.set(e.resourceName,e),"unicode"===e.kind&&!this.unicodeFontStates.has(e.resourceName)){const t=function(e){const t=new qm(e);return{program:e,layouter:t.hasShaping?t:new Zm(e),subsetter:new ch}}(function(e){const t=ve.decodeSync(e);return Ae.parse(t)}(e.fontData)),n=1e3/t.program.unitsPerEm,o={id:0,codePoints:[0],advanceWidth:t.program.advanceWidthForGlyph(0)};this.unicodeFontStates.set(e.resourceName,{resource:e,font:t,usedGlyphs:/* @__PURE__ */new Map([[0,o]]),scale:n,layoutCache:/* @__PURE__ */new Map})}}resolveAndMarkFontName(e){const t=function(e){return e.fontResourceName?e.fontResourceName:e.bold&&e.italic?"F4":e.bold?"F2":e.italic?"F3":"F1"}(e);return this.usedFontResourceNames.add(t),t}getUnicodeState(e){return this.unicodeFontStates.get(e)}buildUnicodeShowCommand(e,t,n){const o=this.layoutUnicodeText(e,t,n),r=this.encodeUnicodeGlyphRun(e,o);return 0===r.length?null:r.some(e=>Math.abs(e.nominalWidth-e.desiredAdvance)>.01)?`[${r.map(e=>{const t=e.nominalWidth-e.desiredAdvance;return 0===t?`<${Pm(e.glyphId)}>`:`<${Pm(e.glyphId)}> ${hm(t)}`}).join(" ")}] TJ`:`<${r.map(e=>Pm(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>"base14"===e.kind||this.usedFontResourceNames.has(e.resourceName)),n=t.map(t=>{if("unicode"===t.kind){const n=this.unicodeFontStates.get(t.resourceName);if(n)return this.addUnicodeFontObjects(n,e)}return e(function(e){switch(e.kind){case"base14":return`<< /Type /Font /Subtype /Type1 /BaseFont /${e.baseFont} /Encoding /WinAnsiEncoding >>`;case"unicode":return"<< /Type /Font /Subtype /Type0 /BaseFont /OasisPending /Encoding /Identity-H >>"}}(t))});return{resourceXml:t.map((e,t)=>`/${e.resourceName} ${n[t]} 0 R`).join(" ")}}layoutUnicodeText(e,t,n){const o=`${n?.join(",")??""}\0${t}`,r=e.layoutCache.get(o);if(r)return r;const a=e.font.layouter.layout(t,n);return e.layoutCache.set(o,a),a}encodeUnicodeGlyphRun(e,t){return t.glyphs.map((n,o)=>{e.usedGlyphs.has(n.id)||e.usedGlyphs.set(n.id,n);const r=t.positions[o],a=n.advanceWidth*e.scale,i=(r?.xAdvance??n.advanceWidth)*e.scale;return{glyphId:n.id,nominalWidth:a,desiredAdvance:i}})}addUnicodeFontObjects(e,t){const n=e.font.subsetter.createSubset(e.font.program,e.usedGlyphs.values()),o=t(function(e,t=""){const n=`${ym(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${bm(n)} /Filter /ASCIIHexDecode${o} >>\nstream\n${n}\nendstream`}(n.fontFile)),r=e.font.program.metadata,a=r.familyClass>>8||0;let i=4;r.isFixedPitch&&(i|=1),a>=1&&a<=7&&(i|=2),10===a&&(i|=8),r.macStyleItalic&&(i|=64);const l=`${Sm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Sm(r.postscriptName,e.resource.family)}`,s=r.bbox,c=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${i}`,`/FontBBox [${[s.minX*e.scale,s.minY*e.scale,s.maxX*e.scale,s.maxY*e.scale].map(hm).join(" ")}]`,`/ItalicAngle ${hm(r.italicAngle)}`,`/Ascent ${hm(r.ascent*e.scale)}`,`/Descent ${hm(r.descent*e.scale)}`,`/CapHeight ${hm(r.capHeight*e.scale)}`,`/XHeight ${hm(r.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${o} 0 R`,">>"].join("\n")),d=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${c} 0 R`,`/W [0 [${n.widths.map(e=>hm(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${bm(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${Tm(e)}>`).filter(e=>"<>"!==e);0===t.length&&t.push("<0000>");const n=[];for(let o=0;o<t.length;o+=256){const e=Math.min(o+256,t.length);n.push(`<${vm(o)}> <${vm(e-1)}> [${t.slice(o,e).join(" ")}]`)}return["/CIDInit /ProcSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo <<"," /Registry (Adobe)"," /Ordering (UCS)"," /Supplement 0",">> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def","1 begincodespacerange","<0000><ffff>","endcodespacerange",`${n.length} beginbfrange`,n.join("\n"),"endbfrange","endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(n.unicode)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${d} 0 R]`,`/ToUnicode ${u} 0 R`,">>"].join("\n"))}},uh=class{imageResources=/* @__PURE__ */new Map;registerImageResource(e){const t=e.resourceName??`Im${this.imageResources.size+1}`;return this.imageResources.has(t)||this.imageResources.set(t,{resourceName:t,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height)),data:e.data,filter:e.filter}),t}has(e){return this.imageResources.has(e)}buildImageObjects(e){const t=/* @__PURE__ */new Map;for(const n of this.imageResources.values())t.set(n.resourceName,this.addImageObject(n,e));return t}addImageObject(e,t){return t(function(e,t){const n=`${ym(e)}>`;return[`<< /Length ${bm(n)}`," /Filter [/ASCIIHexDecode /DCTDecode]",` ${t.join(" ")}`," >>","stream",n,"endstream"].join("\n")}(e.data,["/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},ph=class{shadings=[];register(e){const t=`Sh${this.shadings.length+1}`;return this.shadings.push({name:t,spec:e}),t}buildShadingObjects(e){const t=/* @__PURE__ */new Map;for(const{name:n,spec:o}of this.shadings)t.set(n,this.addShadingObject(o,e));return t}addShadingObject(e,t){const n=t(function(e){if(2===e.length)return gh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(gh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>hm(e.offset)),o=e.slice(0,-1).map(()=>"0 1").join(" ");return["<< /FunctionType 3","/Domain [0 1]",`/Functions [${t.join(" ")}]`,`/Bounds [${n.join(" ")}]`,`/Encode [${o}]`,">>"].join("\n")}(function(e){const t=e.map(e=>({offset:Math.min(1,Math.max(0,e.offset)),rgb:xm(e.color,[0,0,0])})).sort((e,t)=>e.offset-t.offset);if(0===t.length)return[{offset:0,rgb:[0,0,0]},{offset:1,rgb:[0,0,0]}];if(1===t.length)return[{offset:0,rgb:t[0].rgb},{offset:1,rgb:t[0].rgb}];t[0].offset=0,t[t.length-1].offset=1;for(let n=1;n<t.length-1;n+=1){const e=t[n-1].offset+1e-4;t[n].offset<=e&&(t[n].offset=Math.min(.9999,e))}return t}(e.stops)));return t(["<< /ShadingType 2","/ColorSpace /DeviceRGB",`/Coords [${[e.x0,e.y0,e.x1,e.y1].map(hm).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function gh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(hm).join(" ")}]`,`/C1 [${t.map(hm).join(" ")}]`,"/N 1",">>"].join("\n")}var fh=new TextEncoder;function mh(e){return"string"==typeof e?bm(e):e.length}function hh(e){const t=e.reduce((e,t)=>e+mh(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?fh.encode(r):r;n.set(e,o),o+=e.length}return n}function bh(e){const t=ge(fh.encode(e));return hh([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function yh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function vh(e){return`<FEFF${Tm(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function xh(e){const t=[];if(e.title&&t.push(`/Title ${vh(e.title)}`),e.author&&t.push(`/Author ${vh(e.author)}`),e.subject&&t.push(`/Subject ${vh(e.subject)}`),e.keywords&&t.push(`/Keywords ${vh(e.keywords)}`),e.producer&&t.push(`/Producer (${yh(e.producer)})`),e.creationDate&&t.push(`/CreationDate (${function(e){const t=(e,t=2)=>String(e).padStart(t,"0");return`D:${e.getUTCFullYear()}${t(e.getUTCMonth()+1)}${t(e.getUTCDate())}${t(e.getUTCHours())}${t(e.getUTCMinutes())}${t(e.getUTCSeconds())}+00'00'`}(e.creationDate)})`),0!==t.length)return`<< ${t.join(" ")} >>`}function wh(e){return e.children.reduce((e,t)=>e+1+wh(t),0)}function Sh(e,t,n,o,r=[],a=[],i){const l=[],s=e=>{const t=l.length+1;return l.push({id:t,body:e}),t},c=s(""),d=s(""),{resourceXml:u}=t.buildFontObjects(s),p=n.buildImageObjects(s),g=o.buildShadingObjects(s),f=/* @__PURE__ */new Map;for(const B of e)for(const[e,t]of B.graphicsStateOpacities??[])f.has(e)||f.set(e,s(`<< /Type /ExtGState /ca ${hm(t)} /CA ${hm(t)} >>`));const m=[];for(const B of e){const e=s(bh(`${B.commands.join("\n")}\n`)),t=Array.from(B.imageResourceNames).map(e=>{const t=p.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),n=t?` /XObject << ${t} >>`:"",o=Array.from(B.shadingResourceNames).map(e=>{const t=g.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),r=o?` /Shading << ${o} >>`:"",a=Array.from(B.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${f.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",l=B.annotations.map(e=>{const t=e.x,n=e.x+e.width,o=B.height-e.y-e.height,r=B.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${yh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${yh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${hm(t)} ${hm(o)} ${hm(n)} ${hm(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=l.length>0?`\n/Annots [${l.map(e=>`${e} 0 R`).join(" ")}]`:"",h=s(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${hm(B.width)} ${hm(B.height)}]`,`/Resources << /Font << ${u} >>${n}${r}${i} >>`,`/Contents ${e} 0 R${c}`,">>"].join("\n"));m.push(h)}let h;const b=r.filter(e=>void 0!==m[e.pageIndex]).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0);let y;b.length>0&&(h=s(`<< /Dests ${s(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${yh(t.name)}) [${n} 0 R /XYZ ${hm(t.x)} ${hm(o)} null]`}).join(" ")}] >>`)} 0 R >>`));const v=new Set(b.map(e=>e.name)),x=function(e){const t=[],n=[];for(const o of e){const e={title:o.title,destName:o.destName,children:[]};for(;n.length>0&&n[n.length-1].level>=o.level;)n.pop();0===n.length?t.push(e):n[n.length-1].node.children.push(e),n.push({node:e,level:o.level})}return t}(a.filter(e=>v.has(e.destName)));if(x.length>0){y=s("");const e=t=>t.map(t=>{const n=s("");return t.id=n,t.childIds=e(t.children),n}),t=e(x),n=(e,t)=>{e.forEach((o,r)=>{const a=o,i=r>0?e[r-1]:void 0,s=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+vh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${yh(o.destName)})`];a.childIds.length>0&&(c.push(`/First ${a.childIds[0]} 0 R`),c.push(`/Last ${a.childIds[a.childIds.length-1]} 0 R`),c.push(`/Count ${wh(o)}`)),c.push(">>"),l[a.id-1].body=c.filter(Boolean).join("\n"),n(o.children,a.id)})};n(x,y);const o=a.filter(e=>v.has(e.destName)).length;l[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(l[c-1].body=["<< /Type /Catalog",`/Pages ${d} 0 R`,void 0!==h?`/Names ${h} 0 R`:"",void 0!==y?`/Outlines ${y} 0 R`:"",void 0!==y?"/PageMode /UseOutlines":"",">>"].filter(Boolean).join("\n"),l[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=xh(i);e&&(w=s(e))}const S=[fm];let I=mh(fm);const C=[0],T=e=>{S.push(e),I+=mh(e)};for(const B of l)C[B.id]=I,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const P=I;let k=`xref\n0 ${l.length+1}\n`;k+="0000000000 65535 f \n";for(const B of l)k+=`${String(C[B.id]??0).padStart(10,"0")} 00000 n \n`;T(k);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${l.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(P),"%%EOF",""].join("\n")),hh(S)}var Ih=class{pages=[];streams=[];fonts;images=new uh;shadings=new ph;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=mm){this.fonts=new dh(e)}registerFontResource(e){this.fonts.registerFontResource(e)}addPage(e){const t={width:Math.max(1,e.width),height:Math.max(1,e.height),commands:[],imageResourceNames:/* @__PURE__ */new Set,shadingResourceNames:/* @__PURE__ */new Set,annotations:[],graphicsStateOpacities:/* @__PURE__ */new Map};return this.pages.push(t),this.streams.push(new Bm(t,this.fonts,this.images,this.shadings)),this.pages.length-1}getPageCount(){return this.pages.length}drawRect(e,t){this.streams[e]?.drawRect(t)}drawLine(e,t){this.streams[e]?.drawLine(t)}drawPath(e,t){this.streams[e]?.drawPath(t)}saveGraphicsState(e){this.streams[e]?.saveGraphicsState()}restoreGraphicsState(e){this.streams[e]?.restoreGraphicsState()}setOpacity(e,t){this.streams[e]?.setOpacity(t)}rotateAbout(e,t,n,o){this.streams[e]?.rotateAbout(t,n,o)}clipRect(e,t,n,o,r){this.streams[e]?.clipRect(t,n,o,r)}clipPath(e,t){this.streams[e]?.clipPath(t)}drawText(e,t){this.streams[e]?.drawText(t)}registerAxialGradient(e,t){return this.streams[e]?.registerAxialGradient(t)??null}registerImageResource(e){return this.images.registerImageResource(e)}drawImage(e,t){this.streams[e]?.drawImage(t)}addLinkAnnotation(e,t){this.pages[e]?.annotations.push(t)}addNamedDestination(e){this.namedDestinations.some(t=>t.name===e.name)||this.namedDestinations.push(e)}addOutlineItem(e){this.outlineItems.push(e)}setDocumentInfo(e){this.documentInfo=e}toArrayBuffer(){const e=this.toUint8Array();return Uint8Array.from(e).buffer}toBlob(){return new Blob([this.toArrayBuffer()],{type:"application/pdf"})}toUint8Array(){return 0===this.pages.length&&this.addPage({width:612,height:792}),Sh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function Ch(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=Bo(i),s=Bo(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:s,y:l});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:s,y:l}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function Th(e){e=fe(e);const t=new gm,n=ma(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new Ih(t.getPdfFontResources());o.setDocumentInfo(function(e){const t=e.metadata??{},n=e=>"string"==typeof e&&""!==e.trim()?e:void 0;return{title:n(t.title),author:n(t.author),subject:n(t.subject),keywords:n(t.keywords),producer:"Oasis Editor",creationDate:/* @__PURE__ */new Date}}(e));const r=ho(e),a=function(e){return ra(e)}(e),i=function(e){const t=/* @__PURE__ */new Map,n=e.bookmarks;if(!n)return t;for(const o of n.order){const e=n.items[o],r=e?.start?.paragraphId;if(!e||!r)continue;const a=t.get(r)??[];a.push(e.name),t.set(r,a)}return t}(e),l=new Map(dn(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,Bo(s.pageSettings.width)),r=Math.max(1,Bo(s.pageSettings.height)),c=o.addPage({width:n,height:r});await cm(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=j(s.pageSettings);await sm(o,c,s.headerBlocks,e,d,s.headerTop??he(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??Ct(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=$t(s.pageSettings),r=/* @__PURE__ */new Map;for(const e of s.blocks){const t=e.columnIndex??0,n=r.get(t)??[];n.push(e),r.set(t,n)}for(const[d,u]of r){const r=n[d]??n[0];await sm(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,Ch(o,c,r.left,i,l))}}else await sm(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,Ch(o,c,d,i,l));await sm(o,c,s.footerBlocks,e,d,s.footerTop??s.bodyBottom??s.pageSettings.height,u,t,a,s.pageSettings),s.footnoteBlocks&&s.footnoteBlocks.length>0&&void 0!==s.footnoteTop&&(void 0!==s.footnoteSeparatorTop&&o.drawLine(c,{x1:Bo(d),y1:Bo(s.footnoteSeparatorTop+.5),x2:Bo(d+Math.min(180,.35*u)),y2:Bo(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:Bo(1)}),await kh(o,c,s.footnoteBlocks,s.footnoteReferenceIds??[],e,d,s.footnoteTop,u,t,a))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await cm(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function Ph(e){const t=await Th(e);return new Blob([t],{type:"application/pdf"})}async function kh(e,t,n,o,r,a,i,l,s,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,vn(r,e)?.run.text??""]));for(const g of n){const n=o.find(e=>g.blockId.startsWith(`${e}:`));if(n&&!u.has(n)){const o=p.get(n);if(o){const n="paragraph"===g.sourceBlock.type?g.sourceBlock:void 0,i=Xe(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:Bo(a),y:Bo(d+12),text:o,fontSize:Mr(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await sm(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function Rh(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Bh(e){return new Promise(t=>{const n=URL.createObjectURL(e),o=document.createElement("iframe");o.setAttribute("aria-hidden","true"),o.style.position="fixed",o.style.right="0",o.style.bottom="0",o.style.width="0",o.style.height="0",o.style.border="0";let r=!1;const a=()=>{r||(r=!0,o.remove(),URL.revokeObjectURL(n),t())},i=()=>{if(!r){if(!window.open(n,"_blank")){const e=document.createElement("a");e.href=n,e.download="oasis-editor.pdf",e.click()}a()}};o.addEventListener("load",()=>{try{const e=o.contentWindow;if(!e)return void i();e.addEventListener("afterprint",a),globalThis.setTimeout(a,6e4),e.focus(),e.print()}catch{i()}}),o.src=n,document.body.appendChild(o)})}async function Mh(e){return"function"==typeof e.arrayBuffer?e.arrayBuffer():new Promise((t,n)=>{const o=new FileReader;o.onerror=()=>n(o.error??/* @__PURE__ */new Error("Failed to read file.")),o.onload=()=>{const e=o.result;e instanceof ArrayBuffer?t(e):n(/* @__PURE__ */new Error("Failed to read file as ArrayBuffer."))},o.readAsArrayBuffer(e)})}function Fh(e){if(!e)return null;for(const t of Array.from(e.items??[])){if("file"!==t.kind)continue;const e=t.getAsFile();if(e&&e.type.startsWith("image/"))return e}for(const t of Array.from(e.files??[]))if(t.type.startsWith("image/"))return t;return null}function Ah(e){return function(e){const t=Vr(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=De(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=Xe(o.styles,i.style?.styleId,e.styles),l=t.fontFamily??"<null>";n.set(l,(n.get(l)??0)+1),null!==t.characterSpacing&&(r+=1),null!==t.characterScale&&(a+=1)}}return{paragraphCount:t.length,alignCounts:Array.from(o.entries()),fontCounts:Array.from(n.entries()),characterSpacingRuns:r,characterScaleRuns:a,firstParagraphs:t.slice(0,30).map((t,n)=>{const o=De(t.style,e.styles),r=t.runs[0],a=Xe(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:ot(t).length,runCount:t.runs.length,rawParagraphStyle:t.style,align:o.align,indentFirstLine:o.indentFirstLine,lineGridPitch:o.lineGridPitch,lineGridType:o.lineGridType,fontFamily:a.fontFamily,fontSize:a.fontSize,characterSpacing:a.characterSpacing,characterScale:a.characterScale,firstRunStyle:r?.styles}})}}(e)}function Oh(e,t){const n=Bn(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=ao(e)[n.startIndex];if(!o)return null;let r=0;for(let a=0;a<o.runs.length;a+=1){const e=o.runs[a],i=r;if(r+=e.text.length,t(e)&&1===e.text.length&&i===n.startParagraphOffset)return{paragraph:o,paragraphIndex:n.startIndex,run:e,runIndex:a,offset:i}}return null}function Dh(e,t){if("inline"===t)return;const n={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"};switch(t){case"square":case"tight":case"through":case"topAndBottom":return{...n,wrap:t,behindDoc:!1};case"behind":return{...n,wrap:"none",behindDoc:!0};case"front":return{...n,wrap:"none",behindDoc:!1}}}function Eh(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function Lh(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function Nh(e){return"page"===e?.positionV?.relativeFrom}function $h(e){return Oh(e,e=>"image"===e.kind)}function zh(e,t,n){return Gh(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function Hh(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function Wh(e,t){return Gh(e,e=>{const n={...e},o=function(e){if(!e)return;const t=Hh(e.left),n=Hh(e.top),o=Hh(e.right),r=Hh(e.bottom),a=Math.min(o,Math.max(0,.99-t)),i=Math.min(r,Math.max(0,.99-n));return 0!==t||0!==n||0!==a||0!==i?{left:t,top:n,right:a,bottom:i}:void 0}(t.crop);return o?n.crop=o:delete n.crop,void 0!==t.width&&(n.width=Math.max(24,Math.round(t.width))),void 0!==t.height&&(n.height=Math.max(24,Math.round(t.height))),n})}function Uh(e,t){const n=$h(e),o=n&&nn(n.run);return o?Wh(e,function(e,t){if("reset"===t)return{crop:null};const n=t,{width:o,height:r}=e;if(!Number.isFinite(n)||n<=0||o<=0||r<=0)return{crop:e.crop??null};const a=e.crop??{},i=Hh(a.left),l=Hh(a.top),s=Hh(a.right),c=Hh(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-s);return{crop:{...a,left:i+t/2,right:s+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-l-c);return{crop:{...a,top:l+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function jh(e){const t=e.intrinsicWidth??e.width,n=e.intrinsicHeight??e.height,o=t>0&&n>0?t/n:e.width/Math.max(1,e.height),r=e.width/Math.max(1,e.height);if(!Number.isFinite(o)||!Number.isFinite(r))return{};if(o>r){const e=r/o,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(o<r){const e=o/r,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}return{}}function Vh(e){return Gh(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function Kh(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function _h(e,t,n=90){const o=$h(e);if(!o||!nn(o.run))return e;const r="right"===t?-n:n,a=Kh(function(e){const t=$h(e);return(t&&nn(t.run))?.rotation??0}(e)+r);return Gh(e,e=>({...e,rotation:a}))}function Xh(e,t){const n=function(e){const t=$h(e),n=t&&nn(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?Gh(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function Gh(e,t){const n=$h(e);if(!n||!nn(n.run))return e;const r=ao(e),{paragraphIndex:a,run:i}=n,l=r.map((e,n)=>n!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id===i.id&&"image"===e.kind?{...e,image:t(e.image)}:o(e))});return da(e,l,we(l,Bn(e)))}function Yh(e,t){return Gh(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function qh(e,t){const n=$h(e);if(!n)return e;const o=ao(e),{paragraphIndex:r,offset:a,run:i}=n,l=Yo(o,t.paragraphId);if(l<0)return e;const s=o[l],c=u(s,t),d=l===r&&c>a?c-1:c;if(l===r&&d===a)return e;const p=e=>me(e,[...U(e,0,a),...U(e,a+1,Se(e))]),g=(e,t)=>Y(e,Math.max(0,Math.min(t,Se(e))),[rr("",Nt(e,t),nn(i))]),f=o.map((e,t)=>t===r&&t===l?g(p(e),d):t===r?p(e):t===l?g(e,d):tt([e])[0]),m=f[l],h=Math.max(0,Math.min(d+1,Se(m)));return da(e,f,nt(ua(m,h)))}function Zh(e,t,n,o=0){const r=j(q(t));if(!n)return r;const a=Dr(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function Jh(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await Mh(t),r=`data:${t.type};base64,${function(e){return btoa(new Uint8Array(e).reduce((e,t)=>e+String.fromCharCode(t),""))}(o)}`,a=new Image;a.src=r,await new Promise(e=>{a.onload=e,a.onerror=e});const i=a.naturalWidth||300,l=a.naturalHeight||300,s=e.state(),c=n?.paragraphId??s.selection.focus.paragraphId,d=Zh(e.surfaceRef(),s.document,c,s.activeSectionIndex??0),u=i>d?d/i:1,p=Math.max(24,Math.round(i*u)),g=Math.max(24,Math.round(l*u));e.logger.info(`image insert:decoded natural=${i}x${l} fitted=${p}x${g} maxWidth=${d}`),e.applyTransactionalState(e=>function(e,t){const n=vr(e.selection)?e:_e(e),{paragraph:o,index:r,offset:a}=E(n),i=rr("",Nt(o,a),t),l=Y(o,a,[i]),s=ao(n).map((e,t)=>t===r?l:Gt(e));return da(n,s,nt(ua(l,a+1)))}(n?Sa(e,{anchor:n,focus:n}):e,{src:r,width:p,height:g,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:fi})}}}var Qh={"reading-file":[0,8],opening:[8,20],parsing:[20,72],finishing:[72,78],"preparing-fonts":[78,90],"applying-editor-state":[90,94],"stabilizing-layout":[94,99],done:[100,100],error:[100,100]};function eb(e){return function(e){const[t,n]=Wt(null),o=(e,t)=>{const[n,o]=Qh[e];return void 0!==t&&Number.isFinite(t)?Math.round(10*(n+(o-n)*Math.min(1,Math.max(0,t))))/10:o},r=(e,t)=>{n({phase:e,progress:o(e,t),subProgress:t})},i=()=>{globalThis.setTimeout(()=>{n(e=>"done"===e?.phase||"error"===e?.phase?null:e)},1200)},l=function(e){return{handleImportFile:async t=>{if(!t)return;const n=ha(t);if(!n)return e.setImportPhase("error"),e.logger.error("import:unsupported-format",{name:t.name,type:t.type}),void e.clearImportProgressSoon();const o=e.now();e.logger.info("import:start",{format:n.id,name:t.name,size:t.size}),e.setImportPhase("reading-file");const r="docx"===n.id?e.requestLocalFontAccess().catch(()=>!1):Promise.resolve(!1);try{const i=e.now(),l=await Mh(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:So(e.now()-i,2)});let s=null,c=-1,d=0;const u=await n.import(l,(t,n)=>{const o=e.now(),r=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==s;if(!(a||void 0!==r&&(c<0||r-c>=1)||o-d>=40))return;s=t,c=r??c,d=o,e.setImportPhase(t,n);const i={phase:t,subProgress:n};a||void 0===n||1===n?e.logger.info("import:phase",i):e.logger.debug("import:phase",i)});e.logger.debug("import:document-diagnostics",Ah(u));const p=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(u),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:So(e.now()-p,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(Tr(u));const g=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:So(e.now()-g,2)});const f=a(u).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),m=bt(u).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:f,paragraphs:m,durationMs:So(e.now()-o,2)}),e.focusInput()}catch(i){e.setImportPhase("error"),e.logger.error("import:error",i)}finally{e.clearImportProgressSoon()}}}}({applyState:e.applyState,stabilizeLayoutAfterImport:e.stabilizeLayoutAfterImport,resetEditorChromeState:e.resetEditorChromeState,focusInput:e.focusInput,requestLocalFontAccess:e.requestLocalFontAccess,prepareDocumentFonts:e.prepareDocumentFonts,setImportPhase:r,clearImportProgressSoon:i,now:()=>performance.now(),logger:e.logger}),s=Jh({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),c=function(e){const t=e.download??Rh,n=e.print??Bh;let o=!1;return{handleExportDocx:async()=>{const n=await Lf(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await Ph(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await Ph(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>Lf(e.document()),exportPdfBlob:()=>Ph(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),d=async t=>{e.isReadOnly()||await l.handleImportFile(t)},u=async(e,t)=>{await s.insertImageFromFile(e,t)},p=async t=>{e.isReadOnly()||t&&(await u(t),e.focusInput())};return{importProgress:t,handleImportFile:d,handleExportDocx:async()=>c.handleExportDocx(),handleExportPdf:async()=>c.handleExportPdf(),handlePrint:async()=>c.handlePrint(),exportDocxBlob:c.exportDocxBlob,exportPdfBlob:c.exportPdfBlob,insertImageFromFile:u,handleInsertImage:p}}(e)}function tb(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function nb(e){return" "===e||"\t"===e||"\n"===e}function ob(e,t,n){if(n.isCollapsed)return null;const o=t.get(e);return void 0===o||o<n.startIndex||o>n.endIndex?null:n.startIndex===n.endIndex?{start:n.startParagraphOffset,end:n.endParagraphOffset}:e===n.start.paragraphId?{start:n.startParagraphOffset,end:Number.POSITIVE_INFINITY}:e===n.end.paragraphId?{start:0,end:n.endParagraphOffset}:{start:0,end:Number.POSITIVE_INFINITY}}function rb(e,t){if(!e)return null;for(const n of e)if("table"===n.type){if(n.id===t)return n;for(const e of n.rows)for(const n of e.cells){const e=rb(n.blocks,t);if(e)return e}}return null}function ab(e,t){const n=Bn(t),o=[],r=e.surfaceRect,a=new Map(ao(t).map((e,t)=>[e.id,t]));let i=null,l=null;if(!n.isCollapsed&&n.startIndex===n.endIndex&&n.endParagraphOffset-n.startParagraphOffset===1){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.inlineImages.find(t)??e.floatingImages.find(t);if(o&&(i={paragraphId:o.paragraphId,startOffset:o.startOffset,endOffset:o.endOffset,left:o.left-r.left,top:o.top-r.top,width:o.width,height:o.height,rotation:o.rotation??0}),!i){const t=e=>e.paragraphId===n.start.paragraphId&&e.startOffset===n.startParagraphOffset&&e.endOffset===n.endParagraphOffset,o=e.floatingTextBoxes.find(t),a=o?void 0:e.inlineTextBoxes.find(t),i=o??a;i&&(l={paragraphId:i.paragraphId,startOffset:i.startOffset,endOffset:i.endOffset,left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height,rotation:i.rotation??0,floating:Boolean(o)})}}const s=(e.paragraphsById.get(t.selection.anchor.paragraphId)??[]).find(e=>e.tableCell)?.tableCell,c=(e.paragraphsById.get(t.selection.focus.paragraphId)??[]).find(e=>e.tableCell)?.tableCell;let d=!1;if(s&&c&&s.tableId===c.tableId&&(s.rowIndex!==c.rowIndex||s.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of Co(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=rb(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=rb(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=Xt(n),a=t.find(e=>e.rowIndex===s.rowIndex&&e.cellIndex===s.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const l=Math.min(a.visualRowIndex,i.visualRowIndex),s=Math.max(a.visualRowIndex+a.rowSpan-1,i.visualRowIndex+i.rowSpan-1),c=Math.min(a.visualColumnIndex,i.visualColumnIndex),u=Math.max(a.visualColumnIndex+a.colSpan-1,i.visualColumnIndex+i.colSpan-1),p=/* @__PURE__ */new Set;for(const a of e.paragraphs)if(a.tableCell&&a.tableCell.tableId===n.id){const e=t.find(e=>e.rowIndex===a.tableCell.rowIndex&&e.cellIndex===a.tableCell.cellIndex);if(e){const t=e.visualRowIndex<=s&&e.visualRowIndex+e.rowSpan-1>=l,n=e.visualColumnIndex<=u&&e.visualColumnIndex+e.colSpan-1>=c;if(t&&n){const t=`${e.rowIndex}:${e.cellIndex}`;p.has(t)||(p.add(t),o.push({left:a.tableCell.left-r.left,top:a.tableCell.top-r.top,width:a.tableCell.width,height:a.tableCell.height}))}}}}}}if(!(d||n.isCollapsed||i||l))for(const u of e.paragraphs){const e=ob(u.paragraphId,a,n);if(!e)continue;const t=Math.max(e.start,u.startOffset),i=Math.min(e.end,u.endOffset);if(!(t>=i))for(const n of u.lines){let e=Math.max(t,n.startOffset),a=Math.min(i,n.endOffset);for(;e<a&&nb(tb(u,e));)e+=1;for(;a>e&&nb(tb(u,a-1));)a-=1;if(e>=a)continue;const l=n.slots.find(t=>t.offset===e),s=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!l||!s)continue;const c=0===u.startOffset&&n.startOffset===u.startOffset&&n.top>u.top,d=c?u.top:n.top,p=c?n.top+n.height-u.top:n.height;o.push({left:l.left-r.left+1,top:d-r.top,width:Math.max(1,s.left-l.left+1-1),height:p})}}const p=t.selection.focus.paragraphId,g=e.paragraphsById.get(p)??[],f=g[0]?.paragraph,m=function(e,t){if(0===e.length)return null;const n=e.find(e=>t>=e.startOffset&&t<=e.endOffset)??e[e.length-1],o=n.lines.flatMap(e=>e.slots);if(0===o.length)return{left:n.left,top:n.top,height:Math.max(18,n.height)};let r=o[0],a=Math.abs(t-r.offset);for(const l of o){const e=Math.abs(t-l.offset);e<a&&(r=l,a=e)}const i=n.lines[0];return 0===n.startOffset&&void 0!==i&&t>=i.startOffset&&t<=i.endOffset&&r.top>n.top?{left:r.left,top:n.top,height:r.top+r.height-n.top}:{left:r.left,top:r.top,height:r.height}}(g,f?u(f,t.selection.focus):t.selection.focus.offset),h=(m?.left??r.left)-r.left,b=(m?.top??r.top)-r.top,y=Math.max(18,m?.height??28),v={left:h,top:b,height:y,visible:g.length>0&&!d&&!i&&!l};let x=null;const w=(e.paragraphsById.get(p)??[])[0]?.tableCell?.tableId??null;if(w){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of e.paragraphs){const e=r.tableCell;e&&e.tableId===w&&(t=Math.min(t,e.left),n=Math.min(n,e.top),o=Math.max(o,e.left+e.width),a=Math.max(a,e.top+e.height))}Number.isFinite(t)&&o>t&&a>n&&(x={tableId:w,left:t-r.left,top:n-r.top,width:o-t,height:a-n})}return{selectionBoxes:o,inputBox:{left:h,top:b,height:y},caretBox:v,selectedImageBox:i,selectedTextBoxBox:l,selectedTableBox:x}}var ib={composeMeasuredParagraphLines:e=>ta.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>ta.resolveRenderedLineHeightPx(e,t)};function lb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function sb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>{const o=e?.[n];return o?.blockIndex===t.blockIndex&&o?.offset===t.offset})}function cb(){let e=/* @__PURE__ */new Map,t=/* @__PURE__ */new Map;return function(n){const o=/* @__PURE__ */new Map,r=t=>t?.map(t=>{const n=e.get(t.blockId),r=function(e,t){return Boolean(e&&e.blockId===t.blockId&&e.sourceBlock===t.sourceBlock&&e.estimatedHeight===t.estimatedHeight&&e.tableSegment?.startRowIndex===t.tableSegment?.startRowIndex&&e.tableSegment?.endRowIndex===t.tableSegment?.endRowIndex&&e.tableSegment?.repeatedHeaderRowCount===t.tableSegment?.repeatedHeaderRowCount&&lb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&lb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&sb(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&sb(e.tableSegment?.endRowCellBlockPositions,t.tableSegment?.endRowCellBlockPositions)&&function(e,t){return e===t||!(!e||!t)&&e.text===t.text&&e.startOffset===t.startOffset&&e.endOffset===t.endOffset&&e.lines.length===t.lines.length&&t.lines.every((t,n)=>{const o=e.lines[n];return void 0!==o&&o.startOffset===t.startOffset&&o.endOffset===t.endOffset&&o.top===t.top&&o.height===t.height})}(e.layout,t.layout))}(n,t)?n:t;return o.set(r.blockId,r),r}),a=n.pages.map(e=>{const n={...e,blocks:r(e.blocks)??[],headerBlocks:r(e.headerBlocks),footerBlocks:r(e.footerBlocks),footnoteBlocks:r(e.footnoteBlocks)},o=t.get(n.id);return function(e,t){const n=Boolean(e&&e.pageSettings.width===t.pageSettings.width&&e.pageSettings.height===t.pageSettings.height&&e.pageSettings.orientation===t.pageSettings.orientation&&e.pageSettings.margins.top===t.pageSettings.margins.top&&e.pageSettings.margins.right===t.pageSettings.margins.right&&e.pageSettings.margins.bottom===t.pageSettings.margins.bottom&&e.pageSettings.margins.left===t.pageSettings.margins.left&&e.pageSettings.margins.header===t.pageSettings.margins.header&&e.pageSettings.margins.footer===t.pageSettings.margins.footer&&e.pageSettings.margins.gutter===t.pageSettings.margins.gutter);if(!e||e.id!==t.id||e.index!==t.index||e.height!==t.height||e.maxHeight!==t.maxHeight||!n||e.bodyTop!==t.bodyTop||e.bodyBottom!==t.bodyBottom||e.headerTop!==t.headerTop||e.footerTop!==t.footerTop||e.footnoteTop!==t.footnoteTop||e.footnoteSeparatorTop!==t.footnoteSeparatorTop)return!1;const o=(e,t)=>(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t);return o(e.blocks,t.blocks)&&o(e.headerBlocks,t.headerBlocks)&&o(e.footerBlocks,t.footerBlocks)&&o(e.footnoteBlocks,t.footnoteBlocks)&&(r=e.footnoteReferenceIds,a=t.footnoteReferenceIds,(r?.length??0)===(a?.length??0)&&(a??[]).every((e,t)=>r?.[t]===e));var r,a}(o,n)?o:n});return e=o,t=new Map(a.map(e=>[e.id,e])),{pages:a}}}function db(e,t){if(0===t.length)return e;let n;for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&(n??={...e},delete n[o]);return n??e}function ub(e){return function(e){const[t,n]=Wt({}),[o,r]=Wt({}),[a,i]=Wt({left:0,top:0,height:28}),[l,s]=Wt([]),[c,d]=Wt([]),[u,p]=Wt(null),[g,f]=Wt(null),[m,h]=Wt(null),[b,y]=Wt({left:0,top:0,height:28,visible:!1}),[v,x]=Wt(null),w=cb(),S=Q(()=>(br(),w(ho(e.state.document,void 0,t(),o(),{measurer:ib})))),I=ze();let C=0;const T=(t="selection")=>{const n=e.surfaceRef();if(!n)return s([]),d([]),p(null),f(null),h(null),void y(e=>({...e,visible:!1}));const o=I.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:S(),zoomFactor:e.zoomFactor?.()});if(!o)return s([]),d([]),p(null),f(null),h(null),void y(e=>({...e,visible:!1}));const r=ab(o,e.state);s(r.selectionBoxes),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length)return[];const o=e.surfaceRect,r=new Map(ao(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const t=n.items[i];if(!t?.start||!t?.end)continue;const l=r.get(t.start.paragraphId),s=r.get(t.end.paragraphId);if(void 0!==l&&void 0!==s)for(const n of e.paragraphs){const e=r.get(n.paragraphId);if(void 0===e||e<l||e>s)continue;const c=e===l?t.start.offset:0,d=e===s?t.end.offset:Number.POSITIVE_INFINITY,u=Math.max(c,n.startOffset),p=Math.min(d,n.endOffset);if(!(u>=p))for(const t of n.lines){const e=Math.max(u,t.startOffset),n=Math.min(p,t.endOffset);if(e>=n)continue;const r=t.slots.find(t=>t.offset===e),l=t.slots.find(e=>e.offset===n)??t.slots[t.slots.length-1];r&&l&&a.push({commentId:i,left:r.left-o.left,top:t.top-o.top,width:Math.max(1,l.left-r.left),height:t.height})}}}return a}(o,e.state)),p(r.selectedImageBox),f(r.selectedTextBoxBox),h(r.selectedTableBox),i(r.inputBox),y(r.caretBox)},P=(e="selection")=>{const t=++C;queueMicrotask(()=>{t===C&&T(e)})},k=(e="content-change")=>(P(e),!1),R=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(r(e=>db(e,t.paragraphIds??[])),_o()),P(e),t.resolveWhenDone?Promise.resolve():null),B=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),r({}),_o();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];r(t=>db(t,e)),_o()}P("content-change")}},M=async()=>{n({}),r({}),_o(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),P("import")};Dt(()=>{e.state.selection.anchor.paragraphId,e.state.selection.anchor.runId,e.state.selection.anchor.offset,e.state.selection.focus.paragraphId,e.state.selection.focus.runId,e.state.selection.focus.offset,P("selection")}),Dt(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||P("content-change")}),Dt(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{P("scroll")},o=()=>{P("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),pe(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const F=()=>x(null),A=()=>{C+=1,I.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:o,documentLayout:S,canvasSnapshotProvider:I,inputBox:a,selectionBoxes:l,commentHighlights:c,selectedImageBox:u,selectedTextBoxBox:g,selectedTableBox:m,caretBox:b,preferredColumnX:v,setPreferredColumnX:x,clearPreferredColumn:F,requestInputBoxSync:P,scheduleDeferredLayoutMeasurement:R,stabilizeLayoutAfterImport:M,syncMeasuredLayoutMetrics:k,syncInputBox:T,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:r,applyInvalidation:B,onCleanupHook:A}}(e)}function pb(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function gb(e){return function(e){const t=(e,t)=>{const n=a(e.document),o=Math.max(0,Math.min(Kn(e),n.length-1)),r=tr(e),i=n[o];if(!i)return e;const l=[...n],s={...i},c=Or("");if("header"===r){const e=[...i.header??[]];t<0?e.unshift(c):e.push(c),s.header=e}else if("footer"===r){const e=[...i.footer??[]];t<0?e.unshift(c):e.push(c),s.footer=e}else{const e=[...i.blocks];t<0?e.unshift(c):e.push(c),s.blocks=e}return l[o]=s,{...e,document:{...e.document,sections:l}}},n=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:pb(n.redoStack,o),lastTransactionMeta:null},nextState:n.undoStack[n.undoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},o=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.redoStack.length?null:{history:{undoStack:pb(n.undoStack,o),redoStack:n.redoStack.slice(0,-1),lastTransactionMeta:null},nextState:n.redoStack[n.redoStack.length-1]});var n,o;t&&(e.updateHistoryState(()=>t.history),e.clearPreferredColumn(),e.applyHistoryState(t.nextState),e.focusInput())},r=n=>{const o=e.imageOps().getSelectedImageInfo(e.state());if(!o)return!1;const r=ao(e.state()),a=r.findIndex(e=>e.id===o.paragraph.id);if(a<0)return!1;const i=a+n;if(i<0||i>=r.length){const o=e.state(),r=t(o,n),a=ao(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=ua(i,n<0?Se(i):0);return e.applyTransactionalState(()=>qh(r,l),{mergeKey:hi}),e.focusInput(),!0}const l=r[i],s=n<0?Se(l):0;return e.applyTransactionalState(e=>qh(e,ua(l,s)),{mergeKey:hi}),e.focusInput(),!0},i=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(Qo)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:i}}(e)}function fb(e={}){const t=e.dbName??"oasis-editor-db",n=e.storeName??"documents",o=e.key??"current-document";let r=null;async function a(){return r||(r=await function(e){return new Promise((t,n)=>{const o=indexedDB.open(e.name,e.version);o.onerror=()=>{n(/* @__PURE__ */new Error(`Failed to open IndexedDB: ${o.error?.message}`))},o.onsuccess=()=>{t(o.result)},o.onupgradeneeded=t=>{const n=o.result;e.onUpgrade(n,t.oldVersion,t.newVersion)}})}({name:t,version:1,onUpgrade:e=>{e.objectStoreNames.contains(n)||e.createObjectStore(n)}}),r)}return{async saveDocument(e){await function(e,t,n,o){return new Promise((r,a)=>{try{const i=e.transaction([t],"readwrite"),l=i.objectStore(t).put(o,n);l.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${l.error?.message}`))},i.oncomplete=()=>{r()},i.onabort=i.onerror=()=>{a(/* @__PURE__ */new Error(`Transaction failed putting item in ${t}: ${i.error?.message}`))}}catch(i){a(i)}})}(await a(),n,o,e)},loadDocument:async()=>function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readonly").objectStore(t).get(n);a.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to get item from ${t}: ${a.error?.message}`))},a.onsuccess=()=>{o(a.result??null)}}catch(a){r(a)}})}(await a(),n,o),async clearDocument(){await function(e,t,n){return new Promise((o,r)=>{try{const a=e.transaction([t],"readwrite"),i=a.objectStore(t).delete(n);i.onerror=()=>{r(/* @__PURE__ */new Error(`Failed to delete item from ${t}: ${i.error?.message}`))},a.oncomplete=()=>{o()},a.onabort=a.onerror=()=>{r(/* @__PURE__ */new Error(`Transaction failed deleting item from ${t}: ${a.error?.message}`))}}catch(a){r(a)}})}(await a(),n,o)},close(){r&&(r.close(),r=null)}}}function mb(e){return function(e){const[t,n]=Wt([]),[o,r]=Wt([]);let i={undoStack:[],redoStack:[],lastTransactionMeta:null};const l=()=>{n(i.undoStack),r(i.redoStack)},s=t=>{e.commitState(e.cloneState(t))},c=(t,n)=>{const o=e.stateSnapshot(),r=Wr("txn:produce",()=>t(o),0);if(r===o)return;i=function(e,t,n,o,r=Date.now()){return{undoStack:void 0!==o?.mergeKey&&e.lastTransactionMeta?.mergeKey===o.mergeKey&&r-e.lastTransactionMeta.timestamp<1e3?e.undoStack:pb(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(i,o,0,n),l();const s=Wr("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>a(e.document).map(e=>[...(e.header??[]).map(e=>e.id),...e.blocks.map(e=>e.id),...(e.footer??[]).map(e=>e.id)].join("|")).join("||");if(n(e)!==n(t))return{dirtyAll:!0,structureChanged:!0};const o=ao(e),r=ao(t),i=/* @__PURE__ */new Map;for(const a of o)i.set(a.id,a);const l=[];for(const a of r){const e=i.get(a.id);if(!e){l.push(a.id);continue}if(e===a)continue;if(e.runs.length!==a.runs.length){l.push(a.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=a.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const i=nn(o),l=nn(r);if(Boolean(i)!==Boolean(l)||(i?.width??-1)!==(l?.width??-1)||(i?.height??-1)!==(l?.height??-1)||(i?.floating?.wrap??"")!==(l?.floating?.wrap??"")||Boolean(i?.floating?.behindDoc)!==Boolean(l?.floating?.behindDoc)||(i?.wrapPolygon?.length??-1)!==(l?.wrapPolygon?.length??-1)){t=!0;break}}t&&l.push(a.id)}return{dirtyParagraphIds:l}}(o,r),0);e.applyLayoutInvalidation(s),Wr("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:c,applyHistoryState:s,resetTransactionGrouping:()=>{var e;e=i,i={...e,lastTransactionMeta:null}},updateHistoryState:e=>{i=e(i),l()},getHistoryState:()=>i,clearHistory:()=>{i={undoStack:[],redoStack:[],lastTransactionMeta:null},l()}}}(e)}function hb(e){Dt(()=>{var t;if(e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone,t=e.state,ni&&(ai={anchor:{paragraphId:t.selection.anchor.paragraphId,runId:t.selection.anchor.runId,offset:t.selection.anchor.offset},focus:{paragraphId:t.selection.focus.paragraphId,runId:t.selection.focus.runId,offset:t.selection.focus.offset},activeZone:t.activeZone??"main",activeSectionIndex:t.activeSectionIndex??0}),e.isImportInProgress())return;const n=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(n),e.emit("change",n),e.emit("documentChange",n.document),e.emit("selectionChange",n.selection)})}function bb(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:l,applyState:s,cloneState:c,isReadOnly:d,focusInput:u,surfaceRef:p,viewportRef:g,zoomFactor:f,getImageOps:m}=e,h=eb({state:()=>r,applyState:s,applyTransactionalState:(e,t)=>W(e,t),isReadOnly:d,surfaceRef:()=>p()??null,stabilizeLayoutAfterImport:async()=>{await A()},resetEditorChromeState:()=>G(),focusInput:u,requestLocalFontAccess:at,prepareDocumentFonts:async e=>{await ae(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),b=()=>"done"!==h.importProgress()?.phase&&"error"!==h.importProgress()?.phase&&null!==h.importProgress(),{measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:k,caretBox:R,preferredColumnX:B,setPreferredColumnX:M,clearPreferredColumn:F,stabilizeLayoutAfterImport:A,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyInvalidation:E,onCleanupHook:L}=ub({state:r,surfaceRef:p,viewportRef:g,isImporting:b,zoomFactor:f}),N=fb({key:t().persistenceKey}),{status:$}=function(e,t,n){const[o,r]=Wt("Initial"),[a,l]=Wt(!1),s=()=>n.enabled??!1,c=n.persistence,d=io(async e=>{if(s()&&a()){r("Saving...");try{const t=JSON.parse(JSON.stringify(i(e)));await c.saveDocument(t),r("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),r("Error")}}},1e3);return Dt(dr(()=>e.document,e=>{s()&&a()&&d(e)},{defer:!0})),Jt(async()=>{if(!s())return l(!0),void r("Saved");try{const e=await c.loadDocument();e&&t(e)}catch(e){n.logger?.error("persistence:load failed",e)}finally{l(!0),r("Saved")}}),{status:o}}(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=Tr(e);a(t),G()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??N,logger:n}),{undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_}=mb({stateSnapshot:l,commitState:a,cloneState:c,applyLayoutInvalidation:E}),X=gb({state:()=>r,stateSnapshot:l,applyHistoryState:U,applyTransactionalState:W,focusInput:u,clearPreferredColumn:F,imageOps:m,updateHistoryState:V,getHistoryState:K}),G=()=>{F(),O({}),D({}),_o(),w.clear(),_()};return hb({state:r,isImportInProgress:b,cloneState:c,getStateSnapshot:l,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:h,isImportInProgress:b,measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,selectedImageBox:T,selectedTextBoxBox:P,selectedTableBox:k,caretBox:R,preferredColumnX:B,setPreferredColumnX:M,clearPreferredColumn:F,stabilizeLayoutAfterImport:A,setMeasuredBlockHeights:O,setMeasuredParagraphLayouts:D,applyLayoutInvalidation:E,onCleanupHook:L,fallbackPersistence:N,persistenceStatus:$,undoStack:z,redoStack:H,applyTransactionalState:W,applyHistoryState:U,resetTransactionGrouping:j,updateHistoryState:V,getHistoryState:K,clearHistory:_,historyActions:X,resetEditorChromeState:G}}(e)}function yb(e){return Oh(e,e=>"textBox"===e.kind)}function vb(e,t){const n=yb(e);if(!n||!Qe(n.run))return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:a,run:i}=n,l=ao(e).map((e,t)=>t!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id===i.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:o(e))});return da(e,l,we(l,Bn(e)))}function xb(e,t){const n=yb(e);if(!n||!Qe(n.run))return e;const{paragraphIndex:r,run:a}=n,i=ao(e).map((e,n)=>n!==r?Gt(e):{...Gt(e),runs:e.runs.map(e=>{if(e.id!==a.id||"textBox"!==e.kind)return o(e);const n=t(e.textBox.floating),r={...e.textBox};return n?r.floating=n:delete r.floating,{...e,textBox:r}})});return da(e,i,we(i,Bn(e)))}function wb(e,t,n,r={}){const a=yb(e),i=a&&Qe(a.run);if(!a||!i)return e;const l=r.handleDirection??"se",s=l.includes("n")||l.includes("s"),c=l.includes("w"),d=l.includes("n"),u=Math.max(24,Math.round(t)),p=Math.max(24,Math.round(n)),{paragraphIndex:g,run:f}=a,m=u-i.width,h=p-i.height,b=ao(e).map((e,t)=>t!==g?Gt(e):{...Gt(e),runs:e.runs.map(e=>{if(e.id!==f.id||"textBox"!==e.kind)return o(e);const t=e.textBox,n={...t,width:u,height:p};return s&&t.body?.autoFit&&(n.body={...t.body,autoFit:!1}),t.floating&&(n.floating=function(e,t,n,o,r){let a=e;if(o&&0!==t){const n=e.positionH;n?.align||(a={...a,positionH:{...n??{},offset:(n?.offset??0)-t*Ko}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*Ko}})}return a}(t.floating,m,h,c,d)),{...e,textBox:n}})});return da(e,b,we(b,Bn(e)))}var Sb=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),Ib=e=>e.rows.reduce((e,t)=>Math.max(e,Sb(t)),0),Cb=(e,t)=>{let n=0;for(const o of e.cells){const e=Math.max(1,o.colSpan??1);if(t>=n&&t<n+e)return o;n+=e}return null};function Tb(e){if(!e)return null;for(const t of e.blocks){const e=We(t)[0];if(e)return e}return null}var Pb=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=Tb(e);if(t)return t}return null};function kb(e,t){return e.some(e=>We(e).some(e=>e.id===t))}var Rb=(e,t,n)=>{const o=Zr(e,t);if(!o)return null;const r=y(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!kb(o,n))continue;const e=T(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Zr(e,t);if(!n)return[];if("footnote"===n.zone){const t=n.footnoteId?e.footnotes?.items[n.footnoteId]:void 0;return t?[t.blocks]:[]}const o=Co(e)[n.sectionIndex];return o?"main"===n.zone?[o.blocks]:"header"===n.zone?[o.header,o.firstPageHeader,o.evenPageHeader].filter(e=>Boolean(e)):[o.footer,o.firstPageFooter,o.evenPageFooter].filter(e=>Boolean(e)):[]}(e,t),r.tablePath,t);if(!a)return null;const i=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),l=i.findIndex(e=>function(e,t){return e.blocks.some(e=>We(e).some(e=>e.id===t))}(e,t));if(-1===l)return null;const s=Tb(i[l+n]);return s?ua(s,0):null};function Bb(e,t){return Boolean(e?.some(e=>We(e).some(e=>e.id===t)))}function Mb(e,t,n){if("main"===n)return"blocks";const o=e.selection.focus.paragraphId;return"header"===n?[["header",t.header],["firstPageHeader",t.firstPageHeader],["evenPageHeader",t.evenPageHeader]].find(([,e])=>Bb(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>Bb(e,o))?.[0]??"footer":"blocks"}function Fb(e){const t=Zr(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function Ab(e,t){if("footnote"===t){const t=Fb(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=a(e.document),o=Kn(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const i=Mb(e,r,t);return"blocks"===i?r.blocks:r[i]??[]}var Ob=(e,t,n="main")=>{if("footnote"===n){const n=Fb(e),o=e.document.footnotes,r=n?o?.items[n]:void 0;return n&&o&&r?{...e,document:{...e.document,footnotes:{...o,items:{...o.items,[n]:{...r,blocks:t}}}}}:e}const o=Kn(e),r=a(e.document),i=Math.max(0,Math.min(o,r.length-1)),l=r[i];if(!l)return e;const s=Mb(e,l,n),c=[...r];return c[i]="blocks"===s?{...l,blocks:t}:{...l,[s]:t},{...e,document:{...e.document,sections:c}}};function Db(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Eb(e,t){const n=T(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:Db(t),targetBlocks:e}:null}function Lb(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];if(!a||"table"!==a.type)return null;const i=[...r];return i[o.tableBlockIndex]=bo(a),Eb(i,n)}var Nb=(e,t,n)=>{const o=y(e.document,e.selection.focus.paragraphId,Kn(e));if(!o||e.selection.anchor.paragraphId!==e.selection.focus.paragraphId)return n(e);const r=function(e,t,n){const o=n.tablePath[0];if(!o)return null;const r=t(e,n.zone),a=r[o.tableBlockIndex];return a&&"table"===a.type?Eb(function(e,t){const n=[...e];let o=n;for(let r=0;r<t.length;r+=1){const e=t[r];if(!e)break;const n=o[e.tableBlockIndex];if(!n||"table"!==n.type)break;const a={...n,rows:[...n.rows]};o[e.tableBlockIndex]=a;const i=a.rows[e.rowIndex];if(!i)break;const l={...i,cells:[...i.cells]};a.rows[e.rowIndex]=l;const s=l.cells[e.cellIndex];if(!s)break;const c={...s,blocks:[...s.blocks]};l.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,o);if(!r)return n(e);const i=n({...e,document:Mo(r.targetCell.blocks.map(e=>"paragraph"===e.type?Gt(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),l=a(i.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...l),{...Ob(e,r.targetBlocks,o.zone),selection:i.selection}};function $b(e,t){const n=y(e.document,e.selection.focus.paragraphId,Kn(e));return n?Lb(e,t,n):null}function zb(e,t,n,o){const r=Ob(e,t,n);return o?{...r,selection:{anchor:ua(o,0),focus:ua(o,0)}}:r}function Hb(e,t,n,o){const r=t.getTargetBlocks(e,n),a=T(r,o);return a?.[a.length-1]?.table??null}function Wb(e,t){const n=y(e.document,e.selection.focus.paragraphId,Kn(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Hb(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function Ub(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Wb(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.colSpan??1)>1)},o=t=>{const n=e.resolveVerticalTableCellRange(t);if(!n)return!1;const o=Hb(t,e,n.zone,n.tablePath);if(!o)return!1;for(let e=n.startRowIndex;e<=n.endRowIndex;e+=1){const t=o.rows[e]?.cells[n.cellIndex];if(!t||"continue"===t.vMerge||1!==t.blocks.length||"paragraph"!==t.blocks[0]?.type)return!1}return!0},r=e=>t(e)||o(e),a=t=>{const n=Wb(t,e);if(!n)return!1;const o=n.table.rows[n.rowIndex]?.cells[n.cellIndex];return Boolean((o?.rowSpan??1)>1&&"restart"===o?.vMerge)},i=e=>n(e)||a(e),l=t=>null!==Wb(t,e),s=t=>{const n=Wb(t,e);return Boolean(n&&Ib(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function jb(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function Vb(e){return e.blocks.flatMap(We)}function Kb(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function _b(e,t){return function(e,t){const n=e.selection,o=Kn(e),r=y(e.document,n.anchor.paragraphId,o),a=y(e.document,n.focus.paragraphId,o);if(!r||!a||r.zone!==a.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(r.tablePath,a.tablePath))return null;const i=t.getTargetBlocks(e,r.zone),l=T(i,r.tablePath),s=T(i,a.tablePath),c=l?.[l.length-1],d=s?.[s.length-1];if(!c||!d||c.table!==d.table)return null;const u=Kb(r),p=Kb(a),g=c.table,f=Xt(g),m=f.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex),h=f.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex);return m&&h?{anchorLocation:u,focusLocation:p,anchorCell:m,focusCell:h,tableBlock:g,tableLayout:f}:null}(e,t)}function Xb(e){return function(e){const t=t=>{const n=t.selection,o=_b(t,e);if(!o||o.anchorLocation.rowIndex===o.focusLocation.rowIndex&&o.anchorLocation.cellIndex===o.focusLocation.cellIndex)return e.logger?.debug(`resolveTableCellRangeSelection: no expansion (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId})`),null;const r=Math.min(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),a=Math.max(o.anchorLocation.rowIndex,o.focusLocation.rowIndex),i=Math.min(o.anchorLocation.cellIndex,o.focusLocation.cellIndex),l=Math.max(o.anchorLocation.cellIndex,o.focusLocation.cellIndex);e.logger?.info(`resolveTableCellRangeSelection: expanding r${o.anchorLocation.rowIndex}:c${o.anchorLocation.cellIndex}->r${o.focusLocation.rowIndex}:c${o.focusLocation.cellIndex} (anchor=${n.anchor.paragraphId} focus=${n.focus.paragraphId}) range=[rows ${r}..${a}, cells ${i}..${l}]`);const s=jb(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=jb(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[s.rowIndex]?.cells[s.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?Vb(d)[0]:void 0,g=u?Vb(u):[],f=g[g.length-1];return p&&f?{anchor:ua(p,0),focus:ua(f,ot(f).length)}:null},n=t=>{const n=_b(t,e);if(!n)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex+n.anchorCell.rowSpan-1,n.focusCell.visualRowIndex+n.focusCell.rowSpan-1),a=Math.min(n.anchorCell.visualColumnIndex,n.focusCell.visualColumnIndex),i=Math.max(n.anchorCell.visualColumnIndex+n.anchorCell.colSpan-1,n.focusCell.visualColumnIndex+n.focusCell.colSpan-1),l=n.tableLayout.filter(e=>e.visualRowIndex<=r&&e.visualRowIndex+e.rowSpan-1>=o&&e.visualColumnIndex<=i&&e.visualColumnIndex+e.colSpan-1>=a);return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),cells:l,zone:n.anchorLocation.zone}},o=t=>{const n=_b(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=jb(n.anchorCell,n.focusCell);if(0===o)return null;const r=o<=0?n.anchorLocation:n.focusLocation,a=o<=0?n.focusLocation:n.anchorLocation;return{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),rowIndex:r.rowIndex,startCellIndex:r.cellIndex,endCellIndex:a.cellIndex,zone:n.anchorLocation.zone}},r=t=>{const n=_b(t,e);if(!n||n.anchorLocation.cellIndex!==n.focusLocation.cellIndex)return null;const o=Math.min(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex),r=Math.max(n.anchorCell.visualRowIndex,n.focusCell.visualRowIndex);return o===r?null:{blockIndex:n.anchorLocation.blockIndex,tablePath:n.anchorLocation.tablePath.map(e=>({...e})),startRowIndex:o,endRowIndex:r,cellIndex:n.anchorLocation.cellIndex,zone:n.anchorLocation.zone}};return{resolveTableCellRangeSelection:t,resolveSelectedTableCells:n,resolveHorizontalTableCellRange:o,resolveVerticalTableCellRange:r}}(e)}function Gb(e){if(e)for(const t of e.blocks){const e=We(t)[0];if(e)return e}}function Yb(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Lb(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function qb(e){return function(e){const t=e=>({...e,style:e.style?{...e.style}:void 0,conditionalStyle:e.conditionalStyle?{...e.conditionalStyle}:void 0,mergeRevisionState:void 0,blocks:e.blocks.map(e=>bo(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Yb(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=a.rows[o.rowIndex];if(!l)return n;const s=l.cells.slice(o.startCellIndex,o.endCellIndex+1);if(s.length<2)return n;const c=n.trackChangesEnabled?Ll():void 0,d={...s[0],colSpan:s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:s.flatMap(e=>e.blocks.map(e=>bo(e))),...c?{style:{...s[0].style??{},revision:{...c,type:"merge",previous:{colSpan:s[0].colSpan,rowSpan:s[0].rowSpan,vMerge:s[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"horizontal",currentCellCount:1,previousCells:s.map(t)}}:{}};l.cells.splice(o.startCellIndex,s.length,d);const u=Gb(d);return u?zb(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Yb(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,l=[];for(let e=o.startRowIndex;e<=o.endRowIndex;e+=1){const t=a.rows[e],r=t?.cells[o.cellIndex];if(!t||!r||"continue"===r.vMerge||1!==r.blocks.length||"paragraph"!==r.blocks[0]?.type)return n;l.push(r)}if(l.length<2)return n;const s=Math.max(1,l[0].colSpan??1);if(!l.every(e=>Math.max(1,e.colSpan??1)===s))return n;const c=n.trackChangesEnabled?Ll():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>bo(e))),...c?{style:{...l[0].style??{},revision:{...c,type:"merge",previous:{colSpan:l[0].colSpan,rowSpan:l[0].rowSpan,vMerge:l[0].vMerge}}},mergeRevisionState:{revisionId:c.id,orientation:"vertical",currentCellCount:1,previousCells:l.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=so([Or("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Gb(d);return u?zb(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=$b(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex]?.cells[a.cellIndex],s=Math.max(1,l?.rowSpan??1);if(!l||s<=1||"restart"!==l.vMerge)return n;const c=t(l),d=n.trackChangesEnabled?Ll():void 0,u=Math.max(1,l.colSpan??1);l.rowSpan=void 0,l.vMerge=void 0,d&&(l.style={...l.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},l.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:s-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):so([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=so([Or("")],u);t.cells[a.cellIndex]=n}const p=Gb(l);return p?zb(n,i,a.zone,p):n},i=n=>{const o=$b(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex],s=l?.cells[a.cellIndex],c=Math.max(1,s?.colSpan??1);if(!l||!s||c<=1)return n;const d=t(s),u=n.trackChangesEnabled?Ll():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>bo(e)),...u?{style:{...s.style??{},revision:{...u,type:"merge",previous:{colSpan:d.colSpan,rowSpan:d.rowSpan,vMerge:d.vMerge}}},mergeRevisionState:{revisionId:u.id,orientation:"horizontal",currentCellCount:c,previousCells:[d]}}:{}},...Array.from({length:c-1},()=>so([Or("")]))];l.cells.splice(a.cellIndex,1,...p);const g=Gb(p[0]);return g?zb(n,i,a.zone,g):n},l=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:l}}(e)}function Zb(e,t){e.style={...e.style??{},revision:{...Ll(),type:t}}}function Jb(e){if(!e)return null;for(const t of e.blocks){const e=We(t)[0];if(e)return e}return null}function Qb(e,t,n){const o=Jb(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=Jb(r);if(e)return e}return Pb(e)}function ey(e){return function(e){const t=(t,n)=>{const o=$b(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,l=r.rows[a.rowIndex];if(!l)return t;const s=Math.max(0,Math.min(r.rows.length,a.rowIndex+(n>0?1:0)));let c;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge))){const e=Xt(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),l=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=to(l.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<s&&e.visualRowIndex+e.rowSpan>s);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=so([Or("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return so([Or("")],t.colSpan)})),t.trackChangesEnabled&&Zb(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=Qb(r,Cb(c,d),c);return zb(t,i,a.zone,u)}c=to(l.cells.map(e=>so([Or("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&Zb(c,"insert"),r.rows.splice(s,0,c);const d=Qb(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return zb(t,i,a.zone,d)},n=t=>{const n=$b(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(o.rows.length<=1&&!t.trackChangesEnabled)return t;const i=o.rows[r.rowIndex];if(!i)return t;if(t.trackChangesEnabled)return Zb(i,"delete"),zb(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const l=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),s=l?Xt(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=Xt(o);for(const t of e)t.visualRowIndex<r.rowIndex&&t.visualRowIndex+t.rowSpan>r.rowIndex&&(t.cell.rowSpan=Math.max(1,t.cell.rowSpan??1)-1,t.cell.rowSpan<=1?(t.cell.rowSpan=void 0,t.cell.vMerge=void 0):t.cell.vMerge="restart")}o.rows.splice(r.rowIndex,1);const c=o.rows[Math.min(r.rowIndex,o.rows.length-1)],d=Qb(o,c?Cb(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,Sb(c)-1))):null);return zb(t,a,r.zone,d)},o=(t,n)=>{const o=$b(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o;if(r.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Xt(r).find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=(e?.visualColumnIndex??a.cellIndex)+(n>0?Math.max(1,e?.colSpan??1):0);for(const n of r.rows){const e=[];let r=0,a=!1;for(const i of n.cells){const n=Math.max(1,i.colSpan??1);if(!a&&o<=r){const n=so([Or("")]);t.trackChangesEnabled&&Zb(n,"insert"),e.push(n),a=!0}!a&&r<o&&o<r+n?(e.push({...i,colSpan:n+1,...t.trackChangesEnabled?{style:{...i.style??{},revision:{...Ll(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=so([Or("")]);t.trackChangesEnabled&&Zb(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=Qb(r,l?Cb(l,o):null);return zb(t,i,a.zone,s)}const l=Math.max(0,Math.min(r.rows[0]?.cells.length??0,a.cellIndex+(n>0?1:0)));for(const e of r.rows){const n=so([Or("")]);t.trackChangesEnabled&&Zb(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=Qb(r,s);return zb(t,i,a.zone,c)},r=t=>{const n=$b(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(Ib(o)<=1)return t;if(t.trackChangesEnabled){const e=Xt(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=Cb(t,e);n&&Zb(n,"delete")}return zb(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Xt(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=[];let o=0;for(const r of t.cells){const t=Math.max(1,r.colSpan??1);e>=o&&e<o+t?t>1&&n.push({...r,colSpan:t-1>1?t-1:void 0}):n.push(r),o+=t}t.cells=n}const n=o.rows[r.rowIndex],i=Qb(o,n&&Cb(n,Math.min(e,Math.max(0,Sb(n)-1))));return zb(t,a,r.zone,i)}if(o.rows[0]?.cells.length<=1)return t;for(const e of o.rows)e.cells.splice(r.cellIndex,1);const i=o.rows[r.rowIndex],l=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],s=Qb(o,l);return zb(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function ty(e){return function(e){const t=t=>{const n=e.resolveTableCellRangeSelection(t);return n?e.applySelectionToStatePreservingStructure(t,n):t},n=(n,o)=>{e.applyTransactionalState(r=>{const a=e.resolveSelectedTableCells(r);if(!a||a.cells.length<=1){const a=t(r);return a!==r&&e.logger?.info(`${o}: expanded selection to ${a.selection.anchor.paragraphId}[${a.selection.anchor.offset}]..${a.selection.focus.paragraphId}[${a.selection.focus.offset}]`),n(a)}const{blockIndex:i,tablePath:l,cells:s,zone:c}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${l.length} (${s.length} cells) in zone ${c}`);const u=[],p=[];for(const e of s){const t=e.cell.blocks.flatMap(We);u.push(...t),p.push(t.length)}if(0===u.length)return r;const g=n({...r,document:Mo(u,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:ua(u[0],0),focus:ua(u[u.length-1],ot(u[u.length-1]).length)}}),f=ao(g),m=l[l.length-1];if(!m)return r;const h=Lb(r,e.getTargetBlocks,{blockIndex:i,rowIndex:m.rowIndex,cellIndex:m.cellIndex,paragraphIndex:0,tablePath:l,zone:c});if(!h)return r;let b=0;for(let e=0;e<s.length;e+=1){const t=s[e],n=p[e]??0,o=f.slice(b,b+n);b+=n;const r=h.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=d(r.blocks,o))}return Ob(r,h.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function ny(e){return function(e){const t=Ab,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Xb({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=Ub({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=qb({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I}=ey({getTargetBlocks:t}),C=(e,n)=>Nb(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:k}=ty({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,logger:e.logger}),R=(t,n)=>{e.logger?.info(`insertTableCommand: ${t}x${n}`),e.applyTransactionalState(e=>function(e,t,n){const o=100/Math.max(1,n)+"%",r=e.trackChangesEnabled?Ll():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...so([Or("")]),style:{width:o}});const t=to(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...zo(a),style:{width:"100%"}},l=fr(e,e.selection.focus),s=Co(e.document),c=Kn(e),d=tr(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&We(e).some(e=>e.id===l.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=s[c];if(!p)return e;const g={...p};let f=!1;if("header"===d){const e=u(p.header??[]);g.header=e.nextBlocks,f=e.found}else if("footer"===d){const e=u(p.footer??[]);g.footer=e.nextBlocks,f=e.found}else{const e=u(p.blocks);g.blocks=e.nextBlocks,f=e.found}if(!f)return e;const m=[...s];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:nt(ua(h,0))}}(e,t,n),{mergeKey:mi}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I,getRowVisualWidth:Sb,getTableVisualWidth:Ib,findCellAtVisualColumn:Cb,findFirstNavigableParagraphInTable:Pb,updateBlocksInCurrentSection:Ob,resolveAdjacentTableCellPosition:Rb,applyTableAwareParagraphEdit:C,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:k,insertTableCommand:R}}(e)}function oy(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function ry(e,t){let n=null;const o=(e,t,n)=>{const o=ao(e).find(e=>e.id===t);return o?{anchor:ua(o,n),focus:ua(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=oy(),i=i=>{if(!a.owns(i))return;const l=n;if(!l)return;const s=t.zoomFactor?.()??1,c=(i.clientX-l.startClientX)/s,d=(i.clientY-l.startClientY)/s,u=e.getMaxWidth(t.state,l.paragraphId),{width:p,height:g}=st(l,c,d,i.shiftKey,u),f=o(t.state,l.paragraphId,l.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,l.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,l)},l=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:pb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),s(),t.focusInput()},s=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)};return{start:(s,c,d,u,p)=>{const g=o(p,s,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:s,paragraphOffset:c,handleDirection:d,startClientX:u.clientX,startClientY:u.clientY,startWidth:f.width,startHeight:f.height,aspectRatio:f.width/f.height,initialState:t.cloneState(p)},a.claim(u),window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l))},stop:s}}function ay(e,t){let n=null;const o=oy(),r=r=>{if(!o.owns(r))return;const a=n;if(!a)return;let i=((180*Math.atan2(r.clientY-a.centerY,r.clientX-a.centerX)/Math.PI+90)%360+360)%360;r.shiftKey&&(i=15*Math.round(i/15)%360);const l=((e,t,n)=>{const o=ao(e).find(e=>e.id===t);return o?{anchor:ua(o,n),focus:ua(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);l?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,l),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:pb(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),i(),t.focusInput()},i=()=>{n=null,o.release(),window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)};return{start:(e,i,l,s)=>{const c=l.currentTarget.closest(".oasis-editor-selection-overlay");if(!c)return;const d=c.getBoundingClientRect();n={paragraphId:e,paragraphOffset:i,centerX:d.left+d.width/2,centerY:d.top+d.height/2,initialState:t.cloneState(s)},o.claim(l),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function iy(e,t){return Math.max(1e-4,1-e-t)}function ly(e,t,n,o){const r=Math.max(.01,1-e-t),a=Math.max(0,Math.min(n,.99-t)),i=Math.max(0,Math.min(o,.99-a));return a+i>=.99?{near:Math.max(0,.99-r-t),far:t}:{near:a,far:i}}function sy(e){let t=null;const n=(e,t,n)=>{const o=ao(e).find(e=>e.id===t);return o?{anchor:ua(o,n),focus:ua(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=oy(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const l=e.zoomFactor?.()??1,s=(a.clientX-i.startClientX)/l,c=(a.clientY-i.startClientY)/l,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=iy(a,l)/o,d=iy(i,s)/r,u=1-a-l,p=1-i-s,g=Math.max(0,Math.min(1-u,a-t*c)),f=Math.max(0,Math.min(1-p,i-n*d));return{crop:{left:g,right:Math.max(0,1-u-g),top:f,bottom:Math.max(0,1-p-f)},width:Math.round(o),height:Math.round(r)}}(i,s,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,l=e.startCrop.right??0,s=e.startCrop.bottom??0,c=iy(a,l)/o,d=iy(i,s)/r,u=se(e.handleDirection,"x"),p=se(e.handleDirection,"y");let g=a,f=l,m=o;if(0!==u)if(u<0){m=ke(o-t,24,o+a/c);const e=ly(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=ke(o+t,24,o+l/c);const e=ly(a,l,a,l-(m-o)*c);g=e.near,f=e.far}let h=i,b=s,y=r;if(0!==p)if(p<0){y=ke(r-n,24,r+i/d);const e=ly(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=ke(r+n,24,r+s/d);const e=ly(i,s,i,s-(y-r)*d);h=e.near,b=e.far}return{crop:{left:g,top:h,right:f,bottom:b},width:Math.round(m),height:Math.round(y)}}(i,s,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(Wh(o(e.state,u),{crop:d.crop,width:d.width,height:d.height})):e.logger.warn("image crop:missing paragraph",i)},i=()=>{const n=t;n&&e.updateHistoryState(t=>({...t,undoStack:pb(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),l(),e.focusInput()},l=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},s=(l,s,c,d,u,p)=>{const g=n(u,l,s);if(!g)return;const f=$h(o(u,g)),m=f&&nn(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:l,paragraphOffset:s,handleDirection:c,startClientX:d.clientX,startClientY:d.clientY,startWidth:m.width,startHeight:m.height,startCrop:h,initialState:e.cloneState(u),mode:p},r.claim(d),window.addEventListener("pointermove",a),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i)};return{start:(e,t,n,o,r)=>s(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>s(e,t,"se",n,o,"move"),stop:l}}function cy(e){return function(e){const[t,n]=Wt(!1),[o,r]=Wt(!1),[a,i]=Wt(null);Dt(()=>{o()&&!m(e.state)&&r(!1)});const l=()=>{m(e.state)?r(e=>!e):r(!1)},[s,c]=Wt({x:0,y:0}),[d,u]=Wt(null);let p=null,g=null,f=null;const m=e=>{const t=Bn(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=ao(e)[t.startIndex];if(!n)return null;let o=0;for(const r of n.runs){const a=o;if(o+=r.text.length,"image"===r.kind&&1===r.text.length&&a===t.startParagraphOffset)return{paragraph:n,run:r,startOffset:a,width:r.image.width,height:r.image.height,src:vo(e.document,r.image.src)}}return null},h=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),b=()=>{f||(f=document.createElement("style"),f.setAttribute("data-oasis-image-drag-cursor",""),f.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(f))},y=()=>{f&&(f.remove(),f=null),document.body.style.cursor=""},v=oy(),x=()=>{y(),g=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P)},w=()=>{x()},S=ry({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>zh(e,t,n),getMaxWidth:(t,n)=>Zh(e.surfaceRef(),t.document,n,t.activeSectionIndex??0)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),I=ay({label:"image",applyRotate:(e,t)=>function(e,t){const n=Kh(t);return Gh(e,e=>({...e,rotation:n}))}(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),C=sy({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),T=t=>{if(!v.owns(t))return;let o=p;if(!o){const r=g;if(!r)return;if(Math.abs(t.clientX-r.startClientX)+Math.abs(t.clientY-r.startClientY)<4)return;o={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},p=o,g=null,n(!0),b(),e.logger.info(`image drag:start ${o.paragraphId}@${o.paragraphOffset} client=(${t.clientX},${t.clientY})`)}c({x:t.clientX,y:t.clientY}),i({...o}),u(h(t.clientX,t.clientY))},P=t=>{if(!v.owns(t))return;const n=p;if(n||g){if(n){const o=h(t.clientX,t.clientY);o?(e.logger.info(`image drag:done ${n.paragraphId} -> ${o.paragraphId}:${o.runId}[${o.offset}]`),e.applyTransactionalState(e=>qh(e,o),{mergeKey:hi})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},k=(t,o,r,a)=>{const l=r.currentTarget,s=a?{left:a.left,top:a.top,width:a.width,height:a.height}:l?.getBoundingClientRect();if(!s)return;const d=m(e.state);g={paragraphId:t,paragraphOffset:o,startClientX:r.clientX,startClientY:r.clientY,src:d?.src??"",width:d?.width??s.width,height:d?.height??s.height,offsetX:r.clientX-s.left,offsetY:r.clientY-s.top},p=null,c({x:r.clientX,y:r.clientY}),n(!1),i(null),u(null),v.claim(r),window.addEventListener("pointermove",T),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P)},R=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=Vr(e.state.document).find(e=>e.id===t);r&&e.applyState(Sa(e.state,{anchor:ua(r,n),focus:ua(r,n+1)})),k(t,n,o),e.focusInputAfterPointerSelection()},B=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,o,r,e.state)},M=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),I.start(t,n,o,e.state)},F=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),C.start(t,n,o,r,e.state)},A=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:l,draggedImageInfo:a,mousePos:s,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:k,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:I.stop,stopImageCrop:C.stop,handleImagePointerDown:R,handleImageResizeHandlePointerDown:B,handleImageRotateHandlePointerDown:M,handleImageCropHandlePointerDown:F,handleImageCropBodyPointerDown:A}}(e)}function dy(e){return function(e){const t=e=>{const t=yb(e),n=t&&Qe(t.run);return n?{width:n.width,height:et(n,e,0)}:null},n=ry({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>wb(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=Zh(e.surfaceRef(),n.document,o,n.activeSectionIndex??0),a=t(n);return a?Math.max(r,a.width):r}},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),o=ay({label:"text box",applyRotate:(e,t)=>vb(e,t)},{state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger}),r=(t,o,r,a)=>{a.preventDefault(),a.stopPropagation(),n.start(t,o,r,a,e.state)},a=(t,n,r)=>{r.preventDefault(),r.stopPropagation(),o.start(t,n,r,e.state)};return{handleTextBoxResizeHandlePointerDown:r,handleTextBoxRotateHandlePointerDown:a,stopTextBoxResize:n.stop,stopTextBoxRotate:o.stop}}(e)}function uy(e){return function(e){const[t,n]=Wt(void 0),o=()=>{n(void 0)};Dt(()=>{vr(e.state().selection)||o()});const r=(e,t)=>{n(n=>{const o={...n??{}};return null==t||""===t?delete o[e]:o[e]=t,Object.keys(o).length>0?o:void 0})},a=(e,t)=>{n(n=>{const o={...n??{}};return o[e]=t,"superscript"===e&&t&&(o.subscript=!1),"subscript"===e&&t&&(o.superscript=!1),o})},i=()=>{const n=$(e.state()),o=t();return vr(e.state().selection)&&o?{...n,bold:o.bold??n.bold,italic:o.italic??n.italic,underline:o.underline??n.underline,underlineStyle:void 0!==o.underlineStyle?String(o.underlineStyle??""):n.underlineStyle,strike:o.strike??n.strike,superscript:o.superscript??n.superscript,subscript:o.subscript??n.subscript,fontFamily:o.fontFamily??n.fontFamily,fontSize:void 0!==o.fontSize&&null!==o.fontSize?String(o.fontSize):n.fontSize,color:o.color??n.color,highlight:o.highlight??n.highlight,textShading:o.shading??n.textShading,link:o.link??n.link,characterStyleId:void 0!==o.styleId&&null!==o.styleId?String(o.styleId):n.characterStyleId}:n},l=(t,n)=>{if(vr(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),r(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},s=t=>{if(vr(e.state().selection)){const n=!i()[t];return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),a(t,n),void e.focusInput()}e.commandsController().applyBooleanStyleCommand(t)},c=t=>{if(vr(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),n(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:o,toolbarStyleState:i,applyToolbarValueStyleCommand:l,applyToolbarUnderlineStyleCommand:c,applyToolbarBooleanStyleCommand:s}}(e)}function py(e,t,n={}){if(!t)return[];const o=[],r=Vr(e),{matchCase:a=!1,wholeWord:i=!1}=n,l=a?"g":"gi";let s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(s=`\\b${s}\\b`);const c=new RegExp(s,l);return r.forEach((e,t)=>{const n=ot(e);let r;for(c.lastIndex=0;null!==(r=c.exec(n));){const n=r.index,a=r.index+r[0].length;o.push({anchor:ua(e,n),focus:ua(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function gy(e,t,n,o={}){const r=py(e.document,t,o);if(0===r.length)return e;let a=e;for(let i=r.length-1;i>=0;i-=1){const e=r[i];a=Sa(a,{anchor:e.anchor,focus:e.focus}),a=Fa(a,n)}return a}function fy(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*H+(r<e?e-r:r>i?r-i:0)}function my(e,t,n){if(0===e.slots.length)return{offset:e.startOffset,score:Number.POSITIVE_INFINITY};let o=e.slots[0].offset,r=Number.POSITIVE_INFINITY,a=e.slots[0].left,i=e.slots[0].top,l=e.slots[0].height;for(const s of e.slots){const e=n<s.top?s.top-n:n>s.top+s.height?n-(s.top+s.height):0,c=Math.abs(t-s.left),d=e*H+c;d<r&&(r=d,o=s.offset,a=s.left,i=s.top,l=s.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:l}}function hy(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=my(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function by(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function yy(e){const{snapshot:t,state:n}=e,o=e.pierce??!1,r=e.zoomFactor&&e.zoomFactor>0?e.zoomFactor:1,a=t.surfaceRect,i=a.left+(e.clientX-a.left)/r,l=a.top+(e.clientY-a.top)/r,s=function(e,t,n){if(0===e.length)return null;let o=e[0],r=Number.POSITIVE_INFINITY;for(const a of e){const e=fy(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,l);if(!s)return null;const c=function(e,t){const n=t-e.top;return n<e.bodyTop?"header":void 0!==e.footnoteSeparatorTop&&n>=e.footnoteSeparatorTop&&n<(e.footerTop??e.height)?"footnote":n>=e.bodyBottom?"footer":"main"}(s,l),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const l=e.floatingTextBoxes[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&o>=l.left&&o<=l.left+l.width&&r>=l.top&&r<=l.top+l.height)return l}return null}(t,s.index,c,i,l,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&d.startOffset>=e.startOffset&&d.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(d.startOffset,n.endOffset)),t=ua(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:d.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:d.left,top:d.top,height:d.height},textBox:{paragraphId:d.paragraphId,paragraphOffset:e,startOffset:d.startOffset,endOffset:d.endOffset,left:d.left,top:d.top,width:d.width,height:d.height}}}}const u=function(e,t,n,o,r,a){for(let i=e.floatingImages.length-1;i>=0;i-=1){const l=e.floatingImages[i];if(l.pageIndex===t&&l.zone===n&&(!l.behindDoc||a)&&by(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&by(o,r,i))return i;return null}(t,s.index,c,i,l,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===s.index&&e.zone===c&&u.startOffset>=e.startOffset&&u.startOffset<=e.endOffset)??e[0];if(n){const e=Math.max(n.startOffset,Math.min(u.startOffset,n.endOffset)),t=ua(n.paragraph,e);return{zone:c,footnoteId:n.footnoteId,paragraphId:u.paragraphId,paragraphOffset:e,position:t,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:n.tableCell?.anchorPosition,caretViewport:{left:u.left,top:u.top,height:u.height},image:{paragraphId:u.paragraphId,paragraphOffset:e,startOffset:u.startOffset,endOffset:u.endOffset,left:u.left,top:u.top,width:u.width,height:u.height}}}}const p=function(e,t,n){if(0===e.length)return null;let o=null;for(const i of e)for(const e of i.lines){const r=e.top-2,a=e.top+e.height+2;if(n<r||n>a)continue;const{offset:l,score:s,slotLeft:c,slotTop:d,slotHeight:u}=my(e,t,n);(!o||s<o.score)&&(o={paragraph:i,offset:l,score:s,caretViewport:void 0!==c&&void 0!==d&&void 0!==u?{left:c,top:d,height:u}:void 0})}if(o)return{paragraph:o.paragraph,offset:o.offset,caretViewport:o.caretViewport};let r=null,a=Number.POSITIVE_INFINITY;for(const i of e){const e=fy(i.left,i.top,Math.max(1,i.width),Math.max(1,i.height),t,n);e<a&&(a=e,r=i)}return r?{paragraph:r,offset:hy(r,t,n),caretViewport:{left:r.left,top:r.top,height:Math.max(16,Math.min(32,r.height||24))}}:null}(t.paragraphs.filter(e=>e.pageIndex===s.index&&e.zone===c),i,l);if(!p){const e=n.selection.focus.paragraphId,o=n.selection.focus.offset,r=function(e,t,n,o,r){return e.unsupportedRegions.find(e=>e.pageIndex===t&&e.zone===n&&o>=e.left&&o<=e.left+e.width&&r>=e.top&&r<=e.top+e.height)?.reason??null}(t,s.index,c,i,l);return{zone:c,paragraphId:e,paragraphOffset:o,position:{...n.selection.focus},source:"canvas-layout",resolvedFromParagraph:!1,missReason:r??"zone-without-paragraph"}}const g=p.paragraph,f=Math.max(0,Math.min(p.offset,g.textLength)),m=ua(g.paragraph,f);return{zone:c,footnoteId:g.footnoteId,paragraphId:g.paragraphId,paragraphOffset:f,position:m,source:"canvas-layout",resolvedFromParagraph:!0,tableCellAnchorPosition:g.tableCell?.anchorPosition,caretViewport:p.caretViewport}}function vy(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),l=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){ni&&(ri=e?function(e){return{surfaceRect:{left:e.surfaceRect.left,top:e.surfaceRect.top,width:e.surfaceRect.width,height:e.surfaceRect.height},pages:(t=e.pages,t.map(e=>({index:e.index,left:e.left,top:e.top,width:e.width,height:e.height,bodyTop:e.bodyTop,bodyBottom:e.bodyBottom}))),paragraphs:e.paragraphs.map(e=>{return{paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,textLength:e.textLength,left:e.left,top:e.top,width:e.width,height:e.height,lines:(t=e.lines,t.map(e=>{return{startOffset:e.startOffset,endOffset:e.endOffset,top:e.top,height:e.height,slots:(t=e.slots,t.map(e=>({offset:e.offset,left:e.left,top:e.top,height:e.height})))};var t})),tableCell:e.tableCell?{tableId:e.tableCell.tableId,rowIndex:e.tableCell.rowIndex,cellIndex:e.tableCell.cellIndex,left:e.tableCell.left,top:e.tableCell.top,width:e.tableCell.width,height:e.tableCell.height}:void 0,verticalMode:e.verticalMode};var t}),inlineImages:e.inlineImages.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height})),inlineTextBoxes:e.inlineTextBoxes.map(e=>({paragraphId:e.paragraphId,paragraphIndex:e.paragraphIndex,zone:e.zone,pageIndex:e.pageIndex,startOffset:e.startOffset,endOffset:e.endOffset,left:e.left,top:e.top,width:e.width,height:e.height,rotation:e.rotation})),unsupportedRegions:e.unsupportedRegions.map(e=>({...e}))};var t}(e):null)}(l),!l)return si(null),null;const s=yy({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return si(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var xy=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],wy=/* @__PURE__ */new Map;function Sy(){return xy.map(e=>({...e}))}var Iy=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function Cy(e,t,n){const[o,r]=e,[a,i]=t,[l,s]=n,c=l-a,d=s-i,u=c*c+d*d;return 0===u?Math.hypot(o-a,r-i):Math.abs(c*(i-r)-d*(a-o))/Math.sqrt(u)}function Ty(e,t){if(e.length<3)return e.slice();let n=0,o=0;const r=e[0],a=e[e.length-1];for(let s=1;s<e.length-1;s+=1){const t=Cy(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=Ty(e.slice(0,o+1),t),l=Ty(e.slice(o),t);return[...i.slice(0,-1),...l]}function Py(e,t,n){let o=0;for(let s=0;s<e.length;s+=1)1===e[s]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return Sy();const r=function(e,t,n){const o=(o,r)=>o>=0&&o<t&&r>=0&&r<n&&1===e[r*t+o];let r=-1,a=-1;for(let u=0;u<n&&a<0;u+=1)for(let n=0;n<t;n+=1)if(1===e[u*t+n]){r=n,a=u;break}if(r<0)return[];const i=[];let l=r,s=a,c=6;const d=t*n*4;for(let u=0;u<d;u+=1){let e=!1;for(let t=1;t<=8;t+=1){const n=(c+t)%8,[r,a]=Iy[n],d=l+r,u=s+a;if(o(d,u)){i.push([l,s]),c=(n+4)%8,l=d,s=u,e=!0;break}}if(!e){i.push([l,s]);break}if(l===r&&s===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return Sy();const a=.012*Math.max(t,n);let i=Ty(r,a),l=a;for(;i.length>40;)l*=1.6,i=Ty(r,l);return i.length<3?Sy():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function ky(e){const t=e.src,n=wy.get(t);if(n)return n.map(e=>({...e}));const o=function(e){const t=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(!t||!n)return null;const o=Math.min(1,256/Math.max(t,n)),r=Math.max(1,Math.round(t*o)),a=Math.max(1,Math.round(n*o)),i=document.createElement("canvas");i.width=r,i.height=a;const l=i.getContext("2d",{willReadFrequently:!0});if(!l)return null;let s;l.drawImage(e,0,0,r,a);try{s=l.getImageData(0,0,r,a).data}catch{return null}const c=new Uint8Array(r*a);let d=0;for(let u=0;u<c.length;u+=1)s[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return Sy();const r=Py(o.mask,o.width,o.height);return wy.set(t,r),r.map(e=>({...e}))}function Ry(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:r,focusInput:a}=e,i=()=>$h(t())?"image":yb(t())?"textBox":null,l=(e,t)=>{const o=i();o&&(n(),r(e=>t(e,o),{mergeKey:e}),a())},s=(e,n)=>{const a=vo(t().document,n),i=t=>{const n=ky(t);r(t=>function(e,t,n){const r=ao(e);let a=!1;const i=r.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...Gt(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return o(e);a=!0;const r={...e.image};return n&&n.length>0?r.wrapPolygon=n:delete r.wrapPolygon,{...e,image:r}})}:Gt(e));return a?da(e,i,we(i,Bn(e))):e}(t,e,n),{mergeKey:ki})},l=on(a,()=>{l.naturalWidth>0&&i(l)});l.complete&&l.naturalWidth>0&&i(l)};return{target:i,preset:()=>{const e=i();return"image"===e?function(e){const t=$h(e),n=t&&nn(t.run);return n?Eh(n.floating):null}(t()):"textBox"===e?function(e){const t=yb(e),n=t&&Qe(t.run);return n?Eh(n.floating):null}(t()):null},fixedPosition:()=>{const e=i();return"image"===e?function(e){const t=$h(e),n=t&&nn(t.run);return Nh(n?.floating)}(t()):"textBox"===e&&function(e){const t=yb(e),n=t&&Qe(t.run);return Nh(n?.floating)}(t())},setPreset:e=>{if(l(ml,(t,n)=>"image"===n?function(e,t){return Yh(e,e=>Dh(e,t))}(t,e):function(e,t){return xb(e,e=>Dh(e,t))}(t,e)),"tight"===e||"through"===e){const e=$h(t()),n=e&&nn(e.run);n&&!n.wrapPolygon&&s(e.run.id,n.src)}},setFixedPosition:e=>l(hl,(t,n)=>"image"===n?function(e,t){return Yh(e,e=>e?Lh(e,t):e)}(t,e):function(e,t){return xb(e,e=>e?Lh(e,t):e)}(t,e))}}function By(e){return function(e){const t=t=>{const n=wa(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Ta(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},n=t=>{if(e.isReadOnly())return void t.preventDefault();const n=wa(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Ta(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e))),e.focusInput()}},o=t=>{if(e.isReadOnly())return void t.preventDefault();const n=e.consumePasteMode?.();if(e.forcePlainTextPaste()||"text"===n){e.setForcePlainTextPaste(!1);const n=t.clipboardData?.getData("text/plain")??"";return 0===n.length?void t.preventDefault():(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Oa(e,n))),t.currentTarget.value="",void e.focusInput())}const o="merge"!==n?Fh(t.clipboardData):null;if(o)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(o),t.currentTarget.value="",void e.focusInput();const r=Xa(t.clipboardData?.getData("text/html")??""),a="merge"===n?_a(e.state(),r):r;if(a.length>0)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Pa(e,a))),t.currentTarget.value="",void e.focusInput();const i=t.clipboardData?.getData("text/plain")??"";0!==i.length&&(t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Oa(e,i))),t.currentTarget.value="",e.focusInput())},r=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Fh(t.dataTransfer);if(!n)return;t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const o=e.resolvePositionAtSurfacePoint(t.clientX,t.clientY)??e.state().selection.focus;e.insertImageFromFile(n,o),e.focusInput()};return{handleCopy:t,handleCut:n,handlePaste:o,handleDrop:r}}(e)}var My=/* @__PURE__ */new WeakMap;function Fy(e,t){return function(e){return a(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function Ay(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=My.get(a);if(i)return i;const l=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(const d of a.paragraphs){const e=d.tableCell;if(!e)continue;const t=`${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,n=l.get(e.tableId)??/* @__PURE__ */new Map;let o=n.get(t);o||(o={tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,pageIndex:d.pageIndex,left:e.left,top:e.top,right:e.left+e.width,bottom:e.top+e.height,width:e.width,height:e.height,contentMinWidth:0,contentMinHeight:0},n.set(t,o),l.set(e.tableId,n));const r=d.lines.flatMap(e=>e.slots.map(e=>e.left)),a=d.lines.map(e=>e.top+e.height),i=r.length>0?Math.min(...r):d.left,c=r.length>0?Math.max(...r):d.left,u=d.lines.length>0?d.lines[0].top:d.top,p=a.length>0?Math.max(...a):d.top+d.height,g=`${e.tableId}:${d.pageIndex}:${e.rowIndex}:${e.cellIndex}`,f=s.get(g);f?(f.left=Math.min(f.left,i),f.top=Math.min(f.top,u),f.right=Math.max(f.right,c),f.bottom=Math.max(f.bottom,p)):s.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of l.entries())for(const e of u.values()){const t=s.get(`${d}:${e.pageIndex}:${e.rowIndex}:${e.cellIndex}`);t&&(e.contentMinWidth=Math.max(0,t.right-t.left),e.contentMinHeight=Math.max(0,t.bottom-t.top))}const c=[];for(const[d,u]of l.entries()){const e=Array.from(u.values());if(0===e.length)continue;const t=Math.min(...e.map(e=>e.left)),n=Math.min(...e.map(e=>e.top)),o=Math.max(...e.map(e=>e.right)),r=Math.max(...e.map(e=>e.bottom));c.push({tableId:d,cells:e,bounds:{left:t,top:n,right:o,bottom:r,width:Math.max(1,o-t),height:Math.max(1,r-n)}})}return My.set(a,c),c}function Oy(e,t,n,o,r,a){const i=Ay(t,n,o,r,a);if(0===i.length)return null;let l=null;for(const d of i)if(!(e.clientX<d.bounds.left-4||e.clientX>d.bounds.right+4||e.clientY<d.bounds.top-4||e.clientY>d.bounds.bottom+4))for(const t of d.cells){const n=e.clientY>=t.top-4&&e.clientY<=t.bottom+4,o=e.clientX>=t.left-4&&e.clientX<=t.right+4;if(n){const n=Math.abs(e.clientX-t.left);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!l||n<l.distance)&&(l={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!l||o<l.distance)&&(l={geometry:d,cell:t,side:"bottom",distance:o})}}if(!l)return null;const s=Fy(n,l.geometry.tableId);if(!s)return null;const c=Xt(s).find(e=>e.rowIndex===l.cell.rowIndex&&e.cellIndex===l.cell.cellIndex);return c?{tableId:l.geometry.tableId,rowIndex:l.cell.rowIndex,cellIndex:l.cell.cellIndex,side:l.side,rect:l.cell,tableNode:s,layoutEntry:c,tableGeometry:l.geometry}:null}var Dy=1/.75;function Ey(e){return.75*e}function Ly(e){return e*Dy}var Ny=ds;function $y(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Ly(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Ly(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Ly(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Ly(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Ly(e.style.borderRight.width)):1)}function zy(e,t,n){const o=Math.max(1,e.rows.length),r=n.bounds.height/o,a=Array(o).fill(r),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(let l=0;l<o;l+=1){const n=Ny(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Ly(n));continue}const o=t.find(e=>e.rowIndex===l&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[l]=Math.max(1,e.height))}}return a}function Hy(e,t,n){const o=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),r=o-1,a=Array(o).fill(n.bounds.width/o),i=new Map(n.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));if(e.gridCols&&e.gridCols.length>=o)for(let s=0;s<o;s+=1)a[s]=Math.max(1,Ly(e.gridCols[s]));else for(const s of t){if(1!==s.colSpan)continue;const e=i.get(`${s.rowIndex}:${s.cellIndex}`);e&&(a[s.visualColumnIndex]=Math.max(1,e.width))}const l={};for(let s=0;s<o;s+=1)l[s]=Math.max(10,Ey(a[s]));return{widthsPt:l,maxColumnIndex:r}}function Wy(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Ly(10),r=Math.max(Ly(10),t.minRowHeightPx??Ly(10)),a=Math.max(10,Ey(Math.max(r,o+n)));return function(e,t,n,o){return cs(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Uy(e){const t=e();if(!t)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight};const n=t.getBoundingClientRect();return{left:n.left,top:n.top,width:Math.max(0,n.width),height:Math.max(0,n.height)}}var jy=null;function Vy(e,t){jy=t,e?(document.body.classList.add("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize")):(document.body.classList.add("oasis-editor-hover-row-resize"),document.body.classList.remove("oasis-editor-hover-col-resize"))}function Ky(e){e&&jy!==e||(jy=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function _y(e,t){Vy(e,t)}function Xy(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Gy(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Yy(e){const[t,n]=Wt(null);let o=null,r=null,a=null,i=null;const l={},s=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Ky();const i=Oy(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Vy("left"===i.side||"right"===i.side,l):Ky()},c=oy(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Xy(u)))},u=()=>{a=null;const o=i;i=null;const r=t();o&&r&&n({...r,currentPos:"column"===r.type?o.clientX:o.clientY,guideBounds:Uy(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Gy(o),o=null),null!==a&&(Gy(a),a=null),n(null),Ky(l),c.release(),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)},g=n=>{if(!c.owns(n))return;const o=t();if(!o)return;const r=e.zoomFactor?.()??1,a=(("column"===o.type?n.clientX:n.clientY)-o.initialPos)/r;Math.abs(a)>=2&&e.applyTransactionalState(e=>"row"===o.type?Wy(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=Ey(n),r=t.maxColumnIndex??t.index,a={...t.columnWidthsPt??{}};for(let m=0;m<=r;m+=1)void 0===a[m]&&(a[m]=10);const i=t.minColumnWidthsPx??{},l=a[t.index]??10,s=Math.max(10,Ey(i[t.index]??Ly(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(s,l-o),i=l-r;n+i<0&&(i=-n,r=l-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return us(e,t.tableId,a,c,d)}let c=Math.max(s,l+o);const d=t.index===r;if(d)a[t.index]=c;else{const e=t.index+1,n=a[e]??10,o=Math.max(10,Ey(i[e]??Ly(10)));let r=n-(c-l);r<o&&(r=o,c=l+(n-o),c=Math.max(s,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=Fy(e,t.tableId),g=Ny(p?.style?.width),f=d?u:null!==g?g:void 0;return us(e,t.tableId,a,f)}(e,o,a)),p()};return{resizing:t,handlePointerMove:e=>{c.owns(e)&&(t()||(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Xy(s))))},handlePointerDown:t=>{r=null,null!==o&&(Gy(o),o=null),Ky();const a=e.surfaceRef();if(!a)return!1;const i=Oy(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=Xt(i.tableNode);if("left"===i.side||"right"===i.side){const o="left"===i.side&&0===i.layoutEntry.visualColumnIndex,r=o?0:"left"===i.side?i.layoutEntry.visualColumnIndex-1:i.layoutEntry.visualColumnIndex+i.layoutEntry.colSpan-1;if(r<0)return!1;const a="left"===i.side?i.rect.left:i.rect.right,{widthsPt:p,maxColumnIndex:f}=Hy(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Ly(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const l of n){if(1!==l.colSpan)continue;if(!i.get(`${l.rowIndex}:${l.cellIndex}`))continue;const n=t.rows[l.rowIndex]?.cells[l.cellIndex];if(!n)continue;const o=l.visualColumnIndex,s=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,ft(n,e.document.styles)),1);a[o]=Math.max(s,c+$y(n)+12,r)}return a}(s,i.tableNode,u,i.tableGeometry);return n({type:"column",tableId:i.tableId,index:r,initialPos:a,currentPos:a,columnWidthsPt:p,maxColumnIndex:f,minColumnWidthsPx:m,resizeFromLeftEdge:o,initialTableIndentLeftPt:Ny(i.tableNode.style?.indentLeft)??0,guideBounds:Uy(e.viewportRef)}),_y(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=zy(i.tableNode,u,i.tableGeometry),f="top"===i.side?i.layoutEntry.visualRowIndex-1:i.layoutEntry.visualRowIndex+i.layoutEntry.rowSpan-1;if(f<0||f>=p.length)return!1;const m="top"===i.side?i.rect.top:i.rect.bottom,h=function(e,t,n,o){const r=e.rows[o];if(!r)return Ly(10);const a=Ly(10);let i=a;for(let l=0;l<r.cells.length;l+=1){if(!r.cells[l])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===l);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===l);a&&(i=Math.max(i,a.contentMinHeight+4))}return Math.max(a,i)}(i.tableNode,u,i.tableGeometry,f);return n({type:"row",tableId:i.tableId,index:f,initialPos:m,currentPos:m,initialRowHeightPx:p[f],minRowHeightPx:h,guideBounds:Uy(e.viewportRef)}),_y(!1,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var qy=null;function Zy(e){const t=(e.bounds.width+(e.currentClientX-e.startClientX))/e.bounds.width,n=(e.bounds.height+(e.currentClientY-e.startClientY))/e.bounds.height,o=Object.values(e.widthsPt),r=o.length>0?Math.min(...o):1,a=r>0?10/r:0,i=Ly(10),l=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,s=l>0?i/l:0;return{scaleX:Math.max(a,t),scaleY:Math.max(s,n)}}function Jy(e){const[t,n]=Wt(null);let o=null,r=null;const a={},i=oy(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Xy(s)))},s=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(Gy(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),qy===a&&(qy=null,"nwse-resize"===document.body.style.cursor&&(document.body.style.cursor=""))},d=n=>{if(!i.owns(n))return;const o=t();if(o){const t=Math.abs(n.clientX-o.startClientX),r=Math.abs(n.clientY-o.startClientY);if(t>=2||r>=2){const t={...o,currentClientX:n.clientX,currentClientY:n.clientY},{scaleX:r,scaleY:a}=Zy(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const s of Object.keys(t.widthsPt)){const e=Number(s);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=us(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,Ey(e*o))}),cs(i,t.tableId,l)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=Zy(e);return{left:e.bounds.left,top:e.bounds.top,width:e.bounds.width*n,height:e.bounds.height*o}},handlePointerDown:(t,o)=>{const r=e.surfaceRef();if(!r)return;const s=Ay(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=Fy(e.state(),t);if(!s||!c)return;const u=Xt(c),{widthsPt:p}=Hy(c,u,s),g=zy(c,u,s),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:s.bounds.left,top:s.bounds.top,width:Math.max(1,s.bounds.width),height:Math.max(1,s.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),qy=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",l),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var Qy=null;function ev(e,t,n,o){if(!e)return null;for(const r of e)if("table"===r.type){if(r.id===t)return{table:r,nested:n,movableTopLevelStory:o};for(const e of r.rows)for(const n of e.cells){const e=ev(n.blocks,t,!0,!1);if(e)return e}}return null}function tv(e,t){for(const n of Co(e)){for(const e of[n.blocks,n.header,n.footer]){const n=ev(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=ev(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=ev(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=ev(n.blocks,t,!1,!1);if(e)return e}return null}function nv(e){return function(e){const[t,n]=Wt(!1),[o,r]=Wt(null),[a,i]=Wt(null),[l,s]=Wt(0),[c,d]=Wt(0),[u,p]=Wt({x:0,y:0});let g=null,f=null;const m={},h=(e,t)=>e===t||null!==e&&null!==t&&e.paragraphId===t.paragraphId&&e.runId===t.runId&&e.offset===t.offset,b=e=>{i(t=>h(t,e)?t:e)},y=oy(),v=()=>{f=null,null!==g&&(Gy(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),Qy===m&&(Qy=null,"grabbing"===document.body.style.cursor&&(document.body.style.cursor=""))},x=()=>{g=null;const n=f;if(f=null,!n||!t())return;p({x:n.clientX,y:n.clientY});const r=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),a=o()?.tableId;r&&a&&function(e,t,n){const o=tv(e,n);return Boolean(o?.table&&We(o.table).some(e=>e.id===t))}(e.state().document,r.paragraphId,a)?b(null):b(r)},w=e=>{if(y.owns(e)){if(!t()){if(Math.abs(e.clientY-l())<=4)return;n(!0),Qy=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Xy(x))}},S=n=>{if(!y.owns(n))return;const r=o();if(t()){const t=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY),o=r?.tableId;o&&e.applyTransactionalState(e=>{const r=tv(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return is(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*hr,y:(t.y??0)+(n.clientY-l())*hr,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?He(e,o,t):e})}v(),e.focusInput()};return{dragging:t,draggedTableInfo:o,mousePos:u,dropTargetPos:a,handlePointerDown:(e,t)=>{t.preventDefault(),t.stopPropagation();const o=t.currentTarget.getBoundingClientRect(),a=o;r({tableId:e,width:a.width,height:a.height,offsetX:t.clientX-o.left,offsetY:t.clientY-o.top}),s(t.clientY),d(t.clientX),p({x:t.clientX,y:t.clientY}),n(!1),i(null),y.claim(t),window.addEventListener("pointermove",w),window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)},stop:v}}(e)}var ov=e=>"touch"===e.pointerType;function rv(e,t){if(!e||0===e.length){const e=Hr(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:We(n)[0]??null,blocks:e}}function av(e,t,n){const o=Vr(e.document).filter(t=>{const o=Zr(e.document,t.id);return null!==o&&o.zone===n}),r=o.findIndex(e=>e.id===t.id),a=r>=0?o[r+1]:void 0;return{start:ua(t,0),end:a?ua(a,0):ua(t,ot(t).length)}}function iv(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,l=0,s=0,c=null,d=0,u=0,p=0,g=null,f=null;const m=e=>"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>e()):globalThis.setTimeout(e,16),h=e=>{"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)},b=(t,n,o,r)=>{const a=n!==(t.activeZone??"main"),i="footnote"===n&&r?Zr(o.document,r.paragraphId)?.footnoteId:void 0,l="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!l)return void e.applyState(o);let s=o.document,c=t.activeSectionIndex??0;if(!s.sections||0===s.sections.length){const e=Hr("header"),t=Hr("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:sr(s.pageSettings??Ft),header:[e],footer:[t]}]},c=0}const d=s.sections,u=d[c];let p=u.header,g=u.footer,f=null;if("header"===n){const e=rv(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=rv(g,"footer");f=e.paragraph,g=e.blocks}if(p!==u.header||g!==u.footer){const e=[...d];e[c]={...u,header:p,footer:g},s={...s,sections:e}}const m=r||(f?ua(f,0):o.selection.anchor);e.applyState({...o,document:s,selection:{anchor:m,focus:m},activeSectionIndex:c,activeZone:n,activeFootnoteId:"footnote"===n?i:void 0})},y=t=>{const n=e.state(),o=n.selection,r=Kn(n),a=dt(n.document,o.anchor.paragraphId,r),i=dt(n.document,o.focus.paragraphId,r),l=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",s=i?`b${i.blockIndex}r${i.rowIndex}c${i.cellIndex}`:"";e.logger.debug(`${t} ${o.anchor.paragraphId}[${o.anchor.offset}]→${o.focus.paragraphId}[${o.focus.offset}] [${l}→${s}]`)},v=()=>{f?.longPressHandle&&clearTimeout(f.longPressHandle),f=null},x=()=>{t=null,o=null,g=null,v(),null!==n&&(h(n),n=null),window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",T),window.removeEventListener("pointercancel",P)},w=e=>{g=e,window.addEventListener("pointermove",C),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",P)},S=()=>{if(n=null,!t)return;const r=o;if(o=null,!r)return;const a=e.resolveSurfaceHitAtPoint(r.clientX,r.clientY,{forDrag:!0});if(!a?.resolvedFromParagraph)return;const i=e.state();if(Zr(i.document,t.paragraphId)?.sectionIndex!==Zr(i.document,a.paragraphId)?.sectionIndex)return;const l=Sa(i,{anchor:t,focus:a.position});b(i,a.zone,l,a.position),y("selection:drag")},I=()=>{o&&(null!==n&&(h(n),n=null),S())},C=e=>{null!==g&&e.pointerId!==g||(!f||f.longPressFired?t&&(o={clientX:e.clientX,clientY:e.clientY},null===n&&(n=m(S))):Math.hypot(e.clientX-f.clientX,e.clientY-f.clientY)>20&&x())},T=t=>{if(null===g||t.pointerId===g){if(f&&!f.longPressFired){const n=f,o=Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<=20&&Date.now()-n.startedAt<=500;return v(),x(),void(o&&(D(n.hit,n.clickDetail,t),e.onSelectionFinalized?.()))}I(),y("selection:end"),x(),e.onSelectionFinalized?.(),e.focusInputAfterPointerSelection()}},P=e=>{null!==g&&e.pointerId!==g||x()},k=(n,o,r)=>{if(r<2)return t=null,x(),void e.focusInputAfterPointerSelection();t=null,o.resolvedFromParagraph?b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position):b(n,o.zone,n),x(),e.focusInputAfterPointerSelection()},R=(n,o)=>{const r=e.getParagraphById(n.document,o.textBox.paragraphId);if(!r)return void e.focusInputAfterPointerSelection();t=null;const a=ua(r,o.textBox.startOffset),i=ua(r,o.textBox.endOffset);b(n,o.zone,Sa(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},B=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=ua(a,o.image.startOffset),l=ua(a,o.image.endOffset);b(n,o.zone,Sa(n,{anchor:i,focus:l}),i),x(),ov(r)||e.imageOps.startImageDrag(o.image.paragraphId,o.image.startOffset,r,{left:o.image.left,top:o.image.top,width:o.image.width,height:o.image.height}),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,Sa(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},F=(n,o,r)=>{t=null;const a=av(n,r,o.zone);b(n,o.zone,Sa(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=null;let a=0;const i=r.runs.find(e=>{const t="math"===e.kind&&o.paragraphOffset>=a&&o.paragraphOffset<=a+e.text.length;return a+=e.text.length,t});if("math"===i?.kind){const t=ua(r,o.paragraphOffset);return b(n,o.zone,Sa(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const l=Me(ot(r),o.paragraphOffset),s=ua(r,l.start),c=ua(r,l.end);b(n,o.zone,Sa(n,{anchor:s,focus:c}),s),x(),e.focusInputAfterPointerSelection()},O=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!ov(a)&&e.textDrag?.tryStartTextDrag(a,o))return t=null,x(),void e.focusInputAfterPointerSelection();const i=e.getParagraphById(n.document,o.paragraphId);o.zone===(n.activeZone??"main")?o.textBox?R(n,o):o.image?B(n,o,a):a.shiftKey&&o.resolvedFromParagraph?M(n,o,a.pointerId):r>=3&&i?F(n,o,i):2===r&&i?A(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),ov(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():k(n,o,r)},D=(t,n,o)=>{O(e.state(),t,n,o),e.focusInputSync()},E=()=>{const n=f;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const o=n.hit;if(!o?.resolvedFromParagraph)return;const r=e.state(),a=e.getParagraphById(r.document,o.paragraphId);if(!a)return;const i=Me(ot(a),o.paragraphOffset),l=ua(a,i.start),s=ua(a,i.end);b(r,o.zone,Sa(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-l);r=n-a<=450&&o<=((e,t)=>ov(e)?20:t)(t,6)&&t.button===s?r+1:1,a=n,i=t.clientX,l=t.clientY,s=t.button;const g=Math.max(t.detail,r),m=e.state();if(e.clearPendingCaretTextStyle(),e.tableResize.handlePointerDown(t))return void t.preventDefault();const h=e.resolveSurfaceHitAtPoint(t.clientX,t.clientY,{pierce:t.altKey});if(c=h,d=n,u=t.clientX,p=t.clientY,ov(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(E,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),O(m,h,g,t)},N=n=>{if(n.detail<3)return;n.preventDefault();const o=e.state(),r=Math.hypot(n.clientX-u,n.clientY-p),a=Date.now()-d<=600&&r<=8?c:e.resolveSurfaceHitAtPoint(n.clientX,n.clientY);if(!a?.resolvedFromParagraph)return void e.focusInputAfterPointerSelection();const i=e.getParagraphById(o.document,a.paragraphId);if(!i)return void e.focusInputAfterPointerSelection();t=null;const l=av(o,i,a.zone);b(o,a.zone,Sa(o,{anchor:l.start,focus:l.end}),l.start),x(),e.focusInputAfterPointerSelection()},$=(e,t)=>{0===t.button&&(ov(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:$,stopDragging:x}}(e)}function lv(e){return function(e){const[t,n]=Wt(!1);let o,r=0,a="",i=null;const l=()=>{r=0,a="",o=void 0},s=(t,n)=>{if(!n&&t===a)return;if(0===r&&0===t.length)return void(n&&l());const s=r,c=kr(o);e.clearPreferredColumn(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>{const n=function(e,t){if(t<=0)return e;const{paragraph:n,index:o,offset:r}=E(e);if(r<t)return e;const a=ao(e),i=r-t,l=me(n,[...U(n,0,i),...U(n,r,Se(n))],Nt(n,i)),s=a.map((e,t)=>t===o?l:e);return da(e,s,nt(ua(l,i)))}(e,s);return t.length>0?Fa(n,t,c):n}),{mergeKey:gi}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(gn("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(n.currentTarget.value)}`),n.currentTarget.value="",void l();const o=n.currentTarget.value;if(0===o.length)return;if(t())return e.logger.debug(`input:composing buffer=${JSON.stringify(o)}`),void s(o,!1);if(null!==i){const t=o===i;if(i=null,t)return e.logger.debug(`input:suppressed text=${JSON.stringify(o)}`),void(n.currentTarget.value="")}const r=e.state(),a=r.selection,c=ao(r).find(e=>e.id===a.anchor.paragraphId)?.runs.find(e=>e.id===a.anchor.runId),d=c?{bold:c.styles?.bold,italic:c.styles?.italic,underline:c.styles?.underline}:null;e.logger.info(`input:text ${JSON.stringify(o)} (len=${o.length}) at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}] run:${JSON.stringify(d)}`),e.clearPreferredColumn();const u=kr(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Fa(e,o,u)),{mergeKey:pi}),n.currentTarget.value="",e.focusInput(),no("input:text")},d=()=>{e.logger.debug("input:composition start"),l(),i=null,o=kr(e.pendingCaretTextStyle()),n(!0)},u=t=>{e.isReadOnly()||s(t.data??"",!1)},p=t=>{if(n(!1),e.isReadOnly())return t.currentTarget.value="",void l();const o=t.data??t.currentTarget.value,r=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(o)} (len=${o.length}) at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}]`),s(o,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:c,handleCompositionStart:d,handleCompositionUpdate:u,handleCompositionEnd:p,composing:t}}(e)}var sv="url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='white' stroke-width='4'/%3E%3Cpath d='M6 3.5 6 22.5 10.7 17.9 14.1 26.6 17.2 25.4 13.8 16.9 20.4 16.9Z' fill='white' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M7.5 7.1 7.5 19.1 10.9 15.8 14.7 24.4' stroke='white' stroke-width='1.15' opacity='.95'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' fill='white' stroke='white' stroke-width='3'/%3E%3Crect x='22' y='23' width='8.5' height='6.5' rx='.5' stroke='black' stroke-width='1.25' stroke-dasharray='2 2'/%3E%3C/g%3E%3C/svg%3E\") 6 4, auto";function cv(e,t){const n=Bn(e);if(n.isCollapsed)return!1;const o=ao(e),r=o.findIndex(e=>e.id===t.paragraphId);if(r<n.startIndex||r>n.endIndex)return!1;const a=o[r];if(!a)return!1;const i=u(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function dv(e){return function(e){const[t,n]=Wt(!1),[o,r]=Wt(null),[a,i]=Wt(!1),[l,s]=Wt(null),[c,d]=Wt(null);let u=null,p=null,g=null;const f=()=>{p&&(p.remove(),p=null)},m=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${sv} !important; }`,document.head.appendChild(p))},h=oy(),b=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,n(!1),r(null),i(!1),s(null),d(null),f(),h.release(),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)},y=o=>{if(!h.owns(o))return;if(!u)return;const a=o.ctrlKey||o.metaKey;if(i(a),!t()){const t=Math.abs(o.clientX-u.x),r=Math.abs(o.clientY-u.y);if(t+r<4)return;e.logger?.info("text-drag:activate",{start:u,at:{x:o.clientX,y:o.clientY},deltaX:t,deltaY:r}),n(!0),m()}s({x:o.clientX,y:o.clientY});const l=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY);if(!l?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=l.tableCellAnchorPosition??l.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${l.zone}|src=${l.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:l.zone,resolvedFromParagraph:l.resolvedFromParagraph,paragraphId:l.paragraphId,paragraphOffset:l.paragraphOffset,hitPosition:`${l.position.paragraphId}:${l.position.runId}[${l.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:l.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(l.caretViewport??null)},v=n=>{if(h.owns(n)){if(e.logger?.info("text-drag:mouseup",{x:n.clientX,y:n.clientY,dragging:t(),copyMode:a(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null}),t()&&o()){const t=o(),n=a();e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>Ma(e,t,{copy:n})),{mergeKey:n?Ni:$i}),e.logger?.info("text-drag:apply",{mode:n?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position;e.applyTransactionalState(e=>cv(e,t)?Sa(e,{anchor:t,focus:t}):e,{mergeKey:zi}),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}b(),e.focusInputAfterPointerSelection()}},x=(t,o)=>e.isReadOnly()||!o?.resolvedFromParagraph?(e.logger?.debug("text-drag:skip-start",{reason:e.isReadOnly()?"readonly":"no-hit",x:t.clientX,y:t.clientY}),!1):cv(e.state(),o.position)?(e.logger?.info("text-drag:start-pending",{x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`,zone:o.zone}),u={x:t.clientX,y:t.clientY,position:o.position},s({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),d(o.caretViewport??null),n(!1),h.claim(t),window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),!0):(e.logger?.debug("text-drag:skip-start",{reason:"outside-selection",x:t.clientX,y:t.clientY,hit:`${o.position.paragraphId}:${o.position.runId}[${o.position.offset}]`}),!1);return{dragging:t,dropTargetPos:o,copyMode:a,pointerPos:l,caretViewport:c,tryStartTextDrag:x,stopDrag:b}}(e)}function uv(e){return e.blocks.flatMap(We)}function pv(e,t){if(!e)return;const n=uv(e);return"start"===t?n[0]:n[n.length-1]}function gv(e){return function(e){const t=(t,n)=>{const o=e.state(),r=ao(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:ot(r).length,i=ua(r,a);return e.clearPreferredColumn(),e.applyState(Sa(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=ao(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:ot(a).length,l=ua(a,i);return e.clearPreferredColumn(),e.applyState(Sa(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=ao(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const s=ot(i),c=o.selection.focus.offset,d=s.length;if(!n&&!vr(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ia(o):Ca(o)),!0;let u=i,p=c;"left"===t?0===c&&a>0?(u=r[a-1],p=ot(u).length):p=wo(s,c):c===d&&a<r.length-1?(u=r[a+1],p=0):p=l(s,c);const g=ua(u,p);return e.clearPreferredColumn(),e.applyState(Sa(o,{anchor:n?o.selection.anchor:g,focus:g})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=ao(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const i=e.surfaceRef(),l=i?.getBoundingClientRect()??null,s=e.preferredColumnX(),c=null===s?e.caretBox().left+(l?.left??0):s,d=i?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:i,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let p=a+t;const g=y(o.document,o.selection.focus.paragraphId,Kn(o)),f=g?.tablePath[g.tablePath.length-1];if(g&&f){const e=Ab(o,g.zone),n=T(e,g.tablePath),a=n?.[n.length-1]?.table;if(a){const e=Xt(a),n=e.find(e=>e.rowIndex===f.rowIndex&&e.cellIndex===f.cellIndex);if(n){const o=[];for(let e=n.visualRowIndex+t;e>=0&&e<a.rows.length;e+=t)o.push(e);for(const n of o){const o=e.filter(e=>e.visualRowIndex===n&&uv(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=pv(e.cell,"start")?.id,n=t?d?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??c,r=n?n.left+n.width:c;return{entry:e,distance:c<o?o-c:c>r?c-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=pv(i.cell,t<0?"end":"start");p=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=pv(a.rows[0]?.cells[0],"start");e&&(p=r.findIndex(t=>t.id===e.id)-1)}else{const e=a.rows[a.rows.length-1],t=e?.cells[e.cells.length-1],n=pv(t,"end");n&&(p=r.findIndex(e=>e.id===n.id)+1)}}}if(p<0||p>=r.length)return!1;const m=r[p];let h=0;const b=d?nr(d,m.id):[],v=t<0?b[b.length-1]:b[0];if(v&&v.lines.length>0){const e=v.lines,n=t<0?e[e.length-1]:e[0];h=n.slots.length?n.slots.reduce((e,t)=>Math.abs(c-t.left)<Math.abs(c-e.left)?t:e,n.slots[0]).offset:0}else h=Math.min(u(m,o.selection.focus),ot(m).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Sa(e,{anchor:n?e.selection.anchor:ua(m,h),focus:ua(m,h)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function fv(e){return function(e){const[t,n]=Wt(null),o=(t,o)=>{const r=ao(e.state());let a;for(const e of r){for(const n of e.runs)if(n.revision?.id===t){a=n.revision;break}if(a)break}const i=e=>{for(const n of e)if("paragraph"!==n.type){if(n.style?.revision?.id===t)return n.style.revision;if(n.gridRevision?.id===t)return n.gridRevision;for(const e of n.rows){if(e.style?.revision?.id===t)return e.style.revision;if(e.style?.propertyRevision?.id===t)return e.style.propertyRevision;for(const n of e.cells){if(n.style?.revision?.id===t)return n.style.revision;if(n.style?.propertyRevision?.id===t)return n.style.propertyRevision;const e=i(n.blocks);if(e)return e}}}};if(!a)for(const n of Co(e.state().document)){for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter])if(e&&(a=i(e),a))break;if(a)break}if(!a)return;const l=o.currentTarget.getBoundingClientRect(),s=e.surfaceRef()?.getBoundingClientRect();if(!s)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(l.left-s.left)/c,top:(l.top-s.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function mv(e){const t=ao(e);if(!t.length)return null;const n=Bn(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:U(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:Se(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=kr(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(r?r.styles:Nt(o,n.startParagraphOffset)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===Se(o));return{text:a,paragraph:i?Hn(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function hv(e,t){const n=ao(e);if(!n.length)return e;const o=Bn(e,n);if(o.isCollapsed)return e;let r=!1;const a=n.map((e,n)=>{if(n<o.startIndex||n>o.endIndex)return e;const a=n===o.startIndex?o.startParagraphOffset:0,i=n===o.endIndex?o.endParagraphOffset:Se(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===Se(e))}(e,n,o),s=l?Hn(t.paragraph):e.style,c=l?t.list?{...t.list}:void 0:e.list,d=l&&(JSON.stringify(s)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),u=a<i&&U(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=kr(t.text)??{};void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision);const o=Object.keys(n).length?n:void 0;return!fo(e.styles,o)});if(!d&&!u)return e;r=!0;let p=u?ne(e,a,i,e=>{if("text"!==e.kind)return e;const n=kr(t.text)??{};return void 0!==e.styles?.link&&(n.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(n.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(n).length?n:void 0}}):e;return l&&(p={...p,style:s,list:c}),p});return r?da(e,a,we(a,o)):e}function bv(e){const t=ao(e);if(!t.length)return"";const n=Bn(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function yv(e){const[t,n]=Wt(null);let o=null,r=null,a="";const i=()=>{o=null,r=null,a="",n(null)},l=()=>!e.isReadOnly()&&ao(e.state()).length>0,s=t=>{if(!l())return!1;const i=e.state(),s=mv(i);return!!s&&(o=s,r=i.document,a=bv(i),n(t),e.focusInput(),!0)};return{mode:t,canCapture:l,armOnce:()=>s("once"),armContinuous:()=>s("continuous"),cancel:i,applyToSelection:n=>{if(!o||!t())return!1;if(e.isReadOnly()||e.state().document!==r)return i(),!1;const l=e.state();if(bv(l)===a)return!1;const s=function(e,t){const n=ao(e);if(0===n.length)return null;const o=Bn(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=Me(ot(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:ua(r,a.start),focus:ua(r,a.end)}}}(l,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==r)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>hv(e,o));return c=n.document!==t.document,n}),"once"===t()?i():c&&(r=e.state().document),c&&e.focusInput(),c}}}function vv(e){return function(e){const{state:t,logger:n,isReadOnly:o,applyState:r,cloneState:a,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,surfaceRef:c,viewportRef:d,zoomFactor:u,insertImageFromFile:p,getForcePlainTextPaste:g,setForcePlainTextPaste:f,getCommandsController:m,applyTransactionalState:h,clearPreferredColumn:b,resetTransactionGrouping:y,updateHistoryState:v,caretBox:x,preferredColumnX:w,setPreferredColumnX:S,documentLayout:I,canvasSnapshotProvider:C}=e,T=()=>$h(t),P=()=>yb(t),k=Ry({state:()=>t,resetTransactionGrouping:y,applyTransactionalState:h,focusInput:i}),R=vy({state:()=>t,surfaceRef:()=>c()??null,viewportRef:()=>d()??null,documentLayout:I,canvasSnapshotProvider:C,zoomFactor:u}).resolveSurfaceHitAtPoint,B=function(e){const[t,n]=Wt(""),[o,r]=Wt(""),[a,i]=Wt({matchCase:!1,wholeWord:!1}),[l,s]=Wt([]),[c,d]=Wt(-1),[u,p]=Wt(!1);Dt(dr([()=>e.state.document,t,a],([e,t,n])=>{const o=py(e,t,n);s(o),0===o.length?d(-1):(c()>=o.length||-1===c())&&d(0)}));const g=t=>{const n=l()[t];n&&e.applyState(Sa(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:o,setReplaceTerm:r,findOptions:a,setFindOptions:i,matches:l,currentIndex:c,findNext:()=>{const e=l().length;if(0===e)return;const t=(c()+1)%e;d(t),g(t)},findPrevious:()=>{const e=l().length;if(0===e)return;const t=(c()-1+e)%e;d(t),g(t)},replace:()=>{if(0===l().length||-1===c())return;const t=l()[c()];e.applyTransactionalState(e=>Fa(Sa(e,{anchor:t.anchor,focus:t.focus}),o()),{mergeKey:Ai})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>gy(e,n,o(),a()),{mergeKey:Oi}),p(!1),e.focusInput())},isOpen:u,setIsOpen:p}}({state:t,applyState:r,applyTransactionalState:h,focusInput:i}),M=ny({applyTransactionalState:h,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:xn(e).document,selection:t}),focusInput:i,logger:n}),A=yv({state:()=>t,isReadOnly:o,applyTransactionalState:h,applyTableAwareParagraphEdit:M.applyTableAwareParagraphEdit,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i}),O=(e,t)=>R(e,t)?.position??null,D=cy({state:t,surfaceRef:c,resolvePositionAtSurfacePoint:O,applyState:r,applyTransactionalState:h,updateHistoryState:v,focusInput:i,focusInputAfterPointerSelection:l,cloneState:a,logger:n,zoomFactor:u}),E=dy({state:t,surfaceRef:c,applyState:r,updateHistoryState:v,focusInput:i,cloneState:a,logger:n,zoomFactor:u}),L=uy({state:()=>t,commandsController:m,clearPreferredColumn:b,resetTransactionGrouping:y,focusInput:i,logger:n}),N=function(e){const t=()=>e.state,n=Yy({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=Jy({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=nv({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=fv({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=dv({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),l=iv({state:t,applyState:e.applyState,tableResize:n,imageOps:e.imageOps,clearPendingCaretTextStyle:e.styleController.clearPendingCaretTextStyle,onSelectionFinalized:()=>{e.formatPainter.applyToSelection("pointer")},clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,focusInputSync:e.focusInputSync,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,getParagraphById:F,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),s=lv({state:t,isReadOnly:e.isReadOnly,logger:e.logger,clearPreferredColumn:e.clearPreferredColumn,pendingCaretTextStyle:e.styleController.pendingCaretTextStyle,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput}),c=gv({state:t,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,surfaceRef:()=>e.surfaceRef()??null,caretBox:e.caretBox,preferredColumnX:e.preferredColumnX,setPreferredColumnX:e.setPreferredColumnX,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),{handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}=By({state:t,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,consumePasteMode:e.clipboardActions?.consumePasteMode,onNativeClipboardSuccess:e.clipboardActions?.dismiss,setForcePlainTextPaste:e.setForcePlainTextPaste,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,insertImageFromFile:e.insertImageFromFile,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint});return{tableResize:n,tableCornerResize:o,tableDrag:r,revisionController:a,textDrag:i,surfaceEvents:l,textInput:s,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,applyState:r,applyTransactionalState:h,isReadOnly:o,logger:n,focusInput:i,focusInputAfterPointerSelection:l,focusInputSync:s,clearPreferredColumn:b,resetTransactionGrouping:y,surfaceRef:c,viewportRef:d,caretBox:()=>x(),preferredColumnX:()=>w(),setPreferredColumnX:S,zoomFactor:u,documentLayout:I,canvasSnapshotProvider:C,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:O,tableOps:M,imageOps:D,styleController:L,formatPainter:A,getForcePlainTextPaste:g,setForcePlainTextPaste:f,clipboardActions:e.clipboardActions,insertImageFromFile:p,openEquationDialog:e.openEquationDialog}),$=e=>{0===e.button&&(L.clearPendingCaretTextStyle(),e.preventDefault(),i())};return{selectedImageRun:T,selectedTextBoxRun:P,layoutOptionsOverlay:k,fr:B,resolveSurfaceHitAtPoint:R,resolvePositionAtSurfacePoint:O,tableOps:M,imageOps:D,textBoxOps:E,styleController:L,formatPainter:A,onEditorPointerDown:$,tableResize:N.tableResize,tableCornerResize:N.tableCornerResize,tableDrag:N.tableDrag,revisionController:N.revisionController,textDrag:N.textDrag,surfaceEventsWithTextDrag:N.surfaceEvents,textInput:N.textInput,navigation:N.navigation,handleCopy:N.handleCopy,handleCut:N.handleCut,handlePaste:N.handlePaste,handleDrop:N.handleDrop}}(e)}function xv(e){if("main"!==(e.activeZone??"main"))return e;const t=vr(e.selection)?e:_e(e),{paragraph:n,index:o,offset:r}=E(t),a=Fn(),i=function(e){const t=e.footnotes,n=t?.settings?.numberFormat??"decimal";let o=(t?.settings?.startAt??1)-1;const r=/* @__PURE__ */new Set;for(const{run:a}of Sr(e)){const e=Kt(a);e&&!e.customMark&&(r.has(e.footnoteId)||(r.add(e.footnoteId),o+=1))}return Jo(o+1,n)}(t.document),l=pn(a.id,i),s=Y(n,r,[l]),c=ao(t).map((e,t)=>t===o?s:e),d=ua(s,r+i.length),u=da(t,c,hn(d)),p=function(e){return e||{items:{}}}(u.document.footnotes),g={...u.document,footnotes:{...p,items:{...p.items,[a.id]:a}}},f=An(g),m=a.blocks.flatMap(We).find(Boolean);return m?{...u,document:f,selection:hn(ua(m,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...u,document:f}}function wv(e,t,n){return e.flatMap(e=>{if("paragraph"===e.type)return[e];let o=e.style;if(o?.revision?.id===t)if(n){const{revision:e,...t}=o;o=t}else o={...o.revision.previous};let r=e.gridCols,a=e.gridRevision;a?.id===t&&(r=n?r:[...a.previous],a=void 0);const i=e.rows.map(e=>({...e,cells:[...e.cells]}));for(let s=0;s<i.length;s+=1){const e=i[s];for(let o=0;o<e.cells.length;o+=1){const r=e.cells[o],a=r.mergeRevisionState;if(a&&a.revisionId===t){if(n){const{mergeRevisionState:t,...n}=r;e.cells[o]=n;continue}"horizontal"===a.orientation?e.cells.splice(o,a.currentCellCount,...a.previousCells):a.previousCells.forEach((e,t)=>{const n=i[s+t];n&&(n.cells[o]=e)})}}}const l=i.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};if(o?.revision?.id===t){const{revision:e,...t}=o;o=t}const r=e.cells.flatMap(e=>{if(e.style?.revision?.id===t&&(n&&"delete"===e.style.revision.type||!n&&"insert"===e.style.revision.type))return[];let o=e.style;if(o?.propertyRevision?.id===t)if(n){const{propertyRevision:e,...t}=o;o=t}else o={...o.propertyRevision.previous,revision:o.revision};let r={...e,style:o,blocks:wv(e.blocks,t,n)};if(o?.revision?.id===t&&e.mergeRevisionState?.revisionId!==t){const e=o.revision,{revision:t,...a}=o;r={...r,...n||"merge"!==e.type?{}:e.previous,style:a}}return[r]});return[{...e,isHeader:o&&"isHeader"in o?o.isHeader:e.isHeader,style:o,cells:r}]});return 0===l.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:l}]})}function Sv(e,t,n){const o=Co(e.document).map(e=>({...e,blocks:wv(e.blocks,t,n),header:e.header?wv(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?wv(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?wv(e.evenPageHeader,t,n):void 0,footer:e.footer?wv(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?wv(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?wv(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function Iv(e,t){const n=ao(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"delete"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"insert"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:me(e,n)});return Sv(da(e,n,we(n,Bn(e))),t,!0)}function Cv(e,t){const n=ao(e).map(e=>{const n=e.runs.filter(e=>!(e.revision?.id===t&&"insert"===e.revision.type)).map(e=>{if(e.revision?.id===t&&"delete"===e.revision.type){const t={...e};return delete t.revision,t}return e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:me(e,n)});return Sv(da(e,n,we(n,Bn(e))),t,!1)}function Tv(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>Tv(e,t))))}function Pv(e,t,n){for(const o of e)if("paragraph"!==o.type){Tv(o,t)&&(o.style?.revision&&n.add(o.style.revision.id),o.gridRevision&&n.add(o.gridRevision.id));for(const e of o.rows){const o=e.cells.filter(e=>e.blocks.some(e=>Tv(e,t)));o.length>0&&(e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id));for(const e of o)e.style?.revision&&n.add(e.style.revision.id),e.style?.propertyRevision&&n.add(e.style.propertyRevision.id),Pv(e.blocks,t,n)}}}function kv(e){const t=Bn(e),n=ao(e),o=/* @__PURE__ */new Set;for(let a=t.startIndex;a<=t.endIndex;a+=1){const e=n[a],r=a===t.startIndex?t.startParagraphOffset:0,i=a===t.endIndex?t.endParagraphOffset:Se(e),l=U(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Co(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&Pv(e,r,o);return o}function Rv(e){return function(e){const t=/* @__PURE__ */new Set,n=e=>{for(const n of e)n.revision?.id&&t.add(n.revision.id),n.revisionRangeMarker?.id&&t.add(n.revisionRangeMarker.id)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){r.style?.revision&&t.add(r.style.revision.id),r.gridRevision&&t.add(r.gridRevision.id);for(const e of r.rows){e.style?.revision&&t.add(e.style.revision.id),e.style?.propertyRevision&&t.add(e.style.propertyRevision.id);for(const n of e.cells)n.style?.revision&&t.add(n.style.revision.id),n.style?.propertyRevision&&t.add(n.style.propertyRevision.id),n.mergeRevisionState?.revisionId&&t.add(n.mergeRevisionState.revisionId),o(n.blocks)}}else n(r.runs)};for(const i of Co(e.document))i.propertyRevision&&t.add(i.propertyRevision.id),o(i.blocks),o(i.header),o(i.firstPageHeader),o(i.evenPageHeader),o(i.footer),o(i.firstPageFooter),o(i.evenPageFooter);const r=e.document.footnotes?.items??{};for(const i of Object.values(r))o(i.blocks);const a=e.document.endnotes?.items??{};for(const i of Object.values(a))o(i.blocks);return t}(e).size>0}function Bv(e,t){if(!Rv(e))return e;const n=Xo(e.document,t);if(!n.changed)return e;const o=ao({...e,document:n.document}),r=we(o,Bn(e));return{...e,document:n.document,selection:r}}function Mv(e){const t=Bn(e),n=ao(e);if(t.isCollapsed){const e=n[t.startIndex];return e?It(e,t.startParagraphOffset)?.href??null:null}const o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:Se(e);return U(e,r,a)}).filter(e=>e.text.length>0&&"image"!==e.kind);if(0===o.length)return null;const r=o[0]?.styles?.link;return r&&o.every(e=>e.styles?.link===r)?r:null}function Fv(e){const t=Bn(e),n=ao(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return Gt(e);if(!e.list)return Gt(e);const o=e.list.level??0;return o<=0?lr(e):ce(e,o-1)});return da(e,n,we(n,t))}function Av(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:a,applySelectionAwareTextCommand:i,applySelectionAwareParagraphCommand:l,applyTableAwareParagraphEdit:s,focusInput:c,clearPreferredColumn:d,resetTransactionGrouping:p,toolbarStyleState:g,selectionCollapsed:f,selectedImageRun:m}=e,h=e=>{d(),p(),o(e),c()},b=e=>{d(),p(),i(e),c()},y=e=>{d(),p(),l(e),c()},v=(e,t)=>{d(),p(),a(e,t),c()},x=()=>{const e=Bn(t);return ao(t).slice(e.startIndex,e.endIndex+1)},w=()=>x().some(e=>Boolean(e.list)),S=()=>{const e=t.selection.focus.paragraphId;return ao(t).find(t=>t.id===e)??null},I=()=>{const e=S();return!!e?.list&&(d(),p(),f()&&0===ot(e).length?l(e=>function(e){const t=Bn(e),n=ao(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Gt(e):lr(e));return da(e,n,we(n,t))}(e)):a(e=>s(e,e=>function(e){const t=vr(e.selection)?e:_e(e),{paragraph:n,index:o,offset:r}=E(t),a=me(n,U(n,0,r),Nt(n,r)),i=U(n,r,Se(n)),l=i.length>0?Vt(n,i.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=Or("");return e.style=n.style?{...n.style}:void 0,e.list=ln(n.list),e})(),s=ao(t),c=[...tt(s.slice(0,o)),a,l,...tt(s.slice(o+1))];return da(t,c,nt(ua(l,0)))}(e)),{mergeKey:bi}),c(),!0)},T=()=>{const e=t.selection,n=Kn(t),o=dt(t.document,e.anchor.paragraphId,n),r=dt(t.document,e.focus.paragraphId,n);return o&&r&&o.blockIndex===r.blockIndex?` [table b${o.blockIndex} r${o.rowIndex}:c${o.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},P=e=>{if(f())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${T()}`),b(t=>La(t,e))},k=e=>{f()||b(t=>function(e,t){const n=Bn(e);if(n.isCollapsed)return e;const o=ao(e).map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:Se(e);return ne(e,r,a,e=>({...e,styles:mr(Vo(e.styles,"underline",null!==t),"underlineStyle","single"===t?null:t)}))});return da(e,o,we(o,n))}(t,e))},R=(e,o)=>{if(f())return;const r=t.selection;n.info(`setStyle:${e}=${JSON.stringify(o)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${T()}`),b(t=>Na(t,e,o))},B=(e,t)=>{y(n=>r(n,e,t))},F=e=>{const t=!g()[e];B(e,"widowControl"===e?t:!!t||null)},A=()=>{v(e=>s(e,e=>M(e)))},O=()=>"main"===(t.activeZone??"main"),D=()=>{O()&&v(e=>xv(e))},L=e=>{const n=Mv(t);f()&&!n||v(t=>function(e,t){const n=Bn(e);if(!n.isCollapsed)return Na(e,"link",t);const o=ao(e)[n.startIndex];if(!o)return e;const r=It(o,n.startParagraphOffset);if(!r)return e;const a=Na(Sa(e,{anchor:ua(o,r.startOffset),focus:ua(o,r.endOffset)}),"link",t),i=ao(a)[n.startIndex];return i?{...a,selection:{anchor:ua(i,r.startOffset),focus:ua(i,r.endOffset)}}:a}(t,e),{mergeKey:yi})},N=()=>{const n=Mv(t)??"";f()&&!n||e.openLinkDialog(n)},$=()=>{L(null)},z=()=>{const t=m();if(!t)return;const n=nn(t.run)?.alt??"";e.openImageAltDialog(n)},H=t=>{m()&&v(n=>function(e,t,n){const o=$h(e);if(!o||!nn(o.run))return e;const r=ao(e),a=o.paragraphIndex+1,i=a<r.length&&xe(r[a])?en(r[a],t,n):Bt(t,n,1),l=a<r.length&&xe(r[a])?[...tt(r.slice(0,a)),i,...tt(r.slice(a+1))]:[...tt(r.slice(0,a)),i,...tt(r.slice(a))],s=pr(l),c=s[a]??i;return da(e,s,nt(ua(c,jt(c))))}(n,t,e.imageCaptionLabel()),{mergeKey:xi})},W=()=>{m()&&e.openImageCaptionDialog(function(e){const t=$h(e);if(!t||!nn(t.run))return null;const n=ao(e);return G(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:P,applyToggleCharacterBorderCommand:()=>{f()||b(e=>function(e){const t=Bn(e);if(t.isCollapsed)return e;const n=ao(e),o=n.slice(t.startIndex,t.endIndex+1).flatMap((e,n)=>{const o=t.startIndex+n,r=o===t.startIndex?t.startParagraphOffset:0,a=o===t.endIndex?t.endParagraphOffset:Se(e);return U(e,r,a)}).filter(e=>e.text.length>0);if(0===o.length)return e;const r=!o.every(e=>Boolean(e.styles?.textBorder)),a=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,a=n===t.endIndex?t.endParagraphOffset:Se(e);return ne(e,o,a,e=>({...e,styles:Ha(e.styles,r)}))});return da(e,a,we(a,t))}(e))},applyValueStyleCommand:R,applyUnderlineStyleCommand:k,applyChangeTextCaseCommand:e=>{f()||b(t=>ja(t,e))},applyClearFormattingCommand:()=>{f()||b(e=>function(e){const t=Bn(e);if(t.isCollapsed)return e;const n=ao(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const o=n===t.startIndex?t.startParagraphOffset:0,r=n===t.endIndex?t.endParagraphOffset:Se(e);return ne(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return da(e,n,we(n,t))}(e))},applyParagraphStyleCommand:B,toggleParagraphFlagCommand:F,applyParagraphListCommand:e=>{y(t=>function(e,t){const n=Bn(e),o=ao(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),l=i.length>0&&i.every(e=>e.list?.kind===t),s=o.map((e,n)=>{if(n<r||n>a)return Gt(e);const o=Gt(e);return l?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return da(e,s,we(s,n))}(t,e))},handleListFormatChange:e=>{y(t=>function(e,t){const n=Bn(e),o=ao(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Gt(e):e.list?{...Gt(e),list:{...e.list,format:t||void 0}}:Gt(e));return da(e,o,we(o,n))}(t,e))},handleListStartAtChange:e=>{y(t=>function(e,t){const n=Bn(e),o=ao(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Gt(e):e.list?{...Gt(e),list:{...e.list,startAt:null!==t?t:void 0}}:Gt(e));return da(e,o,we(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{h(C(t,e))},applyInsertPageBreakCommand:A,canInsertFootnoteCommand:O,applyInsertFootnoteCommand:D,handleStyleChange:e=>{y(t=>Io(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{h(Re(t,e,n))},applyToggleTrackChangesCommand:()=>{h(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),c()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),c()},applyAcceptRevisionsCommand:()=>{h(function(e){let t=e;for(const n of kv(e))t=Iv(t,n);return t}(t))},applyRejectRevisionsCommand:()=>{h(function(e){let t=e;for(const n of kv(e))t=Cv(t,n);return t}(t))},applyAcceptAllRevisionsCommand:()=>{h(function(e){return Bv(e,"accept")}(t))},applyRejectAllRevisionsCommand:()=>{h(function(e){return Bv(e,"reject")}(t))},applyLinkCommand:L,promptForLink:N,removeLinkCommand:$,applyImageAltCommand:e=>{m()&&v(t=>function(e,t){return Gh(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:vi})},promptForImageAlt:z,applyImageCaptionCommand:H,promptForImageCaption:W,applyImageWidthCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||v(t=>function(e,t){const n=$h(e),o=n&&nn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*mo));return zh(e,r,r*(o.height/o.width))}(t,e),{mergeKey:wi})},applyImageHeightCmCommand:e=>{!m()||!Number.isFinite(e)||e<=0||v(t=>function(e,t){const n=$h(e),o=n&&nn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*mo));return zh(e,r*(o.width/o.height),r)}(t,e),{mergeKey:wi})},applyImageCropAspectCommand:e=>{if(!m())return;const t=function(e){const t=e.trim().toLowerCase();if("reset"===t||"fit"===t||"fill"===t)return"reset";const n=t.split(/[:/]/);if(2!==n.length)return null;const o=Number(n[0]),r=Number(n[1]);return!Number.isFinite(o)||!Number.isFinite(r)||o<=0||r<=0?null:o/r}(e);null!==t&&v(e=>"reset"===t?Vh(e):Uh(e,t),{mergeKey:Si})},applyImageCropShapeCommand:e=>{m()&&v(t=>function(e,t){const n=t?.trim();return Gh(e,e=>{const t={...e};return n&&"rect"!==n?(t.cropShape={preset:n},t.cropFit||(t.cropFit="fill")):delete t.cropShape,t})}(t,e),{mergeKey:Si})},applyImageCropFillCommand:()=>{m()&&v(e=>function(e){const t=$h(e),n=t&&nn(t.run);return n?Gh(Wh(e,{crop:jh(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Si})},applyImageCropFitCommand:()=>{m()&&v(e=>function(e){return Gh(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Si})},resetImageCropCommand:()=>{m()&&v(e=>Vh(e),{mergeKey:Si})},applyImageBorderCommand:e=>{m()&&v(t=>function(e,t){return Gh(e,e=>{if(null===t.color){const{border:t,...n}=e;return n}const n={...e.border??{color:"#000000"}};return void 0!==t.color&&(n.color=t.color),void 0!==t.widthPt&&(n.widthPt=t.widthPt),void 0!==t.dash&&(n.dash=t.dash),{...e,border:n}})}(t,e))},flipImageCommand:e=>{m()&&v(t=>Xh(t,e),{mergeKey:Ii})},rotateImageCommand:e=>{m()&&v(t=>_h(t,e),{mergeKey:Ci})},applyImageTransparencyCommand:e=>{m()&&v(t=>function(e,t){return null===$h(e)?e:Gh(e,e=>{if(!Number.isFinite(t)||t<=0){const{transparency:t,...n}=e;return n}const n=Math.min(1,t);return{...e,transparency:Math.round(1e3*n)/1e3}})}(t,e??0),{mergeKey:Ti})},resetImageCommand:()=>{m()&&v(e=>function(e){return null===$h(e)?e:Gh(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,delete t.transparency,delete t.border,delete t.rotation,delete t.flipH,delete t.flipV,delete t.fillMode,t})}(e),{mergeKey:Pi})},handleListTab:e=>!dt(t.document,t.selection.focus.paragraphId,Kn(t))&&(!!w()&&(y(t=>"indent"===e?function(e){const t=Bn(e),n=ao(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Gt(e):e.list?ce(e,(e.list.level??0)+1):Gt(e));return da(e,n,we(n,t))}(t):Fv(t)),!0)),handleListEnter:I,handleListBoundaryBackspace:e=>{const n=S();return!(!n?.list||!f())&&(0===u(n,t.selection.focus)&&(d(),p(),l(e=>Fv(e)),e.currentTarget.value="",c(),!0))}}}(e)}function Ov(e){return function(e){const t=Av({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:e.applyTransactionalState,applySelectionAwareTextCommand:e.tableOps.applySelectionAwareTextCommand,applySelectionAwareParagraphCommand:e.tableOps.applySelectionAwareParagraphCommand,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,focusInput:e.focusInput,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,toolbarStyleState:e.toolbarStyleState,selectionCollapsed:()=>vr(e.state.selection),selectedImageRun:e.selectedImageRun,openLinkDialog:t=>e.setLinkDialog({isOpen:!0,initialHref:t}),openImageAltDialog:t=>e.setImageAltDialog({isOpen:!0,initialAlt:t}),openImageCaptionDialog:t=>e.setImageCaptionDialog({isOpen:!0,initialCaption:t}),imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Dv(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Ev=class{bindings=/* @__PURE__ */new Map;register(e){this.bindings.set(e.id,e)}unregister(e){this.bindings.delete(e)}getBindings(){return Array.from(this.bindings.values())}execute(e,t,n){const o=e.ctrlKey||e.metaKey,r=e.key.toLowerCase();for(const a of this.bindings.values())if(a.key.toLowerCase()===r&&Boolean(a.ctrlOrMeta)===o&&Boolean(a.shift)===e.shiftKey&&Boolean(a.alt)===e.altKey){if(a.command&&n&&(n.canExecuteCommand?.(a.command)??!0))return n.executeCommand(a.command),e.preventDefault(),!0;if(!1!==a.execute(t,e))return e.preventDefault(),!0}return!1}},Lv=[{id:"newDocument",command:"newDocument",key:"n",ctrlOrMeta:!0,execute:()=>!0},{id:"print",command:"print",key:"p",ctrlOrMeta:!0,execute:()=>!0},{id:"selectAll",command:"selectAll",key:"a",ctrlOrMeta:!0,execute:e=>{const t=e.state(),n=ao(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Sa(t,{anchor:ua(o,0),focus:ua(r,ot(r).length)})),e.focusInput(),!0}},{id:"editImageAlt",command:"editImageAlt",key:"a",ctrlOrMeta:!0,alt:!0,execute:e=>!!e.selectedImageRun()&&(e.commandsController.promptForImageAlt(),!0)},{id:"insertFootnote",command:"insertFootnote",key:"f",ctrlOrMeta:!0,alt:!0,execute:e=>(e.commandsController.applyInsertFootnoteCommand(),!0)},{id:"pastePlainText",command:"pastePlainText",key:"v",ctrlOrMeta:!0,shift:!0,execute:e=>(e.setForcePlainTextPaste(!0),e.focusInput(),!0)},{id:"bold",command:"bold",key:"b",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("bold"),!0)},{id:"italic",command:"italic",key:"i",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("italic"),!0)},{id:"underline",command:"underline",key:"u",ctrlOrMeta:!0,execute:e=>(e.commandsController.applyBooleanStyleCommand("underline"),!0)},{id:"link",command:"link",key:"k",ctrlOrMeta:!0,execute:e=>(e.commandsController.promptForLink(),!0)},{id:"orderedList",command:"orderedList",key:"7",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("ordered"),!0)},{id:"bulletList",command:"bulletList",key:"8",ctrlOrMeta:!0,shift:!0,execute:e=>(e.commandsController.applyParagraphListCommand("bullet"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:e=>(e.toggleFindReplace(!0),!0)},{id:"replace",command:"replace",key:"h",ctrlOrMeta:!0,execute:e=>(e.toggleReplace(!0),!0)},{id:"undo",command:"undo",key:"z",ctrlOrMeta:!0,execute:e=>(e.performUndo(),!0)},{id:"redo",command:"redo",key:"z",ctrlOrMeta:!0,shift:!0,execute:e=>(e.performRedo(),!0)},{id:"redoAlternative",command:"redo",key:"y",ctrlOrMeta:!0,execute:e=>(e.performRedo(),!0)},{id:"pageBreak",command:"pageBreak",key:"Enter",ctrlOrMeta:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>M(e))),e.focusInput(),!0)},{id:"lineBreak",command:"lineBreak",key:"Enter",shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Fa(e,"\n"))),e.focusInput(),!0)},{id:"columnBreak",command:"columnBreak",key:"Enter",ctrlOrMeta:!0,shift:!0,execute:e=>(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Aa(e))),e.focusInput(),!0)},{id:"splitBlock",command:"splitBlock",key:"Enter",execute:e=>(e.commandsController.handleListEnter()||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>yo(e))),e.focusInput()),!0)}];function Nv(e){return function(e){const t=new Ev;Lv.forEach(e=>t.register(e));const n=n=>{const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="ArrowLeft"===e||"ArrowRight"===e||"ArrowUp"===e||"ArrowDown"===e||"Home"===e||"End"===e||"PageUp"===e||"PageDown"===e,r="Shift"===e||"Control"===e||"Meta"===e||"Alt"===e,a=(n.ctrlKey||n.metaKey)&&("a"===t||"c"===t);return void(o||r||a||n.preventDefault())}if(n.isComposing||229===n.keyCode)return;const r=e.executeCommand?{executeCommand:(t,n)=>e.executeCommand?.(t,n),canExecuteCommand:(t,n)=>e.canExecuteCommand?.(t,n)}:void 0;if(!t.execute(n,e,r)){if((n.ctrlKey||n.metaKey)&&!n.altKey){if(("ArrowLeft"===n.key||"ArrowRight"===n.key)&&(n.preventDefault(),e.resetTransactionGrouping(),e.moveSelectionByWord("ArrowLeft"===n.key?"left":"right",n.shiftKey)))return void e.focusInput();if("Backspace"===n.key||"Delete"===n.key){if(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!vr(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e))),n.currentTarget.value="",void e.focusInput();const t=ao(o),r=t[t.findIndex(e=>e.id===o.selection.focus.paragraphId)];if(!r)return n.currentTarget.value="",void e.focusInput();if("Backspace"===n.key&&r.list&&0===u(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>Fv(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=ot(r),l=Me(i,a);return"Backspace"===n.key?0===a||l.start===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Sa(t,{anchor:ua(r,l.start),focus:ua(r,a)}),e=>Da(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ea(e))):l.end>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Sa(t,{anchor:ua(r,a),focus:ua(r,l.end)}),e=>Da(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ea(e))),n.currentTarget.value="",void e.focusInput()}}if("Home"===n.key||"End"===n.key){n.preventDefault(),e.resetTransactionGrouping();const t="Home"===n.key?"start":"end";return n.ctrlKey||n.metaKey?e.moveSelectionToDocumentBoundary(t,n.shiftKey):e.moveSelectionToParagraphBoundary(t,n.shiftKey),void e.focusInput()}if(!n.altKey||n.ctrlKey||n.metaKey||"ArrowUp"!==n.key&&"ArrowDown"!==n.key||(n.preventDefault(),e.resetTransactionGrouping(),e.clearPreferredColumn(),!e.moveSelectedImageByParagraph("ArrowUp"===n.key?-1:1)))switch(n.key){case"Backspace":return e.commandsController.handleListBoundaryBackspace(n)?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Da(e))),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ea(e))),n.currentTarget.value="",void e.focusInput();case"Tab":{if(e.commandsController.handleListTab(n.shiftKey?"outdent":"indent"))return void n.preventDefault();const t=e.resolveAdjacentTableCellPosition(o.document,o.selection.focus.paragraphId,n.shiftKey?-1:1);if(t)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applySelectionPreservingStructure({anchor:t,focus:t}),void e.focusInput();break}case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(va(o,-1))):(e.clearPreferredColumn(),e.applyState(Ia(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return va(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Ca(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return xa(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return ya(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return xa(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return ya(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var $v=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var zv={oasis:{color:"#0f766e",heading:"#115e59",body:"#1f2937"},office:{color:"#4472c4",heading:"#2f5597",body:"#1f2937"},facet:{color:"#8064a2",heading:"#604a7b",body:"#262626"},integral:{color:"#70ad47",heading:"#548235",body:"#1f2937"},ion:{color:"#ed7d31",heading:"#c55a11",body:"#262626"},retrospect:{color:"#5b9bd5",heading:"#2f75b5",body:"#1f2937"}},Hv={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},Wv={aptos:["Aptos, sans-serif","Aptos Display, sans-serif"],calibri:["Calibri, sans-serif","Calibri Light, sans-serif"],georgia:["Georgia, serif","Georgia, serif"],garamond:["Garamond, serif","Garamond, serif"]};function Uv(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function jv(e,t){return function(e,t){const n=zv[t],o=e.document.styles??{},r=Object.fromEntries(Object.entries(o).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.body,...o?{fontFamily:"Aptos Display, sans-serif"}:{fontFamily:"Aptos, sans-serif"}}}]}));return{...e,document:{...e.document,design:{...e.document.design??{},themeId:t,colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading,dk2:n.body},fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:"Aptos Display"},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:"Aptos"}}}},styles:r}}}(e,t)}function Vv(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Kv(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function _v(e){return null!=e&&""!==e?Number(e):null}function Xv({gate:e,style:t,selection:n,history:o,formatting:r,link:a,command:i,valueCommand:l,actionCommand:s}){const c=t.state;return{selectAll:i("selectAll",r.selectAll),selectWord:i("selectWord",r.selectWord),selectSentence:i("selectSentence",r.selectSentence),selectParagraph:i("selectParagraph",r.selectParagraph),selectCollapse:s("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:l("selectText",e=>{const t=e??{};return r.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:s("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:i("insertFootnote",r.insertFootnote),setNoteOptions:s("setNoteOptions",e=>{const t=e??{},n="endnote"===t.kind?"endnote":"footnote";r.setNoteOptions({kind:n,...void 0!==t.numberFormat?{numberFormat:t.numberFormat}:{},...void 0!==t.startAt?{startAt:_v(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:i("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:i("updateTableOfContents",r.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&r.hasTableOfContents()})),insertText:s("insertText",e=>{const t="object"==typeof e&&null!==e&&"text"in e?e:{text:e};r.insertText(String(t.text??""),"string"==typeof t.fontFamily?t.fontFamily:null)}),insertEquation:s("insertEquation",e=>{r.insertEquation(e)}),updateEquation:s("updateEquation",e=>{const t=e;r.updateEquation(t.runId,t.expression)}),pastePlainText:i("pastePlainText",r.pastePlainText),formatPainter:i("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:i("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:i("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:i("bold",r.bold,()=>({isActive:Boolean(c().bold)})),italic:i("italic",r.italic,()=>({isActive:Boolean(c().italic)})),underline:i("underline",r.underline,()=>({isActive:Boolean(c().underline)})),doubleUnderline:i("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===c().underlineStyle})),wordUnderline:i("wordUnderline",r.wordUnderline,()=>({isActive:"words"===c().underlineStyle})),strike:i("strike",r.strike,()=>({isActive:Boolean(c().strike)})),doubleStrike:i("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(c().doubleStrike)})),smallCaps:i("smallCaps",r.smallCaps,()=>({isActive:Boolean(c().smallCaps)})),allCaps:i("allCaps",r.allCaps,()=>({isActive:Boolean(c().allCaps)})),hidden:i("hidden",r.hidden,()=>({isActive:Boolean(c().hidden)})),noProof:i("noProof",r.noProof,()=>({isActive:Boolean(c().noProof)})),webHidden:i("webHidden",r.webHidden,()=>({isActive:Boolean(c().webHidden)})),specVanish:i("specVanish",r.specVanish,()=>({isActive:Boolean(c().specVanish)})),contextualAlternates:i("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(c().contextualAlternates)})),characterBorder:i("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(c().characterBorder)})),shadow:i("shadow",r.shadow,()=>({isActive:Boolean(c().shadow)})),emboss:i("emboss",r.emboss,()=>({isActive:Boolean(c().emboss)})),engrave:i("engrave",r.engrave,()=>({isActive:Boolean(c().imprint)})),outline:i("outline",r.outline,()=>({isActive:Boolean(c().outline)})),superscript:i("superscript",r.superscript,()=>({isActive:Boolean(c().superscript)})),subscript:i("subscript",r.subscript,()=>({isActive:Boolean(c().subscript)})),link:i("link",()=>(a.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&a.canPrompt(),isActive:Boolean(c().link)})),alignLeft:i("alignLeft",r.alignLeft,()=>({isActive:"left"===c().align})),alignCenter:i("alignCenter",r.alignCenter,()=>({isActive:"center"===c().align})),alignRight:i("alignRight",r.alignRight,()=>({isActive:"right"===c().align})),alignJustify:i("alignJustify",r.alignJustify,()=>({isActive:"justify"===c().align})),orderedList:i("orderedList",r.orderedList,()=>({isActive:"ordered"===c().listKind})),bulletList:i("bulletList",r.bulletList,()=>({isActive:"bullet"===c().listKind})),find:i("find",r.find),replace:i("replace",r.replace),replaceAll:s("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),toggleTrackChanges:i("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),acceptRevisions:i("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:i("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:i("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:i("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:i("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:i("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:i("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:i("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:i("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:i("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:i("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:i("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:i("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:i("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:i("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:i("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:i("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:i("togglePreciseFonts",r.togglePreciseFonts,()=>(Et(),{isActive:m()})),undo:i("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:i("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:i("pageBreak",r.pageBreak),lineBreak:i("lineBreak",r.lineBreak),columnBreak:i("columnBreak",r.columnBreak),splitBlock:i("splitBlock",r.splitBlock),insertNonBreakingSpace:i("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:i("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:i("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:i("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:i("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:i("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:i("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:i("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:l("setFontFamily",e=>r.setFontFamily(e||null),()=>c().fontFamily),setFontSize:l("setFontSize",e=>{const t=e&&"object"==typeof e&&"size"in e?e.size:e;return r.setFontSize(null!=t&&""!==t?yr(t):null),!0},()=>mn(c().fontSize)),increaseFontSize:i("increaseFontSize",r.increaseFontSize),decreaseFontSize:i("decreaseFontSize",r.decreaseFontSize),growFont1:i("growFont1",r.growFont1),shrinkFont1:i("shrinkFont1",r.shrinkFont1),changeTextCase:s("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:i("clearFormatting",r.clearFormatting),setColor:l("setColor",e=>r.setColor(e??null),()=>c().color||null),setHighlight:l("setHighlight",e=>r.setHighlight(e??null),()=>c().highlight||null),setTextShading:l("setTextShading",e=>r.setTextShading(e??null),()=>c().textShading||null),setStyleId:l("setStyleId",e=>r.setStyleId(String(e)),()=>c().styleId||"normal"),setCharacterStyleId:l("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>c().characterStyleId||""),applyUnderlineStyle:l("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>c().underlineStyle),setUnderlineStyle:l("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>c().underlineStyle),setUnderlineColor:l("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>c().underlineColor),setCharacterScale:l("setCharacterScale",e=>r.setCharacterScale(_v(e)),()=>c().characterScale),setCharacterSpacing:l("setCharacterSpacing",e=>r.setCharacterSpacing(_v(e)),()=>c().characterSpacing),setRunSnapToGrid:l("setRunSnapToGrid",e=>r.setRunSnapToGrid(Vv(e)),()=>c().snapToGrid),setFitText:l("setFitText",e=>r.setFitText(_v(e)),()=>c().fitText),setBaselineShift:l("setBaselineShift",e=>r.setBaselineShift(_v(e)),()=>c().baselineShift),setEmphasisMark:l("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>c().emphasisMark),setTextEffect:l("setTextEffect",e=>r.setTextEffect(e||null),()=>c().textEffect),setKerning:l("setKerning",e=>r.setKerning(_v(e)),()=>c().kerningThreshold),setLigatures:l("setLigatures",e=>r.setLigatures(e||null),()=>c().ligatures),setNumberSpacing:l("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>c().numberSpacing),setNumberForm:l("setNumberForm",e=>r.setNumberForm(e||null),()=>c().numberForm),setStylisticSet:l("setStylisticSet",e=>r.setStylisticSet(_v(e)),()=>c().stylisticSet)}}function Gv({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const l=t.state;return{documentStyles:i("documentStyles",()=>{},()=>({isEnabled:!0,value:n.documentStyles()})),print:i("print",()=>n.printDocument(),()=>({isEnabled:!0})),paste:i("paste",()=>a.paste(),()=>({isEnabled:e.isCommandEnabled("paste")&&a.canPaste()})),pasteAsPlainText:i("pasteAsPlainText",()=>a.pasteAsPlainText(),()=>({isEnabled:e.isCommandEnabled("pasteAsPlainText")&&a.canPaste()})),cut:i("cut",()=>a.cut(),()=>({isEnabled:e.isCommandEnabled("cut")&&a.hasSelection()&&a.canCut()})),pasteMergeFormatting:i("pasteMergeFormatting",()=>a.pasteMergeFormatting(),()=>({isEnabled:e.isCommandEnabled("pasteMergeFormatting")&&a.canPaste()})),copy:i("copy",()=>a.copy(),()=>({isEnabled:e.isCommandEnabled("copy")&&a.hasSelection()})),newDocument:i("newDocument",()=>n.newDocument()),exportDocx:i("exportDocx",()=>n.exportDocx()),exportPdf:i("exportPdf",()=>n.exportPdf()),importDocument:i("importDocument",()=>n.importDocument()),insertHtml:i("insertHtml",e=>{if(!e||"object"!=typeof e||"string"!=typeof e.html)throw new TypeError("insertHtml requires a payload with a string html property.");n.insertHtml(e.html)}),insertImage:i("insertImage",()=>n.insertImage()),insertShape:i("insertShape",e=>n.insertShape(String(e))),setShapeFill:i("setShapeFill",e=>n.setShapeFill(null==e?null:String(e))),setShapeOutline:i("setShapeOutline",e=>n.setShapeOutline(null==e?null:String(e))),setShapeOutlineWidth:i("setShapeOutlineWidth",e=>n.setShapeOutlineWidth(Number(e))),alignFloatingObject:i("alignFloatingObject",e=>n.alignFloatingObject(e??"center")),reorderFloatingObject:i("reorderFloatingObject",e=>n.reorderFloatingObject(e??"front")),nudgeFloatingObject:i("nudgeFloatingObject",e=>{const t=e??{};n.nudgeFloatingObject(Number(t.dx)||0,Number(t.dy)||0)}),setFloatingFixedPosition:i("setFloatingFixedPosition",e=>n.setFloatingFixedPosition(Boolean(e))),setFloatingRotation:i("setFloatingRotation",e=>n.setFloatingRotation(Number(e))),setFloatingWrapPreset:i("setFloatingWrapPreset",e=>n.setFloatingWrapPreset(e??"square")),setFloatingWrapText:i("setFloatingWrapText",e=>n.setFloatingWrapText(e??"bothSides")),setFloatingPositionPreset:i("setFloatingPositionPreset",e=>n.setFloatingPositionPreset(e??"middleCenter")),setShapePreset:i("setShapePreset",e=>n.setShapePreset(null==e?"rect":String(e))),setTextBoxTextDirection:i("setTextBoxTextDirection",e=>n.setTextBoxTextDirection(e??"horz")),setTextBoxVerticalAlign:i("setTextBoxVerticalAlign",e=>n.setTextBoxVerticalAlign(e??"t")),editTextBoxAlt:i("editTextBoxAlt",e=>n.setTextBoxAlt(null==e?null:String(e))),rotateTextBox:i("rotateTextBox",e=>n.rotateTextBox(e??"left")),textBoxWidthCm:i("textBoxWidthCm",e=>n.setTextBoxWidthCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.width??null})),textBoxHeightCm:i("textBoxHeightCm",e=>n.setTextBoxHeightCm(Number(e)),()=>({isEnabled:n.isTextBoxSelected(),value:n.getTextBoxSizeCm()?.height??null})),openSymbolDialog:i("openSymbolDialog",()=>n.openSymbolDialog()),openEquationDialog:i("openEquationDialog",()=>n.openEquationDialog()),tableProperties:i("tableProperties",e=>n.openTableProperties(e?.activeTab??"table"),()=>({isEnabled:n.hasActiveTable()})),unlink:i("unlink",()=>o.remove(),()=>({isEnabled:e.isCommandEnabled("unlink")&&Boolean(l().link),isActive:Boolean(l().link)})),editImageAlt:i("editImageAlt",()=>r.promptAlt(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),insertImageCaption:i("insertImageCaption",()=>r.promptCaption(),()=>({isEnabled:r.isSelected(),isActive:r.isSelected()})),imageContext:i("imageContext",()=>{},()=>({isEnabled:r.isSelected(),isActive:r.isSelected(),value:null})),imageWidthCm:i("imageWidthCm",e=>r.setWidthCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.width??null})),imageHeightCm:i("imageHeightCm",e=>r.setHeightCm(Number(e)),()=>({isEnabled:r.isSelected(),value:r.getSizeCm()?.height??null})),imageCrop:i("imageCrop",()=>r.toggleCrop(),()=>({isEnabled:r.isSelected(),isActive:r.isCropActive()})),imageCropAspect:i("imageCropAspect",e=>r.applyCropAspect(String(e)),()=>({isEnabled:r.isSelected()})),imageCropShape:i("imageCropShape",e=>r.applyCropShape(String(e)),()=>({isEnabled:r.isSelected(),value:r.getCropShape()})),imageCropFill:i("imageCropFill",()=>r.applyCropFill(),()=>({isEnabled:r.isSelected()})),imageCropFit:i("imageCropFit",()=>r.applyCropFit(),()=>({isEnabled:r.isSelected()})),imageCropReset:i("imageCropReset",()=>r.resetCrop(),()=>({isEnabled:r.isSelected()})),imageFlip:i("imageFlip",e=>r.flip(e??"horizontal"),()=>({isEnabled:r.isSelected()})),imageRotate:i("imageRotate",e=>r.rotate(e??"left"),()=>({isEnabled:r.isSelected()})),imageBorder:i("imageBorder",e=>r.setBorder(e),()=>({isEnabled:r.isSelected(),value:r.getBorder()})),imageTransparency:i("imageTransparency",e=>r.setTransparency("number"==typeof e?e:null==e?0:Number(e)),()=>({isEnabled:r.isSelected(),value:r.getTransparency()})),resetImage:i("resetImage",()=>r.reset(),()=>({isEnabled:r.canReset()}))}}function Yv({style:e,paragraph:t,section:n,valueCommand:o,actionCommand:r}){const a=e.state;return{outdent:r("outdent",()=>t.outdent()),indent:r("indent",()=>t.indent()),moveParagraphsUp:r("moveParagraphsUp",()=>t.moveParagraphsUp(),()=>({isEnabled:t.canMoveParagraphsUp()})),moveParagraphsDown:r("moveParagraphsDown",()=>t.moveParagraphsDown(),()=>({isEnabled:t.canMoveParagraphsDown()})),togglePageBreakBefore:r("togglePageBreakBefore",()=>t.togglePageBreakBefore(),()=>({isActive:Boolean(a().pageBreakBefore)})),toggleKeepWithNext:r("toggleKeepWithNext",()=>t.toggleKeepWithNext(),()=>({isActive:Boolean(a().keepWithNext)})),toggleKeepLinesTogether:r("toggleKeepLinesTogether",()=>t.toggleKeepLinesTogether(),()=>({isActive:Boolean(a().keepLinesTogether)})),toggleWidowControl:r("toggleWidowControl",()=>t.toggleWidowControl(),()=>({isActive:Boolean(a().widowControl)})),toggleParagraphBidi:r("toggleParagraphBidi",()=>t.setBidi(!a().bidi||null),()=>({isActive:Boolean(a().bidi)})),setParagraphBidi:o("setParagraphBidi",e=>(t.setBidi(Vv(e)),!0),()=>a().bidi),setParagraphAlign:o("setParagraphAlign",e=>(t.setParagraphAlign(e),!0),()=>a().align),sortParagraphs:r("sortParagraphs",e=>t.sortParagraphs(!0===e||"true"===e||Boolean(e?.descending))),promote:r("promote",()=>t.promote()),demote:r("demote",()=>t.demote()),resetParagraphFormatting:r("resetParagraphFormatting",()=>t.resetParagraphFormatting()),setOutlineLevel:r("setOutlineLevel",e=>{const n=e??void 0,o=null==n||"body"===n||""===n?null:Number(n);t.setOutlineLevel(null===o||Number.isNaN(o)?null:o)},()=>({value:Number(e.state().outlineLevel)||null})),setParagraphTabStops:r("setParagraphTabStops",e=>{const n=e??{};t.setTabStops({...void 0!==n.tabs?{tabs:n.tabs}:{},...void 0!==n.set?{set:n.set}:{},...void 0!==n.clear?{clear:n.clear}:{},...void 0!==n.clearAll?{clearAll:n.clearAll}:{},...void 0!==n.default?{default:n.default}:{}})}),setSpacingAfter:o("setSpacingAfter",e=>(t.setSpacingAfter(_v(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(_v(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(Vv(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Kv(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Kv(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(Vv(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(Vv(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(Vv(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(Vv(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(Vv(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(Vv(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(Vv(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(Vv(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(Vv(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(Vv(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(Vv(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(Vv(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(Vv(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(Vv(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(_v(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(_v(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(_v(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(_v(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",_v(n.value))},()=>{const e=Number(a().indentFirstLine),t=Number(a().indentHanging),n=Number.isFinite(t)&&t>0?"hanging":Number.isFinite(e)&&e>0?"firstLine":"none";return{isActive:"none"!==n,value:n}}),setParagraphShading:o("setParagraphShading",e=>(t.setShading(e??null),!0),()=>a().shading||"#ffffff"),applyParagraphBorders:r("applyParagraphBorders",()=>t.applyBorders()),applyHorizontalLine:r("applyHorizontalLine",()=>t.addHorizontalLine()),setDropCap:r("setDropCap",e=>{const n=e??{};t.setDropCap(n)},()=>({value:t.hasDropCap()})),setLineHeight:o("setLineHeight",e=>(t.setLineHeight(_v(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(_v(e))),setListLevel:r("setListLevel",e=>t.setListLevel(_v(e)??0)),toggleOrientation:r("toggleOrientation",()=>n.toggleOrientation(),()=>({isActive:n.isLandscape()})),setOrientation:r("setOrientation",e=>n.setOrientation(e)),sectionBreakNextPage:r("sectionBreakNextPage",()=>n.breakNextPage()),sectionBreakContinuous:r("sectionBreakContinuous",()=>n.breakContinuous()),sectionBreakEvenPage:r("sectionBreakEvenPage",()=>n.breakEvenPage()),sectionBreakOddPage:r("sectionBreakOddPage",()=>n.breakOddPage()),sectionBreakNextColumn:r("sectionBreakNextColumn",()=>n.breakNextColumn()),setPageMargins:r("setPageMargins",e=>{n.setPageMargins(e??{})},()=>({value:n.getMargins()})),setMarginsPreset:r("setMarginsPreset",e=>{"string"==typeof e&&e.length>0&&n.setMarginsPreset(e)}),setSectionPageNumbering:r("setSectionPageNumbering",e=>{const t=e??{};n.setPageNumbering({...void 0!==t.start?{start:Number(t.start)}:{},..."string"==typeof t.format?{format:t.format}:{}})},()=>({value:n.getPageNumbering()})),setPaperSize:r("setPaperSize",e=>{const t=e??{};void 0!==t.widthPt&&void 0!==t.heightPt&&n.setPaperSize({widthPt:Number(t.widthPt),heightPt:Number(t.heightPt)})},()=>({value:n.getPaperSize()})),setPaperSizePreset:r("setPaperSizePreset",e=>{"string"==typeof e&&e.length>0&&n.setPaperSizePreset(e)}),setColumns:r("setColumns",e=>{const t=e??{};void 0!==t.count&&n.setColumns({count:Number(t.count),...void 0!==t.space?{space:Number(t.space)}:{},...void 0!==t.separator?{separator:Boolean(t.separator)}:{}})}),setColumnsPreset:r("setColumnsPreset",e=>{if("string"==typeof e&&e.length>0){const t=sn(e);if(!t)return;n.setColumns({count:t.count})}}),setSectionVerticalAlign:r("setSectionVerticalAlign",e=>{const t=e??void 0;void 0!==t&&"top"!==t&&"center"!==t&&"both"!==t&&"bottom"!==t||n.setVerticalAlign(t??"top")},()=>({value:n.getVerticalAlign()})),setSectionStart:r("setSectionStart",e=>{const t=e??void 0;void 0!==t&&"nextPage"!==t&&"continuous"!==t&&"evenPage"!==t&&"oddPage"!==t&&"nextColumn"!==t||n.setSectionStart(t??"nextPage")},()=>({value:n.getSectionStart()})),setSectionBidi:r("setSectionBidi",e=>{const t=e??void 0;n.setBidi(t??!0)},()=>({value:n.getBidi()})),setHyphenation:r("setHyphenation",e=>{const t=e??{};n.setHyphenation(t)},()=>({value:n.getHyphenation().value}))}}function qv({gate:e,headerFooter:t,command:n,actionCommand:o}){return{editHeader:n("editHeader",()=>(t.editHeader(),!0)),editFooter:n("editFooter",()=>(t.editFooter(),!0)),editFirstPageHeader:n("editFirstPageHeader",()=>(t.editFirstPageHeader(),!0)),editEvenPageHeader:n("editEvenPageHeader",()=>(t.editEvenPageHeader(),!0)),editFirstPageFooter:n("editFirstPageFooter",()=>(t.editFirstPageFooter(),!0)),editEvenPageFooter:n("editEvenPageFooter",()=>(t.editEvenPageFooter(),!0)),insertPageNumber:n("insertPageNumber",()=>(t.insertPageNumber(),!0)),insertPageNumberXOfY:n("insertPageNumberXOfY",()=>(t.insertPageNumberXOfY(),!0)),placePageNumberTop:n("placePageNumberTop",()=>(t.placePageNumberTop(),!0)),placePageNumberBottom:n("placePageNumberBottom",()=>(t.placePageNumberBottom(),!0)),exitHeaderFooter:o("exitHeaderFooter",()=>t.exit(),()=>({isEnabled:e.isCommandEnabled("exitHeaderFooter")&&t.isInHeaderFooter()})),setDifferentFirstPage:o("setDifferentFirstPage",e=>{const n=e??void 0;t.setDifferentFirstPage(n??!0)},()=>({value:t.getDifferentFirstPage()})),setDifferentOddEven:o("setDifferentOddEven",e=>{const n=e??void 0;t.setDifferentOddEven(n??!0)},()=>({value:t.getDifferentOddEven()}))}}function Zv({bookmark:e,actionCommand:t}){return{insertBookmark:t("insertBookmark",t=>{e.insert("string"==typeof t&&t.trim().length>0?t:void 0)}),removeBookmark:t("removeBookmark",t=>{"string"==typeof t&&e.remove(t)})}}function Jv({fields:e,actionCommand:t}){return{insertDateField:t("insertDateField",()=>{e.insertDate()}),insertDateTime:t("insertDateTime",t=>{const n=t??{};e.insertDateTime(n.dateFormat)}),insertCrossReference:t("insertCrossReference",t=>{const n=t??{};if("string"!=typeof n.bookmark||0===n.bookmark.length)return;const o="PAGEREF"===n.type?"PAGEREF":"REF";e.insertCrossReference({type:o,bookmark:n.bookmark})})}}function Qv({gate:e,table:t,actionCommand:n,valueCommand:o}){return{tableContext:n("tableContext",()=>{},()=>({isEnabled:t.insideTable(),isActive:t.insideTable(),value:t.selectionLabel()})),tableMerge:n("tableMerge",()=>t.merge(),()=>({isEnabled:e.isCommandEnabled("tableMerge")&&t.canMerge()})),tableSplit:n("tableSplit",()=>t.split(),()=>({isEnabled:e.isCommandEnabled("tableSplit")&&t.canSplit()})),tableToText:n("tableToText",()=>t.convertToText(),()=>({isEnabled:e.isCommandEnabled("tableToText")&&t.canConvertToText()})),textToTable:n("textToTable",()=>t.convertToTable(),()=>({isEnabled:e.isCommandEnabled("textToTable")&&t.canConvertToTable()})),tableSplitAtRow:n("tableSplitAtRow",()=>t.splitTableAtRow(),()=>({isEnabled:e.isCommandEnabled("tableSplitAtRow")&&t.canSplitTableAtRow()})),tableSortAscending:n("tableSortAscending",()=>t.sortTable("ascending"),()=>({isEnabled:e.isCommandEnabled("tableSortAscending")&&t.canSortTable()})),tableSortDescending:n("tableSortDescending",()=>t.sortTable("descending"),()=>({isEnabled:e.isCommandEnabled("tableSortDescending")&&t.canSortTable()})),tableDelete:n("tableDelete",()=>t.deleteTable(),()=>({isEnabled:e.isCommandEnabled("tableDelete")&&t.canDeleteTable()})),tableRepeatHeaderRows:n("tableRepeatHeaderRows",()=>t.toggleRepeatHeaderRows(),()=>({isEnabled:e.isCommandEnabled("tableRepeatHeaderRows")&&t.canToggleRepeatHeaderRows(),isActive:t.isRepeatHeaderRowsActive()})),tableInsertColumnBefore:n("tableInsertColumnBefore",()=>t.insertColumnBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnBefore")&&t.canEditColumn()})),tableInsertColumnAfter:n("tableInsertColumnAfter",()=>t.insertColumnAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertColumnAfter")&&t.canEditColumn()})),tableDeleteColumn:n("tableDeleteColumn",()=>t.deleteColumn(),()=>({isEnabled:e.isCommandEnabled("tableDeleteColumn")&&t.canEditColumn()})),tableInsertRowBefore:n("tableInsertRowBefore",()=>t.insertRowBefore(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowBefore")&&t.canEditRow()})),tableInsertRowAfter:n("tableInsertRowAfter",()=>t.insertRowAfter(),()=>({isEnabled:e.isCommandEnabled("tableInsertRowAfter")&&t.canEditRow()})),tableDeleteRow:n("tableDeleteRow",()=>t.deleteRow(),()=>({isEnabled:e.isCommandEnabled("tableDeleteRow")&&t.canEditRow()})),tableDeleteCells:n("tableDeleteCells",()=>t.deleteCell(),()=>({isEnabled:e.isCommandEnabled("tableDeleteCells")&&t.canDeleteCell()})),tableCellShading:n("tableCellShading",e=>t.cellShading(e??null)),tableCellBorders:n("tableCellBorders",()=>t.cellBorders()),tableCellNoBorders:n("tableCellNoBorders",()=>t.cellNoBorders()),tableApplyBorderPreset:n("tableApplyBorderPreset",e=>t.applyBorderPreset(e)),toggleTableDrawBorders:n("toggleTableDrawBorders",()=>t.toggleDrawingBorders(),()=>({isEnabled:t.insideTable(),isActive:t.isDrawingBorders()})),toggleTableGridlines:n("toggleTableGridlines",()=>t.toggleGridlines(),()=>({isEnabled:t.insideTable(),isActive:t.isShowingGridlines()})),tableWidth100:n("tableWidth100",()=>t.width100()),tableAlignLeft:n("tableAlignLeft",()=>t.alignLeft()),tableAlignCenter:n("tableAlignCenter",()=>t.alignCenter()),tableAlignRight:n("tableAlignRight",()=>t.alignRight()),tableSetCellVerticalAlign:n("tableSetCellVerticalAlign",e=>t.setCellVerticalAlign(e)),tableSetCellTextDirection:n("tableSetCellTextDirection",e=>t.setCellTextDirection(e)),tableSetCellWidth:n("tableSetCellWidth",e=>t.setCellWidth(String(e))),tableSetCellNoWrap:n("tableSetCellNoWrap",e=>t.setCellNoWrap(Vv(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(Vv(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(Vv(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(Vv(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetHeaderRow")&&t.canSetActiveTableRowHeader()})),tableSetColumnWidth:o("tableSetColumnWidth",e=>(t.setActiveTableColumnWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetColumnWidth")&&t.canSetActiveTableColumnWidth()})),tableSetTableWidth:o("tableSetTableWidth",e=>(t.setActiveTableWidth(e),!0),()=>({isEnabled:e.isCommandEnabled("tableSetTableWidth")&&t.canSetActiveTableWidth()})),tableSetCellMargins:n("tableSetCellMargins",e=>t.setCellMargins(e??{}),()=>({isEnabled:e.isCommandEnabled("tableSetCellMargins")&&t.canSetCellMargins()})),tableSetCellSpacing:n("tableSetCellSpacing",e=>t.setCellSpacing(_v(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(_v(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Kv(e)),()=>({isEnabled:e.isCommandEnabled("tableSetAlignment")&&t.canSetTableAlignment()})),tableFormula:n("tableFormula",e=>t.evaluateTableFormula(String(e)),()=>({isEnabled:e.isCommandEnabled("tableFormula")&&t.canEvaluateTableFormula()})),tableSelectCell:n("tableSelectCell",()=>t.selectTablePart("cell"),()=>({isEnabled:e.isCommandEnabled("tableSelectCell")&&t.canSelectTable()})),tableSelectRow:n("tableSelectRow",()=>t.selectTablePart("row"),()=>({isEnabled:e.isCommandEnabled("tableSelectRow")&&t.canSelectTable()})),tableSelectColumn:n("tableSelectColumn",()=>t.selectTablePart("column"),()=>({isEnabled:e.isCommandEnabled("tableSelectColumn")&&t.canSelectTable()})),tableSelectTable:n("tableSelectTable",()=>t.selectTablePart("table"),()=>({isEnabled:e.isCommandEnabled("tableSelectTable")&&t.canSelectTable()})),tableToggleHeaderRow:n("tableToggleHeaderRow",()=>t.toggleTblLook("firstRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstRow??!1})),tableToggleTotalRow:n("tableToggleTotalRow",()=>t.toggleTblLook("lastRow"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastRow??!1})),tableToggleBandedRows:n("tableToggleBandedRows",()=>t.toggleTblLook("bandedRows"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedRows??!1})),tableToggleFirstColumn:n("tableToggleFirstColumn",()=>t.toggleTblLook("firstCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.firstCol??!1})),tableToggleLastColumn:n("tableToggleLastColumn",()=>t.toggleTblLook("lastCol"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.lastCol??!1})),tableToggleBandedColumns:n("tableToggleBandedColumns",()=>t.toggleTblLook("bandedCols"),()=>({isEnabled:t.insideTable(),isActive:t.getTblLook()?.bandedCols??!1})),setTableStyle:n("setTableStyle",e=>t.setStyleId(String(e??"")),()=>({isEnabled:t.insideTable(),value:t.getStyleId()})),tableToggleAutoFit:n("tableToggleAutoFit",()=>t.toggleAutoFit(),()=>({isEnabled:t.insideTable(),isActive:"autofit"===t.getLayout()})),tableAutoFit:n("tableAutoFit",e=>t.setAutoFit(e??"contents"),()=>({isEnabled:t.canSetAutoFit()})),tableDistributeColumns:n("tableDistributeColumns",()=>t.distributeColumns(),()=>({isEnabled:e.isCommandEnabled("tableDistributeColumns")&&t.canEditColumn()})),tableDistributeRows:n("tableDistributeRows",()=>t.distributeRows(),()=>({isEnabled:e.isCommandEnabled("tableDistributeRows")&&t.canEditRow()})),insertTable:n("insertTable",e=>{const{rows:n,cols:o,columns:r}=e??{},a=o??r;n&&a&&t.insert(n,a)})}}function ex({design:e,actionCommand:t}){return{applyDocumentTheme:t("applyDocumentTheme",t=>e.applyTheme(String(t)),()=>({value:e.getDesign()?.themeId})),setDocumentColorScheme:t("setDocumentColorScheme",t=>e.setColorScheme(String(t)),()=>({value:e.getDesign()?.colorSchemeId})),setDocumentFontScheme:t("setDocumentFontScheme",t=>e.setFontScheme(String(t)),()=>({value:e.getDesign()?.fontSchemeId})),setDocumentParagraphSpacing:t("setDocumentParagraphSpacing",t=>e.setParagraphSpacing(String(t)),()=>({value:e.getDesign()?.paragraphSpacingId})),setDocumentEffects:t("setDocumentEffects",t=>e.setEffects(String(t)),()=>({value:e.getDesign()?.effectsId})),setDocumentPageColor:t("setDocumentPageColor",t=>e.setPageColor(t??null),()=>({value:e.getDesign()?.pageColor})),setDocumentWatermark:t("setDocumentWatermark",t=>e.setWatermark(t??null),()=>({value:e.getDesign()?.watermark})),setDocumentPageBorder:t("setDocumentPageBorder",t=>e.setPageBorder(t??null),()=>({value:e.getPageBorder()})),setDocumentDesignDefault:t("setDocumentDesignDefault",()=>e.setDefault())}}var tx=/* @__PURE__ */new Set(["copy","selectAll","selectWord","selectSentence","selectParagraph","selectCollapse","nextRevision","previousRevision","nextComment","previousComment","toggleCommentsPanel","find","replace","print","exportDocx","exportPdf","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts"]);function nx(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||(tx.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))}}function ox(e){return{state:()=>e.styleController.toolbarStyleState()}}function rx(e){return{isCollapsed:()=>vr(e.state().selection)}}function ax(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var ix={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function lx(e){return/\p{L}|\p{N}/u.test(e)}function sx(e){return"."===e||"!"===e||"?"===e}function cx(e,t){return ua(e,t)}function dx(e,t,n,o){return e-n||t-o}function ux(e,t){const n=ao(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:cx(o,t.startOffset),focus:cx(r,t.endOffset)}}:e}function px(e,t,n){if(!t.length)return null;const o=ao(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?Bn(e,o).end:Bn(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=u(l,a);return("next"===n?t.find(e=>dx(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>dx(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function gx(e){const t=ao(e),n=[],o=/* @__PURE__ */new Set;return t.forEach((e,t)=>{let r=0;for(const a of e.runs){const e=a.revision?.id;e&&!o.has(e)&&(o.add(e),n.push({id:e,startIndex:t,startOffset:r,endIndex:t,endOffset:r+a.text.length})),r+=a.text.length}}),n}function fx(e,t){const n=px(e,gx(e),t);return n?ux(e,n):e}function mx(e){const t=ao(e),n=new Map(t.map((e,t)=>[e.id,t])),o=e.document.comments;if(!o)return[];const r=[];for(const a of o.order){const e=o.items[a];if(!e?.start||!e.end)continue;const i=n.get(e.start.paragraphId),l=n.get(e.end.paragraphId);if(void 0===i||void 0===l)continue;const s=t[i],c=t[l],d=Math.max(0,Math.min(e.start.offset,s.runs.reduce((e,t)=>e+t.text.length,0))),u=Math.max(0,Math.min(e.end.offset,c.runs.reduce((e,t)=>e+t.text.length,0)));dx(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>dx(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function hx(e,t){const n=px(e,mx(e),t);return n?ux(e,n):e}function bx(e){const t=mx(e);if(!t.length)return null;const n=Bn(e),o=t.find(e=>0===dx(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===dx(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>dx(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&dx(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}var yx=e=>Math.round(e/Zo*96);function vx(e,t=3){const n=[];for(const o of Vr(e.document)){const e=Qn(o.style?.styleId);if(null===e||e>t)continue;const r=ot(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function xx(e){const t=Gn(e.text).id;return e.fieldChar?{id:t,text:e.text,kind:"fieldChar",fieldChar:e.fieldChar}:void 0!==e.fieldInstruction?{id:t,text:e.text,kind:"fieldInstruction",fieldInstruction:e.fieldInstruction}:{id:t,text:e.text,kind:"text"}}function wx(e,t){const n=Or("");return n.runs=e,t&&(n.style=t),n}function Sx(e,t,n){const o=void 0!==t?String(t):"";return wx([xx({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:yx(40),indentLeft:yx(397*(e.level-1))})}function Ix(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return So(o*hr,2)}function Cx(e,t,n,o){const r=Co(e.document),a=r[t];if(!a)return e;const i=[...r];return i[t]={...a,blocks:n},{...e,document:{...e.document,sections:i},selection:nt(ua(o,0))}}function Tx(e,t=()=>{},n=3){if("main"!==tr(e))return e;const o=Kn(e),r=Co(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>Sx(e,t(e.id),n));return[wx([xx({text:"",fieldChar:{kind:"begin"}}),xx({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),xx({text:"",fieldChar:{kind:"separate"}})]),...o,wx([xx({text:"",fieldChar:{kind:"end"}})])]}(vx(e,n),t,Ix(r)),i=fr(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&We(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return Cx(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function Px(e){let t=0,n="",o=-1,r=-1,a=!1;for(let i=0;i<e.length;i+=1){const l=e[i];if("paragraph"===l.type)for(const e of l.runs){const l=de(e),s=qt(e);if("begin"===l?.kind)t+=1,1===t&&(r=i,n="",a=!1,o=-1);else if(1===t&&void 0!==s)n+=s,/\bTOC\b/i.test(n)&&(a=!0);else if("separate"===l?.kind)1===t&&(o=i);else if("end"===l?.kind){if(1===t&&a)return{startBlockIndex:o>=0?o:r,endBlockIndex:i};t=Math.max(0,t-1)}}}return null}function kx(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?po(n):11,r="increase"===t?Go(o):Rn(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",gr(r)),!0},n=e=>{const t=ho(e.document),n=/* @__PURE__ */new Map;for(const o of t.pages)for(const e of o.blocks){const t=e.paragraphId;t&&!n.has(t)&&n.set(t,o.index+1)}return e=>n.get(e)};return{formatPainterOnce:e.formatPainter.armOnce,formatPainterContinuous:e.formatPainter.armContinuous,cancelFormatPainter:()=>(e.formatPainter.cancel(),!0),formatPainterMode:e.formatPainter.mode,canCaptureFormatPainter:e.formatPainter.canCapture,selectAll:()=>{const t=Vr(e.state().document);if(0===t.length)return!1;const n=t[0],o=t[t.length-1];return e.applyState({...e.state(),selection:{anchor:ua(n,0),focus:ua(o,ot(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=E(e),o=ot(t);let r=n,a=n;for(;r>0&&lx(o[r-1]);)r-=1;for(;a<o.length&&lx(o[a]);)a+=1;return Sa(e,{anchor:ua(t,r),focus:ua(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=E(e),o=ot(t);let r=n;for(;r>0&&!sx(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!sx(o[a]);)a+=1;return a<o.length&&(a+=1),Sa(e,{anchor:ua(t,r),focus:ua(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=ao(e),n=Bn(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Sa(e,{anchor:ua(o,0),focus:ua(r,Se(r))}):e}(e.state())),e.focusInput(),!0),selectCollapse:(t=!1)=>!e.isReadOnly()&&(e.applyState(function(e,t=!1){const n=e.selection.anchor,o=e.selection.focus,r=ao(e),a=go(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Sa(e,{anchor:i,focus:i})}(e.state(),t)),e.focusInput(),!0),selectText:(t,n=1)=>0!==t.length&&(e.applyState(function(e,t,n=1){const o=py(e.document,t)[Math.max(1,n)-1];return o?Sa(e,{anchor:o.anchor,focus:o.focus}):e}(e.state(),t,n)),e.focusInput(),!0),selectRange:(t,n)=>(e.applyState(function(e,t,n){return Sa(e,{anchor:t,focus:n})}(e.state(),t,n)),e.focusInput(),!0),insertFootnote:()=>(e.commandsController.applyInsertFootnoteCommand(),!0),setNoteOptions:t=>{e.applyTransactionalState(e=>function(e,t){const n=t.kind,o={...("endnote"===n?e.document.endnotes?.settings:e.document.footnotes?.settings)??{}};let r=!1;if(void 0!==t.numberFormat){const e=null===t.numberFormat?void 0:t.numberFormat;o.numberFormat!==e&&(o.numberFormat=e,r=!0)}if(void 0!==t.startAt){const e=null===t.startAt?void 0:Math.max(1,Math.round(t.startAt));o.startAt!==e&&(o.startAt=e,r=!0)}if(void 0!==t.restart){const e=null===t.restart?void 0:t.restart;o.restart!==e&&(o.restart=e,r=!0)}if(!r)return e;const a=Object.keys(o).length>0?{...o}:void 0;if("endnote"===n){const t=e.document.endnotes??{items:{}};return{...e,document:{...e.document,endnotes:{...t,settings:a}}}}const i=e.document.footnotes??{items:{}};return{...e,document:{...e.document,footnotes:{...i,settings:a}}}}(e,{kind:t.kind,...void 0!==t.numberFormat?{numberFormat:null===t.numberFormat?null:t.numberFormat}:{},...void 0!==t.startAt?{startAt:t.startAt}:{},...void 0!==t.restart?{restart:null===t.restart?null:t.restart}:{}})),e.focusInput()},getNoteOptions:t=>function(e,t){return"endnote"===t?{...e.document.endnotes?.settings??{}}:{...e.document.footnotes?.settings??{}}}(e.state(),t),insertText:(t,n)=>{if(0===t.length)return!1;const o=n?{fontFamily:n}:void 0;return e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>Fa(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){const n=vr(e.selection)?e:_e(e),{paragraph:o,index:r,offset:a}=E(n),i=Nt(o,a),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},s=Y(o,a,[l]),c=ao(n).map((e,t)=>t===r?s:e);return da(n,c,nt(ua(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=ao(e).map(e=>{let r=!1;const a=e.runs.map(e=>e.id!==t||"math"!==e.kind?e:(o=!0,r=!0,{...e,math:n,text:""}));return r?{...e,runs:a}:e});return o?da(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=Co(e.document)[Kn(e)];return!!t&&null!==Px(t.blocks)}(e.state()),hasRevisionsInSelection:()=>kv(e.state()).size>0,hasRevisionsInDocument:()=>Rv(e.state()),hasNavigableRevisions:()=>gx(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),mx(t).map(e=>e.id)).length>0;var t},canCreateComment:e.commentComposer.canCreate,canReplyToComment:e.commentComposer.canReply,newComment:e.commentComposer.openNew,replyComment:e.commentComposer.openReply,editComment:e.commentComposer.openEdit,toggleCommentsPanel:e.commentComposer.togglePanel,isCommentsPanelOpen:e.commentComposer.panelOpen,canEditComment:e.commentComposer.canEdit,navigateRevisionNext:()=>{const t=e.state(),n=fx(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=fx(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=hx(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=hx(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==bx(e.state()),isSelectedCommentResolved:()=>Boolean(bx(e.state())?.resolved),canManageSelectedComment:e.commentComposer.canResolveSelected,resolveSelectedComment:()=>e.commentComposer.resolveSelected(!0),reopenSelectedComment:()=>e.commentComposer.resolveSelected(!1),deleteSelectedComment:e.commentComposer.deleteSelected,canDeleteSelectedComment:e.commentComposer.canDeleteSelected,insertTableOfContents:()=>(e.applyTransactionalState(e=>Tx(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=Kn(e),r=Co(e.document)[o];if(!r)return e;const a=Px(r.blocks);if(!a)return e;const i=vx(e,n).map(e=>Sx(e,t(e.id),Ix(r)));return Cx(e,o,[...r.blocks.slice(0,a.startBlockIndex+1),...i,...r.blocks.slice(a.endBlockIndex)],i[0]??r.blocks[a.startBlockIndex])}(e,n(e))),e.focusInput(),!0),pastePlainText:()=>(e.forcePlainTextPaste.set(!0),e.focusInput(),!0),bold:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("bold"),!0),italic:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("italic"),!0),underline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("underline"),!0),doubleUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"double"===e.styleController.toolbarStyleState().underlineStyle?null:"double"),!0),wordUnderline:()=>(e.styleController.applyToolbarUnderlineStyleCommand(e.styleController.toolbarStyleState().underline&&"words"===e.styleController.toolbarStyleState().underlineStyle?null:"words"),!0),strike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("strike"),!0),doubleStrike:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("doubleStrike"),!0),smallCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("smallCaps"),!0),allCaps:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("allCaps"),!0),hidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("hidden"),!0),noProof:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("noProof"),!0),webHidden:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("webHidden"),!0),specVanish:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("specVanish"),!0),contextualAlternates:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("contextualAlternates"),!0),toggleCharacterBorder:()=>(e.keyboardCommandsController.applyToggleCharacterBorderCommand(),!0),shadow:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("shadow"),!0),emboss:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("emboss"),!0),engrave:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("imprint"),!0),outline:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("outline"),!0),superscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("superscript"),!0),subscript:()=>(e.keyboardCommandsController.applyBooleanStyleCommand("subscript"),!0),alignLeft:()=>(e.commandsController.applyParagraphStyleCommand("align","left"),!0),alignCenter:()=>(e.commandsController.applyParagraphStyleCommand("align","center"),!0),alignRight:()=>(e.commandsController.applyParagraphStyleCommand("align","right"),!0),alignJustify:()=>(e.commandsController.applyParagraphStyleCommand("align","justify"),!0),orderedList:()=>(e.commandsController.applyParagraphListCommand("ordered"),!0),bulletList:()=>(e.commandsController.applyParagraphListCommand("bullet"),!0),find:()=>(e.findReplace.setIsOpen(!0),!0),replace:()=>(e.findReplace.setIsOpen(!0),!0),replaceAll:t=>(e.isReadOnly()||(e.applyTransactionalState(e=>gy(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:Oi}),e.focusInput()),!0),isTrackChangesEnabled:()=>Boolean(e.state().trackChangesEnabled),areMarginsVisible:()=>Boolean(e.state().showMargins),areParagraphMarksVisible:()=>Boolean(e.state().showParagraphMarks),toggleTrackChanges:()=>(e.commandsController.applyToggleTrackChangesCommand(),!0),acceptRevisions:()=>(e.commandsController.applyAcceptRevisionsCommand(),!0),rejectRevisions:()=>(e.commandsController.applyRejectRevisionsCommand(),!0),acceptAllRevisions:()=>(e.commandsController.applyAcceptAllRevisionsCommand(),!0),rejectAllRevisions:()=>(e.commandsController.applyRejectAllRevisionsCommand(),!0),toggleShowMargins:()=>(e.commandsController.applyToggleShowMarginsCommand(),!0),toggleShowParagraphMarks:()=>(e.commandsController.applyToggleShowParagraphMarksCommand(),!0),togglePreciseFonts:()=>(Ot(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>M(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Fa(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Aa(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>yo(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return Fa(e,ix[t])}(e,t))),e.focusInput(),!0),setFontFamily:t=>(e.styleController.applyToolbarValueStyleCommand("fontFamily",t),!0),setFontSize:t=>(e.styleController.applyToolbarValueStyleCommand("fontSize",t),!0),increaseFontSize:()=>t("increase"),decreaseFontSize:()=>t("decrease"),growFont1:()=>(e.applyTransactionalState(e=>$a(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>$a(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>vr(e.state().selection)?(e.styleController.clearPendingCaretTextStyle(),e.focusInput(),!0):(e.commandsController.applyClearFormattingCommand(),!0),setColor:t=>(e.styleController.applyToolbarValueStyleCommand("color",t),!0),setHighlight:t=>(e.styleController.applyToolbarValueStyleCommand("highlight",t),!0),setTextShading:t=>(e.styleController.applyToolbarValueStyleCommand("shading",t),!0),setStyleId:t=>(e.commandsController.handleStyleChange(t),!0),setCharacterStyleId:t=>(e.styleController.applyToolbarValueStyleCommand("styleId",t||null),!0),applyUnderlineStyle:e.styleController.applyToolbarUnderlineStyleCommand,setUnderlineStyle:t=>e.styleController.applyToolbarValueStyleCommand("underlineStyle",t),setUnderlineColor:t=>(e.styleController.applyToolbarValueStyleCommand("underlineColor",t),!0),setCharacterScale:t=>(e.styleController.applyToolbarValueStyleCommand("characterScale",t),!0),setCharacterSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("characterSpacing",t),!0),setRunSnapToGrid:t=>(e.styleController.applyToolbarValueStyleCommand("snapToGrid",t),!0),setFitText:t=>(e.styleController.applyToolbarValueStyleCommand("fitText",t),!0),setBaselineShift:t=>(e.styleController.applyToolbarValueStyleCommand("baselineShift",t),!0),setEmphasisMark:t=>(e.styleController.applyToolbarValueStyleCommand("emphasisMark",t),!0),setTextEffect:t=>(e.styleController.applyToolbarValueStyleCommand("textEffect",t),!0),setKerning:t=>(e.styleController.applyToolbarValueStyleCommand("kerningThreshold",t),!0),setLigatures:t=>(e.styleController.applyToolbarValueStyleCommand("ligatures",t||null),!0),setNumberSpacing:t=>(e.styleController.applyToolbarValueStyleCommand("numberSpacing",t||null),!0),setNumberForm:t=>(e.styleController.applyToolbarValueStyleCommand("numberForm",t||null),!0),setStylisticSet:t=>(e.styleController.applyToolbarValueStyleCommand("stylisticSet",t),!0)}}function Rx(e,t){const n=yb(e),r=n&&Qe(n.run);if(!n||!r)return e;const{paragraphIndex:a,run:i}=n,l=ao(e).map((e,n)=>n!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id===i.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:o(e))});return da(e,l,we(l,Bn(e)))}function Bx(e,t){return{...e??{type:"floating",allowOverlap:!0,positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none"===e?.wrap?e.wrap:e?.wrap??"square",behindDoc:e?.behindDoc,positionH:{relativeFrom:"margin",align:t,offset:0}}}function Mx(e,t,n){const o={...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating"},r=o.positionH??{},a=o.positionV??{};return{...o,wrap:"none"===o.wrap?o.wrap:o.wrap??"square",positionH:{...r,offset:(r.offset??0)+Math.round(t*Ko),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*Ko)}}}function Fx(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:a,run:i}=n,l=ao(e).map((e,t)=>t!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,rotation:r}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:r}}:o(e))});return da(e,l,we(l,Bn(e)))}function Ax(e,t,n=90){return Ox(e,e=>{const o="right"===t?-n:n,r=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}((e.rotation??0)+o);return{...e,rotation:r}})}function Ox(e,t){const n=yb(e);if(!n||!Qe(n.run))return e;const{paragraphIndex:r,run:a}=n,i=ao(e).map((e,n)=>n!==r?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:o(e))});return da(e,i,we(i,Bn(e)))}function Dx(e,t){return Ox(e,e=>({...e,body:t(e.body??{})}))}function Ex(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of Vr(t)){e.style?.styleId&&o.add(e.style.styleId);for(const t of e.runs)t.styles?.styleId&&o.add(t.styles.styleId)}return Object.values(n).map(e=>{const t=oe(e.id,n),r="table"===e.type?En(e.id,n).tableStyle:void 0,a=r?.conditionalFormats?.wholeTable,i=r?.conditionalFormats?.firstRow,l=r?.conditionalFormats?.band1Horz,s=a?.borders?.borderBottom??r?.borders?.borderBottom;return{id:e.id,name:e.name,type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:t.fontFamily?.trim()||void 0,fontSize:"number"==typeof t.fontSize?t.fontSize:void 0,color:t.color??void 0,bold:t.bold??void 0,italic:t.italic??void 0,tablePreview:r?{wholeFill:a?.shading,headerFill:i?.shading,bandFill:l?.shading,borderColor:s?.color,headerColor:i?.textStyle?.color??void 0}:void 0}})},newDocument:()=>e.newDocument(),openSymbolDialog:()=>e.openSymbolDialog(),openEquationDialog:()=>e.openEquationDialog(),hasActiveTable:()=>zs(e.state()),openTableProperties:t=>e.openTablePropertiesDialog(t??"table"),exportDocx:()=>{e.docIO.handleExportDocx()},exportPdf:()=>{e.docIO.handleExportPdf()},printDocument:()=>{e.docIO.handlePrint()},importDocument:()=>e.importInputRef()?.click(),insertImage:()=>e.imageInputRef()?.click(),insertHtml:t=>e.applyTransactionalState(e=>function(e,t){if(!t.trim())return e;const n=Z(t),o=a(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return Pa(e,o.map(e=>({runs:e.runs.map(e=>({text:e.text,styles:e.styles,..."image"===e.kind?{image:e.image}:{}})),style:e.style,list:e.list})));const r=vr(e.selection)?e:_e(e),{paragraph:i,offset:l}=E(r),s=U(i,0,l),c=U(i,l,Se(i)),d=Or(""),u={...i,runs:s.length?s:Or("").runs},p={...i,id:d.id,runs:c.length?c:d.runs},g=[...l>0?[u]:[],...o,...c.length||"table"===o[o.length-1]?.type?[p]:[]];let f=!1;const m=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===i.id)return f=!0,t=!0,g;if("table"!==e.type)return[e];let n=!1;const o=e.rows.map(e=>{let t=!1;const o=e.cells.map(e=>{const n=m(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:o}):e});return n?(t=!0,[{...e,rows:o}]):[e]});return t?n:e},h=r.activeZone??"main";let b=r.document;if("footnote"===h&&r.activeFootnoteId&&r.document.footnotes?.items[r.activeFootnoteId]){const e=r.document.footnotes,t=e.items[r.activeFootnoteId],n=m(t.blocks);f&&(b={...r.document,footnotes:{...e,items:{...e.items,[r.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=a(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const i="header"===h?"header":"footer"===h?"footer":"blocks",l=m(o[i]??[]);if(f){const e=[...t];e[n]={...o,[i]:l},b={...r.document,sections:e}}}if(!f)return e;const y=o[o.length-1],v="paragraph"!==y.type||c.length?ua(p,0):ua(y,Se(y));return{...r,document:b,selection:nt(v)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=vr(e.selection)?e:_e(e),{paragraph:o,index:r,offset:a}=E(n),i=function(e){switch(e.document.design?.effectsId){case"flat":return{fill:"#e2e8f0",border:"#64748b"};case"intense":return{fill:"#0f766e",border:"#115e59"};case"moderate":return{fill:"#5b9bd5",border:"#2f75b5"};default:return{fill:"#4472C4",border:"#2F528F"}}}(n),l={width:150,height:100,blocks:[Or("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:Dh(void 0,"front")},s=rr("",Nt(o,a),void 0,l),c=Y(o,a,[s]),d=ao(n).map((e,t)=>t===r?c:Gt(e));return da(n,d,nt(ua(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:bl}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Rx(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:yl}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:vl}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=ao(e).map((e,n)=>n!==r?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id!==a.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:Bx(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Bx(e.textBox.floating,t)}}:o(e))});return da(e,i,we(i,Bn(e)))}(e,t),{mergeKey:xl}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=e=>({...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none",behindDoc:"back"===t}),l=ao(e).map((e,t)=>t!==r?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id!==a.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:i(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:i(e.textBox.floating)}}:o(e))});return da(e,l,we(l,Bn(e)))}(e,t),{mergeKey:wl}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const r=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!r)return e;const{paragraphIndex:a,run:i}=r,l=ao(e).map((e,r)=>r!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:Mx(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Mx(e.textBox.floating,t,n)}}:o(e))});return da(e,l,we(l,Bn(e)))}(e,t,n),{mergeKey:Sl}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:r,run:a}=n,i=ao(e).map((e,n)=>n!==r?Gt(e):{...Gt(e),runs:e.runs.map(e=>{if(e.id!==a.id)return o(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?Lh(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?Lh(n,t):n}}}return o(e)})});return da(e,i,we(i,Bn(e)))}(e,t),{mergeKey:Il}),setFloatingRotation:t=>e.applyTransactionalState(e=>Fx(e,t),{mergeKey:Cl}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>Dh(e,t),{paragraphIndex:a,run:i}=n,l=ao(e).map((e,t)=>t!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>{if(e.id!==i.id)return o(e);if("image"===e.kind){const t=r(e.image.floating),n=t?{...e.image,floating:t}:(()=>{const{floating:t,...n}=e.image;return n})();return{...e,image:n}}if("textBox"===e.kind){const t=r(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return o(e)})});return da(e,l,we(l,Bn(e)))}(e,t),{mergeKey:Tl}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const r=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:a,run:i}=n,l=ao(e).map((e,t)=>t!==a?Gt(e):{...Gt(e),runs:e.runs.map(e=>e.id!==i.id?o(e):"image"===e.kind?{...e,image:{...e.image,floating:r(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:r(e.textBox.floating)}}:o(e))});return da(e,l,we(l,Bn(e)))}(e,t),{mergeKey:Pl}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=Oh(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:r,v:a}=function(e){return{h:e.endsWith("Left")?"left":e.endsWith("Right")?"right":"center",v:e.startsWith("top")?"top":e.startsWith("bottom")?"bottom":"ctr"}}(t),i={relativeFrom:"margin",align:r,offset:0},l={relativeFrom:"margin",align:a,offset:0},{paragraphIndex:s,run:c}=n,d=ao(e).map((e,t)=>t!==s?Gt(e):{...Gt(e),runs:e.runs.map(e=>{if(e.id!==c.id)return o(e);if("image"===e.kind){const t={...e.image.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.image.floating?.wrap?e.image.floating.wrap:e.image.floating?.wrap??"square",behindDoc:e.image.floating?.behindDoc,positionH:i,positionV:l};return{...e,image:{...e.image,floating:t}}}if("textBox"===e.kind){const t={...e.textBox.floating??{type:"floating",allowOverlap:!0},type:"floating",wrap:"none"===e.textBox.floating?.wrap?e.textBox.floating.wrap:e.textBox.floating?.wrap??"square",behindDoc:e.textBox.floating?.behindDoc,positionH:i,positionV:l};return{...e,textBox:{...e.textBox,floating:t}}}return o(e)})});return da(e,d,we(d,Bn(e)))}(e,t),{mergeKey:kl}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Rx(e,e=>({...e,preset:t}))}(e,t),{mergeKey:Rl}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Dx(e,e=>({...e,vert:n}))}(e,t),{mergeKey:Bl}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Dx(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:Ml}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return Ox(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:Fl}),rotateTextBox:t=>e.applyTransactionalState(e=>Ax(e,t),{mergeKey:Al}),getTextBoxSizeCm:()=>function(e){const t=yb(e),n=t&&Qe(t.run);return n?{width:n.width/mo,height:n.height/mo}:null}(e.state()),isTextBoxSelected:()=>null!==yb(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return Ox(e,e=>({...e,width:Math.max(24,Math.round(t*mo))}))}(e,t),{mergeKey:Ol}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return Ox(e,e=>({...e,height:Math.max(24,Math.round(t*mo))}))}(e,t),{mergeKey:Dl})}}function Lx(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!vr(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function Nx(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=$h(e),n=t&&nn(t.run);return n?{width:n.width/mo,height:n.height/mo}:null}(e.state()),setWidthCm:t=>e.commandsController.applyImageWidthCmCommand(t),setHeightCm:t=>e.commandsController.applyImageHeightCmCommand(t),isCropActive:()=>e.imageCropMode.isActive(),toggleCrop:()=>e.imageCropMode.toggle(),applyCropAspect:t=>e.commandsController.applyImageCropAspectCommand(t),getCropShape:()=>function(e){const t=$h(e);return(t&&nn(t.run))?.cropShape??null}(e.state())?.preset??null,applyCropShape:t=>e.commandsController.applyImageCropShapeCommand(t),applyCropFill:()=>e.commandsController.applyImageCropFillCommand(),applyCropFit:()=>e.commandsController.applyImageCropFitCommand(),resetCrop:()=>e.commandsController.resetImageCropCommand(),getBorder:()=>function(e){const t=$h(e);return(t&&nn(t.run))?.border??null}(e.state()),setBorder:t=>e.commandsController.applyImageBorderCommand(t),flip:t=>e.commandsController.flipImageCommand(t),rotate:t=>e.commandsController.rotateImageCommand(t),getTransparency:()=>function(e){const t=$h(e),n=t&&nn(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==$h(e.state())}}function $x(e){const t=e.clipboardActions??Ja({state:e.state,isReadOnly:e.isReadOnly,applyTransactionalState:e.applyTransactionalState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInput:e.focusInput});return{canCut:()=>!0,canPaste:()=>!0,hasSelection:t.hasSelection,copy:()=>{t.copy()},cut:()=>{t.cut()},paste:()=>{t.paste("rich")},pasteAsPlainText:()=>{t.paste("text")},pasteMergeFormatting:()=>{t.paste("merge")}}}function zx(e,t){const n=tr(e),o=Co(e.document);if("header"===n||"footer"===n){const r=Kn(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=Nr(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=Kn(e),r=o[n];if(!r)return e;const a=[...o];return a[n]={...r,blocks:t},{...e,document:{...e.document,sections:a}}}return e}function Hx(e,t){return null!==Ux(e,t)}function Wx(e,t){const n=Ux(e,t);if(!n)return e;const{nextBlocks:o}=n,r=zx(e,o),a=o.flatMap(We);return{...r,selection:jx(e.selection,a)}}function Ux(e,t){const n=tr(e);if("footnote"===n)return null;const o=Lo(e,n);if(0===o.length)return null;const r=Bn(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let l=n;l<=o;l+=1){const e=t[l];if(void 0===e)return null;r.add(e)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==e[l].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{We(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:l}=a,s=o.slice(i,l+1);let c;if("up"===t){if(0===i)return null;const e=o[i-1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i-1),...s,e,...o.slice(l+1)]}else{if(l===o.length-1)return null;const e=o[l+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...s,...o.slice(l+2)]}return{nextBlocks:c}}function jx(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return ua(r,Math.min(e.offset,Se(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Vx(e,t){const n=function(e){const t=tr(e);if("footnote"===t)return null;const n=Lo(e,t);if(0===n.length)return null;const o=Bn(e),r=/* @__PURE__ */new Set;for(let l=o.startIndex;l<=o.endIndex;l+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=We(n[o]).length;if(l<e+r){t=o;break}e+=r}if(t<0)return null;r.add(t)}if(0===r.size)return null;const a=Math.min(...r),i=Math.max(...r);for(let l=a;l<=i;l+=1)if("paragraph"!==n[l].type)return null;return{blocks:n,lo:a,hi:i}}(e);if(!n)return e;if(n.hi-n.lo<1)return e;const{lo:o,hi:r,blocks:a}=n,i=a.slice(o,r+1).map((e,t)=>({block:e,index:t,key:Kx(ot(e))}));i.sort((e,n)=>{const o=function(e,t){const n=function(e,t){return void 0!==e&&void 0!==t?e===t?0:e<t?-1:1:void 0!==e?-1:void 0!==t?1:0}(e.num,t.num);return 0!==n?n:e.text.localeCompare(t.text,void 0,{sensitivity:"base"})}(e.key,n.key);return 0!==o?t?-o:o:e.index-n.index});const l=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],s=zx(e,l),c=l.flatMap(We);return{...s,selection:_x(e.selection,c)}}function Kx(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function _x(e,t){const n=new Map(t.map((e,t)=>[e.id,t])),o=e=>{const o=n.get(e.paragraphId);if(void 0===o)return e;const r=t[o];return ua(r,Math.min(e.offset,Se(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Xx(e,t){const n=Bn(e),o=ao(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=Qn(o[l]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return Gt(e);const i=Qn(e.style?.styleId);if(e.list&&e.list.kind){const n=e.list.level??0,o=t?Math.max(0,n-1):Math.min(8,n+1);return o===n?Gt(e):(a=!0,ce(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return Gt(e);a=!0;const o=Gt(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return Gt(e);a=!0;const l=Gt(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?da(e,i,we(i,n)):e}var Gx=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function Yx(e,t){return Math.abs(e-t)<1e-6}function qx(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var Zx=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var Jx=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var Qx={width:1.5,type:"solid",color:"#000000"};function ew(e,t){const n=t.text??ot(e).slice(0,1),o=Math.max(1,Math.min(10,Math.round(t.lines??3))),r=e.runs[0]?.styles,a=t.font;return{text:n,lines:o,type:"margin"===t.type?"margin":"drop",style:void 0!==a?{...r??{},fontFamily:a}:r}}function tw(e){return{togglePageBreakBefore:()=>e.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),toggleKeepWithNext:()=>e.commandsController.toggleParagraphFlagCommand("keepWithNext"),toggleKeepLinesTogether:()=>e.commandsController.toggleParagraphFlagCommand("keepLinesTogether"),toggleWidowControl:()=>e.commandsController.toggleParagraphFlagCommand("widowControl"),setSpacingAfter:t=>e.commandsController.applyParagraphStyleCommand("spacingAfter",t),setSpacingBefore:t=>e.commandsController.applyParagraphStyleCommand("spacingBefore",t),setLineRule:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.lineRule,i=(()=>{if(null!==t&&"auto"!==t)return Zx.has(t)?t:a})();if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.textDirection,i=null===t||"lrTb"===t?void 0:Jx.has(t)?t:a;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressAutoHyphens,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.suppressLineNumbers,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.kinsoku,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.overflowPunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.wordWrap,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDE,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.autoSpaceDN,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.adjustRightInd,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.topLinePunct,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.pageBreakBefore,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepWithNext,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.keepLinesTogether,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.widowControl,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.contextualSpacing,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e);let r=!1;const a=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;const a=e.style?.mirrorIndents,i=null===t?void 0:t;if(a===i)return e;r=!0;const l=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...Gt(e),style:l}});return r?da(e,a,we(a,n)):e}(e,t)),setIndentLeft:t=>e.commandsController.applyParagraphStyleCommand("indentLeft",t),setIndentRight:t=>e.commandsController.applyParagraphStyleCommand("indentRight",t),setIndentFirstLine:t=>e.commandsController.applyParagraphStyleCommand("indentFirstLine",t),setIndentHanging:t=>e.commandsController.applyParagraphStyleCommand("indentHanging",t),setSpecialIndent:(t,n)=>{const o=n??48;e.applyTransactionalState(e=>{let n=r(e,"indentFirstLine",null);return n=r(n,"indentHanging",null),"firstLine"===t?n=r(n,"indentFirstLine",o):"hanging"===t&&(n=r(n,"indentHanging",o)),n},{mergeKey:Ri}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=r(e,"borderTop",t);return n=r(n,"borderRight",t),n=r(n,"borderBottom",t),n=r(n,"borderLeft",t),n},{mergeKey:Bi}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>r(e,"borderBottom",Qx),{mergeKey:Bi}),e.focusInput()},setLineHeight:t=>e.commandsController.applyParagraphStyleCommand("lineHeight",t),setListFormat:t=>e.commandsController.handleListFormatChange(t),setListStartAt:t=>e.commandsController.handleListStartAtChange(t),setListLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=Math.min(8,Math.max(0,Math.round(t))),r=ao(e);let a=!1;const i=r.map((e,t)=>t<n.startIndex||t>n.endIndex?e:e.list?(e.list.level??0)===o?e:(a=!0,ce(e,o)):e);return a?da(e,i,we(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Hx(e.state(),"up")?(e.applyTransactionalState(e=>Wx(e,"up"),{mergeKey:Mi}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Hx(e.state(),"down")?(e.applyTransactionalState(e=>Wx(e,"down"),{mergeKey:Fi}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Hx(e.state(),"up"),canMoveParagraphsDown:()=>Hx(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>Xx(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>Xx(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=Bn(e),n=ao(e);let o=!1;const r=n.map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return e;const r=e.style;if(!r||Gx.every(e=>!(e in r)))return e;o=!0;const a=Gt(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?da(e,r,we(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e),r=e.document.styles,a=t.set??[],i=t.clear??[],l=Boolean(t.clearAll),s=void 0!==t.tabs||a.length>0||i.length>0||l;let c=!1;const d=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return e;if(!s)return e;const d=L(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!Yx(e.position,t));return d.some(e=>Yx(e.position,t))&&n.push({position:t,type:"clear"}),n};let p=[...void 0!==t.tabs?(t.tabs??[]).map(e=>({...e})):(e.style?.tabs??[]).map(e=>({...e}))];if(l){p=[];for(const e of d)p=u(p,e.position)}for(const t of i)p=u(p,t);for(const t of a)p=p.filter(e=>!Yx(e.position,t.position)),p.push(qx(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=Gt(e);return g.style={...e.style??{},tabs:p.length>0?p:null},c=!0,g});let u=c;const p=void 0!==t.default&&null!==t.default,g=e.document.settings?.defaultTabStop,f=p&&void 0!==t.default&&null!==t.default?Math.min(1584,Math.max(1,t.default)):void 0;if((p||null===t.default)&&(null===t.default?void 0!==g:void 0!==t.default&&g!==f)&&(u=!0),!u)return e;let m=da(e,d,we(d,n));if(p||null===t.default){const n={...e.document.settings??{}};null===t.default?delete n.defaultTabStop:void 0!==t.default&&(n.defaultTabStop=f),m={...m,document:{...m.document,settings:n}}}return m}(e,t),{mergeKey:Ei}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e),r=null==t?null:Math.min(8,Math.max(0,Math.round(t)));let a=!1;const i=o.map((e,t)=>{if(t<n.startIndex||t>n.endIndex)return e;if((e.style?.outlineLevel??null)===r)return e;a=!0;const o={...e.style??{}};null===r?delete o.outlineLevel:o.outlineLevel=r;const i=Gt(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?da(e,i,we(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return r(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>Vx(e,t)),hasDropCap:()=>function(e){const t=Bn(e);return ao(e).slice(t.startIndex,t.endIndex+1).some(e=>void 0!==e.dropCap)}(e.state()),setDropCap:t=>{e.applyTransactionalState(e=>function(e,t){const n=Bn(e),o=ao(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,l=o.map((e,n)=>n<r||n>a?Gt(e):i?{...Gt(e),dropCap:void 0}:{...Gt(e),dropCap:ew(e,{...t,type:"margin"===t.type?"margin":"drop"})});return da(e,l,we(l,n))}(e,t)),e.focusInput()}}}function nw(e){const t=Co(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Kn(e),t.length-1))}}function ow(e,t){const{sections:n,sectionIndex:o}=nw(e);if(0===n.length)return e;const r=t(n[o]);if(r===n[o])return e;const a=[...n];return a[o]=r,{...e,document:{...e.document,sections:a}}}function rw(e,t,n="default"){const o=cn(t,n);return ow(e,e=>e[o]?e:{...e,[o]:[Hr(t)]})}function aw(e,t,n="default"){const o=cn(t,n),r=ow(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:tr(r)===t?cw(r):r}function iw(e,t,n="default"){const o=rw(e,t,n),{sections:r,sectionIndex:a}=nw(o),i=(r[a][cn(t,n)]??[]).flatMap(We).find(Boolean);return i?{...o,selection:hn(ua(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function lw(e){const{sections:t,sectionIndex:n}=nw(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function sw(e){const{sections:t,sectionIndex:n}=nw(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function cw(e){const{sections:t,sectionIndex:n}=nw(e),o=(t[n]?.blocks??[]).flatMap(We).find(Boolean);return o?{...e,selection:hn(ua(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function dw(e){return function(e,t){const n=vr(e.selection)?e:_e(e),{paragraph:o,index:r,offset:a}=E(n),i=U(o,0,a),l=U(o,a,Se(o)),s={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:Nt(o,a)},c=me(o,[...i,s,...l]),d=ao(n),u=[...tt(d.slice(0,r)),c,...tt(d.slice(r+1))];return da(n,u,nt(ua(c,a+s.text.length)))}(e,"PAGE")}function uw(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function pw(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},uw("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},uw("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[uw("PAGE",void 0,`run:page-field:${n}`,t)]}function gw(e,t="page",n){return function(e,t){const n=vr(e.selection)?e:_e(e),{paragraph:o,index:r,offset:a}=E(n),i=Nt(o,a),l=t.map((e,t)=>e.styles?e:{...e,styles:i,id:`${e.id}:${t}`}),s=me(o,[...U(o,0,a),...l,...U(o,a,Se(o))]),c=ao(n),d=[...tt(c.slice(0,r)),s,...tt(c.slice(r+1))],u=l.reduce((e,t)=>e+t.text.length,0);return da(n,d,nt(ua(s,a+u)))}(e,pw(t,n))}function fw(e){const t=Co(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(Kn(e),t.length-1))}}function mw(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return gw(e,o,r);const i="top"===t?"header":"footer",l=cn(i,"default"),{sections:s,sectionIndex:c}=fw(e);if(0===s.length)return e;const d={id:Ao("paragraph"),type:"paragraph",runs:pw(o,r),style:{styleId:i,align:a}},u={...s[c],[l]:[d]},p=[...s];return p[c]=u,{...e,document:{...e.document,sections:p},selection:hn(ua(d,0)),activeSectionIndex:c,activeZone:i}}function hw(e){const t={isLandscape:()=>{const t=Kn(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=Kn(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=Kn(e.state()),o=e.state().document.sections?.[n]??e.state().document;if(!o)return;const r=o.pageSettings?.orientation??"portrait";t.setOrientation("portrait"===r?"landscape":"portrait")},breakNextPage:()=>e.commandsController.applyInsertSectionBreakCommand("nextPage"),breakContinuous:()=>e.commandsController.applyInsertSectionBreakCommand("continuous"),breakEvenPage:()=>e.commandsController.applyInsertSectionBreakCommand("evenPage"),breakOddPage:()=>e.commandsController.applyInsertSectionBreakCommand("oddPage"),breakNextColumn:()=>e.commandsController.applyInsertSectionBreakCommand("nextColumn"),getMargins:()=>{const t=Kn(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=Kn(e.state()),o=e.state().document.sections?.[n]??e.state().document;o?.pageSettings&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,margins:{...o.pageSettings.margins,...t}}})},setMarginsPreset:t=>{e.applyTransactionalState(e=>ct(e,t)),e.focusInput()},getPageNumbering:()=>{const t=Kn(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=fw(e);if(0===n.length)return e;const r={...n[o].pageNumbering,...void 0!==t.start?{start:t.start}:{},...void 0!==t.format?{format:t.format}:{}};return Re(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>Zn(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>b(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>jr(e,t)),e.focusInput()},getColumns:()=>ro(e.state()),setColumns:t=>{e.applyTransactionalState(e=>qr(e,t)),e.focusInput()},getVerticalAlign:()=>oa(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>ht(e,t)),e.focusInput()},getSectionStart:()=>{const t=Kn(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=Kn(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>Lr(e.state()),setBidi:t=>{e.applyTransactionalState(e=>wn(e,t)),e.focusInput()},getHyphenation:()=>function(e){const t=e.document.settings;return{value:!0===t?.autoHyphenation,zone:t?.hyphenationZone,caps:t?.doNotHyphenateCaps,limit:t?.consecutiveHyphenLimit}}(e.state()),setHyphenation:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.settings,o={...n??{},...void 0!==t.value?{autoHyphenation:t.value}:void 0!==n?.autoHyphenation?{autoHyphenation:n.autoHyphenation}:{},...void 0!==t.zone?{hyphenationZone:t.zone}:void 0!==n?.hyphenationZone?{hyphenationZone:n.hyphenationZone}:{},...void 0!==t.caps?{doNotHyphenateCaps:t.caps}:void 0!==n?.doNotHyphenateCaps?{doNotHyphenateCaps:n.doNotHyphenateCaps}:{},...void 0!==t.limit?{consecutiveHyphenLimit:t.limit}:void 0!==n?.consecutiveHyphenLimit?{consecutiveHyphenLimit:n.consecutiveHyphenLimit}:{}};return{...e,document:{...e.document,settings:o}}}(e,t)),e.focusInput()}};return t}function bw(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>iw(e,"header")),editFooter:()=>t(e=>iw(e,"footer")),editFirstPageHeader:()=>t(e=>iw(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>iw(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>iw(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>iw(e,"footer","evenPage")),insertPageNumber:()=>t(e=>dw(e)),insertPageNumberXOfY:()=>t(e=>gw(e,"xOfY")),placePageNumberTop:()=>t(e=>mw(e,"top")),placePageNumberBottom:()=>t(e=>mw(e,"bottom")),exit:()=>t(e=>function(e){return cw(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>lw(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(lw(e)===t)return e;let n=e;return t?(n=rw(n,"header","firstPage"),n=rw(n,"footer","firstPage"),n):(n=aw(n,"header","firstPage"),aw(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>sw(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(sw(e)===t)return e;let n=e;return t?(n=rw(n,"header","evenPage"),n=rw(n,"footer","evenPage"),n):(n=aw(n,"header","evenPage"),aw(n,"footer","evenPage"))}(t,e))}}function yw(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function vw(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=Bn(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:wr(),name:l,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[s.id]:s},order:[...i,s.id]},d={...e.document,bookmarks:c};return{...e,document:d}}(e,t)),e.focusInput()},remove:t=>{e.applyTransactionalState(e=>function(e,t){const n=e.document.bookmarks;if(!n||!n.items[t])return e;const o={...n.items};delete o[t];const r={items:o,order:n.order.filter(e=>e!==t)};return{...e,document:{...e.document,bookmarks:r}}}(e,t)),e.focusInput()},list:()=>yw(e.state()).map(e=>({id:e.id,name:e.name}))}}var xw=["January","February","March","April","May","June","July","August","September","October","November","December"],ww=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Sw(e,t){let n="";const o=e=>String(e).padStart(2,"0");let r=0;const a=t;for(;r<a.length;){const t=a[r];let i=t;for(;r+i.length<a.length&&a[r+i.length]===t;)i+=t;const l=e.getHours();switch(t){case"d":n+=i.length>=4?ww[e.getDay()]:3===i.length?ww[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?xw[e.getMonth()]:3===i.length?xw[e.getMonth()].slice(0,3):2===i.length?o(e.getMonth()+1):String(e.getMonth()+1);break;case"y":n+=i.length>=3?String(e.getFullYear()):String(e.getFullYear()).slice(-2);break;case"H":n+=o(l);break;case"h":n+=i.length>=2?o(l%12==0?12:l%12):String(l%12==0?12:l%12);break;case"m":n+=i.length>=2?o(e.getMinutes()):String(e.getMinutes());break;case"s":n+=i.length>=2?o(e.getSeconds()):String(e.getSeconds());break;default:if(a.slice(r).toLowerCase().startsWith("am/pm")){n+=l<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}function Iw(e,t){const n=t.type??"REF";if(!function(e,t){return yw(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=vr(e.selection)?e:_e(e),{paragraph:r,index:a,offset:i}=E(o),l=Nt(r,i),s={type:n,bookmark:t.bookmark},c={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:s,styles:l},d=me(r,[...U(r,0,i),c,...U(r,i,Se(r))]),u=ao(o),p=[...tt(u.slice(0,a)),d,...tt(u.slice(a+1))];return da(o,p,nt(ua(d,i+c.text.length)))}function Cw(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,r=vr(e.selection)?e:_e(e),{paragraph:a,index:i,offset:l}=E(r),s=Nt(a,l),c=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},d={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:Sw(o,n),kind:"field",field:c,styles:s},u=me(a,[...U(a,0,l),d,...U(a,l,Se(a))]),p=ao(r),g=[...tt(p.slice(0,i)),u,...tt(p.slice(i+1))],f=d.text.length;return da(r,g,nt(ua(u,l+f)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=Sw(n,t);return 0===o.length?e:Fa(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>Iw(e,t)),e.focusInput()}}}function Tw(e){let t=!1,n=!1;const o=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},r={firstRow:!1,lastRow:!1,firstCol:!1,lastCol:!1,noHBand:!1,noVBand:!1},a=e=>{const t=Kn(e),n=y(e.document,e.selection.focus.paragraphId,t);if(!n)return null;const o=function(e,t,n){if("footnote"===n){const t=e.activeFootnoteId;return t?e.document.footnotes?.items[t]?.blocks??null:null}const o=Co(e.document)[t];return o?"header"===n?o.header??[]:"footer"===n?o.footer??[]:o.blocks:null}(e,t,n.zone);if(!o)return null;const r=T(o,n.tablePath);return r?.[r.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=Fr(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(y(e.state().document,e.state().selection.focus.paragraphId,Kn(e.state()))),selectionLabel:()=>{const t=e.state();if(Bn(t).isCollapsed)return null;const n=Kn(t),o=y(t.document,t.selection.anchor.paragraphId,n),r=y(t.document,t.selection.focus.paragraphId,n),a=o?.tablePath[o.tablePath.length-1],i=r?.tablePath[r.tablePath.length-1];if(!o||!r||!a||!i||o.zone!==r.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(o.tablePath,r.tablePath)||a.rowIndex===i.rowIndex&&a.cellIndex===i.cellIndex)return null;const l=e.selectionBoxes().length;return 0===l?null:`Table selection: ${l} cell${1===l?"":"s"}`},getTblLook:()=>{const t=i(e.state());return t?{firstRow:t.firstRow,lastRow:t.lastRow,firstCol:t.firstCol,lastCol:t.lastCol,bandedRows:!t.noHBand,bandedCols:!t.noVBand}:null},toggleTblLook:e=>o(t=>{const n=i(t);if(!n)return t;const o={...n};switch(e){case"firstRow":o.firstRow=!n.firstRow;break;case"lastRow":o.lastRow=!n.lastRow;break;case"firstCol":o.firstCol=!n.firstCol;break;case"lastCol":o.lastCol=!n.lastCol;break;case"bandedRows":o.noHBand=!n.noHBand;break;case"bandedCols":o.noVBand=!n.noVBand}return as(t,"tblLook",o)},pl),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>as(t,"styleId",e||null),gl),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>as(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),fl),canSetAutoFit:()=>null!==Ul(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return Ql(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...Ll(),type:"property",previous:{...r??{}}}});let a=Nl(r,"layout",n);return"window"===t?a=Nl(a,"width","100%"):"contents"===t&&(a=Nl(a,"width",null)),{...o,style:a}})}(t,e),ll),distributeColumns:()=>o(e=>Ql(e,e=>{const t=Xt(e),n=Math.max(1,...t.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),o=(e.gridCols??[]).reduce((e,t)=>e+("number"==typeof t&&t>0?t:0),0),r=o>0?o:120*n,a=r/n,i=Array.from({length:n},()=>a),l=e.rows.map((e,n)=>({...e,cells:e.cells.map((e,o)=>{const r=t.find(e=>e.rowIndex===n&&e.cellIndex===o);return r?{...e,style:{...e.style??{},width:a*Math.max(1,r.colSpan)}}:e})}));return{...e,gridCols:i,rows:l,style:{...e.style??{},width:r}}}),fl),distributeRows:()=>o(e=>Ql(e,e=>{let t=0;for(const o of e.rows){const e=o.style?.height,n="number"==typeof e?e:"string"==typeof e?Number.parseFloat(e):0;Number.isFinite(n)&&n>t&&(t=n)}t<=0&&(t=24);const n=e.rows.map(e=>({...e,style:{...e.style??{},height:t,heightRule:"atLeast"}}));return{...e,rows:n}}),fl),canMerge:()=>e.tableOps.canMergeSelectedTable(e.state()),canSplit:()=>e.tableOps.canSplitSelectedTable(e.state()),canEditColumn:()=>e.tableOps.canEditSelectedTableColumn(e.state()),canEditRow:()=>e.tableOps.canEditSelectedTableRow(e.state()),canConvertToText:()=>null!==Ul(e.state()),convertToText:()=>o(e=>ps(e),el),canConvertToTable:()=>{return!Ul(t=e.state())&&null!==ql(t);var t},convertToTable:()=>o(e=>gs(e),tl),canSplitTableAtRow:()=>function(e){const t=Ul(e);if(!t)return!1;const n=Yl(e);if(!n)return!1;const o=Xl(n,t.loc.tablePath);if(!o)return!1;const r=t.loc.rowIndex;return r>0&&r<o.rows.length}(e.state()),splitTableAtRow:()=>o(e=>function(e){const t=Ul(e);if(!t)return e;const n=Yl(e);if(!n)return e;const o=Xl(n,t.loc.tablePath);if(!o)return e;const r=t.loc.rowIndex;if(r<=0||r>=o.rows.length)return e;const a=o.rows.slice(0,r),i=o.rows.slice(r),l={...o,rows:a},s=zo(i),c=Jl(e,[l,Or(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:nt(ua(d,0))}:e}(e),nl),canSortTable:()=>function(e){const t=Ul(e);if(!t)return!1;const n=Yl(e);if(!n)return!1;const o=Xl(n,t.loc.tablePath);return!!o&&function(e){let t=0;for(const n of e)n.isHeader||(t+=1);return t}(o.rows)>=2}(e.state()),sortTable:e=>o(t=>ms(t,e),"ascending"===e?ol:rl),canDeleteTable:()=>null!==Ul(e.state()),deleteTable:()=>o(e=>function(e){const t=Ul(e);if(!t)return e;const n=Yl(e);if(!n)return e;const o=t.loc.tablePath[0]?.tableBlockIndex;if(void 0===o||"table"!==n[o]?.type)return e;if(1===n.length){const t=Or(""),n=Jl(e,[t]);return n===e?e:{...n,selection:nt(ua(t,0))}}const r=function(e,t){for(let n=t+1;n<e.length;n+=1){const t=e[n];if("paragraph"===t?.type)return t.id}for(let n=t-1;n>=0;n-=1){const t=e[n];if("paragraph"===t?.type)return t.id}return null}(n,o),a=Jl(e,[]);if(a===e)return e;if(r){const e=ao(a).find(e=>e.id===r);if(e)return{...a,selection:nt(ua(e,0))}}return a}(e),al),canToggleRepeatHeaderRows:()=>function(e){const t=Ul(e);if(!t)return!1;const n=Yl(e);if(!n)return!1;const o=Xl(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=Ul(e);if(!t)return!1;const n=Yl(e);if(!n)return!1;const o=Xl(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&bs(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=Ul(e);if(!t)return e;const n=Yl(e);if(!n)return e;const o=Xl(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=bs(o.rows[0]);return Ql(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),sl),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),Hi),split:()=>o(t=>e.tableOps.splitSelectedTable(t),Wi),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),Ui),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),Ui),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),ji),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),Vi),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),Vi),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),Ki),canDeleteCell:()=>Fs(e.state()),deleteCell:()=>o(e=>As(e),il),cellShading:e=>o(t=>os(t,"shading",e||null),_i),cellBorders:()=>o(e=>rs(e,{width:1,type:"solid",color:"#64748b"}),Xi),cellNoBorders:()=>o(e=>rs(e,{width:0,type:"none",color:"transparent"}),Xi),applyBorderPreset:e=>o(t=>function(e,t,n=es){const o=ns(e);if(!o)return e;const r=/* @__PURE__ */new Map,a=new Set(o.selectedEntries.map(e=>e.cell.id)),i=/* @__PURE__ */new Map;for(const m of o.entries)for(let e=m.visualRowIndex;e<m.visualRowIndex+m.rowSpan;e+=1)for(let t=m.visualColumnIndex;t<m.visualColumnIndex+m.colSpan;t+=1)i.set(`${e}:${t}`,m);const l=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},s=(e,t,o,r,a=n)=>{l(e,t,a),o&&o.cell.id!==e?.cell.id&&l(o,r,a)},c=(e,t=n)=>{if("top"===e||"bottom"===e){const n="top"===e?o.startRow:o.endRow,r=n+("top"===e?-1:1);for(let l=o.startCol;l<=o.endCol;l+=1){const o=i.get(`${n}:${l}`);o&&a.has(o.cell.id)&&s(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${l}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,l=r+("left"===e?-1:1);for(let n=o.startRow;n<=o.endRow;n+=1){const o=i.get(`${n}:${r}`);o&&a.has(o.cell.id)&&s(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${l}`),"left"===e?"borderRight":"borderLeft",t)}},d=()=>{for(let e=o.startRow+1;e<=o.endRow;e+=1)for(let t=o.startCol;t<=o.endCol;t+=1){const n=i.get(`${e-1}:${t}`),o=i.get(`${e}:${t}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderBottom",o,"borderTop")}},u=()=>{for(let e=o.startCol+1;e<=o.endCol;e+=1)for(let t=o.startRow;t<=o.endRow;t+=1){const n=i.get(`${t}:${e-1}`),o=i.get(`${t}:${e}`);n&&o&&n.cell.id!==o.cell.id&&a.has(n.cell.id)&&a.has(o.cell.id)&&s(n,"borderRight",o,"borderLeft")}};switch(t){case"none":for(const e of o.selectedEntries)for(const t of["borderTop","borderRight","borderBottom","borderLeft","borderStart","borderEnd","borderTopLeftToBottomRight","borderTopRightToBottomLeft"])l(e,t,ts);c("top",ts),c("right",ts),c("bottom",ts),c("left",ts);break;case"top":c("top");break;case"right":c("right");break;case"bottom":c("bottom");break;case"left":c("left");break;case"outside":c("top"),c("right"),c("bottom"),c("left");break;case"insideHorizontal":d();break;case"insideVertical":u();break;case"inside":d(),u();break;case"all":c("top"),c("right"),c("bottom"),c("left"),d(),u();break;case"diagonalDown":for(const e of o.selectedEntries)l(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)l(e,"borderTopRightToBottomLeft")}if(0===r.size)return e;const p=/* @__PURE__ */new Set;for(const m of o.entries)if(r.has(m.cell.id))for(const e of m.cell.blocks)for(const t of We(e))p.add(t.id);const g=t=>{const n=r.get(t.id);if(!n)return t;let o=t.style;e.trackChangesEnabled&&!o?.propertyRevision&&(o={...o??{},propertyRevision:{...Ll(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=Nl(o,e,r);return{...t,style:o}},f=Co(e.document).map(e=>({...e,blocks:Mt(e.blocks,p,g),header:e.header?Mt(e.header,p,g):void 0,footer:e.footer?Mt(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),Xi),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>as(e,"width","100%"),Gi),alignLeft:()=>o(e=>os(e,"horizontalAlign","left"),Yi),alignCenter:()=>o(e=>os(e,"horizontalAlign","center"),Yi),alignRight:()=>o(e=>os(e,"horizontalAlign","right"),Yi),setCellVerticalAlign:e=>o(t=>os(t,"verticalAlign",e),qi),setCellTextDirection:e=>o(t=>os(t,"textDirection",e),Zi),setCellWidth:e=>o(t=>function(e,t){return os(e,"width",t)}(t,e),Ji),setCellNoWrap:e=>o(t=>function(e,t){return os(e,"noWrap",t)}(t,e),Ji),setCellFitText:e=>o(t=>function(e,t){return os(e,"fitText",t)}(t,e),Ji),canSetCellMargins:()=>null!==Ul(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=os(n,"paddingTop",t.top)),void 0!==t.right&&(n=os(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=os(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=os(n,"paddingLeft",t.left)),n}(t,e),cl),canSetCellSpacing:()=>ys(e.state()),setCellSpacing:e=>o(t=>function(e,t){return ys(e)?as(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),cl),canSetTableIndent:()=>vs(e.state()),setTableIndent:e=>o(t=>function(e,t){return vs(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?as(e,"indentLeft",null):as(e,"indentLeft",Math.round(2*t)/2):e}(t,e),cl),canSetTableAlignment:()=>null!==Ul(e.state()),setTableAlignment:e=>o(t=>ws(t,e),cl),canEvaluateTableFormula:()=>null!==Ul(e.state()),evaluateTableFormula:e=>o(t=>Cs(t,e),dl),canSelectTable:()=>null!==Ul(e.state()),selectTablePart:t=>e.applyState(Bs(e.state(),t)),canSetActiveTableRowHeight:()=>null!==Ul(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=ls(n,"height",t.height),void 0!==t.heightRule&&(n=ls(n,"heightRule",t.heightRule)),n}(t,e),ul),canSetActiveTableRowBreakAcrossPages:()=>Ss(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Ss(e)?ls(e,"cantSplit",null===t?null:!t):e}(t,e),ul),canSetActiveTableRowHeader:()=>null!==Ul(e.state()),setActiveTableRowHeader:e=>o(t=>ss(t,e),sl),canSetActiveTableColumnWidth:()=>null!==Ul(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=Ul(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Xl(Hl(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=Xt(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:us(e,a.id,{[l]:t})}(t,e),Qi),canSetActiveTableWidth:()=>null!==Ul(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=Ul(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=Xl(Hl(e.document,o,r.zone),r.tablePath);return a?is(e,a.id,"width",t):e}(t,e),Gi),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function Pw(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>jv(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Hv[t]??Hv.oasis,o=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>{if(!/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e))return[e,t];const o=/^heading[1-9]$/i.test(e)||/title|quote/i.test(e);return[e,{...t,textStyle:{...t.textStyle??{},color:o?n.heading:n.color}}]}));return{...e,document:{...e.document,styles:o,design:{...e.document.design??{},colorSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,colors:{...e.document.design?.themeData?.colors??{},accent1:n.color,accent2:n.heading}}}}}}(t,e)),setFontScheme:e=>t(t=>function(e,t){const[n,o]=Wv[t]??Wv.aptos,r=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,textStyle:{...t.textStyle??{},fontFamily:/^heading|title|quote/i.test(e)?o:n}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},fontSchemeId:t,themeData:{...e.document.design?.themeData??{},sourceXml:void 0,fonts:{...e.document.design?.themeData?.fonts??{},major:{...e.document.design?.themeData?.fonts?.major??{},majorHAnsi:o.split(",")[0].trim()},minor:{...e.document.design?.themeData?.fonts?.minor??{},minorHAnsi:n.split(",")[0].trim()}}}},styles:r}}}(t,e)),setParagraphSpacing:e=>t(t=>function(e,t){const n={compact:[0,4],tight:[0,6],open:[0,10],relaxed:[4,12]},[o,r]=n[t]??n.open,a=Object.fromEntries(Object.entries(e.document.styles??{}).map(([e,t])=>/^(normal|title|subtitle|heading[1-9]|quote|intensequote)$/i.test(e)?[e,{...t,paragraphStyle:{...t.paragraphStyle??{},spacingBefore:o,spacingAfter:r}}]:[e,t]));return{...e,document:{...e.document,design:{...e.document.design??{},paragraphSpacingId:t},styles:a}}}(t,e)),setEffects:e=>t(t=>Uv(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return Uv(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return Uv(e,{watermark:t})}(t,e)),setPageBorder:e=>t(t=>function(e,t){const n=(e.document.sections??[]).map(e=>({...e,pageBorder:t}));return{...e,document:{...e.document,sections:n,design:{...e.document.design??{}}}}}(t,e)),setDefault:()=>{const t=e.state().document.design;t&&globalThis.localStorage?.setItem("oasis-design-default",JSON.stringify(t))},getDesign:()=>e.state().document.design,getPageBorder:()=>e.state().document.sections?.find(e=>e.pageBorder)?.pageBorder}}function kw(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,o)=>({execute:t,refresh:()=>({isEnabled:n(e),...o?.()})}));var n;const o=function(e){return(t,n,o)=>({execute:n,refresh:()=>({isEnabled:e(t),value:o()})})}(e.gate.isCommandEnabled),r=function(e){return(t,n,o)=>({execute:e=>(n(e),!0),refresh:()=>({isEnabled:e(t),...o?.()})})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...Xv({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,link:e.link,command:t,valueCommand:o,actionCommand:r}),...Gv({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...Yv({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...qv({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...Qv({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...ex({design:e.design,actionCommand:r}),...Zv({bookmark:e.bookmark,actionCommand:r}),...Jv({fields:e.fields,actionCommand:r})}}}({gate:nx(e),style:ox(e),selection:rx(e),history:ax(e),formatting:kx(e),document:Ex(e),link:Lx(e),image:Nx(e),browser:$x(e),paragraph:tw(e),section:hw(e),headerFooter:bw(e),table:Tw(e),design:Pw(e),bookmark:vw(e),fields:Cw(e)})}var Rw=[{id:"file_new",path:"File/New",labelKey:"menu.file.new",shortcut:"Ctrl+N",command:"newDocument",icon:"file-plus"},{id:"file_import",path:"File/Import",labelKey:"toolbar.importDocx",shortcut:"Ctrl+O",command:"importDocument",icon:"upload"},{id:"file_save",path:"File/Save",labelKey:"generic.save",shortcut:"Ctrl+S",hidden:!0,icon:"save"},{id:"file_export",path:"File/Export",labelKey:"menu.file.export",icon:"download"},{id:"file_export_pdf",path:"File/Export/PDF",command:"exportPdf",icon:"file-down"},{id:"file_export_docx",path:"File/Export/DOCX",command:"exportDocx",icon:"file-text"},{id:"file_export_html",path:"File/Export/HTML",hidden:!0},{id:"file_export_md",path:"File/Export/MD",hidden:!0},{id:"file_print",path:"File/Print",labelKey:"menu.file.print",shortcut:"Ctrl+P",command:"print",icon:"printer"},{id:"edit_undo",path:"Edit/Undo",labelKey:"toolbar.undo",shortcut:"Ctrl+Z",command:"undo",icon:"undo-2"},{id:"edit_redo",path:"Edit/Redo",labelKey:"toolbar.redo",shortcut:"Ctrl+Y",command:"redo",icon:"redo-2"},{id:"edit_cut",path:"Edit/Cut",labelKey:"menu.edit.cut",shortcut:"Ctrl+X",command:"cut",icon:"scissors"},{id:"edit_copy",path:"Edit/Copy",labelKey:"menu.edit.copy",shortcut:"Ctrl+C",command:"copy",icon:"copy"},{id:"edit_paste",path:"Edit/Paste",labelKey:"menu.edit.paste",shortcut:"Ctrl+V",command:"paste",icon:"clipboard-paste"},{id:"edit_paste_merge",path:"Edit/Paste Merge Formatting",labelKey:"toolbar.pasteMergeFormatting",command:"pasteMergeFormatting",icon:"paintbrush"},{id:"edit_paste_plain",path:"Edit/Paste as Plain Text",labelKey:"toolbar.pastePlainText",command:"pasteAsPlainText",icon:"clipboard"},{id:"edit_format_painter",path:"Edit/Format Painter",labelKey:"toolbar.formatPainter",command:"formatPainter",icon:"paintbrush"},{id:"edit_format_painter_continuous",path:"Edit/Format Painter Continuous",labelKey:"toolbar.formatPainterContinuous",command:"formatPainterContinuous",icon:"paintbrush"},{id:"edit_cancel_format_painter",path:"Edit/Cancel Format Painter",labelKey:"toolbar.formatPainterCancel",command:"cancelFormatPainter",icon:"x"},{id:"edit_find",path:"Edit/Find & Replace",labelKey:"find.title",shortcut:"Ctrl+F",command:"find",icon:"search"},{id:"edit_selectAll",path:"Edit/Select All",labelKey:"menu.edit.selectAll",shortcut:"Ctrl+A",hidden:!0},{id:"review_previous_revision",path:"Review/Previous Change",labelKey:"toolbar.previousRevision",command:"previousRevision",icon:"chevron-up"},{id:"review_next_revision",path:"Review/Next Change",labelKey:"toolbar.nextRevision",command:"nextRevision",icon:"chevron-down"},{id:"review_comments_panel",path:"Review/Comments Panel",labelKey:"review.commentsPanel",command:"toggleCommentsPanel",icon:"list-filter"},{id:"review_new_comment",path:"Review/New Comment",labelKey:"toolbar.newComment",command:"newComment",icon:"message-square-plus"},{id:"review_reply_comment",path:"Review/Reply to Comment",labelKey:"toolbar.replyComment",command:"replyComment",icon:"reply"},{id:"review_edit_comment",path:"Review/Edit Comment",labelKey:"toolbar.editComment",command:"editComment",icon:"pencil"},{id:"review_previous_comment",path:"Review/Previous Comment",labelKey:"toolbar.previousComment",command:"previousComment",icon:"message-square"},{id:"review_next_comment",path:"Review/Next Comment",labelKey:"toolbar.nextComment",command:"nextComment",icon:"messages-square"},{id:"review_resolve_comment",path:"Review/Resolve Comment",labelKey:"toolbar.resolveComment",command:"resolveComment",icon:"message-square-check"},{id:"review_reopen_comment",path:"Review/Reopen Comment",labelKey:"toolbar.reopenComment",command:"reopenComment",icon:"message-square-more"},{id:"review_delete_comment",path:"Review/Delete Comment",labelKey:"toolbar.deleteComment",command:"deleteComment",icon:"message-square-x"},{id:"view_outline",path:"View/Show Outline",labelKey:"menu.view.outline",hidden:!0},{id:"view_ruler",path:"View/Show Ruler",hidden:!0},{id:"view_margins",path:"View/Show Margins",labelKey:"menu.view.margins",command:"toggleShowMargins",icon:e=>e.commands.state("toggleShowMargins").isActive?"check-square":"square"},{id:"view_paragraph_marks",path:"View/Show Paragraph Marks",labelKey:"menu.view.paragraphMarks",command:"toggleShowParagraphMarks",icon:e=>e.commands.state("toggleShowParagraphMarks").isActive?"check-square":"square"},{id:"view_precise_fonts",path:"View/Precise Fonts",labelKey:"menu.view.preciseFonts",command:"togglePreciseFonts",icon:e=>e.commands.state("togglePreciseFonts").isActive?"check-square":"square"},{id:"view_fullscreen",path:"View/Full Screen",labelKey:"menu.view.fullscreen",hidden:!0},{id:"view_zoom",path:"View/Zoom",labelKey:"status.zoom",hidden:!0},{id:"view_zoom_50",path:"View/Zoom/50%",hidden:!0},{id:"view_zoom_75",path:"View/Zoom/75%",hidden:!0},{id:"view_zoom_100",path:"View/Zoom/100%",hidden:!0},{id:"view_zoom_125",path:"View/Zoom/125%",hidden:!0},{id:"view_zoom_150",path:"View/Zoom/150%",hidden:!0},{id:"view_zoom_200",path:"View/Zoom/200%",hidden:!0},{id:"insert_image",path:"Insert/Image",labelKey:"toolbar.image",command:"insertImage",icon:"image"},{id:"insert_image_caption",path:"Insert/Image Caption",labelKey:"toolbar.imageCaption",command:"insertImageCaption",icon:"subtitles"},{id:"insert_table",path:"Insert/Table",labelKey:"toolbar.table",command:{name:"insertTable",payload:{rows:3,cols:3}},icon:"table"},{id:"insert_link",path:"Insert/Link",labelKey:"toolbar.link",command:"link",icon:"link"},{id:"insert_footnote",path:"Insert/Footnote",labelKey:"toolbar.footnote",shortcut:"Ctrl+Alt+F",command:"insertFootnote",icon:"footnote"},{id:"insert_toc",path:"Insert/Table of Contents",labelKey:"menu.insert.toc",command:"insertTableOfContents",icon:"list"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"refresh-cw"},{id:"insert_hr",path:"Insert/Horizontal Rule",hidden:!0},{id:"insert_pageBreak",path:"Insert/Page Break",labelKey:"metric.pageBreak",command:"pageBreak",icon:"file-minus"},{id:"insert_header",path:"Insert/Header",labelKey:"headerFooter.header",command:"editHeader",icon:"panel-top"},{id:"insert_footer",path:"Insert/Footer",labelKey:"headerFooter.footer",command:"editFooter",icon:"panel-bottom"},{id:"insert_page_number",path:"Insert/Page Number",labelKey:"headerFooter.pageNumber",icon:"hash"},{id:"insert_page_number_current",path:"Insert/Page Number/Current Position",labelKey:"headerFooter.pageNumberCurrent",command:"insertPageNumber"},{id:"insert_page_number_xofy",path:"Insert/Page Number/Page X of Y",labelKey:"headerFooter.pageNumberXOfY",command:"insertPageNumberXOfY"},{id:"insert_page_number_top",path:"Insert/Page Number/Top of Page",labelKey:"headerFooter.pageNumberTop",command:"placePageNumberTop"},{id:"insert_page_number_bottom",path:"Insert/Page Number/Bottom of Page",labelKey:"headerFooter.pageNumberBottom",command:"placePageNumberBottom"},{id:"insert_bookmark",path:"Insert/Bookmark",labelKey:"toolbar.bookmark",command:"insertBookmark",icon:"bookmark"},{id:"insert_date",path:"Insert/Date",labelKey:"toolbar.date",command:"insertDateField",icon:"calendar"},{id:"insert_specialChar",path:"Insert/Special Character",hidden:!0},{id:"insert_comment",path:"Insert/Comment",hidden:!0},{id:"format_text",path:"Format/Text",labelKey:"menu.format.text",icon:"type"},{id:"format_text_bold",path:"Format/Text/Bold",labelKey:"toolbar.bold",shortcut:"Ctrl+B",command:"bold",icon:"bold"},{id:"format_text_italic",path:"Format/Text/Italic",labelKey:"toolbar.italic",shortcut:"Ctrl+I",command:"italic",icon:"italic"},{id:"format_text_underline",path:"Format/Text/Underline",labelKey:"toolbar.underline",shortcut:"Ctrl+U",command:"underline",icon:"underline"},{id:"format_text_strike",path:"Format/Text/Strikethrough",labelKey:"toolbar.strike",command:"strike",icon:"strikethrough"},{id:"format_paragraphStyles",path:"Format/Paragraph styles",labelKey:"toolbar.style",hidden:!0},{id:"format_align",path:"Format/Align",labelKey:"menu.format.align",icon:"align-left"},{id:"format_align_left",path:"Format/Align/Left",labelKey:"toolbar.alignLeft",command:"alignLeft",icon:"align-left"},{id:"format_align_center",path:"Format/Align/Center",labelKey:"toolbar.alignCenter",command:"alignCenter",icon:"align-center"},{id:"format_align_right",path:"Format/Align/Right",labelKey:"toolbar.alignRight",command:"alignRight",icon:"align-right"},{id:"format_align_justify",path:"Format/Align/Justify",labelKey:"toolbar.justify",command:"alignJustify",icon:"align-justify"},{id:"format_lineSpacing",path:"Format/Line spacing",hidden:!0},{id:"format_lists",path:"Format/Lists",labelKey:"menu.format.lists",icon:"list"},{id:"format_lists_bullet",path:"Format/Lists/Bullet List",labelKey:"toolbar.bulletList",command:"bulletList",icon:"list"},{id:"format_lists_numbered",path:"Format/Lists/Numbered List",labelKey:"toolbar.numberedList",command:"orderedList",icon:"list-ordered"},{id:"format_clear",path:"Format/Clear formatting",hidden:!0},{id:"layout_orientation",path:"Layout/Orientation",labelKey:"section.orientation",icon:"layout"},{id:"layout_orientation_portrait",path:"Layout/Orientation/Portrait",labelKey:"section.portrait",command:{name:"setOrientation",payload:"portrait"},icon:e=>e.commands.state("toggleOrientation").isActive?"":"check"},{id:"layout_orientation_landscape",path:"Layout/Orientation/Landscape",labelKey:"section.landscape",command:{name:"setOrientation",payload:"landscape"},icon:e=>e.commands.state("toggleOrientation").isActive?"check":""},{id:"tools_wordcount",path:"Tools/Word count",labelKey:"menu.tools.wordcount",hidden:!0},{id:"tools_spelling",hidden:!0,path:"Tools/Spelling"},{id:"tools_preferences",path:"Tools/Preferences",hidden:!0},{id:"help_shortcuts",path:"Help/Keyboard shortcuts",labelKey:"menu.help.shortcuts",hidden:!0},{id:"help_about",path:"Help/About",labelKey:"menu.help.about",hidden:!0}];function Bw(t){const n=kw(t.essentials),{runtimePlugins:o,toolbarRegistry:r,menuRegistry:a,dispose:i}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=jn(),i=new e;for(const e of Cr(t.t))a.register(e);for(const e of Rw)i.register(e);for(const e of n){for(const t of e.toolbar??[]){const e={type:"button",id:t.id,testId:t.id,command:t.command,iconName:t.icon,tab:t.tab??"plugins",group:t.group??"general",groupLabel:t.groupLabel,row:t.row??1,ribbonSize:t.ribbonSize,ribbonGroupResize:t.ribbonGroupResize,ribbonGroupLayout:t.ribbonGroupLayout,order:t.order};a.register(e),o.push(t.id)}for(const t of e.menubar??[])i.register({id:t.id,path:t.path,command:t.command,icon:t.icon,shortcut:t.shortcut}),r.push(t.id)}return t.customizeToolbar?.(a),t.customizeMenubar?.(i),{runtimePlugins:n,toolbarRegistry:a,menuRegistry:i,dispose:()=>{for(const e of o)a.remove(e);for(const e of r)i.unregister(e)}}}({essentialsPlugin:n,externalPlugins:t.externalPlugins,t:t.t,customizeToolbar:t.customizeToolbar,customizeMenubar:t.customizeMenubar}),l=function(e){const[t,n]=Wt(!1),[o,r]=Wt(new yt({doc:e.initialDocument}));let a=!1;const i=e=>{const t=la(e),n=o().commands.get(t);if(!n)return{isEnabled:!1,isActive:!1,value:void 0};const r=n.refresh?.()??{isEnabled:!0};return{isEnabled:!1!==r.isEnabled,isActive:Boolean(r.isActive),value:r.value}};return{runtimeReady:t,runtimeEditor:o,commandStateOf:i,toolbarHost:()=>({commands:{execute:(e,t)=>{const n=Tn(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=Tn(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await yt.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(a)return void(await t.destroy());const i=o();r(t),await i.destroy(),n(!0),requestAnimationFrame(()=>{e.onSettled?.(),e.onReady?.(t)})}catch(t){e.logger.error("runtime:init failed",t),e.onError?.(t),e.onSettled?.()}},dispose:async()=>{a=!0,await o().destroy()}}}({initialDocument:t.initialDocument,runtimePlugins:o,focusEditor:t.focusEditor,logger:t.logger,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return Jt(()=>{l.initialize()}),pe(()=>{l.dispose(),i()}),{toolbarRegistry:r,menuRegistry:a,runtimeReady:l.runtimeReady,runtimeEditor:l.runtimeEditor,commandStateOf:l.commandStateOf,toolbarHost:l.toolbarHost}}function Mw(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Ov({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:e.focusInput,selectedImageRun:n.selectedImageRun,tableOps:n.tableOps,toolbarStyleState:n.styleController.toolbarStyleState,applyBooleanStyleCommand:e=>n.styleController.applyToolbarBooleanStyleCommand(e),locale:e.locale,setLinkDialog:e.setLinkDialog,setImageAltDialog:e.setImageAltDialog,setImageCaptionDialog:e.setImageCaptionDialog}),{runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:c,toolbarRegistry:d,menuRegistry:u}=Bw({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:r,keyboardCommandsController:a,historyActions:t.historyActions,styleController:n.styleController,formatPainter:n.formatPainter,commentComposer:e.commentComposer,tableOps:n.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:n.selectedImageRun,imageCropMode:{isActive:n.imageOps.cropMode,toggle:n.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:n.fr.setIsOpen},newDocument:Dv({isDirty:()=>o.isDirty(),resetDocument:()=>o.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openTablePropertiesDialog:t=>{const n=Hs(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=Vr(e.state.document).find(e=>e.id===t.paragraphId);if("paragraph"===n?.type){let o=0;for(const r of n.runs){if("math"===r.kind&&t.offset>=o&&t.offset<=o+r.text.length)return void e.setEquationDialog({isOpen:!0,initial:r.math,targetRunId:r.id});o+=r.text.length}}e.setEquationDialog({isOpen:!0})}},externalPlugins:e.runtimeOptions().plugins,t:e.translator,customizeToolbar:e.runtimeOptions().customizeToolbar,customizeMenubar:e.runtimeOptions().customizeMenubar,initialDocument:e.getStateSnapshot().document,focusEditor:e.focusInput,logger:e.logger,onReady:t=>{o.resolveReady(t),e.runtimeOptions().onReady?.(o)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>o.rejectReady(e)});(function(e,t){const n=()=>t.cloneState(t.getStateSnapshot());e.connectHost({getRuntimeEditor:()=>t.runtimeReady()?t.runtimeEditor():null,getState:()=>n(),getDocument:()=>n().document,setDocument:e=>{t.applyState(Tr(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=jo();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=jv(e,n.themeId)),e=Uv(e,n)}}catch{}t.applyState(e),t.resetEditorChromeState(),t.focusInput()},saveDocument:async()=>{await t.getPersistence().saveDocument(n().document)},getSelection:()=>n().selection,setSelection:e=>{t.applyState({...n(),selection:e}),t.focusInput()},focus:()=>t.focusInput(),blur:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.setFocused(!1)},clearHistory:()=>t.clearHistory(),importDocx:e=>t.docIO.handleImportFile(e),exportDocx:()=>Promise.resolve(t.docIO.handleExportDocx()),exportPdf:()=>Promise.resolve(t.docIO.handleExportPdf()),exportDocxBlob:()=>t.docIO.exportDocxBlob(),exportPdfBlob:()=>t.docIO.exportPdfBlob(),getUiState:t.getUiState,updateUiState:t.updateUiState,getZoom:t.getZoom,setZoom:t.setZoom,adjustZoom:t.adjustZoom,toolbarRegistry:t.toolbarRegistry,menuRegistry:t.menuRegistry})})(o,{runtimeReady:i,runtimeEditor:l,getStateSnapshot:e.getStateSnapshot,cloneState:e.cloneState,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,resetEditorChromeState:t.resetEditorChromeState,focusInput:e.focusInput,setFocused:e.setFocused,clearHistory:t.clearHistory,getPersistence:()=>e.documentOptions().persistence??t.fallbackPersistence,docIO:t.docIO,getUiState:e.getUiState,updateUiState:e.updateUiState,getZoom:e.zoom.zoomPercent,setZoom:e.zoom.setZoomPercent,adjustZoom:e.zoom.adjustZoom,toolbarRegistry:d,menuRegistry:u}),Dt(()=>{if(!i())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());l().dispatch(()=>t)});const{handleKeyDown:p}=function(e){const{state:t,isReadOnly:n,logger:o,focusInput:r,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:g,historyActions:f,styleController:m,findReplace:h,runtimeEditor:b}=e,{handleKeyDown:y}=Nv({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:l,applyTransactionalState:s,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:u,selectedImageRun:d,setForcePlainTextPaste:c,moveSelectionByWord:g.moveSelectionByWord,moveSelectionToDocumentBoundary:g.moveSelectionToDocumentBoundary,moveSelectionToParagraphBoundary:g.moveSelectionToParagraphBoundary,moveSelectedImageByParagraph:f.moveSelectedImageByParagraph,performUndo:f.performUndo,performRedo:f.performRedo,moveVerticalSelection:g.moveVerticalSelection,moveVerticalByBlock:g.moveVerticalByBlock,resolveAdjacentTableCellPosition:p.resolveAdjacentTableCellPosition,applySelectionPreservingStructure:f.applySelectionPreservingStructure,toggleFindReplace:e=>{h.setIsOpen(e??!h.isOpen())},toggleReplace:e=>{h.setIsOpen(e??!h.isOpen())},executeCommand:(e,t)=>b().commands.execute(e,t),canExecuteCommand:e=>b().commands.canExecute(e)});return{handleKeyDown:e=>{$v.includes(e.key)&&m.clearPendingCaretTextStyle();const n=[e.ctrlKey?"Ctrl":null,e.metaKey?"Meta":null,e.altKey?"Alt":null,e.shiftKey?"Shift":null].filter(Boolean).join("+"),r=n?`${n}+${e.key}`:e.key,a=t().selection;o.debug(`key:down ${r} at ${a.anchor.paragraphId}:${a.anchor.runId}[${a.anchor.offset}]`),gn("input-to-layout"),y(e),no("input-to-layout")}}}({state:()=>e.state,isReadOnly:e.isReadOnly,logger:e.logger,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,setForcePlainTextPaste:e.setForcePlainTextPaste,selectedImageRun:n.selectedImageRun,commandsController:a,tableOps:n.tableOps,navigation:n.navigation,historyActions:t.historyActions,styleController:n.styleController,findReplace:n.fr,runtimeEditor:l});return{commandsController:r,runtimeReady:i,runtimeEditor:l,commandStateOf:s,toolbarHost:c,toolbarRegistry:d,menuRegistry:u,handleKeyDown:p}}(e)}function Fw(e,t){const n=e.document.comments?.items;if(!n?.[t])return null;const o=/* @__PURE__ */new Set;let r=t;for(;n[r]?.parentId&&!o.has(r);){o.add(r);const e=n[r].parentId;if(!n[e])break;r=e}return r}function Aw(e,t,n){if(t.document===e.document)return e;const o=e.document.comments?.items[n.commentId]??t.document.comments?.items[n.commentId];if(!o)return t;const r=Fw(e,n.commentId)??Fw(t,n.commentId)??n.commentId,a=e.document.comments?.order.length??0,i=t.document.comments?.order.length??0;return function(e,t){if(!(t.id.trim()&&t.commentId.trim()&&t.threadId.trim()&&t.actorName.trim()&&Number.isFinite(t.timestamp)))return e;const n=e.document.reviewActivity??[];return n.some(e=>e.id===t.id)?e:{...e,document:{...e.document,reviewActivity:[...n,{...t}]}}}(t,{id:n.id,kind:n.kind,commentId:n.commentId,threadId:r,...n.parentId?{parentId:n.parentId}:{},actorName:n.actorName,...n.actorId?{actorId:n.actorId}:{},targetAuthor:o.author,timestamp:n.timestamp,..."comment-deleted"===n.kind?{affectedCount:Math.max(1,a-i)}:{}})}function Ow(e,t){if(!t)return!1;if(!e)return!0;if(e.canModerate)return!0;const n=e.identity?.id.trim();return Boolean(n&&t.authorId&&n===t.authorId)}function Dw(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!Ow(e,t.items[n]))return!1;const o=/* @__PURE__ */new Set([n]),r=[n],a=/* @__PURE__ */new Map;for(const i of Object.values(t.items)){if(!i.parentId)continue;const e=a.get(i.parentId)??[];e.push(i.id),a.set(i.parentId,e)}for(;r.length;){const n=r.pop();for(const i of a.get(n)??[])if(!o.has(i)){if(o.add(i),!Ow(e,t.items[i]))return!1;r.push(i)}}return!0}function Ew(e){const[t,n]=Wt(null),[o,r]=Wt(""),[a,i]=Wt(!1),l=()=>e.access?.(),s=()=>{const e=l()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},c=()=>!(e.isReadOnly()||l()&&null===s()),d=()=>c()&&null!==P(e.state()),u=t=>c()&&Boolean(e.state().document.comments?.items[t]),p=()=>c()&&null!==bx(e.state()),g=t=>!e.isReadOnly()&&Ow(l(),e.state().document.comments?.items[t]),f=()=>{const t=bx(e.state());return null!==t&&g(t.id)},m=t=>!e.isReadOnly()&&Dw(l(),e.state().document.comments,t),h=g,b=(e="Local editor")=>{const t=s();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},y=(e,t,n,o,r,a)=>Aw(e,t,{id:Ao("review-activity"),kind:n,commentId:o,...b(r),timestamp:Date.now(),...a?{parentId:a}:{}}),v=t=>{if(!u(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"reply",snapshot:o,parentId:r.id,parentAuthor:r.author,parentText:r.text}),!0)},x=t=>{if(!g(t))return!1;const o=e.state(),r=o.document.comments?.items[t];return!!r&&(n({mode:"edit",snapshot:o,commentId:t,commentAuthor:r.author,commentText:r.text}),!0)},w=()=>{n(null),e.focusInput()},S=t=>{if(!m(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!Dw(l(),r.document.comments,t))return r;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const o=/* @__PURE__ */new Set([t]),r=[t],a=/* @__PURE__ */new Map;for(const l of Object.values(n.items)){if(!l.parentId)continue;const e=a.get(l.parentId)??[];e.push(l.id),a.set(l.parentId,e)}for(;r.length>0;){const e=r.pop();for(const t of a.get(e)??[])o.has(t)||(o.add(t),r.push(t))}const i=Object.fromEntries(Object.entries(n.items).filter(([e])=>!o.has(e)));return{...e,document:{...e.document,comments:{...n,items:i,order:n.order.filter(e=>!o.has(e))}}}}(r,t);return o=a.document!==r.document,o?y(r,a,"comment-deleted",t):a}),o},I=(t,n)=>{if(!h(t))return!1;const o=e.state();let r=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==o.document||!Ow(l(),a.document.comments?.items[t]))return a;const i=function(e,t,n){const o=e.document.comments,r=o?.items[t];return o&&r&&Boolean(r.resolved)!==n?{...e,document:{...e.document,comments:{...o,items:{...o.items,[t]:{...r,resolved:n}}}}}:e}(a,t,n);return r=i.document!==a.document,r?y(a,i,n?"comment-resolved":"comment-reopened",t):i}),r};return{draft:t,lastAuthor:o,panelOpen:a,togglePanel:()=>(i(!a()),!0),closePanel:()=>{i(!1)},canCreate:d,canReply:p,canReplyId:u,canEdit:f,canEditId:g,canDeleteId:m,canDeleteSelected:()=>{const t=bx(e.state());return null!==t&&m(t.id)},deleteSelected:()=>{const t=bx(e.state());return!!t&&S(t.id)},deleteById:S,canResolveId:h,canResolveSelected:()=>{const t=bx(e.state());return null!==t&&h(t.id)},resolveSelected:t=>{const n=bx(e.state());return!!n&&I(n.id,t)},resolveById:I,authorName:()=>s()?.displayName??o(),authorLocked:()=>void 0!==l(),openNew:()=>!!d()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!p())return!1;const t=bx(e.state());return!!t&&v(t.id)},openReplyToId:v,openEdit:()=>{if(!f())return!1;const t=bx(e.state());return!!t&&x(t.id)},openEditToId:x,close:w,submit:(n,o)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!g(a.commentId))return!1;if("edit"!==a.mode&&!c())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":s()?.displayName??n.trim(),d=o.trim();if(!i||!d||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===d)return w(),!0;const u="edit"===a.mode?null:{id:Ao("comment"),author:i,...s()?{authorId:s().id}:{},text:d,date:Date.now()};let p=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!Ow(l(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!c())return t;const n="edit"===a.mode?A(t,a.commentId,d):"reply"===a.mode?Po(t,a.parentId,u):je({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},u);return p=n.document!==t.document,p?y(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:u.id,i,"reply"===a.mode?a.parentId:void 0):n}),p&&("edit"!==a.mode&&r(i),w()),p}}}var Lw=/*#__PURE__*/ie("<div class=oasis-review-comments-filters role=group>"),Nw=/*#__PURE__*/ie("<div class=oasis-review-comments-list>"),$w=/*#__PURE__*/ie("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),zw=/*#__PURE__*/ie("<div role=region class=oasis-review-comments-panel data-testid=review-comments-panel><div class=oasis-review-comments-heading></div><div class=oasis-review-mode-switch role=group>"),Hw=/*#__PURE__*/ie("<div class=oasis-review-thread-replies>"),Ww=/*#__PURE__*/ie("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),Uw=/*#__PURE__*/ie("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),jw=/*#__PURE__*/ie("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function Vw(e){const t=Xr(),[n,o]=Wt("all"),[r,a]=Wt(!1),[i,l]=Wt(""),[c,d]=Wt(null),[u,p]=Wt(null),g=()=>e.state().document.comments,m=Q(()=>{const e=g();if(!e)return[];const t=i().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(o=>("open"!==n()||!o.resolved)&&(!("resolved"===n()&&!o.resolved)&&(!t||[o,...vt(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),h=e=>vt(g()?.items??{},e),b=Q(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),y=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",v=t=>{u()===t?e.composer.deleteById(t)&&(p(null),c()===t&&d(null)):p(t)};return x=zw(),w=x.firstChild,S=w.nextSibling,ko(w,f($r,{as:"strong",get children(){return t("review.commentsPanel")}}),null),ko(w,f(Le,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),ko(S,f(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),ko(S,f(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return r()},onClick:()=>{a(!0)},"data-testid":"review-show-activity",get children(){return t("review.activity.title")}}),null),ko(x,f($r,{as:"p",get children(){return s(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${g()?.order.length??0}`}}),null),ko(x,f(oo,{get label(){return s(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),ko(x,f(fa,{get when(){return!r()},get children(){return[(a=Lw(),ko(a,f(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),ko(a,f(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),ko(a,f(Le,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),kt(()=>Fe(a,"aria-label",t("review.filterComments"))),a),(r=Nw(),ko(r,f(fa,{get when(){return 0===m().length},get children(){return f($r,{as:"p",get children(){return t("review.noComments")}})}}),null),ko(r,f(it,{get each(){return m()},children:n=>{return o=Ww(),r=o.firstChild,a=r.nextSibling,ko(r,f($r,{as:"strong",get children(){return n.author||"—"}}),null),ko(r,f($r,{as:"span",get children(){return s(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),ko(o,f($r,{as:"p",get children(){return n.text}}),a),ko(a,f(Le,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),ko(a,f(fa,{get when(){return e.composer.canEditId(n.id)},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),ko(a,f(fa,{get when(){return e.composer.canResolveId(n.id)},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return s(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),ko(a,f(fa,{get when(){return e.composer.canReplyId(n.id)},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),ko(a,f(fa,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[f(Le,{size:"sm",variant:"ghost",onClick:()=>v(n.id),"data-testid":"review-comment-delete",get children(){return s(()=>u()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),f(fa,{get when(){return u()===n.id},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),ko(o,f(fa,{get when(){return h(n.id).length>0},get children(){return f(Le,{size:"sm",variant:"ghost",get"aria-expanded"(){return c()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{d(c()===n.id?null:n.id)},get children(){return s(()=>c()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${h(n.id).length})`}})}}),null),ko(o,f(fa,{get when(){return c()===n.id},get children(){var o=Hw();return ko(o,f(it,{get each(){return h(n.id)},children:n=>{return o=Uw(),r=o.firstChild,ko(o,f($r,{as:"strong",get children(){return n.author||"—"}}),r),ko(o,f($r,{as:"p",get children(){return n.text}}),r),ko(r,f(fa,{get when(){return e.composer.canEditId(n.id)},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),ko(r,f(fa,{get when(){return e.composer.canReplyId(n.id)},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),ko(r,f(fa,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[f(Le,{size:"sm",variant:"ghost",onClick:()=>v(n.id),"data-testid":"review-reply-delete",get children(){return s(()=>u()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),f(fa,{get when(){return u()===n.id},get children(){return f(Le,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),kt(()=>Fe(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),kt(()=>Fe(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),ko(x,f(fa,{get when(){return r()},get children(){var n=$w();return ko(n,f(fa,{get when(){return 0===b().length},get children(){return f($r,{as:"p",get children(){return t("review.activity.empty")}})}}),null),ko(n,f(it,{get each(){return b()},children:n=>{return o=jw(),r=o.firstChild,ko(r,f($r,{as:"strong",get children(){return n.actorName}}),null),ko(r,f($r,{as:"span",get children(){return y(n.timestamp)}}),null),ko(o,f($r,{as:"p",get children(){return[s(()=>(e=>{switch(e){case"comment-created":return t("review.activity.created");case"comment-replied":return t("review.activity.replied");case"comment-edited":return t("review.activity.edited");case"comment-resolved":return t("review.activity.resolved");case"comment-reopened":return t("review.activity.reopened");case"comment-deleted":return t("review.activity.deleted")}})(n.kind))," — ",s(()=>n.targetAuthor),s(()=>s(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),ko(o,f(fa,{get when(){return Boolean(g()?.items[n.commentId])},get children(){return f(Le,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),kt(()=>Fe(o,"data-activity-kind",n.kind)),o;var o,r}}),null),kt(()=>Fe(n,"aria-label",t("review.activity.title"))),n}}),null),kt(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&Fe(x,"aria-label",e.e=n),o!==e.t&&Fe(S,"aria-label",e.t=o),e},{e:void 0,t:void 0}),x;var x,w,S}var Kw=/*#__PURE__*/ie('<div class="oasis-editor-shell oasis-editor-app">');function _w(e={}){const t=e.runtime?.client??xo(),[n,o]=Wt({}),r=()=>({...e.ui??{},...n(),toolbar:{...e.ui?.toolbar??{},...n().toolbar??{}}}),a=()=>({...e.document??{},...void 0===n().readOnly?{}:{readOnly:n().readOnly}}),i=()=>({...r(),readOnly:a().readOnly}),l=()=>e.runtime??{};li();const c=xt(()=>r().locale??"pt-BR"),d=Kr("app"),{state:u,commitState:p,getStateSnapshot:g}=function(e){const t=e.initialState?xn(e.initialState):e.initialDocument?Tr(e.initialDocument):jo();let n=t;const[o,r]=Wt(t);return{state:new Proxy({},{get(e,t){const n=o();if(null!==n&&("object"==typeof n||"function"==typeof n))return Reflect.get(n,t)},has(e,t){const n=o();return null!==n&&("object"==typeof n||"function"==typeof n)&&Reflect.has(n,t)},ownKeys(e){const t=o();return null===t||"object"!=typeof t&&"function"!=typeof t?[]:Reflect.ownKeys(t)},getOwnPropertyDescriptor(e,t){const n=o();return null===n||"object"!=typeof n&&"function"!=typeof n?{configurable:!0,enumerable:!0}:{...Reflect.getOwnPropertyDescriptor(n,t),configurable:!0,enumerable:!0}}}),setStateSignal:r,commitState:e=>{const t=Jn(e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),m=e=>{p(e)},h=xn;let b=!1;const{showChrome:y,showTitleBar:x,showMenubar:S,showToolbar:C,showOutline:T,toolbarView:P,toolbarLayout:k,isReadOnly:R,useComposedShell:B,loadingOptions:M,loadingLabel:F,shellComponent:A}=function(e){const{ui:t,documentOptions:n}=e,o=()=>{const e=t().loading;return"object"==typeof e&&null!==e?e:void 0};return{showChrome:()=>t().showChrome??!0,showTitleBar:()=>t().showTitleBar??!0,showMenubar:()=>t().showMenubar??!0,showToolbar:()=>t().showToolbar??!0,showOutline:()=>t().showOutline??!0,toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>n().readOnly??!1,useComposedShell:()=>"docs"===t().uiVariant||"document"!==(t().shell??"document"),loadingOptions:o,loadingLabel:()=>o()?.label??"Loading oasis-editor...",shellComponent:()=>{const e=t().shell??"document";return"inline"===e?Yr:"balloon"===e?I:St}}}({ui:r,documentOptions:a}),O=function(){const[e,t]=Wt(!1);let n,o,r,a,i;return{focused:e,setFocused:t,focusInput:()=>{t(!0),queueMicrotask(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})},focusInputAfterPointerSelection:()=>{t(!0),queueMicrotask(()=>{requestAnimationFrame(()=>{r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)})})},focusInputSync:()=>{t(!0),r?.focus({preventScroll:!0}),r&&(r.selectionStart=r.value.length,r.selectionEnd=r.value.length)},get viewportRef(){return n},set viewportRef(e){n=e},get surfaceRef(){return o},set surfaceRef(e){o=e},get textareaRef(){return r},set textareaRef(e){r=e},get importInputRef(){return a},set importInputRef(e){a=e},get imageInputRef(){return i},set imageInputRef(e){i=e}}}(),D=O.focused,E=O.setFocused,L=O.focusInput,N=O.focusInputAfterPointerSelection,$=O.focusInputSync,[z,H]=Wt(!1!==r().loading),U=W(),{linkDialog:j,setLinkDialog:V,imageAltDialog:K,setImageAltDialog:_,imageCaptionDialog:X,setImageCaptionDialog:G,contextMenu:Y,setContextMenu:q,fontDialog:Z,setFontDialog:Q,paragraphDialog:ee,setParagraphDialog:te,tablePropertiesDialog:ne,setTablePropertiesDialog:oe,newDocumentDialog:re,setNewDocumentDialog:ae,symbolDialog:ie,setSymbolDialog:le,equationDialog:se,setEquationDialog:ce}=function(){const[e,t]=Wt({isOpen:!1}),[n,o]=Wt({isOpen:!1}),[r,a]=Wt({isOpen:!1}),[i,l]=Wt({isOpen:!1,initialHref:""}),[s,c]=Wt({isOpen:!1,initialAlt:""}),[d,u]=Wt({isOpen:!1,initialCaption:""}),[p,g]=Wt({isOpen:!1,x:0,y:0}),[f,m]=Wt({isOpen:!1,initial:{fontFamily:"",fontSize:"",color:"",colorMode:"automatic",highlight:"",shading:"",bold:!1,italic:!1,underline:!1,underlineStyle:null,underlineColor:"",strike:!1,doubleStrike:!1,superscript:!1,subscript:!1,smallCaps:!1,allCaps:!1,hidden:!1,characterScale:"",characterSpacing:"",baselineShift:"",kerningThreshold:"",ligatures:"",numberSpacing:"",numberForm:"",stylisticSet:"",contextualAlternates:!1}}),[h,b]=Wt({isOpen:!1,initial:{align:"",indentLeft:"",indentRight:"",indentFirstLine:"",indentHanging:"",mirrorIndents:!1,spacingBefore:"",spacingAfter:"",lineHeight:"",lineRule:"",contextualSpacing:!1,outlineLevel:"",shading:"",borderStyle:"",borderWidth:"",borderColor:"",borderSideTop:!1,borderSideRight:!1,borderSideBottom:!1,borderSideLeft:!1,pageBreakBefore:!1,keepWithNext:!1,keepLinesTogether:!1,widowControl:!0,tabs:[]}}),[y,v]=Wt({isOpen:!1,initial:{activeTab:"table",tableWidth:"",tableWidthUnit:"points",tableAlign:"",tableIndentLeft:"",tableWrapping:"none",floatingSummary:"",floatingHorizontalAnchor:"margin",floatingVerticalAnchor:"text",floatingX:"0",floatingY:"0",floatingXAlign:"",floatingYAlign:"",floatingDistanceTop:"0",floatingDistanceRight:"0",floatingDistanceBottom:"0",floatingDistanceLeft:"0",floatingOverlap:"overlap",rowHeight:"",rowHeightRule:"",repeatHeader:!1,allowBreakAcrossPages:!0,hiddenRow:!1,columnWidth:"",cellWidth:"",cellVerticalAlign:"",cellTextDirection:"",cellNoWrap:!1,cellFitText:!1,cellHideMark:!1,marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",borderStyle:"none",borderWidth:"",borderColor:"",borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1,borderStart:!1,borderEnd:!1,borderTopLeftToBottomRight:!1,borderTopRightToBottomLeft:!1,shading:"",altTitle:"",altDescription:""}});return{newDocumentDialog:e,setNewDocumentDialog:t,symbolDialog:n,setSymbolDialog:o,equationDialog:r,setEquationDialog:a,linkDialog:i,setLinkDialog:l,imageAltDialog:s,setImageAltDialog:c,imageCaptionDialog:d,setImageCaptionDialog:u,contextMenu:p,setContextMenu:g,fontDialog:f,setFontDialog:m,paragraphDialog:h,setParagraphDialog:b,tablePropertiesDialog:y,setTablePropertiesDialog:v}}(),[de,ue]=Wt(!1),ge=()=>O.viewportRef,fe=()=>O.surfaceRef,me=bb({documentOptions:a,logger:d,runtimeClient:t,state:u,commitState:p,getStateSnapshot:g,applyState:m,cloneState:h,isReadOnly:R,focusInput:L,surfaceRef:fe,viewportRef:ge,zoomFactor:U.zoomFactor,getImageOps:()=>He.imageOps}),{docIO:he,measuredBlockHeights:be,measuredParagraphLayouts:ye,documentLayout:ve,canvasSnapshotProvider:xe,inputBox:we,selectionBoxes:Se,commentHighlights:Ie,selectedImageBox:Te,selectedTextBoxBox:Pe,selectedTableBox:ke,caretBox:Re,preferredColumnX:Be,setPreferredColumnX:Me,clearPreferredColumn:Ae,onCleanupHook:Oe,persistenceStatus:De,applyTransactionalState:Ee,resetTransactionGrouping:Le,updateHistoryState:$e}=me,ze=Ja({state:()=>u,isReadOnly:R,applyTransactionalState:Ee,applyTableAwareParagraphEdit:(e,t)=>He.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:Ae,resetTransactionGrouping:Le,focusInput:L}),He=vv({clipboardActions:ze,state:u,logger:d,isReadOnly:R,applyState:m,cloneState:h,focusInput:L,focusInputAfterPointerSelection:N,focusInputSync:$,surfaceRef:fe,viewportRef:ge,zoomFactor:U.zoomFactor,insertImageFromFile:he.insertImageFromFile,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},getCommandsController:()=>it.commandsController,applyTransactionalState:Ee,clearPreferredColumn:Ae,resetTransactionGrouping:Le,updateHistoryState:$e,caretBox:Re,preferredColumnX:Be,setPreferredColumnX:Me,measuredBlockHeights:be,measuredParagraphLayouts:ye,documentLayout:ve,canvasSnapshotProvider:xe,openEquationDialog:(e,t)=>{ce({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:We,fr:Ue,tableOps:je,imageOps:Ve,textBoxOps:Ke,styleController:_e,onEditorPointerDown:Xe,tableResize:Ge,tableCornerResize:Ye,tableDrag:qe,revisionController:Ze,textDrag:Je,surfaceEventsWithTextDrag:Qe,textInput:et,handleCopy:tt,handleCut:nt,handlePaste:ot,handleDrop:rt}=He,at=Ew({state:()=>u,isReadOnly:R,applyTransactionalState:Ee,focusInput:L,access:()=>l().review}),it=Mw({clipboardActions:ze,document:me,interaction:He,commentComposer:at,state:u,logger:d,isReadOnly:R,focusInput:L,applyState:m,getStateSnapshot:g,cloneState:h,setFocused:E,setInitialLoading:H,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},locale:()=>r().locale??"pt-BR",translator:c,runtimeClient:t,runtimeOptions:l,documentOptions:a,getUiState:i,updateUiState:e=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...i(),...e}),zoom:U,importInputRef:()=>O.importInputRef,imageInputRef:()=>O.imageInputRef,setLinkDialog:V,setImageAltDialog:_,setImageCaptionDialog:G,setNewDocumentDialog:ae,setSymbolDialog:le,setEquationDialog:ce,setTablePropertiesDialog:oe}),{commandsController:lt,runtimeReady:st,runtimeEditor:ct,toolbarHost:pt,toolbarRegistry:gt,menuRegistry:ft,handleKeyDown:mt}=it,{computeFontFamilyOptions:ht,computeFontSizeOptions:bt,applyFontDialogValues:yt,applyParagraphDialogValues:vt,setParagraphDialogDefault:wt,applyTablePropertiesDialogValues:It,buildContextMenuItems:Ct,handleEditorContextMenu:Tt,closeContextMenu:Pt}=Vs({clipboardActions:ze,state:()=>u,selection:()=>u.selection,toolbarStyleState:_e.toolbarStyleState,isReadOnly:R,t:c,logger:d,setFontDialog:Q,setParagraphDialog:te,setTablePropertiesDialog:oe,setContextMenu:q,clearPreferredColumn:Ae,resetTransactionGrouping:Le,applyTransactionalState:Ee,applyTableAwareParagraphEdit:je.applyTableAwareParagraphEdit,focusInput:L,promptForLink:lt.promptForLink,tableOps:je}),{layout:Rt,overlays:Bt,refs:Mt,surfaceHandlers:Ft,inputHandlers:At,fileHandlers:Ot}=function(e){const{layout:t,overlays:n,refs:o,surface:r,input:a,files:i}=e;return{layout:{documentLayout:t.documentLayout,remoteWebFonts:t.remoteWebFonts,viewportHeight:t.viewportHeight,class:t.className,style:t.style,zoomPercent:t.zoomPercent,setZoomPercent:t.setZoomPercent,zoomFactor:t.zoomFactor},overlays:{selectionBoxes:n.selectionBoxes,commentHighlights:n.commentHighlights,onReplyToComment:n.onReplyToComment,onEditComment:n.onEditComment,canEditComment:n.canEditComment,canReplyComment:n.canReplyComment,selectedImageBox:n.selectedImageBox,selectedTextBoxBox:n.selectedTextBoxBox,selectedTableBox:n.selectedTableBox,layoutOptions:n.layoutOptions,caretBox:n.caretBox,inputBox:n.inputBox,hoveredRevision:n.hoveredRevision,focused:n.focused,showCaret:n.showCaret,importProgress:n.importProgress,imageCropMode:n.imageCropMode},refs:{onViewportRef:e=>{o.focusController.viewportRef=e},onSurfaceRef:e=>{o.focusController.surfaceRef=e},onTextareaRef:e=>{o.focusController.textareaRef=e},onImportInputRef:e=>{o.focusController.importInputRef=e},onImageInputRef:e=>{o.focusController.imageInputRef=e}},surfaceHandlers:{onDragOver:e=>e.preventDefault(),onDrop:r.handleDrop,onEditorPointerDown:r.onEditorPointerDown,onSurfacePointerDown:r.surfaceEvents.handleSurfacePointerDown,onSurfaceClick:r.surfaceEvents.handleSurfaceClick,onSurfacePointerMove:r.tableResize.handlePointerMove,onSurfaceDblClick:r.surfaceEvents.handleSurfaceDblClick,onParagraphPointerDown:r.surfaceEvents.handleParagraphPointerDown,onImagePointerDown:r.handleImagePointerDown,onImageResizeHandlePointerDown:r.handleImageResizeHandlePointerDown,onTextBoxResizeHandlePointerDown:r.handleTextBoxResizeHandlePointerDown,onImageRotateHandlePointerDown:r.handleImageRotateHandlePointerDown,onImageCropHandlePointerDown:r.handleImageCropHandlePointerDown,onImageCropBodyPointerDown:r.handleImageCropBodyPointerDown,onTextBoxRotateHandlePointerDown:r.handleTextBoxRotateHandlePointerDown,onTableDragHandlePointerDown:r.tableDrag.handlePointerDown,onTableCornerResizeHandlePointerDown:r.tableCornerResize.handlePointerDown,onRevisionMouseEnter:r.revisionController.handleRevisionMouseEnter,onRevisionMouseLeave:r.revisionController.handleRevisionMouseLeave,onEditorContextMenu:e=>r.handleEditorContextMenu(e)},inputHandlers:{onInputBlur:()=>a.setFocused(!1),onInputFocus:()=>a.setFocused(!0),onCompositionEnd:a.textInput.handleCompositionEnd,onCompositionStart:a.textInput.handleCompositionStart,onCompositionUpdate:a.textInput.handleCompositionUpdate,onCopy:a.handleCopy,onCut:a.handleCut,onInput:a.textInput.handleTextInput,onKeyDown:a.handleKeyDown,onKeyUp:a.handleKeyUp,onPaste:a.handlePaste},fileHandlers:{onImportInputChange:e=>i.handleImportFile(e.currentTarget.files?.[0]??null),onImageInputChange:e=>i.handleInsertImage(e.currentTarget.files?.[0]??null)}}}({layout:{documentLayout:ve,remoteWebFonts:a().remoteWebFonts,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:U.zoomPercent,setZoomPercent:U.setZoomPercent,zoomFactor:U.zoomFactor},overlays:{selectionBoxes:Se,commentHighlights:Ie,onReplyToComment:e=>{at.openReplyToId(e)},onEditComment:e=>{at.openEditToId(e)},canEditComment:at.canEditId,canReplyComment:at.canReplyId,selectedImageBox:Te,selectedTextBoxBox:Pe,selectedTableBox:ke,layoutOptions:We,caretBox:Re,inputBox:we,hoveredRevision:Ze.hoveredRevision,focused:D,showCaret:()=>function(e,t){if(!t.visible||!vr(e.selection))return!1;const n=Kn(e),o=dt(e.document,e.selection.anchor.paragraphId,n),r=dt(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(u,Re()),importProgress:he.importProgress,imageCropMode:Ve.cropMode},refs:{focusController:O},files:{handleImportFile:he.handleImportFile,handleInsertImage:he.handleInsertImage},surface:{surfaceEvents:Qe,tableResize:Ge,tableCornerResize:Ye,tableDrag:qe,revisionController:Ze,handleDrop:rt,onEditorPointerDown:Xe,handleImagePointerDown:Ve.handleImagePointerDown,handleImageResizeHandlePointerDown:Ve.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:Ke.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:Ve.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:Ve.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:Ve.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:Ke.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:Tt},input:{textInput:et,setFocused:E,handleCopy:tt,handleCut:nt,handlePaste:ot,handleKeyDown:e=>{if("Escape"===e.key&&He.formatPainter.mode())return He.formatPainter.cancel(),void e.preventDefault();mt(e)},handleKeyUp:e=>{He.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&He.formatPainter.applyToSelection("keyboard")}}});return Jt(()=>{ut(),Pn(),co(),sa(()=>fe()??null),Ce(),!J()&&ga()&&ue(!0)}),pe(()=>{Oe(),Qe.stopDragging(),Je.stopDrag(),Ge.stop(),Ye.stop(),qe.stop(),Ve.stopImageDrag(),Ve.stopImageResize(),Ve.stopImageCrop(),Ke.stopTextBoxResize(),v()}),f(w,{translator:c,get children(){var e=Kw();return Ne(e,"--oasis-editor-gutter-x","34px"),ko(e,f(fa,{get when(){return s(()=>!(B()||!y()))()&&C()},get children(){return f(an,{host:pt,registry:gt,get view(){return P()},get layout(){return k()}})}}),null),ko(e,f(ti,{get notice(){return ze.notice},onDismiss:()=>{ze.dismiss(),L()}}),null),ko(e,f(fa,{get when(){return at.panelOpen()},get children(){return f(Vw,{state:()=>u,composer:at,locale:()=>r().locale??"pt-BR",get onClose(){return at.closePanel},onNavigate:e=>{const t=function(e,t){const n=e.document.comments?.items;if(!n?.[t])return e;let o=n[t];const r=/* @__PURE__ */new Set;for(;o&&!o.start&&o.parentId&&!r.has(o.id);)r.add(o.id),o=n[o.parentId];const a=o?.start,i=o?.end;if(!a||!i)return e;const l=ao(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:ua(s,a.offset),focus:ua(c,i.offset)}}:e}(u,e);t!==u&&(m(t),L())}})}}),null),ko(e,f(Sd,{commentComposer:at,dialogs:{linkDialog:j,setLinkDialog:V,imageAltDialog:K,setImageAltDialog:_,imageCaptionDialog:X,setImageCaptionDialog:G,contextMenu:Y,setContextMenu:q,fontDialog:Z,setFontDialog:Q,paragraphDialog:ee,setParagraphDialog:te,tablePropertiesDialog:ne,setTablePropertiesDialog:oe,newDocumentDialog:re,setNewDocumentDialog:ae,symbolDialog:ie,setSymbolDialog:le,equationDialog:se,setEquationDialog:ce},findReplace:Ue,fontFamilyOptions:ht,fontSizeOptions:bt,contextMenuItems:Ct,focusInput:L,get applyLinkCommand(){return lt.applyLinkCommand},get applyImageAltCommand(){return lt.applyImageAltCommand},get applyImageCaptionCommand(){return lt.applyImageCaptionCommand},applyFontDialogValues:yt,applyParagraphDialogValues:vt,setParagraphDialogDefault:wt,applyTablePropertiesDialogValues:It,confirmNewDocument:()=>t.resetDocument(),insertSymbol:(e,t)=>{ct().commands.execute("insertText",{text:e,fontFamily:t}),L()},applyEquation:(e,t)=>{t?ct().commands.execute("updateEquation",{runId:t,expression:e}):ct().commands.execute("insertEquation",e),L()},closeContextMenu:Pt}),null),ko(e,f(Cd,{useComposedShell:B,shellComponent:A,runtime:{state:()=>u,toolbarHost:pt,runtimeEditor:ct,persistenceStatus:De,toolbarRegistry:gt,menuRegistry:ft},chrome:{showChrome:y,showTitleBar:x,showMenubar:S,showToolbar:C,showOutline:T,toolbarView:P,toolbarLayout:k},view:{isReadOnly:R,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:be,measuredParagraphLayouts:ye,documentLayout:ve,layout:Rt,overlays:Bt,refs:Mt,surfaceHandlers:Ft,inputHandlers:At,fileHandlers:Ot}}),null),ko(e,f(qs,{state:u,get surfaceRef(){return fe()},documentLayout:ve,snapshotProvider:xe,get zoomFactor(){return U.zoomFactor},tableResize:Ge,tableCornerResize:Ye,imageOps:Ve,tableDrag:qe,textDrag:Je}),null),ko(e,f(fa,{get when(){return z()||!st()},get children(){return f(ea,{get label(){return F()},get class(){return M()?.class},get style(){return M()?.style}})}}),null),ko(e,f(Pd,{get isOpen(){return s(()=>!(!de()||z()))()&&st()},onClose:()=>ue(!1)}),null),kt(t=>{var n=r().theme??"light",o=!!B(),a=!!R(),i=!(null===He.formatPainter.mode());return n!==t.e&&Fe(e,"data-theme",t.e=n),o!==t.t&&e.classList.toggle("oasis-editor-docs",t.t=o),a!==t.a&&e.classList.toggle("oasis-editor-read-only",t.a=a),i!==t.o&&e.classList.toggle("oasis-editor-format-painter-active",t.o=i),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e}})}export{_w as OasisEditorApp};
|