oasis-editor 0.0.328 → 0.0.329
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-CBbANoKL.js +1 -0
- package/dist/defaultToolbar-DQT_deI6.js +1 -0
- package/dist/i18n/locales/en.d.ts +12 -0
- package/dist/i18n/locales/pt-BR.d.ts +12 -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/plugins/internal/essentialsCapabilities.d.ts +1 -0
- package/dist/ui/app/essentials/builtinStyleLabel.d.ts +4 -0
- package/dist/ui/components/Toolbar/primitives/Popover.d.ts +3 -0
- package/dist/ui/components/Toolbar/primitives/usePopoverPosition.d.ts +3 -1
- package/dist/ui/components/Toolbar/schema/items.d.ts +2 -0
- package/dist/ui/components/Toolbar/styleGalleryLayout.d.ts +9 -0
- package/dist/ui/toolbarStyleState.d.ts +2 -0
- package/package.json +1 -1
- package/dist/OasisEditorApp-DypG7JZe.js +0 -1
- package/dist/defaultToolbar-BnVz03A0.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,$a as t,$n as n,$o as o,$t as r,A as a,Aa as i,An as l,Ar as s,B as c,Ba as d,Bi as u,Bn as p,Bo as g,Br as f,Bt as m,C as h,Ca as b,Ci as y,Cn as v,Co as x,Cr as w,Ct as S,D as I,Da as C,Di as T,Dn as k,Do as P,Dr as R,Dt as B,E as M,Ea as A,Ei as F,En as O,Eo as D,Er as L,Et as E,F as N,Fa as $,Fn as z,Fo as H,Fr as W,Ft as U,G as j,Ga as V,Gi as K,Gn as _,Go as X,Gr as G,Gt as Y,H as q,Ha as Z,Hi as J,Hn as Q,Ho as ee,Hr as te,Ht as ne,I as oe,Ia as re,Ii as ae,In as ie,Ir as le,It as se,J as ce,Ja as de,Ji as ue,Jn as pe,Jo as ge,Jr as fe,Jt as me,K as he,Ka as be,Ki as ye,Kn as ve,Ko as xe,Kr as we,Kt as Se,L as Ie,La as Ce,Li as Te,Ln as ke,Lo as Pe,Lr as Re,Lt as Be,M as Me,Ma as Ae,Mi as Fe,Mn as Oe,Mo as De,Mr as Le,N as Ee,Na as Ne,Ni as $e,Nn as ze,No as He,Nr as We,Nt as Ue,O as je,Oa as Ve,Oi as Ke,On as _e,Oo as Xe,Or as Ge,P as Ye,Pa as qe,Pi as Ze,Pn as Je,Po as Qe,Pr as et,Pt as tt,Q as nt,Qa as ot,Qn as rt,Qr as at,Qt as it,R as lt,Ra as st,Ri as ct,Rn as dt,Ro as ut,Rr as pt,Rt as gt,S as ft,Sa as mt,Si as ht,Sn as bt,So as yt,Sr as vt,St as xt,T as wt,Ta as St,Ti as It,Tn as Ct,To as Tt,Tr as kt,Tt as Pt,U as Rt,Ua as Bt,Ui as Mt,Un as At,Uo as Ft,Ur as Ot,Ut as Dt,V as Lt,Va as Et,Vi as Nt,Vn as $t,Vo as zt,Vr as Ht,Vt as Wt,W as Ut,Wa as jt,Wi as Vt,Wn as Kt,Wo as _t,Wr as Xt,Wt as Gt,X as Yt,Xa as qt,Xn as Zt,Xo as Jt,Xr as Qt,Xt as en,Y as tn,Ya as nn,Yi as on,Yn as rn,Yo as an,Yr as ln,Yt as sn,Z as cn,Za as dn,Zn as un,Zo as pn,Zt as gn,_ as fn,_a as mn,_i as hn,_n as bn,_o as yn,_r as vn,_t as xn,a as wn,aa as Sn,ai as In,an as Cn,ao as Tn,ar as kn,at as Pn,b as Rn,ba as Bn,bi as Mn,bn as An,bo as Fn,br as On,bt as Dn,c as Ln,ca as En,cn as Nn,co as $n,cr as zn,ct as Hn,d as Wn,da as Un,dn as jn,do as Vn,dr as Kn,dt as _n,en as Xn,eo as Gn,er as Yn,es as qn,et as Zn,f as Jn,fa as Qn,fn as eo,fo as to,fr as no,ft as oo,g as ro,ga as ao,gi as io,gn as lo,go as so,gr as co,gt as uo,h as po,ha as go,hi as fo,hn as mo,ho,hr as bo,ht as yo,i as vo,ia as xo,ii as wo,in as So,io as Io,ir as Co,it as To,j as ko,ja as Po,ji as Ro,jn as Bo,jo as Mo,jr as Ao,k as Fo,ka as Oo,kn as Do,ko as Lo,kr as Eo,l as No,la as $o,ln as zo,lo as Ho,lr as Wo,lt as Uo,m as jo,ma as Vo,mi as Ko,mn as _o,mo as Xo,mr as Go,mt as Yo,n as qo,nn as Zo,no as Jo,nr as Qo,nt as er,o as tr,oa as nr,on as or,oo as rr,or as ar,ot as ir,p as lr,pa as sr,pn as cr,po as dr,pr as ur,pt as pr,q as gr,qa as fr,qi as mr,qn as hr,qo as br,qr as yr,qt as vr,r as xr,ri as wr,rn as Sr,ro as Ir,rr as Cr,rs as Tr,s as kr,sa as Pr,sn as Rr,so as Br,sr as Mr,st as Ar,t as Fr,tn as Or,to as Dr,tr as Lr,ts as Er,tt as Nr,u as $r,ua as zr,un as Hr,uo as Wr,ur as Ur,ut as jr,v as Vr,va as Kr,vi as _r,vn as Xr,vo as Gr,vr as Yr,vt as qr,w as Zr,wa as Jr,wi as Qr,wn as ea,wo as ta,wr as na,wt as oa,x as ra,xa as aa,xi as ia,xn as la,xo as sa,xr as ca,xt as da,y as ua,ya as pa,yi as ga,yn as fa,yo as ma,yr as ha,yt as ba,z as ya,za as va,zi as xa,zn as wa,zr as Sa,zt as Ia}from"./defaultToolbar-DQT_deI6.js";function Ca(e,t){return{document:e.document,selection:t}}function Ta(e,t){if(!zr(e.selection))return ko(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=Ee(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ca(e,oe(Z(i,Math.min(r,d(i)))))}function ka(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=Ee(e),i=d(o);if(t<0&&a>0)return Ca(e,{anchor:e.selection.anchor,focus:Z(o,a-1)});if(t>0&&a<i)return Ca(e,{anchor:e.selection.anchor,focus:Z(o,a+1)});if(t<0&&r>0){const t=n[r-1];return Ca(e,{anchor:e.selection.anchor,focus:Z(t,d(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return Ca(e,{anchor:e.selection.anchor,focus:Z(t,0)})}return e}function Pa(e,t){const{paragraphs:n,index:o,offset:r}=Ee(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return Ca(e,{anchor:e.selection.anchor,focus:Z(i,Math.min(r,d(i)))})}function Ra(e){const t=Un(e);if(t.isCollapsed)return"";const n=Kr(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return Et(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(Et(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(Et(n[i]));return o.push(Et(a).slice(0,t.endParagraphOffset)),o.join("\n")}function Ba(e,t){return{...e,selection:{anchor:nr(e,t.anchor),focus:nr(e,t.focus)}}}function Ma(e){if(!zr(e.selection))return ko(e,"start");const{paragraph:t,index:n,offset:o}=Ee(e),r=Kr(e);if(o>0)return{document:e.document,selection:oe(Z(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:oe(Z(a,d(a)))}}function Aa(e){if(!zr(e.selection))return ko(e,"end");const{paragraph:t,index:n,offset:o}=Ee(e),r=Kr(e);if(o<d(t))return{document:e.document,selection:oe(Z(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:oe(Z(a,0))}}function Fa(e){const t=Un(e);if(t.isCollapsed)return"";const n=Kr(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:d(l),u=Rt(l,s,c),p=Te(l.style),g=p.length>0?` style="${p}"`:"",f=ae(u,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${g}>${f}</li>`);continue}a(),o.push(`<p${g}>${f}</p>`)}return a(),o.join("")}function Oa(e,t){if(0===t.length)return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ee(n),l=Kr(n),s=Rt(o,0,i),c=Rt(o,i,d(o)),u=t.map(e=>{const t=ho(e.runs.map(e=>({text:e.text,styles:Zo(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 p,g=oe(Z(o,i));if(1===u.length){const e=u[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=Ut(o,[...s,...e.runs.map(Xn),...c],q(o,i));n.style=o.style?{...o.style}:e.style?{...e.style}:void 0,n.list=o.list?{...o.list}:e.list?{...e.list}:void 0,p=[...r(l.slice(0,a)),n,...r(l.slice(a+1))],g=oe(Z(n,s.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=u[0],t=u[u.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),d=Ut(o,[...s,...e.runs.map(Xn)],q(o,i));d.style=o.style?{...o.style}:e.style?{...e.style}:void 0,d.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const f=u.slice(1,-1).map(gn),m=Ut(t,[...t.runs.map(Xn),...c],void 0);m.list=t.list?{...t.list}:void 0,p=[...r(l.slice(0,a)),d,...f,m,...r(l.slice(a+1))],g=oe(Z(m,n))}return Ie(n,p,g)}function Da(e){return e.map(Xn)}function La(e){return e.reduce((e,t)=>e+t.text.length,0)}function Ea(e,t,n){if(0===n.length)return e;const o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return e;const a=o[r],i=Bt(a,t),l=Da(n[0].runs);if(1===n.length){const t=c(a,i,l),n=o.map((e,n)=>n===r?t:e),s=La(l),d=Z(t,i),u=Z(t,i+s);return Ie(e,n,{anchor:d,focus:u})}const s=Rt(a,0,i),u=Rt(a,i,d(a)),p=n[n.length-1],g=n.slice(1,-1),f=Ut(gn(n[0].paragraphTemplate),[...s,...l],q(a,i)),m=g.map(e=>Ut(gn(e.paragraphTemplate),Da(e.runs))),h=Ut(gn(p.paragraphTemplate),[...Da(p.runs),...u],q(a,i)),b=[...o.slice(0,r),f,...m,h,...o.slice(r+1)],y=Z(f,La(s)),v=Z(h,La(p.runs));return Ie(e,b,{anchor:y,focus:v})}function Na(e,t,n={}){if(Un(e).isCollapsed)return e;if(function(e,t){const n=Un(e);if(n.isCollapsed)return!1;const o=Kr(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=Bt(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=Un(e);if(t.isCollapsed)return[];const n=Kr(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:d(e),l=Rt(e,a,i);o.push({paragraphTemplate:gn(e),runs:l})}return o}(e);if(0===o.length)return e;if(n.copy)return Ea(e,t,o);const r=function(e,t){const n=Un(e),o=Kr(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=Bt(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return Z(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,t);return Ea(Me(e),r,o)}function $a(e,t,n){if(0===t.length)return e;const o=zr(e.selection)?e:Me(e),{paragraph:r,index:a,offset:i}=Ee(o),l=n?{...n}:q(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 d=c(r,i,[s]),u=Kr(o).map((e,t)=>t===a?d:e);return Ie(o,u,oe(Z(d,i+t.length)))}function za(e){return $a(e,"\v")}function Ha(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 $a(e,o,n);const r=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ee(r),s=o.split("\n"),c=n?{...n}:q(a,l),u=Rt(a,0,l),p=Ut(a,[...u,yn(s[0],c)],c),g=Rt(a,l,d(a)),f=s.slice(1,-1).map(e=>gr([{text:e,styles:c}])),m=gr([{text:s[s.length-1],styles:c},...g.map(e=>({text:e.text,styles:e.styles}))]),h=Kr(r),b=[...h.slice(0,i),p,...f,m,...h.slice(i+1)];return Ie(r,b,oe(Z(m,s[s.length-1].length)))}function Wa(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ee(e),r=Kr(e);if(o>0){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<=t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o-1),...Rt(t,o,d(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o-1)))}const c=i.text[s-1],u={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()}},p=[...Rt(t,0,o-1),u,...Rt(t,o,d(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o-1)))}}const a=Ut(t,[...Rt(t,0,o-1),...Rt(t,o,d(t))],q(t,o-1)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o-1)))}if(0===n)return e;const a=r[n-1],i=Ut(a,[...a.runs.map(Xn),...t.runs.map(Xn)]),l=[...r.slice(0,n-1),i,...r.slice(n+1)];return Ie(e,l,oe(Z(i,d(a))))}function Ua(e){if(!zr(e.selection))return Me(e);const{paragraph:t,index:n,offset:o}=Ee(e),r=Kr(e);if(o<d(t)){if(e.trackChangesEnabled){const a=t.runs;let i=0,l=-1,s=-1;for(let e=0;e<a.length;e+=1){const t=i+a[e].text.length;if(o<t){l=e,s=o-i;break}i=t}if(-1!==l){const i=a[l];if("insert"===i.revision?.type){const a=[...Rt(t,0,o),...Rt(t,o+1,d(t))],i=Ut(t,a),l=r.map((e,t)=>t===n?i:e);return Ie(e,l,oe(Z(i,o)))}const c=i.text[s],u={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()}},p=[...Rt(t,0,o),u,...Rt(t,o+1,d(t))],g=Ut(t,p),f=r.map((e,t)=>t===n?g:e);return Ie(e,f,oe(Z(g,o)))}}const a=Ut(t,[...Rt(t,0,o),...Rt(t,o+1,d(t))],q(t,o)),i=r.map((e,t)=>t===n?a:e);return Ie(e,i,oe(Z(a,o)))}if(n>=r.length-1)return e;const a=r[n+1],i=Ut(t,[...t.runs.map(Xn),...a.runs.map(Xn)]),l=[...r.slice(0,n),i,...r.slice(n+2)];return Ie(e,l,oe(Z(i,o)))}function ja(e,t,n,o,r){let a=Sr(n,o,r);const i=Ce(a,t.style?.styleId,e.document.styles);return!r&&i[o]&&(a={...a,[o]:!1}),!r||"superscript"!==o&&"subscript"!==o||(a=ja(e,t,a,"superscript"===o?"subscript":"superscript",!1)),a}function Va(e,t){const n=Un(e);if(n.isCollapsed)return e;const o=Kr(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((t,o)=>{const r=n.startIndex+o,a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:d(t);return Rt(t,a,i).map(n=>({...n,styles:Ce(n.styles,t.style?.styleId,e.document.styles)}))}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.[t])),i=o.map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const i=r===n.startIndex?n.startParagraphOffset:0,l=r===n.endIndex?n.endParagraphOffset:d(o);return Ye(o,i,l,n=>({...n,styles:ja(e,o,n.styles,t,a)}))});return Ie(e,i,N(i,n))}function Ka(e,t,n){const o=Un(e);if(o.isCollapsed)return e;const r=Kr(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:d(e);return Ye(e,a,i,e=>({...e,styles:So(e.styles,t,n)}))});return Ie(e,r,N(r,o))}function _a(e,t){const n=Un(e);if(n.isCollapsed)return e;const o=Kr(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:d(e);return Ye(e,a,i,n=>{const o=(Ce(n.styles,e.style?.styleId,r).fontSize??14.6667)*Br,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:So(n.styles,"fontSize",a/Br)}})});return Ie(e,a,N(a,n))}var Xa={width:.5,type:"solid",color:"#000000"};function Ga(e,t){const n={...e??{}};return t?n.textBorder=Xa:delete n.textBorder,Object.keys(n).length>0?n:void 0}function Ya(e){return/\p{L}/u.test(e)}function qa(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=Ya(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&&Ya(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function Za(e,t){return function(e,t){const n=Un(e);if(n.isCollapsed)return e;const o=Kr(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:d(e),i=t(Rt(e,r,a).map(e=>e.text).join(""));let l=0;return Ye(e,r,a,e=>{const t=e.text.length,n=i.slice(l,l+t);return l+=t,{...e,text:n}})});return Ie(e,o,N(o,n))}(e,e=>qa(e,t))}var Ja=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function Qa(e,t){const n=Zo(e)??{};delete n.link;for(const o of Ja)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function ei(e,t){if(0===t.length)return[];const n=Un(e),o=Kr(e)[n.startIndex];if(!o)return t;const r=q(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:Qa(r,e.styles)})),style:Or(o.style),list:o.list?{...o.list}:void 0}))}function ti(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:[yn("")];n.push({runs:r.map(e=>{const t=Gn(e);return{text:e.text,styles:Zo(e.styles),image:t?{...t}:void 0}}),style:e?ye(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,mr(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,[yn(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=on(e.tagName);if(t){a(e,t);continue}if(ue(e.tagName)){r(e,mr(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=mr(e,void 0);n.length>0&&r(null,n)}return n}async function ni(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?ti(r.html):[],i="merge"===t?ei({...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?Oa(e,i):Ha(e,r.text));return l=s.document!==t.document,s}),l&&e.focusInput(),l}function oi(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 ri(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>oi(e))}catch{}return Promise.resolve(oi(e))}async function ai(e,t){const n=await function(e){const t=Ra(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=Fa(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,()=>ri(t))}catch{}return ri(t)}(e);return!n&&Ra(e)&&t?.("access-denied"),n}function ii(e){return function(e){const[t,n]=Jt();let o,r=0;pn()&&qn(()=>{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 ai(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(!Ra(t))return!1;if(!(await ai(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=>Wa(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):ni(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:()=>Ra(e.state()).length>0}}(e)}var li=/*#__PURE__*/zt("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),si=/*#__PURE__*/zt("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function ci(e){const t=Xe();let n;const[o,r]=Jt(12);br(()=>{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),qn(()=>{a.disconnect(),window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)})});return a=li(),"function"==typeof n?ee(n,a):n=a,Qe(a,xe(_t,{get when(){return e.notice()},children:n=>{return o=si(),Qe(o,xe(Qr,{name:"clipboard"}),null),Qe(o,xe(ia,{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),Qe(o,xe(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}})),an(e=>ut(a,"top",`${o()}px`)),a;var a}var di=/[\s\-–—/_([{]/;function ui(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=t.toLowerCase();if(o===n)return 1e3;const r=o.indexOf(n);if(r>=0){let e=400;return 0===r?e+=400:!function(e,t){return 0===t||di.test(e[t-1]??"")}(o,r)?e+=100:e+=200,e+=Math.round(n.length/o.length*50),e}let a=0,i=-1,l=-1,s=0;for(const d of n){const e=o.indexOf(d,a);if(-1===e)return null;-1===i&&(i=e),s+=e-a,a=e+1,l=e}const c=l-i+1;return Math.max(1,120-s-4*Math.abs(c-n.length))}function pi(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=ui(n,t.label),r=ui(n,t.command),a=Math.max(o??Number.NEGATIVE_INFINITY,(r??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var gi=/*#__PURE__*/zt("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),fi=/*#__PURE__*/zt("<div class=oasis-command-search-overlay role=presentation data-testid=editor-command-search-overlay><div class=oasis-command-search role=dialog aria-modal=true data-testid=editor-command-search>"),mi=/*#__PURE__*/zt("<kbd class=oasis-command-search-shortcut>"),hi=/*#__PURE__*/zt("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function bi(e){const t=Xe(),[n,o]=Jt(""),[r,a]=Jt(0);let i;br(()=>{e.isOpen&&(o(""),a(0),queueMicrotask(()=>{i?.focus()}))});const l=ge(()=>function(e,t,n=24){const o=e.trim().toLowerCase();if(0===o.length)return t.map(e=>({...e,score:0})).sort((e,t)=>e.label.localeCompare(t.label)).slice(0,n);const r=[];for(const a of t){const e=pi(o,a);null!==e&&r.push({...a,score:e})}return r.sort((e,t)=>t.score-e.score||e.label.length-t.label.length),r.slice(0,n)}(n(),e.entries,12));br(()=>{l(),a(e=>Math.min(e,Math.max(0,l().length-1)))});const s=t=>e.isEnabled(t.command,t.payload),c=t=>{s(t)&&e.onExecute(t)},d=e=>{const t=l().length;0!==t&&a(n=>(n+e+t)%t)},u=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),d(1);break;case"ArrowUp":t.preventDefault(),d(-1);break;case"Enter":{t.preventDefault();const e=l()[r()];e&&c(e);break}case"Escape":t.preventDefault(),e.onClose()}};return xe(_t,{get when(){return e.isOpen},get children(){var d=fi(),p=d.firstChild;return Mo(d,"click",e.onClose,!0),p.$$keydown=u,p.$$click=e=>e.stopPropagation(),Qe(p,xe(uo,{id:"editor-command-search-input",get placeholder(){return t("commandSearch.placeholder")},get value(){return n()},onChange:e=>{o(e)},ref(e){"function"==typeof i?i(e):i=e},role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":"editor-command-search-listbox",get"aria-activedescendant"(){return H(()=>!!l()[r()])()?`editor-command-search-option-${r()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),Qe(p,xe(ia,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),Qe(p,xe(_t,{get when(){return l().length>0},get fallback(){return xe(ia,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=gi();return Qe(e,xe(Ft,{get each(){return l()},children:(e,t)=>{const n=()=>t()===r(),o=()=>s(e);return(i=hi()).$$click=()=>c(e),i.addEventListener("mouseenter",()=>{a(t())}),Qe(i,xe(ia,{as:"span",get children(){return e.label}}),null),Qe(i,xe(_t,{get when(){return e.shortcut},get children(){var t=mi();return Qe(t,()=>e.shortcut),t}}),null),an(r=>{var a=`editor-command-search-option-${t()}`,l=n(),s=!o()||void 0,c=!!n(),d=!o(),u=e.command;return a!==r.e&&Pe(i,"id",r.e=a),l!==r.t&&Pe(i,"aria-selected",r.t=l),s!==r.a&&Pe(i,"aria-disabled",r.a=s),c!==r.o&&i.classList.toggle("oasis-command-search-option-active",r.o=c),d!==r.i&&i.classList.toggle("oasis-command-search-option-disabled",r.i=d),u!==r.n&&Pe(i,"data-command",r.n=u),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i;var i}})),e}}),null),Qe(p,xe(ht,{size:"sm",variant:"ghost",class:"oasis-command-search-close",get onClick(){return e.onClose},"data-testid":"editor-command-search-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),an(()=>Pe(p,"aria-label",t("commandSearch.title"))),d}})}function yi(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function vi(e){return yi(e.command)}He(["click","keydown"]);var xi=!1,wi=null,Si=null,Ii=null,Ci=[];function Ti(){"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}()?xi&&(delete window.__oasisCanvasDebug,xi=!1):xi||(window.__oasisCanvasDebug={getLastHit:()=>wi?{...wi}:null,getLayoutSnapshot:()=>Si?{...Si,surfaceRect:{...Si.surfaceRect},pages:Si.pages.map(e=>({...e})),paragraphs:Si.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:Si.inlineImages.map(e=>({...e})),inlineTextBoxes:Si.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:Si.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>Ii?{anchor:{...Ii.anchor},focus:{...Ii.focus},activeZone:Ii.activeZone,activeSectionIndex:Ii.activeSectionIndex}:null,getMissEvents:()=>Ci.map(e=>({...e})),clearMissEvents:()=>{Ci=[]}},xi=!0))}function ki(e){xi&&e&&(wi={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Pi=["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 Ri(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function Bi(e){return function(e){const[t,n]=Jt([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))Ri(r,o,i.textStyle?.fontFamily);Ri(r,o,t.fontFamily);for(const i of n)Ri(a,o,i);for(const i of Pi)Ri(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(qo);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(vo(e))}const o=vo(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 $t();e.length>0&&n(e)}}}(e)}var Mi="insertText",Ai="composition",Fi="insertImage",Oi="insertTable",Di="moveImage",Li="splitListItem",Ei="link",Ni="imageAlt",$i="imageCaption",zi="imageResize",Hi="imageCrop",Wi="imageFlip",Ui="imageRotate",ji="imageTransparency",Vi="imageReset",Ki="layoutWrapPolygon",_i="specialIndent",Xi="paraBorders",Gi="paragraphMoveUp",Yi="paragraphMoveDown",qi="findReplace",Zi="findReplaceAll",Ji="tableProperties",Qi="paragraph-dialog",el="font-dialog",tl="copyTextByDrag",nl="moveTextByDrag",ol="collapseSelectionByClick",rl="mergeTable",al="splitTable",il="insertTableColumn",ll="deleteTableColumn",sl="insertTableRow",cl="deleteTableRow",dl="tableShading",ul="tableBorders",pl="tableWidth",gl="tableAlign",fl="tableCellAlignment",ml="tableCellVerticalAlign",hl="tableCellTextDirection",bl="tableCellWidth",yl="tableColumnWidth",vl="tableToText",xl="textToTable",wl="tableSplitAtRow",Sl="tableSortAscending",Il="tableSortDescending",Cl="tableDelete",Tl="deleteTableCell",kl="tableAutoFit",Pl="tableRepeatHeaderRows",Rl="tableCellMargins",Bl="tableFormula",Ml="tableRowHeight",Al="tableStyleOptions",Fl="tableStyleGallery",Ol="tableDistribute",Dl="layoutWrapPreset",Ll="layoutFixedPosition",El="shapeFill",Nl="shapeOutline",$l="shapeOutlineWidth",zl="floatingAlign",Hl="floatingReorder",Wl="floatingNudge",Ul="floatingFixedPosition",jl="floatingRotation",Vl="floatingWrap",Kl="floatingWrapText",_l="floatingPositionPreset",Xl="shapePreset",Gl="textBoxTextDirection",Yl="textBoxVerticalAlign",ql="textBoxAlt",Zl="textBoxRotate",Jl="textBoxWidthCm",Ql="textBoxHeightCm";function es(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 ts(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function ns(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function os(e,t){const n=Ae(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 rs(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:rs(e.blocks,t)}))}))}})}function as(e,t,n){const o=Ae(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function is(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function ls(e){const t=go(e),n=A(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:is(n)}:null}function ss(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=ss(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 cs(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function ds(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?cs(e.firstPageHeader,n)?"firstPage":cs(e.evenPageHeader,n)?"evenPage":"default":cs(e.firstPageFooter,n)?"firstPage":cs(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[Bn(t,o)]??null}return null}function us(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?cs(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:cs(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?cs(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:cs(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function ps(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?ps(a.blocks,t.slice(1)):null}function gs(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=gs(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 fs(e){const t=ls(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return hs(e,r);const a=Ae(e.document)[n];return a?ds(a,o.zone,r):null}function ms(e){const t=e.selection.focus.paragraphId,n=ao(e);if("footnote"===n)return hs(e,t);const o=go(e),r=Ae(e.document)[o];return r?ds(r,n,t):null}function hs(e,t){const n=Jr(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function bs(e,t){const n=ls(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>gs(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Jr(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=Ae(e.document).map((e,t)=>t===o?us(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}function ys(e,t){const n=ls(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>ss(e,r.tablePath,t);if("footnote"===r.zone){const t=Jr(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=Ae(e.document).map((e,t)=>t===o?us(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:l}}}var vs={width:.5,type:"solid",color:"#000000"},xs={width:0,type:"none",color:"transparent"};function ws(e){const t=go(e),n=A(e.document,e.selection.anchor.paragraphId,t),o=A(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=as(e.document,t,n.zone);if(!r)return null;const a=i(r,n.tablePath),l=i(r,o.tablePath),s=a?.[a.length-1],c=l?.[l.length-1];if(!s||!c||s.table!==c.table)return null;const d=n.tablePath[n.tablePath.length-1],u=o.tablePath[o.tablePath.length-1];if(!d||!u)return null;const p=ln(s.table),g=p.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex),f=p.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex);if(!g||!f)return null;const m=Math.min(g.visualRowIndex,f.visualRowIndex),h=Math.max(g.visualRowIndex+g.rowSpan-1,f.visualRowIndex+f.rowSpan-1),b=Math.min(g.visualColumnIndex,f.visualColumnIndex),y=Math.max(g.visualColumnIndex+g.colSpan-1,f.visualColumnIndex+f.colSpan-1);return{entries:p,selectedEntries:p.filter(e=>e.visualRowIndex<=h&&e.visualRowIndex+e.rowSpan-1>=m&&e.visualColumnIndex<=y&&e.visualColumnIndex+e.colSpan-1>=b),startRow:m,endRow:h,startCol:b,endCol:y}}function Ss(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=ws(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of Po(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=Un(e),o=Kr(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:{...ts(),type:"property",previous:{...r??{}}}}),{...o,style:ns(r,t,n)}},a=Ae(e.document).map(e=>({...e,blocks:ya(e.blocks,o,r),header:e.header?ya(e.header,o,r):void 0,footer:e.footer?ya(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function Is(e,t){let n=Ss(e,"borderTop",t);return n=Ss(n,"borderRight",t),n=Ss(n,"borderBottom",t),n=Ss(n,"borderLeft",t),n}function Cs(e,t,n){const o=function(e){const t=Un(e),n=Kr(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:{...ts(),type:"property",previous:{...r??{}}}}),{...o,style:ns(r,t,n)}})(l):l});return os(e,r)}function Ts(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:{...ts(),type:"property",previous:{...a??{}}}}),{...r,style:ns(a,n,o)}};return os(e,e=>rs(e,r))}function ks(e,t,n){const o=ls(e);if(!o)return e;return ys(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:{...ts(),type:"property",previous:{...o??{}}}}),{...r,style:ns(o,t,n)}})():r);return{...r,rows:a}})}function Ps(e,t){const n=ls(e);if(!n)return e;return ys(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:{...ts(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:ns(a,"isHeader",i??null)}})}))}function Rs(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:{...ts(),type:"property",previous:{...r??{}}}}),{...t,style:ns(r,"height",n[o])}});return{...o,rows:r}};return os(e,e=>rs(e,o))}function Bs(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*Br:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Ms(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=ln(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=Bs(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?{...ts(),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={...ts(),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?{...ts(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return os(e,e=>rs(e,a))}function As(e){const t=ls(e);if(!t)return e;const n=fs(e);if(!n)return e;const o=ps(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(gn(n));return t}(o);if(0===r.length)return e;const a=bs(e,r);if(a===e)return e;const i=r[0];return{...a,selection:oe(Z(i,0))}}function Fs(e){if(ls(e))return e;if(!ms(e))return e;const t=Kr(e);if(0===t.length)return e;const n=Un(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(Os),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>Fn(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:dr("paragraph"),type:"paragraph",runs:o.length>0?o:[so("")]};return ma([r])})));return Gr(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=ao(e),r=go(e);if("footnote"===o){const o=Jr(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=Ae(e.document).map((e,a)=>a===r?us(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:oe(Z(l,0))}:e}function Os(e){const t=[];let n=[];const o=()=>{n.length>0&&t.push(n),n=[]};for(const r of e.runs){const e=r.text.split("\t");for(let t=0;t<e.length;t+=1){t>0&&o();const a=e[t];if(a.length>0){const e=Xn(r);e.id=`run:${Math.random().toString(36).slice(2,9)}`,e.text=a,n.push(e)}}}return n.length>0&&t.push(n),t}function Ds(e,t){const n=ls(e);if(!n)return e;const o=n.loc.cellIndex;return ys(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=Ls(e.cells[t]),r=Ls(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 Ls(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Es(e){return!0===e.isHeader}function Ns(e){return null!==ls(e)}function $s(e){return null!==ls(e)}var zs=/* @__PURE__ */new Set(["left","center","right"]);function Hs(e,t){const n=ls(e);if(!n)return e;if(null!==t&&!zs.has(t))return e;const o=function(e,t){const n=ls(e);if(!n)return null;const o=i(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,as(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:Cs(e,"align",a)}function Ws(e){return null!==ls(e)}var Us=["SUM","AVERAGE","COUNT","MIN","MAX"];function js(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 Us.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=ls(e);if(!o)return e;const r=fs(e);if(!r)return e;const a=ps(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=ln(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(!Ks(r,i,t))continue;if(!_s(r,i,t))continue;const e=Xs(Vs(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=ys(e,e=>({...e,rows:e.rows.map((e,t)=>t!==s?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Xo(l)]})})}));if(d===e)return e;const u=Xo(l);return{...d,selection:oe(Z(u,l.length))}}function Vs(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:Po(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Ks(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 _s(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 Xs(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 Gs(e,t){const n=function(e){const t=ls(e);if(!t)return null;const n=fs(e);if(!n)return null;const o=ps(n,t.loc.tablePath);if(!o)return null;const r=ln(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=Ys(s),u=Ys(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:Z(p,0),focus:Z(g,Et(g).length)}}:e}function Ys(e){return e.blocks.flatMap(Po)}function qs(e){const t=function(e){const t=ls(e);if(!t)return null;const n=fs(e);if(!n)return null;const o=ps(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function Zs(e){const t=ls(e);if(!t)return e;const n=fs(e);if(!n)return e;const o=ps(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=ys(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(Po)[0]??null:null;return c?{...l,selection:oe(Z(c,0))}:l}var Js={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 Qs(e){const t=go(e),n=A(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=i(function(e,t){const n=Ae(e.document)[go(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 l=ln(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:l?.visualColumnIndex??o.cellIndex}}function ec(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 tc(e){return!!e&&"none"!==e.type&&e.width>0}function nc(e,t="table"){const n=ec(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=ec(o?.style?.height),i=ec(r?.style?.width),l=e.table.gridCols?.[e.visualColumnIndex],s=ec(l),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(tc)[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{...Js,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:ec(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:tc(c.borderTop),borderRight:tc(c.borderRight),borderBottom:tc(c.borderBottom),borderLeft:tc(c.borderLeft),borderStart:tc(c.borderStart),borderEnd:tc(c.borderEnd),borderTopLeftToBottomRight:tc(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:tc(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function oc(e,t,n){return Ss(e,t,n)}function rc(e){return Boolean(Qs(e))}function ac(e,t="table"){const n=Qs(e);return n?nc(n,t):null}function ic(e){const t=()=>rc(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=ac(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=Qs(e);if(!n)return e;let o=e;return o=Ts(o,n.tableId,"width",t.tableWidth),o=Ts(o,n.tableId,"align",t.tableAlign),o=Ts(o,n.tableId,"indentLeft",t.tableIndentLeft),o=Ts(o,n.tableId,"floating",t.tableFloating),o=Ts(o,n.tableId,"tblOverlap",t.tableOverlap),o=Ts(o,n.tableId,"altTitle",t.altTitle),o=Ts(o,n.tableId,"altDescription",t.altDescription),o=Ps(o,t.repeatHeader),o=ks(o,"height",t.rowHeight),o=ks(o,"heightRule",t.rowHeightRule),o=ks(o,"cantSplit",t.cantSplit),o=ks(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Ms(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=oc(o,"width",t.cellWidth),o=oc(o,"verticalAlign",t.cellVerticalAlign),o=oc(o,"textDirection",t.cellTextDirection),o=oc(o,"noWrap",t.cellNoWrap),o=oc(o,"fitText",t.cellFitText),o=oc(o,"hideMark",t.cellHideMark),o=oc(o,"paddingTop",t.margins.top),o=oc(o,"paddingRight",t.margins.right),o=oc(o,"paddingBottom",t.margins.bottom),o=oc(o,"paddingLeft",t.margins.left),o=oc(o,"borderTop",t.borders.top),o=oc(o,"borderRight",t.borders.right),o=oc(o,"borderBottom",t.borders.bottom),o=oc(o,"borderLeft",t.borders.left),o=oc(o,"borderStart",t.borders.start),o=oc(o,"borderEnd",t.borders.end),o=oc(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=oc(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=oc(o,"shading",t.shading),o}(e,n),{mergeKey:Ji}),e.focusInput())}}}function lc(e){return function(e){const t=e.t,n=e.clipboardActions??ii({...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=!zr(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 sc(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),rl),split:()=>o(e=>n.splitSelectedTable(e),al),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),il),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),il),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),ll),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),sl),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),sl),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),cl)}}function cc(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=Bi({state:e.state,toolbarStyleState:e.toolbarStyleState}),r=function(e){return{openFontDialog:()=>{var t;e.loadLocalFontFamilyOptions(),e.setFontDialog({isOpen:!0,initial:(t=e.toolbarStyleState(),{fontFamily:t.fontFamily??"",fontSize:wn(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()||(zr(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=Ka(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=Ka(o,"fontSize",kr(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=Ka(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=Ka(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=Ka(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=Va(o,"bold")),t.italic!==Boolean(n.italic)&&(o=Va(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=Ka(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=Ka(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=Va(o,"underline")),t.strike!==Boolean(n.strike)&&(o=Va(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=Va(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=Va(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=Va(o,"subscript")),t.superscript&&t.subscript&&(o=Va(o,"subscript")),t.strike&&t.doubleStrike&&(o=Va(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=Va(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=Va(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=Va(o,"hidden"));const l=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(l??null)&&(o=Ka(o,"characterScale",t.characterScale));const s=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(s??null)&&(o=Ka(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=Ka(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=Ka(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=Ka(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=Ka(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=Ka(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=Ka(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=Va(o,"contextualAlternates")),o},{mergeKey:el})),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}),a=r.openFontDialog,i=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 r=e;t.align!==(n.align||null)&&(r=je(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=je(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=je(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=je(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=je(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=je(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=je(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=je(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=je(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=je(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=je(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=je(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=je(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=je(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=je(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=je(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=je(r,"widowControl",t.widowControl)),JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=je(r,"tabs",t.tabs.length>0?t.tabs:null));const l="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,s={borderTop:n.borderSideTop?l:null,borderRight:n.borderSideRight?l:null,borderBottom:n.borderSideBottom?l:null,borderLeft:n.borderSideLeft?l:null},c={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(c[t])!==JSON.stringify(s[t])&&(r=je(r,t,c[t]));return r},{mergeKey:Qi}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=$(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:es(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}),l=i.openParagraphDialog,s=ic({state:e.state,isReadOnly:e.isReadOnly,setTablePropertiesDialog:e.setTablePropertiesDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),c=s.openTablePropertiesDialog,d=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},u=lc({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:a,openParagraphDialog:l,table:sc({state:e.state,tableOps:e.tableOps,isInsideTable:s.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:s.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function dc(e){const t=ge(()=>{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=Kr(e.state).find(e=>e.id===t.paragraphId),r=n?Bt(n,t):0,a=fo(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=hn(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 xe(_t,{get when(){return t()},children:e=>xe(z,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var uc=/*#__PURE__*/zt("<div class=oasis-editor-table-resize-guide>"),pc=/*#__PURE__*/zt("<div class=oasis-editor-table-resize-outline>"),gc=/*#__PURE__*/zt("<img class=oasis-editor-image-ghost>"),fc=/*#__PURE__*/zt("<div class=oasis-editor-table-ghost>");function mc(e){return[xe(_t,{get when(){return e.tableResize.resizing()},children:e=>{return t=uc(),an(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=g(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),xe(_t,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=pc(),an(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&ut(t,"left",n.e=o),r!==n.t&&ut(t,"top",n.t=r),a!==n.a&&ut(t,"width",n.a=a),i!==n.o&&ut(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),xe(_t,{get when(){return H(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=gc(),an(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&&Pe(n,"src",o.e=r),a!==o.t&&ut(n,"width",o.t=a),i!==o.a&&ut(n,"height",o.a=i),l!==o.o&&ut(n,"left",o.o=l),s!==o.i&&ut(n,"top",o.i=s),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),xe(_t,{get when(){return H(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=fc(),an(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&&ut(n,"width",o.e=r),a!==o.t&&ut(n,"height",o.t=a),i!==o.a&&ut(n,"left",o.a=i),l!==o.o&&ut(n,"top",o.o=l),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),xe(_t,{get when(){return H(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>xe(dc,{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})}),xe(_t,{get when(){return H(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>xe(dc,{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})}),xe(_t,{get when(){return H(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>xe(dc,{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 hc(e){return[xe(Je,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),xe(Je,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function bc(e){const t=Xe(),[n,o]=Jt(e.initialValue);let r;br(()=>{e.isOpen&&(o(e.initialValue),setTimeout(()=>r?.focus(),50))});const a=()=>{e.onConfirm(n()),e.onClose()};return xe(xt,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return xe(hc,{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 xe(uo,{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 yc(e){const t=Xe();return xe(bc,{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 vc(e){const t=Xe();return xe(bc,{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 xc(e){const t=Xe();return xe(bc,{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 wc=/*#__PURE__*/zt("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),Sc=/*#__PURE__*/zt("<div class=oasis-editor-comment-composer>");function Ic(e){const t=Xe(),[n,o]=Jt(""),[r,a]=Jt("");let i;const l=e.composer.draft,s=()=>("edit"===l()?.mode||n().trim().length>0)&&r().trim().length>0,c=()=>{s()&&e.composer.submit(n(),r())};return br(()=>{l()&&(o("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),a("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>i?.focus()))}),xe(xt,{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[xe(Je,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),xe(Je,{variant:"primary",get disabled(){return!s()},onClick:c,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var s=Sc();return Qe(s,xe(_t,{get when(){return"reply"===l()?.mode},get children(){var e=wc();return Qe(e,xe(ia,{as:"strong",get children(){return[H(()=>t("comment.replyTo"))," ",H(()=>l()?.parentAuthor)]}}),null),Qe(e,xe(ia,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),Qe(s,xe(uo,{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),Qe(s,xe(yo,{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(),c())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),s}})}var Cc=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],Tc=[33,50,66,75,90,100,105,110,115,120,150,200];function kc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Pc(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function Rc(e){return null==e||""===e?"":String(e)}function Bc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Mc(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function Ac(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Fc(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 Oc(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 Dc(e,t){const n=[],o=Ac(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Lc(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 Ec(e){return{characterScale:Rc(e.characterScale),spacingMode:Bc(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Mc(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:Rc(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:Rc(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function Nc(e){const t=Xe(),[n,o]=Jt("font"),[r,a]=Jt(Lc(e.initial)),[i,l]=Jt(Ec(e.initial));br(()=>{e.isOpen&&(o("font"),a(Lc(e.initial)),l(Ec(e.initial)))});const s=ge(()=>{return e=r().bold,t=r().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),c=ge(()=>{const t=r().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),d=ge(()=>{const t=new Set(Cc);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=ge(()=>{const e=r().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),p=ge(()=>{const e=i();return e.characterScale.trim()&&null===kc(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Pc(e.spacingAmount)||"normal"!==e.positionMode&&null===Pc(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Pc(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===Ac(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),g=ge(()=>function(e,t){const n=Number(e.fontSize),o=kc(t.characterScale)??100,r="normal"===t.spacingMode?null:Pc(t.spacingAmount),a="normal"===t.positionMode?null:Pc(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":Fc(t.ligatures),"font-variant-numeric":Oc(t.numberSpacing,t.numberForm),"font-feature-settings":Dc(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()?kc(t.characterScale):null,l="normal"===t.spacingMode?null:Pc(t.spacingAmount),s="normal"===t.positionMode?null:Pc(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Pc(t.kerningThreshold):null,d=Ac(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 $c=/*#__PURE__*/zt("<div>");function zc(e){const t=Xe();return n=$c(),Qe(n,()=>t("dialog.font.previewText")),an(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&De(n,t.e=o),r!==t.t&&Pe(n,"data-testid",t.t=r),t.a=g(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Hc=/*#__PURE__*/zt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Wc(e){const t=Xe(),{ctrl:n}=e;return o=Hc(),Qe(o,xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:12,get children(){return xe(uo,{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"})}}),xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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}))]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(oo,{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)}))]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return[xe(uo,{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"}),xe(Dn,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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),Qe(o,xe(qr,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[xe(qr,{size:{xs:12,md:4},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(Yo,{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"})}}),xe(qr,{size:{xs:12,md:2},get children(){return xe(Yo,{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"})}}),xe(qr,{size:{xs:12,md:2},get children(){return xe(Yo,{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),Qe(o,xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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")},...nt.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(Yo,{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),Qe(o,xe(xn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return xe(Ft,{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=>xe(Ar,{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),Qe(o,xe(xn,{get label(){return t("dialog.font.preview")},get children(){return xe(zc,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var Uc=/*#__PURE__*/zt("<div class=oasis-editor-font-dialog-kerning-line>"),jc=/*#__PURE__*/zt('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function Vc(e){const t=Xe(),{ctrl:n}=e;return o=jc(),Qe(o,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:4},get children(){return xe(oo,{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 Tc.map(e=>({value:String(e),label:`${e}%`}))}})}}),xe(qr,{size:{xs:12,md:8},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(uo,{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"})}})]}})}}),xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(uo,{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"})}}),xe(qr,{size:12,get children(){var e=Uc();return Qe(e,xe(pr,{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),Qe(e,xe(uo,{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),Qe(e,xe(Dn,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),Qe(o,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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)}))]}})}})]}}),xe(pr,{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),Qe(o,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return xe(zc,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),Qe(o,xe(Dn,{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 Kc(e){const t=Xe(),n=Nc(e);return xe(xt,{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 xe(hc,{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 xe(da,{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:xe(Wc,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:xe(Vc,{ctrl:n})}]}})}})}var _c=/*#__PURE__*/zt("<div class=oasis-editor-tab-stops><div class=oasis-editor-tab-stops-actions>"),Xc=/*#__PURE__*/zt("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Gc(e){return{position:e.position,type:e.type,leader:e.leader??"none"}}function Yc(e){const t=Xe(),[n,o]=Jt([]);br(()=>{e.isOpen&&o(e.initial.map(Gc))});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 xe(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},get footer(){return n=Xc(),r=n.firstChild,a=r.nextSibling,Qe(r,xe(Je,{variant:"secondary",onClick:()=>{o([])},"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}})),Qe(a,xe(Je,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),null),Qe(a,xe(Je,{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=_c(),i=e.firstChild;return Qe(e,xe(Ft,{get each(){return n()},get fallback(){return xe(Dn,{as:"p",class:"oasis-editor-dialog-help-text",get children(){return t("paragraph.tabsEmpty")}})},children:(e,n)=>xe(qr,{container:!0,spacing:1.5,alignItems:"flex-end",get children(){return[xe(qr,{size:{xs:12,md:4},get children(){return xe(_n,{get label(){return t("paragraph.tabsPosition")},step:"1",get value(){return e.position??""},onChange:e=>r(n(),{position:e})})}}),xe(qr,{size:{xs:6,md:3},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:6,md:3},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:2},get children(){return xe(Je,{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),Qe(i,xe(Je,{variant:"secondary",icon:"plus",onClick:a,"data-testid":"editor-tab-stops-add",get children(){return t("paragraph.tabsAdd")}})),e}})}var qc=96/72;function Zc(e){const[t,n]=Jt(""),[o,r]=Jt(""),[a,i]=Jt(null),[l,s]=Jt(null),[c,d]=Jt("none"),[u,p]=Jt(null),[g,f]=Jt(!1),[m,h]=Jt(null),[b,y]=Jt(null),[v,x]=Jt("multiple"),[w,S]=Jt(null),[I,C]=Jt(!1),[T,k]=Jt(""),[P,R]=Jt("none"),[B,M]=Jt(null),[A,F]=Jt(""),[O,D]=Jt(!1),[L,E]=Jt(!1),[N,$]=Jt(!1),[z,H]=Jt(!1),[W,U]=Jt(!1),[j,V]=Jt(!1),[K,_]=Jt(!1),[X,G]=Jt(!0),[Y,q]=Jt([]);br(()=>{if(e.isOpen){n(e.initial.align??""),r(e.initial.outlineLevel??""),i(cn(e.initial.indentLeft??"")),s(cn(e.initial.indentRight??"")),f(e.initial.mirrorIndents??!1),h(cn(e.initial.spacingBefore??"")),y(cn(e.initial.spacingAfter??"")),C(e.initial.contextualSpacing??!1),k(e.initial.shading??"");const{mode:a,at:l}=(t=e.initial.lineRule??"",o=cn(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==o?Math.round(o/qc):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(cn(e.initial.borderWidth??"")),F(e.initial.borderColor??""),D(e.initial.borderSideTop??!1),E(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=cn(e.initial.indentFirstLine??""),g=cn(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()*qc:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==w()?w()*qc:null,lineRule:"exact"}}},J=ge(()=>{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"!==P()?`${B()??.5}pt ${P()} ${A().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&&L()?s:void 0,"border-bottom":s&&N()?s:void 0,"border-left":s&&z()?s:void 0}}),Q=()=>{const e=P();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:A().trim()||"#000000"};return{top:O()?n:null,right:L()?n:null,bottom:N()?n:null,left:z()?n:null}},ee=()=>{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:Q(),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:k,borderStyle:P,setBorderStyle:R,borderWidth:B,setBorderWidth:M,borderColor:A,setBorderColor:F,sideTop:O,setSideTop:D,sideRight:L,setSideRight:E,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(ee(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(ee()),e.onClose()}}}var Jc=/*#__PURE__*/zt("<div class=oasis-editor-paragraph-dialog-panel>"),Qc=/*#__PURE__*/zt("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),ed=/*#__PURE__*/zt("<div>"),td=/*#__PURE__*/zt("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function nd(e){const t=Xe(),[n,o]=Jt(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:l,indentLeft:s,setIndentLeft:c,indentRight:d,setIndentRight:u,special:p,setSpecial:f,specialBy:m,setSpecialBy:h,mirrorIndents:b,setMirrorIndents:y,spacingBefore:v,setSpacingBefore:x,spacingAfter:w,setSpacingAfter:S,lineMode:I,setLineMode:C,lineAt:T,setLineAt:k,contextualSpacing:P,setContextualSpacing:R,shading:B,setShading:M,borderStyle:A,setBorderStyle:F,borderWidth:O,setBorderWidth:D,borderColor:L,setBorderColor:E,sideTop:N,setSideTop:$,sideRight:z,setSideRight:H,sideBottom:W,setSideBottom:U,sideLeft:j,setSideLeft:V,pageBreakBefore:K,setPageBreakBefore:_,keepWithNext:X,setKeepWithNext:G,keepLinesTogether:Y,setKeepLinesTogether:q,widowControl:Z,setWidowControl:J,tabs:Q,setTabs:ee,atEnabled:te,previewStyle:ne,handleApply:oe,handleSetDefault:re}=Zc(e),ae=xe(oo,{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")}]}}),ie=xe(oo,{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])}))]}}),le=(se=Jc(),Qe(se,xe(Hn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},children:ae}),xe(qr,{size:{xs:12,md:6},children:ie})]}})}}),null),Qe(se,xe(Hn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},get children(){return xe(_n,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return s()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(_n,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:u,"data-testid":"editor-paragraph-dialog-indent-right"})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{get label(){return t("paragraph.specialLabel")},get value(){return p()},onChange:e=>{const t=e;f(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")}]}})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(_n,{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"})}}),xe(qr,{size:12,get children(){return xe(pr,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return b()},onChange:y,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),Qe(se,xe(Hn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:4},get children(){return xe(_n,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return v()??""},onChange:x,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(_n,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return w()??""},onChange:S,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),xe(qr,{size:{xs:12,md:4}}),xe(qr,{size:{xs:12,md:8},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(_n,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===I()?"0.05":"1"},get disabled(){return!te()},get value(){return T()??""},onChange:k,"data-testid":"editor-paragraph-dialog-line-at"})}}),xe(qr,{size:12,get children(){return xe(pr,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return P()},onChange:R,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),Qe(se,xe(Hn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:3},get children(){return xe(oo,{get label(){return t("paragraph.borderStyleLabel")},get value(){return A()},onChange:e=>{const t=e;F(t),"none"===t?($(!1),H(!1),U(!1),V(!1)):N()||z()||W()||j()||($(!0),H(!0),U(!0),V(!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")}]}})}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(_n,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===A()},get value(){return O()??""},onChange:D,"data-testid":"editor-paragraph-dialog-border-width"})}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(Yo,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===A()},get value(){return L()||"#000000"},onChange:E,"data-testid":"editor-paragraph-dialog-border-color"})}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(Yo,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:M,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),xe(xn,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[xe(pr,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===A()},get checked(){return N()},onChange:$,"data-testid":"editor-paragraph-dialog-border-side-top"}),xe(pr,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===A()},get checked(){return z()},onChange:H,"data-testid":"editor-paragraph-dialog-border-side-right"}),xe(pr,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===A()},get checked(){return W()},onChange:U,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),xe(pr,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===A()},get checked(){return j()},onChange:V,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),se);var se;const ce=(de=Jc(),Qe(de,xe(Hn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return xe(ba,{direction:"column",spacing:1,get children(){return[xe(pr,{get label(){return t("paragraph.widowControlLabel")},get checked(){return Z()},onChange:J,"data-testid":"editor-paragraph-dialog-widow-control"}),xe(pr,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return X()},onChange:G,"data-testid":"editor-paragraph-dialog-keep-with-next"}),xe(pr,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Y()},onChange:q,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),xe(pr,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return K()},onChange:_,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),de);var de,ue;return ue=ed(),Qe(ue,xe(xt,{get isOpen(){return e.isOpen},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",testId:"editor-paragraph-dialog",get footer(){return n=td(),r=n.firstChild,a=r.nextSibling,Qe(r,xe(Je,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),Qe(r,xe(Je,{variant:"secondary",onClick:re,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),Qe(a,xe(Je,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),Qe(a,xe(Je,{variant:"primary",onClick:oe,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[xe(da,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:le,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:ce,testId:"editor-paragraph-dialog-tab-breaks"}]}}),xe(xn,{get label(){return t("paragraph.preview")},get children(){var e=Qc();return Qe(e,()=>t("paragraph.previewText")),an(t=>g(e,ne(),t)),e}})]}}),null),Qe(ue,xe(Yc,{get isOpen(){return n()},get initial(){return Q()},onClose:()=>{o(!1)},onApply:ee}),null),ue}function od(e,t){const n=cn(e);return null===n?null:"percent"===t?`${n}%`:n}function rd(e,t,n){if("none"===e)return null;const o=cn(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function ad(e){const[t,n]=Ro({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:""});br(()=>{var t;e.isOpen&&n(Fe({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=rd(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:od(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:od(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:cn(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:cn(e.floatingY)??0},distanceTop:cn(e.floatingDistanceTop)??0,distanceRight:cn(e.floatingDistanceRight)??0,distanceBottom:cn(e.floatingDistanceBottom)??0,distanceLeft:cn(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:od(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:od(e.columnWidth,"points"),cellWidth:od(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:cn(e.marginTop),right:cn(e.marginRight),bottom:cn(e.marginBottom),left:cn(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 id(e,t,n,o,r=!1,a=!1){return xe(uo,{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 ld=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-panel>");function sd(e){const t=Xe(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=ld(),Qe(r,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},get children(){return id(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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),Qe(r,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[xe(jr,{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=>xe(Uo,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),xe(qr,{container:!0,spacing:1.5,get children(){return xe(qr,{size:{xs:12,md:6},get children(){return id(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),Qe(r,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[xe(pr,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),xe(pr,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),xe(_t,{get when(){return"around"===n().tableWrapping},get children(){return[xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(oo,{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}))]}})}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(oo,{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}))]}})}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),xe(pr,{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 cd=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-panel>");function dd(e){const t=Xe(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=cd(),Qe(r,xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:6},get children(){return id(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),xe(qr,{size:{xs:12,md:6},get children(){return xe(oo,{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),Qe(r,xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[xe(pr,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),xe(pr,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),xe(pr,{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 ud=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-panel>");function pd(e){const t=Xe(),n=e.ctrl.set;return o=ud(),Qe(o,xe(qr,{container:!0,spacing:1.5,get children(){return xe(qr,{size:{xs:12,md:6},get children(){return id(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var gd=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),fd=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-panel>");function md(e){const t=Xe(),n=()=>e.ctrl.form,o=e.ctrl.set,r=ge(()=>{const e=rd(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=fd(),Qe(i,xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:4},get children(){return id(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:4},get children(){return xe(oo,{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),Qe(i,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[xe(pr,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),xe(pr,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),xe(pr,{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),Qe(i,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:3},get children(){return id(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),Qe(i,xe(Hn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[xe(qr,{container:!0,spacing:1.5,get children(){return[xe(qr,{size:{xs:12,md:3},get children(){return xe(oo,{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")}]}})}}),xe(qr,{size:{xs:12,md:3},get children(){return id(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(Yo,{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"})}}),xe(qr,{size:{xs:12,md:3},get children(){return xe(Yo,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),xe(ba,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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"}),xe(pr,{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=gd(),an(t=>g(e,r(),t)),e)];var e}}),null),i;var i}var hd=/*#__PURE__*/zt("<div class=oasis-editor-table-properties-panel>");function bd(e){const t=Xe(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=hd(),Qe(r,xe(uo,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),Qe(r,xe(yo,{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 yd(e){const t=Xe(),n=ad(e);return xe(xt,{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 xe(hc,{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 xe(da,{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:xe(sd,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:xe(dd,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:xe(pd,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:xe(md,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:xe(bd,{ctrl:n})}]}})}})}var vd=/*#__PURE__*/zt("<p data-testid=editor-new-document-message>");function xd(e){const t=Xe();return xe(xt,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return xe(hc,{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=vd();return Qe(e,()=>t("dialog.newDocument.message")),e}})}function wd(e){const t=Xe(),n=()=>"accept"===e.action;return xe(xt,{get isOpen(){return e.isOpen},get title(){return t(n()?"review.bulkAcceptTitle":"review.bulkRejectTitle")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",testId:"editor-revision-bulk-dialog",get footer(){return xe(hc,{get onCancel(){return e.onClose},get onConfirm(){return e.onConfirm},get cancelLabel(){return t("generic.cancel")},get confirmLabel(){return t(n()?"toolbar.acceptAll":"toolbar.rejectAll")},cancelTestId:"editor-revision-bulk-cancel",confirmTestId:"editor-revision-bulk-confirm"})},get children(){return xe(ia,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var Sd=/*#__PURE__*/zt("<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>"),Id=/*#__PURE__*/zt("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),Cd=/*#__PURE__*/zt("<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>"),Td=/*#__PURE__*/zt("<option>"),kd=/*#__PURE__*/zt("<button type=button class=oasis-editor-symbol-dialog-tile>"),Pd=/*#__PURE__*/zt("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),Rd=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function Bd(e){const t=Xe(),[n,o]=Jt("common"),[r,a]=Jt(Wn[0]),[i,l]=Jt(Rd[0]),[s,c]=Jt(Wn[0].codePoint),d=ge(()=>(e.isOpen,No())),u=ge(()=>"all"===n()?Jn.flatMap(e=>e.entries):Jn.find(e=>e.id===n())?.entries??Wn),p=e=>{a(e),c(e.codePoint)},g=()=>{const t=r().character;t&&($r(t),e.onInsert(t,i()),e.onClose())};return xe(xt,{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[xe(Je,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),xe(Je,{variant:"primary",onClick:g,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(w=Sd(),S=w.firstChild,I=S.firstChild,C=I.nextSibling,T=S.nextSibling.firstChild,k=T.nextSibling,P=k.firstChild,Qe(I,()=>t("dialog.symbol.font")),C.addEventListener("change",e=>{l(e.currentTarget.value)}),Qe(C,xe(Ft,{each:Rd,children:e=>{return(t=Td()).value=e,Qe(t,e),t;var t}})),Qe(T,()=>t("dialog.symbol.subset")),k.addEventListener("change",e=>{o(e.currentTarget.value)}),Qe(P,()=>t("symbols.category.all")),Qe(k,xe(Ft,{each:Jn,children:e=>{return n=Td(),Qe(n,()=>t(e.labelKey)),an(()=>n.value=e.id),n;var n}}),null),an(()=>C.value=i()),an(()=>k.value=n()),w),(e=Cd(),f=e.firstChild,m=f.nextSibling.firstChild,h=m.nextSibling,b=h.nextSibling,y=b.firstChild,v=y.nextSibling,x=b.nextSibling,Qe(f,xe(_t,{get when(){return d().length>0},get children(){var e=Id(),n=e.firstChild,o=n.nextSibling;return Qe(n,()=>t("dialog.symbol.recent")),Qe(o,xe(Ft,{get each(){return d()},children:e=>{return(t=kd()).$$click=()=>p(e),Qe(t,()=>e.character),an(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&Pe(t,"title",n.e=o),r!==n.t&&Pe(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),Qe(f,xe(Ft,{get each(){return u()},children:e=>{return(t=Pd()).$$dblclick=g,t.$$click=()=>p(e),Qe(t,()=>e.character),an(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&&Pe(t,"title",n.t=a),i!==n.a&&Pe(t,"aria-label",n.a=i),l!==n.o&&Pe(t,"data-testid",n.o=l),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),Qe(m,()=>t("dialog.symbol.preview")),Qe(h,()=>r().character),Qe(y,()=>t("dialog.symbol.code")),v.$$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),Pe(v,"spellcheck",!1),Qe(x,()=>t("dialog.symbol.doubleClickHelp")),an(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&Pe(f,"aria-label",e.e=n),o!==e.t&&ut(h,"font-family",e.t=o),e},{e:void 0,t:void 0}),an(()=>v.value=s()),e)];var e,f,m,h,b,y,v,x,w,S,I,C,T,k,P}})}He(["input","click","dblclick"]);var Md=/*#__PURE__*/zt("<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>"),Ad=/*#__PURE__*/zt("<button type=button data-testid=editor-equation-template>"),Fd=[["\\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 Od(e){const t=Xe(),[n,o]=Jt(""),[r,a]=Jt(Ir);br(()=>{if(!e.isOpen)return;const t=e.initial??Ir;a(t),o(L(t))});const i=e=>{o(e),a(kt(e))};return xe(xt,{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[xe(Je,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),xe(Je,{variant:"primary",onClick:()=>e.onApply(r()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Md(),o=e.firstChild,a=o.nextSibling,l=a.firstChild,s=l.nextSibling,c=a.nextSibling;return Qe(o,xe(Ft,{each:Fd,children:([e,t])=>{return(n=Ad()).$$click=()=>i(t),Qe(n,e),n;var n}})),Qe(l,()=>t("dialog.equation.linear")),s.$$input=e=>i(e.currentTarget.value),Pe(s,"spellcheck",!1),Qe(c,()=>L(r())||t("dialog.equation.empty")),an(()=>Pe(o,"aria-label",t("dialog.equation.structures"))),an(()=>s.value=n()),e}})}He(["input","click"]);var Dd=/*#__PURE__*/zt("<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 Ld(e){const t=Xe(),{fr:n}=e,o=e=>{n.isOpen()&&"Escape"===e.key&&n.setIsOpen(!1)},r=e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?n.findPrevious():n.findNext())};return Er(()=>{window.addEventListener("keydown",o,!0)}),qn(()=>{window.removeEventListener("keydown",o,!0)}),xe(_t,{get when(){return n.isOpen()},get children(){var e=Dd(),o=e.firstChild,a=o.nextSibling,i=a.firstChild,l=i.firstChild,s=i.nextSibling;return e.$$keydown=r,Qe(o,xe(ia,{get children(){return t("find.title")}}),null),Qe(o,xe(ht,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),Qe(l,xe(uo,{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),Qe(l,xe(Dn,{class:"oasis-editor-fr-counter",get children(){return H(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),Qe(i,xe(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[xe(ht,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),xe(ht,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),Qe(s,xe(uo,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),Qe(s,xe(ba,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[xe(ht,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),xe(ht,{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),Qe(a,xe(ba,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[xe(pr,{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})}),xe(pr,{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}})}He(["keydown"]);var Ed=/*#__PURE__*/zt("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),Nd=/*#__PURE__*/zt("<i>"),$d=/*#__PURE__*/zt("<span class=oasis-editor-context-menu-shortcut>"),zd=/*#__PURE__*/zt("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),Hd=/*#__PURE__*/zt("<div class=oasis-editor-context-menu-separator>"),Wd=/*#__PURE__*/zt("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function Ud(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 Er(()=>{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)}),qn(()=>{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)}),br(()=>{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`}),xe(_t,{get when(){return e.isOpen},get children(){var n=Ed();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?ee(t,n):t=n,Qe(n,xe(Ft,{get each(){return e.items},children:t=>xe(_t,{get when(){return"separator"!==t.type},get fallback(){return Hd()},get children(){var n=zd(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},Qe(n,xe(_t,{get when(){return t.icon},get fallback(){return e=Wd(),Qe(e,xe(y,{size:16})),e;var e},get children(){var e=Nd();return an(()=>Pe(e,"data-lucide",t.icon)),e}}),o),Qe(o,()=>t.label),Qe(n,xe(_t,{get when(){return t.shortcut},get children(){var e=$d();return Qe(e,()=>t.shortcut),e}}),null),an(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&Pe(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),an(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&ut(n,"left",t.e=o),r!==t.t&&ut(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function jd(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:f,setNewDocumentDialog:m,revisionBulkDialog:h,setRevisionBulkDialog:b,symbolDialog:y,setSymbolDialog:v,equationDialog:x,setEquationDialog:w}=e.dialogs;return[xe(xd,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),xe(wd,{get isOpen(){return h().isOpen},get action(){return h().action},get count(){return h().count},onClose:()=>{b({...h(),isOpen:!1}),e.focusInput()},onConfirm:()=>{const t=h().action;b({...h(),isOpen:!1}),e.applyBulkRevisions(t)}}),xe(Bd,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),xe(Od,{get isOpen(){return x().isOpen},get initial(){return x().initial},onClose:()=>{w({isOpen:!1}),e.focusInput()},onApply:t=>{w({isOpen:!1}),e.applyEquation(t,x().targetRunId)}}),xe(yc,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),xe(vc,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),xe(xc,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),xe(Ic,{get composer(){return e.commentComposer}}),xe(Ld,{get fr(){return e.findReplace}}),xe(Kc,{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}}),xe(nd,{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}}),xe(yd,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),xe(Ud,{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}})]}He(["contextmenu","click"]);var Vd=/*#__PURE__*/zt("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function Kd(e){let t,n;const o=tt(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=Ue({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[xe(_t,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return xe(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 showRuler(){return o.showRuler()},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}})})()}}),xe(_t,{get when(){return!e.useComposedShell()},get children(){return xe(E,{get editor(){return e.runtime.runtimeEditor},get children(){var l=Vd(),s=l.firstChild;return Qe(l,xe(_t,{get when(){return e.chrome.showOutline()},get children(){return xe(Ko,{get state(){return e.runtime.state()},onNavigate:i,surfaceRef:()=>t,viewportRef:()=>n,get documentLayout(){return e.view.documentLayout},get zoomFactor(){return e.view.layout.zoomFactor},snapshotProvider:o})}}),s),Qe(s,xe(U,{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,onSurfaceRef:r,onViewportRef:a}},get surfaceHandlers(){return e.view.surfaceHandlers},get inputHandlers(){return e.view.inputHandlers},get fileHandlers(){return e.view.fileHandlers}})),l}})}})]}var _d=/*#__PURE__*/zt("<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 Xd(e){const t=Xe(),n=()=>{wa(),_(),e.onClose()},o=()=>{Kt(!1),_(),e.onClose()};return xe(_t,{get when(){return e.isOpen},get children(){var e=_d(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,l=i.nextSibling,s=l.nextSibling;return Qe(r,xe(D,{height:72,class:"oasis-editor-welcome-mark"}),a),Qe(a,()=>t("welcome.title")),Qe(i,()=>t("welcome.body")),Qe(l,()=>t("welcome.note")),Qe(s,xe(Je,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),Qe(s,xe(Je,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}var Gd=/* @__PURE__ */Tr(Ct(),1),Yd=ea(),qd="word/comments.xml";function Zd(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 Jd(e){return e.localName??e.tagName}function Qd(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 eu(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 tu(e){let t="";for(const n of Zd(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===Jd(n)){t+=n.textContent??"";continue}if("tab"===Jd(n)){t+="\t";continue}if("br"===Jd(n)||"cr"===Jd(n)){t+="\n";continue}}t+=tu(n)}return t}function nu(e){return Zd(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===Jd(e))}function ou(e){return nu(e).map(tu).join("\n").trim()}function ru(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===Jd(t)?t:void 0}function au(e,t){const n=Qd(nu(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=nu(t)[0];n&&o&&o.setAttributeNS(eo,"w14:paraId",n)}function iu(e,t){const n=nu(e),o=nu(t);n[0]&&o[0]&&jn(n[0],o[0]);const r=new Set(Zd(t).filter(e=>e.namespaceURI!==cr).map(e=>`${e.namespaceURI??""}\0${Jd(e)}`));for(const a of Zd(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${Jd(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function lu(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(qd);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=ru(e),o=ru(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Zd(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Jd(i))continue;const e=Qd(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of Zd(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==Jd(i))continue;const e=Qd(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new Yd.XMLSerializer).serializeToString(t);eu(i,t),ou(i)===ou(t)?au(i,t):iu(i,t),(new Yd.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new Yd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(qd,a),!0)}var su="http://schemas.microsoft.com/office/word/2012/wordml",cu="word/commentsExtended.xml";function du(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 uu(e){return e.localName??e.tagName}function pu(e){return`${e.namespaceURI??""}\0${uu(e)}`}function gu(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 fu(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function mu(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 hu(e){const t=/* @__PURE__ */new Map,n=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(cr,"comment"))){const e=gu(o,"id"),n=o.getElementsByTagNameNS(cr,"p").item(0),r=n?gu(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function bu(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===su&&"commentsEx"===uu(t)?t:void 0}function yu(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))||fu(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(du(t).map(pu));for(const r of du(e))o.has(pu(r))||t.appendChild(r.cloneNode(!0))}function vu(e,t,n,o){const r=bu(t),a=bu(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))||fu(t,o,o.value)}}(r,a);const i=hu(e),l=hu(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 du(e)){if(n.namespaceURI!==su||"commentEx"!==uu(n))continue;const e=gu(n,"paraId");e&&t.set(e,n)}return t}(a),d=du(r),u=new Set(du(a).filter(e=>!(e.namespaceURI===su&&"commentEx"===uu(e))).map(pu));for(const p of d){if(p.namespaceURI===su&&"commentEx"===uu(p)){const e=gu(p,"paraId"),t=e?s.get(e):void 0,n=t?c.get(t):void 0;n&&yu(p,n,s);continue}u.has(pu(p))||(a.appendChild(p.cloneNode(!0)),u.add(pu(p)))}return(new Yd.XMLSerializer).serializeToString(a.ownerDocument)}var xu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function wu(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 Su(e){return e.localName??e.tagName}function Iu(e){return`${e.namespaceURI??""}\0${Su(e)}`}function Cu(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 Tu(e,t){return wu(e).find(e=>e.namespaceURI===xu&&Su(e)===t)}function ku(e,t){return e.filter(e=>e.namespaceURI===xu&&t.has(Su(e)))}function Pu(e){if(e.namespaceURI!==xu)return;const t=Su(e);if("p"===t){const t=Cu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Tu(e,"sdtPr"),n=t?Tu(t,"id"):void 0,o=n?Cu(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function Ru(e,t,n){const o=(new Yd.DOMParser).parseFromString(e,"application/xml"),r=(new Yd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==xu||i.namespaceURI!==xu||Su(a)!==n||Su(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=wu(a),s=wu(i),c=new Set(s.map(Iu));return l.forEach((e,t)=>{if(e.namespaceURI===xu||c.has(Iu(e)))return;const n=l.slice(t+1).map(e=>s.find(t=>Iu(t)===Iu(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new Yd.XMLSerializer).serializeToString(r)}function Bu(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=Ru(e,t,n),a=(new Yd.DOMParser).parseFromString(e,"application/xml"),i=(new Yd.DOMParser).parseFromString(r,"application/xml"),l=a.documentElement,s=i.documentElement;if(!l||!s||l.namespaceURI!==xu||s.namespaceURI!==xu||Su(l)!==n||Su(s)!==n)return r;const c=wu(l),d=wu(s),u=function(e,t,n){const o=ku(e,n),r=ku(t,n);return o.length===r.length&&o.every((e,t)=>Su(e)===Su(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==xu||o.has(Su(e)))return;const n=Iu(e),r=p.get(n)??0;if(p.set(n,r+1),wu(s).filter(e=>Iu(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===xu&&o.has(Su(e)));if(!a)return;const i=Pu(a);if(i){const e=ku(n,o).find(e=>Pu(e)===i);if(e)return e}if(!r)return;const l=ku(e,o),s=ku(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 Yd.XMLSerializer).serializeToString(i)}var Mu="word/document.xml",Au=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function Fu(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 Ou(e){return e.localName??e.tagName}function Du(e){return`${e.namespaceURI??""}\0${Ou(e)}`}function Lu(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 Eu(e,t){return Fu(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ou(e)===t)}function Nu(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Au.has(Ou(e))}function $u(e){return e.filter(Nu)}function zu(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=Ou(e);if("p"===t){const t=Lu(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Eu(e,"sdtPr"),n=t?Lu(Eu(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Hu(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml"),o=(new Yd.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"!==Ou(r)||"document"!==Ou(a))return t;!function(e,t){const n=Fu(e),o=Eu(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===Ou(e))),i=/* @__PURE__ */new Set;for(let l=a.length-1;l>=0;l-=1){const e=a[l],n=Fu(t).find(t=>!i.has(t)&&Du(t)===Du(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=Eu(r,"body"),l=Eu(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=Fu(i),c=Fu(l),d=function(e,t){const n=$u(e),o=$u(t);return n.length===o.length&&n.every((e,t)=>Ou(e)===Ou(o[t]))}(s,c),u=/* @__PURE__ */new Map;return s.forEach((e,t)=>{if(Nu(e))return;const n=Du(e),o=u.get(n)??0;if(u.set(n,o+1),Fu(l).filter(e=>Du(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(Nu);if(!o)return;const r=zu(o);return r?$u(n).find(e=>zu(e)===r):void 0}(s,t,c),a=d?function(e,t,n){const o=$u(e),r=$u(n),a=e.slice(t+1).find(Nu);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"===Ou(e))}(c)??null)}),(new Yd.XMLSerializer).serializeToString(o)}async function Wu(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(Mu);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Hu(e,Ru(e,t,"document"))}(n.data,r);return a!==r&&(t.file(Mu,a),!0)}var Uu="word/document.xml",ju="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Vu(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 Ku(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(ju,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function _u(e){const t=[];return Ku(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===ju&&"headerReference"===r.localName?"header":r.namespaceURI===ju&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Vu(r,"id");if(!a)continue;const i=Vu(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 Xu(e){return new Map(e.map(e=>[e.id,e]))}async function Gu(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(Uu)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=Ku(n.data),a=Ku(o);if(r.length!==a.length)return!1;const i=_u(n.data),l=_u(o),s=new Map(i.map(e=>[e.key,e])),c=Xu(n.relationships??[]),d=Xu(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`}(Uu))?.async("string"));return An(Uu,fa(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=Bu(a.data,l,g);f!==l&&(t.file(i,f),u=!0)}return u}var Yu="word/document.xml",qu={"/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"},Zu=["/officeDocument",...Object.keys(qu)];function Ju(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function Qu(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 ep(e){for(const[t,n]of Object.entries(qu))if(e.type.endsWith(t))return n}function tp(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:Qu(t.get(n)??n)}function np(e,t){for(const[n,o]of t)if(o===e)return n;return e}function op(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 rp(e,t){const n=e.parts[t];return"xml"===n?.kind?fa(n.data):[]}function ap(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:rp(e,mo):e.parts[t]?.relationships??rp(e,Qu(t));return An(t,n)}function ip(e,t,n){return ap(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function lp(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,Zu.find(e=>i.endsWith(e)));var i;const l=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,s=An(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:op(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function sp(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(Ju(e)===Ju(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 cp(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 dp(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===Wt(o))}async function up(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Gd.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>bn(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(Yu,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=ep(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!==Yu&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),l=new Gd.default;for(const c of Object.keys(n.parts))cp(l,n,c);for(const c of i)l.remove(c),l.remove(Qu(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=ap(t,i),s=l.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(s.length===l.length)continue;const c=np(i,n);o.has(Qu(c))||(0===s.length?e.remove(a):e.file(a,bt(s)))}}(l,n,a,r,i);let s=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=bn(c);if("[Content_Types].xml"===e){s=await d.async("string");continue}const t=tp(e,a),o=lo(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,s=ip(n,r,i),c=sp(s,lp(fa(await d.async("string")),s,e,r,a),t);l.file(t,bt(c));continue}const r=await d.async("uint8array");dp(n,e,t,r)||l.file(t,r)}return s&&l.file(_o,function(e,t,n,o){const r=Xr(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 la({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,s,a,i)),l.generateAsync({type:"arraybuffer"})}var pp="word/document.xml",gp=["first","even","default"];function fp(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 mp(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 hp(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,t){const n=[],o=e=>{for(const r of hp(e))r.localName===t&&n.push(r),o(r)};return o(e),n}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,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 xp(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml"),n=[],o=bp(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of hp(e)){const e="headerReference"===r.localName?"header":"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=yp(r,"id");if(!a)continue;const i=yp(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 wp(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function Sp(e,t){const n=e.parts[t]?.relationships??fa(wp(e,fp(t)));return An(t,n)}function Ip(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 Cp(e,t){const n=wp(e,e.mainDocumentPart),o=await(t.file(pp)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=xp(n),a=xp(o),i=Ip(r.references,Sp(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=gp.indexOf(e.type),o=gp.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=Ip(a.references,await async function(e,t){const n=await(e.file(fp(t))?.async("string"));return An(t,fa(n))}(t,pp)),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 Tp(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function kp(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===Wt(await a.async("uint8array")):void 0===r}async function Pp(e,t,n,o){for(const r of n)if(!(await kp(e,t,o?fp(r.current.partPath):r.current.partPath,r.source.baselinePath?o?fp(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function Rp(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?fp(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?Wt(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 Bp(e,t,n){const o=await(e.file(pp)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[pp],a=Wt((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of bp(n,r)){const n=yp(e,"id"),r=n?t.get(n):void 0;r&&(o=vp(e,"id",r.id)||o)}return o?(new Yd.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(pp,t)}}const r=fp(pp),a=fa(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:mp(pp,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,bt(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(Tp(e)===Tp(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 Mp(e,t,n){const o=n[0],r=o.source.partPath;if(!(await Pp(e,t,n,!1))){await Rp(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=fp(r);if(!(await Pp(e,t,n,!0))){await Rp(e,n,!0);const t=fp(o.current.partPath),c=await(e.file(t)?.async("string"));c&&e.file(a,bt((i=fa(c),l=o.current.partPath,s=r,i.map(e=>{if("External"===e.targetMode)return e;const t=An(l,[e])[0]?.resolvedTarget;return t?{...e,target:mp(s,t),targetMode:"Internal",resolvedTarget:t}:e}))))}var i,l,s;for(const c of n){const t=fp(c.current.partPath);t!==a&&e.remove(t)}}async function Ap(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 Mp(e,t,o)}async function Fp(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Gd.default.loadAsync(t),r=await Cp(n,o);r.matches.length>0&&(await Bp(o,n,r),await Ap(o,n,r),await async function(e,t){const n=await(e.file(_o)?.async("string"));if(!n)return;const o=Xr(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(_o,la(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return up(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[fp(d)];const a=r[n.mainDocumentPart],i=Sp(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const l=fp(n.mainDocumentPart),s=r[l];s&&(r[l]={...s,data:bt(i)});const c=r[_o];return c&&(r[_o]={...c,data:la(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var Op=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],Dp=/* @__PURE__ */new Set(["p","tbl"]),Lp=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function Ep(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 Np(e){return e.localName??e.tagName}function $p(e){return`${e.namespaceURI??""}\0${Np(e)}`}function zp(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 Hp(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 Wp(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Np(n)===t?n:void 0}function Up(e){const t=zp(e,"type");if(t&&Lp.has(t))return`type:${t}`;const n=zp(e,"id");return n?`id:${n}`:void 0}function jp(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Dp.has(Np(e))}function Vp(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Np(e))return;const t=zp(e,"paraId");return t?`p:${t}`:void 0}function Kp(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=Ep(e),o=Ep(t),r=function(e,t){const n=e.filter(jp),o=t.filter(jp);return n.length===o.length&&n.every((e,t)=>Np(e)===Np(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(jp(e))return;const l=$p(e),s=a.get(l)??0;if(a.set(l,s+1),Ep(t).filter(e=>$p(e)===l)[s])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(jp);if(!r)return;const a=Vp(r);if(a){const e=n.filter(jp).find(e=>Vp(e)===a);if(e)return e}if(!o)return;const i=e.filter(jp),l=n.filter(jp),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 _p(e,t,n,o){const r=Wp(t,o.rootName),a=Wp(n,o.rootName);if(!r||!a)return n;const i=Ep(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Np(e)===o.entryName),l=/* @__PURE__ */new Map;for(const c of Ep(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Np(c)!==o.entryName)continue;const e=Up(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=Up(c);if(!e)continue;const t=l.get(e),n=zp(c,"type");if(t){n&&Lp.has(n)?a.replaceChild(c.cloneNode(!0),t):Kp(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=zp(c,"id");o&&s.has(o)&&a.appendChild(c.cloneNode(!0))}return(new Yd.XMLSerializer).serializeToString(a.ownerDocument)}var Xp="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Gp="word/numbering.xml";function Yp(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 qp(e){return e.localName??e.tagName}function Zp(e){return`${e.namespaceURI??""}\0${qp(e)}`}function Jp(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 Qp(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(Xp,`w:${t}`,n)}function eg(e,t){return Yp(e).find(e=>e.namespaceURI===Xp&&qp(e)===t)}function tg(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 ng(e,t){const n=new Set(Yp(t).map(Zp));for(const o of Yp(e))o.namespaceURI===Xp||n.has(Zp(o))||t.appendChild(o.cloneNode(!0))}function og(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 rg=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function ag(e,t){tg(e,t);const n=Yp(e),o=new Map(Yp(t).map(e=>[Zp(e),e]));n.forEach((e,r)=>{const a=Zp(e),i=o.get(a),l=qp(e);if(i)return tg(e,i),void(e.namespaceURI===Xp&&"rPr"===l?function(e,t){tg(e,t);const n=Yp(e),o=new Map(Yp(t).map(e=>[Zp(e),e]));n.forEach((e,r)=>{const a=Zp(e),i=o.get(a);if(i)return tg(e,i),void ng(e,i);e.namespaceURI===Xp&&"rFonts"===qp(e)||og(n,r,e,t,e=>o.get(Zp(e)))})}(e,i):ng(e,i));if(e.namespaceURI!==Xp||!rg.has(l)){if(e.namespaceURI===Xp&&"rPr"===l){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of Yp(e))o.namespaceURI===Xp&&"rFonts"===qp(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}og(n,r,e,t,e=>o.get(Zp(e)))}})}function ig(e){return function(e){return e.namespaceURI===Xp&&"lvl"===qp(e)?`${Zp(e)}\0${Jp(e,"ilvl")??"0"}`:Zp(e)}(e)}function lg(e,t,n){const o=eg(t,"abstractNumId"),r=o?Jp(o,"val"):void 0;if(!r)return;const a=Yp(e).find(e=>e.namespaceURI===Xp&&"abstractNum"===qp(e)&&Jp(e,"abstractNumId")===r);return a?Yp(a).find(e=>e.namespaceURI===Xp&&"lvl"===qp(e)&&(Jp(e,"ilvl")??"0")===n):void 0}function sg(e,t){const n=t.cloneNode(!0);ag(e,n);const o=eg(e,"pPr"),r=eg(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function cg(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=Jp(eg(t,"start")??t,"val")??"1";for(const r of Yp(e)){const e=qp(r);if(r.namespaceURI===Xp&&"startOverride"===e){const e=r.cloneNode(!0);Qp(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==Xp||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(sg(r,t))}return n}function dg(e){if(e.namespaceURI!==Xp)return Zp(e);const t=qp(e);return"abstractNum"===t?`${Zp(e)}\0${Jp(e,"abstractNumId")??""}`:"num"===t?`${Zp(e)}\0${Jp(e,"numId")??""}`:Zp(e)}function ug(e,t){const n=function(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new Yd.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===Xp&&o.namespaceURI===Xp&&"numbering"===qp(n)&&"numbering"===qp(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;tg(o,r);const a=Yp(o),i=new Map(Yp(r).map(e=>[dg(e),e]));return a.forEach((e,t)=>{const n=dg(e),o=i.get(n),l=qp(e);if(o)return tg(e,o),void(e.namespaceURI===Xp&&"abstractNum"===l?function(e,t){tg(e,t);const n=Yp(e),o=new Map(Yp(t).map(e=>[ig(e),e]));n.forEach((e,r)=>{const a=ig(e),i=o.get(a);if(i)return tg(e,i),void(e.namespaceURI===Xp&&"lvl"===qp(e)?ag(e,i):ng(e,i));og(n,r,e,t,e=>o.get(ig(e)))})}(e,o):e.namespaceURI===Xp&&"num"===l?function(e,t,n){tg(e,t);const o=eg(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of Yp(t))a.namespaceURI===Xp&&"lvlOverride"===qp(a)&&r.set(Jp(a,"ilvl")??"0",a);for(const a of Yp(e)){const e=qp(a);if(a.namespaceURI!==Xp||"abstractNumId"!==e){if(a.namespaceURI===Xp&&"lvlOverride"===e){const e=Jp(a,"ilvl")??"0",o=cg(a,lg(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===Xp||Yp(t).some(e=>Zp(e)===Zp(a))||t.appendChild(a.cloneNode(!0))}else o&&(tg(a,o),ng(a,o))}}(e,o,r):ng(e,o));og(a,t,e,r,e=>i.get(dg(e)))}),(new Yd.XMLSerializer).serializeToString(r.ownerDocument)}async function pg(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(Gp);if(!n||!o)return!1;const r=await o.async("string"),a=ug(n,r);return a!==r&&(t.file(Gp,a),!0)}var gg=[{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 fg(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 mg="http://schemas.openxmlformats.org/wordprocessingml/2006/main",hg=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);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 yg(e){return e.localName??e.tagName}function vg(e){return`${e.namespaceURI??""}\0${yg(e)}`}function xg(e){const t=[],n=e=>{for(const o of bg(e))o.namespaceURI===mg&&"sectPr"===yg(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function wg(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 Sg(e){return e.namespaceURI===mg&&hg.has(yg(e))}function Ig(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml"),o=(new Yd.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=xg(n),l=xg(o);return 0===i.length||i.length!==l.length?t:(wg(r,a),i.forEach((e,t)=>{!function(e,t){wg(e,t);const n=bg(e),o=bg(t),r=/* @__PURE__ */new Map;for(const i of o){const e=vg(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=vg(e),l=a.get(o)??0;a.set(o,l+1);const s=r.get(o)?.[l];if(s){wg(e,s);continue}if(Sg(e))continue;const c=n.slice(i+1).map(e=>r.get(vg(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,l[t])}),(new Yd.XMLSerializer).serializeToString(o))}var Cg="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Tg(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 kg(e){return e.localName??e.tagName}function Pg(e,t){const n=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===Cg&&kg(n)===t?n:void 0}function Rg(e){return Tg(e).length>0?(new Yd.XMLSerializer).serializeToString(e.ownerDocument):void 0}var Bg=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),Mg=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function Ag(e){const t=Pg(e,"settings");if(!t)return e;for(const n of[...Tg(t)]){if(n.namespaceURI!==Cg)continue;const e=kg(n);if(Bg.has(e)){t.removeChild(n);continue}const o=Mg.get(e);if(o){for(const e of[...Tg(n)])e.namespaceURI===Cg&&o.has(kg(e))&&n.removeChild(e);0===Tg(n).length&&t.removeChild(n)}}return Rg(t)}function Fg(e){const t=Pg(e,"styles");if(!t)return e;for(const n of[...Tg(t)])n.namespaceURI===Cg&&"style"===kg(n)&&t.removeChild(n);return Rg(t)}function Og(e){const t=Pg(e,"fonts");if(!t)return e;for(const n of[...Tg(t)])n.namespaceURI===Cg&&"font"===kg(n)&&t.removeChild(n);return Rg(t)}async function Dg(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 Lg="word/styles.xml";function Eg(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 Ng(e){return e.localName??e.tagName}function $g(e){return`${e.namespaceURI??""}\0${Ng(e)}`}function zg(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 Hg(e,t){return Eg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Ng(e)===t)}function Wg(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Ng(e)?`${$g(e)}\0${zg(e,"type")??""}`:$g(e)}function Ug(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Ng(t)?t:void 0}function jg(e,t){const n=Hg(e,"pPr");if(!n)return!1;const o=Hg(t,"pPr"),r=new Yd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=or(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 Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Ng(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=Eg(e),a=r.indexOf(n),i=Eg(t),l=new Map(i.map(e=>[Wg(e),e])),s=r.slice(a+1).map(e=>l.get(Wg(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function Vg(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=Ug(e),o=Ug(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Eg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Ng(i))continue;const e=zg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Eg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Ng(i))continue;const e=zg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=jg(i,t)||a)}return a?(new Yd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Lg,a),!0)}function Kg(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 _g(e){return e.localName??e.tagName}function Xg(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 Gg(e,t){const n=function(e){if(!e)return;const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===_g(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${cr}" xmlns:w14="${eo}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};v(r,`<w:r xmlns:w="${cr}" xmlns:w14="${eo}">${e}<w:t/></w:r>`);const a=function(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===_g(t)?t:void 0}(Rr(r,o));if(!a)return t;let i=Kg(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===_g(e));return!i&&Xg(n)&&(i=a.ownerDocument.createElementNS(cr,"w:rPr"),a.insertBefore(i,a.firstChild)),i?(jn(n,i),0!==Kg(i).length||Xg(i)?(new Yd.XMLSerializer).serializeToString(i):""):""}var Yg="word/styles.xml";function qg(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 Jg(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 Qg(e,t){return qg(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Zg(e)===t)}function ef(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Zg(t)?t:void 0}function tf(e,t){const n=Qg(e,"rPr");if(!n)return!1;const o=Qg(t,"rPr"),r=new Yd.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",l=Gg(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 Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Zg(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=qg(e),a=r.indexOf(n),i=qg(t),l=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&Zg(t)===Zg(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function nf(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(Yg);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=ef(e),o=ef(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of qg(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Zg(i))continue;const e=Jg(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of qg(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Zg(i))continue;const e=Jg(i,"styleId"),t=e?r.get(e):void 0;t&&(a=tf(i,t)||a)}return a?(new Yd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Yg,a),!0)}var of="word/styles.xml",rf=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function af(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 lf(e){return e.localName??e.tagName}function sf(e){return`${e.namespaceURI??""}\0${lf(e)}`}function cf(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 df(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 uf(e,t){return af(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&lf(e)===t)}function pf(e){return e?(new Yd.XMLSerializer).serializeToString(e):""}function gf(e,t){if(!e)return;const n=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&lf(n)===t?n:void 0}function ff(e,t,n){switch(e){case"pPr":return or(t,n);case"rPr":return Gg(t,n);case"tblPr":return zo(t,n);case"trPr":return Hr(t,n);case"tcPr":return Nn(t,n);default:return n}}function mf(e,t,n,o){const r=af(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&rf.has(lf(e)));return i?uf(t,lf(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===lf(e)&&rf.has(o)?af(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===lf(e))??null:null}function hf(e,t,n){const o=uf(e,n);if(!o)return!1;const r=uf(t,n),a=pf(r),i=ff(n,pf(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const l=gf(i,n);if(!l)return!1;const s=l.cloneNode(!0);return r?(t.replaceChild(s,r),!0):(t.insertBefore(s,mf(e,t,o,n)),!0)}function bf(e,t){df(e,t);let n=!1;for(const r of rf)n=hf(e,t,r)||n;const o=new Set(af(t).map(sf));for(const r of af(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&rf.has(lf(r))||o.has(sf(r))||(t.appendChild(r.cloneNode(!0)),o.add(sf(r)),n=!0);return n}function yf(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(cr,"w:tblStylePr");df(e,n);let o=!1;for(const r of af(e)){const e=lf(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&rf.has(e)){const t=gf(ff(e,pf(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function vf(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==lf(e))return;const t=cf(e,"type");return t?`tblStylePr:${t}`:void 0}function xf(e,t){let n=!1;n=hf(e,t,"tblPr")||n;const o=af(e).filter(e=>void 0!==vf(e)),r=/* @__PURE__ */new Map;for(const a of af(t)){const e=vf(a);e&&r.set(e,a)}for(const a of o){const o=vf(a),i=r.get(o);if(i){n=bf(a,i)||n;continue}const l=yf(a);if(!l)continue;const s=af(e),c=s.indexOf(a),d=s.slice(c+1).find(e=>void 0!==vf(e)),u=d?r.get(vf(d))??null:null;t.insertBefore(l.cloneNode(!0),u),n=!0}return n}function wf(e){const t=(new Yd.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===lf(t)?t:void 0}async function Sf(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(of);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=wf(e),o=wf(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of af(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===lf(i)){const e=cf(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of af(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==lf(i))continue;if("table"!==cf(i,"type"))continue;const e=cf(i,"styleId"),t=e?r.get(e):void 0;t&&(a=xf(i,t)||a)}return a?(new Yd.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(of,a),!0)}var If="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Cf(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 Tf(e){return e.localName??e.tagName}function kf(e){return`${e.namespaceURI??""}\0${Tf(e)}`}function Pf(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 Rf(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 Bf(e,t,n){const o=(new Yd.DOMParser).parseFromString(e,"application/xml"),r=(new Yd.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===If&&i.namespaceURI===If&&Tf(a)===n&&Tf(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function Mf(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 Af(e,t){const n=new Set(Cf(t).map(kf));for(const o of Cf(e))o.namespaceURI===If||n.has(kf(o))||t.appendChild(o.cloneNode(!0))}var Ff=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var Of=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function Df(e){return e.namespaceURI===If&&"tblStylePr"===Tf(e)?`${kf(e)}\0${Pf(e,"type")??""}`:kf(e)}function Lf(e){return e.namespaceURI===If&&"style"===Tf(e)?`${kf(e)}\0${Pf(e,"styleId")??""}`:kf(e)}var Ef=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function Nf(e){return e.namespaceURI===If&&"font"===Tf(e)?`${kf(e)}\0${Pf(e,"name")??""}`:kf(e)}var $f=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=Bf(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Rf(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=Cf(o),l=new Map(Cf(r).map(e=>[kf(e),e]));return i.forEach((e,t)=>{const n=kf(e),o=l.get(n),s=Tf(e),c=e.namespaceURI===If?a.get(s):void 0;if(o)return Rf(e,o),void(c?function(e,t,n){Rf(e,t);const o=Cf(t),r=new Map(o.map(e=>[kf(e),e])),a=Cf(e);a.forEach((e,o)=>{const i=kf(e),l=r.get(i);if(l)return Rf(e,l),void Af(e,l);e.namespaceURI===If&&n.has(Tf(e))||Mf(a,o,e,t,e=>r.get(kf(e)))})}(e,o,c):Af(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of Cf(e))r.namespaceURI===If&&t.has(Tf(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(kf(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===If&&Ff.has(s)||Mf(i,t,e,r,e=>l.get(kf(e)))}),(new Yd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=Bf(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Rf(o,r);const a=Cf(o),i=new Map(Cf(r).map(e=>[Lf(e),e]));return a.forEach((e,t)=>{const n=Lf(e),o=i.get(n);if(o)return Rf(e,o),void(e.namespaceURI===If&&"style"===Tf(e)?function(e,t){Rf(e,t);const n=Cf(e),o=new Map(Cf(t).map(e=>[Df(e),e]));n.forEach((e,r)=>{const a=Df(e),i=o.get(a);if(i)return Rf(e,i),void Af(e,i);e.namespaceURI===If&&Of.has(Tf(e))||Mf(n,r,e,t,e=>o.get(Df(e)))})}(e,o):Af(e,o));Mf(a,t,e,r,e=>i.get(Lf(e)))}),(new Yd.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=Bf(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Rf(o,r);const a=Cf(o),i=new Map(Cf(r).map(e=>[Nf(e),e]));return a.forEach((e,t)=>{const n=Nf(e),o=i.get(n);if(o)return Rf(e,o),void(e.namespaceURI===If&&"font"===Tf(e)&&function(e,t){Rf(e,t);const n=Cf(e),o=new Map(Cf(t).map(e=>[kf(e),e]));n.forEach((e,r)=>{const a=kf(e),i=o.get(a);i?Rf(e,i):e.namespaceURI===If&&Ef.has(Tf(e))||Mf(n,r,e,t,e=>o.get(kf(e)))})}(e,o));Mf(a,t,e,r,e=>i.get(Nf(e)))}),(new Yd.XMLSerializer).serializeToString(r.ownerDocument)}}];function zf(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 Hf="word/document.xml";function Wf(e){const t=(new Yd.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 Uf(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return up(e,t);const r=await Gd.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 $f){const r=zf(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 pg(n,r)||l),i.styles&&(l=await Vg(n,r)||l,l=await nf(n,r)||l,l=await Sf(n,r)||l),l=await async function(e,t){let n=!1;return t.settings||(n=await Dg(e,"word/settings.xml",Ag)||n),t.styles||(n=await Dg(e,"word/styles.xml",Fg)||n),t.fontTable||(n=await Dg(e,"word/fontTable.xml",Og)||n),n}(r,i)||l,l=await async function(e,t){let n=!1;for(const o of gg){const r=fg(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),l=Ru(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 Op){const a=Hp(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const l=await i.async("string"),s=_p(e,a,l,r);s!==l&&(n.file(r.rebuiltPath,s),o=!0)}return o}(e,n,r)||l,l=await lu(n,r)||l,l=await async function(e,t){const n=mu(e,"/comments"),o=mu(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(cu);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),l=await a.async("string"),s=vu(n,o,i,l);return s!==l&&(t.file(cu,s),!0)}(n,r)||l,l=await Gu(n,r)||l,l=await Wu(n,r)||l;const s=await(r.file(Hf)?.async("string"));if(!s||Wf(o.data)!==Wf(s)){return up(e,l?await r.generateAsync({type:"arraybuffer"}):t)}const c=Ig(o.data,s);c!==s&&(r.file(Hf,c),l=!0);return Fp(e,l?await r.generateAsync({type:"arraybuffer"}):t)}function jf(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function Vf(e){const t=(new Yd.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 Kf(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 _f(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 Xf(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 Gf(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=jf(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=Vf(r.data);if(a&&jf(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 Yd.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=Kf(i[0]);if(!s||1!==s.index)return null;if(!_f(r,s.prefix,s.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=Kf(i[m]);if(!e)return null;const t=Xf(c).filter(t=>_f(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(Xf(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 Yd.XMLSerializer).serializeToString(r.document),!0)}function Yf(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 qf(e){return e.blocks.map(Jf).filter(Boolean).join("\n")}function Zf(e){return e.cells.map(qf).filter(Boolean).join("\t")}function Jf(e){return"paragraph"===e.type?Et(e):e.rows.map(Zf).filter(Boolean).join("\n")}function Qf(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])Yf(t,e,n.text,"");"textBox"===n.kind&&tm(n.textBox.blocks,t)}}function em(e,t){for(const n of e.rows){const e=Zf(n);for(const o of n.sdtWrappers??[])Yf(t,o,e,"\n");for(const o of n.cells){const e=qf(o);for(const n of o.sdtWrappers??[])Yf(t,n,e,"\n");tm(o.blocks,t)}}}function tm(e,t){if(e)for(const n of e){const e=Jf(n);for(const o of n.sdtWrappers??[])Yf(t,o,e,"\n");"paragraph"===n.type?Qf(n,t):em(n,t)}}async function nm(e){if(!e.sourcePackage)return ne(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 Ne(e))tm(o.blocks,t),tm(o.header,t),tm(o.firstPageHeader,t),tm(o.evenPageHeader,t),tm(o.footer,t),tm(o.firstPageFooter,t),tm(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&Gf(e.sourcePackage,t,r)&&(n+=1)}}(t);return Uf(t,await ne(t))}async function om(e){if(!e.sourcePackage)return Dt(e);const t=await nm(e);return new Blob([t],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function rm(e){switch(e){case"dashed":return[tn(5),tn(3)];case"dotted":return[tn(1),tn(3)];default:return}}async function am(e,t,n,o,r,a,i,l){const s=t.rotation;s&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,tn(o+a/2),tn(r+i/2),s)),function(e,t,n,o,r,a,i){const l=rt(n.shape?.preset,tn(o),tn(r),tn(a),tn(i)),s=n.shape?.fill,c=n.shape?.borderColor,d=n.shape?.borderWidthPt??(c?.75:0);e.drawPath(t,{segments:l,fill:s,stroke:c&&d>0?c:void 0,lineWidth:d})}(e,n.pageIndex,t,o,r,a,i),await async function(e,t,n,o,r,a,i,l){if(0===t.blocks.length)return;const s=function(e){return{left:e.body?.paddingLeft??0,top:e.body?.paddingTop??0,right:e.body?.paddingRight??0,bottom:e.body?.paddingBottom??0}}(t),c=o+s.left,d=r+s.top,u=Math.max(1,a-s.left-s.right),p=Math.max(1,i-s.top-s.bottom),g=zn({blocks:t.blocks,pageSettings:{width:u,height:p,orientation:"portrait",margins:{top:0,right:0,bottom:0,left:0,header:0,footer:0,gutter:0}},maxPageHeight:p,styles:n.document.styles,pageOffset:n.pageIndex})[0]?.blocks??[];if(0===g.length)return;const f=mt(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,tn(c),tn(d),tn(u),tn(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await l.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,l);break;case"table":await l.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,l);break;default:Jo(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,o,r,a,i,l),s&&e.restoreGraphicsState(n.pageIndex)}async function im(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=no({object:Kn(f),pageSettings:i,contentLeft:l,contentTop:s,contentWidth:c,paragraphTop:d,lineTop:b,anchorLeft:h});await am(t,f,{document:n,fontRegistry:o,pageIndex:r},y.x,y.y,y.width,y.height,u)}}}var lm=/* @__PURE__ */new WeakMap;function sm(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 cm(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=sm(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?sm(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 dm(e,t,n){const o=qe(t,n.src);if(!o)return null;let r=lm.get(e);r||(r=/* @__PURE__ */new Map,lm.set(e,r));const a=r.get(o);if(a)return a;const i=cm(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 um(e,t,n,o,r,a,i,l){const s=await dm(e,n,o);if(!s)return;const c=o.intrinsicWidth??o.width,d=o.intrinsicHeight??o.height,u=c/Math.max(1,d),p=i/Math.max(1,l);let g=r,f=a,m=i,h=l;"fit"===o.cropFit&&u>0&&(u>p?(h=i/u,f+=(l-h)/2):(m=l*u,g+=(i-m)/2));const b="fill"!==o.cropFit||o.crop?o.crop:(()=>{if(u>p){const e=p/u,t=Math.max(0,(1-e)/2);return{left:t,right:t}}if(u<p){const e=u/p,t=Math.max(0,(1-e)/2);return{top:t,bottom:t}}})(),y=o.cropShape?.preset,v=y?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}})}(rt(y,r,a,i,l),r,a,i,l,o.rotation??0):null,x=o.transparency??0,w="fit"===o.cropFit&&Boolean(o.rotation);v&&(e.saveGraphicsState(t),e.clipPath(t,v)),w&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,o.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:s,x:g,y:f,width:m,height:h,rotation:w?void 0:o.rotation,crop:b}),x>0&&e.restoreGraphicsState(t),w&&e.restoreGraphicsState(t),v&&e.restoreGraphicsState(t);const S=o.border;if(!S)return;const I=o.rotation;I&&!v&&(e.saveGraphicsState(t),e.rotateAbout(t,r+i/2,a+l/2,I));const C=at(S.dash);v?e.drawPath(t,{segments:v,stroke:S.color,lineWidth:S.widthPt??1}):e.drawRect(t,{x:r,y:a,width:i,height:l,stroke:S.color,lineWidth:S.widthPt??1,...C.length>0?{dashArray:C}:{}}),I&&!v&&e.restoreGraphicsState(t)}function pm(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 gm(e,t,n){const o=pm(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 fm(e,t,n,o,r,a,i){const l=gm(e,t,n.fontSize??14.6667);return l?{x:tn(o+l.left),y:tn(r+e.top+a),width:tn(Math.max(0,l.right-l.left)),height:tn(Math.max(2,e.height-i))}:null}function mm(e,t,n,o,r,a,i){const l=i.textFill;if(!l||"gradient"!==l.type||l.stops.length<2)return;const s=gm(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=rn(c,u,d,p,l.angle??0);return e.registerAxialGradient(t,{x0:tn(g.x0),y0:tn(g.y0),x1:tn(g.x1),y1:tn(g.y1),stops:l.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function hm(e,t,n,o,r,a,i){const l=Vt(i),s=(r,i)=>{e.drawLine(t,{x1:tn(n),y1:tn(r),x2:tn(o),y2:tn(r),stroke:a,lineWidth:tn(l),dashArray:i})};if(u(i))return s(r-hr),void s(r+hr);Nt(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)*xa;e.drawLine(t,{x1:tn(l),y1:tn(s),x2:tn(c),y2:tn(o),stroke:a,lineWidth:tn(i)}),l=c,s=o}}(e,t,n,o,r,a,l):s(r,Mt(i))}function bm(e,t){const n=wo(wr(e));if(!n)return e;const o=Math.max(0,Math.min(1,t));return In(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function ym(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:l,gradientShadingName:s,styles:c,baseTextOptions:d}=e,u=tn(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:tn(t)+u*e,y:tn(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*tn(e.radiusPt*Ho),l=bm(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:tn(t)+c,y:tn(a)+u,text:n,color:l})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,l=tn(e.distPt*Ho);o.drawText(r,{...d,x:tn(t)+Math.cos(i)*l,y:tn(a)+Math.sin(i)*l,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:tn(t)+u,y:tn(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,s=bm(l,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:tn(t),y:tn(a)+tn(e.distPt*Ho)+i,text:n,color:s})}const p=c.textOutline;o.drawText(r,{...d,x:tn(t),y:tn(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 vm(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=no({object:Ur(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 um(e.writer,e.pageIndex,e.document,r,tn(l.x),tn(l.y),tn(l.width),tn(l.height))}}}function xm(e,t,n,o,r,a,i,l){const s=gm(n,o,i.fontSize??14.6667);if(!s)return;const c=a+pe(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:tn(d),y1:tn(c-ve),x2:tn(u),y2:tn(c-ve),stroke:p,lineWidth:tn(1)}),void e.drawLine(t,{x1:tn(d),y1:tn(c+ve),x2:tn(u),y2:tn(c+ve),stroke:p,lineWidth:tn(1)})):void hm(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:tn(d),y1:tn(c),x2:tn(u),y2:tn(c),stroke:p,lineWidth:tn(1)})}async function wm(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 um(e,t,a,r.image,tn(i+n.left),tn(l+o.top+o.height-r.image.height),tn(r.image.width),tn(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 am(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=Ce(r.styles,n.style?.styleId,a.styles),u=s.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:tn(i+c.left),y:tn(l+o.top+o.height*We),text:na(r.math),fontSize:Yt(d),color:d.color??"#000000",fontResourceName:u.writerResourceName})}const d=Ce(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=Yt(d),g=(d.baselineShift??0)*Ho,f=re(n.style,a.styles),m=W(f.textAlignment,d.fontSize??14.6667,o.height),h=l+o.top+o.height*We-g+m,b=pm(o,r),y=b.map(e=>Ge(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=gm(n,o,i.fontSize??14.6667);if(!l||l.right<=l.left)return;const s=i.link.startsWith("#");e.addLinkAnnotation(t,{x:tn(r+l.left),y:tn(a+n.top),width:tn(l.right-l.left),height:tn(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=fm(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=fm(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=fm(n,o,i,r,a,1,2);s&&e.drawRect(t,{...s,stroke:l.color,lineWidth:tn(Math.max(.5,l.width*Ho))})}(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=re(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*Ho})).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:tn(i+n.left),y1:tn(m),x2:tn(i+r.left),y2:tn(m),stroke:s,lineWidth:tn("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=re(n.style,a.styles).align??"left",x=J(d,Yt(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=>Ge(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;ym({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of s){const n=Boolean(o.smallCaps&&R(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&&ym(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:mm(e,t,o,r,i,l,d),styles:d,baseTextOptions:w},b,i,d,o,r,v),d.underline&&xm(e,t,o,r,i,l,d,"underline"),d.strike&&xm(e,t,o,r,i,l,d,"strike"),d.doubleStrike&&xm(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=ct[l];if(!s)return;const c=pm(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:tn(r+l-.25*u),y:tn(p),text:s,fontSize:tn(u),color:i.color??"#000000"})}}(e,t,o,r,i,l,d)}function Sm(e,t,n,o,r,a,i,l,s){if(0!==o.index)return;const c=b(n,s);if(!c)return;const d=o.slots[0];if(!d)return;const u=Ce(void 0,n.style?.styleId,r.styles),p=l.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=w(n,r.styles),f=Yt(u),m=c.length*f*.62*Ho,h=vt(n,r.styles,d.left,m);e.drawText(t,{x:tn(a+Math.max(0,h||g)),y:tn(i+o.top+o.height*We),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function Im(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=le(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:tn(p),y:tn(a),width:tn(Math.max(0,g-p)),height:tn(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:tn(n),y1:tn(o),x2:tn(r),y2:tn(i),stroke:h.color,lineWidth:h.width,dashArray:rm(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:tn(p),y1:tn(a),x2:tn(p),y2:tn(f),stroke:m.color,lineWidth:m.width,dashArray:rm(m.type)})}async function Cm(e,t,n,o,r,a,i,l,s,c){for(const d of o){Sm(e,t,n,d,r,a,i,l,s);for(const o of d.fragments)await wm(e,t,n,d,o,r,a,i,l,c)}}function Tm(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:tn(o),y1:tn(r),x2:tn(a),y2:tn(i),stroke:n.color,lineWidth:tn(n.width),dashArray:rm(n.type)})}function km(e,t,n,o,r){const a=o+n.left,i=r+n.top,l=a+n.width,s=i+n.height;Tm(e,t,n.borders.top,a,i,l,i),Tm(e,t,n.borders.right,l,i,l,s),Tm(e,t,n.borders.bottom,a,s,l,s),Tm(e,t,n.borders.left,a,i,a,s),n.borders.topLeftToBottomRight&&Tm(e,t,n.borders.topLeftToBottomRight,a,i,l,s),n.borders.topRightToBottomLeft&&Tm(e,t,n.borders.topRightToBottomLeft,l,i,a,s)}async function Pm(e,t,o,r,a,i,l,s,c,d){if("table"!==o.sourceBlock.type)return;const u=o.sourceBlock,p=o.tableSegment?fe(u,o.tableSegment):u;if(0===p.rows.length)return;const g=n({table:p,state:{document:r},pageIndex:0,originX:0,originY:0,contentWidth:l,estimatedHeight:o.estimatedHeight});for(const n of g.cells)n.shading&&e.drawRect(t,{x:tn(a+n.left),y:tn(i+n.top),width:tn(n.width),height:tn(n.height),fill:n.shading});for(const n of g.cells)if(km(e,t,n,a,i),n.revision){const o="insert"===n.revision.type?"#059669":"delete"===n.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:tn(a+n.left+1),y:tn(i+n.top+1),width:tn(Math.max(0,n.width-2)),height:tn(Math.max(0,n.height-2)),stroke:o,lineWidth:tn(2)})}for(const n of g.cells)for(const o of n.paragraphs)await Cm(e,t,o.paragraph,o.lines,r,a+o.originX,i+o.originY,s,c,d)}var Rm={drawParagraph:Cm,drawTableBlock:Pm};async function Bm(e,t,n,o,r,a,i,l,s,c,d){if(!n||0===n.length)return;const u=a;let p=a;for(let g=0;g<n.length;g+=1){const f=n[g];switch(f.sourceBlock.type){case"paragraph":{if(!f.layout)break;const n=re(f.sourceBlock.style,o.styles),g=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0);d?.(f.sourceBlock.id,g);const m=g+le(n).top;Im(e,t,n,f.layout.lines,r,g,i),c&&(await vm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await im({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Rm,layer:"behind"})),await Cm(e,t,f.sourceBlock,f.layout.lines,o,r,m,l,s,Rm),c&&(await vm({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await im({writer:e,document:o,fontRegistry:l,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:Rm,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=Yn(f.sourceBlock,i),a=ur({floating:f.sourceBlock.style.floating,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,anchorTop:p,width:n,height:f.floatingTableHeight??1,pageIndex:t});a.y+=f.floatingTableOffsetY??0,await Pm(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,l,s,Rm);break}await Pm(e,t,f,o,r,p,i,l,s,Rm);break;default:Jo(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const l=n[g+1];if("paragraph"===l?.sourceBlock.type&&l.layout&&l.sourceBlock.id!==f.sourceBlock.id){const n=re(f.sourceBlock.style,o.styles),s=re(l.sourceBlock.style,o.styles);if(Re(n,s)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+le(n).top;let l=0;for(const e of f.layout.lines)l=Math.max(l,e.top+e.height);const s=o+l,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:tn(c),y1:tn(s),x2:tn(d),y2:tn(s),stroke:u.color,lineWidth:u.width,dashArray:rm(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function Mm(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 dm(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 Am=[{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 Fm(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function Om(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Dm=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of Am)this.registerFontFace(e)}registerFontFace(e){this.faces.set(Fm(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=Xt(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(Fm(t,n,o))??this.faces.get(Fm(this.fallbackFamily,n,o))??this.faces.get(Fm(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(Xt).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(te)){const e=await Ot(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 Eo(e.families);for(const n of t){const e=`Remote${Om(n.postscriptName||n.family)}`;this.registerFontFace({key:Fm(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 Ht){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 Ot(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,l=`${Om(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}},Lm="%PDF-1.4\n% Oasis PDF\n",Em=[{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 Nm(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function $m(e){return(new TextEncoder).encode(e).byteLength}function zm(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0").toUpperCase()).join("")}function Hm(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Wm(e,t){if(!e)return t;const n=wo(wr(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Um(e,t,n){const[o,r,a]=Wm(e,n);return`${Nm(o)} ${Nm(r)} ${Nm(a)} ${t}`}function jm(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var Vm=/* @__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 Km(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:Vm.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function _m(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(Hm).join("")}function Xm(e){return Hm(e)}function Gm(e){return`% OasisText ${_m(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function Ym(e){return e&&0!==e.length?`[${e.map(e=>Nm(e)).join(" ")}] 0 d`:null}var qm=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(Um(e.fill,"rg",[1,1,1])),e.stroke){n.push(Um(e.stroke,"RG",[0,0,0])),n.push(`${Nm(e.lineWidth??1)} w`);const t=Ym(e.dashArray);t&&n.push(t)}n.push([Nm(e.x),Nm(t.height-e.y-e.height),Nm(e.width),Nm(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=Ym(e.dashArray),o=["q",Um(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${Nm(e.lineWidth??1)} w`,`${Nm(e.x1)} ${Nm(t.height-e.y1)} m`,`${Nm(e.x2)} ${Nm(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(Um(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(Um(e.stroke,"RG",[0,0,0])),o.push(`${Nm(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${Nm(r.x)} ${Nm(n(r.y))} m`);break;case"line":o.push(`${Nm(r.x)} ${Nm(n(r.y))} l`);break;case"cubic":o.push(`${Nm(r.x1)} ${Nm(n(r.y1))} ${Nm(r.x2)} ${Nm(n(r.y2))} ${Nm(r.x)} ${Nm(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(`${Nm(i)} ${Nm(l)} ${Nm(-l)} ${Nm(i)} ${Nm(s)} ${Nm(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${Nm(e)} ${Nm(r.height-t-o)} ${Nm(n)} ${Nm(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(`${Nm(r.x)} ${Nm(n(r.y))} m`);break;case"line":o.push(`${Nm(r.x)} ${Nm(n(r.y))} l`);break;case"cubic":o.push(`${Nm(r.x1)} ${Nm(n(r.y1))} ${Nm(r.x2)} ${Nm(n(r.y2))} ${Nm(r.x)} ${Nm(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):`<${Km(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${Nm(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Nm(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Nm(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([Gm(n.text),"BT",Um(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Um(n.strokeColor??n.color,"RG",[0,0,0]),`${Nm(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Nm(n.x)} ${Nm(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([Gm(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Nm(n.x)} ${Nm(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",[Nm(e.width),"0","0",Nm(e.height),Nm(e.x),Nm(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",[Nm(p),Nm(g),Nm(f),Nm(m),Nm(h),Nm(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",[Nm(h),Nm(b),Nm(y),Nm(v),Nm(x),Nm(w),"cm"].join(" "),`0 0 ${Nm(a)} ${Nm(i)} re W n`,[Nm(l),"0","0",Nm(s),Nm(c),Nm(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function Zm(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function Jm(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function Qm(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function eh(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 th(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=Jm(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 nh(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:Jm(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 oh(e,t,n){return e.seek(t),Qm(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=Qm(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 rh(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 ah(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=Qm(e,o,t).map(t=>(e.seek(t),Jm(e,e.u16())));return{coverage:eh(e,n),sets:r}}function ih(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 lh(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function sh(e,t){e.seek(t);const n=e.u16();return Qm(e,n,t).map(t=>(e.seek(t),{backtrack:Jm(e,e.u16()),input:Jm(e,Math.max(0,e.u16()-1)),lookahead:Jm(e,e.u16()),records:ih(e,e.u16())}))}function ch(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 lh(t,n,i.records,o),e}}}return null}function dh(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=eh(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=Jm(e,t),r=eh(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=ah(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=ah(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=Qm(e,o,t).map(t=>(e.seek(t),Qm(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:Jm(e,Math.max(0,o-1))}}))),a=eh(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=Qm(e,e.u16(),t),o=Qm(e,e.u16(),t),r=Qm(e,e.u16(),t),a=ih(e,e.u16()),i=n.map(t=>eh(e,t)),l=o.map(t=>eh(e,t)),s=r.map(t=>eh(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 lh(e,t,a,n),l.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=Qm(e,o,t),a=eh(e,n),i=r.map(t=>sh(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:ch(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=eh(e,n),c=th(e,o),d=th(e,r),u=th(e,a),p=l.map(t=>0===t?[]:sh(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?ch(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return Zm(e,t,dh);default:return null}}var uh=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=nh(n),a=oh(n,r,dh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return rh(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 ph(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 gh(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function fh(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=ph(e,e.u16()),n=eh(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=gh(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=ph(e,t);const l=eh(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=Qm(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=ph(e,r),i=ph(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),s=eh(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=gh(r),u=d+gh(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]=ph(e,r),e.seek(p+o+d),f[t*c+n]=ph(e,a)}const m=eh(e,o),h=th(e,n),b=th(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 Zm(e,t,fh);default:return null}}var mh=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new Le(t),{featureToLookups:o,lookupListOffset:r}=nh(n),a=oh(n,r,fh);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=rh(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}}}},hh=/* @__PURE__ */new Set(["kern"]),bh=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?uh.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?mh.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=>!hh.has(e))??[],r=t?.filter(e=>hh.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}}},yh=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 vh(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function xh(e,t){return vh(e).getUint16(t)}function wh(e,t,n){vh(e).setUint16(t,n,!1)}function Sh(e,t,n){vh(e).setUint32(t,n,!1)}function Ih(e){return e+3&-4}function Ch(e){const t=e.reduce((e,t)=>e+Ih(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=Ih(r.byteLength);return n}function Th(e,t){const n=[],o=vh(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 kh(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function Ph(e,t){if(e.byteLength<10||function(e,t){return vh(e).getInt16(t)}(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)return;o=xh(e,n),t(xh(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 Rh(e){const t=new Uint8Array(4*e.length);return e.forEach((e,n)=>Sh(t,4*n,e)),t}function Bh(e,t){const n=new Uint8Array(4*(t+1));for(let o=0;o<=t;o+=1)wh(n,4*o,e.advanceWidthForGlyph(o)),wh(n,4*o+2,0);return n}var Mh=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=Th(o,xh(r,50)),i=/* @__PURE__ */new Set([0,...t]),l=Array.from(i);for(;l.length>0;){const e=kh(a,l.pop());!e||e.end<=e.start||e.end>n.byteLength||Ph(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=Th(o,xh(r,50)),u=[],p=[];let g=0;for(let y=0;y<=s;y+=1){u.push(g);const e=kh(d,y);if(c.has(y)&&e&&e.end>e.start){const t=n.slice(e.start,e.end);p.push(t),g+=Ih(t.byteLength)}}u.push(g);const f=r.slice();Sh(f,8,0),wh(f,50,1);const m=a.slice();wh(m,34,s+1);const h=i.slice();wh(h,4,s+1);const b={cmap:l,head:f,hhea:m,hmtx:Bh(e,s),loca:Rh(u),maxp:h,glyf:Ch(p)};for(const y of["OS/2","name","post"]){const t=e.getRawTableData(y);t&&(b[y]=t)}return b}(e,r),i=we(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 Ah=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 bh(e);return{program:e,layouter:t.hasShaping?t:new yh(e),subsetter:new Mh}}(function(e){const t=G.decodeSync(e);return Ao.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?`<${Xm(e.glyphId)}>`:`<${Xm(e.glyphId)}> ${Nm(t)}`}).join(" ")}] TJ`:`<${r.map(e=>Xm(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=`${zm(e)}>`,o=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${$m(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=`${jm(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${jm(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(Nm).join(" ")}]`,`/ItalicAngle ${Nm(r.italicAngle)}`,`/Ascent ${Nm(r.ascent*e.scale)}`,`/Descent ${Nm(r.descent*e.scale)}`,`/CapHeight ${Nm(r.capHeight*e.scale)}`,`/XHeight ${Nm(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=>Nm(e??0)).join(" ")}]]`,"/CIDToGIDMap /Identity",">>"].filter(Boolean).join("\n")),u=t(function(e,t=""){const n=t?` /${t.trim().replace(/^\/+/,"")}`:"";return`<< /Length ${$m(e)}${n} >>\nstream\n${e}endstream`}(function(e){const t=e.map(e=>`<${_m(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(`<${Hm(o)}> <${Hm(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"))}},Fh=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=`${zm(e)}>`;return[`<< /Length ${$m(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"]))}},Oh=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 Dh(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Dh(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>Nm(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:Wm(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(Nm).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Dh(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Nm).join(" ")}]`,`/C1 [${t.map(Nm).join(" ")}]`,"/N 1",">>"].join("\n")}var Lh=new TextEncoder;function Eh(e){return"string"==typeof e?$m(e):e.length}function Nh(e){const t=e.reduce((e,t)=>e+Eh(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Lh.encode(r):r;n.set(e,o),o+=e.length}return n}function $h(e){const t=yr(Lh.encode(e));return Nh([`<< /Length ${t.length} /Filter /FlateDecode >>\nstream\n`,t,"\nendstream"])}function zh(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function Hh(e){return`<FEFF${_m(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Wh(e){const t=[];if(e.title&&t.push(`/Title ${Hh(e.title)}`),e.author&&t.push(`/Author ${Hh(e.author)}`),e.subject&&t.push(`/Subject ${Hh(e.subject)}`),e.keywords&&t.push(`/Keywords ${Hh(e.keywords)}`),e.producer&&t.push(`/Producer (${zh(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 Uh(e){return e.children.reduce((e,t)=>e+1+Uh(t),0)}function jh(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 ${Nm(t)} /CA ${Nm(t)} >>`));const m=[];for(const B of e){const e=s($h(`${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 (${zh(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${zh(e.uri??"")}) >>`;return s(["<< /Type /Annot /Subtype /Link",`/Rect [${Nm(t)} ${Nm(o)} ${Nm(n)} ${Nm(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 ${Nm(B.width)} ${Nm(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`(${zh(t.name)}) [${n} 0 R /XYZ ${Nm(t.x)} ${Nm(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 "+Hh(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",s?`/Next ${s.id} 0 R`:"",`/Dest (${zh(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 ${Uh(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=Wh(i);e&&(w=s(e))}const S=[Lm];let I=Eh(Lm);const C=[0],T=e=>{S.push(e),I+=Eh(e)};for(const B of l)C[B.id]=I,T(`${B.id} 0 obj\n`),T(B.body),T("\nendobj\n");const k=I;let P=`xref\n0 ${l.length+1}\n`;P+="0000000000 65535 f \n";for(const B of l)P+=`${String(C[B.id]??0).padStart(10,"0")} 00000 n \n`;T(P);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${l.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(k),"%%EOF",""].join("\n")),Nh(S)}var Vh=class{pages=[];streams=[];fonts;images=new Fh;shadings=new Oh;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=Em){this.fonts=new Ah(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 qm(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}),jh(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function Kh(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const l=tn(i),s=tn(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 _h(e){e=sn(e);const t=new Dm,n=pt(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new Vh(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=Cr(e),a=function(e){return mt(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(Mn(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const s of r.pages){const n=Math.max(1,tn(s.pageSettings.width)),r=Math.max(1,tn(s.pageSettings.height)),c=o.addPage({width:n,height:r});await Mm(o,c,n,r,e.design,e.sections?.[s.sectionIndex??0]?.pageBorder,e);const d=s.pageSettings.margins.left+s.pageSettings.margins.gutter,u=de(s.pageSettings);await Bm(o,c,s.headerBlocks,e,d,s.headerTop??nn(s.pageSettings),u,t,a,s.pageSettings);const p=s.bodyTop??be(s.pageSettings);if(s.blocks.some(e=>void 0!==e.columnIndex)){const n=fr(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 Bm(o,c,u,e,r.left,p,r.width,t,a,s.pageSettings,Kh(o,c,r.left,i,l))}}else await Bm(o,c,s.blocks,e,d,p,u,t,a,s.pageSettings,Kh(o,c,d,i,l));await Bm(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:tn(d),y1:tn(s.footnoteSeparatorTop+.5),x2:tn(d+Math.min(180,.35*u)),y2:tn(s.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:tn(1)}),await Gh(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 Mm(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function Xh(e){const t=await _h(e);return new Blob([t],{type:"application/pdf"})}async function Gh(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,Co(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=Ce(void 0,n?.style?.styleId,r.styles),l=s.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:tn(a),y:tn(d+12),text:o,fontSize:Yt(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:l.writerResourceName})}u.add(n)}await Bm(e,t,[g],r,a+24,d,Math.max(24,l-24),s,c),d+=Math.max(0,g.estimatedHeight)+2}}function Yh(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function qh(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 Zh(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 Jh(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 Qh(e){return function(e){const t=C(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=re(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=Ce(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=re(t.style,e.styles),r=t.runs[0],a=Ce(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:Et(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 eb(e,t){const n=Un(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=Kr(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 tb(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 nb(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function ob(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function rb(e){return"page"===e?.positionV?.relativeFrom}function ab(e){return eb(e,e=>"image"===e.kind)}function ib(e,t,n){return mb(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function lb(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function sb(e,t){return mb(e,e=>{const n={...e},o=function(e){if(!e)return;const t=lb(e.left),n=lb(e.top),o=lb(e.right),r=lb(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 cb(e,t){const n=ab(e),o=n&&Gn(n.run);return o?sb(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=lb(a.left),l=lb(a.top),s=lb(a.right),c=lb(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 db(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 ub(e){return mb(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function pb(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function gb(e,t,n=90){const o=ab(e);if(!o||!Gn(o.run))return e;const r="right"===t?-n:n,a=pb(function(e){const t=ab(e);return(t&&Gn(t.run))?.rotation??0}(e)+r);return mb(e,e=>({...e,rotation:a}))}function fb(e,t){const n=function(e){const t=ab(e),n=t&&Gn(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?mb(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function mb(e,t){const n=ab(e);if(!n||!Gn(n.run))return e;const o=Kr(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Xn(e))});return Ie(e,i,N(i,Un(e)))}function hb(e,t){return mb(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function bb(e,t){const n=ab(e);if(!n)return e;const o=Kr(e),{paragraphIndex:a,offset:i,run:l}=n,s=$o(o,t.paragraphId);if(s<0)return e;const u=o[s],p=Bt(u,t),g=s===a&&p>i?p-1:p;if(s===a&&g===i)return e;const f=e=>Ut(e,[...Rt(e,0,i),...Rt(e,i+1,d(e))]),m=(e,t)=>c(e,Math.max(0,Math.min(t,d(e))),[yn("",q(e,t),Gn(l))]),h=o.map((e,t)=>t===a&&t===s?m(f(e),g):t===a?f(e):t===s?m(e,g):r([e])[0]),b=h[s],y=Math.max(0,Math.min(g+1,d(b)));return Ie(e,h,oe(Z(b,y)))}function yb(e,t,n,o=0){const r=de(V(t));if(!n)return r;const a=Wo(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function vb(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await Zh(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(),d=n?.paragraphId??s.selection.focus.paragraphId,u=yb(e.surfaceRef(),s.document,d,s.activeSectionIndex??0),p=i>u?u/i:1,g=Math.max(24,Math.round(i*p)),f=Math.max(24,Math.round(l*p));e.logger.info(`image insert:decoded natural=${i}x${l} fitted=${g}x${f} maxWidth=${u}`),e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ee(n),i=yn("",q(o,a),t),l=c(o,a,[i]),s=Kr(n).map((e,t)=>t===r?l:gn(e));return Ie(n,s,oe(Z(l,a+1)))}(n?Ba(e,{anchor:n,focus:n}):e,{src:r,width:g,height:f,intrinsicWidth:i,intrinsicHeight:l}),{mergeKey:Fi})}}}var xb={"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 wb(e){return function(e){const[t,n]=Jt(null),o=(e,t)=>{const[n,o]=xb[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})},a=()=>{globalThis.setTimeout(()=>{n(e=>"done"===e?.phase||"error"===e?.phase?null:e)},1200)},i=function(e){return{handleImportFile:async t=>{if(!t)return;const n=m(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 a=e.now(),i=await Zh(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:s(e.now()-a,2)});let l=null,c=-1,d=0;const u=await n.import(i,(t,n)=>{const o=e.now(),r=void 0!==n&&Number.isFinite(n)?Math.floor(100*n):void 0,a=t!==l;if(!(a||void 0!==r&&(c<0||r-c>=1)||o-d>=40))return;l=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",Qh(u));const p=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(u),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:s(e.now()-p,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(xo(u));const g=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:s(e.now()-g,2)});const f=Ne(u).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),m=Ve(u).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:f,paragraphs:m,durationMs:s(e.now()-o,2)}),e.focusInput()}catch(a){e.setImportPhase("error"),e.logger.error("import:error",a)}finally{e.clearImportProgressSoon()}}}}({applyState:e.applyState,stabilizeLayoutAfterImport:e.stabilizeLayoutAfterImport,resetEditorChromeState:e.resetEditorChromeState,focusInput:e.focusInput,requestLocalFontAccess:e.requestLocalFontAccess,prepareDocumentFonts:e.prepareDocumentFonts,setImportPhase:r,clearImportProgressSoon:a,now:()=>performance.now(),logger:e.logger}),l=vb({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),c=function(e){const t=e.download??Yh,n=e.print??qh;let o=!1;return{handleExportDocx:async()=>{const n=await om(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await Xh(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await Xh(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>om(e.document()),exportPdfBlob:()=>Xh(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),d=async t=>{e.isReadOnly()||await i.handleImportFile(t)},u=async(e,t)=>{await l.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 Sb(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function Ib(e){return" "===e||"\t"===e||"\n"===e}function Cb(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 Tb(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=Tb(n.blocks,t);if(e)return e}}return null}function kb(e,t){const n=Un(t),o=[],r=e.surfaceRect,a=new Map(Kr(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 Ae(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=Tb(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=Tb(n.blocks,t);if(e)return e}return null}(t.document,s.tableId);if(n){const t=ln(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 w of e.paragraphs){const e=Cb(w.paragraphId,a,n);if(!e)continue;const t=Math.max(e.start,w.startOffset),i=Math.min(e.end,w.endOffset);if(!(t>=i))for(const n of w.lines){let e=Math.max(t,n.startOffset),a=Math.min(i,n.endOffset);for(;e<a&&Ib(Sb(w,e));)e+=1;for(;a>e&&Ib(Sb(w,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===w.startOffset&&n.startOffset===w.startOffset&&n.top>w.top,d=c?w.top:n.top,u=c?n.top+n.height-w.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:u})}}const u=t.selection.focus.paragraphId,p=e.paragraphsById.get(u)??[],g=p[0]?.paragraph,f=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}}(p,g?Bt(g,t.selection.focus):t.selection.focus.offset),m=(f?.left??r.left)-r.left,h=(f?.top??r.top)-r.top,b=Math.max(18,f?.height??28),y={left:m,top:h,height:b,visible:p.length>0&&!d&&!i&&!l};let v=null;const x=(e.paragraphsById.get(u)??[])[0]?.tableCell?.tableId??null;if(x){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===x&&(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&&(v={tableId:x,left:t-r.left,top:n-r.top,width:o-t,height:a-n})}return{selectionBoxes:o,inputBox:{left:m,top:h,height:b},caretBox:y,selectedImageBox:i,selectedTextBoxBox:l,selectedTableBox:v}}function Pb(e,t){if(e)for(const n of e)if("paragraph"!==n.type)for(const e of n.rows)for(const n of e.cells)Pb(n.blocks,t);else t.push(n.id)}function Rb(e){const t=[],n=e=>{if(e)for(const o of e)if("paragraph"!==o.type)for(const e of o.rows)for(const t of e.cells)n(t.blocks);else for(const e of o.runs)t.push(e.text)};return n(e),t.join("").trim()}function Bb(e){return e.cells.flatMap(e=>e.blocks)}function Mb(e){return e.rows.flatMap(Bb)}function Ab(e){return{id:e.id,type:e.type,author:e.author,date:e.date}}function Fb(e){return{id:e.id,type:"property",author:e.author,date:e.date}}function Ob(e){const t=[];return e.style?.revision&&t.push(Ab(e.style.revision)),e.style?.propertyRevision&&t.push(Fb(e.style.propertyRevision)),t}function Db(e){const t=[];return e.style?.revision&&t.push(Ab(e.style.revision)),e.style?.propertyRevision&&t.push(Fb(e.style.propertyRevision)),e.propertyExceptionsRevision&&t.push(Fb(e.propertyExceptionsRevision)),t}function Lb(e){const t=[];return e.style?.revision&&t.push(Fb(e.style.revision)),e.gridRevision&&t.push({id:e.gridRevision.id,type:"grid",author:e.gridRevision.author,date:e.gridRevision.date}),t}function Eb(e){const t=[],n=/* @__PURE__ */new Set,o=(e,o,r,a,i,l)=>{if(n.has(e.id))return;n.add(e.id);const s=[];Pb(l,s),t.push({...e,scope:o,tableId:r,rowIndex:a,cellIndex:i,paragraphIds:s,snippet:Rb(l)})},r=e=>{if(e)for(const t of e)if("paragraph"!==t.type){for(const e of Lb(t))o(e,"table",t.id,void 0,void 0,Mb(t));t.rows.forEach((e,n)=>{for(const r of Db(e))o(r,"row",t.id,n,void 0,Bb(e));e.cells.forEach((e,a)=>{for(const r of Ob(e))o(r,"cell",t.id,n,a,e.blocks);r(e.blocks)})})}};for(const a of Ae(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])r(e);for(const a of Object.values(e.document.footnotes?.items??{}))r(a.blocks);for(const a of Object.values(e.document.endnotes?.items??{}))r(a.blocks);return t}function Nb(e){const t=[],n=/* @__PURE__ */new Set;return Ae(e.document).forEach((e,o)=>{const r=e.propertyRevision;if(!r||n.has(r.id))return;n.add(r.id);const a=[];Pb(e.blocks,a);const i=Rb(e.blocks);t.push({id:r.id,type:"property",author:r.author,date:r.date,sectionId:e.id,sectionIndex:o,paragraphIds:a,snippet:i.length>96?`${i.slice(0,93)}…`:i})}),t}var $b={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments",formatting:"showMarkupFormatting"};function zb(e,t){return e[$b[t]]??!0}function Hb(e,t){return"boolean"==typeof t.allAuthors?Vb(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=Kb(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=Kb(n);return Vb(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Xb(e)):t.section?function(e,t){const n=$b[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function Wb(e,t){return e.markupAuthors?.includes(t)??!0}function Ub(e,t,n){return!("insert"===t&&!zb(e,"insertions"))&&(!("delete"===t&&!zb(e,"deletions"))&&(!("property"===t&&!zb(e,"formatting"))&&Wb(e,n)))}function jb(e){const t=/* @__PURE__ */new Map;for(const n of Eb(e))if(Ub(e,n.type,n.author))for(const e of n.paragraphIds)t.has(e)||t.set(e,null);for(const n of function(e){const t=[];for(const n of Nb(e))Ub(e,n.type,n.author)&&t.push(...n.paragraphIds);return t}(e))t.has(n)||t.set(n,null);for(const n of C(e.document)){const o=[];let r=0;for(const t of n.runs){const n=t.text.length,a=t.revision,i="delete"===a?.type,l=t.styles?.propertyRevision;let s=!1;!a||"insert"!==a.type&&"delete"!==a.type?l&&(s=Ub(e,"property",l.author)):s=Ub(e,a.type,a.author),s&&(i?o.push({start:Math.max(0,r-1),end:r+1}):n>0&&o.push({start:r,end:r+n})),i||(r+=n)}if(0===o.length)continue;const a=t.get(n.id);void 0===a?t.set(n.id,o):null!==a&&t.set(n.id,[...a,...o])}return t}function Vb(e,t){return void 0===e.markupAuthors&&void 0===t||void 0!==e.markupAuthors&&void 0!==t&&e.markupAuthors.length===t.length&&e.markupAuthors.every((e,n)=>e===t[n])?e:{...e,markupAuthors:t}}function Kb(e){return[...new Set(e)].sort()}function _b(e,t){for(const n of e.runs){const e=n.revision?.author??n.revisionRangeMarker?.author??n.styles?.propertyRevision?.author;e&&t.add(e)}}function Xb(e){const t=/* @__PURE__ */new Set,n=e=>{e&&t.add(e)},o=e=>{if(e)for(const r of e)if("paragraph"!==r.type){n(r.style?.revision?.author),n(r.gridRevision?.author);for(const e of r.rows){n(e.style?.revision?.author),n(e.style?.propertyRevision?.author);for(const t of e.cells)n(t.style?.revision?.author),n(t.style?.propertyRevision?.author),o(t.blocks)}}else _b(r,t)},r=C(e.document);for(const s of r)_b(s,t);for(const s of Ae(e.document)){for(const e of[s.blocks,s.header,s.firstPageHeader,s.evenPageHeader,s.footer,s.firstPageFooter,s.evenPageFooter])o(e);n(s.propertyRevision?.author)}const a=e.document.footnotes?.items??{};for(const s of Object.values(a))o(s.blocks);const i=e.document.endnotes?.items??{};for(const s of Object.values(i))o(s.blocks);const l=e.document.comments?.items??{};for(const s of Object.values(l)){const e=s.author??s.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function Gb(e,t){const n=[];let o=0;for(const r of e.runs){const e=o,a=o+r.text.length;o=a;const i=r.revision,l=r.styles?.propertyRevision;let s,c,d;if(!i||"insert"!==i.type&&"delete"!==i.type?l&&(s=l.id,c="property",d=l.author):(s=i.id,c=i.type,d=i.author),void 0!==s&&void 0!==c&&void 0!==d&&Ub(t,c,d)&&a>e){const t=n.at(-1);t&&t.revisionId===s&&t.type===c&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:s,type:c})}}return n}function Yb(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=Gb(r.paragraph,t);if(0!==e.length)for(const t of r.lines)for(const r of e){const e=Math.max(r.start,t.startOffset),a=Math.min(r.end,t.endOffset);if(e>=a)continue;const i=t.slots.find(t=>t.offset===e),l=t.slots.find(e=>e.offset===a)??t.slots[t.slots.length-1];i&&l&&o.push({revisionId:r.revisionId,type:r.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,l.left-i.left),height:t.height})}}return o.push(...function(e,t){const{surfaceRect:n}=e,o=[],r=/* @__PURE__ */new Set;for(const i of e.paragraphs){const e=i.tableCell;if(!e)continue;const t=`${e.tableId}:${e.rowIndex}:${e.cellIndex}`;r.has(t)||(r.add(t),o.push({tableId:e.tableId,rowIndex:e.rowIndex,cellIndex:e.cellIndex,left:e.left,top:e.top,width:e.width,height:e.height}))}const a=[];for(const i of Eb(t)){if(!Ub(t,i.type,i.author))continue;const e=o.filter(e=>e.tableId===i.tableId&&("table"===i.scope||e.rowIndex===i.rowIndex&&("row"===i.scope||e.cellIndex===i.cellIndex)));if(0===e.length)continue;const r=Math.min(...e.map(e=>e.left)),l=Math.min(...e.map(e=>e.top)),s=Math.max(...e.map(e=>e.left+e.width)),c=Math.max(...e.map(e=>e.top+e.height));a.push({revisionId:i.id,type:i.type,variant:"cell",left:r-n.left,top:l-n.top,width:s-r,height:c-l})}return a}(e,t)),o.push(...function(e,t){const{surfaceRect:n}=e,o=[];for(const r of Nb(t)){if(!Ub(t,r.type,r.author))continue;const a=new Set(r.paragraphIds),i=/* @__PURE__ */new Map;for(const t of e.paragraphs){if(!a.has(t.paragraphId))continue;const e=i.get(t.pageIndex)??[];e.push(t),i.set(t.pageIndex,e)}for(const e of i.values()){const t=Math.min(...e.map(e=>e.left)),a=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.left+e.width)),l=Math.max(...e.map(e=>e.top+e.height));o.push({revisionId:r.id,type:r.type,variant:"section",left:t-n.left,top:a-n.top,width:i-t,height:l-a})}}return o}(e,t)),o}function qb(e,t){const{surfaceRect:n}=e,o=/* @__PURE__ */new Map;for(const s of e.pages??[]){const e=s.left+s.width-12-168;o.set(s.index,e-n.left)}const r=e.paragraphs,a=[];for(const s of function(e){const t=/* @__PURE__ */new Map,n=(e,n,o)=>{const r=t.get(e.id);if(r)return r.paragraphIds.push(...n),void(o&&r.snippetParts.push(o));t.set(e.id,{...e,paragraphIds:[...n],snippetParts:o?[o]:[]})};for(const o of C(e.document))for(const e of o.runs){const t=e.revision,r=e.styles?.propertyRevision,a=!t||"insert"!==t.type&&"delete"!==t.type?r?{id:r.id,type:"property",author:r.author,date:r.date,scope:"run"}:void 0:{id:t.id,type:t.type,author:t.author,date:t.date,scope:"run"};a&&n(a,[o.id],e.text)}for(const o of Eb(e))n({id:o.id,type:o.type,author:o.author,date:o.date,scope:o.scope},o.paragraphIds,o.snippet);for(const o of Nb(e))n({id:o.id,type:o.type,author:o.author,date:o.date,scope:"section"},o.paragraphIds,o.snippet);return[...t.values()].map(e=>{return{id:e.id,type:e.type,author:e.author,date:e.date,scope:e.scope,snippet:(t=e.snippetParts.join("").trim(),t.length>96?`${t.slice(0,93)}…`:t),paragraphIds:[...new Set(e.paragraphIds)]};var t})}(t)){if(!Ub(t,s.type,s.author))continue;const e=new Set(s.paragraphIds);let i;for(const t of r)e.has(t.paragraphId)&&(!i||t.top<i.top)&&(i=t);if(!i)continue;const l=o.get(i.pageIndex);if(void 0===l)continue;const c=i.lines[0];a.push({descriptor:s,pageIndex:i.pageIndex,top:(c?c.top:i.top)-n.top,lineHeight:c?c.height:i.height,connectorLeft:i.left+i.width-n.left,balloonLeft:l})}a.sort((e,t)=>e.pageIndex-t.pageIndex||e.top-t.top);const i=/* @__PURE__ */new Map,l=[];for(const s of a){const e=i.get(s.pageIndex)??-1/0,t=Math.max(s.top,e+6);i.set(s.pageIndex,t+42);const n=s.descriptor;l.push({revisionId:n.id,type:n.type,variant:"balloon",left:s.balloonLeft,top:t,width:168,height:42,author:n.author,date:n.date,snippet:n.snippet,connectorLeft:s.connectorLeft,connectorTop:s.top+Math.max(1,s.lineHeight/2),connectorWidth:Math.max(4,s.balloonLeft-s.connectorLeft)})}return l}var Zb={composeMeasuredParagraphLines:e=>On.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>On.resolveRenderedLineHeightPx(e,t)};function Jb(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function Qb(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 ey(){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&&Jb(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&Jb(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&Qb(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&Qb(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 ty(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 ny(e){return function(e){const[t,n]=Jt({}),[o,r]=Jt({}),[a,i]=Jt({left:0,top:0,height:28}),[l,s]=Jt([]),[c,d]=Jt([]),[u,p]=Jt([]),[g,f]=Jt([]),[m,h]=Jt(null),[b,y]=Jt(null),[v,x]=Jt(null),[w,S]=Jt({left:0,top:0,height:28,visible:!1}),[I,C]=Jt(null),T=ey(),k=ge(()=>{Qo();const t=void 0===(n=e.state.reviewDisplayMode)||"all"===n?null:"original"===n?"original":"final";var n;return null===t?e.state.document:Nr(e.state.document,t).document}),P=ge(()=>(Qo(),T(Cr(k(),void 0,t(),o(),{measurer:Zb})))),R=tt();let B=0;const M=(t="selection")=>{const n=e.surfaceRef();if(!n)return s([]),d([]),p([]),f([]),h(null),y(null),x(null),void S(e=>({...e,visible:!1}));const o=R.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:P(),zoomFactor:e.zoomFactor?.()});if(!o)return s([]),d([]),p([]),f([]),h(null),y(null),x(null),void S(e=>({...e,visible:!1}));const r=e.state.reviewDisplayMode??"all";if("all"!==r)return s([]),h(null),y(null),x(null),S({left:0,top:0,height:28,visible:!1}),i({left:0,top:0,height:28}),d([]),p([]),void f("simple"===r&&!1!==e.state.showRevisionMarkup?function(e,t){const n=jb(t);if(0===n.size)return[];const o=e.surfaceRect,r=/* @__PURE__ */new Map;for(const l of e.paragraphs){const e=r.get(l.pageIndex);(void 0===e||l.left<e)&&r.set(l.pageIndex,l.left)}const a=/* @__PURE__ */new Map;for(const l of e.pages??[]){const e=r.get(l.index),t=void 0===e?0:e-l.left;a.set(l.index,l.left+(t>0?.5*t:12)-o.left)}const i=[];for(const l of e.paragraphs){const e=n.get(l.paragraphId);if(void 0===e)continue;const t=a.get(l.pageIndex)??l.left-o.left-12,r=l.lines;if(0===r.length){i.push({paragraphId:l.paragraphId,left:t,top:l.top-o.top,height:Math.max(1,l.height)});continue}const s=null===e?r:r.filter(t=>e.some(e=>e.start<t.endOffset&&e.end>t.startOffset)),c=s.length>0?s:[r[0]];for(const n of c)i.push({paragraphId:l.paragraphId,left:t,top:n.top-o.top,height:Math.max(1,n.height)})}return i}(o,e.state):[]);const a=kb(o,e.state);f([]),s(a.selectionBoxes),p(!1===e.state.showRevisionMarkup?[]:[...Yb(o,e.state),...qb(o,e.state)]),d(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!zb(t,"comments"))return[];const o=e.surfaceRect,r=new Map(Kr(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const l=n.items[i];if(!l?.start||!l?.end||!Wb(t,l.author))continue;const s=r.get(l.start.paragraphId),c=r.get(l.end.paragraphId);if(void 0!==s&&void 0!==c)for(const t of e.paragraphs){const e=r.get(t.paragraphId);if(void 0===e||e<s||e>c)continue;const n=e===s?l.start.offset:0,d=e===c?l.end.offset:Number.POSITIVE_INFINITY,u=Math.max(n,t.startOffset),p=Math.min(d,t.endOffset);if(!(u>=p))for(const r of t.lines){const e=Math.max(u,r.startOffset),t=Math.min(p,r.endOffset);if(e>=t)continue;const n=r.slots.find(t=>t.offset===e),l=r.slots.find(e=>e.offset===t)??r.slots[r.slots.length-1];n&&l&&a.push({commentId:i,left:n.left-o.left,top:r.top-o.top,width:Math.max(1,l.left-n.left),height:r.height})}}}return a}(o,e.state)),h(a.selectedImageBox),y(a.selectedTextBoxBox),x(a.selectedTableBox),i(a.inputBox),S(a.caretBox)},A=(e="selection")=>{const t=++B;queueMicrotask(()=>{t===B&&M(e)})},F=(e="content-change")=>(A(e),!1),O=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(r(e=>ty(e,t.paragraphIds??[])),Lr()),A(e),t.resolveWhenDone?Promise.resolve():null),D=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)n({}),r({}),Lr();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];r(t=>ty(t,e)),Lr()}A("content-change")}},L=async()=>{n({}),r({}),Lr(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),A("import")};br(()=>{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,A("selection")}),br(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||A("content-change")}),br(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.showMarkupFormatting,e.state.markupAuthors,A("content-change")}),br(()=>{e.state.reviewDisplayMode,A("content-change")}),br(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{A("scroll")},o=()=>{A("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),qn(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const E=()=>C(null),N=()=>{B+=1,R.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:o,documentLayout:P,canvasSnapshotProvider:R,inputBox:a,selectionBoxes:l,commentHighlights:c,revisionMarkupBoxes:u,changeBarBoxes:g,selectedImageBox:m,selectedTextBoxBox:b,selectedTableBox:v,caretBox:w,preferredColumnX:I,setPreferredColumnX:C,clearPreferredColumn:E,requestInputBoxSync:A,scheduleDeferredLayoutMeasurement:O,stabilizeLayoutAfterImport:L,syncMeasuredLayoutMetrics:F,syncInputBox:M,setMeasuredBlockHeights:n,setMeasuredParagraphLayouts:r,applyInvalidation:D,onCleanupHook:N}}(e)}function oy(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function ry(e){return function(e){const t=(e,t)=>{const n=Ne(e.document),o=Math.max(0,Math.min(go(e),n.length-1)),r=ao(e),a=n[o];if(!a)return e;const i=[...n],l={...a},s=Xo("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(s):e.push(s),l.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(s):e.push(s),l.footer=e}else{const e=[...a.blocks];t<0?e.unshift(s):e.push(s),l.blocks=e}return i[o]=l,{...e,document:{...e.document,sections:i}}},n=()=>{const t=(n=e.getHistoryState(),o=e.stateSnapshot(),0===n.undoStack.length?null:{history:{undoStack:n.undoStack.slice(0,-1),redoStack:oy(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:oy(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=Kr(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=Kr(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const l=Z(i,n<0?d(i):0);return e.applyTransactionalState(()=>bb(r,l),{mergeKey:Di}),e.focusInput(),!0}const l=r[i],s=n<0?d(l):0;return e.applyTransactionalState(e=>bb(e,Z(l,s)),{mergeKey:Di}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(ir)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function ay(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 iy(e){return function(e){const[t,n]=Jt([]),[o,r]=Jt([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},l=t=>{e.commitState(e.cloneState(t))},s=(t,n)=>{const o=e.stateSnapshot(),r=vn("txn:produce",()=>t(o),0);if(r===o)return;a=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:oy(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const l=vn("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>Ne(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=Kr(e),r=Kr(t),a=/* @__PURE__ */new Map;for(const l of o)a.set(l.id,l);const i=[];for(const l of r){const e=a.get(l.id);if(!e){i.push(l.id);continue}if(e===l)continue;if(e.runs.length!==l.runs.length){i.push(l.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=l.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=Gn(o),i=Gn(r);if(Boolean(a)!==Boolean(i)||(a?.width??-1)!==(i?.width??-1)||(a?.height??-1)!==(i?.height??-1)||(a?.floating?.wrap??"")!==(i?.floating?.wrap??"")||Boolean(a?.floating?.behindDoc)!==Boolean(i?.floating?.behindDoc)||(a?.wrapPolygon?.length??-1)!==(i?.wrapPolygon?.length??-1)){t=!0;break}}t&&i.push(l.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(l),vn("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:s,applyHistoryState:l,resetTransactionGrouping:()=>{var e;e=a,a={...e,lastTransactionMeta:null}},updateHistoryState:e=>{a=e(a),i()},getHistoryState:()=>a,clearHistory:()=>{a={undoStack:[],redoStack:[],lastTransactionMeta:null},i()}}}(e)}function ly(e){let t=e.state.document,n=e.state.selection;br(()=>{const o=e.state.document,r=e.state.selection,a=o!==t,i=r!==n;var l;if(t=o,n=r,e.state.activeSectionIndex,e.state.activeZone,l=e.state,xi&&(Ii={anchor:{paragraphId:l.selection.anchor.paragraphId,runId:l.selection.anchor.runId,offset:l.selection.anchor.offset},focus:{paragraphId:l.selection.focus.paragraphId,runId:l.selection.focus.runId,offset:l.selection.focus.offset},activeZone:l.activeZone??"main",activeSectionIndex:l.activeSectionIndex??0}),e.isImportInProgress())return;const s=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(s),a&&(e.emit("change",s),e.emit("documentChange",s.document)),i&&e.emit("selectionChange",s.selection)})}function sy(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:r,state:a,commitState:i,getStateSnapshot:l,applyState:s,cloneState:c,isReadOnly:d,focusInput:u,surfaceRef:p,viewportRef:g,zoomFactor:f,getImageOps:m}=e,h=wb({state:()=>a,applyState:s,applyTransactionalState:(e,t)=>j(e,t),isReadOnly:d,surfaceRef:()=>p()??null,stabilizeLayoutAfterImport:async()=>{await D()},resetEditorChromeState:()=>q(),focusInput:u,requestLocalFontAccess:wa,prepareDocumentFonts:async e=>{await ke(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,revisionMarkupBoxes:T,changeBarBoxes:k,selectedImageBox:P,selectedTextBoxBox:R,selectedTableBox:B,caretBox:M,preferredColumnX:A,setPreferredColumnX:F,clearPreferredColumn:O,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:L,setMeasuredParagraphLayouts:E,applyInvalidation:N,onCleanupHook:$}=ny({state:a,surfaceRef:p,viewportRef:g,isImporting:b,zoomFactor:f}),z=ay({key:t().persistenceKey}),{status:H}=function(e,t,n){const[r,a]=Jt("Initial"),[i,l]=Jt(!1),s=()=>n.enabled??!1,c=n.persistence,d=_r(async e=>{if(s()&&i()){a("Saving...");try{const t=JSON.parse(JSON.stringify($e(e)));await c.saveDocument(t),a("Saved")}catch(t){n.logger?.error("persistence:autosave failed",t),a("Error")}}},1e3);return br(o(()=>e.document,e=>{s()&&i()&&d(e)},{defer:!0})),Er(async()=>{if(!s())return l(!0),void a("Saved");try{const e=await c.loadDocument();e&&t(e)}catch(e){n.logger?.error("persistence:load failed",e)}finally{l(!0),a("Saved")}}),{status:r}}(a,e=>{n.info("persistence:loaded",{docId:e.id});const t=xo(e);i(t),q()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??z,logger:n}),{undoStack:W,redoStack:U,applyTransactionalState:j,applyHistoryState:V,resetTransactionGrouping:K,updateHistoryState:_,getHistoryState:X,clearHistory:G}=iy({stateSnapshot:l,commitState:i,cloneState:c,applyLayoutInvalidation:N}),Y=ry({state:()=>a,stateSnapshot:l,applyHistoryState:V,applyTransactionalState:j,focusInput:u,clearPreferredColumn:O,imageOps:m,updateHistoryState:_,getHistoryState:X}),q=()=>{O(),L({}),E({}),Lr(),w.clear(),G()};return ly({state:a,isImportInProgress:b,cloneState:c,getStateSnapshot:l,getOnStateChange:()=>t().onStateChange,emit:r.emit}),{docIO:h,isImportInProgress:b,measuredBlockHeights:y,measuredParagraphLayouts:v,documentLayout:x,canvasSnapshotProvider:w,inputBox:S,selectionBoxes:I,commentHighlights:C,revisionMarkupBoxes:T,changeBarBoxes:k,selectedImageBox:P,selectedTextBoxBox:R,selectedTableBox:B,caretBox:M,preferredColumnX:A,setPreferredColumnX:F,clearPreferredColumn:O,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:L,setMeasuredParagraphLayouts:E,applyLayoutInvalidation:N,onCleanupHook:$,fallbackPersistence:z,persistenceStatus:H,undoStack:W,redoStack:U,applyTransactionalState:j,applyHistoryState:V,resetTransactionGrouping:K,updateHistoryState:_,getHistoryState:X,clearHistory:G,historyActions:Y,resetEditorChromeState:q}}(e)}function cy(e){return eb(e,e=>"textBox"===e.kind)}function dy(e,t){const n=cy(e);if(!n||!Dr(n.run))return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}function uy(e,t){const n=cy(e);if(!n||!Dr(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?gn(e):{...gn(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Xn(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return Ie(e,a,N(a,Un(e)))}function py(e,t,n,o={}){const r=cy(e),a=r&&Dr(r.run);if(!r||!a)return e;const i=o.handleDirection??"se",l=i.includes("n")||i.includes("s"),s=i.includes("w"),c=i.includes("n"),d=Math.max(24,Math.round(t)),u=Math.max(24,Math.round(n)),{paragraphIndex:p,run:g}=r,f=d-a.width,m=u-a.height,h=Kr(e).map((e,t)=>t!==p?gn(e):{...gn(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Xn(e);const t=e.textBox,n={...t,width:d,height:u};return l&&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*rr}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*rr}})}return a}(t.floating,f,m,s,c)),{...e,textBox:n}})});return Ie(e,h,N(h,Un(e)))}var gy=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),fy=e=>e.rows.reduce((e,t)=>Math.max(e,gy(t)),0),my=(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 hy(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}var by=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=hy(e);if(t)return t}return null};function yy(e,t){return e.some(e=>Po(e).some(e=>e.id===t))}var vy=(e,t,n)=>{const o=Jr(e,t);if(!o)return null;const r=A(e,t,o.sectionIndex);if(!r)return null;const a=function(e,t,n){for(const o of e){if(!yy(o,n))continue;const e=i(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Jr(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=Ae(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 l=a.rows.flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),s=l.findIndex(e=>function(e,t){return e.blocks.some(e=>Po(e).some(e=>e.id===t))}(e,t));if(-1===s)return null;const c=hy(l[s+n]);return c?Z(c,0):null};function xy(e,t){return Boolean(e?.some(e=>Po(e).some(e=>e.id===t)))}function wy(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])=>xy(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>xy(e,o))?.[0]??"footer":"blocks"}function Sy(e){const t=Jr(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function Iy(e,t){if("footnote"===t){const t=Sy(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=Ne(e.document),o=go(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=wy(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var Cy=(e,t,n="main")=>{if("footnote"===n){const n=Sy(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=go(e),r=Ne(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const l=wy(e,i,n),s=[...r];return s[a]="blocks"===l?{...i,blocks:t}:{...i,[l]:t},{...e,document:{...e.document,sections:s}}};function Ty(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function ky(e,t){const n=i(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:Ty(t),targetBlocks:e}:null}function Py(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]=To(a),ky(i,n)}var Ry=(e,t,n)=>{const o=A(e.document,e.selection.focus.paragraphId,go(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?ky(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 a=n({...e,document:Qn(r.targetCell.blocks.map(e=>"paragraph"===e.type?gn(e):e),void 0,void 0,void 0,void 0,e.document.assets),selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}}),i=Ne(a.document)[0]?.blocks??[];return r.targetCell.blocks.splice(0,r.targetCell.blocks.length,...i),{...Cy(e,r.targetBlocks,o.zone),selection:a.selection}};function By(e,t){const n=A(e.document,e.selection.focus.paragraphId,go(e));return n?Py(e,t,n):null}function My(e,t,n,o){const r=Cy(e,t,n);return o?{...r,selection:{anchor:Z(o,0),focus:Z(o,0)}}:r}function Ay(e,t,n,o){const r=t.getTargetBlocks(e,n),a=i(r,o);return a?.[a.length-1]?.table??null}function Fy(e,t){const n=A(e.document,e.selection.focus.paragraphId,go(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Ay(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function Oy(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=Fy(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=Ay(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=Fy(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!==Fy(t,e),s=t=>{const n=Fy(t,e);return Boolean(n&&fy(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:l,canEditSelectedTableColumn:s}}(e)}function Dy(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function Ly(e){return e.blocks.flatMap(Po)}function Ey(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Ny(e,t){return function(e,t){const n=e.selection,o=go(e),r=A(e.document,n.anchor.paragraphId,o),a=A(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 l=t.getTargetBlocks(e,r.zone),s=i(l,r.tablePath),c=i(l,a.tablePath),d=s?.[s.length-1],u=c?.[c.length-1];if(!d||!u||d.table!==u.table)return null;const p=Ey(r),g=Ey(a),f=d.table,m=ln(f),h=m.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex),b=m.find(e=>e.rowIndex===g.rowIndex&&e.cellIndex===g.cellIndex);return h&&b?{anchorLocation:p,focusLocation:g,anchorCell:h,focusCell:b,tableBlock:f,tableLayout:m}:null}(e,t)}function $y(e){return function(e){const t=t=>{const n=t.selection,o=Ny(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=Dy(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Dy(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?Ly(d)[0]:void 0,g=u?Ly(u):[],f=g[g.length-1];return p&&f?{anchor:Z(p,0),focus:Z(f,Et(f).length)}:null},n=t=>{const n=Ny(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=Ny(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Dy(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=Ny(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 zy(e){if(e)for(const t of e.blocks){const e=Po(t)[0];if(e)return e}}function Hy(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?Py(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Wy(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=>To(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Hy(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?ts():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=>To(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=zy(d);return u?My(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Hy(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?ts():void 0,d={...l[0],rowSpan:l.length,vMerge:"restart",blocks:l.flatMap(e=>e.blocks.map(e=>To(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=ma([Xo("")],s);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=zy(d);return u?My(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=By(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?ts():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):ma([],u)})]});for(let e=1;e<s;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=ma([Xo("")],u);t.cells[a.cellIndex]=n}const p=zy(l);return p?My(n,i,a.zone,p):n},i=n=>{const o=By(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?ts():void 0,p=[{...s,colSpan:void 0,blocks:s.blocks.map(e=>To(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},()=>ma([Xo("")]))];l.cells.splice(a.cellIndex,1,...p);const g=zy(p[0]);return g?My(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 Uy(e,t){e.style={...e.style??{},revision:{...ts(),type:t}}}function jy(e){if(!e)return null;for(const t of e.blocks){const e=Po(t)[0];if(e)return e}return null}function Vy(e,t,n){const o=jy(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=jy(r);if(e)return e}return by(e)}function Ky(e){return function(e){const t=(t,n)=>{const o=By(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=ln(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=Fn(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=ma([Xo("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return ma([Xo("")],t.colSpan)})),t.trackChangesEnabled&&Uy(c,"insert"),r.rows.splice(s,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=Vy(r,my(c,d),c);return My(t,i,a.zone,u)}c=Fn(l.cells.map(e=>ma([Xo("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&Uy(c,"insert"),r.rows.splice(s,0,c);const d=Vy(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return My(t,i,a.zone,d)},n=t=>{const n=By(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 Uy(i,"delete"),My(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?ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(l){const e=ln(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=Vy(o,c?my(c,Math.min(s?.visualColumnIndex??r.cellIndex,Math.max(0,gy(c)-1))):null);return My(t,a,r.zone,d)},o=(t,n)=>{const o=By(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=ln(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=ma([Xo("")]);t.trackChangesEnabled&&Uy(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:{...ts(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=ma([Xo("")]);t.trackChangesEnabled&&Uy(n,"insert"),e.push(n)}n.cells=e}const l=r.rows[a.rowIndex],s=Vy(r,l?my(l,o):null);return My(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=ma([Xo("")]);t.trackChangesEnabled&&Uy(n,"insert"),e.cells.splice(l,0,n)}const s=r.rows[a.rowIndex]?.cells[l],c=Vy(r,s);return My(t,i,a.zone,c)},r=t=>{const n=By(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(fy(o)<=1)return t;if(t.trackChangesEnabled){const e=ln(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=my(t,e);n&&Uy(n,"delete")}return My(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=ln(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=Vy(o,n&&my(n,Math.min(e,Math.max(0,gy(n)-1))));return My(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=Vy(o,l);return My(t,a,r.zone,s)};return{insertSelectedTableRow:t,deleteSelectedTableRow:n,insertSelectedTableColumn:o,deleteSelectedTableColumn:r}}(e)}function _y(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 d=[],u=[];for(const e of s){const t=e.cell.blocks.flatMap(Po);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p=n({...r,document:Qn(d,void 0,void 0,void 0,void 0,r.document.assets),selection:{anchor:Z(d[0],0),focus:Z(d[d.length-1],Et(d[d.length-1]).length)}}),g=Kr(p),f=l[l.length-1];if(!f)return r;const m=Py(r,e.getTargetBlocks,{blockIndex:i,rowIndex:f.rowIndex,cellIndex:f.cellIndex,paragraphIndex:0,tablePath:l,zone:c});if(!m)return r;let h=0;for(let e=0;e<s.length;e+=1){const t=s[e],n=u[e]??0,o=g.slice(h,h+n);h+=n;const r=m.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=lt(r.blocks,o))}return Cy(r,m.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function Xy(e){return function(e){const t=Iy,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=$y({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:l,canMergeSelectedTableRows:s,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=Oy({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Wy({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:s,canSplitSelectedTableCell:l,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,deleteSelectedTableRow:w,insertSelectedTableColumn:S,deleteSelectedTableColumn:I}=Ky({getTargetBlocks:t}),C=(e,n)=>Ry(e,t,n),{withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P}=_y({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?ts():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...ma([Xo("")]),style:{width:o}});const t=Fn(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...Gr(a),style:{width:"100%"}},l=nr(e,e.selection.focus),s=Ae(e.document),c=go(e),d=ao(e),u=e=>{const t=e.findIndex(e=>e.id===l.paragraphId||"paragraph"!==e.type&&Po(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:oe(Z(h,0))}}(e,t,n),{mergeKey:Oi}),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:gy,getTableVisualWidth:fy,findCellAtVisualColumn:my,findFirstNavigableParagraphInTable:by,updateBlocksInCurrentSection:Cy,resolveAdjacentTableCellPosition:vy,applyTableAwareParagraphEdit:C,withExpandedTableCellSelection:T,applySelectionAwareTextCommand:k,applySelectionAwareParagraphCommand:P,insertTableCommand:R}}(e)}function Gy(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function Yy(e,t){let n=null;const o=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=Gy(),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}=Ia(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:oy(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 qy(e,t){let n=null;const o=Gy(),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=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(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:oy(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 Zy(e,t){return Math.max(1e-4,1-e-t)}function Jy(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 Qy(e){let t=null;const n=(e,t,n)=>{const o=Kr(e).find(e=>e.id===t);return o?{anchor:Z(o,n),focus:Z(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=Gy(),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=Zy(a,l)/o,d=Zy(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=Zy(a,l)/o,d=Zy(i,s)/r,u=Be(e.handleDirection,"x"),p=Be(e.handleDirection,"y");let g=a,f=l,m=o;if(0!==u)if(u<0){m=gt(o-t,24,o+a/c);const e=Jy(a,l,a-(m-o)*c,l);g=e.near,f=e.far}else{m=gt(o+t,24,o+l/c);const e=Jy(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=gt(r-n,24,r+i/d);const e=Jy(i,s,i-(y-r)*d,s);h=e.near,b=e.far}else{y=gt(r+n,24,r+s/d);const e=Jy(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(sb(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:oy(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=ab(o(u,g)),m=f&&Gn(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 ev(e){return function(e){const[t,n]=Jt(!1),[o,r]=Jt(!1),[a,i]=Jt(null);br(()=>{o()&&!m(e.state)&&r(!1)});const l=()=>{m(e.state)?r(e=>!e):r(!1)},[s,c]=Jt({x:0,y:0}),[d,u]=Jt(null);let p=null,g=null,f=null;const m=e=>{const t=Un(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=Kr(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:qe(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=Gy(),x=()=>{y(),g=null,p=null,n(!1),i(null),u(null),v.release(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P)},w=()=>{x()},S=Yy({label:"image",getSelected:e=>m(e),applyResize:(e,t,n)=>ib(e,t,n),getMaxWidth:(t,n)=>yb(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=qy({label:"image",applyRotate:(e,t)=>function(e,t){const n=pb(t);return mb(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}),T=Qy({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),k=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=>bb(e,o),{mergeKey:Di})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}x(),e.focusInput()}else e.focusInput()},R=(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",k),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P)},B=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=C(e.state.document).find(e=>e.id===t);r&&e.applyState(Ba(e.state,{anchor:Z(r,n),focus:Z(r,n+1)})),R(t,n,o),e.focusInputAfterPointerSelection()},M=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),S.start(t,n,o,r,e.state)},A=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),I.start(t,n,o,e.state)},F=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),T.start(t,n,o,r,e.state)},O=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),T.startMove(t,n,o,e.state)};return{dragging:t,cropMode:o,setCropMode:r,toggleCropMode:l,draggedImageInfo:a,mousePos:s,dropTargetPos:d,getSelectedImageInfo:m,startImageDrag:R,stopImageDrag:w,stopImageResize:S.stop,stopImageRotate:I.stop,stopImageCrop:T.stop,handleImagePointerDown:B,handleImageResizeHandlePointerDown:M,handleImageRotateHandlePointerDown:A,handleImageCropHandlePointerDown:F,handleImageCropBodyPointerDown:O}}(e)}function tv(e){return function(e){const t=e=>{const t=cy(e),n=t&&Dr(t.run);return n?{width:n.width,height:un(n,e,0)}:null},n=Yy({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>py(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=yb(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=qy({label:"text box",applyRotate:(e,t)=>dy(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 nv(e){return function(e){const[t,n]=Jt(void 0),o=()=>{n(void 0)};br(()=>{zr(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=ie(e.state()),o=t();return zr(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(zr(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(zr(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(zr(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 ov(e,t,n={}){if(!t)return[];const o=[],r=C(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=Et(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:Z(e,n),focus:Z(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function rv(e,t,n,o={}){const r=ov(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=Ba(a,{anchor:e.anchor,focus:e.focus}),a=$a(a,n)}return a}function av(e,t,n,o,r,a){const i=e+n,l=t+o;return(a<t?t-a:a>l?a-l:0)*et+(r<e?e-r:r>i?r-i:0)}function iv(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*et+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 lv(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=iv(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function sv(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function cv(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=av(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=Z(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)&&sv(o,r,l))return l}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&sv(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=Z(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}=iv(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=av(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:lv(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=Z(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 dv(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){xi&&(Si=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 ki(null),null;const s=cv({snapshot:l,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return ki(s),s};return{resolveSurfaceHitAtPoint:t}}(e)}var uv=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],pv=/* @__PURE__ */new Map;function gv(){return uv.map(e=>({...e}))}var fv=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function mv(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 hv(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=mv(e[s],r,a);t>n&&(n=t,o=s)}if(n<=t)return[r,a];const i=hv(e.slice(0,o+1),t),l=hv(e.slice(o),t);return[...i.slice(0,-1),...l]}function bv(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 gv();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]=fv[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 gv();const a=.012*Math.max(t,n);let i=hv(r,a),l=a;for(;i.length>40;)l*=1.6,i=hv(r,l);return i.length<3?gv():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function yv(e){const t=e.src,n=pv.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 gv();const r=bv(o.mask,o.width,o.height);return pv.set(t,r),r.map(e=>({...e}))}function vv(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>ab(t())?"image":cy(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},l=(e,n)=>{const r=qe(t().document,n),a=t=>{const n=yv(t);o(t=>function(e,t,n){const o=Kr(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...gn(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Xn(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:gn(e));return r?Ie(e,a,N(a,Un(e))):e}(t,e,n),{mergeKey:Ki})},i=Zt(r,()=>{i.naturalWidth>0&&a(i)});i.complete&&i.naturalWidth>0&&a(i)};return{target:a,preset:()=>{const e=a();return"image"===e?function(e){const t=ab(e),n=t&&Gn(t.run);return n?nb(n.floating):null}(t()):"textBox"===e?function(e){const t=cy(e),n=t&&Dr(t.run);return n?nb(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=ab(e),n=t&&Gn(t.run);return rb(n?.floating)}(t()):"textBox"===e&&function(e){const t=cy(e),n=t&&Dr(t.run);return rb(n?.floating)}(t())},setPreset:e=>{if(i(Dl,(t,n)=>"image"===n?function(e,t){return hb(e,e=>tb(e,t))}(t,e):function(e,t){return uy(e,e=>tb(e,t))}(t,e)),"tight"===e||"through"===e){const e=ab(t()),n=e&&Gn(e.run);n&&!n.wrapPolygon&&l(e.run.id,n.src)}},setFixedPosition:e=>i(Ll,(t,n)=>"image"===n?function(e,t){return hb(e,e=>e?ob(e,t):e)}(t,e):function(e,t){return uy(e,e=>e?ob(e,t):e)}(t,e))}}function xv(e){return function(e){const t=t=>{const n=Ra(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Fa(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},n=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Ra(e.state());if(0!==n.length&&(t.preventDefault(),t.clipboardData)){try{t.clipboardData.setData("text/plain",n),t.clipboardData.setData("text/html",Fa(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(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=>Ha(e,n))),t.currentTarget.value="",void e.focusInput())}const o="merge"!==n?Jh(t.clipboardData):null;if(o)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(o),t.currentTarget.value="",void e.focusInput();const r=ti(t.clipboardData?.getData("text/html")??""),a="merge"===n?ei(e.state(),r):r;if(a.length>0)return t.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Oa(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=>Ha(e,i))),t.currentTarget.value="",e.focusInput())},r=t=>{if(e.isReadOnly())return void t.preventDefault();const n=Jh(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 wv=/* @__PURE__ */new WeakMap;function Sv(e,t){return function(e){return Ne(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function Iv(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=wv.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 wv.set(a,c),c}function Cv(e,t,n,o,r,a){const i=Iv(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=Sv(n,l.geometry.tableId);if(!s)return null;const c=ln(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 Tv=1/.75;function kv(e){return.75*e}function Pv(e){return e*Tv}var Rv=Bs;function Bv(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,Pv(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?Pv(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?Pv(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,Pv(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,Pv(e.style.borderRight.width)):1)}function Mv(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=Rv(e.rows[l]?.style?.height);if(null!==n){a[l]=Math.max(1,Pv(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 Av(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,Pv(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,kv(a[s]));return{widthsPt:l,maxColumnIndex:r}}function Fv(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??Pv(10),r=Math.max(Pv(10),t.minRowHeightPx??Pv(10)),a=Math.max(10,kv(Math.max(r,o+n)));return function(e,t,n,o){return Rs(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Ov(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 Dv=null;function Lv(e,t){Dv=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 Ev(e){e&&Dv!==e||(Dv=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Nv(e,t){Lv(e,t)}function $v(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function zv(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Hv(e){const[t,n]=Jt(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 Ev();const i=Cv(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Lv("left"===i.side||"right"===i.side,l):Ev()},c=Gy(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=$v(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:Ov(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(zv(o),o=null),null!==a&&(zv(a),a=null),n(null),Ev(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?Fv(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=kv(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,kv(i[t.index]??Pv(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 Ms(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,kv(i[e]??Pv(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=Sv(e,t.tableId),g=Rv(p?.style?.width),f=d?u:null!==g?g:void 0;return Ms(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=$v(s))))},handlePointerDown:t=>{r=null,null!==o&&(zv(o),o=null),Ev();const a=e.surfaceRef();if(!a)return!1;const i=Cv(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const s=e.state(),u=ln(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}=Av(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=Pv(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,ca(n,e.document.styles)),1);a[o]=Math.max(s,c+Bv(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:Rv(i.tableNode.style?.indentLeft)??0,guideBounds:Ov(e.viewportRef)}),Nv(!0,l),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=Mv(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 Pv(10);const a=Pv(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:Ov(e.viewportRef)}),Nv(!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 Wv=null;function Uv(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=Pv(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 jv(e){const[t,n]=Jt(null);let o=null,r=null;const a={},i=Gy(),l=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=$v(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&&(zv(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Wv===a&&(Wv=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}=Uv(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=Ms(e,t.tableId,r,a),l={};return t.rowHeightsPx.forEach((e,t)=>{l[t]=Math.max(10,kv(e*o))}),Rs(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}=Uv(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=Iv(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=Sv(e.state(),t);if(!s||!c)return;const u=ln(c),{widthsPt:p}=Av(c,u,s),g=Mv(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}),Wv=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 Vv=null;function Kv(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=Kv(n.blocks,t,!0,!1);if(e)return e}}return null}function _v(e,t){for(const n of Ae(e)){for(const e of[n.blocks,n.header,n.footer]){const n=Kv(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=Kv(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=Kv(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=Kv(n.blocks,t,!1,!1);if(e)return e}return null}function Xv(e){return function(e){const[t,n]=Jt(!1),[o,r]=Jt(null),[a,i]=Jt(null),[l,s]=Jt(0),[c,d]=Jt(0),[u,p]=Jt({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=Gy(),v=()=>{f=null,null!==g&&(zv(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),Vv===m&&(Vv=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=_v(e,n);return Boolean(o?.table&&Po(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),Vv=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=$v(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=_v(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return Ts(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*Br,y:(t.y??0)+(n.clientY-l())*Br,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?M(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 Gv=e=>"touch"===e.pointerType;function Yv(e,t){if(!e||0===e.length){const e=yt(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:Po(n)[0]??null,blocks:e}}function qv(e,t,n){const o=C(e.document).filter(t=>{const o=Jr(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:Z(t,0),end:a?Z(a,0):Z(t,Et(t).length)}}function Zv(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?Jr(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=yt("header"),t=yt("footer");s={...s,sections:[{id:"section:1",blocks:[],pageSettings:qt(s.pageSettings??jt),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=Yv(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=Yv(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?Z(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=go(n),a=St(n.document,o.anchor.paragraphId,r),i=St(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",k)},w=e=>{g=e,window.addEventListener("pointermove",C),window.addEventListener("pointerup",T),window.addEventListener("pointercancel",k)},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(Jr(i.document,t.paragraphId)?.sectionIndex!==Jr(i.document,a.paragraphId)?.sectionIndex)return;const l=Ba(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()}},k=e=>{null!==g&&e.pointerId!==g||x()},P=(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=Z(r,o.textBox.startOffset),i=Z(r,o.textBox.endOffset);b(n,o.zone,Ba(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=Z(a,o.image.startOffset),l=Z(a,o.image.endOffset);b(n,o.zone,Ba(n,{anchor:i,focus:l}),i),x(),Gv(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,Ba(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=null;const a=qv(n,r,o.zone);b(n,o.zone,Ba(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},F=(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=Z(r,o.paragraphOffset);return b(n,o.zone,Ba(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const l=ze(Et(r),o.paragraphOffset),s=Z(r,l.start),c=Z(r,l.end);b(n,o.zone,Ba(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(!Gv(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?A(n,o,i):2===r&&i?F(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),Gv(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,o,r)},D=(t,n,o)=>{O(e.state(),t,n,o),e.focusInputSync()},L=()=>{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=ze(Et(a),o.paragraphOffset),l=Z(a,i.start),s=Z(a,i.end);b(r,o.zone,Ba(r,{anchor:l,focus:s}),l),t=l,e.focusInputSync()},E=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)=>Gv(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,Gv(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(L,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=qv(o,i,a.zone);b(o,a.zone,Ba(o,{anchor:l.start,focus:l.end}),l.start),x(),e.focusInputAfterPointerSelection()},$=(e,t)=>{0===t.button&&(Gv(t)||t.preventDefault(),E(t))};return{handleSurfacePointerDown:E,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:$,stopDragging:x}}(e)}function Jv(e){return function(e){const[t,n]=Jt(!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=Zo(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}=Ee(e);if(r<t)return e;const a=Kr(e),i=r-t,l=Ut(n,[...Rt(n,0,i),...Rt(n,r,d(n))],q(n,i)),s=a.map((e,t)=>t===o?l:e);return Ie(e,s,oe(Z(l,i)))}(e,s);return t.length>0?$a(n,t,c):n}),{mergeKey:Ai}),n?(l(),i=t.length>0?t:null):(r=t.length,a=t)},c=n=>{if(co("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=Kr(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=Zo(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>$a(e,o,u)),{mergeKey:Mi}),n.currentTarget.value="",e.focusInput(),bo("input:text")},u=()=>{e.logger.debug("input:composition start"),l(),i=null,o=Zo(e.pendingCaretTextStyle()),n(!0)},p=t=>{e.isReadOnly()||s(t.data??"",!1)},g=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:u,handleCompositionUpdate:p,handleCompositionEnd:g,composing:t}}(e)}var Qv="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 ex(e,t){const n=Un(e);if(n.isCollapsed)return!1;const o=Kr(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=Bt(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function tx(e){return function(e){const[t,n]=Jt(!1),[o,r]=Jt(null),[a,i]=Jt(!1),[l,s]=Jt(null),[c,d]=Jt(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: ${Qv} !important; }`,document.head.appendChild(p))},h=Gy(),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=>Na(e,t,{copy:n})),{mergeKey:n?tl:nl}),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=>ex(e,t)?Ba(e,{anchor:t,focus:t}):e,{mergeKey:ol}),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):ex(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 nx(e){return e.blocks.flatMap(Po)}function ox(e,t){if(!e)return;const n=nx(e);return"start"===t?n[0]:n[n.length-1]}function rx(e){return function(e){const t=(t,n)=>{const o=e.state(),r=Kr(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:Et(r).length,i=Z(r,a);return e.clearPreferredColumn(),e.applyState(Ba(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=Kr(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:Et(a).length,l=Z(a,i);return e.clearPreferredColumn(),e.applyState(Ba(o,{anchor:n?o.selection.anchor:l,focus:l})),!0},o=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const l=Et(i),s=o.selection.focus.offset,c=l.length;if(!n&&!zr(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?Ma(o):Aa(o)),!0;let d=i,u=s;"left"===t?0===s&&a>0?(d=r[a-1],u=Et(d).length):u=Oe(l,s):s===c&&a<r.length-1?(d=r[a+1],u=0):u=Bo(l,s);const p=Z(d,u);return e.clearPreferredColumn(),e.applyState(Ba(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=Kr(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const l=e.surfaceRef(),s=l?.getBoundingClientRect()??null,c=e.preferredColumnX(),d=null===c?e.caretBox().left+(s?.left??0):c,u=l?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:l,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let p=a+t;const g=A(o.document,o.selection.focus.paragraphId,go(o)),f=g?.tablePath[g.tablePath.length-1];if(g&&f){const e=Iy(o,g.zone),n=i(e,g.tablePath),a=n?.[n.length-1]?.table;if(a){const e=ln(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&&nx(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=ox(e.cell,"start")?.id,n=t?u?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??d,r=n?n.left+n.width:d;return{entry:e,distance:d<o?o-d:d>r?d-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const l=ox(i.cell,t<0?"end":"start");p=l?r.findIndex(e=>e.id===l.id):-1;break}}else if(t<0){const e=ox(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=ox(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=u?io(u,m.id):[],y=t<0?b[b.length-1]:b[0];if(y&&y.lines.length>0){const e=y.lines,n=t<0?e[e.length-1]:e[0];h=n.slots.length?n.slots.reduce((e,t)=>Math.abs(d-t.left)<Math.abs(d-e.left)?t:e,n.slots[0]).offset:0}else h=Math.min(Bt(m,o.selection.focus),Et(m).length);return e.setPreferredColumnX(d),e.resetTransactionGrouping(),e.applyTransactionalState(e=>Ba(e,{anchor:n?e.selection.anchor:Z(m,h),focus:Z(m,h)})),e.focusInput(),!0};return{moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function ax(e){return function(e){const[t,n]=Jt(null),o=(t,o)=>{const r=Kr(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 Ae(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 ix(e){const t=Kr(e);if(!t.length)return null;const n=Un(e,t),o=t[n.startIndex];if(!o)return null;const r=(n.isCollapsed?[]:Rt(o,n.startParagraphOffset,n.startIndex===n.endIndex?n.endParagraphOffset:d(o))).find(e=>"text"===e.kind&&e.text.length>0),a=function(e){const t=Zo(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(Ce(r?r.styles:q(o,n.startParagraphOffset),o.style?.styleId,e.document.styles)),i=n.isCollapsed||0===n.startParagraphOffset&&(n.endIndex>n.startIndex||n.endParagraphOffset===d(o));return{text:a,paragraph:i?Or(o.style):void 0,list:i&&o.list?{...o.list}:void 0,copyParagraph:i}}function lx(e,t){const n=Kr(e);if(!n.length)return e;const o=Un(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:d(e),l=t.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===d(e))}(e,n,o),s=l?Or(t.paragraph):e.style,c=l?t.list?{...t.list}:void 0:e.list,u=l&&(JSON.stringify(s)!==JSON.stringify(e.style)||JSON.stringify(c)!==JSON.stringify(e.list)),p=a<i&&Rt(e,a,i).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const n=Zo(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!Cn(e.styles,o)});if(!u&&!p)return e;r=!0;let g=p?Ye(e,a,i,e=>{if("text"!==e.kind)return e;const n=Zo(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&&(g={...g,style:s,list:c}),g});return r?Ie(e,a,N(a,o)):e}function sx(e){const t=Kr(e);if(!t.length)return"";const n=Un(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function cx(e){const[t,n]=Jt(null);let o=null,r=null,a="";const i=()=>{o=null,r=null,a="",n(null)};pn()&&(br(()=>{t()&&(e.isReadOnly()||e.state().document!==r)&&i()}),qn(i));const l=()=>!e.isReadOnly()&&Kr(e.state()).length>0,s=t=>{if(!l())return!1;const i=e.state(),s=ix(i);return!!s&&(o=s,r=i.document,a=sx(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(sx(l)===a)return!1;const s=function(e,t){const n=Kr(e);if(0===n.length)return null;const o=Un(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=ze(Et(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:Z(r,a.start),focus:Z(r,a.end)}}}(l,"pointer"===n);if(!s)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return X(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==r)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:s.selection},e=>lx(e,o));return c=n.document!==t.document,n}),"once"===t()?i():c&&(r=e.state().document)}),c&&e.focusInput(),c}}}function dx(e){return function(e){const{state:t,logger:n,isReadOnly:r,applyState:a,cloneState:i,focusInput:l,focusInputAfterPointerSelection:s,focusInputSync:c,surfaceRef:d,viewportRef:u,zoomFactor:p,insertImageFromFile:g,getForcePlainTextPaste:f,setForcePlainTextPaste:m,getCommandsController:h,applyTransactionalState:b,clearPreferredColumn:y,resetTransactionGrouping:v,updateHistoryState:x,caretBox:w,preferredColumnX:S,setPreferredColumnX:I,documentLayout:C,canvasSnapshotProvider:T}=e,k=()=>ab(t),P=()=>cy(t),R=vv({state:()=>t,resetTransactionGrouping:v,applyTransactionalState:b,focusInput:l}),B=dv({state:()=>t,surfaceRef:()=>d()??null,viewportRef:()=>u()??null,documentLayout:C,canvasSnapshotProvider:T,zoomFactor:p}).resolveSurfaceHitAtPoint,M=function(e){const[t,n]=Jt(""),[r,a]=Jt(""),[i,l]=Jt({matchCase:!1,wholeWord:!1}),[s,c]=Jt([]),[d,u]=Jt(-1),[p,g]=Jt(!1);br(o([()=>e.state.document,t,i],([e,t,n])=>{const o=ov(e,t,n);c(o),0===o.length?u(-1):(d()>=o.length||-1===d())&&u(0)}));const f=t=>{const n=s()[t];n&&e.applyState(Ba(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:n,replaceTerm:r,setReplaceTerm:a,findOptions:i,setFindOptions:l,matches:s,currentIndex:d,findNext:()=>{const e=s().length;if(0===e)return;const t=(d()+1)%e;u(t),f(t)},findPrevious:()=>{const e=s().length;if(0===e)return;const t=(d()-1+e)%e;u(t),f(t)},replace:()=>{if(0===s().length||-1===d())return;const t=s()[d()];e.applyTransactionalState(e=>$a(Ba(e,{anchor:t.anchor,focus:t.focus}),r()),{mergeKey:qi})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>rv(e,n,r(),i()),{mergeKey:Zi}),g(!1),e.focusInput())},isOpen:p,setIsOpen:g}}({state:t,applyState:a,applyTransactionalState:b,focusInput:l}),A=Xy({applyTransactionalState:b,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:Pn(e).document,selection:t}),focusInput:l,logger:n}),F=cx({state:()=>t,isReadOnly:r,applyTransactionalState:b,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:l}),O=(e,t)=>B(e,t)?.position??null,D=ev({state:t,surfaceRef:d,resolvePositionAtSurfacePoint:O,applyState:a,applyTransactionalState:b,updateHistoryState:x,focusInput:l,focusInputAfterPointerSelection:s,cloneState:i,logger:n,zoomFactor:p}),L=tv({state:t,surfaceRef:d,applyState:a,updateHistoryState:x,focusInput:l,cloneState:i,logger:n,zoomFactor:p}),E=nv({state:()=>t,commandsController:h,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:l,logger:n}),N=function(e){const t=()=>e.state,n=Hv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=jv({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=Xv({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=ax({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=tx({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=Zv({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:Oo,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),s=Jv({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=rx({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}=xv({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:a,applyTransactionalState:b,isReadOnly:r,logger:n,focusInput:l,focusInputAfterPointerSelection:s,focusInputSync:c,clearPreferredColumn:y,resetTransactionGrouping:v,surfaceRef:d,viewportRef:u,caretBox:()=>w(),preferredColumnX:()=>S(),setPreferredColumnX:I,zoomFactor:p,documentLayout:C,canvasSnapshotProvider:T,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:A,imageOps:D,styleController:E,formatPainter:F,getForcePlainTextPaste:f,setForcePlainTextPaste:m,clipboardActions:e.clipboardActions,insertImageFromFile:g,openEquationDialog:e.openEquationDialog}),$=e=>{0===e.button&&(E.clearPendingCaretTextStyle(),e.preventDefault(),l())};return{selectedImageRun:k,selectedTextBoxRun:P,layoutOptionsOverlay:R,fr:M,resolveSurfaceHitAtPoint:B,resolvePositionAtSurfacePoint:O,tableOps:A,imageOps:D,textBoxOps:L,styleController:E,formatPainter:F,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 ux(e){if("main"!==(e.activeZone??"main"))return e;const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ee(n),i=to(),l=function(e){const n=e.footnotes,o=n?.settings?.numberFormat??"decimal";let r=(n?.settings?.startAt??1)-1;const a=/* @__PURE__ */new Set;for(const{run:i}of ar(e)){const e=t(i);e&&!e.customMark&&(a.has(e.footnoteId)||(a.add(e.footnoteId),r+=1))}return kn(r+1,o)}(n.document),s=sa(i.id,l),d=c(o,a,[s]),u=Kr(n).map((e,t)=>t===r?d:e),p=Z(d,a+l.length),g=Ie(n,u,En(p)),f=function(e){return e||{items:{}}}(g.document.footnotes),m={...g.document,footnotes:{...f,items:{...f.items,[i.id]:i}}},h=Mr(m),b=i.blocks.flatMap(Po).find(Boolean);return b?{...g,document:h,selection:En(Z(b,0)),activeZone:"footnote",activeFootnoteId:i.id}:{...g,document:h}}function px(e){if(!e)return;const{propertyRevision:t,...n}=e;return Object.keys(n).length>0?n:void 0}function gx(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:gx(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 fx(e,t,n){const o=Ae(e.document).map(e=>({...e,blocks:gx(e.blocks,t,n),header:e.header?gx(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?gx(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?gx(e.evenPageHeader,t,n):void 0,footer:e.footer?gx(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?gx(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?gx(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function mx(e,t,n){const o=Ae(e.document),r=o.findIndex(e=>e.propertyRevision?.id===t);if(-1===r)return e;const a=o[r],i=a.propertyRevision,l=[...o];if(n)l[r]={...a,propertyRevision:void 0};else{const e=structuredClone(i.previous);l[r]={...a,pageSettings:e.pageSettings,pageBorder:e.pageBorder,pageNumbering:e.pageNumbering,verticalAlignment:e.verticalAlignment,bidi:e.bidi,propertyRevision:void 0};const t=l[r+1];t&&(l[r+1]={...t,breakType:e.nextBreakType})}return{...e,document:{...e.document,sections:l}}}function hx(e,t){const n=Kr(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.styles?.propertyRevision?.id===t?{...e,styles:px(e.styles)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return mx(fx(Ie(e,n,N(n,Un(e))),t,!0),t,!0)}function bx(e,t){const n=Kr(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}const n=e.styles?.propertyRevision;return n?.id===t?{...e,styles:px(n.previous)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:Ut(e,n)});return mx(fx(Ie(e,n,N(n,Un(e))),t,!1),t,!1)}function yx(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>yx(e,t))))}function vx(e,t,n){for(const o of e)if("paragraph"!==o.type){yx(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=>yx(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),vx(e.blocks,t,n)}}}function xx(e){const t=Un(e),n=Kr(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:d(e),l=Rt(e,r,i);for(const t of l)t.revision?.id&&o.add(t.revision.id),t.styles?.propertyRevision?.id&&o.add(t.styles.propertyRevision.id)}const r=new Set(n.slice(t.startIndex,t.endIndex+1).map(e=>e.id));for(const a of Ae(e.document))for(const e of[a.blocks,a.header,a.firstPageHeader,a.evenPageHeader,a.footer,a.firstPageFooter,a.evenPageFooter])e&&vx(e,r,o);for(const a of Nb(e))a.paragraphIds.some(e=>r.has(e))&&o.add(a.id);return o}function wx(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),n.styles?.propertyRevision?.id&&t.add(n.styles.propertyRevision.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 Ae(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}function Sx(e){return wx(e).size>0}function Ix(e,t){if(!Sx(e))return e;const n=er(e.document,t);if(!n.changed)return e;const o=Kr({...e,document:n.document}),r=N(o,Un(e));return{...e,document:n.document,selection:r}}function Cx(e){const t=Un(e),n=Kr(e);if(t.isCollapsed){const e=n[t.startIndex];return e?Lt(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:d(e);return Rt(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 Tx(e){const t=Un(e),n=Kr(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return gn(e);if(!e.list)return gn(e);const o=e.list.level??0;return o<=0?j(e):he(e,o-1)});return Ie(e,n,N(n,t))}function kx(e){return function(e){const{state:t,logger:n,applyState:o,applyTransactionalState:i,applySelectionAwareTextCommand:l,applySelectionAwareParagraphCommand:s,applyTableAwareParagraphEdit:c,focusInput:u,clearPreferredColumn:p,resetTransactionGrouping:g,toolbarStyleState:f,selectionCollapsed:m,selectedImageRun:h}=e,b=e=>{p(),g(),o(e),u()},y=e=>{p(),g(),l(e),u()},v=e=>{p(),g(),s(e),u()},x=(e,t)=>{p(),g(),i(e,t),u()},w=()=>{const e=Un(t);return Kr(t).slice(e.startIndex,e.endIndex+1)},S=()=>w().some(e=>Boolean(e.list)),C=()=>{const e=t.selection.focus.paragraphId;return Kr(t).find(t=>t.id===e)??null},T=()=>{const e=C();return!!e?.list&&(p(),g(),m()&&0===Et(e).length?s(e=>function(e){const t=Un(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?gn(e):j(e));return Ie(e,n,N(n,t))}(e)):i(e=>c(e,e=>function(e){const t=zr(e.selection)?e:Me(e),{paragraph:n,index:o,offset:a}=Ee(t),i=Ut(n,Rt(n,0,a),q(n,a)),l=Rt(n,a,d(n)),s=l.length>0?ce(n,l.map(e=>({text:e.text,styles:e.styles}))):(()=>{const e=Xo("");return e.style=n.style?{...n.style}:void 0,e.list=it(n.list),e})(),c=Kr(t),u=[...r(c.slice(0,o)),i,s,...r(c.slice(o+1))];return Ie(t,u,oe(Z(s,0)))}(e)),{mergeKey:Li}),u(),!0)},k=()=>{const e=t.selection,n=go(t),o=St(t.document,e.anchor.paragraphId,n),r=St(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(m())return;const o=t.selection;n.info(`toggleStyle:${e} at ${o.anchor.paragraphId}:${o.anchor.runId}[${o.anchor.offset}..${o.focus.offset}]${k()}`),y(t=>Va(t,e))},R=e=>{m()||y(t=>function(e,t){const n=Un(e);if(n.isCollapsed)return e;const o=Kr(e).map((o,r)=>{if(r<n.startIndex||r>n.endIndex)return o;const a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:d(o);return Ye(o,a,i,n=>{let r=So(ja(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!Ce(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return Ie(e,o,N(o,n))}(t,e))},B=(e,o)=>{if(m())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}]${k()}`),y(t=>Ka(t,e,o))},M=(e,t)=>{v(n=>je(n,e,t))},A=e=>{const t=!f()[e];M(e,"widowControl"===e?t:!!t||null)},F=()=>{x(e=>c(e,e=>Zr(e)))},O=()=>"main"===(t.activeZone??"main"),D=()=>{O()&&x(e=>ux(e))},L=e=>{const n=Cx(t);m()&&!n||x(t=>function(e,t){const n=Un(e);if(!n.isCollapsed)return Ka(e,"link",t);const o=Kr(e)[n.startIndex];if(!o)return e;const r=Lt(o,n.startParagraphOffset);if(!r)return e;const a=Ka(Ba(e,{anchor:Z(o,r.startOffset),focus:Z(o,r.endOffset)}),"link",t),i=Kr(a)[n.startIndex];return i?{...a,selection:{anchor:Z(i,r.startOffset),focus:Z(i,r.endOffset)}}:a}(t,e),{mergeKey:Ei})},E=()=>{const n=Cx(t)??"";m()&&!n||e.openLinkDialog(n)},$=()=>e.openFontDialog(),z=()=>e.openParagraphDialog(),H=()=>{L(null)},W=()=>{const t=h();if(!t)return;const n=Gn(t.run)?.alt??"";e.openImageAltDialog(n)},U=t=>{h()&&x(n=>function(e,t,n){const o=ab(e);if(!o||!Gn(o.run))return e;const a=Kr(e),i=o.paragraphIndex+1,l=i<a.length&&vr(a[i])?en(a[i],t,n):Gt(t,n,1),s=i<a.length&&vr(a[i])?[...r(a.slice(0,i)),l,...r(a.slice(i+1))]:[...r(a.slice(0,i)),l,...r(a.slice(i))],c=me(s),d=c[i]??l;return Ie(e,c,oe(Z(d,Y(d))))}(n,t,e.imageCaptionLabel()),{mergeKey:$i})},V=()=>{h()&&e.openImageCaptionDialog(function(e){const t=ab(e);if(!t||!Gn(t.run))return null;const n=Kr(e);return Se(n[t.paragraphIndex+1])}(t)??"")};return{applyBooleanStyleCommand:P,applyToggleCharacterBorderCommand:()=>{m()||y(e=>function(e){const t=Un(e);if(t.isCollapsed)return e;const n=Kr(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:d(e);return Rt(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:d(e);return Ye(e,o,a,e=>({...e,styles:Ga(e.styles,r)}))});return Ie(e,a,N(a,t))}(e))},applyValueStyleCommand:B,applyUnderlineStyleCommand:R,applyChangeTextCaseCommand:e=>{m()||y(t=>Za(t,e))},applyClearFormattingCommand:()=>{m()||y(e=>function(e){const t=Un(e);if(t.isCollapsed)return e;const n=Kr(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:d(e);return Ye(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return Ie(e,n,N(n,t))}(e))},applyParagraphStyleCommand:M,toggleParagraphFlagCommand:A,applyParagraphListCommand:e=>{v(t=>function(e,t){const n=Un(e),o=Kr(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 gn(e);const o=gn(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 Ie(e,s,N(s,n))}(t,e))},handleListFormatChange:e=>{v(t=>function(e,t){const n=Un(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?gn(e):e.list?{...gn(e),list:{...e.list,format:t||void 0}}:gn(e));return Ie(e,o,N(o,n))}(t,e))},handleListStartAtChange:e=>{v(t=>function(e,t){const n=Un(e),o=Kr(e).map((e,o)=>o<n.startIndex||o>n.endIndex?gn(e):e.list?{...gn(e),list:{...e.list,startAt:null!==t?t:void 0}}:gn(e));return Ie(e,o,N(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{b(wt(t,e))},applyInsertPageBreakCommand:F,canInsertFootnoteCommand:O,applyInsertFootnoteCommand:D,handleStyleChange:e=>{v(t=>I(t,e||null))},applyUpdateSectionSettingsCommand:(e,n)=>{b(a(t,e,n))},applyToggleTrackChangesCommand:()=>{b(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(t))},applyToggleRevisionMarkupCommand:()=>{b(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(t))},applySetReviewDisplayModeCommand:e=>{b(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(t,e))},applyShowMarkupCommand:e=>{b(Hb(t,e))},applyToggleShowMarginsCommand:()=>{o({...t,showMargins:!t.showMargins}),u()},applyToggleShowParagraphMarksCommand:()=>{o({...t,showParagraphMarks:!t.showParagraphMarks}),u()},applyAcceptRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of xx(e))t=hx(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{x(e=>function(e){let t=e;for(const n of xx(e))t=bx(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{x(e=>function(e){return Ix(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{x(e=>function(e){return Ix(e,"reject")}(e))},applyLinkCommand:L,promptForLink:E,openFontDialog:$,openParagraphDialog:z,openStylesDialog:()=>{n.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{n.warn("pageSetupDialog not yet implemented")},removeLinkCommand:H,applyImageAltCommand:e=>{h()&&x(t=>function(e,t){return mb(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:Ni})},promptForImageAlt:W,applyImageCaptionCommand:U,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=ab(e),o=n&&Gn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*$n));return ib(e,r,r*(o.height/o.width))}(t,e),{mergeKey:zi})},applyImageHeightCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||x(t=>function(e,t){const n=ab(e),o=n&&Gn(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*$n));return ib(e,r*(o.width/o.height),r)}(t,e),{mergeKey:zi})},applyImageCropAspectCommand:e=>{if(!h())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&&x(e=>"reset"===t?ub(e):cb(e,t),{mergeKey:Hi})},applyImageCropShapeCommand:e=>{h()&&x(t=>function(e,t){const n=t?.trim();return mb(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:Hi})},applyImageCropFillCommand:()=>{h()&&x(e=>function(e){const t=ab(e),n=t&&Gn(t.run);return n?mb(sb(e,{crop:db(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Hi})},applyImageCropFitCommand:()=>{h()&&x(e=>function(e){return mb(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Hi})},resetImageCropCommand:()=>{h()&&x(e=>ub(e),{mergeKey:Hi})},applyImageBorderCommand:e=>{h()&&x(t=>function(e,t){return mb(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=>{h()&&x(t=>fb(t,e),{mergeKey:Wi})},rotateImageCommand:e=>{h()&&x(t=>gb(t,e),{mergeKey:Ui})},applyImageTransparencyCommand:e=>{h()&&x(t=>function(e,t){return null===ab(e)?e:mb(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:ji})},resetImageCommand:()=>{h()&&x(e=>function(e){return null===ab(e)?e:mb(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:Vi})},handleListTab:e=>!St(t.document,t.selection.focus.paragraphId,go(t))&&(!!S()&&(v(t=>"indent"===e?function(e){const t=Un(e),n=Kr(e).map((e,n)=>n<t.startIndex||n>t.endIndex?gn(e):e.list?he(e,(e.list.level??0)+1):gn(e));return Ie(e,n,N(n,t))}(t):Tx(t)),!0)),handleListEnter:T,handleListBoundaryBackspace:e=>{const n=C();return!(!n?.list||!m())&&(0===Bt(n,t.selection.focus)&&(p(),g(),s(e=>Tx(e)),e.currentTarget.value="",u(),!0))}}}(e)}function Px(e){return{fontFamily:e.fontFamily??"",fontSize:wn(e.fontSize),color:e.color??"",colorMode:e.color?"custom":"automatic",highlight:e.highlight??"",shading:e.textShading??"",bold:Boolean(e.bold),italic:Boolean(e.italic),underline:Boolean(e.underline),underlineStyle:e.underlineStyle?e.underlineStyle:null,underlineColor:e.underlineColor??"",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),characterScale:e.characterScale??"",characterSpacing:e.characterSpacing??"",baselineShift:e.baselineShift??"",kerningThreshold:e.kerningThreshold??"",ligatures:e.ligatures??"",numberSpacing:e.numberSpacing??"",numberForm:e.numberForm??"",stylisticSet:e.stylisticSet??"",contextualAlternates:Boolean(e.contextualAlternates)}}function Rx(e){return{align:e.align??"",indentLeft:e.indentLeft??"",indentRight:e.indentRight??"",indentFirstLine:e.indentFirstLine??"",indentHanging:e.indentHanging??"",mirrorIndents:e.mirrorIndents??!1,spacingBefore:e.spacingBefore??"",spacingAfter:e.spacingAfter??"",lineHeight:e.lineHeight??"",lineRule:e.lineRule??"",contextualSpacing:e.contextualSpacing??!1,outlineLevel:e.outlineLevel??"",shading:e.shading??"",borderStyle:e.borderStyle??"",borderWidth:e.borderWidth??"",borderColor:e.borderColor??"",borderSideTop:e.borderSideTop??!1,borderSideRight:e.borderSideRight??!1,borderSideBottom:e.borderSideBottom??!1,borderSideLeft:e.borderSideLeft??!1,pageBreakBefore:e.pageBreakBefore??!1,keepWithNext:e.keepWithNext??!1,keepLinesTogether:e.keepLinesTogether??!1,widowControl:e.widowControl??!0,tabs:e.tabs??[]}}function Bx(e){return function(e){const t=kx({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:()=>zr(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}),openFontDialog:()=>{e.setFontDialog({isOpen:!0,initial:Px(e.toolbarStyleState())})},openParagraphDialog:()=>{e.setParagraphDialog({isOpen:!0,initial:Rx(e.toolbarStyleState())})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function Mx(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}var Ax=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)return n.canExecuteCommand?.(a.command)??!0?(n.executeCommand(a.command),e.preventDefault(),!0):(e.preventDefault(),!0);if(!1!==a.execute(t,e))return e.preventDefault(),!0}return!1}},Fx=[{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=Kr(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(Ba(t,{anchor:Z(o,0),focus:Z(r,Et(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:"repeatLastAction",command:"repeatLastAction",key:"F4",ctrlOrMeta:!1,execute:e=>(e.executeCommand?.("repeatLastAction"),!0)},{id:"find",command:"find",key:"f",ctrlOrMeta:!0,execute:e=>(e.toggleFindReplace(!0),!0)},{id:"commandSearch",command:"openCommandSearch",key:"q",alt:!0,execute:e=>(e.toggleCommandSearch(!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=>Zr(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=>$a(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=>za(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=>Fo(e))),e.focusInput()),!0)}];function Ox(e){return function(e){const t=new Ax;Fx.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(),!zr(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e))),n.currentTarget.value="",void e.focusInput();const t=Kr(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===Bt(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>Tx(e)),n.currentTarget.value="",void e.focusInput();const a=o.selection.focus.offset,i=Et(r),l=ze(i,a);return"Backspace"===n.key?0===a||l.start===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Wa(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ba(t,{anchor:Z(r,l.start),focus:Z(r,a)}),e=>Wa(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(e))):l.end>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(Ba(t,{anchor:Z(r,a),focus:Z(r,l.end)}),e=>Wa(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(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=>Wa(e))),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Ua(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(ka(o,-1))):(e.clearPreferredColumn(),e.applyState(Ma(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return ka(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(Aa(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return Pa(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return Ta(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return Pa(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return Ta(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var Dx=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var Lx={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"}},Ex={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},Nx={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 $x(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function zx(e,t){return function(e,t){const n=Lx[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 Hx(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function Wx(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function Ux(e){return null!=e&&""!==e?Number(e):null}function jx({gate:e,style:t,selection:n,history:o,formatting:r,dialog:a,link:i,command:l,valueCommand:s,actionCommand:c}){const d=t.state;return{selectAll:l("selectAll",r.selectAll),selectWord:l("selectWord",r.selectWord),selectSentence:l("selectSentence",r.selectSentence),selectParagraph:l("selectParagraph",r.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:s("selectText",e=>{const t=e??{};return r.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:c("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:l("insertFootnote",r.insertFootnote),setNoteOptions:c("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:Ux(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:l("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:l("updateTableOfContents",r.updateTableOfContents,()=>({isEnabled:e.isCommandEnabled("updateTableOfContents")&&r.hasTableOfContents()})),insertText:c("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:c("insertEquation",e=>{r.insertEquation(e)}),updateEquation:c("updateEquation",e=>{const t=e;r.updateEquation(t.runId,t.expression)}),pastePlainText:l("pastePlainText",r.pastePlainText),formatPainter:l("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:l("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:l("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:l("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:l("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:l("underline",r.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:l("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:l("wordUnderline",r.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:l("strike",r.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:l("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:l("smallCaps",r.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:l("allCaps",r.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:l("hidden",r.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:l("noProof",r.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:l("webHidden",r.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:l("specVanish",r.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:l("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:l("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:l("shadow",r.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:l("emboss",r.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:l("engrave",r.engrave,()=>({isActive:Boolean(d().imprint)})),outline:l("outline",r.outline,()=>({isActive:Boolean(d().outline)})),superscript:l("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:l("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:l("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:l("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:l("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:l("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:l("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:l("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:l("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:l("find",r.find),replace:l("replace",r.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),setReviewDisplayMode:s("setReviewDisplayMode",e=>{const t="string"==typeof e?e:e?.mode;return("all"===t||"final"===t||"original"===t||"simple"===t)&&r.setReviewDisplayMode(t)},()=>r.reviewDisplayMode()),toggleTrackChanges:l("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),toggleRevisionMarkup:l("toggleRevisionMarkup",r.toggleRevisionMarkup,()=>({isActive:r.areRevisionMarkupVisible()})),showMarkupOptions:s("showMarkupOptions",()=>!1,()=>r.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{r.applyShowMarkup(e??{})}),toggleOutlinePanel:l("toggleOutlinePanel",r.toggleOutlinePanel,()=>({isActive:r.areOutlineVisible()})),toggleRevisionsPanel:l("toggleRevisionsPanel",r.toggleRevisionsPanel,()=>({isActive:r.areRevisionsPanelVisible()})),acceptRevisions:l("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:l("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:l("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:l("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),requestAcceptAllRevisions:l("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&r.hasRevisionsInDocument()})),requestRejectAllRevisions:l("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:l("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:l("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:l("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:l("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:l("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:l("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:l("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:l("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:l("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:l("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:l("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:l("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:l("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:l("togglePreciseFonts",r.togglePreciseFonts,()=>(f(),{isActive:Sa()})),undo:l("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:l("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:l("pageBreak",r.pageBreak),lineBreak:l("lineBreak",r.lineBreak),columnBreak:l("columnBreak",r.columnBreak),splitBlock:l("splitBlock",r.splitBlock),insertNonBreakingSpace:l("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:l("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:l("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:l("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:l("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:l("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:l("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:l("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:s("setFontFamily",e=>r.setFontFamily(e||null),()=>d().fontFamily),setFontSize:s("setFontSize",e=>{const t=e&&"object"==typeof e&&"size"in e?e.size:e;if(null==t||""===t)return r.setFontSize(null);if("string"!=typeof t&&"number"!=typeof t)return!1;const n=kr(t);return null!==n&&r.setFontSize(n)},()=>wn(d().fontSize)),increaseFontSize:l("increaseFontSize",r.increaseFontSize),decreaseFontSize:l("decreaseFontSize",r.decreaseFontSize),growFont1:l("growFont1",r.growFont1),shrinkFont1:l("shrinkFont1",r.shrinkFont1),changeTextCase:c("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:l("clearFormatting",r.clearFormatting),setColor:s("setColor",e=>r.setColor(e??null),()=>d().color||null),setHighlight:s("setHighlight",e=>r.setHighlight(e??null),()=>d().highlight||null),setTextShading:s("setTextShading",e=>r.setTextShading(e??null),()=>d().textShading||null),setStyleId:s("setStyleId",e=>r.setStyleId(String(e)),()=>{const e=d();return e.mixedParagraphStyles?"":e.styleId||"normal"}),setCharacterStyleId:s("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:s("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:s("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:s("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:s("setCharacterScale",e=>r.setCharacterScale(Ux(e)),()=>d().characterScale),setCharacterSpacing:s("setCharacterSpacing",e=>r.setCharacterSpacing(Ux(e)),()=>d().characterSpacing),setRunSnapToGrid:s("setRunSnapToGrid",e=>r.setRunSnapToGrid(Hx(e)),()=>d().snapToGrid),setFitText:s("setFitText",e=>r.setFitText(Ux(e)),()=>d().fitText),setBaselineShift:s("setBaselineShift",e=>r.setBaselineShift(Ux(e)),()=>d().baselineShift),setEmphasisMark:s("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:s("setTextEffect",e=>r.setTextEffect(e||null),()=>d().textEffect),setKerning:s("setKerning",e=>r.setKerning(Ux(e)),()=>d().kerningThreshold),setLigatures:s("setLigatures",e=>r.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:s("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:s("setNumberForm",e=>r.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:s("setStylisticSet",e=>r.setStylisticSet(Ux(e)),()=>d().stylisticSet)}}function Vx({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()),saveDocument:i("saveDocument",()=>n.saveDocument()),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()),openCommandSearch:i("openCommandSearch",()=>n.openCommandSearch()),repeatLastAction:i("repeatLastAction",()=>n.repeatLastAction()),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 Kx({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(Hx(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(Ux(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(Ux(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(Hx(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(Wx(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(Wx(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(Hx(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(Hx(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(Hx(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(Hx(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(Hx(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(Hx(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(Hx(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(Hx(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(Hx(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(Hx(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(Hx(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(Hx(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(Hx(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(Hx(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(Ux(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(Ux(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(Ux(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(Ux(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",Ux(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(Ux(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(Ux(e))),setListLevel:r("setListLevel",e=>t.setListLevel(Ux(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=po(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 _x({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 Xx({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 Gx({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 Yx({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()),tableSetCellAlignment:n("tableSetCellAlignment",e=>t.setCellAlignment(e),()=>({value:t.getCellAlignmentState()})),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(Hx(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(Hx(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(Hx(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(Hx(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(Ux(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(Ux(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(Wx(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 qx({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())}}function Zx({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",()=>{e.openParagraphDialog()})}}var Jx=/* @__PURE__ */new Set(["copy","selectAll","selectWord","selectSentence","selectParagraph","selectCollapse","nextRevision","previousRevision","nextComment","previousComment","toggleCommentsPanel","find","replace","print","exportDocx","exportPdf","toggleShowMargins","toggleShowParagraphMarks","togglePreciseFonts","toggleRevisionMarkup","showMarkupOptions","applyShowMarkup","toggleRevisionsPanel","toggleOutlinePanel","setReviewDisplayMode","imageContext","tableContext","toggleTableGridlines","documentStyles"]),Qx=/* @__PURE__ */new Set(["bold","italic","underline","doubleUnderline","wordUnderline","strike","doubleStrike","smallCaps","allCaps","hidden","noProof","webHidden","specVanish","contextualAlternates","characterBorder","shadow","emboss","engrave","outline","superscript","subscript","setFontFamily","setFontSize","increaseFontSize","decreaseFontSize","growFont1","shrinkFont1","changeTextCase","clearFormatting","setColor","setHighlight","setTextShading","setCharacterStyleId","setUnderlineStyle","applyUnderlineStyle","setUnderlineColor","setCharacterScale","setCharacterSpacing","setRunSnapToGrid","setFitText","setBaselineShift","setEmphasisMark","setTextEffect","setKerning","setLigatures","setNumberSpacing","setNumberForm","setStylisticSet"]),ew=/* @__PURE__ */new WeakMap;function tw(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!Qx.has(t)||!function(e){const t=e.state?.();if(!t)return!1;const n=t.document,o=t.selection;if(!n||!o)return!1;let r=ew.get(n);r||(r=/* @__PURE__ */new WeakMap,ew.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==eb(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((Jx.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function nw(e){return{state:()=>e.styleController.toolbarStyleState()}}function ow(e){return{isCollapsed:()=>zr(e.state().selection)}}function rw(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var aw={nbsp:" ",nbHyphen:"‑",optionalHyphen:"",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function iw(e){return/\p{L}|\p{N}/u.test(e)}function lw(e){return"."===e||"!"===e||"?"===e}function sw(e,t){return Z(e,t)}function cw(e,t,n,o){return e-n||t-o}function dw(e,t){const n=Kr(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:sw(o,t.startOffset),focus:sw(r,t.endOffset)}}:e}function uw(e,t,n){if(!t.length)return null;const o=Kr(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?Un(e,o).end:Un(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const l=o[i],s=Bt(l,a);return("next"===n?t.find(e=>cw(e.startIndex,e.startOffset,i,s)>0):[...t].reverse().find(e=>cw(e.startIndex,e.startOffset,i,s)<0))??("next"===n?t[0]:t[t.length-1])}function pw(e){const t=Kr(e),n=[],o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(const a of[...Eb(e),...Nb(e)]){const e=a.paragraphIds[0];if(!e)continue;const t=r.get(e)??[];t.push(a.id),r.set(e,t)}return t.forEach((e,t)=>{for(const i of r.get(e.id)??[])o.has(i)||(o.add(i),n.push({id:i,startIndex:t,startOffset:0,endIndex:t,endOffset:e.runs.reduce((e,t)=>e+t.text.length,0)}));let a=0;for(const r of e.runs){const e=[r.revision?.id,r.styles?.propertyRevision?.id].filter(e=>"string"==typeof e);for(const i of e)o.has(i)||(o.add(i),n.push({id:i,startIndex:t,startOffset:a,endIndex:t,endOffset:a+r.text.length}));a+=r.text.length}}),n}function gw(e,t){const n=uw(e,pw(e),t);return n?dw(e,n):e}function fw(e){const t=Kr(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)));cw(i,d,l,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:l,endOffset:u})}return r.sort((e,t)=>cw(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function mw(e,t){const n=uw(e,fw(e),t);return n?dw(e,n):e}function hw(e){const t=fw(e);if(!t.length)return null;const n=Un(e),o=t.find(e=>0===cw(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===cw(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>cw(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&cw(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function bw(e,t){const n=pw(e).find(e=>e.id===t);return n?dw(e,n):e}var yw=e=>Math.round(e/Wr*96);function vw(e,t=3){const n=[];for(const o of C(e.document)){const e=ga(o.style?.styleId);if(null===e||e>t)continue;const r=Et(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function xw(e){const t=so(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 ww(e,t){const n=Xo("");return n.runs=e,t&&(n.style=t),n}function Sw(e,t,n){const o=void 0!==t?String(t):"";return ww([xw({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:yw(40),indentLeft:yw(397*(e.level-1))})}function Iw(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return s(o*Br,2)}function Cw(e,t,n,o){const r=Ae(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:oe(Z(o,0))}}function Tw(e,t=()=>{},n=3){if("main"!==ao(e))return e;const o=go(e),r=Ae(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>Sw(e,t(e.id),n));return[ww([xw({text:"",fieldChar:{kind:"begin"}}),xw({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),xw({text:"",fieldChar:{kind:"separate"}})]),...o,ww([xw({text:"",fieldChar:{kind:"end"}})])]}(vw(e,n),t,Iw(r)),i=nr(e,e.selection.focus),l=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&Po(e).some(e=>e.id===i.paragraphId)),s=-1===l?r.blocks.length:l+1;return Cw(e,o,[...r.blocks.slice(0,s),...a,...r.blocks.slice(s)],a[0])}function kw(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=dn(e),s=ot(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 Pw(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?vo(n):11,r="increase"===t?tr(o):Ln(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",xr(r)),!0},n=e=>{const t=Cr(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=C(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:Z(n,0),focus:Z(o,Et(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ee(e),o=Et(t);let r=n,a=n;for(;r>0&&iw(o[r-1]);)r-=1;for(;a<o.length&&iw(o[a]);)a+=1;return Ba(e,{anchor:Z(t,r),focus:Z(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=Ee(e),o=Et(t);let r=n;for(;r>0&&!lw(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!lw(o[a]);)a+=1;return a<o.length&&(a+=1),Ba(e,{anchor:Z(t,r),focus:Z(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=Kr(e),n=Un(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?Ba(e,{anchor:Z(o,0),focus:Z(r,d(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=Kr(e),a=Pr(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return Ba(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=ov(e.document,t)[Math.max(1,n)-1];return o?Ba(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 Ba(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=>$a(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ee(n),i=q(o,a),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},s=c(o,a,[l]),d=Kr(n).map((e,t)=>t===r?s:e);return Ie(n,d,oe(Z(s,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=Kr(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?Ie(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=Ae(e.document)[go(e)];return!!t&&null!==kw(t.blocks)}(e.state()),hasRevisionsInSelection:()=>xx(e.state()).size>0,hasRevisionsInDocument:()=>Sx(e.state()),hasNavigableRevisions:()=>pw(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),fw(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=gw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=gw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=mw(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=mw(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==hw(e.state()),isSelectedCommentResolved:()=>Boolean(hw(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=>Tw(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=go(e),r=Ae(e.document)[o];if(!r)return e;const a=kw(r.blocks);if(!a)return e;const i=vw(e,n).map(e=>Sw(e,t(e.id),Iw(r)));return Cw(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=>rv(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:Zi}),e.focusInput()),!0),isTrackChangesEnabled:()=>Boolean(e.state().trackChangesEnabled),areMarginsVisible:()=>Boolean(e.state().showMargins),areParagraphMarksVisible:()=>Boolean(e.state().showParagraphMarks),areRevisionMarkupVisible:()=>Boolean(e.state().showRevisionMarkup??!0),areOutlineVisible:()=>e.isOutlineVisible(),toggleRevisionsPanel:()=>(e.toggleRevisionsPanel(),!0),areRevisionsPanelVisible:()=>e.revisionsPanelVisible(),reviewDisplayMode:()=>e.state().reviewDisplayMode??"all",setReviewDisplayMode:t=>(e.commandsController.applySetReviewDisplayModeCommand(t),!0),showMarkupOptions:()=>function(e){const t=void 0===e.markupAuthors;return{insertions:zb(e,"insertions"),deletions:zb(e,"deletions"),comments:zb(e,"comments"),formatting:zb(e,"formatting"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Xb(e)}}(e.state()),applyShowMarkup:t=>(e.commandsController.applyShowMarkupCommand(t),!0),toggleTrackChanges:()=>(e.commandsController.applyToggleTrackChangesCommand(),!0),toggleRevisionMarkup:()=>(e.commandsController.applyToggleRevisionMarkupCommand(),!0),toggleOutlinePanel:()=>(e.toggleOutlinePanel(),!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:()=>(Q(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Zr(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>$a(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>za(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Fo(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return $a(e,aw[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:()=>zr(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 Rw(e,t){const n=cy(e),o=n&&Dr(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,n)=>n!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}function Bw(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 Mw(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*rr),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*rr)}}}function Aw(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=function(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}(t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id!==a.id?Xn(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}function Fw(e,t,n=90){return Ow(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 Ow(e,t){const n=cy(e);if(!n||!Dr(n.run))return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?gn(e):{...gn(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Xn(e))});return Ie(e,a,N(a,Un(e)))}function Dw(e,t){return Ow(e,e=>({...e,body:t(e.body??{})}))}var Lw={normal:"toolbar.style.builtin.normal",heading1:"toolbar.style.builtin.heading1",heading2:"toolbar.style.builtin.heading2",heading3:"toolbar.style.builtin.heading3",header:"toolbar.style.builtin.header",footer:"toolbar.style.builtin.footer",Caption:"toolbar.style.builtin.caption",footnoteText:"toolbar.style.builtin.footnoteText",footnoteReference:"toolbar.style.builtin.footnoteReference"};function Ew(e){return Io[e.id]===e?Lw[e.id]:void 0}function Nw(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of C(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 r=va(e.id,n),a="table"===e.type?Vo(e.id,n).tableStyle:void 0,i=a?.conditionalFormats?.wholeTable,l=a?.conditionalFormats?.firstRow,s=a?.conditionalFormats?.band1Horz,c=i?.borders?.borderBottom??a?.borders?.borderBottom;return{id:e.id,name:e.name,labelKey:t.sourcePackage?void 0:Ew(e),type:e.type,qFormat:e.qFormat,uiPriority:e.uiPriority,semiHidden:e.semiHidden,unhideWhenUsed:e.unhideWhenUsed,isUsed:o.has(e.id),fontFamily:r.fontFamily?.trim()||void 0,fontSize:"number"==typeof r.fontSize?r.fontSize:void 0,color:r.color??void 0,bold:r.bold??void 0,italic:r.italic??void 0,tablePreview:a?{wholeFill:i?.shading,headerFill:l?.shading,bandFill:s?.shading,borderColor:c?.color,headerColor:l?.textStyle?.color??void 0}:void 0}})},newDocument:()=>e.newDocument(),saveDocument:()=>e.saveDocument(),openSymbolDialog:()=>e.openSymbolDialog(),openCommandSearch:()=>e.openCommandSearch(),repeatLastAction:()=>e.repeatLastAction(),openEquationDialog:()=>e.openEquationDialog(),hasActiveTable:()=>rc(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=K(t),o=Ne(n)[0]?.blocks??[];if(0===o.length)return e;if(o.every(e=>"paragraph"===e.type))return Oa(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=zr(e.selection)?e:Me(e),{paragraph:a,offset:i}=Ee(r),l=Rt(a,0,i),s=Rt(a,i,d(a)),c=Xo(""),u={...a,runs:l.length?l:Xo("").runs},p={...a,id:c.id,runs:s.length?s:c.runs},g=[...i>0?[u]:[],...o,...s.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===a.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=Ne(r.document),n=Math.max(0,Math.min(r.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const a="header"===h?"header":"footer"===h?"footer":"blocks",i=m(o[a]??[]);if(f){const e=[...t];e[n]={...o,[a]:i},b={...r.document,sections:e}}}if(!f)return e;const y=o[o.length-1],v="paragraph"!==y.type||s.length?Z(p,0):Z(y,d(y));return{...r,document:b,selection:oe(v)}}(e,t)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:r,offset:a}=Ee(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:[Xo("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:tb(void 0,"front")},s=yn("",q(o,a),void 0,l),d=c(o,a,[s]),u=Kr(n).map((e,t)=>t===r?d:gn(e));return Ie(n,u,oe(Z(d,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return Rw(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:El}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,Rw(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Nl}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return Rw(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:$l}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?gn(e):{...gn(e),runs:e.runs.map(e=>e.id!==r.id?Xn(e):"image"===e.kind?{...e,image:{...e.image,floating:Bw(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Bw(e.textBox.floating,t)}}:Xn(e))});return Ie(e,a,N(a,Un(e)))}(e,t),{mergeKey:zl}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=e=>({...e??{type:"floating",allowOverlap:!0,positionH:{relativeFrom:"column",offset:0},positionV:{relativeFrom:"paragraph",offset:0}},type:"floating",wrap:"none",behindDoc:"back"===t}),i=Kr(e).map((e,t)=>t!==o?gn(e):{...gn(e),runs:e.runs.map(e=>e.id!==r.id?Xn(e):"image"===e.kind?{...e,image:{...e.image,floating:a(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:a(e.textBox.floating)}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}(e,t),{mergeKey:Hl}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=Kr(e).map((e,o)=>o!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id!==a.id?Xn(e):"image"===e.kind?{...e,image:{...e.image,floating:Mw(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:Mw(e.textBox.floating,t,n)}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}(e,t,n),{mergeKey:Wl}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=Kr(e).map((e,n)=>n!==o?gn(e):{...gn(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Xn(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?ob(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?ob(n,t):n}}}return Xn(e)})});return Ie(e,a,N(a,Un(e)))}(e,t),{mergeKey:Ul}),setFloatingRotation:t=>e.applyTransactionalState(e=>Aw(e,t),{mergeKey:jl}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>tb(e,t),{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?gn(e):{...gn(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Xn(e);if("image"===e.kind){const t=o(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=o(e.textBox.floating),n=t?{...e.textBox,floating:t}:(()=>{const{floating:t,...n}=e.textBox;return n})();return{...e,textBox:n}}return Xn(e)})});return Ie(e,i,N(i,Un(e)))}(e,t),{mergeKey:Vl}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>{if(!e)return e;if("bothSides"===t){const{wrapText:t,...n}=e;return n}return{...e,wrapText:t}},{paragraphIndex:r,run:a}=n,i=Kr(e).map((e,t)=>t!==r?gn(e):{...gn(e),runs:e.runs.map(e=>e.id!==a.id?Xn(e):"image"===e.kind?{...e,image:{...e.image,floating:o(e.image.floating)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:o(e.textBox.floating)}}:Xn(e))});return Ie(e,i,N(i,Un(e)))}(e,t),{mergeKey:Kl}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=eb(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{h:o,v:r}=function(e){return{h:e.endsWith("Left")?"left":e.endsWith("Right")?"right":"center",v:e.startsWith("top")?"top":e.startsWith("bottom")?"bottom":"ctr"}}(t),a={relativeFrom:"margin",align:o,offset:0},i={relativeFrom:"margin",align:r,offset:0},{paragraphIndex:l,run:s}=n,c=Kr(e).map((e,t)=>t!==l?gn(e):{...gn(e),runs:e.runs.map(e=>{if(e.id!==s.id)return Xn(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:a,positionV:i};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:a,positionV:i};return{...e,textBox:{...e.textBox,floating:t}}}return Xn(e)})});return Ie(e,c,N(c,Un(e)))}(e,t),{mergeKey:_l}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return Rw(e,e=>({...e,preset:t}))}(e,t),{mergeKey:Xl}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return Dw(e,e=>({...e,vert:n}))}(e,t),{mergeKey:Gl}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return Dw(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:Yl}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return Ow(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:ql}),rotateTextBox:t=>e.applyTransactionalState(e=>Fw(e,t),{mergeKey:Zl}),getTextBoxSizeCm:()=>function(e){const t=cy(e),n=t&&Dr(t.run);return n?{width:n.width/$n,height:n.height/$n}:null}(e.state()),isTextBoxSelected:()=>null!==cy(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return Ow(e,e=>({...e,width:Math.max(24,Math.round(t*$n))}))}(e,t),{mergeKey:Jl}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return Ow(e,e=>({...e,height:Math.max(24,Math.round(t*$n))}))}(e,t),{mergeKey:Ql})}}function $w(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!zr(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function zw(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=ab(e),n=t&&Gn(t.run);return n?{width:n.width/$n,height:n.height/$n}: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=ab(e);return(t&&Gn(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=ab(e);return(t&&Gn(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=ab(e),n=t&&Gn(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==ab(e.state())}}function Hw(e){const t=e.clipboardActions??ii({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 Ww(e,t){const n=ao(e),o=Ae(e.document);if("header"===n||"footer"===n){const r=go(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",l=aa(a,n,i,t),s=[...o];return s[r]=l,{...e,document:{...e.document,sections:s}}}if("main"===n){const n=go(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 Uw(e,t){return null!==Vw(e,t)}function jw(e,t){const n=Vw(e,t);if(!n)return e;const{nextBlocks:o}=n,r=Ww(e,o),a=o.flatMap(Po);return{...r,selection:Kw(e.selection,a)}}function Vw(e,t){const n=ao(e);if("footnote"===n)return null;const o=mn(e,n);if(0===o.length)return null;const r=Un(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)=>{Po(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 Kw(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 Z(r,Math.min(e.offset,d(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function _w(e,t){const n=function(e){const t=ao(e);if("footnote"===t)return null;const n=mn(e,t);if(0===n.length)return null;const o=Un(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=Po(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:Xw(Et(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=Ww(e,l),c=l.flatMap(Po);return{...s,selection:Gw(e.selection,c)}}function Xw(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function Gw(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 Z(r,Math.min(e.offset,d(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function Yw(e,t){const n=Un(e),o=Kr(e);let r=1;for(let l=0;l<n.startIndex;l+=1){const e=ga(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 gn(e);const i=ga(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?gn(e):(a=!0,he(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return gn(e);a=!0;const o=gn(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return gn(e);a=!0;const l=gn(e);return l.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},l});return a?Ie(e,i,N(i,n)):e}var qw=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];function Zw(e,t){return Math.abs(e-t)<1e-6}function Jw(e,t){return{position:e,type:t.type,...void 0!==t.leader?{leader:t.leader}:{}}}var Qw=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var eS=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var tS={width:1.5,type:"solid",color:"#000000"};function nS(e,t){const n=t.text??Et(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 oS(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=Un(e),o=Kr(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 Qw.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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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:eS.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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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{...gn(e),style:l}});return r?Ie(e,a,N(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=je(e,"indentFirstLine",null);return n=je(n,"indentHanging",null),"firstLine"===t?n=je(n,"indentFirstLine",o):"hanging"===t&&(n=je(n,"indentHanging",o)),n},{mergeKey:_i}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=je(e,"borderTop",t);return n=je(n,"borderRight",t),n=je(n,"borderBottom",t),n=je(n,"borderLeft",t),n},{mergeKey:Xi}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>je(e,"borderBottom",tS),{mergeKey:Xi}),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=Un(e),o=Math.min(8,Math.max(0,Math.round(t))),r=Kr(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,he(e,o)):e);return a?Ie(e,i,N(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.commandsController.handleListTab("outdent")},indent:()=>{e.commandsController.handleListTab("indent")},moveParagraphsUp:()=>{Uw(e.state(),"up")?(e.applyTransactionalState(e=>jw(e,"up"),{mergeKey:Gi}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{Uw(e.state(),"down")?(e.applyTransactionalState(e=>jw(e,"down"),{mergeKey:Yi}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>Uw(e.state(),"up"),canMoveParagraphsDown:()=>Uw(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>Yw(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>Yw(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=Un(e),n=Kr(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||qw.every(e=>!(e in r)))return e;o=!0;const a=gn(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?Ie(e,r,N(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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=st(e.style?.styleId,r).tabs??[],u=(e,t)=>{const n=e.filter(e=>!Zw(e.position,t));return d.some(e=>Zw(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=>!Zw(e.position,t.position)),p.push(Jw(t.position,t));p.sort((e,t)=>e.position-t.position),p=p.slice(0,64);const g=gn(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=Ie(e,d,N(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:Qi}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=Un(e),o=Kr(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=gn(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?Ie(e,i,N(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return je(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>_w(e,t)),hasDropCap:()=>function(e){const t=Un(e);return Kr(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=Un(e),o=Kr(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?gn(e):i?{...gn(e),dropCap:void 0}:{...gn(e),dropCap:nS(e,{...t,type:"margin"===t.type?"margin":"drop"})});return Ie(e,l,N(l,n))}(e,t)),e.focusInput()}}}function rS(e){const t=Ae(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(go(e),t.length-1))}}function aS(e,t){const{sections:n,sectionIndex:o}=rS(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 iS(e,t,n="default"){const o=Bn(t,n);return aS(e,e=>e[o]?e:{...e,[o]:[yt(t)]})}function lS(e,t,n="default"){const o=Bn(t,n),r=aS(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:ao(r)===t?uS(r):r}function sS(e,t,n="default"){const o=iS(e,t,n),{sections:r,sectionIndex:a}=rS(o),i=(r[a][Bn(t,n)]??[]).flatMap(Po).find(Boolean);return i?{...o,selection:En(Z(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function cS(e){const{sections:t,sectionIndex:n}=rS(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function dS(e){const{sections:t,sectionIndex:n}=rS(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function uS(e){const{sections:t,sectionIndex:n}=rS(e),o=(t[n]?.blocks??[]).flatMap(Po).find(Boolean);return o?{...e,selection:En(Z(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function pS(e){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ee(n),l=Rt(o,0,i),s=Rt(o,i,d(o)),c={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:t},styles:q(o,i)},u=Ut(o,[...l,c,...s]),p=Kr(n),g=[...r(p.slice(0,a)),u,...r(p.slice(a+1))];return Ie(n,g,oe(Z(u,i+c.text.length)))}(e,"PAGE")}function gS(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function fS(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},gS("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},gS("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[gS("PAGE",void 0,`run:page-field:${n}`,t)]}function mS(e,t="page",n){return function(e,t){const n=zr(e.selection)?e:Me(e),{paragraph:o,index:a,offset:i}=Ee(n),l=q(o,i),s=t.map((e,t)=>e.styles?e:{...e,styles:l,id:`${e.id}:${t}`}),c=Ut(o,[...Rt(o,0,i),...s,...Rt(o,i,d(o))]),u=Kr(n),p=[...r(u.slice(0,a)),c,...r(u.slice(a+1))],g=s.reduce((e,t)=>e+t.text.length,0);return Ie(n,p,oe(Z(c,i+g)))}(e,fS(t,n))}function hS(e){const t=Ae(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(go(e),t.length-1))}}function bS(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return mS(e,o,r);const i="top"===t?"header":"footer",l=Bn(i,"default"),{sections:s,sectionIndex:c}=hS(e);if(0===s.length)return e;const d={id:dr("paragraph"),type:"paragraph",runs:fS(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:En(Z(d,0)),activeSectionIndex:c,activeZone:i}}function yS(e){const t={isLandscape:()=>{const t=go(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=go(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=go(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=go(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=go(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=>Rn(e,t)),e.focusInput()},getPageNumbering:()=>{const t=go(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=hS(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 a(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>jo(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ra(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>ft(e,t)),e.focusInput()},getColumns:()=>lr(e.state()),setColumns:t=>{e.applyTransactionalState(e=>ua(e,t)),e.focusInput()},getVerticalAlign:()=>fn(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>h(e,t)),e.focusInput()},getSectionStart:()=>{const t=go(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=go(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>ro(e.state()),setBidi:t=>{e.applyTransactionalState(e=>Vr(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 vS(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>sS(e,"header")),editFooter:()=>t(e=>sS(e,"footer")),editFirstPageHeader:()=>t(e=>sS(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>sS(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>sS(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>sS(e,"footer","evenPage")),insertPageNumber:()=>t(e=>pS(e)),insertPageNumberXOfY:()=>t(e=>mS(e,"xOfY")),placePageNumberTop:()=>t(e=>bS(e,"top")),placePageNumberBottom:()=>t(e=>bS(e,"bottom")),exit:()=>t(e=>function(e){return uS(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>cS(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(cS(e)===t)return e;let n=e;return t?(n=iS(n,"header","firstPage"),n=iS(n,"footer","firstPage"),n):(n=lS(n,"header","firstPage"),lS(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>dS(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(dS(e)===t)return e;let n=e;return t?(n=iS(n,"header","evenPage"),n=iS(n,"footer","evenPage"),n):(n=lS(n,"header","evenPage"),lS(n,"footer","evenPage"))}(t,e))}}function xS(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function wS(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=Un(e),a=e.document.bookmarks,i=a?.order??[],l=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,s={id:Vn(),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:()=>xS(e.state()).map(e=>({id:e.id,name:e.name}))}}var SS=["January","February","March","April","May","June","July","August","September","October","November","December"],IS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function CS(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?IS[e.getDay()]:3===i.length?IS[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?SS[e.getMonth()]:3===i.length?SS[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 TS(e,t){const n=t.type??"REF";if(!function(e,t){return xS(e).find(e=>e.name===t)}(e,t.bookmark))return e;const o=zr(e.selection)?e:Me(e),{paragraph:a,index:i,offset:l}=Ee(o),s=q(a,l),c={type:n,bookmark:t.bookmark},u={id:`run:${n.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:c,styles:s},p=Ut(a,[...Rt(a,0,l),u,...Rt(a,l,d(a))]),g=Kr(o),f=[...r(g.slice(0,i)),p,...r(g.slice(i+1))];return Ie(o,f,oe(Z(p,l+u.text.length)))}function kS(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,t={}){const n=(t.dateFormat??"M/d/yyyy").trim(),o=t.value??/* @__PURE__ */new Date,a=zr(e.selection)?e:Me(e),{paragraph:i,index:l,offset:s}=Ee(a),c=q(i,s),u=n.length>0&&"M/d/yyyy"!==n?{type:"DATE",dateFormat:n}:{type:"DATE"},p={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:CS(o,n),kind:"field",field:u,styles:c},g=Ut(i,[...Rt(i,0,s),p,...Rt(i,s,d(i))]),f=Kr(a),m=[...r(f.slice(0,l)),g,...r(f.slice(l+1))],h=p.text.length;return Ie(a,m,oe(Z(g,s+h)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=CS(n,t);return 0===o.length?e:$a(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>TS(e,t)),e.focusInput()}}}function PS(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=go(e),n=A(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=Ae(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=i(o,n.tablePath);return r?.[r.length-1]?.table??null},l=e=>{const t=a(e);if(!t)return null;const n=sr(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean(A(e.state().document,e.state().selection.focus.paragraphId,go(e.state()))),selectionLabel:()=>{const t=e.state();if(Un(t).isCollapsed)return null;const n=go(t),o=A(t.document,t.selection.anchor.paragraphId,n),r=A(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=l(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=l(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 Cs(t,"tblLook",o)},Al),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>Cs(t,"styleId",e||null),Fl),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>Cs(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Ol),canSetAutoFit:()=>null!==ls(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return ys(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...ts(),type:"property",previous:{...r??{}}}});let a=ns(r,"layout",n);return"window"===t?a=ns(a,"width","100%"):"contents"===t&&(a=ns(a,"width",null)),{...o,style:a}})}(t,e),kl),distributeColumns:()=>o(e=>ys(e,e=>{const t=ln(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}}}),Ol),distributeRows:()=>o(e=>ys(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}}),Ol),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!==ls(e.state()),convertToText:()=>o(e=>As(e),vl),canConvertToTable:()=>{return!ls(t=e.state())&&null!==ms(t);var t},convertToTable:()=>o(e=>Fs(e),xl),canSplitTableAtRow:()=>function(e){const t=ls(e);if(!t)return!1;const n=fs(e);if(!n)return!1;const o=ps(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=ls(e);if(!t)return e;const n=fs(e);if(!n)return e;const o=ps(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=Gr(i),c=bs(e,[l,Xo(""),s]);if(c===e)return e;const d=s.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:oe(Z(d,0))}:e}(e),wl),canSortTable:()=>function(e){const t=ls(e);if(!t)return!1;const n=fs(e);if(!n)return!1;const o=ps(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=>Ds(t,e),"ascending"===e?Sl:Il),canDeleteTable:()=>null!==ls(e.state()),deleteTable:()=>o(e=>function(e){const t=ls(e);if(!t)return e;const n=fs(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=Xo(""),n=bs(e,[t]);return n===e?e:{...n,selection:oe(Z(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=bs(e,[]);if(a===e)return e;if(r){const e=Kr(a).find(e=>e.id===r);if(e)return{...a,selection:oe(Z(e,0))}}return a}(e),Cl),canToggleRepeatHeaderRows:()=>function(e){const t=ls(e);if(!t)return!1;const n=fs(e);if(!n)return!1;const o=ps(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=ls(e);if(!t)return!1;const n=fs(e);if(!n)return!1;const o=ps(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&Es(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=ls(e);if(!t)return e;const n=fs(e);if(!n)return e;const o=ps(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=Es(o.rows[0]);return ys(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),Pl),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),rl),split:()=>o(t=>e.tableOps.splitSelectedTable(t),al),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),il),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),il),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),ll),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),sl),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),sl),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),cl),canDeleteCell:()=>qs(e.state()),deleteCell:()=>o(e=>Zs(e),Tl),cellShading:e=>o(t=>Ss(t,"shading",e||null),dl),cellBorders:()=>o(e=>Is(e,{width:1,type:"solid",color:"#64748b"}),ul),cellNoBorders:()=>o(e=>Is(e,{width:0,type:"none",color:"transparent"}),ul),applyBorderPreset:e=>o(t=>function(e,t,n=vs){const o=ws(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,xs);c("top",xs),c("right",xs),c("bottom",xs),c("left",xs);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 Po(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:{...ts(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=ns(o,e,r);return{...t,style:o}},f=Ae(e.document).map(e=>({...e,blocks:ya(e.blocks,p,g),header:e.header?ya(e.header,p,g):void 0,footer:e.footer?ya(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),ul),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>Cs(e,"width","100%"),pl),alignLeft:()=>o(e=>Ss(e,"horizontalAlign","left"),gl),alignCenter:()=>o(e=>Ss(e,"horizontalAlign","center"),gl),alignRight:()=>o(e=>Ss(e,"horizontalAlign","right"),gl),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,Ss(Ss(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},fl),getCellAlignmentState:()=>function(e){const t=ws(e);if(!t||0===t.selectedEntries.length)return null;const n=t.selectedEntries.map(({cell:e})=>e.style?.horizontalAlign??"left"),o=t.selectedEntries.map(({cell:e})=>e.style?.verticalAlign??"top"),r=(e,t)=>{const n=e[0];return n?e.some(e=>!t.includes(e))?null:e.some(e=>e!==n)?"mixed":n:null};return{horizontal:r(n,["left","center","right"]),vertical:r(o,["top","middle","bottom"])}}(e.state()),setCellVerticalAlign:e=>o(t=>Ss(t,"verticalAlign",e),ml),setCellTextDirection:e=>o(t=>Ss(t,"textDirection",e),hl),setCellWidth:e=>o(t=>function(e,t){return Ss(e,"width",t)}(t,e),bl),setCellNoWrap:e=>o(t=>function(e,t){return Ss(e,"noWrap",t)}(t,e),bl),setCellFitText:e=>o(t=>function(e,t){return Ss(e,"fitText",t)}(t,e),bl),canSetCellMargins:()=>null!==ls(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=Ss(n,"paddingTop",t.top)),void 0!==t.right&&(n=Ss(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=Ss(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=Ss(n,"paddingLeft",t.left)),n}(t,e),Rl),canSetCellSpacing:()=>Ns(e.state()),setCellSpacing:e=>o(t=>function(e,t){return Ns(e)?Cs(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),Rl),canSetTableIndent:()=>$s(e.state()),setTableIndent:e=>o(t=>function(e,t){return $s(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?Cs(e,"indentLeft",null):Cs(e,"indentLeft",Math.round(2*t)/2):e}(t,e),Rl),canSetTableAlignment:()=>null!==ls(e.state()),setTableAlignment:e=>o(t=>Hs(t,e),Rl),canEvaluateTableFormula:()=>null!==ls(e.state()),evaluateTableFormula:e=>o(t=>js(t,e),Bl),canSelectTable:()=>null!==ls(e.state()),selectTablePart:t=>e.applyState(Gs(e.state(),t)),canSetActiveTableRowHeight:()=>null!==ls(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=ks(n,"height",t.height),void 0!==t.heightRule&&(n=ks(n,"heightRule",t.heightRule)),n}(t,e),Ml),canSetActiveTableRowBreakAcrossPages:()=>Ws(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Ws(e)?ks(e,"cantSplit",null===t?null:!t):e}(t,e),Ml),canSetActiveTableRowHeader:()=>null!==ls(e.state()),setActiveTableRowHeader:e=>o(t=>Ps(t,e),Pl),canSetActiveTableColumnWidth:()=>null!==ls(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=ls(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=ps(as(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=ln(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const l=i.visualColumnIndex;return null===t?e:Ms(e,a.id,{[l]:t})}(t,e),yl),canSetActiveTableWidth:()=>null!==ls(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=ls(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=ps(as(e.document,o,r.zone),r.tablePath);return a?Ts(e,a.id,"width",t):e}(t,e),pl),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function RS(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>zx(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=Ex[t]??Ex.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]=Nx[t]??Nx.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=>$x(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return $x(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return $x(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 BS(e){return function(e){const t=(n=e.gate.isCommandEnabled,(e,t,o)=>({execute:t,refresh:()=>{const t=o?.()??{};return{...t,isEnabled:n(e)&&(t.isEnabled??!0)}}}));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:()=>{const n=o?.()??{};return{...n,isEnabled:e(t)&&(n.isEnabled??!0)}}})}(e.gate.isCommandEnabled);return{name:"Essentials",commands:{...jx({gate:e.gate,style:e.style,selection:e.selection,history:e.history,formatting:e.formatting,dialog:e.dialog,link:e.link,command:t,valueCommand:o,actionCommand:r}),...Vx({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...Kx({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...Zx({dialog:e.dialog,actionCommand:r}),..._x({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...Yx({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...qx({design:e.design,actionCommand:r}),...Xx({bookmark:e.bookmark,actionCommand:r}),...Gx({fields:e.fields,actionCommand:r})}}}({gate:tw(e),style:nw(e),selection:ow(e),history:rw(e),formatting:Pw(e),document:Nw(e),link:$w(e),image:zw(e),browser:Hw(e),paragraph:oS(e),section:yS(e),headerFooter:vS(e),table:PS(e),design:RS(e),bookmark:wS(e),fields:kS(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var MS=[{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",command:"saveDocument",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_repeat",path:"Edit/Repeat",labelKey:"quickAccess.repeat",shortcut:"F4",command:"repeatLastAction",icon:"repeat"},{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_revision_markup",path:"Review/Show Markup",labelKey:"toolbar.revisionMarkup",command:"toggleRevisionMarkup",icon:"highlighter"},{id:"review_accept_all_revisions",path:"Review/Accept All Changes",labelKey:"toolbar.acceptAll",command:"requestAcceptAllRevisions",icon:"check-check"},{id:"review_reject_all_revisions",path:"Review/Reject All Changes",labelKey:"toolbar.rejectAll",command:"requestRejectAllRevisions",icon:"undo-2"},{id:"review_comments_panel",path:"Review/Comments Panel",labelKey:"review.commentsPanel",command:"toggleCommentsPanel",icon:"list-filter"},{id:"review_revisions_panel",path:"Review/Reviewing Pane",labelKey:"review.reviewingPane",command:"toggleRevisionsPanel",icon:"list-checks"},{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",command:"toggleOutlinePanel",icon:"list"},{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_command_search",path:"Tools/Command Search",labelKey:"menu.tools.commandSearch",command:"openCommandSearch",icon:"search",shortcut:"Ctrl+K"},{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 AS(t){const n=BS(t.essentials),{runtimePlugins:o,toolbarRegistry:r,menuRegistry:a,dispose:i}=function(t){const n=[t.essentialsPlugin,...t.externalPlugins??[]],o=[],r=[],a=Zn(),i=new e;for(const e of Fr(t.t))a.register(e);for(const e of MS)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]=Jt(!1),[o,r]=Jt(new Ke({doc:e.initialDocument}));let a=!1;const i=e=>{const t=x(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=ta(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=ta(e,t);return o().commands.canExecute(n.name,n.payload)},state:i},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await Ke.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(e.onExecuted&&(t.commands.onExecuted=e.onExecuted),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,onExecuted:t.onExecuted,onReady:t.onReady,onSettled:t.onSettled,onError:t.onError});return Er(()=>{l.initialize()}),qn(()=>{l.dispose(),i()}),{toolbarRegistry:r,menuRegistry:a,runtimeReady:l.runtimeReady,runtimeEditor:l.runtimeEditor,commandStateOf:l.commandStateOf,toolbarHost:l.toolbarHost}}var FS=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function OS(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!FS.has(e)})(e)&&(n={command:e,payload:t})},canExecute:()=>null!==n&&function(e){try{return e()}catch{return!1}}(()=>t(n.command,n.payload)),execute:()=>{n&&e(n.command,n.payload)}}}function DS(e){return function(e){const{document:t,interaction:n,runtimeClient:o}=e,{commandsController:r,keyboardCommandsController:a}=Bx({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,setFontDialog:e.setFontDialog,setParagraphDialog:e.setParagraphDialog});let i;const l=OS((e,t)=>{if(!i)throw new Error("repeat tracking used before ready");return i().commands.execute(e,t)},(e,t)=>!!i&&i().commands.canExecute(e,t)),s=()=>{l.execute()},c=()=>l.canExecute(),{runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m}=AS({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:Mx({isDirty:()=>o.isDirty(),resetDocument:()=>o.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),saveDocument:()=>{o.save().catch(t=>e.logger.error("document:save failed",t))},openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openCommandSearch:()=>e.setCommandSearchOpen(!0),repeatLastAction:s,canRepeatLastAction:c,openTablePropertiesDialog:t=>{const n=ac(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=C(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})},openFontDialog:r.openFontDialog,openParagraphDialog:r.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:wx(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:wx(e.state).size})},toggleOutlinePanel:e.toggleOutline,isOutlineVisible:e.isOutlineVisible,toggleRevisionsPanel:e.toggleRevisionsPanel,revisionsPanelVisible:e.revisionsPanelVisible},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,onExecuted:(t,n)=>{l.record(t,n),e.onExecutedTap?.()},onReady:t=>{i=()=>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(xo(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=Sn();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=zx(e,n.themeId)),e=$x(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({...t.getStateSnapshot(),selection:{anchor:{...e.anchor},focus:{...e.focus}}}),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:d,runtimeEditor:u,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:f,menuRegistry:m}),br(()=>{if(!d())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());u().dispatch(()=>t)});const{handleKeyDown:h}=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,commandSearch:b,runtimeEditor:y}=e,{handleKeyDown:v}=Ox({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())},toggleCommandSearch:e=>{b.setIsOpen(e??!b.isOpen())},executeCommand:(e,t)=>y().commands.execute(e,t),canExecuteCommand:e=>y().commands.canExecute(e)});return{handleKeyDown:e=>{Dx.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}]`),co("input-to-layout"),v(e),bo("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,commandSearch:e.commandSearch,runtimeEditor:u});return{commandsController:r,runtimeReady:d,runtimeEditor:u,commandStateOf:p,toolbarHost:g,toolbarRegistry:f,menuRegistry:m,handleKeyDown:h}}(e)}function LS(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 ES(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=LS(e,n.commentId)??LS(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 NS(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 $S(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!NS(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),!NS(e,t.items[i]))return!1;r.push(i)}}return!0}function zS(e){const[t,n]=Jt(null),[o,r]=Jt(""),[a,i]=Jt(!1),s=()=>e.access?.(),c=()=>{const e=s()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},d=()=>!(e.isReadOnly()||s()&&null===c()),u=()=>d()&&null!==_e(e.state()),p=t=>d()&&Boolean(e.state().document.comments?.items[t]),g=()=>d()&&null!==hw(e.state()),f=t=>!e.isReadOnly()&&NS(s(),e.state().document.comments?.items[t]),m=()=>{const t=hw(e.state());return null!==t&&f(t.id)},h=t=>!e.isReadOnly()&&$S(s(),e.state().document.comments,t),b=f,y=(e="Local editor")=>{const t=c();return t?{actorName:t.displayName,actorId:t.id}:{actorName:e}},v=(e,t,n,o,r,a)=>ES(e,t,{id:dr("review-activity"),kind:n,commentId:o,...y(r),timestamp:Date.now(),...a?{parentId:a}:{}}),x=t=>{if(!p(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)},w=t=>{if(!f(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)},S=()=>{n(null),e.focusInput()},I=t=>{if(!h(t))return!1;const n=e.state();let o=!1;return e.applyTransactionalState(r=>{if(e.isReadOnly()||r.document!==n.document||!$S(s(),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?v(r,a,"comment-deleted",t):a}),o},C=(t,n)=>{if(!b(t))return!1;const o=e.state();let r=!1;return e.applyTransactionalState(a=>{if(e.isReadOnly()||a.document!==o.document||!NS(s(),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?v(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:u,canReply:g,canReplyId:p,canEdit:m,canEditId:f,canDeleteId:h,canDeleteSelected:()=>{const t=hw(e.state());return null!==t&&h(t.id)},deleteSelected:()=>{const t=hw(e.state());return!!t&&I(t.id)},deleteById:I,canResolveId:b,canResolveSelected:()=>{const t=hw(e.state());return null!==t&&b(t.id)},resolveSelected:t=>{const n=hw(e.state());return!!n&&C(n.id,t)},resolveById:C,authorName:()=>c()?.displayName??o(),authorLocked:()=>void 0!==s(),openNew:()=>!!u()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!g())return!1;const t=hw(e.state());return!!t&&x(t.id)},openReplyToId:x,openEdit:()=>{if(!m())return!1;const t=hw(e.state());return!!t&&w(t.id)},openEditToId:w,close:S,submit:(n,o)=>{const a=t();if(!a||e.isReadOnly())return!1;if("edit"===a.mode&&!f(a.commentId))return!1;if("edit"!==a.mode&&!d())return!1;const i="edit"===a.mode?a.commentAuthor?.trim()??"":c()?.displayName??n.trim(),u=o.trim();if(!i||!u||e.state().document!==a.snapshot.document)return!1;if("edit"===a.mode&&a.commentText===u)return S(),!0;const p="edit"===a.mode?null:{id:dr("comment"),author:i,...c()?{authorId:c().id}:{},text:u,date:Date.now()};let g=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a.snapshot.document)return t;if("edit"===a.mode&&!NS(s(),t.document.comments?.items[a.commentId]))return t;if("edit"!==a.mode&&!d())return t;const n="edit"===a.mode?k(t,a.commentId,u):"reply"===a.mode?l(t,a.parentId,p):Do({...t,selection:a.snapshot.selection,activeSectionIndex:a.snapshot.activeSectionIndex,activeZone:a.snapshot.activeZone,activeFootnoteId:a.snapshot.activeFootnoteId},p);return g=n.document!==t.document,g?v(t,n,"new"===a.mode?"comment-created":"reply"===a.mode?"comment-replied":"comment-edited","edit"===a.mode?a.commentId:p.id,i,"reply"===a.mode?a.parentId:void 0):n}),g&&("edit"!==a.mode&&r(i),S()),g}}}var HS=/*#__PURE__*/zt("<div class=oasis-review-comments-filters role=group>"),WS=/*#__PURE__*/zt("<div class=oasis-review-comments-list>"),US=/*#__PURE__*/zt("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),jS=/*#__PURE__*/zt("<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>"),VS=/*#__PURE__*/zt("<div class=oasis-review-thread-replies>"),KS=/*#__PURE__*/zt("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),_S=/*#__PURE__*/zt("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),XS=/*#__PURE__*/zt("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function GS(e){const t=Xe(),[n,o]=Jt("all"),[r,a]=Jt(!1),[i,l]=Jt(""),[s,c]=Jt(null),[d,u]=Jt(null),p=()=>e.state().document.comments,g=ge(()=>{const e=p();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,...O(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),f=e=>O(p()?.items??{},e),m=ge(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),h=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",b=t=>{d()===t?e.composer.deleteById(t)&&(u(null),s()===t&&c(null)):u(t)};return y=jS(),v=y.firstChild,x=v.nextSibling,Qe(v,xe(ia,{as:"strong",get children(){return t("review.commentsPanel")}}),null),Qe(v,xe(Je,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),Qe(x,xe(Je,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),Qe(x,xe(Je,{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),Qe(y,xe(ia,{as:"p",get children(){return H(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${p()?.order.length??0}`}}),null),Qe(y,xe(uo,{get label(){return H(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:l,"data-testid":"review-comments-search"}),null),Qe(y,xe(_t,{get when(){return!r()},get children(){return[(a=HS(),Qe(a,xe(Je,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),an(()=>Pe(a,"aria-label",t("review.filterComments"))),a),(r=WS(),Qe(r,xe(_t,{get when(){return 0===g().length},get children(){return xe(ia,{as:"p",get children(){return t("review.noComments")}})}}),null),Qe(r,xe(Ft,{get each(){return g()},children:n=>{return o=KS(),r=o.firstChild,a=r.nextSibling,Qe(r,xe(ia,{as:"strong",get children(){return n.author||"—"}}),null),Qe(r,xe(ia,{as:"span",get children(){return H(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),Qe(o,xe(ia,{as:"p",get children(){return n.text}}),a),Qe(a,xe(Je,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),Qe(a,xe(_t,{get when(){return e.composer.canEditId(n.id)},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),Qe(a,xe(_t,{get when(){return e.composer.canResolveId(n.id)},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return H(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),Qe(a,xe(_t,{get when(){return e.composer.canReplyId(n.id)},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),Qe(a,xe(_t,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[xe(Je,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-comment-delete",get children(){return H(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),xe(_t,{get when(){return d()===n.id},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),Qe(o,xe(_t,{get when(){return f(n.id).length>0},get children(){return xe(Je,{size:"sm",variant:"ghost",get"aria-expanded"(){return s()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{c(s()===n.id?null:n.id)},get children(){return H(()=>s()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${f(n.id).length})`}})}}),null),Qe(o,xe(_t,{get when(){return s()===n.id},get children(){var o=VS();return Qe(o,xe(Ft,{get each(){return f(n.id)},children:n=>{return o=_S(),r=o.firstChild,Qe(o,xe(ia,{as:"strong",get children(){return n.author||"—"}}),r),Qe(o,xe(ia,{as:"p",get children(){return n.text}}),r),Qe(r,xe(_t,{get when(){return e.composer.canEditId(n.id)},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),Qe(r,xe(_t,{get when(){return e.composer.canReplyId(n.id)},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),Qe(r,xe(_t,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[xe(Je,{size:"sm",variant:"ghost",onClick:()=>b(n.id),"data-testid":"review-reply-delete",get children(){return H(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),xe(_t,{get when(){return d()===n.id},get children(){return xe(Je,{size:"sm",variant:"ghost",onClick:()=>{u(null)},get children(){return t("generic.cancel")}})}})]}}),null),an(()=>Pe(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),an(()=>Pe(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),Qe(y,xe(_t,{get when(){return r()},get children(){var n=US();return Qe(n,xe(_t,{get when(){return 0===m().length},get children(){return xe(ia,{as:"p",get children(){return t("review.activity.empty")}})}}),null),Qe(n,xe(Ft,{get each(){return m()},children:n=>{return o=XS(),r=o.firstChild,Qe(r,xe(ia,{as:"strong",get children(){return n.actorName}}),null),Qe(r,xe(ia,{as:"span",get children(){return h(n.timestamp)}}),null),Qe(o,xe(ia,{as:"p",get children(){return[H(()=>(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))," — ",H(()=>n.targetAuthor),H(()=>H(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),Qe(o,xe(_t,{get when(){return Boolean(p()?.items[n.commentId])},get children(){return xe(Je,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),an(()=>Pe(o,"data-activity-kind",n.kind)),o;var o,r}}),null),an(()=>Pe(n,"aria-label",t("review.activity.title"))),n}}),null),an(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&Pe(y,"aria-label",e.e=n),o!==e.t&&Pe(x,"aria-label",e.t=o),e},{e:void 0,t:void 0}),y;var y,v,x}var YS="oasis-reviewing-pane-v1";function qS(){const[e,t]=Jt(function(){try{return"true"===globalThis.localStorage?.getItem(YS)}catch{return!1}}()),n=e=>{t(e),function(e){try{globalThis.localStorage?.setItem(YS,String(e))}catch{}}(e)};return{open:()=>e(),toggle:()=>(n(!e()),!0),close:()=>{n(!1)}}}var ZS=/*#__PURE__*/zt("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),JS=/*#__PURE__*/zt("<div class=oasis-review-revision-footer>"),QS=/*#__PURE__*/zt('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),eI=/*#__PURE__*/zt("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function tI(e,t){const n=Kr(e),o=[];for(const a of n)for(const e of a.runs)e.revision?.id!==t&&e.styles?.propertyRevision?.id!==t||o.push(e.text);const r=o.join("").trim();return r.length>96?`${r.slice(0,93)}…`:r}function nI(e){const t=Xe(),n=ge(()=>{const t=e.state(),n=Kr(t),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(const e of n)for(const t of e.runs){const e=t.revision;e&&(o.has(e.id)||o.set(e.id,e.author),r.has(e.id)||r.set(e.id,{date:e.date,type:e.type}));const n=t.styles?.propertyRevision;n&&(o.has(n.id)||o.set(n.id,n.author),r.has(n.id)||r.set(n.id,{date:n.date,type:"property"}))}const a=new Map(Eb(t).map(e=>[e.id,e])),i=new Map(Nb(t).map(e=>[e.id,e]));return pw(t).map(e=>{const n=r.get(e.id),l=a.get(e.id),s=i.get(e.id);return{id:e.id,type:n?.type??l?.type??s?.type??"insert",author:o.get(e.id)??l?.author??s?.author??"—",date:n?.date??l?.date??s?.date,snippet:tI(t,e.id)||l?.snippet||s?.snippet||"",section:void 0!==s}})}),o=ge(()=>{const t=e.state();return n().filter(e=>Ub(t,e.type,e.author))});return r=QS(),a=r.firstChild,Qe(a,xe(ia,{as:"strong",get children(){return t("review.reviewingPane")}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),Qe(r,xe(ia,{as:"p",get children(){return[H(()=>t("review.revisionCount")),": ",H(()=>o().length)]}}),null),Qe(r,xe(_t,{get when(){return n().length-o().length>0},get children(){return xe(ia,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),Qe(r,xe(_t,{get when(){return o().length>0},get fallback(){return xe(ia,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=ZS();return Qe(n,xe(Ft,{get each(){return o()},children:n=>{return o=eI(),r=o.firstChild,a=r.nextSibling,Qe(r,xe(ia,{as:"span",get class(){return"oasis-review-revision-type "+(e=n.type,n.section?"review-revisions-icon-section":"delete"===e?"review-revisions-icon-delete":"property"===e?"review-revisions-icon-property":"grid"===e?"review-revisions-icon-grid":"review-revisions-icon-insert");var e},get"data-revision-type"(){return n.type},get children(){return[xe(Qr,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),xe(ia,{as:"span",get children(){return e=n.type,o=n.section,t(o?"review.revisionSection":"insert"===e||"delete"===e?"insert"===e?"review.revisionInsert":"review.revisionDelete":"grid"===e?"review.revisionGrid":"review.revisionProperty");var e,o}})]}}),null),Qe(r,xe(ia,{as:"p",get children(){return n.snippet||"—"}}),null),Qe(r,xe(ia,{as:"span",get children(){return n.author}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),Qe(a,xe(Je,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),an(e=>{var t=n.id,r=n.section?"true":void 0;return t!==e.e&&Pe(o,"data-comment-id",e.e=t),r!==e.t&&Pe(o,"data-revision-section",e.t=r),e},{e:void 0,t:void 0}),o;var o,r,a}})),n}}),null),Qe(r,xe(_t,{get when(){return o().length>0},get children(){var n=JS();return Qe(n,xe(Je,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),Qe(n,xe(Je,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),an(()=>Pe(r,"aria-label",t("review.reviewingPane"))),r;var r,a}var oI=/*#__PURE__*/zt('<div class="oasis-editor-shell oasis-editor-app">');function rI(e={}){const t=e.runtime?.client??Ze(),[n,o]=Jt({}),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=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...i(),...e}),s=()=>e.runtime??{};Ti();const c=Lo(()=>r().locale??"pt-BR"),d=T("app"),{state:u,commitState:g,getStateSnapshot:f}=function(e){const t=e.initialState?Pn(e.initialState):e.initialDocument?xo(e.initialDocument):Sn();let n=t;const[o,r]=Jt(t),a=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}}});return{state:a,setStateSignal:r,commitState:e=>{const t=pa(e===a?n:e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),m=e=>{g(e)},h=Pn;let b=!1;const{showChrome:y,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,showRuler:C,toggleOutline:k,toolbarView:R,toolbarLayout:B,isReadOnly:M,useComposedShell:A,loadingOptions:O,loadingLabel:D,shellComponent:L}=function(e){const{ui:t,documentOptions:n,updateUiState:o,state:r}=e,a=()=>{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,showRuler:()=>t().showRuler??t().showChrome??!0,showOutline:()=>t().showOutline??!0,toggleOutline:()=>{o({showOutline:!(t().showOutline??!0)})},toolbarView:()=>t().toolbar?.view??"ribbon",toolbarLayout:()=>t().toolbar?.layout??"overflow",isReadOnly:()=>(n().readOnly??!1)||"all"!==(r().reviewDisplayMode??"all"),useComposedShell:()=>"docs"===t().uiVariant||"document"!==(t().shell??"document"),loadingOptions:a,loadingLabel:()=>a()?.label??"Loading oasis-editor...",shellComponent:()=>{const e=t().shell??"document";return"inline"===e?oa:"balloon"===e?S:Pt}}}({ui:r,documentOptions:a,updateUiState:l,state:()=>u}),E=function(){const[e,t]=Jt(!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}}}(),N=E.focused,$=E.setFocused,z=E.focusInput,W=E.focusInputAfterPointerSelection,U=E.focusInputSync,[j,V]=Jt(!1!==r().loading),K=se(),{linkDialog:_,setLinkDialog:X,imageAltDialog:G,setImageAltDialog:Y,imageCaptionDialog:q,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:le,setRevisionBulkDialog:ce,newDocumentDialog:de,setNewDocumentDialog:ue,symbolDialog:pe,setSymbolDialog:ge,equationDialog:fe,setEquationDialog:me}=function(){const[e,t]=Jt({isOpen:!1}),[n,o]=Jt({isOpen:!1}),[r,a]=Jt({isOpen:!1}),[i,l]=Jt({isOpen:!1,initialHref:""}),[s,c]=Jt({isOpen:!1,initialAlt:""}),[d,u]=Jt({isOpen:!1,initialCaption:""}),[p,g]=Jt({isOpen:!1,x:0,y:0}),[f,m]=Jt({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]=Jt({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]=Jt({isOpen:!1,action:"accept",count:0}),[x,w]=Jt({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:x,setTablePropertiesDialog:w,revisionBulkDialog:y,setRevisionBulkDialog:v}}(),[he,be]=Jt(!1),ye=()=>E.viewportRef,ve=()=>E.surfaceRef,we=sy({documentOptions:a,logger:d,runtimeClient:t,state:u,commitState:g,getStateSnapshot:f,applyState:m,cloneState:h,isReadOnly:M,focusInput:z,surfaceRef:ve,viewportRef:ye,zoomFactor:K.zoomFactor,getImageOps:()=>_e.imageOps}),{docIO:Se,measuredBlockHeights:Ie,measuredParagraphLayouts:Ce,documentLayout:Te,canvasSnapshotProvider:ke,inputBox:Re,selectionBoxes:Be,commentHighlights:Me,revisionMarkupBoxes:Ae,changeBarBoxes:Fe,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Le,caretBox:Ee,preferredColumnX:Ne,setPreferredColumnX:$e,clearPreferredColumn:ze,onCleanupHook:He,persistenceStatus:We,applyTransactionalState:Ue,resetTransactionGrouping:je,updateHistoryState:Ve}=we,Ke=ii({state:()=>u,isReadOnly:M,applyTransactionalState:Ue,applyTableAwareParagraphEdit:(e,t)=>_e.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:ze,resetTransactionGrouping:je,focusInput:z}),_e=dx({clipboardActions:Ke,state:u,logger:d,isReadOnly:M,applyState:m,cloneState:h,focusInput:z,focusInputAfterPointerSelection:W,focusInputSync:U,surfaceRef:ve,viewportRef:ye,zoomFactor:K.zoomFactor,insertImageFromFile:Se.insertImageFromFile,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},getCommandsController:()=>vt.commandsController,applyTransactionalState:Ue,clearPreferredColumn:ze,resetTransactionGrouping:je,updateHistoryState:Ve,caretBox:Ee,preferredColumnX:Ne,setPreferredColumnX:$e,measuredBlockHeights:Ie,measuredParagraphLayouts:Ce,documentLayout:Te,canvasSnapshotProvider:ke,openEquationDialog:(e,t)=>{me({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:Xe,fr:Ge,tableOps:Ye,imageOps:qe,textBoxOps:Je,styleController:et,onEditorPointerDown:tt,tableResize:nt,tableCornerResize:ot,tableDrag:rt,revisionController:at,textDrag:it,surfaceEventsWithTextDrag:lt,textInput:st,handleCopy:ct,handleCut:pt,handlePaste:gt,handleDrop:ft}=_e,[mt,ht]=Jt(!1),bt=qS(),yt=zS({state:()=>u,isReadOnly:M,applyTransactionalState:Ue,focusInput:z,access:()=>s().review}),vt=DS({commandSearch:{isOpen:mt,setIsOpen:e=>{ht(e)}},setCommandSearchOpen:ht,clipboardActions:Ke,document:we,interaction:_e,commentComposer:yt,state:u,logger:d,isReadOnly:M,focusInput:z,applyState:m,getStateSnapshot:f,cloneState:h,setFocused:$,setInitialLoading:V,getForcePlainTextPaste:()=>b,setForcePlainTextPaste:e=>{b=e},locale:()=>r().locale??"pt-BR",translator:c,runtimeClient:t,runtimeOptions:s,documentOptions:a,getUiState:i,updateUiState:l,zoom:K,importInputRef:()=>E.importInputRef,imageInputRef:()=>E.imageInputRef,setLinkDialog:X,setImageAltDialog:Y,setImageCaptionDialog:J,setNewDocumentDialog:ue,setSymbolDialog:ge,setEquationDialog:me,setTablePropertiesDialog:ie,setFontDialog:ne,setParagraphDialog:re,setRevisionBulkDialog:ce,toggleOutline:k,isOutlineVisible:I,toggleRevisionsPanel:()=>{bt.toggle()},revisionsPanelVisible:bt.open}),{commandsController:xt,runtimeReady:wt,runtimeEditor:Ct,toolbarHost:kt,toolbarRegistry:Rt,menuRegistry:Bt,handleKeyDown:Mt}=vt,Ft=()=>function(e,t,n){const o=[],r=/* @__PURE__ */new Set;for(const a of e){if("hidden"in a&&!0===a.hidden)continue;const e=vi(a);if(!e)continue;const t=a.label;if("string"!=typeof t||!t.trim())continue;if(r.has(e.command))continue;r.add(e.command);const n={id:a.id,label:t,command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"ribbon"};o.push(n)}for(const a of t){if(!0===a.hidden)continue;const e=yi(a.command);if(!e)continue;if(r.has(e.command))continue;r.add(e.command);const t=a.labelKey?n(a.labelKey):a.id;o.push({id:a.id,label:String(t),command:e.command,...void 0===e.payload?{}:{payload:e.payload},source:"menubar",...a.shortcut?{shortcut:a.shortcut}:{}})}return o}(Rt.getOrdered(),Bt.getItems(),c),Ot=e=>{try{return!1!==Ct().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:Dt,computeFontSizeOptions:Lt,applyFontDialogValues:Et,applyParagraphDialogValues:Nt,setParagraphDialogDefault:$t,applyTablePropertiesDialogValues:zt,buildContextMenuItems:Ht,handleEditorContextMenu:Wt,closeContextMenu:Ut}=cc({clipboardActions:Ke,state:()=>u,selection:()=>u.selection,toolbarStyleState:et.toolbarStyleState,isReadOnly:M,t:c,logger:d,setFontDialog:ne,setParagraphDialog:re,setTablePropertiesDialog:ie,setContextMenu:ee,clearPreferredColumn:ze,resetTransactionGrouping:je,applyTransactionalState:Ue,applyTableAwareParagraphEdit:Ye.applyTableAwareParagraphEdit,focusInput:z,promptForLink:xt.promptForLink,tableOps:Ye}),{layout:jt,overlays:Vt,refs:Kt,surfaceHandlers:Xt,inputHandlers:Gt,fileHandlers:Yt}=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,revisionMarkupBoxes:n.revisionMarkupBoxes,changeBarBoxes:n.changeBarBoxes,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:Te,remoteWebFonts:a().remoteWebFonts,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:K.zoomPercent,setZoomPercent:K.setZoomPercent,zoomFactor:K.zoomFactor},overlays:{selectionBoxes:Be,commentHighlights:Me,revisionMarkupBoxes:Ae,changeBarBoxes:Fe,onReplyToComment:e=>{yt.openReplyToId(e)},onEditComment:e=>{yt.openEditToId(e)},canEditComment:yt.canEditId,canReplyComment:yt.canReplyId,selectedImageBox:Oe,selectedTextBoxBox:De,selectedTableBox:Le,layoutOptions:Xe,caretBox:Ee,inputBox:Re,hoveredRevision:at.hoveredRevision,focused:N,showCaret:()=>function(e,t){if(!t.visible||!zr(e.selection))return!1;const n=go(e),o=St(e.document,e.selection.anchor.paragraphId,n),r=St(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(u,Ee()),importProgress:Se.importProgress,imageCropMode:qe.cropMode},refs:{focusController:E},files:{handleImportFile:Se.handleImportFile,handleInsertImage:Se.handleInsertImage},surface:{surfaceEvents:lt,tableResize:nt,tableCornerResize:ot,tableDrag:rt,revisionController:at,handleDrop:ft,onEditorPointerDown:tt,handleImagePointerDown:qe.handleImagePointerDown,handleImageResizeHandlePointerDown:qe.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:Je.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:qe.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:qe.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:qe.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:Je.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:Wt},input:{textInput:st,setFocused:$,handleCopy:ct,handleCut:pt,handlePaste:gt,handleKeyDown:e=>{if("Escape"===e.key&&_e.formatPainter.mode())return _e.formatPainter.cancel(),void e.preventDefault();Mt(e)},handleKeyUp:e=>{_e.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&_e.formatPainter.applyToSelection("keyboard")}}});return Er(()=>{It(),ha(),Go(),Yr(()=>ve()??null),dt(),(r().showWelcome??!0)&&!At()&&p()&&be(!0)}),qn(()=>{He(),lt.stopDragging(),it.stopDrag(),nt.stop(),ot.stop(),rt.stop(),qe.stopImageDrag(),qe.stopImageResize(),qe.stopImageCrop(),Je.stopTextBoxResize(),F()}),xe(P,{translator:c,get children(){var e=oI();return ut(e,"--oasis-editor-gutter-x","34px"),Qe(e,xe(_t,{get when(){return H(()=>!(A()||!y()))()&&w()},get children(){return xe(Qt,{host:kt,registry:Rt,get showFileGroup(){return!!H(()=>"ribbon"===R())()||!x()},get view(){return R()},get layout(){return B()}})}}),null),Qe(e,xe(ci,{get notice(){return Ke.notice},onDismiss:()=>{Ke.dismiss(),z()}}),null),Qe(e,xe(_t,{get when(){return yt.panelOpen()},get children(){return xe(GS,{state:()=>u,composer:yt,locale:()=>r().locale??"pt-BR",get onClose(){return yt.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=Kr(e),s=l.find(e=>e.id===a.paragraphId),c=l.find(e=>e.id===i.paragraphId);return s&&c?{...e,selection:{anchor:Z(s,a.offset),focus:Z(c,i.offset)}}:e}(u,e);t!==u&&(m(t),z())}})}}),null),Qe(e,xe(_t,{get when(){return bt.open()},get children(){return xe(nI,{state:()=>u,get onClose(){return bt.close},onNavigate:e=>{const t=bw(u,e);t!==u&&(m(t),z())},onAccept:e=>{const t=bw(u,e);t!==u&&(m(t),xt.applyAcceptRevisionsCommand(),z())},onReject:e=>{const t=bw(u,e);t!==u&&(m(t),xt.applyRejectRevisionsCommand(),z())},onAcceptAll:()=>Ct().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>Ct().commands.execute("requestRejectAllRevisions")})}}),null),Qe(e,xe(bi,{get isOpen(){return mt()},get entries(){return Ft()},isEnabled:Ot,onExecute:e=>{Ct().commands.execute(e.command,e.payload),ht(!1),z()},onClose:()=>{ht(!1),z()}}),null),Qe(e,xe(jd,{commentComposer:yt,dialogs:{linkDialog:_,setLinkDialog:X,imageAltDialog:G,setImageAltDialog:Y,imageCaptionDialog:q,setImageCaptionDialog:J,contextMenu:Q,setContextMenu:ee,fontDialog:te,setFontDialog:ne,paragraphDialog:oe,setParagraphDialog:re,tablePropertiesDialog:ae,setTablePropertiesDialog:ie,revisionBulkDialog:le,setRevisionBulkDialog:ce,newDocumentDialog:de,setNewDocumentDialog:ue,symbolDialog:pe,setSymbolDialog:ge,equationDialog:fe,setEquationDialog:me},findReplace:Ge,fontFamilyOptions:Dt,fontSizeOptions:Lt,contextMenuItems:Ht,focusInput:z,get applyLinkCommand(){return xt.applyLinkCommand},get applyImageAltCommand(){return xt.applyImageAltCommand},get applyImageCaptionCommand(){return xt.applyImageCaptionCommand},applyFontDialogValues:Et,applyParagraphDialogValues:Nt,setParagraphDialogDefault:$t,applyTablePropertiesDialogValues:zt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{Ct().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),z()},insertSymbol:(e,t)=>{Ct().commands.execute("insertText",{text:e,fontFamily:t}),z()},applyEquation:(e,t)=>{t?Ct().commands.execute("updateEquation",{runId:t,expression:e}):Ct().commands.execute("insertEquation",e),z()},closeContextMenu:Ut}),null),Qe(e,xe(Kd,{useComposedShell:A,shellComponent:L,runtime:{state:()=>u,toolbarHost:kt,runtimeEditor:Ct,persistenceStatus:We,toolbarRegistry:Rt,menuRegistry:Bt},chrome:{showChrome:y,showTitleBar:v,showMenubar:x,showToolbar:w,showOutline:I,showRuler:C,toolbarView:R,toolbarLayout:B},view:{isReadOnly:M,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:Ie,measuredParagraphLayouts:Ce,documentLayout:Te,layout:jt,overlays:Vt,refs:Kt,surfaceHandlers:Xt,inputHandlers:Gt,fileHandlers:Yt}}),null),Qe(e,xe(mc,{state:u,get surfaceRef(){return ve()},documentLayout:Te,snapshotProvider:ke,get zoomFactor(){return K.zoomFactor},tableResize:nt,tableCornerResize:ot,imageOps:qe,tableDrag:rt,textDrag:it}),null),Qe(e,xe(_t,{get when(){return j()||!wt()},get children(){return xe(Tt,{get label(){return D()},get class(){return O()?.class},get style(){return O()?.style}})}}),null),Qe(e,xe(Xd,{get isOpen(){return H(()=>!(!he()||j()))()&&wt()},onClose:()=>be(!1)}),null),an(t=>{var n=r().theme??"light",o=!!A(),a=!!M(),i=!("simplified"!==r().toolbar?.ribbonStyle),l=!(null===_e.formatPainter.mode());return n!==t.e&&Pe(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-ribbon-simplified",t.o=i),l!==t.i&&e.classList.toggle("oasis-editor-format-painter-active",t.i=l),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})}export{rI as OasisEditorApp};
|