oasis-editor 0.0.380 → 0.0.382

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.
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-CjpNFd0O.js";import{$ as t,$i as n,$n as o,$r as r,$t as a,A as i,Ai as s,An as l,At as c,B as d,Bi as u,Bn as p,Br as g,Bt as f,C as m,Cn as h,Cr as b,Ct as y,D as v,Dn as x,Dt as w,E as S,En as I,F as C,Fi as T,Fn as k,G as P,Gn as R,Gr as M,Gt as O,H as A,Hn as B,Hr as D,Ht as F,I as E,Ii as L,In as N,J as z,Ji as $,Jn as H,Jr as W,Jt as U,K as j,Ki as V,Kn as K,Kr as _,Kt as X,L as G,Li as q,Ln as Y,M as Z,Mi as J,Mn as Q,Mt as ee,N as te,Ni as ne,Nn as oe,Nt as re,O as ae,On as ie,Ot as se,P as le,Pi as ce,Pn as de,Q as ue,Qi as pe,Qn as ge,Qr as fe,Qt as me,R as he,Ri as be,Rn as ye,Rr as ve,S as xe,Sn as we,Sr as Se,St as Ie,T as Ce,Tn as Te,Tr as ke,Tt as Pe,U as Re,Ui as Me,Un as Oe,Ur as Ae,Ut as Be,V as De,Vi as Fe,Vn as Ee,Vr as Le,Vt as Ne,W as ze,Wi as $e,Wn as He,Wr as We,Wt as Ue,X as je,Xi as Ve,Xn as Ke,Xr as _e,Xt as Xe,Y as Ge,Yi as qe,Yn as Ye,Yr as Ze,Yt as Je,Z as Qe,Zi as et,Zn as tt,Zr as nt,Zt as ot,_ as rt,_i as at,_n as it,_r as st,_t as lt,a as ct,aa as dt,ai as ut,an as pt,ar as gt,at as ft,b as mt,bi as ht,bn as bt,br as yt,bt as vt,c as xt,ci as wt,cn as St,cr as It,d as Ct,di as Tt,dn as kt,dr as Pt,dt as Rt,ea as Mt,en as Ot,er as At,et as Bt,f as Dt,fi as Ft,fn as Et,fr as Lt,ft as Nt,g as zt,gi as $t,gn as Ht,gr as Wt,gt as Ut,h as jt,hi as Vt,hn as Kt,hr as _t,ht as Xt,i as Gt,ii as qt,in as Yt,ir as Zt,it as Jt,j as Qt,ji as en,jn as tn,jt as nn,k as on,ki as rn,kn as an,kt as sn,l as ln,li as cn,ln as dn,lr as un,lt as pn,m as gn,mi as fn,mn,mr as hn,mt as bn,n as yn,na as vn,ni as xn,nn as wn,nr as Sn,nt as In,o as Cn,oa as Tn,on as kn,or as Pn,ot as Rn,p as Mn,pi as On,pn as An,pr as Bn,pt as Dn,q as Fn,qi as En,qn as Ln,qr as Nn,qt as zn,r as $n,ra as Hn,ri as Wn,rn as Un,rr as jn,rt as Vn,s as Kn,sa as _n,si as Xn,sn as Gn,sr as qn,st as Yn,t as Zn,ta as Jn,tn as Qn,tr as eo,tt as to,u as no,ui as oo,un as ro,ur as ao,ut as io,v as so,vi as lo,vn as co,vr as uo,vt as po,w as go,wn as fo,wt as mo,x as ho,xn as bo,xr as yo,xt as vo,y as xo,yi as wo,yn as So,yr as Io,yt as Co,z as To,zi as ko,zn as Po,zr as Ro,zt as Mo}from"./defaultToolbar-DjX3Bu9a.js";import{$ as Oo,$n as Ao,$t as Bo,A as Do,An as Fo,At as Eo,B as Lo,Bn as No,Bt as zo,C as $o,Ct as Ho,D as Wo,Dn as Uo,Dt as jo,E as Vo,En as Ko,Et as _o,F as Xo,Ft as Go,Gn as qo,Gt as Yo,H as Zo,Hn as Jo,Ht as Qo,I as er,In as tr,J as nr,Jn as or,Jt as rr,Kn as ar,Kt as ir,L as sr,Lt as lr,M as cr,Mn as dr,N as ur,Nn as pr,O as gr,Ot as fr,P as mr,Pn as hr,Pt as br,Q as yr,Qn as vr,Qt as xr,R as wr,Rt as Sr,S as Ir,St as Cr,T as Tr,Tn as kr,Tt as Pr,U as Rr,Un as Mr,V as Or,Vn as Ar,Vt as Br,W as Dr,Wt as Fr,X as Er,Xn as Lr,Xt as Nr,Yn as zr,Yt as $r,Z as Hr,Zn as Wr,Zt as Ur,_ as jr,_n as Vr,_t as Kr,a as _r,an as Xr,at as Gr,b as qr,bn as Yr,bt as Zr,c as Jr,cn as Qr,ct as ea,d as ta,dn as na,en as oa,er as ra,f as aa,fn as ia,ft as sa,g as la,gn as ca,gt as da,h as ua,ht as pa,i as ga,in as fa,it as ma,j as ha,k as ba,kt as ya,l as va,ln as xa,lt as wa,m as Sa,mn as Ia,mt as Ca,n as Ta,nn as ka,o as Pa,on as Ra,ot as Ma,p as Oa,pn as Aa,pt as Ba,qn as Da,qt as Fa,rn as Ea,rt as La,s as Na,tn as za,tr as $a,tt as Ha,u as Wa,un as Ua,v as ja,vn as Va,w as Ka,wn as _a,wt as Xa,x as Ga,xt as qa,y as Ya,yn as Za,yt as Ja,zn as Qa,zt as ei}from"./sourcePackage-DAQgLLKk.js";function ti(e,t){return{document:e.document,selection:t}}function ni(e,t){if(!fr(e.selection))return Qt(e,t<0?"start":"end");const{paragraphs:n,index:o,offset:r}=te(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return ti(e,E(na(i,Math.min(r,xa(i)))))}function oi(e,t){const{paragraphs:n,paragraph:o,index:r,offset:a}=te(e),i=xa(o);if(t<0&&a>0)return ti(e,{anchor:e.selection.anchor,focus:na(o,a-1)});if(t>0&&a<i)return ti(e,{anchor:e.selection.anchor,focus:na(o,a+1)});if(t<0&&r>0){const t=n[r-1];return ti(e,{anchor:e.selection.anchor,focus:na(t,xa(t))})}if(t>0&&r<n.length-1){const t=n[r+1];return ti(e,{anchor:e.selection.anchor,focus:na(t,0)})}return e}function ri(e,t){const{paragraphs:n,index:o,offset:r}=te(e),a=o+t;if(a<0||a>=n.length)return e;const i=n[a];return ti(e,{anchor:e.selection.anchor,focus:na(i,Math.min(r,xa(i)))})}function ai(e){const t=ya(e);if(t.isCollapsed)return"";const n=zo(e);if(t.startIndex===t.endIndex){const e=n[t.startIndex];return Ua(e).slice(t.startParagraphOffset,t.endParagraphOffset)}const o=[],r=n[t.startIndex],a=n[t.endIndex];o.push(Ua(r).slice(t.startParagraphOffset));for(let i=t.startIndex+1;i<t.endIndex;i+=1)o.push(Ua(n[i]));return o.push(Ua(a).slice(0,t.endParagraphOffset)),o.join("\n")}function ii(e,t){return{...e,selection:{anchor:Xa(e,t.anchor),focus:Xa(e,t.focus)}}}function si(e){if(!fr(e.selection))return Qt(e,"start");const{paragraph:t,index:n,offset:o}=te(e),r=zo(e);if(o>0)return{document:e.document,selection:E(na(t,o-1))};if(0===n)return e;const a=r[n-1];return{document:e.document,selection:E(na(a,xa(a)))}}function li(e){if(!fr(e.selection))return Qt(e,"end");const{paragraph:t,index:n,offset:o}=te(e),r=zo(e);if(o<xa(t))return{document:e.document,selection:E(na(t,o+1))};if(n>=r.length-1)return e;const a=r[n+1];return{document:e.document,selection:E(na(a,0))}}function ci(e,t){const n=ya(e);if(n.isCollapsed||n.startIndex!==n.endIndex||n.endParagraphOffset-n.startParagraphOffset!==1)return null;const o=zo(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}var di=La(),ui="http://schemas.openxmlformats.org/officeDocument/2006/relationships",pi="http://schemas.microsoft.com/office/2011/relationships",gi="application/vnd.openxmlformats-officedocument.",fi=16777216,mi=4096,hi=/* @__PURE__ */new Map([[ui+"/chart",/* @__PURE__ */new Set([gi+"drawingml.chart+xml"])],[pi+"/chartStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartstyle+xml"])],[pi+"/chartColorStyle",/* @__PURE__ */new Set(["application/vnd.ms-office.chartcolorstyle+xml"])],[ui+"/image",/* @__PURE__ */new Set(["image/png","image/jpeg","image/gif","image/bmp","image/tiff"])],[ui+"/package",/* @__PURE__ */new Set([gi+"spreadsheetml.sheet"])]]),bi="oasis.opc-chart-transfer.v1",yi=e=>{throw Error("Opaque transfer rejected: "+e)};function vi(e){if(!e||"object"!=typeof e||Array.isArray(e))return yi("expected record");const t=Object.getPrototypeOf(e);return t!==Object.prototype&&null!==t?yi("unexpected record prototype"):e}function xi(e,t=fi){return"string"!=typeof e||!e.length||e.length>t?yi("invalid string or size"):e}function wi(e,t){return!Array.isArray(e)||e.length>t?yi("invalid array or count"):e}function Si(e){const t=xi(e,512);return!/^[A-Za-z0-9_.\-/]+$/.test(t)||t.split("/").some(e=>!e||"."===e||".."===e||"_rels"===e)||t.endsWith(".rels")||"__proto__"===t||"constructor"===t||"prototype"===t?yi("unsafe part path"):t}function Ii(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return yi("unsafe XML declaration");const t=new di.DOMParser({onError:()=>yi("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||yi("missing XML root")}function Ci(e,t){const n=wi(e,mi).map(e=>function(e,t){const n=vi(e),o=xi(n.id,256),r=xi(n.type,512),a=xi(n.target,512);if(!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(o)||!hi.has(r))return yi("unsupported relationship");if(void 0!==n.targetMode&&"Internal"!==n.targetMode)return yi("external relationship");if(!/^[A-Za-z0-9_.\-/]+$/.test(a))return yi("unsafe relationship URI");const i=Si(n.resolvedTarget);return Xo(t,a)!==i?yi("inconsistent relationship target"):{id:o,type:r,target:a,targetMode:"Internal",resolvedTarget:i}}(e,t));return new Set(n.map(e=>e.id)).size!==n.length?yi("duplicate relationship ID"):n}function Ti(e){const t=vi(e),n=Si(t.path),o=xi(t.contentType,256),r=xi(t.data),a=o.endsWith("+xml");return[...hi.values()].some(e=>e.has(o))?t.kind!==(a?"xml":"binary")||t.encoding!==(a?"utf8":"base64")?yi("inconsistent part encoding"):a||/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(r)?(a&&Ii(r),{path:n,contentType:o,kind:a?"xml":"binary",encoding:a?"utf8":"base64",data:r,relationships:Ci(t.relationships,n)}):yi("invalid base64"):yi("unsupported content type")}function ki(e){const t=vi(e);if("oasis.opc-chart-transfer.v1"!==t.format)return yi("unsupported format");const n=Si(t.ownerPath),o=xi(t.fragmentXml,1048576),r=xi(t.signature,2097152),a=Ci(t.relationships,n),i=wi(t.parts,128).map(vi);let s=o.length+r.length,l=a.length;for(const m of i){if(s+=xi(m.data).length,l+=wi(m.relationships,mi).length,3*s>fi)return yi("aggregate size limit");if(l>mi)return yi("aggregate relationship limit")}const c=i.map(Ti),d=Ii(o),u=Rr(d);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==d.namespaceURI||"drawing"!==d.localName||!u||"chart"!==u.objectKind||"inline"!==u.placement||u.signature!==r)return yi("unsupported or changed chart fragment");if(1!==a.filter(e=>e.type===ui+"/chart").length||a.some(e=>e.type!==ui+"/chart")||JSON.stringify([...u.relationshipIds].sort())!==JSON.stringify(a.map(e=>e.id).sort()))return yi("chart relationship mismatch");const p=new Map(c.map(e=>[e.path,e]));if(p.size!==c.length||p.has(n))return yi("duplicate or story-dependent part");if(new Set([n,...p.keys()].map(e=>e.toLowerCase())).size!==c.length+1)return yi("aliased part path");const g=[...a],f=/* @__PURE__ */new Set;for(let m=0;m<g.length;m++){const e=g[m],t=p.get(e.resolvedTarget);if(!t||!hi.get(e.type)?.has(t.contentType))return yi("missing dependency or incompatible relationship type");if(!f.has(t.path)){if(f.add(t.path),t.contentType!==gi+"drawingml.chart+xml"&&t.relationships.length)return yi("unsupported nested dependency owner");if(t.relationships.some(e=>e.type===ui+"/chart"))return yi("nested chart dependency");g.push(...t.relationships)}}return f.size!==c.length?yi("unreachable payload part"):{format:bi,ownerPath:n,fragmentXml:o,signature:r,relationships:a,parts:c.sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:0)}}var Pi=/* @__PURE__ */e(nr(),1);var Ri=new Set(["chart","diagramData","diagramLayout","diagramQuickStyle","diagramColors","oleObject","package","image"].map(e=>"http://schemas.openxmlformats.org/officeDocument/2006/relationships/"+e)),Mi=(e,t)=>Object.hasOwn(e.parts,t),Oi=e=>Array.from(e.childNodes).filter(e=>1===e.nodeType);function Ai(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))throw Error("Unsupported XML declarations");const t=new di.DOMParser({onError:()=>{throw Error("Invalid XML")}}).parseFromString(e,"application/xml");if(!t.documentElement)throw Error("Missing XML root");return t}function Bi(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.startsWith("/")&&!e.split("/").some(e=>""===e||"."===e||".."===e)}function Di(e,t,n){const o=t.parts[e],r=n.parts[e];if(!o||!r||!Bi(e)||o.kind!==r.kind||o.data!==r.data||o.contentType!==r.contentType||o.encoding!==r.encoding)return!1;const a=o.contentType??"";return/^word\/charts\//.test(e)&&/^application\/vnd\.(?:openxmlformats-officedocument\.drawingml\.chart|ms-office\.chart(?:style|colorstyle))\+xml$/i.test(a)||/^word\/diagrams\//.test(e)&&/^application\/vnd\.openxmlformats-officedocument\.drawingml\.diagram(?:Data|Layout|Style|Colors)\+xml$/i.test(a)||/^word\/embeddings\//.test(e)&&/^(?:application\/vnd\.openxmlformats-officedocument\.(?:spreadsheetml\.sheet|wordprocessingml\.document|presentationml\.presentation|oleObject)|application\/vnd\.ms-excel)$/i.test(a)||/^word\/media\//.test(e)&&/^image\//.test(a)}function Fi(e,t){if(e.includes(t))return!0;const n=[Ai(e).documentElement];for(;n.length;){const e=n.pop();if(Array.from(e.attributes).some(e=>e.value.includes(t)))return!0;for(const o of Array.from(e.childNodes))if(1===o.nodeType)n.push(o);else if(o.nodeValue?.includes(t))return!0}return!1}function Ei(e,t){return e.id===t.id&&e.type===t.type&&e.mode===(t.targetMode??"Internal")&&e.resolved===t.resolvedTarget}function Li(e,t,n){const o=e=>({removeEdges:[],removeParts:[],...e?{skippedReason:e}:{}});if(!n.length)return o();try{if(e.mainDocumentPart!==t.mainDocumentPart)return o("Main part changed");if(Object.keys(t.parts).some(e=>e.startsWith("_xmlsignatures/")))return o("Signed package");const r=Zo(e),a=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const b of n){const n=r.objects.filter(e=>e.signature===b.signature),s=1===n.length?n[0]:void 0;if(!s||s.ownerPath!==e.mainDocumentPart||s.ownerPath!==b.ownerPath||s.ordinal!==b.ordinal||s.issues.length)return o("Ambiguous deletion intent");for(const o of s.partPaths)Di(o,e,t)&&a.add(o);for(const e of s.relationshipIds)i.add(e)}if(!a.size)return o();const s=function(e){const t=[];for(const[n,o]of Object.entries(e.parts)){const r=ha(n);if(void 0===r)continue;if(null!==r&&!Mi(e,r))throw Error("Relationship without owner");if("xml"!==o.kind)throw Error("Non-XML relationship part");const a=Ai(o.data).documentElement;if("http://schemas.openxmlformats.org/package/2006/relationships"!==a.namespaceURI||"Relationships"!==a.localName)throw Error("Invalid relationship root");const i=/* @__PURE__ */new Set;for(const o of Oi(a)){if("http://schemas.openxmlformats.org/package/2006/relationships"!==o.namespaceURI||"Relationship"!==o.localName)throw Error("Unknown relationship element");const a=o.getAttribute("Id"),s=o.getAttribute("Type"),l=o.getAttribute("Target"),c=o.getAttribute("TargetMode")||"Internal";if(!a||!s||!l||i.has(a)||"Internal"!==c&&"External"!==c)throw Error("Invalid or duplicate relationship");i.add(a);const d={owner:r,relPath:n,id:a,type:s,target:l,mode:c};if("Internal"===c){if(!/^[A-Za-z0-9_.\-/]+$/.test(l))throw Error("Ambiguous internal relationship URI");const t=Xo(r,l);if(!t||!Bi(t)||!Mi(e,t)||void 0!==ha(t)||"[Content_Types].xml"===t)throw Error("Unresolved internal relationship");d.resolved=t}t.push(d)}}return t}(t),l=t.parts[t.mainDocumentPart];if(!l||"xml"!==l.kind)return o("Missing main story XML");const c=/* @__PURE__ */new Set;for(const n of s)n.owner===t.mainDocumentPart&&"Internal"===n.mode&&n.resolved&&a.has(n.resolved)&&i.has(n.id)&&Ri.has(n.type)&&e.parts[e.mainDocumentPart]?.relationships?.find(e=>Ei(n,e))&&!Fi(l.data,n.id)&&c.add(n);if(!c.size)return o();const d=/* @__PURE__ */new Map;for(const e of s)if(!c.has(e)){const t=d.get(e.owner)??[];t.push(e),d.set(e.owner,t)}const u=/* @__PURE__ */new Set,p=[null,...Object.keys(t.parts).filter(e=>!a.has(e)&&"[Content_Types].xml"!==e&&void 0===ha(e))];for(let e=0;e<p.length;e++){const t=p[e];if(null!==t){if(u.has(t))continue;u.add(t)}for(const e of d.get(t)??[])e.resolved&&!u.has(e.resolved)&&p.push(e.resolved)}const g=/* @__PURE__ */new Set,f=[...c].flatMap(e=>e.resolved?[e.resolved]:[]);for(let e=0;e<f.length;e++){const t=f[e];if(a.has(t)&&!g.has(t)){g.add(t);for(const e of d.get(t)??[])e.resolved&&f.push(e.resolved)}}const m=[...g].filter(e=>!u.has(e)).sort(),h=new Set(m);for(const e of s)if(e.resolved&&h.has(e.resolved)&&!c.has(e)&&(null===e.owner||!h.has(e.owner)))return o("Retained incoming edge");return{removeEdges:[...c],removeParts:m}}catch(r){return o(r instanceof Error?r.message:String(r))}}var Ni="word/comments.xml";function zi(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 $i(e){return e.localName??e.tagName}function Hi(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 Wi(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 Ui(e){let t="";for(const n of zi(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n.namespaceURI){if("t"===$i(n)){t+=n.textContent??"";continue}if("tab"===$i(n)){t+="\t";continue}if("br"===$i(n)||"cr"===$i(n)){t+="\n";continue}}t+=Ui(n)}return t}function ji(e){return zi(e).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"p"===$i(e))}function Vi(e){return ji(e).map(Ui).join("\n").trim()}function Ki(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"comments"===$i(t)?t:void 0}function _i(e,t){const n=Hi(ji(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=ji(t)[0];n&&o&&o.setAttributeNS(Tr,"w14:paraId",n)}function Xi(e,t){const n=ji(e),o=ji(t);n[0]&&o[0]&&$o(n[0],o[0]);const r=new Set(zi(t).filter(e=>e.namespaceURI!==Vo).map(e=>`${e.namespaceURI??""}\0${$i(e)}`));for(const a of zi(e)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===a.namespaceURI)continue;const e=`${a.namespaceURI??""}\0${$i(a)}`;r.has(e)||(t.appendChild(a.cloneNode(!0)),r.add(e))}}async function Gi(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(Ni);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Ki(e),o=Ki(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of zi(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==$i(i))continue;const e=Hi(i,"id");void 0!==e&&r.set(e,i)}let a=!1;for(const i of zi(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"comment"!==$i(i))continue;const e=Hi(i,"id"),t=void 0!==e?r.get(e):void 0;if(!t)continue;const n=(new di.XMLSerializer).serializeToString(t);Wi(i,t),Vi(i)===Vi(t)?_i(i,t):Xi(i,t),(new di.XMLSerializer).serializeToString(t)!==n&&(a=!0)}return a?(new di.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Ni,a),!0)}var qi="http://schemas.microsoft.com/office/word/2012/wordml",Yi="word/commentsExtended.xml";function Zi(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 Ji(e){return e.localName??e.tagName}function Qi(e){return`${e.namespaceURI??""}\0${Ji(e)}`}function es(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 ts(e,t,n){t.namespaceURI?e.setAttributeNS(t.namespaceURI,t.name,n):e.setAttribute(t.name,n)}function ns(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 os(e){const t=/* @__PURE__ */new Map,n=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;if(!n)return t;for(const o of Array.from(n.getElementsByTagNameNS(Vo,"comment"))){const e=es(o,"id"),n=o.getElementsByTagNameNS(Vo,"p").item(0),r=n?es(n,"paraId"):void 0;void 0!==e&&r&&t.set(e,r)}return t}function rs(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return t?.namespaceURI===qi&&"commentsEx"===Ji(t)?t:void 0}function as(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))||ts(t,o,"paraIdParent"===a?n.get(o.value)??o.value:o.value))}const o=new Set(Zi(t).map(Qi));for(const r of Zi(e))o.has(Qi(r))||t.appendChild(r.cloneNode(!0))}function is(e,t,n,o){const r=rs(t),a=rs(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))||ts(t,o,o.value)}}(r,a);const i=os(e),s=os(n),l=/* @__PURE__ */new Map;for(const[p,g]of i){const e=s.get(p);e&&l.set(g,e)}const c=function(e){const t=/* @__PURE__ */new Map;for(const n of Zi(e)){if(n.namespaceURI!==qi||"commentEx"!==Ji(n))continue;const e=es(n,"paraId");e&&t.set(e,n)}return t}(a),d=Zi(r),u=new Set(Zi(a).filter(e=>!(e.namespaceURI===qi&&"commentEx"===Ji(e))).map(Qi));for(const p of d){if(p.namespaceURI===qi&&"commentEx"===Ji(p)){const e=es(p,"paraId"),t=e?l.get(e):void 0,n=t?c.get(t):void 0;n&&as(p,n,l);continue}u.has(Qi(p))||(a.appendChild(p.cloneNode(!0)),u.add(Qi(p)))}return(new di.XMLSerializer).serializeToString(a.ownerDocument)}var ss="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ls(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 cs(e){return e.localName??e.tagName}function ds(e){return`${e.namespaceURI??""}\0${cs(e)}`}function us(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 ps(e,t){return ls(e).find(e=>e.namespaceURI===ss&&cs(e)===t)}function gs(e,t){return e.filter(e=>e.namespaceURI===ss&&t.has(cs(e)))}function fs(e){if(e.namespaceURI!==ss)return;const t=cs(e);if("p"===t){const t=us(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=ps(e,"sdtPr"),n=t?ps(t,"id"):void 0,o=n?us(n,"val"):void 0;return o?`sdt:${o}`:void 0}}function ms(e,t,n){const o=(new di.DOMParser).parseFromString(e,"application/xml"),r=(new di.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(!a||!i||a.namespaceURI!==ss||i.namespaceURI!==ss||cs(a)!==n||cs(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 s=ls(a),l=ls(i),c=new Set(l.map(ds));return s.forEach((e,t)=>{if(e.namespaceURI===ss||c.has(ds(e)))return;const n=s.slice(t+1).map(e=>l.find(t=>ds(t)===ds(e))).find(e=>Boolean(e));i.insertBefore(e.cloneNode(!0),n??null)}),(new di.XMLSerializer).serializeToString(r)}function hs(e,t,n,o=/* @__PURE__ */new Set(["p","tbl","sdt"])){const r=ms(e,t,n),a=(new di.DOMParser).parseFromString(e,"application/xml"),i=(new di.DOMParser).parseFromString(r,"application/xml"),s=a.documentElement,l=i.documentElement;if(!s||!l||s.namespaceURI!==ss||l.namespaceURI!==ss||cs(s)!==n||cs(l)!==n)return r;const c=ls(s),d=ls(l),u=function(e,t,n){const o=gs(e,n),r=gs(t,n);return o.length===r.length&&o.every((e,t)=>cs(e)===cs(r[t]))}(c,d,o),p=/* @__PURE__ */new Map;return c.forEach((e,t)=>{if(e.namespaceURI!==ss||o.has(cs(e)))return;const n=ds(e),r=p.get(n)??0;if(p.set(n,r+1),ls(l).filter(e=>ds(e)===n)[r])return;const a=function(e,t,n,o,r){const a=e.slice(t+1).find(e=>e.namespaceURI===ss&&o.has(cs(e)));if(!a)return;const i=fs(a);if(i){const e=gs(n,o).find(e=>fs(e)===i);if(e)return e}if(!r)return;const s=gs(e,o),l=gs(n,o),c=s.indexOf(a);return c>=0?l[c]:void 0}(c,t,d,o,u);(a||u)&&l.insertBefore(e.cloneNode(!0),a??null)}),(new di.XMLSerializer).serializeToString(i)}var bs="word/document.xml",ys=/* @__PURE__ */new Set(["p","tbl","sdt","sectPr"]);function vs(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 xs(e){return e.localName??e.tagName}function ws(e){return`${e.namespaceURI??""}\0${xs(e)}`}function Ss(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 Is(e,t){return vs(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&xs(e)===t)}function Cs(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&ys.has(xs(e))}function Ts(e){return e.filter(Cs)}function ks(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI)return;const t=xs(e);if("p"===t){const t=Ss(e,"paraId");return t?`p:${t}`:void 0}if("sdt"===t){const t=Is(e,"sdtPr"),n=t?Ss(Is(t,"id")??t,"val"):void 0;return n?`sdt:${n}`:void 0}return"sectPr"===t?"sectPr:final":void 0}function Ps(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml"),o=(new di.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"!==xs(r)||"document"!==xs(a))return t;!function(e,t){const n=vs(e),o=Is(t,"body");if(!o)return;let r=o;const a=n.filter(e=>!("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"body"===xs(e))),i=/* @__PURE__ */new Set;for(let s=a.length-1;s>=0;s-=1){const e=a[s],n=vs(t).find(t=>!i.has(t)&&ws(t)===ws(e)),o=n??e.cloneNode(!0);n&&i.add(n),t.insertBefore(o,r),r=o}}(r,a);const i=Is(r,"body"),s=Is(a,"body");if(!i||!s)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,s);const l=vs(i),c=vs(s),d=function(e,t){const n=Ts(e),o=Ts(t);return n.length===o.length&&n.every((e,t)=>xs(e)===xs(o[t]))}(l,c),u=/* @__PURE__ */new Map;return l.forEach((e,t)=>{if(Cs(e))return;const n=ws(e),o=u.get(n)??0;if(u.set(n,o+1),vs(s).filter(e=>ws(e)===n)[o])return;const r=function(e,t,n){const o=e.slice(t+1).find(Cs);if(!o)return;const r=ks(o);return r?Ts(n).find(e=>ks(e)===r):void 0}(l,t,c),a=d?function(e,t,n){const o=Ts(e),r=Ts(n),a=e.slice(t+1).find(Cs);if(a){const e=o.indexOf(a);if(e>=0)return r[e]}}(l,t,c):void 0,i=r??a;("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||i)&&s.insertBefore(e.cloneNode(!0),i??function(e){return[...e].reverse().find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"sectPr"===xs(e))}(c)??null)}),(new di.XMLSerializer).serializeToString(o)}async function Rs(e,t){const n=e.parts[e.mainDocumentPart],o=t.file(bs);if("xml"!==n?.kind||!o)return!1;const r=await o.async("string"),a=function(e,t){return Ps(e,ms(e,t,"document"))}(n.data,r);return a!==r&&(t.file(bs,a),!0)}function Ms(e){return e.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id")||void 0}function Os(e){return e.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main","type")||"default"}function As(e,t){const n=e.getAttributeNodeNS(Ka,"id");return!(!n||n.value===t)&&(e.setAttributeNS(Ka,n.name,t),!0)}var Bs="word/document.xml",Ds="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Fs(e){const t=(new di.DOMParser).parseFromString(e,"application/xml");return Array.from(t.getElementsByTagNameNS(Ds,"sectPr")).filter(e=>Boolean(e)&&"sectPrChange"!==e.parentNode?.localName)}function Es(e){const t=[];return Fs(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===Ds&&"headerReference"===r.localName?"header":r.namespaceURI===Ds&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Ms(r);if(!a)continue;const i=Os(r),s=`${e}:${i}`,l=o.get(s)??0;o.set(s,l+1),t.push({key:`${n}:${e}:${i}:${l}`,kind:e,relationshipId:a})}}),t}function Ls(e){return new Map(e.map(e=>[e.id,e]))}async function Ns(e,t){const n=e.parts[e.mainDocumentPart],o=await(t.file(Bs)?.async("string"));if("xml"!==n?.kind||!o)return!1;const r=Fs(n.data),a=Fs(o);if(r.length!==a.length)return!1;const i=Es(n.data),s=Es(o),l=new Map(i.map(e=>[e.key,e])),c=Ls(n.relationships??[]),d=Ls(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`}(Bs))?.async("string"));return er(Bs,mr(t))}(t));let u=!1;for(const p of s){const n=l.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,s=await(t.file(i)?.async("string"));if(!s)continue;const g="header"===p.kind?"hdr":"ftr",f=hs(a.data,s,g);f!==s&&(t.file(i,f),u=!0)}return u}var zs="word/document.xml",$s={"/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"},Hs=["/officeDocument",...Object.keys($s)];function Ws(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}function Us(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 js(e){for(const[t,n]of Object.entries($s))if(e.type.endsWith(t))return n}function Vs(e,t){if("[Content_Types].xml"===e||"_rels/.rels"===e)return e;const n=ha(e);return void 0===n?t.get(e)??e:null===n?e:Us(t.get(n)??n)}function Ks(e,t){for(const[n,o]of t)if(o===e)return n;return e}function _s(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 Xs(e,t){const n=e.parts[t];return"xml"===n?.kind?mr(n.data):[]}function Gs(e,t){const n=null===t?e.rootRelationships.length>0?e.rootRelationships:Xs(e,Do):e.parts[t]?.relationships??Xs(e,Us(t));return er(t,n)}function qs(e,t,n){return Gs(e,t).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!n.has(e.resolvedTarget))}function Ys(e,t,n,o,r){return e.map(e=>{if("External"===e.targetMode)return e;const a=(i=e.type,Hs.find(e=>i.endsWith(e)));var i;const s=a?t.find(e=>"External"!==e.targetMode&&e.type.endsWith(a)):void 0,l=er(n,[e])[0]?.resolvedTarget,c=s?.resolvedTarget??(l?r.get(l)??l:void 0);return c?{...e,...s?{id:s.id,type:s.type}:{},target:_s(o,c),targetMode:"Internal",resolvedTarget:c}:e})}function Zs(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(Ws(e)===Ws(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 Js(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 Qs(e,t,n,o){const r=e.rebuiltPartHashes?.[t];return Boolean(r&&e.parts[n]&&r===_r(o))}async function el(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Pi.default.loadAsync(t),r=new Set(Object.entries(o.files).filter(([,e])=>!e.dir).map(([e])=>cr(e))),a=function(e){const t=/* @__PURE__ */new Map;t.set(zs,e.mainDocumentPart);const n=e.parts[e.mainDocumentPart];for(const o of n?.relationships??[]){if("External"===o.targetMode||!o.resolvedTarget)continue;const e=js(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!==zs&&e.rebuiltPartHashes?.[r]&&!n.has(r)&&e.parts[a]&&o.add(a);return o}(n,a,r),s=new Pi.default;for(const c of Object.keys(n.parts))Js(s,n,c);for(const c of i)s.remove(c),s.remove(Us(c));!function(e,t,n,o,r){if(0!==r.size)for(const a of Object.keys(t.parts)){const i=ha(a);if(null==i)continue;const s=Gs(t,i),l=s.filter(e=>"External"===e.targetMode||!e.resolvedTarget||!r.has(e.resolvedTarget));if(l.length===s.length)continue;const c=Ks(i,n);o.has(Us(c))||(0===l.length?e.remove(a):e.file(a,wr(l)))}}(s,n,a,r,i);let l=null;for(const[c,d]of Object.entries(o.files)){if(d.dir)continue;const e=cr(c);if("[Content_Types].xml"===e){l=await d.async("string");continue}const t=Vs(e,a),o=ha(e);if(void 0!==o){const e=o,r=null===e?null:a.get(e)??e,l=qs(n,r,i),c=Zs(l,Ys(mr(await d.async("string")),l,e,r,a),t);s.file(t,wr(c));continue}const r=await d.async("uint8array");Qs(n,e,t,r)||s.file(t,r)}return l&&s.file(gr,function(e,t,n,o){const r=ur(t),a={};for(const[s,l]of Object.entries(r.overrides))a[n.get(s)??s]=l;const i=Object.fromEntries(Object.entries(e.overrides).filter(([e])=>!o.has(e)));return sr({defaults:{...e.defaults,...r.defaults},overrides:{...i,...a}})}(n.contentTypes,l,a,i)),s.generateAsync({type:"arraybuffer"})}var tl="word/document.xml",nl=["first","even","default"];function ol(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 rl(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 al(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 il(e,t){const n=[],o=e=>{for(const r of al(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&r.localName===t&&n.push(r),o(r)};return o(e),n}function sl(e){const t=(new di.DOMParser).parseFromString(e,"application/xml"),n=[],o=il(t,"sectPr").filter(e=>"sectPrChange"!==e.parentNode?.localName);return o.forEach((e,t)=>{const o=/* @__PURE__ */new Map;for(const r of al(e)){const e="http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&"headerReference"===r.localName?"header":"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&"footerReference"===r.localName?"footer":void 0;if(!e)continue;const a=Ms(r);if(!a)continue;const i=Os(r),s=`${e}:${i}`,l=o.get(s)??0;o.set(s,l+1),n.push({key:`${t}:${e}:${i}:${l}`,sectionIndex:t,kind:e,type:i,occurrence:l,relationshipId:a})}}),{references:n,sectionCount:o.length}}function ll(e,t){const n=e.parts[t];return"xml"===n?.kind?n.data:void 0}function cl(e,t){const n=e.parts[t]?.relationships??mr(ll(e,ol(t)));return er(t,n)}function dl(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 ul(e,t){const n=ll(e,e.mainDocumentPart),o=await(t.file(tl)?.async("string"));if(!n||!o)return{matches:[],deletedSourcePartPaths:/* @__PURE__ */new Set,sourceRelationshipByCurrentId:/* @__PURE__ */new Map};const r=sl(n),a=sl(o),i=dl(r.references,cl(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=nl.indexOf(e.type),o=nl.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 s=dl(a.references,await async function(e,t){const n=await(e.file(ol(t))?.async("string"));return er(t,mr(n))}(t,tl)),l=new Map(i.map(e=>[e.key,e])),c=[],d=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const p of s){const e=l.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 pl(e){return[e.type,e.target,e.targetMode??"Internal"].join("\0")}async function gl(e,t,n,o){if(!o)return!1;const r=t.rebuiltPartHashes?.[o],a=e.file(n);return a?!!r&&r===_r(await a.async("uint8array")):void 0===r}async function fl(e,t,n,o){for(const r of n)if(!(await gl(e,t,o?ol(r.current.partPath):r.current.partPath,r.source.baselinePath?o?ol(r.source.baselinePath):r.source.baselinePath:void 0)))return!1;return!0}async function ml(e,t,n){if(t.length<2)return;const o=/* @__PURE__ */new Set;for(const r of t){const t=n?ol(r.current.partPath):r.current.partPath,a=await(e.file(t)?.async("uint8array"));o.add(a?_r(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 hl(e,t,n){const o=await(e.file(tl)?.async("string"));if(o){const r=t.rebuiltPartHashes?.[tl],a=_r((new TextEncoder).encode(o));if(!r||r!==a){const t=function(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml");let o=!1;for(const r of["headerReference","footerReference"])for(const e of il(n,r)){const n=Ms(e),r=n?t.get(n):void 0;r&&(o=As(e,r.id)||o)}return o?(new di.XMLSerializer).serializeToString(n):void 0}(o,n.sourceRelationshipByCurrentId);t&&e.file(tl,t)}}const r=ol(tl),a=mr(await(e.file(r)?.async("string"))).map(e=>{const t=n.sourceRelationshipByCurrentId.get(e.id);return t?.resolvedTarget?{...t,target:rl(tl,t.resolvedTarget),targetMode:"Internal"}:e});e.file(r,wr(function(e,t){const n=[],o=/* @__PURE__ */new Map;for(const r of e){const e=o.get(r.id);if(e){if(pl(e)===pl(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 bl(e,t,n){const o=n[0],r=o.source.partPath;if(!(await fl(e,t,n,!1))){await ml(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 i of n)i.current.partPath!==r&&e.remove(i.current.partPath);const a=ol(r);if(!(await fl(e,t,n,!0))){await ml(e,n,!0);const t=ol(o.current.partPath),i=await(e.file(t)?.async("string"));i&&e.file(a,wr(function(e,t,n){return e.map(e=>{if("External"===e.targetMode)return e;const o=er(t,[e])[0]?.resolvedTarget;return o?{...e,target:rl(n,o),targetMode:"Internal",resolvedTarget:o}:e})}(mr(i),o.current.partPath,r)))}for(const i of n){const t=ol(i.current.partPath);t!==a&&e.remove(t)}}async function yl(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 bl(e,t,o)}async function vl(e,t){const n=e.sourcePackage;if(!n)return t;const o=await Pi.default.loadAsync(t),r=await ul(n,o);r.matches.length>0&&(await hl(o,n,r),await yl(o,n,r),await async function(e,t){const n=await(e.file(gr)?.async("string"));if(!n)return;const o=ur(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(gr,sr(o))}(o,r));const a=r.matches.length>0?await o.generateAsync({type:"arraybuffer"}):t;return el(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[ol(d)];const a=r[n.mainDocumentPart],i=cl(n,n.mainDocumentPart).filter(e=>"External"===e.targetMode||!e.resolvedTarget||!t.has(e.resolvedTarget));a&&(r[n.mainDocumentPart]={...a,relationships:i});const s=ol(n.mainDocumentPart),l=r[s];l&&(r[s]={...l,data:wr(i)});const c=r[gr];return c&&(r[gr]={...c,data:sr(o)}),{...e,sourcePackage:{...n,contentTypes:o,parts:r}}}(e,r.deletedSourcePartPaths),a)}var xl=[{kind:"footnote",relationshipSuffix:"/footnotes",rebuiltPath:"word/footnotes.xml",rootName:"footnotes",entryName:"footnote"},{kind:"endnote",relationshipSuffix:"/endnotes",rebuiltPath:"word/endnotes.xml",rootName:"endnotes",entryName:"endnote"}],wl=/* @__PURE__ */new Set(["p","tbl"]),Sl=/* @__PURE__ */new Set(["separator","continuationSeparator","continuationNotice"]);function Il(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 Cl(e){return e.localName??e.tagName}function Tl(e){return`${e.namespaceURI??""}\0${Cl(e)}`}function kl(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 Pl(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 Rl(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Cl(n)===t?n:void 0}function Ml(e){const t=kl(e,"type");if(t&&Sl.has(t))return`type:${t}`;const n=kl(e,"id");return n?`id:${n}`:void 0}function Ol(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&wl.has(Cl(e))}function Al(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"p"!==Cl(e))return;const t=kl(e,"paraId");return t?`p:${t}`:void 0}function Bl(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=Il(e),o=Il(t),r=function(e,t){const n=e.filter(Ol),o=t.filter(Ol);return n.length===o.length&&n.every((e,t)=>Cl(e)===Cl(o[t]))}(n,o),a=/* @__PURE__ */new Map;n.forEach((e,i)=>{if(Ol(e))return;const s=Tl(e),l=a.get(s)??0;if(a.set(s,l+1),Il(t).filter(e=>Tl(e)===s)[l])return;const c=function(e,t,n,o){const r=e.slice(t+1).find(Ol);if(!r)return;const a=Al(r);if(a){const e=n.filter(Ol).find(e=>Al(e)===a);if(e)return e}if(!o)return;const i=e.filter(Ol),s=n.filter(Ol),l=i.indexOf(r);return l>=0?s[l]: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 Dl(e,t,n,o){const r=Rl(t,o.rootName),a=Rl(n,o.rootName);if(!r||!a)return n;const i=Il(r).filter(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Cl(e)===o.entryName),s=/* @__PURE__ */new Map;for(const c of Il(a)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==c.namespaceURI||Cl(c)!==o.entryName)continue;const e=Ml(c);e&&s.set(e,c)}const l=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=Ml(c);if(!e)continue;const t=s.get(e),n=kl(c,"type");if(t){n&&Sl.has(n)?a.replaceChild(c.cloneNode(!0),t):Bl(c,t);continue}if("continuationNotice"===n){a.appendChild(c.cloneNode(!0));continue}const o=kl(c,"id");o&&l.has(o)&&a.appendChild(c.cloneNode(!0))}return(new di.XMLSerializer).serializeToString(a.ownerDocument)}var Fl="http://schemas.openxmlformats.org/wordprocessingml/2006/main",El="word/numbering.xml";function Ll(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 Nl(e){return e.localName??e.tagName}function zl(e){return`${e.namespaceURI??""}\0${Nl(e)}`}function $l(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 Hl(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(Fl,`w:${t}`,n)}function Wl(e,t){return Ll(e).find(e=>e.namespaceURI===Fl&&Nl(e)===t)}function Ul(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 jl(e,t){const n=new Set(Ll(t).map(zl));for(const o of Ll(e))o.namespaceURI===Fl||n.has(zl(o))||t.appendChild(o.cloneNode(!0))}function Vl(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 Kl=/* @__PURE__ */new Set(["start","numFmt","lvlRestart","pStyle","lvlText","lvlJc","suff","isLgl"]);function _l(e,t){Ul(e,t);const n=Ll(e),o=new Map(Ll(t).map(e=>[zl(e),e]));n.forEach((e,r)=>{const a=zl(e),i=o.get(a),s=Nl(e);if(i)return Ul(e,i),void(e.namespaceURI===Fl&&"rPr"===s?function(e,t){Ul(e,t);const n=Ll(e),o=new Map(Ll(t).map(e=>[zl(e),e]));n.forEach((e,r)=>{const a=zl(e),i=o.get(a);if(i)return Ul(e,i),void jl(e,i);e.namespaceURI===Fl&&"rFonts"===Nl(e)||Vl(n,r,e,t,e=>o.get(zl(e)))})}(e,i):jl(e,i));if(e.namespaceURI!==Fl||!Kl.has(s)){if(e.namespaceURI===Fl&&"rPr"===s){const n=function(e){const t=e.cloneNode(!1);let n=!1;for(const o of Ll(e))o.namespaceURI===Fl&&"rFonts"===Nl(o)||(t.appendChild(o.cloneNode(!0)),n=!0);return n?t:void 0}(e);return void(n&&t.appendChild(n))}Vl(n,r,e,t,e=>o.get(zl(e)))}})}function Xl(e){return function(e){return e.namespaceURI===Fl&&"lvl"===Nl(e)?`${zl(e)}\0${$l(e,"ilvl")??"0"}`:zl(e)}(e)}function Gl(e,t,n){const o=Wl(t,"abstractNumId"),r=o?$l(o,"val"):void 0;if(!r)return;const a=Ll(e).find(e=>e.namespaceURI===Fl&&"abstractNum"===Nl(e)&&$l(e,"abstractNumId")===r);return a?Ll(a).find(e=>e.namespaceURI===Fl&&"lvl"===Nl(e)&&($l(e,"ilvl")??"0")===n):void 0}function ql(e,t){const n=t.cloneNode(!0);_l(e,n);const o=Wl(e,"pPr"),r=Wl(n,"pPr");return o?r?n.replaceChild(o.cloneNode(!0),r):n.appendChild(o.cloneNode(!0)):r&&n.removeChild(r),n}function Yl(e,t){if(!t)return e.cloneNode(!0);const n=e.cloneNode(!1),o=$l(Wl(t,"start")??t,"val")??"1";for(const r of Ll(e)){const e=Nl(r);if(r.namespaceURI===Fl&&"startOverride"===e){const e=r.cloneNode(!0);Hl(e,"val",o),n.appendChild(e);continue}r.namespaceURI!==Fl||"lvl"!==e?n.appendChild(r.cloneNode(!0)):n.appendChild(ql(r,t))}return n}function Zl(e){if(e.namespaceURI!==Fl)return zl(e);const t=Nl(e);return"abstractNum"===t?`${zl(e)}\0${$l(e,"abstractNumId")??""}`:"num"===t?`${zl(e)}\0${$l(e,"numId")??""}`:zl(e)}function Jl(e,t){const n=function(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml").documentElement,o=(new di.DOMParser).parseFromString(t,"application/xml").documentElement;if(n&&o&&n.namespaceURI===Fl&&o.namespaceURI===Fl&&"numbering"===Nl(n)&&"numbering"===Nl(o))return{sourceRoot:n,rebuiltRoot:o}}(e,t);if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;Ul(o,r);const a=Ll(o),i=new Map(Ll(r).map(e=>[Zl(e),e]));return a.forEach((e,t)=>{const n=Zl(e),o=i.get(n),s=Nl(e);if(o)return Ul(e,o),void(e.namespaceURI===Fl&&"abstractNum"===s?function(e,t){Ul(e,t);const n=Ll(e),o=new Map(Ll(t).map(e=>[Xl(e),e]));n.forEach((e,r)=>{const a=Xl(e),i=o.get(a);if(i)return Ul(e,i),void(e.namespaceURI===Fl&&"lvl"===Nl(e)?_l(e,i):jl(e,i));Vl(n,r,e,t,e=>o.get(Xl(e)))})}(e,o):e.namespaceURI===Fl&&"num"===s?function(e,t,n){Ul(e,t);const o=Wl(t,"abstractNumId"),r=/* @__PURE__ */new Map;for(const a of Ll(t))a.namespaceURI===Fl&&"lvlOverride"===Nl(a)&&r.set($l(a,"ilvl")??"0",a);for(const a of Ll(e)){const e=Nl(a);if(a.namespaceURI!==Fl||"abstractNumId"!==e){if(a.namespaceURI===Fl&&"lvlOverride"===e){const e=$l(a,"ilvl")??"0",o=Yl(a,Gl(n,t,e)),i=r.get(e);i?t.replaceChild(o,i):t.appendChild(o),r.set(e,o);continue}a.namespaceURI===Fl||Ll(t).some(e=>zl(e)===zl(a))||t.appendChild(a.cloneNode(!0))}else o&&(Ul(a,o),jl(a,o))}}(e,o,r):jl(e,o));Vl(a,t,e,r,e=>i.get(Zl(e)))}),(new di.XMLSerializer).serializeToString(r.ownerDocument)}async function Ql(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(El);if(!n||!o)return!1;const r=await o.async("string"),a=Jl(n,r);return a!==r&&(t.file(El,a),!0)}var ec=[{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 tc(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 nc="http://schemas.openxmlformats.org/wordprocessingml/2006/main",oc=/* @__PURE__ */new Set(["headerReference","footerReference","type","pgSz","pgMar","pgNumType","cols","vAlign","bidi"]);function rc(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 ac(e){return e.localName??e.tagName}function ic(e){return`${e.namespaceURI??""}\0${ac(e)}`}function sc(e){const t=[],n=e=>{for(const o of rc(e))o.namespaceURI===nc&&"sectPr"===ac(o)&&"sectPrChange"!==o.parentNode?.localName&&t.push(o),n(o)};return n(e),t}function lc(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 cc(e){return e.namespaceURI===nc&&oc.has(ac(e))}function dc(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml"),o=(new di.DOMParser).parseFromString(t,"application/xml"),r=n.documentElement,a=o.documentElement;if(!r||!a)return t;const i=sc(n),s=sc(o);return 0===i.length||i.length!==s.length?t:(lc(r,a),i.forEach((e,t)=>{!function(e,t){lc(e,t);const n=rc(e),o=rc(t),r=/* @__PURE__ */new Map;for(const i of o){const e=ic(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=ic(e),s=a.get(o)??0;a.set(o,s+1);const l=r.get(o)?.[s];if(l){lc(e,l);continue}if(cc(e))continue;const c=n.slice(i+1).map(e=>r.get(ic(e))?.[0]).find(e=>Boolean(e));t.insertBefore(e.cloneNode(!0),c??null)}}(e,s[t])}),(new di.XMLSerializer).serializeToString(o))}var uc="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function pc(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 gc(e){return e.localName??e.tagName}function fc(e,t){const n=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return n?.namespaceURI===uc&&gc(n)===t?n:void 0}function mc(e){return pc(e).length>0?(new di.XMLSerializer).serializeToString(e.ownerDocument):void 0}var hc=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]),bc=/* @__PURE__ */new Map([["compat",/* @__PURE__ */new Set(["allowSpaceOfSameStyleInTable"])],["footnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])],["endnotePr",/* @__PURE__ */new Set(["numFmt","numStart","numRestart"])]]);function yc(e){const t=fc(e,"settings");if(!t)return e;for(const n of[...pc(t)]){if(n.namespaceURI!==uc)continue;const e=gc(n);if(hc.has(e)){t.removeChild(n);continue}const o=bc.get(e);if(o){for(const e of[...pc(n)])e.namespaceURI===uc&&o.has(gc(e))&&n.removeChild(e);0===pc(n).length&&t.removeChild(n)}}return mc(t)}function vc(e){const t=fc(e,"styles");if(!t)return e;for(const n of[...pc(t)])n.namespaceURI===uc&&"style"===gc(n)&&t.removeChild(n);return mc(t)}function xc(e){const t=fc(e,"fonts");if(!t)return e;for(const n of[...pc(t)])n.namespaceURI===uc&&"font"===gc(n)&&t.removeChild(n);return mc(t)}async function wc(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 Sc="word/styles.xml";function Ic(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 Cc(e){return e.localName??e.tagName}function Tc(e){return`${e.namespaceURI??""}\0${Cc(e)}`}function kc(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 Pc(e,t){return Ic(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Cc(e)===t)}function Rc(e){return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Cc(e)?`${Tc(e)}\0${kc(e,"type")??""}`:Tc(e)}function Mc(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Cc(t)?t:void 0}function Oc(e,t){const n=Pc(e,"pPr");if(!n)return!1;const o=Pc(t,"pPr"),r=new di.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",s=ja(a,i);if(s===i)return!1;if(!s)return!!o&&(t.removeChild(o),!0);const l=function(e){if(!e)return;const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"pPr"===Cc(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=Ic(e),a=r.indexOf(n),i=Ic(t),s=new Map(i.map(e=>[Rc(e),e])),l=r.slice(a+1).map(e=>s.get(Rc(e))).find(e=>Boolean(e));t.insertBefore(o,l??null)}(e,t,n,c),!0}async function Ac(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(Sc);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Mc(e),o=Mc(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Ic(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Cc(i))continue;const e=kc(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Ic(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Cc(i))continue;const e=kc(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Oc(i,t)||a)}return a?(new di.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Sc,a),!0)}function Bc(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 Dc(e){return e.localName??e.tagName}function Fc(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 Ec(e,t){const n=function(e){if(!e)return;const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===Dc(t)?t:void 0}(e);if(!n)return t;const o=`<w:r xmlns:w="${Vo}" xmlns:w14="${Tr}">${t}<w:t/></w:r>`,r={id:"ooxml-style-rpr-source",kind:"text",text:""};Ha(r,`<w:r xmlns:w="${Vo}" xmlns:w14="${Tr}">${e}<w:t/></w:r>`);const a=function(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"r"===Dc(t)?t:void 0}(Ya(r,o));if(!a)return t;let i=Bc(a).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"rPr"===Dc(e));return!i&&Fc(n)&&(i=a.ownerDocument.createElementNS(Vo,"w:rPr"),a.insertBefore(i,a.firstChild)),i?($o(n,i),0!==Bc(i).length||Fc(i)?(new di.XMLSerializer).serializeToString(i):""):""}var Lc="word/styles.xml";function Nc(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 zc(e){return e.localName??e.tagName}function $c(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 Hc(e,t){return Nc(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&zc(e)===t)}function Wc(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===zc(t)?t:void 0}function Uc(e,t){const n=Hc(e,"rPr");if(!n)return!1;const o=Hc(t,"rPr"),r=new di.XMLSerializer,a=r.serializeToString(n),i=o?r.serializeToString(o):"",s=Ec(a,i);if(s===i)return!1;if(!s)return!!o&&(t.removeChild(o),!0);const l=function(e){if(!e)return;const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"rPr"===zc(t)?t:void 0}(s);if(!l)return!1;const c=l.cloneNode(!0);return o?t.replaceChild(c,o):function(e,t,n,o){const r=Nc(e),a=r.indexOf(n),i=Nc(t),s=r.slice(a+1).map(e=>i.find(t=>t.namespaceURI===e.namespaceURI&&zc(t)===zc(e))).find(e=>Boolean(e));t.insertBefore(o,s??null)}(e,t,n,c),!0}async function jc(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(Lc);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=Wc(e),o=Wc(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of Nc(o)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==zc(i))continue;const e=$c(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of Nc(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==zc(i))continue;const e=$c(i,"styleId"),t=e?r.get(e):void 0;t&&(a=Uc(i,t)||a)}return a?(new di.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Lc,a),!0)}var Vc="word/styles.xml",Kc=/* @__PURE__ */new Set(["pPr","rPr","tblPr","trPr","tcPr"]);function _c(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 Xc(e){return e.localName??e.tagName}function Gc(e){return`${e.namespaceURI??""}\0${Xc(e)}`}function qc(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 Yc(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 Zc(e,t){return _c(e).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Xc(e)===t)}function Jc(e){return e?(new di.XMLSerializer).serializeToString(e):""}function Qc(e,t){if(!e)return;const n=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===n?.namespaceURI&&Xc(n)===t?n:void 0}function ed(e,t,n){switch(e){case"pPr":return ja(t,n);case"rPr":return Ec(t,n);case"tblPr":return Ga(t,n);case"trPr":return Ir(t,n);case"tcPr":return qr(t,n);default:return n}}function td(e,t,n,o){const r=_c(e),a=r.indexOf(n),i=r.slice(a+1).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&Kc.has(Xc(e)));return i?Zc(t,Xc(i))??null:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"style"===Xc(e)&&Kc.has(o)?_c(t).find(e=>"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===e.namespaceURI&&"tblStylePr"===Xc(e))??null:null}function nd(e,t,n){const o=Zc(e,n);if(!o)return!1;const r=Zc(t,n),a=Jc(r),i=ed(n,Jc(o),a);if(i===a)return!1;if(!i)return!!r&&(t.removeChild(r),!0);const s=Qc(i,n);if(!s)return!1;const l=s.cloneNode(!0);return r?(t.replaceChild(l,r),!0):(t.insertBefore(l,td(e,t,o,n)),!0)}function od(e,t){Yc(e,t);let n=!1;for(const r of Kc)n=nd(e,t,r)||n;const o=new Set(_c(t).map(Gc));for(const r of _c(e))"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Kc.has(Xc(r))||o.has(Gc(r))||(t.appendChild(r.cloneNode(!0)),o.add(Gc(r)),n=!0);return n}function rd(e){const t=e.ownerDocument;if(!t)return;const n=t.createElementNS(Vo,"w:tblStylePr");Yc(e,n);let o=!1;for(const r of _c(e)){const e=Xc(r);if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===r.namespaceURI&&Kc.has(e)){const t=Qc(ed(e,Jc(r),""),e);t&&(n.appendChild(t.cloneNode(!0)),o=!0);continue}n.appendChild(r.cloneNode(!0)),o=!0}return o?n:void 0}function ad(e){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==e.namespaceURI||"tblStylePr"!==Xc(e))return;const t=qc(e,"type");return t?`tblStylePr:${t}`:void 0}function id(e,t){let n=!1;n=nd(e,t,"tblPr")||n;const o=_c(e).filter(e=>void 0!==ad(e)),r=/* @__PURE__ */new Map;for(const a of _c(t)){const e=ad(a);e&&r.set(e,a)}for(const a of o){const o=ad(a),i=r.get(o);if(i){n=od(a,i)||n;continue}const s=rd(a);if(!s)continue;const l=_c(e),c=l.indexOf(a),d=l.slice(c+1).find(e=>void 0!==ad(e)),u=d?r.get(ad(d))??null:null;t.insertBefore(s.cloneNode(!0),u),n=!0}return n}function sd(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").documentElement;return"http://schemas.openxmlformats.org/wordprocessingml/2006/main"===t?.namespaceURI&&"styles"===Xc(t)?t:void 0}async function ld(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(Vc);if(!n||!o)return!1;const r=await o.async("string"),a=function(e,t){const n=sd(e),o=sd(t);if(!n||!o)return t;const r=/* @__PURE__ */new Map;for(const i of _c(o))if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"===i.namespaceURI&&"style"===Xc(i)){const e=qc(i,"styleId");e&&r.set(e,i)}let a=!1;for(const i of _c(n)){if("http://schemas.openxmlformats.org/wordprocessingml/2006/main"!==i.namespaceURI||"style"!==Xc(i))continue;if("table"!==qc(i,"type"))continue;const e=qc(i,"styleId"),t=e?r.get(e):void 0;t&&(a=id(i,t)||a)}return a?(new di.XMLSerializer).serializeToString(o.ownerDocument):t}(n,r);return a!==r&&(t.file(Vc,a),!0)}var cd="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function dd(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 ud(e){return e.localName??e.tagName}function pd(e){return`${e.namespaceURI??""}\0${ud(e)}`}function gd(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 fd(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 md(e,t,n){const o=(new di.DOMParser).parseFromString(e,"application/xml"),r=(new di.DOMParser).parseFromString(t,"application/xml"),a=o.documentElement,i=r.documentElement;if(a&&i&&a.namespaceURI===cd&&i.namespaceURI===cd&&ud(a)===n&&ud(i)===n)return{sourceRoot:a,rebuiltRoot:i}}function hd(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 bd(e,t){const n=new Set(dd(t).map(pd));for(const o of dd(e))o.namespaceURI===cd||n.has(pd(o))||t.appendChild(o.cloneNode(!0))}var yd=/* @__PURE__ */new Set(["defaultTabStop","autoHyphenation","consecutiveHyphenLimit","hyphenationZone","doNotHyphenateCaps","evenAndOddHeaders"]);var vd=/* @__PURE__ */new Set(["name","basedOn","next","uiPriority","qFormat","semiHidden","unhideWhenUsed","pPr","rPr","tblPr","tblStylePr"]);function xd(e){return e.namespaceURI===cd&&"tblStylePr"===ud(e)?`${pd(e)}\0${gd(e,"type")??""}`:pd(e)}function wd(e){return e.namespaceURI===cd&&"style"===ud(e)?`${pd(e)}\0${gd(e,"styleId")??""}`:pd(e)}var Sd=/* @__PURE__ */new Set(["altName","panose1","charset","family","pitch","sig"]);function Id(e){return e.namespaceURI===cd&&"font"===ud(e)?`${pd(e)}\0${gd(e,"name")??""}`:pd(e)}var Cd=[{relationshipSuffix:"/settings",rebuiltPath:"word/settings.xml",merge:function(e,t){const n=md(e,t,"settings");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;fd(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=dd(o),s=new Map(dd(r).map(e=>[pd(e),e]));return i.forEach((e,t)=>{const n=pd(e),o=s.get(n),l=ud(e),c=e.namespaceURI===cd?a.get(l):void 0;if(o)return fd(e,o),void(c?function(e,t,n){fd(e,t);const o=dd(t),r=new Map(o.map(e=>[pd(e),e])),a=dd(e);a.forEach((e,o)=>{const i=pd(e),s=r.get(i);if(s)return fd(e,s),void bd(e,s);e.namespaceURI===cd&&n.has(ud(e))||hd(a,o,e,t,e=>r.get(pd(e)))})}(e,o,c):bd(e,o));if(c){const n=function(e,t){const n=e.cloneNode(!1);let o=!1;for(const r of dd(e))r.namespaceURI===cd&&t.has(ud(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=>s.get(pd(e))).find(e=>Boolean(e));r.insertBefore(n,e??null)}return}e.namespaceURI===cd&&yd.has(l)||hd(i,t,e,r,e=>s.get(pd(e)))}),(new di.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/styles",rebuiltPath:"word/styles.xml",merge:function(e,t){const n=md(e,t,"styles");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;fd(o,r);const a=dd(o),i=new Map(dd(r).map(e=>[wd(e),e]));return a.forEach((e,t)=>{const n=wd(e),o=i.get(n);if(o)return fd(e,o),void(e.namespaceURI===cd&&"style"===ud(e)?function(e,t){fd(e,t);const n=dd(e),o=new Map(dd(t).map(e=>[xd(e),e]));n.forEach((e,r)=>{const a=xd(e),i=o.get(a);if(i)return fd(e,i),void bd(e,i);e.namespaceURI===cd&&vd.has(ud(e))||hd(n,r,e,t,e=>o.get(xd(e)))})}(e,o):bd(e,o));hd(a,t,e,r,e=>i.get(wd(e)))}),(new di.XMLSerializer).serializeToString(r.ownerDocument)}},{relationshipSuffix:"/numbering",rebuiltPath:"word/numbering.xml"},{relationshipSuffix:"/fontTable",rebuiltPath:"word/fontTable.xml",merge:function(e,t){const n=md(e,t,"fonts");if(!n)return t;const{sourceRoot:o,rebuiltRoot:r}=n;fd(o,r);const a=dd(o),i=new Map(dd(r).map(e=>[Id(e),e]));return a.forEach((e,t)=>{const n=Id(e),o=i.get(n);if(o)return fd(e,o),void(e.namespaceURI===cd&&"font"===ud(e)&&function(e,t){fd(e,t);const n=dd(e),o=new Map(dd(t).map(e=>[pd(e),e]));n.forEach((e,r)=>{const a=pd(e),i=o.get(a);i?fd(e,i):e.namespaceURI===cd&&Sd.has(ud(e))||hd(n,r,e,t,e=>o.get(pd(e)))})}(e,o));hd(a,t,e,r,e=>i.get(Id(e)))}),(new di.XMLSerializer).serializeToString(r.ownerDocument)}}];function Td(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 kd="word/document.xml";function Pd(e){const t=(new di.DOMParser).parseFromString(e,"application/xml").getElementsByTagNameNS(Vo,"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 Rd(e,t){const n=e.sourcePackage;if(!n)return t;const o=n.parts[n.mainDocumentPart];if("xml"!==o?.kind)return el(e,t);const r=await Pi.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 s=await async function(e,t){let n=!1;for(const o of Cd){const r=Td(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"),s=o.merge(r,i);s!==i&&(t.file(o.rebuiltPath,s),n=!0)}return n}(n,r);a&&(s=await Ql(n,r)||s),i.styles&&(s=await Ac(n,r)||s,s=await jc(n,r)||s,s=await ld(n,r)||s),s=await async function(e,t){let n=!1;return t.settings||(n=await wc(e,"word/settings.xml",yc)||n),t.styles||(n=await wc(e,"word/styles.xml",vc)||n),t.fontTable||(n=await wc(e,"word/fontTable.xml",xc)||n),n}(r,i)||s,s=await async function(e,t){let n=!1;for(const o of ec){const r=tc(e,o.relationshipSuffix),a=t.file(o.rebuiltPath);if(!r||!a)continue;const i=await a.async("string"),s=ms(r,i,o.rootLocalName);s!==i&&(t.file(o.rebuiltPath,s),n=!0)}return n}(n,r)||s,s=await async function(e,t,n){let o=!1;for(const r of xl){const a=Pl(t,r.relationshipSuffix),i=n.file(r.rebuiltPath);if(!a||!i)continue;const s=await i.async("string"),l=Dl(e,a,s,r);l!==s&&(n.file(r.rebuiltPath,l),o=!0)}return o}(e,n,r)||s,s=await Gi(n,r)||s,s=await async function(e,t){const n=ns(e,"/comments"),o=ns(e,"/commentsExtended"),r=t.file("word/comments.xml"),a=t.file(Yi);if(!(n&&o&&r&&a))return!1;const i=await r.async("string"),s=await a.async("string"),l=is(n,o,i,s);return l!==s&&(t.file(Yi,l),!0)}(n,r)||s,s=await Ns(n,r)||s,s=await Rs(n,r)||s;const l=await(r.file(kd)?.async("string"));if(!l||Pd(o.data)!==Pd(l)){return el(e,s?await r.generateAsync({type:"arraybuffer"}):t)}const c=dc(o.data,l);c!==l&&(r.file(kd,c),s=!0);return vl(e,s?await r.generateAsync({type:"arraybuffer"}):t)}function Md(e){return e.trim().replace(/[{}]/g,"").toLowerCase()}function Od(e){const t=(new di.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 Ad(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 Bd(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 Dd(e){const t=[];for(let n=0;n<e.childNodes.length;n+=1){const o=e.childNodes[n];o?.nodeType===o.ELEMENT_NODE&&t.push(o)}return t}function Fd(e,t,n){if(!e||!t?.storeItemID||!t.xpath)return!1;const o=function(e,t){const n=Md(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=Od(r.data);if(a&&Md(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 di.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 s=i.at(-1)?.startsWith("@")?i.pop():null,l=Ad(i[0]);if(!l||1!==l.index)return null;if(!Bd(r,l.prefix,l.localName,n))return null;let c=r;for(let m=1;m<i.length;m+=1){const e=Ad(i[m]);if(!e)return null;const t=Dd(c).filter(t=>Bd(t,e.prefix,e.localName,n))[e.index-1];if(!t)return null;c=t}if(!s)return{document:o,element:c};const d=s.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(Dd(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 di.XMLSerializer).serializeToString(r.document),!0)}function Ed(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 Ld(e){return e.blocks.map(zd).filter(Boolean).join("\n")}function Nd(e){return e.cells.map(Ld).filter(Boolean).join("\t")}function zd(e){return"paragraph"===e.type?Ua(e):e.rows.map(Nd).filter(Boolean).join("\n")}function $d(e,t){for(const n of e.runs){for(const e of n.sdtWrappers??[])Ed(t,e,n.text,"");"textBox"===n.kind&&Wd(n.textBox.blocks,t)}}function Hd(e,t){for(const n of e.rows){const e=Nd(n);for(const o of n.sdtWrappers??[])Ed(t,o,e,"\n");for(const o of n.cells){const e=Ld(o);for(const n of o.sdtWrappers??[])Ed(t,n,e,"\n");Wd(o.blocks,t)}}}function Wd(e,t){if(e)for(const n of e){const e=zd(n);for(const o of n.sdtWrappers??[])Ed(t,o,e,"\n");"paragraph"===n.type?$d(n,t):Hd(n,t)}}async function Ud(e,t={}){if(!e.sourcePackage)return Pa(e);const n=(o=e.sourcePackage,{...o,contentTypes:{defaults:{...o.contentTypes.defaults},overrides:{...o.contentTypes.overrides}},rootRelationships:o.rootRelationships.map(e=>({...e})),parts:Object.fromEntries(Object.entries(o.parts).map(([e,t])=>[e,{...t,...t.relationships?{relationships:t.relationships.map(e=>({...e}))}:{}}])),...o.diagnostics?{diagnostics:o.diagnostics.map(e=>({...e}))}:{},...o.rebuiltPartHashes?{rebuiltPartHashes:{...o.rebuiltPartHashes}}:{}});var o;const r=Zo(n),a=r.diagnostics.filter(e=>"error"===e.level);if(a.length)throw new Lo(a);n.opaqueObjects=r.objects;const i={...e,sourcePackage:n};!function(e){if(!e.sourcePackage)return 0;const t=/* @__PURE__ */new Map;for(const o of ka(e))Wd(o.blocks,t),Wd(o.header,t),Wd(o.firstPageHeader,t),Wd(o.evenPageHeader,t),Wd(o.footer,t),Wd(o.firstPageFooter,t),Wd(o.evenPageFooter,t);let n=0;for(const{wrapper:o,value:r}of t.values()){const t=o.sdtPr.dataBinding;t&&Fd(e.sourcePackage,t,r)&&(n+=1)}}(i);const s=r.objects.length>0,l=e.opaqueRelocationIntent,c=l?va(n,l,l.destinationOwner):void 0,d=await Jr(i,n);let u=await Rd(i,d);if(c){if(e.opaqueDeletionIntents?.length)throw new Error("Cannot combine opaque deletion and relocation");u=await async function(e,t){const n=await Pi.default.loadAsync(e);if(!n.file(t.destinationOwner))throw Error("Original destination story was not retained");const o=t.destinationOwner.lastIndexOf("/"),r=(o>=0?t.destinationOwner.slice(0,o+1):"")+"_rels/"+t.destinationOwner.slice(o+1)+".rels",a=await(n.file(r)?.async("string"))??'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>';if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(a))throw Error("Unsafe relationship XML");const i=new di.DOMParser({onError:()=>{throw Error("Malformed relationships")}}).parseFromString(a,"application/xml"),s=i.documentElement;if(!s||"http://schemas.openxmlformats.org/package/2006/relationships"!==s.namespaceURI||"Relationships"!==s.localName)throw Error("Invalid destination relationships");const l=/* @__PURE__ */new Set;for(const c of Array.from(s.getElementsByTagNameNS(ba,"Relationship"))){const e=c.getAttribute("Id");if(!e||l.has(e))throw Error("Duplicate destination relationship");l.add(e)}for(const c of t.addedRelationships){if(l.has(c.id)||!c.resolvedTarget||!n.file(c.resolvedTarget))throw Error("Relocation relationship collision or missing target");l.add(c.id);const e=i.createElementNS(ba,s.prefix?s.prefix+":Relationship":"Relationship");e.setAttribute("Id",c.id),e.setAttribute("Type",c.type),e.setAttribute("Target",c.target),s.appendChild(e)}return n.file(r,(new di.XMLSerializer).serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,c)}if(s||t.requireOpaquePreservation||c||e.opaqueDeletionIntents?.length){const{captureDocxSourcePackage:o}=await import("./sourcePackage-DAQgLLKk.js").then(e=>e.r),r=await o(u),a=Or(n,r,e.opaqueDeletionIntents,c?function(e,t){const n=e.opaqueObjects?.find(e=>e.ownerPath===t.sourceOwner&&e.ordinal===t.sourceOrdinal&&e.signature===t.sourceSignature),o=e.parts[t.destinationOwner];if(!n||!o)throw Error("Relocation source missing");const r={...e,parts:{...e.parts,[t.destinationOwner]:{...o,relationships:[...o.relationships??[],...t.addedRelationships]}}},a=Dr(r,t.destinationOwner,t.destinationRun.relationshipIds);if(a.issues.length)throw Error("Invalid relocation closure");return{original:n,expected:{...n,ownerPath:t.destinationOwner,signature:t.destinationRun.signature,fragmentXml:t.destinationRun.fragmentXml,relationshipIds:t.destinationRun.relationshipIds,...a}}}(n,c):void 0);if(a.length)throw new Lo(a);const i=e.opaqueDeletionIntents??[];if(i.length&&!1!==t.pruneDeletedOpaqueDependencies){const e=Li(n,r,i);if(e.removeEdges.length||e.removeParts.length){const t=await async function(e,t){if(!t.removeParts.length&&!t.removeEdges.length)return e;const n=await Pi.default.loadAsync(e),o=new di.XMLSerializer,r=async e=>{const t=n.file(e);if(!t)throw Error("Missing planned OPC part "+e);return Ai(await t.async("string"))};for(const l of new Set(t.removeEdges.map(e=>e.relPath))){const e=await r(l),a=e.documentElement,i=new Set(t.removeEdges.filter(e=>e.relPath===l).map(e=>e.id));for(const t of Oi(a))i.has(t.getAttribute("Id")??"")&&(i.delete(t.getAttribute("Id")),a.removeChild(t));if(i.size)throw Error("OPC relationship plan became stale");Oi(a).length?n.file(l,o.serializeToString(e)):n.remove(l)}const a=new Set(t.removeParts);for(const[l,c]of Object.entries(n.files)){if(c.dir)continue;const e=ha(l);(a.has(l)||"string"==typeof e&&a.has(e))&&n.remove(l)}const i=await r(gr),s=i.documentElement;if("http://schemas.openxmlformats.org/package/2006/content-types"!==s.namespaceURI||"Types"!==s.localName)throw Error("Invalid OPC content types");for(const l of Oi(s))"http://schemas.openxmlformats.org/package/2006/content-types"===l.namespaceURI&&"Override"===l.localName&&a.has((l.getAttribute("PartName")??"").replace(/^\//,""))&&s.removeChild(l);return n.file(gr,o.serializeToString(i)),n.generateAsync({type:"arraybuffer"})}(u,e),r=await o(t),a=Or(n,r,i);if(a.length)throw new Lo(a);return t}}}return u}async function jd(e,t={}){if(!e.sourcePackage)return Na(e);const n=await Ud(e,t);return new Blob([n],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}var Vd="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Kd="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",_d="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Xd=e=>{throw Error("Opaque insertion rejected: "+e)};function Gd(e){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return Xd("unsafe XML declaration");const t=new di.DOMParser({onError:()=>Xd("malformed XML")}).parseFromString(e,"application/xml").documentElement;return t||Xd("missing XML root")}function qd(e){const t=[],n=[e];for(let o=0;o<n.length;o++){const e=n[o];t.push(e);for(const t of Array.from(e.childNodes))1===t.nodeType&&n.push(t)}return t}function Yd(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function Zd(e,t){const n=e.split("/").slice(0,-1),o=t.split("/");for(;n.length&&o.length&&n[0]===o[0];)n.shift(),o.shift();const r="../".repeat(n.length)+o.join("/");return Xo(e,r)!==t?Xd("unrepresentable relative target"):r}function Jd(e){return/^[A-Za-z0-9_.\-/]+$/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e)}var Qd={"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":"xml","application/vnd.ms-office.chartstyle+xml":"xml","application/vnd.ms-office.chartcolorstyle+xml":"xml","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/bmp":"bmp","image/tiff":"tiff"};var eu="http://schemas.openxmlformats.org/wordprocessingml/2006/main",tu="[Content_Types].xml",nu="application/vnd.openxmlformats-package.relationships+xml",ou=e=>{throw Error("Opaque transfer application rejected: "+e)};function ru(e,t,n){if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(e))return ou("unsafe XML declaration");const o=new di.DOMParser({onError:()=>ou("malformed XML")}).parseFromString(e,"application/xml");return o.documentElement?.namespaceURI!==t||o.documentElement.localName!==n?ou("unexpected XML root"):o}function au(e){return Array.from(e.childNodes).filter(e=>1===e.nodeType)}function iu(e){const t=e.lastIndexOf("/");return e.slice(0,t+1)+"_rels/"+e.slice(t+1)+".rels"}function su(e){return(new di.XMLSerializer).serializeToString(e)}function lu(e,t){return e.byteLength===t.byteLength&&e.every((e,n)=>e===t[n])}function cu(e){const t=/* @__PURE__ */new Set;for(const[n,o]of Object.entries(e.files)){if(o.dir)continue;const e=n.toLowerCase();if(t.has(e)||void 0!==o.unsafeOriginalName&&o.unsafeOriginalName!==n)return ou("ambiguous ZIP entry");if(t.add(e),e.startsWith("_xmlsignatures/"))return ou("signed package")}}async function du(e,t,n){const o=await Pi.default.loadAsync(e);cu(o);const r=await Ta(e);!function(e){if([...e.rootRelationships,...Object.values(e.parts).flatMap(e=>e.relationships??[])].some(e=>e.type.includes("digital-signature"))||[...Object.values(e.contentTypes.defaults),...Object.values(e.contentTypes.overrides)].some(e=>e.includes("digital-signature")))ou("signed package")}(r);const a=function(e,t){const n=ki(e),o=t.mainDocumentPart,r=Object.hasOwn(t.parts,o)?t.parts[o]:void 0;if(!Jd(o)||!r||"xml"!==r.kind)return Xd("missing destination main story");const a=Gd(r.data);if(a.namespaceURI!==Vd||"document"!==a.localName)return Xd("only Transitional main story is supported");if(Zo(t).diagnostics.some(e=>"error"===e.level))return Xd("destination opaque inspection errors");const i=/* @__PURE__ */new Set,s=e=>{if("[Content_Types].xml"!==e&&!Jd(e))return Xd("ambiguous destination OPC path");i.add(e.toLowerCase())};for(const[k,P]of Object.entries(t.parts)){if(P.path!==k)return Xd("inconsistent destination part path");s(k),"[Content_Types].xml"===k||k.endsWith(".rels")||s(Yd(k));for(const e of P.relationships??[])if("External"!==e.targetMode){if(!e.resolvedTarget||Xo(k,e.target)!==e.resolvedTarget)return Xd("unresolved destination relationship");s(e.resolvedTarget)}}for(const k of Object.keys(t.contentTypes.overrides))s(k);for(const k of t.rootRelationships)if("External"!==k.targetMode){if(!k.resolvedTarget||Xo(null,k.target)!==k.resolvedTarget)return Xd("unresolved root relationship");s(k.resolvedTarget)}if(new Set(Object.keys(t.parts).map(e=>e.toLowerCase())).size!==Object.keys(t.parts).length)return Xd("aliased destination parts");let l="";for(let k=1;k<=1e5;k++){const e="word/oasis-transfer-"+k;if(![...i].some(t=>t===e||t.startsWith(e+"/")||e.startsWith(t+"/"))){l=e;break}}if(!l)return Xd("part namespace exhausted");const c=new Map(n.parts.map((e,t)=>[e.path,l+"/part-"+(t+1)+"."+Qd[e.contentType]])),d=(e,t,n=e.id)=>{const o=c.get(e.resolvedTarget);return o?{...e,id:n,target:Zd(t,o),resolvedTarget:o,targetMode:"Internal"}:Xd("unmapped dependency")},u=n.parts.map(e=>{const t=c.get(e.path);return{...e,path:t,relationships:e.relationships.map(e=>d(e,t))}}),p=new Set((r.relationships??[]).map(e=>e.id));if(p.size!==(r.relationships??[]).length)return Xd("duplicate destination relationship ID");const g=qd(a).flatMap(e=>Array.from(e.attributes).map(e=>e.value));let f=1;const m=n.relationships.map(e=>{let t;do{t="rIdOasisTransfer"+f++}while(p.has(t)||r.data.includes(t)||g.some(e=>e.includes(t)));return p.add(t),{from:e.id,to:t}}),h=new Map(m.map(e=>[e.from,e.to])),b=n.relationships.map(e=>d(e,o,h.get(e.id))),y=Gd(n.fragmentXml),v=qd(y),x=v.filter(e=>e.namespaceURI===Kd&&"docPr"===e.localName),w=v.filter(e=>"http://schemas.openxmlformats.org/drawingml/2006/chart"===e.namespaceURI&&"chart"===e.localName);if(1!==x.length||1!==w.length||!h.has(w[0].getAttributeNS(_d,"id")??""))return Xd("ambiguous chart or drawing identity");for(const k of v){if(k!==y&&k.namespaceURI===Vd)return Xd("nested WordprocessingML in chart drawing");for(const e of Array.from(k.attributes)){if("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"===e.namespaceURI)return Xd("unsupported extended drawing identity");if(e.namespaceURI===_d||"http://purl.oclc.org/ooxml/officeDocument/relationships"===e.namespaceURI||"urn:schemas-microsoft-com:office:office"===e.namespaceURI&&"relid"===e.localName){if(k!==w[0]||e.namespaceURI!==_d||"id"!==e.localName||!h.has(e.value))return Xd("unknown chart relationship reference");k.setAttributeNS(_d,e.name,h.get(e.value))}else if("http://www.w3.org/2000/xmlns/"!==e.namespaceURI&&h.has(e.value))return Xd("unknown attribute may reference a relationship")}}const S=/* @__PURE__ */new Set;for(const k of Object.values(t.parts)){if("xml"!==k.kind||!k.data.includes("docPr"))continue;const e=k.path===o?a:Gd(k.data);for(const t of qd(e)){if(t.namespaceURI!==Kd||"docPr"!==t.localName)continue;const e=t.getAttribute("id")??"";if(!/^\d+$/.test(e)||Number(e)>4294967295)return Xd("invalid destination drawing ID");S.add(Number(e))}}let I=1879048192;for(;S.has(I)&&I<2147483647;)I++;if(S.has(I))return Xd("drawing identity exhausted");x[0].setAttribute("id",String(I));const C=Rr(y);if(!C)return Xd("chart projection lost");const T=ki({...n,ownerPath:o,fragmentXml:C.fragmentXml,signature:C.signature,relationships:b,parts:u});return{destinationOwner:o,destinationRun:C,addedRelationships:T.relationships,addedParts:T.parts,contentTypeOverrides:Object.fromEntries(T.parts.map(e=>[e.path,e.contentType])),pathMapping:[...c].map(([e,t])=>({from:e,to:t})),relationshipMapping:m,drawingId:I}}(t,r),i=a.destinationOwner,s=r.parts[i],l=ru(s.data,eu,"document"),c=l.documentElement,d=au(c).filter(e=>e.namespaceURI===eu&&"body"===e.localName);if(1!==d.length)return ou("ambiguous document body");const u=au(d[0]).filter(e=>e.namespaceURI===eu&&"p"===e.localName);if(!Number.isSafeInteger(n)||n<0||n>=u.length)return ou("invalid paragraph index");const p=u[n],g=ru(a.destinationRun.fragmentXml,eu,"drawing"),f=l.createElementNS(eu,c.prefix?c.prefix+":r":"r");f.appendChild(l.importNode(g.documentElement,!0)),p.appendChild(f);const m=su(l),h=iu(i),b=function(e,t){const n=ru(e,ba,"Relationships"),o=n.documentElement,r=/* @__PURE__ */new Set;for(const a of au(o)){const e=a.getAttribute("Id")??"";if("http://schemas.openxmlformats.org/package/2006/relationships"!==a.namespaceURI||"Relationship"!==a.localName||!e||r.has(e)||!a.getAttribute("Type")||!a.getAttribute("Target"))return ou("ambiguous existing relationships");const t=a.getAttribute("TargetMode");if(t&&"Internal"!==t&&"External"!==t)return ou("unknown relationship mode");r.add(e)}for(const a of t){if(r.has(a.id))return ou("relationship collision");r.add(a.id);const e=n.createElementNS(ba,o.prefix?o.prefix+":Relationship":"Relationship");e.setAttribute("Id",a.id),e.setAttribute("Type",a.type),e.setAttribute("Target",a.target),o.appendChild(e)}return su(n)}(await(o.file(h)?.async("string"))??'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>',a.addedRelationships),y=await(o.file(tu)?.async("string"));if(!y)return ou("missing content types");const v=function(e,t){const n=ru(e,Wo,"Types"),o=n.documentElement,r=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set;let i;for(const s of au(o)){if("http://schemas.openxmlformats.org/package/2006/content-types"!==s.namespaceURI)return ou("unexpected content type element");const e=s.getAttribute("ContentType")??"";if(!e)return ou("missing content type");if("Default"===s.localName){const t=(s.getAttribute("Extension")??"").toLowerCase();if(!t||a.has(t))return ou("duplicate or invalid content type default");a.add(t),"rels"===t&&(i=e)}else{if("Override"!==s.localName)return ou("unknown content type element");{const e=(s.getAttribute("PartName")??"").toLowerCase();if(!e.startsWith("/")||r.has(e))return ou("duplicate or invalid content type override");r.add(e)}}}if(i&&i!==nu)return ou("inconsistent relationship content type");if(!i){const e=n.createElementNS(Wo,o.prefix?o.prefix+":Default":"Default");e.setAttribute("Extension","rels"),e.setAttribute("ContentType",nu),o.insertBefore(e,au(o).find(e=>"Override"===e.localName)??null)}for(const[s,l]of Object.entries(t.contentTypeOverrides)){const e="/"+s;if(r.has(e.toLowerCase()))return ou("content type override collision");r.add(e.toLowerCase());const t=n.createElementNS(Wo,o.prefix?o.prefix+":Override":"Override");t.setAttribute("PartName",e),t.setAttribute("ContentType",l),o.appendChild(t)}return su(n)}(y,a),x={...r,parts:{...r.parts,[i]:{...s,data:m,relationships:[...s.relationships??[],...a.addedRelationships]}},contentTypes:{defaults:{...r.contentTypes.defaults,rels:nu},overrides:{...r.contentTypes.overrides,...a.contentTypeOverrides}}};for(const N of a.addedParts)x.parts[N.path]={...N,originalHash:""};const w=Zo(r),S=Zo(x);if(S.diagnostics.some(e=>"error"===e.level)||S.objects.length!==w.objects.length+1)return ou("unexpected predicted inventory");const I=S.objects.filter(e=>e.ownerPath===i&&e.signature===a.destinationRun.signature);if(1!==I.length||JSON.stringify(I[0].partPaths)!==JSON.stringify(a.addedParts.map(e=>e.path).sort()))return ou("predicted inserted closure mismatch");const C=S.objects.filter(e=>e!==I[0]),T=e=>JSON.stringify([e.ownerPath,e.kind,e.signature,e.edges,e.partPaths]);if(JSON.stringify(C.map(T).sort())!==JSON.stringify(w.objects.map(T).sort()))return ou("predicted loss of original objects");if(1!==Array.from(c.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing","docPr")).filter(e=>Number(e.getAttribute("id"))===a.drawingId).length)return ou("drawing ID collision");const k=await Pi.default.loadAsync(e),P=/* @__PURE__ */new Set,R=new Set(Object.keys(k.files).map(e=>e.toLowerCase())),M=(e,t,n=!1)=>{const o=e.toLowerCase();if(R.has(o)||P.has(o))return ou("part collision");P.add(o),k.file(e,t,{base64:n})};for(const N of a.addedParts)M(N.path,N.data,"base64"===N.encoding),N.relationships.length&&M(iu(N.path),wr(N.relationships));o.file(h)||P.add(h.toLowerCase()),k.file(i,m),k.file(h,b),k.file(tu,v);const O=await k.generateAsync({type:"arraybuffer",compression:"DEFLATE"}),A=await Pi.default.loadAsync(O);cu(A);const B=await Ta(O),D=Or(x,B);if(D.length)throw new Lo(D);const F=/* @__PURE__ */new Set([i,h,tu]);for(const[N,z]of Object.entries(o.files)){if(z.dir||F.has(N))continue;const e=A.file(N);if(!e||!lu(await z.async("uint8array"),await e.async("uint8array")))return ou("existing part changed: "+N)}for(const[N,z]of Object.entries(A.files))if(!z.dir&&!o.file(N)&&!P.has(N.toLowerCase()))return ou("unexpected added part: "+N);for(const N of a.addedParts){const e=B.parts[N.path];if(!e||e.contentType!==N.contentType||e.kind!==N.kind||e.encoding!==N.encoding||e.data!==N.data)return ou("copied payload mismatch")}for(const[N,z]of Object.entries(r.parts))if(B.parts[N]?.contentType!==z.contentType)return ou("existing part content type changed");for(const[N,z]of Object.entries(r.contentTypes.defaults))if(B.contentTypes.defaults[N]!==z)return ou("existing default changed");for(const[N,z]of Object.entries(r.contentTypes.overrides))if(B.contentTypes.overrides[N]!==z)return ou("existing override changed");const E=B.parts[i]?.relationships??[],L=x.parts[i].relationships??[];return JSON.stringify(E)!==JSON.stringify(L)?ou("owner relationships changed"):{buffer:O,plan:a}}var uu=e=>{throw Error("Opaque editor transfer rejected: "+e)};function pu(e){return 1!==e.sections?.length?uu("only one section is supported"):e.sections[0].blocks.filter(e=>"paragraph"===e.type)}function gu(e){if(!e.document.sourcePackage||"main"!==Sr(e)||1!==e.document.sections?.length||e.trackChangesEnabled||e.document.opaqueDeletionIntents?.length||e.document.opaqueRelocationIntent||e.document.bookmarks?.order.length||e.document.comments?.order.length)return uu("unsupported state or pending opaque edit")}function fu(e){gu(e);const t=ci(e,e=>"opaque"===e.kind);if(!t||"opaque"!==t.run.kind||t.run.revision||t.run.sdtWrappers?.length||!pu(e.document).some(e=>e.id===t.paragraph.id))return uu("select one unwrapped chart in the main story");const n=e.document.sourcePackage,o=t.run.opaque,r=Zo(n).objects.filter(e=>e.ownerPath===n.mainDocumentPart&&e.signature===o.signature),a=1===r.length?r[0]:void 0;return a&&a.fragmentXml===o.fragmentXml&&JSON.stringify(a.relationshipIds)===JSON.stringify(o.relationshipIds)?function(e,t){const n=Zo(e);if(n.diagnostics.some(e=>"error"===e.level))return yi("source inspection errors");const o=n.objects.filter(e=>e.signature===t.signature),r=1===o.length?o[0]:void 0;if(!r||r.ownerPath!==t.ownerPath||r.ordinal!==t.ordinal)return yi("ambiguous original identity");if("chart"!==r.kind||"inline"!==r.geometry?.placement)return yi("only inline charts are supported");const a=Dr(e,r.ownerPath,r.relationshipIds);if(a.issues.length)return yi("unresolved source closure");const i=e.parts[r.ownerPath],s=a.partPaths.map(t=>{const n=Object.hasOwn(e.parts,t)?e.parts[t]:void 0;return n?{path:n.path,contentType:n.contentType,kind:n.kind,encoding:n.encoding,data:n.data,relationships:n.relationships??[]}:yi("missing source part")});return ki({format:bi,ownerPath:r.ownerPath,fragmentXml:r.fragmentXml,signature:r.signature,relationships:(i.relationships??[]).filter(e=>r.relationshipIds.includes(e.id)),parts:s})}(n,a):uu("selection is not an unchanged original")}function mu(e){return JSON.stringify(pu(e).map(e=>{const t=[];let n=0;for(const o of e.runs)"opaque"===o.kind&&t.push([n,o.kind,o.opaque.signature]),n+=o.text.length;return[e.runs.map(e=>e.text).join(""),t]}))}function hu(e,t,n,o){const r=G(t,n,[o]),a=na(r,n+1);return ro(e,zo(e).map(e=>e.id===t.id?r:e),{anchor:a,focus:a})}async function bu(e,t){gu(e);const n=ya(e);if(!n.isCollapsed)return uu("paste requires a collapsed caret");const o=zo(e)[n.startIndex],r=pu(e.document).findIndex(e=>e.id===o?.id);if(!o||r<0)return uu("caret must be in a direct body paragraph");const a=n.startParagraphOffset;if(!Number.isSafeInteger(a)||a<0||a>xa(o))return uu("invalid caret");if(o.runs.some(e=>"text"!==e.kind&&"opaque"!==e.kind||e.revision||e.sdtWrappers?.length||e.styles?.link))return uu("unsupported destination runs");const i=await Ud(e.document);if(mu(await zn(i.slice(0)))!==mu(e.document))return uu("destination body projection mismatch");const s=await du(i,t,r),l=await Ta(s.buffer),c=l.opaqueObjects?.filter(e=>e.signature===s.plan.destinationRun.signature&&e.ownerPath===l.mainDocumentPart);if(1!==c?.length)return uu("staged chart identity mismatch");const d={...s.plan.destinationRun,fragmentXml:c[0].fragmentXml,relationshipIds:[...c[0].relationshipIds]},u={id:ar("run"),kind:"opaque",text:"",opaque:d,styles:{}},p=function(e,t){const n=e.document.sourcePackage,o=Zo(n).objects,r=Zo(t).objects,a=/* @__PURE__ */new Set,i=zo(e).map(e=>{let i=!1;const s=e.runs.map(e=>{if("opaque"!==e.kind)return e;const s=e.opaque,l=o.filter(e=>e.signature===s.signature),c=r.filter(e=>e.signature===s.signature),d=l[0],u=c[0];return 1!==l.length||1!==c.length||!d||!u||d.ownerPath!==n.mainDocumentPart||u.ownerPath!==t.mainDocumentPart||d.kind!==s.objectKind||d.fragmentXml!==s.fragmentXml||JSON.stringify(d.relationshipIds)!==JSON.stringify(s.relationshipIds)||JSON.stringify(d.edges)!==JSON.stringify(u.edges)||JSON.stringify(d.partPaths)!==JSON.stringify(u.partPaths)||d.partPaths.some(e=>{const o=n.parts[e],r=t.parts[e];return!o||!r||o.kind!==r.kind||o.contentType!==r.contentType||o.encoding!==r.encoding||o.data!==r.data})||a.has(d.signature)?uu("cannot rebind original chart provenance"):(a.add(d.signature),u.fragmentXml===s.fragmentXml?e:(i=!0,{...e,opaque:{...s,fragmentXml:u.fragmentXml,relationshipIds:[...u.relationshipIds]}}))});return i?{...e,runs:s}:e});return ro(e,i,e.selection)}(e,l),g=zo(p).find(e=>e.id===o.id);if(!g)return uu("target paragraph lost during rebind");const f={...hu(p,g,xa(g),u).document,sourcePackage:l};if(mu(await zn(s.buffer))!==mu(f))return uu("staged body projection mismatch");l.rebuiltPartHashes=await ga(f,l);const m=hu(p,g,a,u),h={...m,document:{...m.document,sourcePackage:l}},b=await Ud(h.document);return mu(await zn(b))!==mu(h.document)?uu("exported caret position mismatch"):h}var yu="application/x-oasis-chart-token",vu="web "+yu;function xu(e){return"application/x-oasis-chart-token"===e||"web application/x-oasis-chart-token"===e}var wu,Su=0;function Iu(e){const t=++Su;wu=void 0;const n=fu(e),o=globalThis.crypto.randomUUID();let r=!1;return{token:o,confirm:()=>!r&&t===Su&&(r=!0,wu={token:o,manifest:n,expires:Date.now()+3e5},!0)}}function Cu(e){return wu&&Date.now()>=wu.expires&&(wu=void 0),wu&&wu.token===e?structuredClone(wu.manifest):void 0}function Tu(e){const t=zo(e),n=ya(e,t);if(n.isCollapsed)return!1;for(let o=n.startIndex;o<=n.endIndex;o++){const e=t[o];if(!e)continue;const r=o===n.startIndex?n.startParagraphOffset:0,a=o===n.endIndex?n.endParagraphOffset:xa(e);let i=0;for(const t of e.runs){const e=i+t.text.length;if("opaque"===t.kind&&i<a&&e>r)return!0;i=e}}return!1}function ku(e){const n=ya(e);if(n.isCollapsed)return"";const o=zo(e),r=[];let a=null;const i=()=>{a&&(r.push("bullet"===a?"</ul>":"</ol>"),a=null)};for(let s=n.startIndex;s<=n.endIndex;s+=1){const l=o[s];if(!l)continue;const c=s===n.startIndex?n.startParagraphOffset:0,d=s===n.endIndex?n.endParagraphOffset:xa(l),u=t(l,c,d),p=oo(l,e.document,u.map(e=>e.text).join("")),g=Xn(u,e.document);if(l.list?.kind){const e="bullet"===l.list.kind?"ul":"ol";a!==l.list.kind&&(i(),r.push(`<${e}>`),a=l.list.kind),r.push(`<li${p}>${g}</li>`);continue}i(),r.push(`<p${p}>${g}</p>`)}return i(),r.join("")}function Pu(e,t){if(0===t.length||Fn(e))return e;const n=fr(e.selection)?e:Z(e),{paragraph:o,index:r,offset:a}=te(n),i=zo(n),s=0===xa(o);if(Fn(n))return e;const{beforeRuns:l,afterRuns:c}=he(o,a),d=t.map(e=>{const t=or(e.runs.map(e=>({text:e.text,styles:Gr(e.styles),image:e.image?{...e.image}:void 0})));return t.style=e.style?{...e.style}:void 0,t.list=e.list?{...e.list}:void 0,t});let u,p=E(na(o,a));if(1===d.length){const e=d[0],t=e.runs.reduce((e,t)=>e+t.text.length,0),n=To(o,[...l,...e.runs.map(Oo),...c],ue(o,a));n.style=s&&void 0!==e.style?.tabs?{...o.style,tabs:e.style.tabs}:o.style?{...o.style}:e.style?{...e.style}:void 0,n.list=o.list?{...o.list}:e.list?{...e.list}:void 0,u=[...yr(i.slice(0,r)),n,...yr(i.slice(r+1))],p=E(na(n,l.reduce((e,t)=>e+t.text.length,0)+t))}else{const e=d[0],t=d[d.length-1],n=t.runs.reduce((e,t)=>e+t.text.length,0),g=To(o,[...l,...e.runs.map(Oo)],ue(o,a));g.style=s&&void 0!==e.style?.tabs?{...o.style,tabs:e.style.tabs}:o.style?{...o.style}:e.style?{...e.style}:void 0,g.list=o.list?{...o.list}:e.list?{...e.list}:void 0;const f=d.slice(1,-1).map(Er),m=To(t,[...t.runs.map(Oo),...c],void 0);m.list=t.list?{...t.list}:void 0,u=[...yr(i.slice(0,r)),g,...f,m,...yr(i.slice(r+1))],p=E(na(m,n))}return ro(n,u,p)}function Ru(e){return e.map(Oo)}function Mu(e){return e.reduce((e,t)=>e+t.text.length,0)}function Ou(e,n,o){if(0===o.length)return e;const r=zo(e),a=r.findIndex(e=>e.id===n.paragraphId);if(-1===a)return e;const i=r[a],s=ia(i,n),l=Ru(o[0].runs);if(1===o.length){const t=G(i,s,l),n=r.map((e,n)=>n===a?t:e),o=Mu(l),c=na(t,s),d=na(t,s+o);return ro(e,n,{anchor:c,focus:d})}const c=t(i,0,s),d=t(i,s,xa(i)),u=o[o.length-1],p=o.slice(1,-1),g=To(Er(o[0].paragraphTemplate),[...c,...l],ue(i,s)),f=p.map(e=>To(Er(e.paragraphTemplate),Ru(e.runs))),m=To(Er(u.paragraphTemplate),[...Ru(u.runs),...d],ue(i,s)),h=[...r.slice(0,a),g,...f,m,...r.slice(a+1)],b=na(g,Mu(c)),y=na(m,Mu(u.runs));return ro(e,h,{anchor:b,focus:y})}function Au(e,n,o={}){const r=ya(e);if(r.isCollapsed)return e;if(function(e,t){const n=ya(e);if(n.isCollapsed)return!1;const o=zo(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=ia(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset||r===n.endIndex&&i>n.endParagraphOffset)}(e,n))return e;if(Fn(e))return e;const a=zo(e).find(e=>e.id===n.paragraphId);if(a&&(z(a)||j(a,ia(a,n),ia(a,n))))return e;const i=function(e){const n=ya(e);if(n.isCollapsed)return[];const o=zo(e),r=[];for(let a=n.startIndex;a<=n.endIndex;a+=1){const e=o[a],i=a===n.startIndex?n.startParagraphOffset:0,s=a===n.endIndex?n.endParagraphOffset:xa(e),l=t(e,i,s);r.push({paragraphTemplate:Er(e),runs:l})}return r}(e);if(0===i.length)return e;const s=i.flatMap(e=>e.runs);if(s.some(e=>"opaque"===e.kind)){if(o.copy||e.trackChangesEnabled||1!==s.length||"opaque"!==s[0].kind||s[0].revision||s[0].sdtWrappers?.length||1!==i.length)return e;const t=zo(e),a=t.findIndex(e=>e.id===n.paragraphId);if(a<0)return e;const l=t[a],c=ia(l,n),d=r.endParagraphOffset-r.startParagraphOffset,u=a===r.startIndex&&c>r.endParagraphOffset?c-d:c,p=Z(e),g=zo(p).find(e=>e.id===l.id);return g?Ou(p,na(g,u),i):e}if(o.copy)return Ou(e,n,i);const l=function(e,t){const n=ya(e),o=zo(e),r=o.findIndex(e=>e.id===t.paragraphId);if(-1===r)return t;const a=o[r],i=ia(a,t);if(n.startIndex===n.endIndex){if(r!==n.startIndex||i<=n.endParagraphOffset)return t;const e=o[n.startIndex];return na(e,i-(n.endParagraphOffset-n.startParagraphOffset))}return t}(e,n);return Ou(Z(e),l,i)}function Bu(e,t,n){if(0===t.length)return e;if(fr(e.selection)?P(e):Fn(e))return e;const o=fr(e.selection)?e:Z(e),{paragraph:r,index:a,offset:i}=te(o),s=n?{...n}:ue(r,i),l={id:`run:${Math.random().toString(36).slice(2,9)}`,text:t,styles:s,kind:"text"};o.trackChangesEnabled&&(l.revision={id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"insert",author:"User",date:Date.now()});const c=G(r,i,[l]),d=zo(o).map((e,t)=>t===a?c:e);return ro(o,d,E(na(c,i+t.length)))}function Du(e){return Bu(e,"\v")}function Fu(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 Bu(e,o,n);if(Fn(e))return e;const r=fr(e.selection)?e:Z(e),{paragraph:a,index:i,offset:s}=te(r),l=o.split("\n"),c=n?{...n}:ue(a,s),{beforeRuns:d,afterRuns:u}=he(a,s),p=To(a,[...d,Lr(l[0],c)],c),g=l.slice(1,-1).map(e=>A([{text:e,styles:c}])),f=To(A([]),[Lr(l[l.length-1],c),...u],c),m=zo(r),h=[...m.slice(0,i),p,...g,f,...m.slice(i+1)];return ro(r,h,E(na(f,l[l.length-1].length)))}function Eu(e,t){const n=zo(e),o=ya(e,n);if(o.startIndex!==o.endIndex)return;const r=n[o.startIndex];if(!r)return;let a=o.startParagraphOffset,i=o.endParagraphOffset;if(o.isCollapsed&&("backward"===t?a-=1:i+=1),a<0||i>xa(r)||i-a!==1)return;let s,l=0;for(const h of r.runs){if(l===a&&"opaque"===h.kind&&""===h.text){s=h;break}l+=h.text.length}if(!s)return;if(e.trackChangesEnabled||s.revision||"main"!==Sr(e))return e;const c=e.document.sourcePackage;if(!c)return e;const d=s.opaque.signature,u=(c.opaqueObjects??[]).filter(e=>e.signature===d);if(1!==u.length||u[0].ownerPath!==c.mainDocumentPart||u[0].issues.length)return e;const p=u[0],g=e.document.opaqueDeletionIntents??[];if(g.some(e=>e.ownerPath===p.ownerPath&&e.ordinal===p.ordinal))return e;const f=Z({...e,selection:{anchor:na(r,a),focus:na(r,i)}}),m={ownerPath:p.ownerPath,ordinal:p.ordinal,signature:p.signature};return{...f,document:{...f.document,opaqueDeletionIntents:[...g,m]}}}function Lu(e){const n=Eu(e,"backward");if(void 0!==n)return n;if(!fr(e.selection))return Z(e);const{paragraph:o,index:r,offset:a}=te(e),i=zo(e);if(a>0){if(e.trackChangesEnabled&&Ge(e)||ze(e,o,a-1,a))return e;if(z(o)){const t={...e,selection:{anchor:na(o,a-1),focus:na(o,a)}};return Z(t)}if(e.trackChangesEnabled){const n=o.runs;let s=0,l=-1,c=-1;for(let e=0;e<n.length;e+=1){const t=s+n[e].text.length;if(a<=t){l=e,c=a-s;break}s=t}if(-1!==l){const s=n[l];if("insert"===s.revision?.type){const n=[...t(o,0,a-1),...t(o,a,xa(o))],s=To(o,n),l=i.map((e,t)=>t===r?s:e);return ro(e,l,E(na(s,a-1)))}const d=s.text[c-1],u={id:`run:${Math.random().toString(36).slice(2,9)}`,text:d,kind:"text",styles:{...s.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...t(o,0,a-1),u,...t(o,a,xa(o))],g=To(o,p),f=i.map((e,t)=>t===r?g:e);return ro(e,f,E(na(g,a-1)))}}const n=To(o,[...t(o,0,a-1),...t(o,a,xa(o))],ue(o,a-1)),s=i.map((e,t)=>t===r?n:e);return ro(e,s,E(na(n,a-1)))}if(0===r)return e;const s=i[r-1];if(Ge(e)||z(s)||z(o))return e;const l=To(s,[...s.runs.map(Oo),...o.runs.map(Oo)]),c=[...i.slice(0,r-1),l,...i.slice(r+1)];return ro(e,c,E(na(l,xa(s))))}function Nu(e){const n=Eu(e,"forward");if(void 0!==n)return n;if(!fr(e.selection))return Z(e);const{paragraph:o,index:r,offset:a}=te(e),i=zo(e);if(a<xa(o)){if(e.trackChangesEnabled&&Ge(e)||ze(e,o,a,a+1))return e;if(z(o)){const t={...e,selection:{anchor:na(o,a),focus:na(o,a+1)}};return Z(t)}if(e.trackChangesEnabled){const n=o.runs;let s=0,l=-1,c=-1;for(let e=0;e<n.length;e+=1){const t=s+n[e].text.length;if(a<t){l=e,c=a-s;break}s=t}if(-1!==l){const s=n[l];if("insert"===s.revision?.type){const n=[...t(o,0,a),...t(o,a+1,xa(o))],s=To(o,n),l=i.map((e,t)=>t===r?s:e);return ro(e,l,E(na(s,a)))}const d=s.text[c],u={id:`run:${Math.random().toString(36).slice(2,9)}`,text:d,kind:"text",styles:{...s.styles},revision:{id:`rev:${Math.random().toString(36).slice(2,9)}`,type:"delete",author:"User",date:Date.now()}},p=[...t(o,0,a),u,...t(o,a+1,xa(o))],g=To(o,p),f=i.map((e,t)=>t===r?g:e);return ro(e,f,E(na(g,a)))}}const n=To(o,[...t(o,0,a),...t(o,a+1,xa(o))],ue(o,a)),s=i.map((e,t)=>t===r?n:e);return ro(e,s,E(na(n,a)))}if(r>=i.length-1)return e;const s=i[r+1];if(Ge(e)||z(s)||z(o))return e;const l=To(o,[...o.runs.map(Oo),...s.runs.map(Oo)]),c=[...i.slice(0,r),l,...i.slice(r+2)];return ro(e,c,E(na(l,a)))}function zu(e,t,n,o,r){let a=Ma(n,o,r);const i=Ra(a,t.style?.styleId,e.document.styles);return!r&&i[o]&&(a={...a,[o]:!1}),!r||"superscript"!==o&&"subscript"!==o||(a=zu(e,t,a,"superscript"===o?"subscript":"superscript",!1)),a}function $u(e,n){const o=ya(e);if(o.isCollapsed||Fn(e))return e;const r=zo(e),a=r.slice(o.startIndex,o.endIndex+1).flatMap((n,r)=>{const a=o.startIndex+r,i=a===o.startIndex?o.startParagraphOffset:0,s=a===o.endIndex?o.endParagraphOffset:xa(n);return t(n,i,s).map(t=>({...t,styles:Ra(t.styles,n.style?.styleId,e.document.styles)}))}).filter(e=>e.text.length>0);if(0===a.length)return e;const i=!a.every(e=>Boolean(e.styles?.[n])),s=r.map((t,r)=>{if(r<o.startIndex||r>o.endIndex)return t;const a=r===o.startIndex?o.startParagraphOffset:0,s=r===o.endIndex?o.endParagraphOffset:xa(t);return le(t,a,s,o=>({...o,styles:zu(e,t,o.styles,n,i)}))});return ro(e,s,C(s,o))}function Hu(e,t,n){const o=ya(e);if(o.isCollapsed||Fn(e))return e;const r=zo(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:xa(e);return le(e,a,i,e=>({...e,styles:ea(e.styles,t,n)}))});return ro(e,r,C(r,o))}function Wu(e,t){const n=ya(e);if(n.isCollapsed||Fn(e))return e;const o=zo(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:xa(e);return le(e,a,i,n=>{const o=(Ra(n.styles,e.style?.styleId,r).fontSize??14.6667)*Qa,a=Math.max(1,Math.min(1638,o+t));return{...n,styles:ea(n.styles,"fontSize",a/Qa)}})});return ro(e,a,C(a,n))}var Uu={width:.5,type:"solid",color:"#000000"};function ju(e,t){const n={...e??{}};return t?n.textBorder=Uu:delete n.textBorder,Object.keys(n).length>0?n:void 0}function Vu(e){return/\p{L}/u.test(e)}function Ku(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=Vu(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&&Vu(o)?(t+=o.toUpperCase(),n=!1):(t+=o,"."!==o&&"!"!==o&&"?"!==o||(n=!0));return t}(e)}}function _u(e,n){return function(e,n){const o=ya(e);if(o.isCollapsed)return e;const r=zo(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:xa(e),s=n(t(e,a,i).map(e=>e.text).join(""));let l=0;return le(e,a,i,e=>{const t=e.text.length,n=s.slice(l,l+t);return l+=t,{...e,text:n}})});return ro(e,r,C(r,o))}(e,e=>Ku(e,n))}var Xu=["bold","italic","underline","underlineStyle","underlineColor","strike","doubleStrike","smallCaps","allCaps","superscript","subscript","link"];function Gu(e,t){const n=Gr(e)??{};delete n.link;for(const o of Xu)void 0!==t?.[o]&&Object.assign(n,{[o]:t[o]});return Object.keys(n).length>0?n:void 0}function qu(e,t){if(0===t.length)return[];const n=ya(e),o=zo(e)[n.startIndex];if(!o)return t;const r=ue(o,n.startParagraphOffset);return t.map(e=>({runs:e.runs.map(e=>({...e,styles:Gu(r,e.styles)})),style:ma(o.style),list:o.list?{...o.list}:void 0}))}function Yu(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:[Lr("")];n.push({runs:r.map(e=>{const t=Uo(e);return{text:e.text,styles:Gr(e.styles),image:t?{...t}:void 0}}),style:e?cn(e):void 0,list:o})},a=(e,t)=>{for(const n of Array.from(e.children))"LI"===n.tagName&&r(n,lo(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,[Lr(e)]);continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;const e=i,t=ht(e.tagName);if(t){a(e,t);continue}if(wo(e.tagName)){r(e,lo(e,void 0),"LI"===e.tagName?{kind:"bullet",level:0}:void 0);continue}const n=lo(e,void 0);n.length>0&&r(null,n)}return n}async function Zu(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.stateSnapshot?.()??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(),a=n.flatMap(e=>e.types.filter(xu).map(t=>({item:e,type:t})));if(a.length){if(1!==a.length||"rich"!==e)return{kind:"unsupported"};try{const e=await a[0].item.getType(a[0].type);if(e.size>128)return{kind:"unsupported"};const t=await e.text();return t.length<=128?{kind:"chart",token:t}:{kind:"unsupported"}}catch{return{kind:"unsupported"}}}let i="",s="";for(const t of n)"text"!==e&&t.types.includes("text/html")&&(i=await(await t.getType("text/html")).text()),t.types.includes("text/plain")&&(s=await(await t.getType("text/plain")).text());if(i||s)return{kind:"content",html:i,text:s};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(l){return e.onError?.(l),e.onIssue?.("access-denied"),!1}if(e.isReadOnly())return!1;if(e.state().document!==n.document)return e.onIssue?.("document-changed"),!1;if("chart"===r.kind){if("rich"!==t||!e.stateSnapshot)return e.onIssue?.("unsupported"),!1;const o=Cu(r.token);if(!o)return e.onIssue?.("unsupported"),!1;if(e.stateSnapshot()!==n)return e.onIssue?.("document-changed"),!1;let a;try{a=await bu(n,o)}catch(l){return e.isReadOnly()||(e.onError?.(l),e.onIssue?.("unsupported")),!1}if(e.isReadOnly())return!1;if(e.stateSnapshot()!==n)return e.onIssue?.("document-changed"),!1;let i=!1;return e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.isReadOnly()||t!==n?t:(i=!0,a)),i?e.focusInput():e.isReadOnly()||e.onIssue?.("document-changed"),i}if("content"!==r.kind)return e.onIssue?.(r.kind),!1;const a="text"!==t?Yu(r.html):[],i="merge"===t?qu({...n,selection:o},a):a;if(0===i.length&&0===r.text.length)return e.onIssue?.("unsupported"),!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let s=!1;return e.applyTransactionalState(t=>{if(t.document!==n.document||e.isReadOnly())return t;const a={...t,selection:o},l=e.applyTableAwareParagraphEdit(a,e=>i.length>0?Pu(e,i):Fu(e,r.text));return s=l.document!==t.document,l}),s&&e.focusInput(),s}function Ju(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 Qu(e){const t="undefined"!=typeof navigator?navigator.clipboard:void 0;if(t?.writeText)try{return t.writeText(e).then(()=>!0,()=>Ju(e))}catch{}return Promise.resolve(Ju(e))}async function ep(e,t){if(Tu(e)){let n;try{n=Iu(e)}catch{return t?.("unsupported"),!1}const o="undefined"!=typeof navigator?navigator.clipboard:void 0;if(!o?.write||"undefined"==typeof ClipboardItem)return t?.("unsupported"),!1;try{const e=new ClipboardItem({[vu]:new Blob([n.token],{type:vu.slice(4)})});return await o.write([e]),n.confirm()}catch{return t?.("access-denied"),!1}}const n=await function(e){const t=ai(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=ku(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,()=>Qu(t))}catch{}return Qu(t)}(e);return!n&&ai(e)&&t?.("access-denied"),n}function tp(e){return function(e){const[t,n]=vn();let o,r=0;Hn()&&Tn(()=>{r++});const a=()=>{n(void 0),o=void 0},i=()=>{r++,a()},s=async(t,i="rich")=>{const s=++r;a();const l=e.stateSnapshot?.()??e.state(),c=a=>{s===r&&(n({action:t,issue:a,..."paste"===t?{mode:i}:{}}),"access-denied"!==a&&"unsupported"!==a||("paste"!==t||"unsupported"===a&&"rich"!==i||(o={document:l.document,mode:i}),e.focusInput()),e.onIssue?.(a))};if("copy"===t)return ep(l,c);const d={...e,onIssue:c,isReadOnly:()=>s!==r||e.isReadOnly()};return"cut"===t?async function(e){if(e.isReadOnly())return!1;const t=e.stateSnapshot?.()??e.state();if(Tu(t))return e.onIssue?.("unsupported"),!1;if(!ai(t))return!1;if(!(await ep(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=>Lu(e));return o=i.document!==r.document,i}),o&&e.focusInput(),o}(d):Zu(d,i)},l=()=>{const t=o;return i(),t?.document===e.state().document?t.mode:void 0},c=(t,o)=>{r++,a(),n({action:t,issue:o,..."paste"===t?{mode:"rich"}:{}}),e.onIssue?.(o)};return{notice:t,dismiss:i,reportNativeIssue:c,requestGeneration:()=>r,consumePasteMode:l,copy:()=>s("copy"),cut:()=>s("cut"),paste:(e="rich")=>s("paste",e),hasSelection:()=>ai(e.state()).length>0}}(e)}var np=/*#__PURE__*/En("<div class=oasis-editor-clipboard-feedback role=status aria-live=polite aria-atomic=true>"),op=/*#__PURE__*/En("<div class=oasis-editor-clipboard-feedback-message data-testid=editor-clipboard-feedback>");function rp(e){const t=T();let o;const[r,a]=vn(12);n(()=>{if(!e.notice())return;const t=o?.parentElement;if(!t)return;const n=()=>{const e=t.getBoundingClientRect(),n=t.querySelector(".oasis-editor-toolbar"),r=n?n.getBoundingClientRect().bottom-e.top+8:12,i=Math.max(12,12-e.top),s=window.innerHeight-e.top-(o?.offsetHeight??0)-12;a(Math.max(i,Math.min(r,s)))};queueMicrotask(n);const r=new ResizeObserver(n);r.observe(t),o&&r.observe(o);const i=t.querySelector(".oasis-editor-toolbar");i&&r.observe(i),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0),Tn(()=>{r.disconnect(),window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0)})});return i=np(),"function"==typeof o?$(o,i):o=i,u(i,pe(Ve,{get when(){return e.notice()},children:n=>{return o=op(),u(o,pe(Ze,{name:"clipboard"}),null),u(o,pe(_,{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),u(o,pe(re,{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}})),Jn(e=>$e(i,"top",`${r()}px`)),i;var i}var ap=/[\s\-–—/_([{]/;function ip(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||ap.test(e[t-1]??"")}(o,r)?e+=100:e+=200,e+=Math.round(n.length/o.length*50),e}let a=0,i=-1,s=-1,l=0;for(const d of n){const e=o.indexOf(d,a);if(-1===e)return null;-1===i&&(i=e),l+=e-a,a=e+1,s=e}const c=s-i+1;return Math.max(1,120-l-4*Math.abs(c-n.length))}function sp(e,t){const n=e.trim().toLowerCase();if(0===n.length)return 0;const o=ip(n,t.label),r=ip(n,t.command),a=Math.max(o??Number.NEGATIVE_INFINITY,(r??Number.NEGATIVE_INFINITY)-50);return Number.isFinite(a)?a:null}var lp=/*#__PURE__*/En("<ul id=editor-command-search-listbox class=oasis-command-search-list role=listbox data-testid=editor-command-search-listbox>"),cp=/*#__PURE__*/En("<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>"),dp=/*#__PURE__*/En("<kbd class=oasis-command-search-shortcut>"),up=/*#__PURE__*/En("<li role=option class=oasis-command-search-option data-testid=editor-command-search-item>");function pp(e){const t=T(),[o,r]=vn(""),[a,i]=vn(0);let s;n(()=>{e.isOpen&&(r(""),i(0),queueMicrotask(()=>{s?.focus()}))});const l=Mt(()=>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=sp(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)}(o(),e.entries,12));n(()=>{l(),i(e=>Math.min(e,Math.max(0,l().length-1)))});const c=t=>e.isEnabled(t.command,t.payload),d=t=>{c(t)&&e.onExecute(t)},p=e=>{const t=l().length;0!==t&&i(n=>(n+e+t)%t)},g=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),p(1);break;case"ArrowUp":t.preventDefault(),p(-1);break;case"Enter":{t.preventDefault();const e=l()[a()];e&&d(e);break}case"Escape":t.preventDefault(),e.onClose()}};return pe(Ve,{get when(){return e.isOpen},get children(){var n=cp(),p=n.firstChild;return q(n,"click",e.onClose,!0),p.$$keydown=g,p.$$click=e=>e.stopPropagation(),u(p,pe(vo,{id:"editor-command-search-input",get placeholder(){return t("commandSearch.placeholder")},get value(){return o()},onChange:e=>{r(e)},ref(e){"function"==typeof s?s(e):s=e},role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":"editor-command-search-listbox",get"aria-activedescendant"(){return Fe(()=>!!l()[a()])()?`editor-command-search-option-${a()}`:void 0},"data-testid":"editor-command-search-input",autocomplete:"off",spellcheck:!1}),null),u(p,pe(_,{class:"oasis-command-search-hint",get children(){return t("commandSearch.hint")}}),null),u(p,pe(Ve,{get when(){return l().length>0},get fallback(){return pe(_,{as:"p",class:"oasis-command-search-empty","data-testid":"editor-command-search-empty",get children(){return t("commandSearch.noResults")}})},get children(){var e=lp();return u(e,pe(qe,{get each(){return l()},children:(e,t)=>{const n=()=>t()===a(),o=()=>c(e);return(r=up()).$$click=()=>d(e),r.addEventListener("mouseenter",()=>{i(t())}),u(r,pe(_,{as:"span",get children(){return e.label}}),null),u(r,pe(Ve,{get when(){return e.shortcut},get children(){var t=dp();return u(t,()=>e.shortcut),t}}),null),Jn(a=>{var i=`editor-command-search-option-${t()}`,s=n(),l=!o()||void 0,c=!!n(),d=!o(),u=e.command;return i!==a.e&&Me(r,"id",a.e=i),s!==a.t&&Me(r,"aria-selected",a.t=s),l!==a.a&&Me(r,"aria-disabled",a.a=l),c!==a.o&&r.classList.toggle("oasis-command-search-option-active",a.o=c),d!==a.i&&r.classList.toggle("oasis-command-search-option-disabled",a.i=d),u!==a.n&&Me(r,"data-command",a.n=u),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r;var r}})),e}}),null),u(p,pe(Nn,{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),Jn(()=>Me(p,"aria-label",t("commandSearch.title"))),n}})}function gp(e){return e?"string"==typeof e?{command:e}:"object"==typeof e&&"string"==typeof e.name?{command:e.name,payload:e.payload}:null:null}function fp(e){return gp(e.command)}ko(["click","keydown"]);var mp=!1,hp=null,bp=null,yp=null,vp=[];function xp(){"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}()?mp&&(delete window.__oasisCanvasDebug,mp=!1):mp||(window.__oasisCanvasDebug={getLastHit:()=>hp?{...hp}:null,getLayoutSnapshot:()=>bp?{...bp,surfaceRect:{...bp.surfaceRect},pages:bp.pages.map(e=>({...e})),paragraphs:bp.paragraphs.map(e=>({...e,lines:e.lines.map(e=>({...e,slots:e.slots.map(e=>({...e}))})),tableCell:e.tableCell?{...e.tableCell}:void 0})),inlineImages:bp.inlineImages.map(e=>({...e})),inlineTextBoxes:bp.inlineTextBoxes.map(e=>({...e})),unsupportedRegions:bp.unsupportedRegions.map(e=>({...e}))}:null,getSelection:()=>yp?{anchor:{...yp.anchor},focus:{...yp.focus},activeZone:yp.activeZone,activeSectionIndex:yp.activeSectionIndex}:null,getMissEvents:()=>vp.map(e=>({...e})),clearMissEvents:()=>{vp=[]}},mp=!0))}function wp(e){mp&&e&&(hp={timestamp:Date.now(),zone:e.zone,paragraphId:e.paragraphId,paragraphOffset:e.paragraphOffset,source:e.source,missReason:e.missReason,resolvedFromParagraph:e.resolvedFromParagraph})}var Sp=["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 Ip(e,t,n){const o=n?.trim();if(!o)return;const r=o.toLowerCase();t.has(r)||(t.add(r),e.push(o))}function Cp(e){return function(e){const[t,n]=vn([]),o=()=>function(e,t,n=[]){const o=/* @__PURE__ */new Set,r=[],a=[];for(const i of Object.values(e?.styles??{}))Ip(r,o,i.textStyle?.fontFamily);Ip(r,o,t.fontFamily);for(const i of n)Ip(a,o,i);for(const i of Sp)Ip(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(yn);for(const r of Object.values(e?.styles??{})){const e=r.textStyle?.fontSize;"number"==typeof e&&Number.isFinite(e)&&n.add(Gt(e))}const o=Gt(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 So();e.length>0&&n(e)}}}(e)}var Tp="insertText",kp="composition",Pp="insertImage",Rp="insertTable",Mp="moveImage",Op="splitListItem",Ap="link",Bp="imageAlt",Dp="imageCaption",Fp="imageResize",Ep="imageCrop",Lp="imageFlip",Np="imageRotate",zp="imageTransparency",$p="imageReset",Hp="layoutWrapPolygon",Wp="specialIndent",Up="paraBorders",jp="paragraphMoveUp",Vp="paragraphMoveDown",Kp="findReplace",_p="findReplaceAll",Xp="tableProperties",Gp="paragraph-dialog",qp="font-dialog",Yp="copyTextByDrag",Zp="moveTextByDrag",Jp="mergeTable",Qp="splitTable",eg="insertTableColumn",tg="deleteTableColumn",ng="insertTableRow",og="deleteTableRow",rg="tableShading",ag="tableBorders",ig="tableWidth",sg="tableAlign",lg="tableCellAlignment",cg="tableCellVerticalAlign",dg="tableCellTextDirection",ug="tableCellWidth",pg="tableColumnWidth",gg="tableToText",fg="textToTable",mg="tableSplitAtRow",hg="tableSortAscending",bg="tableSortDescending",yg="tableDelete",vg="deleteTableCell",xg="tableAutoFit",wg="tableRepeatHeaderRows",Sg="tableCellMargins",Ig="tableFormula",Cg="tableRowHeight",Tg="tableStyleOptions",kg="tableStyleGallery",Pg="tableDistribute",Rg="layoutWrapPreset",Mg="layoutFixedPosition",Og="shapeFill",Ag="shapeOutline",Bg="shapeOutlineWidth",Dg="floatingAlign",Fg="floatingReorder",Eg="floatingNudge",Lg="floatingFixedPosition",Ng="floatingRotation",zg="floatingWrap",$g="floatingWrapText",Hg="floatingPositionPreset",Wg="shapePreset",Ug="textBoxTextDirection",jg="textBoxVerticalAlign",Vg="textBoxAlt",Kg="textBoxRotate",_g="textBoxWidthCm",Xg="textBoxHeightCm";function Gg(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 qg(){return{id:`rev:${Math.random().toString(36).slice(2,9)}`,author:"User",date:Date.now()}}function Yg(e,t,n){const o={...e??{}};return null===n?delete o[t]:o[t]=n,Object.keys(o).length>0?o:void 0}function Zg(e,t){const n=za(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 Jg(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:Jg(e.blocks,t)}))}))}})}function Qg(e,t,n){const o=za(e)[t];if(o)return"header"===n?o.header:"footer"===n?o.footer:o.blocks}function ef(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function tf(e){const t=lr(e),n=$r(e.document,e.selection.focus.paragraphId,t);return n?{activeSectionIndex:t,loc:ef(n)}:null}function nf(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 s=nf(i.blocks,t.slice(1),n);if(s===i.blocks)return e;const l=[...a.cells];l[o.cellIndex]={...i,blocks:s};const c=[...r.rows];c[o.rowIndex]={...a,cells:l};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function of(e,t){return Boolean(e?.some(e=>oa(e).some(e=>e.id===t)))}function rf(e,t,n){if("main"===t)return e.blocks;if("header"===t||"footer"===t){const o=function(e,t,n){return"header"===t?of(e.firstPageHeader,n)?"firstPage":of(e.evenPageHeader,n)?"evenPage":"default":of(e.firstPageFooter,n)?"firstPage":of(e.evenPageFooter,n)?"evenPage":"default"}(e,t,n);return e[Qo(t,o)]??null}return null}function af(e,t,n,o){return"main"===t?{...e,blocks:o(e.blocks)}:"header"===t?of(e.firstPageHeader,n)?{...e,firstPageHeader:o(e.firstPageHeader)}:of(e.evenPageHeader,n)?{...e,evenPageHeader:o(e.evenPageHeader)}:{...e,header:e.header?o(e.header):e.header}:"footer"===t?of(e.firstPageFooter,n)?{...e,firstPageFooter:o(e.firstPageFooter)}:of(e.evenPageFooter,n)?{...e,evenPageFooter:o(e.evenPageFooter)}:{...e,footer:e.footer?o(e.footer):e.footer}:e}function sf(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?sf(a.blocks,t.slice(1)):null}function lf(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 s=lf(i.blocks,t.slice(1),n);if(!s)return null;const l=[...a.cells];l[o.cellIndex]={...i,blocks:s};const c=[...r.rows];c[o.rowIndex]={...a,cells:l};const d=[...e];return d[o.tableBlockIndex]={...r,rows:c},d}function cf(e){const t=tf(e);if(!t)return null;const{activeSectionIndex:n,loc:o}=t,r=e.selection.focus.paragraphId;if("footnote"===o.zone)return uf(e,r);const a=za(e.document)[n];return a?rf(a,o.zone,r):null}function df(e){const t=e.selection.focus.paragraphId,n=Sr(e);if("footnote"===n)return uf(e,t);const o=lr(e),r=za(e.document)[o];return r?rf(r,n,t):null}function uf(e,t){const n=Fa(e.document,t)?.footnoteId??e.activeFootnoteId,o=e.document.footnotes;return(n?o?.items[n]:void 0)?.blocks??null}function pf(e,t){const n=tf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>lf(e,r.tablePath,t)??e;if("footnote"===r.zone){const t=Fa(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 s=za(e.document).map((e,t)=>t===o?af(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}function gf(e,t){const n=tf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=e.selection.focus.paragraphId,i=e=>nf(e,r.tablePath,t);if("footnote"===r.zone){const t=Fa(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 s=za(e.document).map((e,t)=>t===o?af(e,r.zone,a,i):e);return{...e,document:{...e.document,sections:s}}}var ff={width:.5,type:"solid",color:"#000000"},mf={width:0,type:"none",color:"transparent"};function hf(e){const t=lr(e),n=$r(e.document,e.selection.anchor.paragraphId,t),o=$r(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=Qg(e.document,t,n.zone);if(!r)return null;const a=Bo(r,n.tablePath),i=Bo(r,o.tablePath),s=a?.[a.length-1],l=i?.[i.length-1];if(!s||!l||s.table!==l.table)return null;const c=n.tablePath[n.tablePath.length-1],d=o.tablePath[o.tablePath.length-1];if(!c||!d)return null;const u=Kr(s.table),p=u.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex),g=u.find(e=>e.rowIndex===d.rowIndex&&e.cellIndex===d.cellIndex);if(!p||!g)return null;const f=Math.min(p.visualRowIndex,g.visualRowIndex),m=Math.max(p.visualRowIndex+p.rowSpan-1,g.visualRowIndex+g.rowSpan-1),h=Math.min(p.visualColumnIndex,g.visualColumnIndex),b=Math.max(p.visualColumnIndex+p.colSpan-1,g.visualColumnIndex+g.colSpan-1);return{entries:u,selectedEntries:u.filter(e=>e.visualRowIndex<=m&&e.visualRowIndex+e.rowSpan-1>=f&&e.visualColumnIndex<=b&&e.visualColumnIndex+e.colSpan-1>=h),startRow:f,endRow:m,startCol:h,endCol:b}}function bf(e,t,n){const o=function(e){const t=/* @__PURE__ */new Set,n=hf(e);if(!n)return t;for(const o of n.selectedEntries)for(const e of o.cell.blocks)for(const n of oa(e))t.add(n.id);return t}(e);if(0===o.size)for(const i of function(e){const t=/* @__PURE__ */new Set,n=ya(e),o=zo(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:{...qg(),type:"property",previous:{...r??{}}}}),{...o,style:Yg(r,t,n)}},a=za(e.document).map(e=>({...e,blocks:Et(e.blocks,o,r),header:e.header?Et(e.header,o,r):void 0,footer:e.footer?Et(e.footer,o,r):void 0}));return{...e,document:{...e.document,sections:a}}}function yf(e,t){let n=bf(e,"borderTop",t);return n=bf(n,"borderRight",t),n=bf(n,"borderBottom",t),n=bf(n,"borderLeft",t),n}function vf(e,t,n){const o=function(e){const t=ya(e),n=zo(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)}))})),s={...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:{...qg(),type:"property",previous:{...r??{}}}}),{...o,style:Yg(r,t,n)}})(s):s});return Zg(e,r)}function xf(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:{...qg(),type:"property",previous:{...a??{}}}}),{...r,style:Yg(a,n,o)}};return Zg(e,e=>Jg(e,r))}function wf(e,t,n){const o=tf(e);if(!o)return e;return gf(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:{...qg(),type:"property",previous:{...o??{}}}}),{...r,style:Yg(o,t,n)}})():r);return{...r,rows:a}})}function Sf(e,t){const n=tf(e);if(!n)return e;return gf(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:{...qg(),type:"property",previous:{...a??{},isHeader:o.isHeader}}});const i=null===t?void 0:t;return{...o,isHeader:i,style:Yg(a,"isHeader",i??null)}})}))}function If(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:{...qg(),type:"property",previous:{...r??{}}}}),{...t,style:Yg(r,"height",n[o])}});return{...o,rows:r}};return Zg(e,e=>Jg(e,o))}function Cf(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*Qa:null}if(!/^[+-]?\d+(\.\d+)?$/.test(t))return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function Tf(e,t,n,o,r){const a=a=>{if(a.id!==t)return a;const i=Kr(a),s=new Map(i.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e])),l=Math.max(1,...i.map(e=>e.visualColumnIndex+Math.max(1,e.colSpan))),c=Array(l);let d=!1,u=!0;for(let e=0;e<l;e+=1){const t=Cf(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=s.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?{...qg(),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={...qg(),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?{...qg(),type:"grid",previous:[...a.gridCols??[]]}:a.gridRevision,style:Object.keys(g).length>0?g:void 0}};return Zg(e,e=>Jg(e,a))}function kf(e){const t=tf(e);if(!t)return e;const n=cf(e);if(!n)return e;const o=sf(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(Er(n));return t}(o);if(0===r.length)return e;const a=pf(e,r);if(a===e)return e;const i=r[0];return{...a,selection:E(na(i,0))}}function Pf(e){if(tf(e))return e;if(!df(e))return e;const t=zo(e);if(0===t.length)return e;const n=ya(e,t),o=t.slice(n.startIndex,n.endIndex+1);if(0===o.length)return e;const r=function(e){const t=e.map(Rf),n=Math.max(1,...t.map(e=>e.length)),o=t.map(e=>Ao(Array.from({length:n},(t,n)=>{const o=e[n]??[],r={id:ar("paragraph"),type:"paragraph",runs:o.length>0?o:[zr("")]};return vr([r])})));return Wr(o)}(o),a=o[0].id,i=o[o.length-1].id;let s=null,l=!1;const c=function(e,t){const n=e.selection.focus.paragraphId,o=Sr(e),r=lr(e);if("footnote"===o){const o=Fa(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=za(e.document).map((e,a)=>a===r?af(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 s=0;s<e.length;s+=1){const o=e[s];"paragraph"===o.type&&(o.id===t&&(r=s),o.id===n&&(a=s))}if(-1===r||-1===a||r>a)return{nextBlocks:null,cell:null};for(let s=r;s<=a;s+=1)if("paragraph"!==e[s].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?(s=n,l=!0,t):e});return l&&s?{...c,selection:E(na(s,0))}:e}function Rf(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=Oo(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 Mf(e,t){const n=tf(e);if(!n)return e;const o=n.loc.cellIndex;return gf(e,e=>{const n=function(e,t,n){const o=[],r=[];for(const l of e.rows)l.isHeader?o.push(l):r.push(l);if(r.length<2)return e.rows;const a="ascending"===n?1:-1,i=[...r].sort((e,n)=>{const o=Of(e.cells[t]),r=Of(n.cells[t]);return o.localeCompare(r,void 0,{numeric:!0})*a}),s=[...o,...i];return s.length===e.rows.length&&s.every((t,n)=>t===e.rows[n])?e.rows:s}(e,o,t);return n===e.rows?e:{...e,rows:n}})}function Of(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:oa(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Af(e){return!0===e.isHeader}function Bf(e){return null!==tf(e)}function Df(e){return null!==tf(e)}var Ff=/* @__PURE__ */new Set(["left","center","right"]);function Ef(e,t){const n=tf(e);if(!n)return e;if(null!==t&&!Ff.has(t))return e;const o=function(e,t){const n=tf(e);if(!n)return null;const o=Bo(t,n.loc.tablePath);return(o?.[o.length-1])?.table??null}(e,Qg(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:vf(e,"align",a)}function Lf(e){return null!==tf(e)}var Nf=["SUM","AVERAGE","COUNT","MIN","MAX"];function zf(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 Nf.includes(n)&&["ABOVE","BELOW","LEFT","RIGHT"].includes(o)?{function:n,direction:o}:null}(t);if(!n)return e;const o=tf(e);if(!o)return e;const r=cf(e);if(!r)return e;const a=sf(r,o.loc.tablePath);if(!a)return e;const i=function(e,t,n){const o=Kr(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(!Hf(r,i,t))continue;if(!Wf(r,i,t))continue;const e=Uf($f(i.cell));null!==e&&a.push(e)}return a}(a,n.direction,o.loc);if(0===i.length)return e;const s=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)),l=o.loc.rowIndex,c=o.loc.cellIndex,d=gf(e,e=>({...e,rows:e.rows.map((e,t)=>t!==l?e:{...e,cells:e.cells.map((e,t)=>t!==c?e:{...e,blocks:[Da(s)]})})}));if(d===e)return e;const u=Da(s);return{...d,selection:E(na(u,s.length))}}function $f(e){return e?e.blocks.flatMap(e=>"paragraph"===e.type?[e]:oa(e)).map(e=>e.runs.map(e=>e.text).join("")).join("\n"):""}function Hf(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 Wf(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 Uf(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 jf(e,t){const n=function(e){const t=tf(e);if(!t)return null;const n=cf(e);if(!n)return null;const o=sf(n,t.loc.tablePath);if(!o)return null;const r=Kr(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 s=function(e){return[...e].sort((e,t)=>e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex-t.visualColumnIndex)}(i),l=s[0].cell,c=s[s.length-1].cell,d=Vf(l),u=Vf(c),p=d[0],g=u[u.length-1];return p&&g?{...e,selection:{anchor:na(p,0),focus:na(g,Ua(g).length)}}:e}function Vf(e){return e.blocks.flatMap(oa)}function Kf(e){const t=function(e){const t=tf(e);if(!t)return null;const n=cf(e);if(!n)return null;const o=sf(n,t.loc.tablePath);return o?o.rows[t.loc.rowIndex]??null:null}(e);return Boolean(t&&t.cells.length>1)}function _f(e){const t=tf(e);if(!t)return e;const n=cf(e);if(!n)return e;const o=sf(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 s=gf(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(s===e)return e;const l=i.cells[Math.min(a,i.cells.length-2)],c=l?l.blocks.flatMap(oa)[0]??null:null;return c?{...s,selection:E(na(c,0))}:s}var Xf={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 Gf(e){const t=lr(e),n=$r(e.document,e.selection.focus.paragraphId,t),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Bo(function(e,t){const n=za(e.document)[lr(e)];return n?"header"===t?n.header??[]:"footer"===t?n.footer??[]:n.blocks:[]}(e,n.zone),n.tablePath),a=r?.[r.length-1]?.table;if(!a)return null;const i=Kr(a).find(e=>e.rowIndex===o.rowIndex&&e.cellIndex===o.cellIndex);return{table:a,tableId:a.id,rowIndex:o.rowIndex,cellIndex:o.cellIndex,visualColumnIndex:i?.visualColumnIndex??o.cellIndex}}function qf(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 Yf(e){return!!e&&"none"!==e.type&&e.width>0}function Zf(e,t="table"){const n=qf(e.table.style?.width),o=e.table.rows[e.rowIndex],r=o?.cells[e.cellIndex],a=qf(o?.style?.height),i=qf(r?.style?.width),s=e.table.gridCols?.[e.visualColumnIndex],l=qf(s),c=r?.style??{},d=[c.borderTop,c.borderRight,c.borderBottom,c.borderLeft,c.borderStart,c.borderEnd,c.borderTopLeftToBottomRight,c.borderTopRightToBottomLeft].filter(Yf)[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{...Xf,activeTab:t,tableWidth:n.value,tableWidthUnit:n.unit,tableAlign:e.table.style?.align??"",tableIndentLeft:qf(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:l.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:Yf(c.borderTop),borderRight:Yf(c.borderRight),borderBottom:Yf(c.borderBottom),borderLeft:Yf(c.borderLeft),borderStart:Yf(c.borderStart),borderEnd:Yf(c.borderEnd),borderTopLeftToBottomRight:Yf(c.borderTopLeftToBottomRight),borderTopRightToBottomLeft:Yf(c.borderTopRightToBottomLeft),shading:c.shading??"",altTitle:e.table.style?.altTitle??"",altDescription:e.table.style?.altDescription??""}}function Jf(e,t,n){return bf(e,t,n)}function Qf(e){return Boolean(Gf(e))}function em(e,t="table"){const n=Gf(e);return n?Zf(n,t):null}function tm(e){const t=()=>Qf(e.state());return{isInsideTable:t,openTablePropertiesDialog:(t="table")=>{const n=em(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=Gf(e);if(!n)return e;let o=e;return o=xf(o,n.tableId,"width",t.tableWidth),o=xf(o,n.tableId,"align",t.tableAlign),o=xf(o,n.tableId,"indentLeft",t.tableIndentLeft),o=xf(o,n.tableId,"floating",t.tableFloating),o=xf(o,n.tableId,"tblOverlap",t.tableOverlap),o=xf(o,n.tableId,"altTitle",t.altTitle),o=xf(o,n.tableId,"altDescription",t.altDescription),o=Sf(o,t.repeatHeader),o=wf(o,"height",t.rowHeight),o=wf(o,"heightRule",t.rowHeightRule),o=wf(o,"cantSplit",t.cantSplit),o=wf(o,"hidden",t.hiddenRow),null!==t.columnWidth&&(o=Tf(o,n.tableId,{[n.visualColumnIndex]:t.columnWidth})),o=Jf(o,"width",t.cellWidth),o=Jf(o,"verticalAlign",t.cellVerticalAlign),o=Jf(o,"textDirection",t.cellTextDirection),o=Jf(o,"noWrap",t.cellNoWrap),o=Jf(o,"fitText",t.cellFitText),o=Jf(o,"hideMark",t.cellHideMark),o=Jf(o,"paddingTop",t.margins.top),o=Jf(o,"paddingRight",t.margins.right),o=Jf(o,"paddingBottom",t.margins.bottom),o=Jf(o,"paddingLeft",t.margins.left),o=Jf(o,"borderTop",t.borders.top),o=Jf(o,"borderRight",t.borders.right),o=Jf(o,"borderBottom",t.borders.bottom),o=Jf(o,"borderLeft",t.borders.left),o=Jf(o,"borderStart",t.borders.start),o=Jf(o,"borderEnd",t.borders.end),o=Jf(o,"borderTopLeftToBottomRight",t.borders.topLeftToBottomRight),o=Jf(o,"borderTopRightToBottomLeft",t.borders.topRightToBottomLeft),o=Jf(o,"shading",t.shading),o}(e,n),{mergeKey:Xp}),e.focusInput())}}}function nm(e){return function(e){const t=e.t,n=e.clipboardActions??tp({...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=!fr(e.state().selection),i=e.isReadOnly(),s=[{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}],l=e.table;return l?.isInsideTable()&&s.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:l.openProperties},{id:"table-insert-row-above",label:t("table.insertRowAbove"),icon:"rows-3",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-insert-row-above",onSelect:l.insertRowBefore},{id:"table-insert-row-below",label:t("table.insertRowBelow"),icon:"rows-3",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-insert-row-below",onSelect:l.insertRowAfter},{id:"table-insert-column-left",label:t("table.insertColumnLeft"),icon:"columns-3",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-insert-column-left",onSelect:l.insertColumnBefore},{id:"table-insert-column-right",label:t("table.insertColumnRight"),icon:"columns-3",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-insert-column-right",onSelect:l.insertColumnAfter},{id:"table-delete-row",label:t("table.deleteRow"),icon:"trash-2",disabled:i||!l.canEditRow(),testId:"editor-context-menu-table-delete-row",onSelect:l.deleteRow},{id:"table-delete-column",label:t("table.deleteColumn"),icon:"trash-2",disabled:i||!l.canEditColumn(),testId:"editor-context-menu-table-delete-column",onSelect:l.deleteColumn},{id:"table-merge",label:t("table.mergeTooltip"),icon:"combine",disabled:i||!l.canMerge(),testId:"editor-context-menu-table-merge",onSelect:l.merge},{id:"table-split",label:t("table.splitTooltip"),icon:"split",disabled:i||!l.canSplit(),testId:"editor-context-menu-table-split",onSelect:l.split},{id:"table-borders-shading",label:t("contextmenu.bordersAndShading"),icon:"frame",disabled:i,testId:"editor-context-menu-table-borders-shading",onSelect:l.openBordersAndShading}),s},s=t=>{t.preventDefault(),e.setContextMenu({isOpen:!0,x:t.clientX,y:t.clientY})},l=()=>{e.setContextMenu({isOpen:!1,x:0,y:0})};return{buildContextMenuItems:i,closeContextMenu:l,handleEditorContextMenu:s,programmaticCopy:o,programmaticCut:r,programmaticPaste:a}}(e)}function om(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),Jp),split:()=>o(e=>n.splitSelectedTable(e),Qp),insertColumnBefore:()=>o(e=>n.insertSelectedTableColumn(e,-1),eg),insertColumnAfter:()=>o(e=>n.insertSelectedTableColumn(e,1),eg),deleteColumn:()=>o(e=>n.deleteSelectedTableColumn(e),tg),insertRowBefore:()=>o(e=>n.insertSelectedTableRow(e,-1),ng),insertRowAfter:()=>o(e=>n.insertSelectedTableRow(e,1),ng),deleteRow:()=>o(e=>n.deleteSelectedTableRow(e),og)}}function rm(e){return function(e){const{computeFontFamilyOptions:t,computeFontSizeOptions:n,loadLocalFontFamilyOptions:o}=Cp({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:ct(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()||(fr(e.selection())||(e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(e=>{let o=e;t.fontFamily!==(n.fontFamily||null)&&(o=Hu(o,"fontFamily",t.fontFamily)),t.fontSize!==(n.fontSize?Number(n.fontSize):null)&&(o=Hu(o,"fontSize",Kn(t.fontSize)));const r="automatic"===n.colorMode?null:n.color||null;t.color!==r&&(o=Hu(o,"color",t.color)),(t.highlight??"")!==(n.highlight??"")&&(o=Hu(o,"highlight",t.highlight)),(t.shading??"")!==(n.shading??"")&&(o=Hu(o,"shading",t.shading)),t.bold!==Boolean(n.bold)&&(o=$u(o,"bold")),t.italic!==Boolean(n.italic)&&(o=$u(o,"italic"));const a=n.underline?n.underlineStyle??"single":null;(t.underlineStyle??null)!==(a??null)&&(o=Hu(o,"underlineStyle",t.underlineStyle));const i=n.underline&&n.underlineColor||null;(t.underlineColor??null)!==(i??null)&&(o=Hu(o,"underlineColor",t.underlineColor)),t.underline!==Boolean(n.underline)&&(o=$u(o,"underline")),t.strike!==Boolean(n.strike)&&(o=$u(o,"strike")),t.doubleStrike!==Boolean(n.doubleStrike)&&(o=$u(o,"doubleStrike")),t.superscript!==Boolean(n.superscript)&&(o=$u(o,"superscript")),t.subscript!==Boolean(n.subscript)&&(o=$u(o,"subscript")),t.superscript&&t.subscript&&(o=$u(o,"subscript")),t.strike&&t.doubleStrike&&(o=$u(o,"doubleStrike")),t.smallCaps!==Boolean(n.smallCaps)&&(o=$u(o,"smallCaps")),t.allCaps!==Boolean(n.allCaps)&&(o=$u(o,"allCaps")),t.hidden!==Boolean(n.hidden)&&(o=$u(o,"hidden"));const s=n.characterScale?Number(n.characterScale):null;(t.characterScale??null)!==(s??null)&&(o=Hu(o,"characterScale",t.characterScale));const l=n.characterSpacing?Number(n.characterSpacing):null;(t.characterSpacing??null)!==(l??null)&&(o=Hu(o,"characterSpacing",t.characterSpacing));const c=n.baselineShift?Number(n.baselineShift):null;(t.baselineShift??null)!==(c??null)&&(o=Hu(o,"baselineShift",t.baselineShift));const d=n.kerningThreshold?Number(n.kerningThreshold):null;(t.kerningThreshold??null)!==(d??null)&&(o=Hu(o,"kerningThreshold",t.kerningThreshold)),(t.ligatures??null)!==(n.ligatures||null)&&(o=Hu(o,"ligatures",t.ligatures)),(t.numberSpacing??null)!==(n.numberSpacing||null)&&(o=Hu(o,"numberSpacing",t.numberSpacing)),(t.numberForm??null)!==(n.numberForm||null)&&(o=Hu(o,"numberForm",t.numberForm));const u=n.stylisticSet?Number(n.stylisticSet):null;return(t.stylisticSet??null)!==(u??null)&&(o=Hu(o,"stylisticSet",t.stylisticSet)),t.contextualAlternates!==Boolean(n.contextualAlternates)&&(o=$u(o,"contextualAlternates")),o},{mergeKey:qp})),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;if(e.clearPreferredColumn(),e.resetTransactionGrouping(),n.tabsOnly)return e.applyTransactionalState(e=>(t.tabChanges??[]).reduce(dn,e)),void e.focusInput();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=ae(r,"align",t.align)),t.indentLeft!==o(n.indentLeft)&&(r=ae(r,"indentLeft",t.indentLeft)),t.indentRight!==o(n.indentRight)&&(r=ae(r,"indentRight",t.indentRight)),t.indentFirstLine!==o(n.indentFirstLine)&&(r=ae(r,"indentFirstLine",t.indentFirstLine)),t.indentHanging!==o(n.indentHanging)&&(r=ae(r,"indentHanging",t.indentHanging)),t.spacingBefore!==o(n.spacingBefore)&&(r=ae(r,"spacingBefore",t.spacingBefore)),t.spacingAfter!==o(n.spacingAfter)&&(r=ae(r,"spacingAfter",t.spacingAfter)),t.lineHeight!==o(n.lineHeight)&&(r=ae(r,"lineHeight",t.lineHeight));const a=n.lineRule||null;t.lineRule!==a&&(r=ae(r,"lineRule",t.lineRule)),t.shading!==(n.shading||null)&&(r=ae(r,"shading",t.shading)),t.mirrorIndents!==(n.mirrorIndents??!1)&&(r=ae(r,"mirrorIndents",t.mirrorIndents)),t.contextualSpacing!==(n.contextualSpacing??!1)&&(r=ae(r,"contextualSpacing",t.contextualSpacing));const i=""===n.outlineLevel.trim()?null:Number(n.outlineLevel);t.outlineLevel!==i&&(r=ae(r,"outlineLevel",t.outlineLevel)),t.pageBreakBefore!==(n.pageBreakBefore??!1)&&(r=ae(r,"pageBreakBefore",t.pageBreakBefore)),t.keepWithNext!==(n.keepWithNext??!1)&&(r=ae(r,"keepWithNext",t.keepWithNext)),t.keepLinesTogether!==(n.keepLinesTogether??!1)&&(r=ae(r,"keepLinesTogether",t.keepLinesTogether)),t.widowControl!==(n.widowControl??!0)&&(r=ae(r,"widowControl",t.widowControl)),t.tabChanges?.length?r=t.tabChanges.reduce(dn,r):JSON.stringify(t.tabs)!==JSON.stringify(n.tabs??[])&&(r=ae(r,"tabs",t.tabs.length>0?t.tabs:null));const s="solid"===n.borderStyle||"dashed"===n.borderStyle||"dotted"===n.borderStyle?{type:n.borderStyle,width:Number(n.borderWidth)||0,color:n.borderColor||"#000000"}:null,l={borderTop:n.borderSideTop?s:null,borderRight:n.borderSideRight?s:null,borderBottom:n.borderSideBottom?s:null,borderLeft:n.borderSideLeft?s: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(l[t])&&(r=ae(r,t,c[t]));return r},{mergeKey:Gp}),e.focusInput()},setParagraphDialogDefault:t=>{e.isReadOnly()||(e.resetTransactionGrouping(),e.applyTransactionalState(e=>{const n=e.document.styles,o=fa(n);if(!o||!n?.[o])return e;const r=n[o];return{...e,document:{...e.document,styles:{...n,[o]:{...r,paragraphStyle:Gg(r.paragraphStyle??{},t)}}}}}),e.focusInput())}}}({toolbarStyleState:e.toolbarStyleState,isReadOnly:e.isReadOnly,setParagraphDialog:e.setParagraphDialog,setContextMenu:e.setContextMenu,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,applyTransactionalState:e.applyTransactionalState,focusInput:e.focusInput}),s=i.openParagraphDialog,l=tm({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=l.openTablePropertiesDialog,d=(t,n)=>{e.applyTransactionalState(t,{mergeKey:n}),e.focusInput()},u=nm({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:s,table:om({state:e.state,tableOps:e.tableOps,isInsideTable:l.isInsideTable,openTablePropertiesDialog:c,applyTableContextCommand:d})});return{computeFontFamilyOptions:t,computeFontSizeOptions:n,applyFontDialogValues:r.applyFontDialogValues,applyParagraphDialogValues:i.applyParagraphDialogValues,setParagraphDialogDefault:i.setParagraphDialogDefault,applyTablePropertiesDialogValues:l.applyTablePropertiesDialogValues,buildContextMenuItems:u.buildContextMenuItems,handleEditorContextMenu:u.handleEditorContextMenu,closeContextMenu:u.closeContextMenu}}(e)}function am(e){const t=Mt(()=>{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=zo(e.state).find(e=>e.id===t.paragraphId),r=n?ia(n,t):0,a=Ro(o,t,r);if(a)return{viewportLeft:a.left,viewportTop:a.top,height:Math.min(a.height||28,32)};const i=Le(o,t.paragraphId,"end");if(i)return{viewportLeft:i.left,viewportTop:i.top,height:i.height||28}}const s=e.caretViewport?.()??null;if(s)return r=s.left,a=s.top,i=Math.max(12,Math.min(36,s.height)),{viewportLeft:r,viewportTop:a,height:i};const l=e.pointerPos?.()??null;return l?(r=l.x,a=l.y-12,i=24,{viewportLeft:r,viewportTop:a,height:i}):{viewportLeft:r,viewportTop:a,height:i}});return pe(Ve,{get when(){return t()},children:e=>pe(Yt,{active:!0,fixed:!0,get left(){return e().viewportLeft},get top(){return e().viewportTop},get height(){return e().height}})})}var im=/*#__PURE__*/En("<div class=oasis-editor-table-resize-guide>"),sm=/*#__PURE__*/En("<div class=oasis-editor-table-resize-outline>"),lm=/*#__PURE__*/En("<img class=oasis-editor-image-ghost>"),cm=/*#__PURE__*/En("<div class=oasis-editor-table-ghost>");function dm(e){return[pe(Ve,{get when(){return e.tableResize.resizing()},children:e=>{return t=im(),Jn(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=V(t,a,n.a),n},{e:void 0,t:void 0,a:void 0}),t;var t}}),pe(Ve,{get when(){return e.tableCornerResize.previewRect()},children:e=>{return t=sm(),Jn(n=>{var o=`${e().left}px`,r=`${e().top}px`,a=`${e().width}px`,i=`${e().height}px`;return o!==n.e&&$e(t,"left",n.e=o),r!==n.t&&$e(t,"top",n.t=r),a!==n.a&&$e(t,"width",n.a=a),i!==n.o&&$e(t,"height",n.o=i),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),pe(Ve,{get when(){return Fe(()=>!!e.imageOps.dragging())()&&e.imageOps.draggedImageInfo()},children:t=>{return n=lm(),Jn(o=>{var r=t().src,a=`${t().width}px`,i=`${t().height}px`,s=e.imageOps.mousePos().x-t().offsetX+"px",l=e.imageOps.mousePos().y-t().offsetY+"px";return r!==o.e&&Me(n,"src",o.e=r),a!==o.t&&$e(n,"width",o.t=a),i!==o.a&&$e(n,"height",o.a=i),s!==o.o&&$e(n,"left",o.o=s),l!==o.i&&$e(n,"top",o.i=l),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),n;var n}}),pe(Ve,{get when(){return Fe(()=>!!e.tableDrag.dragging())()&&e.tableDrag.draggedTableInfo()},children:t=>{return n=cm(),Jn(o=>{var r=`${t().width}px`,a=`${t().height}px`,i=e.tableDrag.mousePos().x-t().offsetX+"px",s=e.tableDrag.mousePos().y-t().offsetY+"px";return r!==o.e&&$e(n,"width",o.e=r),a!==o.t&&$e(n,"height",o.t=a),i!==o.a&&$e(n,"left",o.a=i),s!==o.o&&$e(n,"top",o.o=s),o},{e:void 0,t:void 0,a:void 0,o:void 0}),n;var n}}),pe(Ve,{get when(){return Fe(()=>!!e.tableDrag.dragging())()&&e.tableDrag.dropTargetPos()},children:t=>pe(am,{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})}),pe(Ve,{get when(){return Fe(()=>!!e.imageOps.dragging())()&&e.imageOps.dropTargetPos()},children:t=>pe(am,{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})}),pe(Ve,{get when(){return Fe(()=>!!e.textDrag.dragging())()&&e.textDrag.dropTargetPos()},children:t=>pe(am,{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 um(e){return[pe(Un,{variant:"secondary",get onClick(){return e.onCancel},get"data-testid"(){return e.cancelTestId},get children(){return e.cancelLabel}}),pe(Un,{variant:"primary",get onClick(){return e.onConfirm},get"data-testid"(){return e.confirmTestId},get children(){return e.confirmLabel}})]}function pm(e){const t=T(),[o,r]=vn(e.initialValue);let a;n(()=>{e.isOpen&&(r(e.initialValue),setTimeout(()=>a?.focus(),50))});const i=()=>{e.onConfirm(o()),e.onClose()};return pe(se,{get isOpen(){return e.isOpen},get title(){return e.title},get onClose(){return e.onClose},get footer(){return pe(um,{get onCancel(){return e.onClose},onConfirm:i,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 pe(vo,{ref(e){"function"==typeof a?a(e):a=e},get label(){return e.label},get value(){return o()},onChange:r,onKeyDown:e=>"Enter"===e.key&&i(),get placeholder(){return e.placeholder},get"data-testid"(){return e.testIds?.input}})}})}function gm(e){const t=T();return pe(pm,{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 fm(e){const t=T();return pe(pm,{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 mm(e){const t=T();return pe(pm,{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 hm=/*#__PURE__*/En("<div class=oasis-editor-comment-composer-parent data-testid=comment-reply-context>"),bm=/*#__PURE__*/En("<div class=oasis-editor-comment-composer>");function ym(e){const t=T(),[o,r]=vn(""),[a,i]=vn("");let s;const l=e.composer.draft,c=()=>("edit"===l()?.mode||o().trim().length>0)&&a().trim().length>0,d=()=>{c()&&e.composer.submit(o(),a())};return n(()=>{l()&&(r("edit"===l()?.mode?l()?.commentAuthor??"":e.composer.authorName()),i("edit"===l()?.mode?l()?.commentText??"":""),queueMicrotask(()=>s?.focus()))}),pe(se,{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[pe(Un,{get onClick(){return e.composer.close},"data-testid":"comment-composer-cancel",get children(){return t("generic.cancel")}}),pe(Un,{variant:"primary",get disabled(){return!c()},onClick:d,"data-testid":"comment-composer-submit",get children(){return t("generic.save")}})]},get children(){var n=bm();return u(n,pe(Ve,{get when(){return"reply"===l()?.mode},get children(){var e=hm();return u(e,pe(_,{as:"strong",get children(){return[Fe(()=>t("comment.replyTo"))," ",Fe(()=>l()?.parentAuthor)]}}),null),u(e,pe(_,{as:"p",get children(){return l()?.parentText}}),null),e}}),null),u(n,pe(vo,{get label(){return t("comment.author")},get value(){return o()},onChange:r,maxLength:150,required:!0,get disabled(){return"edit"===l()?.mode||e.composer.authorLocked()},"data-testid":"comment-composer-author"}),null),u(n,pe(vt,{ref(e){"function"==typeof s?s(e):s=e},get label(){return t("comment.body")},controlClass:"oasis-editor-comment-composer-textarea",get value(){return a()},onChange:i,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),d())},rows:5,maxLength:2e4,get placeholder(){return t("comment.placeholder")},"data-testid":"comment-composer-body"}),null),n}})}var vm=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],xm=[33,50,66,75,90,100,105,110,115,120,150,200];function wm(e){const t=Number(e.trim());return Number.isFinite(t)&&t>0?t:null}function Sm(e){const t=Number(e.trim());return Number.isFinite(t)&&t>=0?t:null}function Im(e){return null==e||""===e?"":String(e)}function Cm(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"expanded":"condensed":"normal"}function Tm(e){const t=Number(e);return Number.isFinite(t)&&0!==t?t>0?"raised":"lowered":"normal"}function km(e){if(!e.trim())return null;const t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:null}function Pm(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 Rm(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 Mm(e,t){const n=[],o=km(e);return null!==o&&n.push(`"ss${String(o).padStart(2,"0")}" 1`),t&&n.push('"calt" 1'),n.join(", ")||void 0}function Om(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 Am(e){return{characterScale:Im(e.characterScale),spacingMode:Cm(e.characterSpacing),spacingAmount:e.characterSpacing?String(Math.abs(Number(e.characterSpacing))):"",positionMode:Tm(e.baselineShift),positionAmount:e.baselineShift?String(Math.abs(Number(e.baselineShift))):"",kerningEnabled:""!==e.kerningThreshold,kerningThreshold:Im(e.kerningThreshold),ligatures:e.ligatures,numberSpacing:e.numberSpacing,numberForm:e.numberForm,stylisticSet:Im(e.stylisticSet),contextualAlternates:Boolean(e.contextualAlternates)}}function Bm(e){const t=T(),[o,r]=vn("font"),[a,i]=vn(Om(e.initial)),[s,l]=vn(Am(e.initial));n(()=>{e.isOpen&&(r("font"),i(Om(e.initial)),l(Am(e.initial)))});const c=Mt(()=>{return e=a().bold,t=a().italic,e&&t?"boldItalic":e?"bold":t?"italic":"regular";var e,t}),d=Mt(()=>{const t=a().familyFilter.trim().toLowerCase();return t?e.familyOptions.filter(e=>e.toLowerCase().includes(t)):e.familyOptions}),u=Mt(()=>{const t=new Set(vm);for(const o of e.sizeOptions)t.add(o);const n=Number(a().fontSize);return Number.isFinite(n)&&n>0&&t.add(n),Array.from(t).sort((e,t)=>e-t)}),p=Mt(()=>{const e=a().fontSize.trim();if(!e)return"";const n=Number(e);return Number.isFinite(n)&&n>0?"":t("dialog.font.sizeInvalid")}),g=Mt(()=>{const e=s();return e.characterScale.trim()&&null===wm(e.characterScale)?t("dialog.font.advancedScaleInvalid"):"normal"!==e.spacingMode&&null===Sm(e.spacingAmount)||"normal"!==e.positionMode&&null===Sm(e.positionAmount)?t("dialog.font.advancedAmountInvalid"):e.kerningThreshold.trim()&&null===Sm(e.kerningThreshold)?t("dialog.font.advancedKerningInvalid"):e.stylisticSet.trim()&&null===km(e.stylisticSet)?t("dialog.font.advancedStylisticSetInvalid"):""}),f=Mt(()=>function(e,t){const n=Number(e.fontSize),o=wm(t.characterScale)??100,r="normal"===t.spacingMode?null:Sm(t.spacingAmount),a="normal"===t.positionMode?null:Sm(t.positionAmount),i=null===r?void 0:"condensed"===t.spacingMode?`-${r}pt`:`${r}pt`,s=null===a?void 0:"lowered"===t.positionMode?`-${a}pt`:`${a}pt`,l=[];return e.underline&&"none"!==e.underlineStyle&&l.push("underline"),e.strike&&l.push("line-through"),e.doubleStrike&&l.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":l.join(" ")||"none",color:"automatic"===e.colorMode?"inherit":e.color,"background-color":e.highlight||e.shading||void 0,"vertical-align":s??(e.superscript?"super":e.subscript?"sub":"baseline"),"font-stretch":`${o}%`,"letter-spacing":i,"font-variant-ligatures":Pm(t.ligatures),"font-variant-numeric":Rm(t.numberSpacing,t.numberForm),"font-feature-settings":Mm(t.stylisticSet,t.contextualAlternates)}}(a(),s()));return{activeTab:o,setActiveTab:e=>r(e),fontTabValues:a,setFontTabValues:i,advancedTabValues:s,setAdvancedTabValues:l,updateFontTab:(e,t)=>{i(n=>({...n,[e]:t}))},updateAdvancedTab:(e,t)=>{l(n=>({...n,[e]:t}))},selectedFontStyle:c,visibleFamilyOptions:d,effectiveSizeOptions:u,customSizeError:p,advancedValidationError:g,previewStyle:f,applyFontStylePreset:e=>{i(t=>({...t,bold:"bold"===e||"boldItalic"===e,italic:"italic"===e||"boldItalic"===e}))},handleApply:()=>{if(g())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()?wm(t.characterScale):null,s="normal"===t.spacingMode?null:Sm(t.spacingAmount),l="normal"===t.positionMode?null:Sm(t.positionAmount),c=t.kerningEnabled&&t.kerningThreshold.trim()?Sm(t.kerningThreshold):null,d=km(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===s?null:"condensed"===t.spacingMode?-s:s,baselineShift:null===l?null:"lowered"===t.positionMode?-l:l,kerningThreshold:c,ligatures:t.ligatures||null,numberSpacing:t.numberSpacing||null,numberForm:t.numberForm||null,stylisticSet:d,contextualAlternates:t.contextualAlternates}}(a(),s());e.onApply(t,e.initial),e.onClose()}}}var Dm=/*#__PURE__*/En("<div>");function Fm(e){const t=T();return n=Dm(),u(n,()=>t("dialog.font.previewText")),Jn(t=>{var o=e.class??"oasis-editor-dialog-preview",r=e.testId,a=e.style;return o!==t.e&&be(n,t.e=o),r!==t.t&&Me(n,"data-testid",t.t=r),t.a=V(n,a,t.a),t},{e:void 0,t:void 0,a:void 0}),n;var n}var Em=/*#__PURE__*/En('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel">');function Lm(e){const t=T(),{ctrl:n}=e;return o=Em(),u(o,pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:12,get children(){return pe(vo,{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"})}}),pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{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}))]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(lt,{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)}))]}})}}),pe(y,{size:{xs:12,md:4},get children(){return[pe(vo,{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"}),pe(Pe,{class:"oasis-editor-dialog-help-text",get children(){return n.customSizeError()}})]}}),pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{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),u(o,pe(y,{container:!0,spacing:1.5,class:"oasis-editor-font-dialog-color-row",get children(){return[pe(y,{size:{xs:12,md:4},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(Co,{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"})}}),pe(y,{size:{xs:12,md:2},get children(){return pe(Co,{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"})}}),pe(y,{size:{xs:12,md:2},get children(){return pe(Co,{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),u(o,pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{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")},...Vn.map(e=>({value:e.value,label:t(e.labelKey)}))]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(Co,{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),u(o,pe(Ie,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("dialog.font.style")},get children(){return pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return pe(qe,{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=>pe(Nt,{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),u(o,pe(Ie,{get label(){return t("dialog.font.preview")},get children(){return pe(Fm,{testId:"editor-font-dialog-preview",get style(){return n.previewStyle()}})}}),null),o;var o}var Nm=/*#__PURE__*/En("<div class=oasis-editor-font-dialog-kerning-line>"),zm=/*#__PURE__*/En('<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel">');function $m(e){const t=T(),{ctrl:n}=e;return o=zm(),u(o,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedCharacterSpacingGroup")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:4},get children(){return pe(lt,{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 xm.map(e=>({value:String(e),label:`${e}%`}))}})}}),pe(y,{size:{xs:12,md:8},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(vo,{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"})}})]}})}}),pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(vo,{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"})}}),pe(y,{size:12,get children(){var e=Nm();return u(e,pe(po,{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),u(e,pe(vo,{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),u(e,pe(Pe,{class:"oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix",get children(){return t("dialog.font.advancedKerningAbove")}}),null),e}})]}})}}),null),u(o,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedOpenTypeGroup")},get children(){return[pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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)}))]}})}})]}}),pe(po,{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),u(o,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("dialog.font.advancedPreviewGroup")},get children(){return pe(Fm,{class:"oasis-editor-dialog-preview oasis-editor-font-dialog-advanced-preview",testId:"editor-font-dialog-advanced-preview",get style(){return n.previewStyle()}})}}),null),u(o,pe(Pe,{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 Hm(e){const t=T(),n=Bm(e);return pe(se,{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 pe(um,{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 pe(w,{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:pe(Lm,{ctrl:n})},{id:"advanced",label:t("dialog.font.tabAdvanced"),testId:"editor-font-dialog-tab-advanced",panel:pe($m,{ctrl:n})}]}})}})}var Wm=/*#__PURE__*/En("<div class=oasis-editor-word-tabs-fields><div><div class=oasis-editor-word-tabs-list role=group>"),Um=/*#__PURE__*/En("<div class=oasis-editor-word-tabs-fields>"),jm=/*#__PURE__*/En("<div class=oasis-editor-word-tabs-actions>"),Vm=(e,t)=>Math.abs(e-t)<St,Km=e=>null!==e&&Number.isFinite(e)&&Math.abs(e)<=1584;function _m(e){const t=T(),[o,r]=vn([]),[a,i]=vn([]),[s,l]=vn(null),[c,d]=vn("left"),[p,g]=vn("none"),[f,m]=vn(36),[h,b]=vn(36),y=e=>{l(e.position),"clear"!==e.type&&d(e.type),g(e.leader??"none")};n(()=>{if(!e.isOpen)return;const t=e.initial.filter(e=>"clear"!==e.type).map(e=>({...e})).sort((e,t)=>e.position-t.position);r(t),i([]);const n=e.initialDefault??36;m(n),b(n),l(null),d("left"),g("none");const o=t.find(t=>void 0!==e.selectedPosition&&Vm(t.position,e.selectedPosition));o&&y(o)});const v=()=>o().find(e=>null!==s()&&Vm(e.position,s())),x=()=>{const e=f();return null!==e&&Number.isFinite(e)&&e>=1&&e<=1584},w=()=>Km(s())&&(Boolean(v())||o().length<64),S=()=>{const e=s();if(!Km(e)||!w())return;const t={position:e,type:c(),..."bar"!==c()&&"none"!==p()?{leader:p()}:{}};r(n=>[...n.filter(t=>!Vm(t.position,e)),t].sort((e,t)=>e.position-t.position)),i(e=>[...e,{set:[t]}])},I=()=>{const e=s();Km(e)&&v()&&(r(t=>t.filter(t=>!Vm(t.position,e))),i(t=>[...t,{clear:[e]}]),l(null))},C=()=>{r([]),l(null),i(e=>[...e,{clearAll:!0}])},k=()=>{if(!x())return;const t=[...a()];f()!==h()&&t.push({default:f()}),e.onApply(o().map(e=>({...e})),t),e.onClose()};return pe(se,{get isOpen(){return e.isOpen},get title(){return t("paragraph.tabsTitle")},get onClose(){return e.onClose},testId:"editor-tab-stops-dialog",class:"oasis-editor-word-tabs-dialog",initialFocusTestId:"editor-tab-stops-position",get footer(){return[pe(Un,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-tab-stops-cancel",get children(){return t("generic.cancel")}}),pe(Un,{variant:"primary",get disabled(){return!x()},onClick:k,"data-testid":"editor-tab-stops-apply",get children(){return t("generic.apply")}})]},get children(){return[(r=Wm(),a=r.firstChild,i=a.firstChild,u(a,pe(Ut,{get label(){return t("paragraph.tabsPosition")},step:"0.05",min:-Gn,max:Gn,get value(){return s()??""},onChange:l,"data-testid":"editor-tab-stops-position",get error(){return Fe(()=>!(null===s()||Km(s())))()?t("paragraph.tabsInvalidPosition"):void 0}}),i),u(i,pe(qe,{get each(){return o()},get fallback(){return pe(Pe,{as:"p",get children(){return t("paragraph.tabsEmpty")}})},children:e=>pe(Un,{variant:"ghost",class:"oasis-editor-word-tabs-option",get"aria-pressed"(){return Fe(()=>null!==s())()&&Vm(s(),e.position)},onClick:()=>y(e),"data-testid":"editor-tab-stops-option",get children(){return[Fe(()=>Number(e.position.toFixed(2)))," pt"]}})})),u(r,pe(Ut,{get label(){return t("paragraph.tabsDefaultInterval")},step:"0.05",min:"1",max:Gn,get value(){return f()??""},onChange:m,"data-testid":"editor-tab-stops-default",get error(){return Fe(()=>!x())()?t("paragraph.tabsInvalidInterval"):void 0}}),null),Jn(()=>Me(i,"aria-label",t("paragraph.tabsDefined"))),r),(n=Um(),u(n,pe(Xt,{get label(){return t("paragraph.tabsAlignment")},get value(){return c()},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")}]},onChange:e=>d(e)}),null),u(n,pe(Xt,{get label(){return t("paragraph.tabsLeader")},get value(){return Fe(()=>"bar"===c())()?"none":p()},get options(){return[{value:"none",label:t("paragraph.tabLeaderNone")},{value:"dot",label:"2 ............"},{value:"hyphen",label:"3 ----------"},{value:"underscore",label:"4 ________"},{value:"heavy",label:"5 ━━━━━━"},{value:"middleDot",label:"6 ············"}]},get disabled(){return"bar"===c()},onChange:e=>g(e)}),null),n),(e=jm(),u(e,pe(Un,{get disabled(){return!w()},onClick:S,"data-testid":"editor-tab-stops-set",get children(){return t("paragraph.tabsSet")}}),null),u(e,pe(Un,{get disabled(){return!v()},onClick:I,"data-testid":"editor-tab-stops-remove",get children(){return t("paragraph.tabsClear")}}),null),u(e,pe(Un,{onClick:C,"data-testid":"editor-tab-stops-clear",get children(){return t("paragraph.tabsClearAll")}}),null),e),pe(Pe,{as:"p",get children(){return t("paragraph.tabsDraftHelp")}})];var e,n,r,a,i}})}var Xm=96/72;function Gm(e){const[t,o]=vn(""),[r,a]=vn(""),[i,s]=vn(null),[l,c]=vn(null),[d,u]=vn("none"),[p,g]=vn(null),[f,m]=vn(!1),[h,b]=vn(null),[y,v]=vn(null),[x,w]=vn("multiple"),[S,I]=vn(null),[C,T]=vn(!1),[k,P]=vn(""),[R,M]=vn("none"),[O,A]=vn(null),[B,D]=vn(""),[F,E]=vn(!1),[L,N]=vn(!1),[z,$]=vn(!1),[H,W]=vn(!1),[U,j]=vn(!1),[V,K]=vn(!1),[_,X]=vn(!1),[G,q]=vn(!0),[Y,Z]=vn([]),[J,Q]=vn([]),[ee,te]=vn(36);n(()=>{if(e.isOpen){o(e.initial.align??""),a(e.initial.outlineLevel??""),s(In(e.initial.indentLeft??"")),c(In(e.initial.indentRight??"")),m(e.initial.mirrorIndents??!1),b(In(e.initial.spacingBefore??"")),v(In(e.initial.spacingAfter??"")),T(e.initial.contextualSpacing??!1),P(e.initial.shading??"");const{mode:r,at:i}=(t=e.initial.lineRule??"",n=In(e.initial.lineHeight??""),"exact"===t||"atLeast"===t?{mode:t,at:null!==n?Math.round(n/Xm):null}:null===n?{mode:"multiple",at:null}:1===n?{mode:"single",at:null}:1.5===n?{mode:"onePointFive",at:null}:2===n?{mode:"double",at:null}:{mode:"multiple",at:n});w(r),I(i);const l=e.initial.borderStyle;M("solid"===l||"dashed"===l||"dotted"===l?l:"none"),A(In(e.initial.borderWidth??"")),D(e.initial.borderColor??""),E(e.initial.borderSideTop??!1),N(e.initial.borderSideRight??!1),$(e.initial.borderSideBottom??!1),W(e.initial.borderSideLeft??!1),j(e.initial.pageBreakBefore??!1),K(e.initial.keepWithNext??!1),X(e.initial.keepLinesTogether??!1),q(e.initial.widowControl??!0),Z(e.initial.tabs??[]),Q([]),te(e.initial.defaultTabStop??36);const d=In(e.initial.indentFirstLine??""),p=In(e.initial.indentHanging??"");null!==p&&p>0?(u("hanging"),g(p)):null!==d&&d>0?(u("firstLine"),g(d)):(u("none"),g(null))}var t,n});const ne=()=>{switch(x()){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:S(),lineRule:null};case"atLeast":return{lineHeight:null!==S()?S()*Xm:null,lineRule:"atLeast"};case"exact":return{lineHeight:null!==S()?S()*Xm:null,lineRule:"exact"}}},oe=Mt(()=>{const e=i(),n=l(),o="firstLine"===d()?p():null,r="hanging"===d()?p():null,a=null!==o?o:null!==r?-r:null,s="none"!==R()?`${O()??.5}pt ${R()} ${B().trim()||"#000000"}`:void 0,{lineHeight:c,lineRule:u}=ne(),g=null===c?void 0:"exact"===u||"atLeast"===u?`${c}px`:String(c);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!==a?`${a}pt`:void 0,"background-color":k().trim()||void 0,"border-top":s&&F()?s:void 0,"border-right":s&&L()?s:void 0,"border-bottom":s&&z()?s:void 0,"border-left":s&&H()?s:void 0}}),re=()=>{const e=R();if("none"===e)return{top:null,right:null,bottom:null,left:null};const t=O(),n={type:e,width:null!==t&&t>0?t:.5,color:B().trim()||"#000000"};return{top:F()?n:null,right:L()?n:null,bottom:z()?n:null,left:H()?n:null}},ae=()=>{const e=p(),{lineHeight:n,lineRule:o}=ne(),a=r();return{align:t()||null,indentLeft:i(),indentRight:l(),indentFirstLine:"firstLine"===d()?e:null,indentHanging:"hanging"===d()?e:null,mirrorIndents:f(),spacingBefore:h(),spacingAfter:y(),lineHeight:n,lineRule:o,contextualSpacing:C(),outlineLevel:""===a?null:Number(a),shading:k().trim()||null,borders:re(),pageBreakBefore:U(),keepWithNext:V(),keepLinesTogether:_(),widowControl:G(),tabs:Y(),...J().length?{tabChanges:J()}:{}}};return{align:t,setAlign:o,outlineLevel:r,setOutlineLevel:a,indentLeft:i,setIndentLeft:s,indentRight:l,setIndentRight:c,special:d,setSpecial:u,specialBy:p,setSpecialBy:g,mirrorIndents:f,setMirrorIndents:m,spacingBefore:h,setSpacingBefore:b,spacingAfter:y,setSpacingAfter:v,lineMode:x,setLineMode:w,lineAt:S,setLineAt:I,contextualSpacing:C,setContextualSpacing:T,shading:k,setShading:P,borderStyle:R,setBorderStyle:M,borderWidth:O,setBorderWidth:A,borderColor:B,setBorderColor:D,sideTop:F,setSideTop:E,sideRight:L,setSideRight:N,sideBottom:z,setSideBottom:$,sideLeft:H,setSideLeft:W,pageBreakBefore:U,setPageBreakBefore:j,keepWithNext:V,setKeepWithNext:K,keepLinesTogether:_,setKeepLinesTogether:X,widowControl:G,setWidowControl:q,tabs:Y,setTabs:Z,defaultTabStop:ee,setDefaultTabStop:te,setTabChanges:Q,atEnabled:()=>"multiple"===x()||"atLeast"===x()||"exact"===x(),previewStyle:oe,handleApply:()=>{e.onApply(ae(),e.initial),e.onClose()},handleSetDefault:()=>{e.onSetDefault?.(ae()),e.onClose()}}}var qm=/*#__PURE__*/En("<div class=oasis-editor-paragraph-dialog-panel>"),Ym=/*#__PURE__*/En("<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>"),Zm=/*#__PURE__*/En("<div>"),Jm=/*#__PURE__*/En("<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>");function Qm(e){const t=T(),[n,o]=vn(!1),{align:r,setAlign:a,outlineLevel:i,setOutlineLevel:s,indentLeft:l,setIndentLeft:c,indentRight:d,setIndentRight:p,special:g,setSpecial:f,specialBy:m,setSpecialBy:h,mirrorIndents:b,setMirrorIndents:v,spacingBefore:x,setSpacingBefore:S,spacingAfter:I,setSpacingAfter:C,lineMode:k,setLineMode:P,lineAt:R,setLineAt:M,contextualSpacing:O,setContextualSpacing:A,shading:B,setShading:D,borderStyle:F,setBorderStyle:E,borderWidth:L,setBorderWidth:N,borderColor:z,setBorderColor:$,sideTop:H,setSideTop:W,sideRight:U,setSideRight:j,sideBottom:K,setSideBottom:_,sideLeft:X,setSideLeft:G,pageBreakBefore:q,setPageBreakBefore:Y,keepWithNext:Z,setKeepWithNext:J,keepLinesTogether:Q,setKeepLinesTogether:ee,widowControl:te,setWidowControl:ne,tabs:oe,setTabs:re,defaultTabStop:ae,setDefaultTabStop:ie,setTabChanges:le,atEnabled:ce,previewStyle:de,handleApply:ue,handleSetDefault:ge}=Gm(e),fe=pe(lt,{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")}]}}),me=pe(lt,{get label(){return t("paragraph.outlineLevelLabel")},get value(){return i()},onChange:s,"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])}))]}}),he=(be=qm(),u(be,pe(Dn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupGeneral")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},children:fe}),pe(y,{size:{xs:12,md:6},children:me})]}})}}),null),u(be,pe(Dn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupIndent")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},get children(){return pe(Ut,{get label(){return t("paragraph.indentLeftLabel")},step:"1",get value(){return l()??""},onChange:c,"data-testid":"editor-paragraph-dialog-indent-left"})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(Ut,{get label(){return t("paragraph.indentRightLabel")},step:"1",get value(){return d()??""},onChange:p,"data-testid":"editor-paragraph-dialog-indent-right"})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{get label(){return t("paragraph.specialLabel")},get value(){return g()},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")}]}})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(Ut,{get label(){return t("paragraph.specialByLabel")},min:"0",step:"1",get disabled(){return"none"===g()},get value(){return m()??""},onChange:h,"data-testid":"editor-paragraph-dialog-special-by"})}}),pe(y,{size:12,get children(){return pe(po,{get label(){return t("paragraph.mirrorIndentsLabel")},get checked(){return b()},onChange:v,"data-testid":"editor-paragraph-dialog-mirror-indents"})}})]}})}}),null),u(be,pe(Dn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupSpacing")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:4},get children(){return pe(Ut,{get label(){return t("paragraph.spacingBeforeLabel")},min:"0",step:"1",get value(){return x()??""},onChange:S,"data-testid":"editor-paragraph-dialog-spacing-before"})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(Ut,{get label(){return t("paragraph.spacingAfterLabel")},min:"0",step:"1",get value(){return I()??""},onChange:C,"data-testid":"editor-paragraph-dialog-spacing-after"})}}),pe(y,{size:{xs:12,md:4}}),pe(y,{size:{xs:12,md:8},get children(){return pe(lt,{get label(){return t("paragraph.lineSpacingLabel")},get value(){return k()},onChange:e=>{P(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")}]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(Ut,{get label(){return t("paragraph.lineSpacingAt")},min:"0",get step(){return"multiple"===k()?"0.05":"1"},get disabled(){return!ce()},get value(){return R()??""},onChange:M,"data-testid":"editor-paragraph-dialog-line-at"})}}),pe(y,{size:12,get children(){return pe(po,{get label(){return t("paragraph.contextualSpacingLabel")},get checked(){return O()},onChange:A,"data-testid":"editor-paragraph-dialog-contextual-spacing"})}})]}})}}),null),u(be,pe(Dn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupBorders")},get children(){return[pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:3},get children(){return pe(lt,{get label(){return t("paragraph.borderStyleLabel")},get value(){return F()},onChange:e=>{const t=e;E(t),"none"===t?(W(!1),j(!1),_(!1),G(!1)):H()||U()||K()||X()||(W(!0),j(!0),_(!0),G(!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")}]}})}}),pe(y,{size:{xs:12,md:3},get children(){return pe(Ut,{get label(){return t("paragraph.borderWidthLabel")},min:"0",step:"0.25",get disabled(){return"none"===F()},get value(){return L()??""},onChange:N,"data-testid":"editor-paragraph-dialog-border-width"})}}),pe(y,{size:{xs:12,md:3},get children(){return pe(Co,{get label(){return t("paragraph.borderColorLabel")},get disabled(){return"none"===F()},get value(){return z()||"#000000"},onChange:$,"data-testid":"editor-paragraph-dialog-border-color"})}}),pe(y,{size:{xs:12,md:3},get children(){return pe(Co,{get label(){return t("paragraph.shadingLabel")},get value(){return B()||"#ffffff"},onChange:D,"data-testid":"editor-paragraph-dialog-shading"})}})]}}),pe(Ie,{class:"oasis-editor-dialog-input-group-grow",get label(){return t("paragraph.borderSidesLabel")},get children(){return pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[pe(po,{get label(){return t("paragraph.borderSideTop")},get disabled(){return"none"===F()},get checked(){return H()},onChange:W,"data-testid":"editor-paragraph-dialog-border-side-top"}),pe(po,{get label(){return t("paragraph.borderSideRight")},get disabled(){return"none"===F()},get checked(){return U()},onChange:j,"data-testid":"editor-paragraph-dialog-border-side-right"}),pe(po,{get label(){return t("paragraph.borderSideBottom")},get disabled(){return"none"===F()},get checked(){return K()},onChange:_,"data-testid":"editor-paragraph-dialog-border-side-bottom"}),pe(po,{get label(){return t("paragraph.borderSideLeft")},get disabled(){return"none"===F()},get checked(){return X()},onChange:G,"data-testid":"editor-paragraph-dialog-border-side-left"})]}})}})]}}),null),be);var be;const ye=(ve=qm(),u(ve,pe(Dn,{class:"oasis-editor-dialog-fieldset",get legend(){return t("paragraph.groupPagination")},get children(){return pe(mo,{direction:"column",spacing:1,get children(){return[pe(po,{get label(){return t("paragraph.widowControlLabel")},get checked(){return te()},onChange:ne,"data-testid":"editor-paragraph-dialog-widow-control"}),pe(po,{get label(){return t("paragraph.keepWithNextLabel")},get checked(){return Z()},onChange:J,"data-testid":"editor-paragraph-dialog-keep-with-next"}),pe(po,{get label(){return t("paragraph.keepLinesTogetherLabel")},get checked(){return Q()},onChange:ee,"data-testid":"editor-paragraph-dialog-keep-lines-together"}),pe(po,{get label(){return t("paragraph.pageBreakBeforeLabel")},get checked(){return q()},onChange:Y,"data-testid":"editor-paragraph-dialog-page-break-before"})]}})}})),ve);var ve,xe;return xe=Zm(),u(xe,pe(se,{get isOpen(){return Fe(()=>!(!e.isOpen||n()))()&&!e.initial.tabsOnly},get title(){return t("paragraph.title")},get onClose(){return e.onClose},size:"lg",testId:"editor-paragraph-dialog",get footer(){return n=Jm(),r=n.firstChild,a=r.nextSibling,u(r,pe(Un,{variant:"secondary",onClick:()=>{o(!0)},"data-testid":"editor-paragraph-dialog-tabs",get children(){return t("paragraph.tabsButton")}}),null),u(r,pe(Un,{variant:"secondary",onClick:ge,"data-testid":"editor-paragraph-dialog-set-default",get children(){return t("paragraph.setAsDefault")}}),null),u(a,pe(Un,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-paragraph-dialog-cancel",get children(){return t("generic.cancel")}}),null),u(a,pe(Un,{variant:"primary",onClick:ue,"data-testid":"editor-paragraph-dialog-apply",get children(){return t("generic.apply")}}),null),n;var n,r,a},get children(){return[pe(w,{get ariaLabel(){return t("paragraph.title")},get items(){return[{id:"indents",label:t("paragraph.tabIndentsSpacing"),panel:he,testId:"editor-paragraph-dialog-tab-indents"},{id:"breaks",label:t("paragraph.tabLineBreaks"),panel:ye,testId:"editor-paragraph-dialog-tab-breaks"}]}}),pe(Ie,{get label(){return t("paragraph.preview")},get children(){var e=Ym();return u(e,()=>t("paragraph.previewText")),Jn(t=>V(e,de(),t)),e}})]}}),null),u(xe,pe(_m,{get isOpen(){return Fe(()=>!!e.isOpen)()&&(n()||!!e.initial.tabsOnly)},get initial(){return oe()},get initialDefault(){return ae()},get selectedPosition(){return e.initial.selectedTabPosition},onClose:()=>{o(!1),e.initial.tabsOnly&&e.onClose()},onApply:(t,n)=>{re(t),le(e=>[...e,...n]);for(const e of n)"number"==typeof e.default&&ie(e.default);e.initial.tabsOnly&&ue()}}),null),xe}function eh(e,t){const n=In(e);return null===n?null:"percent"===t?`${n}%`:n}function th(e,t,n){if("none"===e)return null;const o=In(t);return{type:e,width:null!==o&&o>0?o:.5,color:n.trim()||"#000000"}}function nh(e){const[t,o]=xn({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:""});n(()=>{var t;e.isOpen&&o(Wn({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:o,handleApply:()=>{e.onApply(function(e){const t=th(e.borderStyle,e.borderWidth,e.borderColor);return{tableWidth:eh(e.tableWidth,e.tableWidthUnit),tableAlign:e.tableAlign||null,tableIndentLeft:eh(e.tableIndentLeft,"points"),tableFloating:"around"===e.tableWrapping?{horizontalAnchor:e.floatingHorizontalAnchor,verticalAnchor:e.floatingVerticalAnchor,...e.floatingXAlign?{xAlign:e.floatingXAlign}:{x:In(e.floatingX)??0},...e.floatingYAlign?{yAlign:e.floatingYAlign}:{y:In(e.floatingY)??0},distanceTop:In(e.floatingDistanceTop)??0,distanceRight:In(e.floatingDistanceRight)??0,distanceBottom:In(e.floatingDistanceBottom)??0,distanceLeft:In(e.floatingDistanceLeft)??0}:null,tableOverlap:"around"===e.tableWrapping?e.floatingOverlap:null,rowHeight:eh(e.rowHeight,"points"),rowHeightRule:e.rowHeightRule||null,repeatHeader:e.repeatHeader,cantSplit:!e.allowBreakAcrossPages,hiddenRow:e.hiddenRow,columnWidth:eh(e.columnWidth,"points"),cellWidth:eh(e.cellWidth,"points"),cellVerticalAlign:e.cellVerticalAlign||null,cellTextDirection:e.cellTextDirection||null,cellNoWrap:e.cellNoWrap,cellFitText:e.cellFitText,cellHideMark:e.cellHideMark,margins:{top:In(e.marginTop),right:In(e.marginRight),bottom:In(e.marginBottom),left:In(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 oh(e,t,n,o,r=!1,a=!1){return pe(vo,{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 rh=/*#__PURE__*/En("<div class=oasis-editor-table-properties-panel>");function ah(e){const t=T(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=rh(),u(r,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.sizeSection")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},get children(){return oh(t("table.preferredWidth"),()=>n().tableWidth,e=>o("tableWidth",e),"editor-table-properties-table-width")}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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),u(r,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.alignmentSection")},get children(){return[pe(Xt,{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=>pe(bn,{value:e,get label(){return t(`table.align${e[0].toUpperCase()}${e.slice(1)}`)},"data-testid":`editor-table-properties-align-${e}`}))}}),pe(y,{container:!0,spacing:1.5,get children(){return pe(y,{size:{xs:12,md:6},get children(){return oh(t("table.indentFromLeft"),()=>n().tableIndentLeft,e=>o("tableIndentLeft",e),"editor-table-properties-indent-left")}})}})]}}),null),u(r,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.textWrappingSection")},get children(){return[pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[pe(po,{get label(){return t("table.wrapNone")},get checked(){return"none"===n().tableWrapping},onChange:()=>o("tableWrapping","none"),"data-testid":"editor-table-properties-wrap-none"}),pe(po,{get label(){return t("table.wrapAround")},get checked(){return"around"===n().tableWrapping},onChange:()=>o("tableWrapping","around"),"data-testid":"editor-table-properties-wrap-around"})]}}),pe(Ve,{get when(){return"around"===n().tableWrapping},get children(){return[pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.positionX"),()=>n().floatingX,e=>o("floatingX",e),"editor-table-properties-floating-x",Boolean(n().floatingXAlign),!0)}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.positionY"),()=>n().floatingY,e=>o("floatingY",e),"editor-table-properties-floating-y",Boolean(n().floatingYAlign),!0)}}),pe(y,{size:{xs:12,md:3},get children(){return pe(lt,{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}))]}})}}),pe(y,{size:{xs:12,md:3},get children(){return pe(lt,{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}))]}})}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.distanceTop"),()=>n().floatingDistanceTop,e=>o("floatingDistanceTop",e),"editor-table-properties-floating-distance-top")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.distanceRight"),()=>n().floatingDistanceRight,e=>o("floatingDistanceRight",e),"editor-table-properties-floating-distance-right")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.distanceBottom"),()=>n().floatingDistanceBottom,e=>o("floatingDistanceBottom",e),"editor-table-properties-floating-distance-bottom")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("table.distanceLeft"),()=>n().floatingDistanceLeft,e=>o("floatingDistanceLeft",e),"editor-table-properties-floating-distance-left")}})]}}),pe(po,{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 ih=/*#__PURE__*/En("<div class=oasis-editor-table-properties-panel>");function sh(e){const t=T(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=ih(),u(r,pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:6},get children(){return oh(t("table.rowHeight"),()=>n().rowHeight,e=>o("rowHeight",e),"editor-table-properties-row-height")}}),pe(y,{size:{xs:12,md:6},get children(){return pe(lt,{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),u(r,pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[pe(po,{get label(){return t("table.repeatHeader")},get checked(){return n().repeatHeader},onChange:e=>o("repeatHeader",e),"data-testid":"editor-table-properties-repeat-header"}),pe(po,{get label(){return t("table.allowBreakAcrossPages")},get checked(){return n().allowBreakAcrossPages},onChange:e=>o("allowBreakAcrossPages",e),"data-testid":"editor-table-properties-allow-break"}),pe(po,{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 lh=/*#__PURE__*/En("<div class=oasis-editor-table-properties-panel>");function ch(e){const t=T(),n=e.ctrl.set;return o=lh(),u(o,pe(y,{container:!0,spacing:1.5,get children(){return pe(y,{size:{xs:12,md:6},get children(){return oh(t("table.columnWidth"),()=>e.ctrl.form.columnWidth,e=>n("columnWidth",e),"editor-table-properties-column-width")}})}})),o;var o}var dh=/*#__PURE__*/En("<div class=oasis-editor-table-properties-cell-preview data-testid=editor-table-properties-cell-preview>"),uh=/*#__PURE__*/En("<div class=oasis-editor-table-properties-panel>");function ph(e){const t=T(),n=()=>e.ctrl.form,o=e.ctrl.set,r=Mt(()=>{const e=th(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=uh(),u(i,pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:4},get children(){return oh(t("table.cellWidth"),()=>n().cellWidth,e=>o("cellWidth",e),"editor-table-properties-cell-width")}}),pe(y,{size:{xs:12,md:4},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:4},get children(){return pe(lt,{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),u(i,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.options")},get children(){return pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[pe(po,{get label(){return t("table.noWrap")},get checked(){return n().cellNoWrap},onChange:e=>o("cellNoWrap",e),"data-testid":"editor-table-properties-cell-nowrap"}),pe(po,{get label(){return t("table.fitText")},get checked(){return n().cellFitText},onChange:e=>o("cellFitText",e),"data-testid":"editor-table-properties-cell-fit-text"}),pe(po,{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),u(i,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("table.cellMargins")},get children(){return pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:3},get children(){return oh(t("paragraph.borderSideTop"),()=>n().marginTop,e=>o("marginTop",e),"editor-table-properties-margin-top")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("paragraph.borderSideRight"),()=>n().marginRight,e=>o("marginRight",e),"editor-table-properties-margin-right")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("paragraph.borderSideBottom"),()=>n().marginBottom,e=>o("marginBottom",e),"editor-table-properties-margin-bottom")}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("paragraph.borderSideLeft"),()=>n().marginLeft,e=>o("marginLeft",e),"editor-table-properties-margin-left")}})]}})}}),null),u(i,pe(Dn,{class:"oasis-editor-font-dialog-fieldset",get legend(){return t("paragraph.bordersSection")},get children(){return[pe(y,{container:!0,spacing:1.5,get children(){return[pe(y,{size:{xs:12,md:3},get children(){return pe(lt,{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")}]}})}}),pe(y,{size:{xs:12,md:3},get children(){return oh(t("paragraph.borderWidthLabel"),()=>n().borderWidth,e=>o("borderWidth",e),"editor-table-properties-border-width",a())}}),pe(y,{size:{xs:12,md:3},get children(){return pe(Co,{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"})}}),pe(y,{size:{xs:12,md:3},get children(){return pe(Co,{get label(){return t("paragraph.shadingLabel")},get value(){return n().shading||"#ffffff"},onChange:e=>o("shading",e),"data-testid":"editor-table-properties-shading"})}})]}}),pe(mo,{class:"oasis-editor-dialog-style-row",direction:"row",spacing:1,get children(){return[pe(po,{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"}),pe(po,{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"}),pe(po,{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"}),pe(po,{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"}),pe(po,{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"}),pe(po,{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"}),pe(po,{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"}),pe(po,{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=dh(),Jn(t=>V(e,r(),t)),e)];var e}}),null),i;var i}var gh=/*#__PURE__*/En("<div class=oasis-editor-table-properties-panel>");function fh(e){const t=T(),n=()=>e.ctrl.form,o=e.ctrl.set;return r=gh(),u(r,pe(vo,{get label(){return t("table.altTitle")},get value(){return n().altTitle},onChange:e=>o("altTitle",e),"data-testid":"editor-table-properties-alt-title"}),null),u(r,pe(vt,{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 mh(e){const t=T(),n=nh(e);return pe(se,{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 pe(um,{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 pe(w,{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:pe(ah,{ctrl:n})},{id:"row",label:t("table.tabRow"),testId:"editor-table-properties-tab-row",panel:pe(sh,{ctrl:n})},{id:"column",label:t("table.tabColumn"),testId:"editor-table-properties-tab-column",panel:pe(ch,{ctrl:n})},{id:"cell",label:t("table.tabCell"),testId:"editor-table-properties-tab-cell",panel:pe(ph,{ctrl:n})},{id:"altText",label:t("table.tabAltText"),testId:"editor-table-properties-tab-alt-text",panel:pe(fh,{ctrl:n})}]}})}})}var hh=/*#__PURE__*/En("<p data-testid=editor-new-document-message>");function bh(e){const t=T();return pe(se,{get isOpen(){return e.isOpen},get title(){return t("dialog.newDocument.title")},get onClose(){return e.onClose},closeOnOverlayClick:!1,size:"sm",get footer(){return pe(um,{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=hh();return u(e,()=>t("dialog.newDocument.message")),e}})}function yh(e){const t=T(),n=()=>"accept"===e.action;return pe(se,{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 pe(um,{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 pe(_,{as:"p","data-testid":"editor-revision-bulk-message",get children(){return t(n()?"review.bulkAcceptMessage":"review.bulkRejectMessage",[e.count])}})}})}var vh=/*#__PURE__*/En("<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>"),xh=/*#__PURE__*/En("<div class=oasis-editor-symbol-dialog-recent><span></span><div class=oasis-editor-symbol-dialog-recent-list>"),wh=/*#__PURE__*/En("<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>"),Sh=/*#__PURE__*/En("<option>"),Ih=/*#__PURE__*/En("<button type=button class=oasis-editor-symbol-dialog-tile>"),Ch=/*#__PURE__*/En("<button type=button class=oasis-editor-symbol-dialog-tile role=gridcell>"),Th=["Segoe UI Symbol","Arial Unicode MS","Cambria Math","Times New Roman"];function kh(e){const t=T(),[n,o]=vn("common"),[r,a]=vn(Ct[0]),[i,s]=vn(Th[0]),[l,c]=vn(Ct[0].codePoint),d=Mt(()=>(e.isOpen,ln())),p=Mt(()=>"all"===n()?Dt.flatMap(e=>e.entries):Dt.find(e=>e.id===n())?.entries??Ct),g=e=>{a(e),c(e.codePoint)},f=()=>{const t=r().character;t&&(no(t),e.onInsert(t,i()),e.onClose())};return pe(se,{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[pe(Un,{variant:"secondary",get onClick(){return e.onClose},"data-testid":"editor-symbol-dialog-cancel",get children(){return t("generic.cancel")}}),pe(Un,{variant:"primary",onClick:f,"data-testid":"editor-symbol-dialog-insert",get children(){return t("dialog.symbol.insert")}})]},get children(){return[(S=vh(),I=S.firstChild,C=I.firstChild,T=C.nextSibling,k=I.nextSibling.firstChild,P=k.nextSibling,R=P.firstChild,u(C,()=>t("dialog.symbol.font")),T.addEventListener("change",e=>{s(e.currentTarget.value)}),u(T,pe(qe,{each:Th,children:e=>{return(t=Sh()).value=e,u(t,e),t;var t}})),u(k,()=>t("dialog.symbol.subset")),P.addEventListener("change",e=>{o(e.currentTarget.value)}),u(R,()=>t("symbols.category.all")),u(P,pe(qe,{each:Dt,children:e=>{return n=Sh(),u(n,()=>t(e.labelKey)),Jn(()=>n.value=e.id),n;var n}}),null),Jn(()=>T.value=i()),Jn(()=>P.value=n()),S),(e=wh(),m=e.firstChild,h=m.nextSibling.firstChild,b=h.nextSibling,y=b.nextSibling,v=y.firstChild,x=v.nextSibling,w=y.nextSibling,u(m,pe(Ve,{get when(){return d().length>0},get children(){var e=xh(),n=e.firstChild,o=n.nextSibling;return u(n,()=>t("dialog.symbol.recent")),u(o,pe(qe,{get each(){return d()},children:e=>{return(t=Ih()).$$click=()=>g(e),u(t,()=>e.character),Jn(n=>{var o=`${e.character} (${e.codePoint})`,r=`${e.character} (${e.codePoint})`;return o!==n.e&&Me(t,"title",n.e=o),r!==n.t&&Me(t,"aria-label",n.t=r),n},{e:void 0,t:void 0}),t;var t}})),e}}),null),u(m,pe(qe,{get each(){return p()},children:e=>{return(t=Ch()).$$dblclick=f,t.$$click=()=>g(e),u(t,()=>e.character),Jn(n=>{var o=!(r().character!==e.character),a=`${e.character} (${e.codePoint})`,i=`${e.character} (${e.codePoint})`,s=`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&&Me(t,"title",n.t=a),i!==n.a&&Me(t,"aria-label",n.a=i),s!==n.o&&Me(t,"data-testid",n.o=s),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t}}),null),u(h,()=>t("dialog.symbol.preview")),u(b,()=>r().character),u(v,()=>t("dialog.symbol.code")),x.$$input=e=>(e=>{c(e);const t=e.trim().toUpperCase().replace(/^U\+/,""),n=Number.parseInt(t,16);!Number.isFinite(n)||n<0||n>1114111||a({character:String.fromCodePoint(n),codePoint:`U+${n.toString(16).toUpperCase().padStart(4,"0")}`})})(e.currentTarget.value),Me(x,"spellcheck",!1),u(w,()=>t("dialog.symbol.doubleClickHelp")),Jn(e=>{var n=t("dialog.symbol.title"),o=i();return n!==e.e&&Me(m,"aria-label",e.e=n),o!==e.t&&$e(b,"font-family",e.t=o),e},{e:void 0,t:void 0}),Jn(()=>x.value=l()),e)];var e,m,h,b,y,v,x,w,S,I,C,T,k,P,R}})}ko(["input","click","dblclick"]);var Ph=/*#__PURE__*/En("<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>"),Rh=/*#__PURE__*/En("<button type=button data-testid=editor-equation-template>"),Mh=[["\\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 Oh(e){const t=T(),[o,r]=vn(""),[a,i]=vn(rn);n(()=>{if(!e.isOpen)return;const t=e.initial??rn;i(t),r(eo(t))});const s=e=>{r(e),i(At(e))};return pe(se,{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[pe(Un,{variant:"secondary",get onClick(){return e.onClose},get children(){return t("generic.cancel")}}),pe(Un,{variant:"primary",onClick:()=>e.onApply(a()),"data-testid":"editor-equation-apply",get children(){return t("dialog.equation.insert")}})]},get children(){var e=Ph(),n=e.firstChild,r=n.nextSibling,i=r.firstChild,l=i.nextSibling,c=r.nextSibling;return u(n,pe(qe,{each:Mh,children:([e,t])=>{return(n=Rh()).$$click=()=>s(t),u(n,e),n;var n}})),u(i,()=>t("dialog.equation.linear")),l.$$input=e=>s(e.currentTarget.value),Me(l,"spellcheck",!1),u(c,()=>eo(a())||t("dialog.equation.empty")),Jn(()=>Me(n,"aria-label",t("dialog.equation.structures"))),Jn(()=>l.value=o()),e}})}ko(["input","click"]);var Ah=/*#__PURE__*/En("<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 Bh(e){const t=T(),{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 _n(()=>{window.addEventListener("keydown",o,!0)}),Tn(()=>{window.removeEventListener("keydown",o,!0)}),pe(Ve,{get when(){return n.isOpen()},get children(){var e=Ah(),o=e.firstChild,a=o.nextSibling,i=a.firstChild,s=i.firstChild,l=i.nextSibling;return e.$$keydown=r,u(o,pe(_,{get children(){return t("find.title")}}),null),u(o,pe(Nn,{class:"oasis-editor-fr-close",icon:"x",onClick:()=>n.setIsOpen(!1),get label(){return t("generic.close")}}),null),u(s,pe(vo,{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),u(s,pe(Pe,{class:"oasis-editor-fr-counter",get children(){return Fe(()=>n.matches().length>0)()?`${n.currentIndex()+1} / ${n.matches().length}`:t("find.noMatches")}}),null),u(i,pe(mo,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[pe(Nn,{get onClick(){return n.findPrevious},get disabled(){return 0===n.matches().length},icon:"chevron-up",get label(){return t("find.prevTooltip")}}),pe(Nn,{get onClick(){return n.findNext},get disabled(){return 0===n.matches().length},icon:"chevron-down",get label(){return t("find.nextTooltip")}})]}}),null),u(l,pe(vo,{type:"text",get placeholder(){return t("replace.placeholder")},get value(){return n.replaceTerm()},onChange:e=>n.setReplaceTerm(e),controlClass:"oasis-editor-fr-input"}),null),u(l,pe(mo,{class:"oasis-editor-fr-actions",direction:"row",spacing:1,get children(){return[pe(Nn,{class:"oasis-editor-fr-btn-text",get onClick(){return n.replace},get disabled(){return 0===n.matches().length},get children(){return t("replace.one")}}),pe(Nn,{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),u(a,pe(mo,{class:"oasis-editor-fr-options",direction:"row",spacing:1,get children(){return[pe(po,{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})}),pe(po,{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}})}ko(["keydown"]);var Dh=/*#__PURE__*/En("<div class=oasis-editor-context-menu role=menu data-testid=editor-context-menu>"),Fh=/*#__PURE__*/En("<i>"),Eh=/*#__PURE__*/En("<span class=oasis-editor-context-menu-shortcut>"),Lh=/*#__PURE__*/En("<button type=button class=oasis-editor-context-menu-item role=menuitem><span class=oasis-editor-context-menu-label>"),Nh=/*#__PURE__*/En("<div class=oasis-editor-context-menu-separator>"),zh=/*#__PURE__*/En("<span aria-hidden=true style=visibility:hidden;flex-shrink:0>");function $h(e){let t;M({refs:()=>[t],open:()=>e.isOpen,onDismiss:()=>e.onClose()});const o=n=>{e.isOpen&&(t&&n.target instanceof Node&&t.contains(n.target)||e.onClose())},r=()=>{e.isOpen&&e.onClose()};return _n(()=>{window.addEventListener("contextmenu",o,!0),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r,!0)}),Tn(()=>{window.removeEventListener("contextmenu",o,!0),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r,!0)}),n(()=>{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`}),pe(Ve,{get when(){return e.isOpen},get children(){var n=Dh();n.$$contextmenu=e=>e.preventDefault();return"function"==typeof t?$(t,n):t=n,u(n,pe(qe,{get each(){return e.items},children:t=>pe(Ve,{get when(){return"separator"!==t.type},get fallback(){return Nh()},get children(){var n=Lh(),o=n.firstChild;return n.$$click=()=>{t.disabled||(t.onSelect?.(),e.onClose())},u(n,pe(Ve,{get when(){return t.icon},get fallback(){return e=zh(),u(e,pe(W,{size:16})),e;var e},get children(){var e=Fh();return Jn(()=>Me(e,"data-lucide",t.icon)),e}}),o),u(o,()=>t.label),u(n,pe(Ve,{get when(){return t.shortcut},get children(){var e=Eh();return u(e,()=>t.shortcut),e}}),null),Jn(e=>{var o=t.disabled,r=t.testId;return o!==e.e&&(n.disabled=e.e=o),r!==e.t&&Me(n,"data-testid",e.t=r),e},{e:void 0,t:void 0}),n}})})),Jn(t=>{var o=`${e.x}px`,r=`${e.y}px`;return o!==t.e&&$e(n,"left",t.e=o),r!==t.t&&$e(n,"top",t.t=r),t},{e:void 0,t:void 0}),n}})}function Hh(e){const{linkDialog:t,setLinkDialog:n,imageAltDialog:o,setImageAltDialog:r,imageCaptionDialog:a,setImageCaptionDialog:i,contextMenu:s,fontDialog:l,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[pe(bh,{get isOpen(){return f().isOpen},onClose:()=>{m({isOpen:!1}),e.focusInput()},onConfirm:()=>{m({isOpen:!1}),e.confirmNewDocument()}}),pe(yh,{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)}}),pe(kh,{get isOpen(){return y().isOpen},onClose:()=>{v({isOpen:!1}),e.focusInput()},onInsert:(t,n)=>{v({isOpen:!1}),e.insertSymbol(t,n)}}),pe(Oh,{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)}}),pe(gm,{get isOpen(){return t().isOpen},get initialHref(){return t().initialHref},onClose:()=>{n({...t(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyLinkCommand(t.trim()||null)}),pe(fm,{get isOpen(){return o().isOpen},get initialAlt(){return o().initialAlt},onClose:()=>{r({...o(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageAltCommand(t.trim())}),pe(mm,{get isOpen(){return a().isOpen},get initialCaption(){return a().initialCaption},onClose:()=>{i({...a(),isOpen:!1}),e.focusInput()},onConfirm:t=>e.applyImageCaptionCommand(t.trim())}),pe(ym,{get composer(){return e.commentComposer}}),pe(Bh,{get fr(){return e.findReplace}}),pe(Hm,{get isOpen(){return l().isOpen},get initial(){return l().initial},get familyOptions(){return e.fontFamilyOptions()},get sizeOptions(){return e.fontSizeOptions()},onClose:()=>{c({...l(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyFontDialogValues}}),pe(Qm,{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}}),pe(mh,{get isOpen(){return p().isOpen},get initial(){return p().initial},onClose:()=>{g({...p(),isOpen:!1}),e.focusInput()},get onApply(){return e.applyTablePropertiesDialogValues}}),pe($h,{get isOpen(){return s().isOpen},get x(){return s().x},get y(){return s().y},get items(){return e.contextMenuItems()},get onClose(){return e.closeContextMenu}})]}ko(["contextmenu","click"]);var Wh=/*#__PURE__*/En("<div class=oasis-editor-main-container><section class=oasis-editor-stage>");function Uh(e){let t,n;const o=f(),r=n=>{t=n,e.view.refs.onSurfaceRef?.(n)},a=t=>{n=t,e.view.refs.onViewportRef?.(t)},i=Mo({state:e.runtime.state,documentLayout:e.view.documentLayout,surfaceRef:()=>t,viewportRef:()=>n,zoomFactor:e.view.layout.zoomFactor,snapshotProvider:o});return[pe(Ve,{get when(){return e.useComposedShell()},get children(){return(()=>{const t=e.shellComponent(),{runtime:n,chrome:o,view:r}=e;return pe(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}})})()}}),pe(Ve,{get when(){return!e.useComposedShell()},get children(){return pe(ee,{get editor(){return e.runtime.runtimeEditor},get children(){var s=Wh(),l=s.firstChild;return u(s,pe(Ve,{get when(){return e.chrome.showOutline()},get children(){return pe(ve,{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})}}),l),u(l,pe(Ne,{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}})),s}})}})]}var jh=/*#__PURE__*/En("<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 Vh(e){const t=T(),n=()=>{it(),fo(),e.onClose()},o=()=>{h(!1),fo(),e.onClose()};return pe(Ve,{get when(){return e.isOpen},get children(){var e=jh(),r=e.firstChild,a=r.firstChild,i=a.nextSibling,s=i.nextSibling,l=s.nextSibling;return u(r,pe(ne,{height:72,class:"oasis-editor-welcome-mark"}),a),u(a,()=>t("welcome.title")),u(i,()=>t("welcome.body")),u(s,()=>t("welcome.note")),u(l,pe(Un,{variant:"secondary",onClick:o,"data-testid":"editor-welcome-skip",get children(){return t("welcome.skip")}}),null),u(l,pe(Un,{variant:"primary",onClick:n,"data-testid":"editor-welcome-enable",get children(){return t("welcome.enable")}}),null),e}})}function Kh(e){switch(e){case"dashed":return[Bt(5),Bt(3)];case"dotted":return[Bt(1),Bt(3)];default:return}}async function _h(e,t,n,o,r,a,i,s){const l=t.rotation;l&&(e.saveGraphicsState(n.pageIndex),e.rotateAbout(n.pageIndex,Bt(o+a/2),Bt(r+i/2),l)),function(e,t,n,o,r,a,i){const s=tn(n.shape?.preset,Bt(o),Bt(r),Bt(a),Bt(i)),l=n.shape?.fill,c=n.shape?.borderColor,d=n.shape?.borderWidthPt??(c?.75:0);e.drawPath(t,{segments:s,fill:l,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,s){if(0===t.blocks.length)return;const l=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+l.left,d=r+l.top,u=Math.max(1,a-l.left-l.right),p=Math.max(1,i-l.top-l.bottom),g=Y({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=Yo(n.document);e.saveGraphicsState(n.pageIndex),e.clipRect(n.pageIndex,Bt(c),Bt(d),Bt(u),Bt(p));let m=d;for(const h of g){switch(h.sourceBlock.type){case"paragraph":h.layout&&await s.drawParagraph(e,n.pageIndex,h.sourceBlock,h.layout.lines,n.document,c,m,n.fontRegistry,f,s);break;case"table":await s.drawTableBlock(e,n.pageIndex,h,n.document,c,m,u,n.fontRegistry,f,s);break;default:dr(h.sourceBlock,"block")}m+=Math.max(0,h.estimatedHeight)}e.restoreGraphicsState(n.pageIndex)}(e,t,n,o,r,a,i,s),l&&e.restoreGraphicsState(n.pageIndex)}async function Xh(e){const{writer:t,document:n,fontRegistry:o,pageIndex:r,lines:a,pageSettings:i,contentLeft:s,contentTop:l,contentWidth:c,paragraphTop:d,drawers:u}=e;for(const g of a){const a=new Map(g.slots.map(e=>[e.offset,e]));for(const f of g.fragments){const m=f.textBox;if(!m?.floating)continue;const h=Boolean(m.floating.behindDoc);if(e.layer&&"behind"===e.layer!==h)continue;const b=s+(a.get(f.startOffset)?.left??0),y=d+g.top,v=Ee({object:p(m),pageSettings:i,contentLeft:s,contentTop:l,contentWidth:c,paragraphTop:d,lineTop:y,anchorLeft:b});await _h(t,m,{document:n,fontRegistry:o,pageIndex:r},v.x,v.y,v.width,v.height,u)}}}var Gh=/* @__PURE__ */new WeakMap;function qh(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 Yh(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=qh(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?qh(e):null,!r)return null}const s=i?a.naturalWidth:t,l=i?a.naturalHeight:n;return{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(l)),data:r.data}}async function Zh(e,t,n){const o=Ea(t,n.src);if(!o)return null;let r=Gh.get(e);r||(r=/* @__PURE__ */new Map,Gh.set(e,r));const a=r.get(o);if(a)return a;const i=Yh(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 Jh(e,t,n,o,r,a,i,s){const l=await Zh(e,n,o);if(!l)return;const c=o.intrinsicWidth??o.width,d=o.intrinsicHeight??o.height,u=c/Math.max(1,d),p=i/Math.max(1,s);let g=r,f=a,m=i,h=s;"fit"===o.cropFit&&u>0&&(u>p?(h=i/u,f+=(s-h)/2):(m=s*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,s=n+r/2,l=a*Math.PI/180,c=(e,t)=>({x:i+(e-i)*Math.cos(l)-(t-s)*Math.sin(l),y:s+(e-i)*Math.sin(l)+(t-s)*Math.cos(l)});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}})}(tn(y,r,a,i,s),r,a,i,s,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+s/2,o.rotation??0)),x>0&&e.saveGraphicsState(t),x>0&&e.setOpacity(t,1-Math.min(1,x)),e.drawImage(t,{resourceName:l,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+s/2,I));const C=ke(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:s,stroke:S.color,lineWidth:S.widthPt??1,...C.length>0?{dashArray:C}:{}}),I&&!v&&e.restoreGraphicsState(t)}function Qh(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 eb(e,t,n){const o=Qh(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],s=r.get(i.offset+1);return{left:a.left,right:s?.left??i.left+.55*n}}function tb(e,t,n,o,r,a,i){const s=eb(e,t,n.fontSize??14.6667);return s?{x:Bt(o+s.left),y:Bt(r+e.top+a),width:Bt(Math.max(0,s.right-s.left)),height:Bt(Math.max(2,e.height-i))}:null}function nb(e,t,n,o,r,a,i){const s=i.textFill;if(!s||"gradient"!==s.type||s.stops.length<2)return;const l=eb(n,o,i.fontSize??14.6667);if(!l)return;const c=r+l.left,d=r+l.right,u=a+n.top,p=a+n.top+n.height,g=ie(c,u,d,p,s.angle??0);return e.registerAxialGradient(t,{x0:Bt(g.x0),y0:Bt(g.y0),x1:Bt(g.x1),y1:Bt(g.y1),stops:s.stops.map(e=>({offset:e.position,color:e.color}))})??void 0}function ob(e,t,n,o,r,a,i){const s=at(i),l=(r,i)=>{e.drawLine(t,{x1:Bt(n),y1:Bt(r),x2:Bt(o),y2:Bt(r),stroke:a,lineWidth:Bt(s),dashArray:i})};if(On(i))return l(r-I),void l(r+I);fn(i)?function(e,t,n,o,r,a,i){let s=n,l=r;for(let c=n;c<=o;c+=1){const o=r+Math.sin((c-n)/4*Math.PI)*Ft;e.drawLine(t,{x1:Bt(s),y1:Bt(l),x2:Bt(c),y2:Bt(o),stroke:a,lineWidth:Bt(i)}),s=c,l=o}}(e,t,n,o,r,a,s):l(r,$t(i))}function rb(e,t,n,o,r,a,i){const s=new Map(n.slots.map(e=>[e.offset,e]));for(const l of o.chars){if("\t"!==l.char)continue;const o=s.get(l.paragraphOffset),c=s.get(l.paragraphOffset+1);if(!o||!c)continue;const d=n.resolvedTabs?.[l.paragraphOffset]?.leader;if(!d||c.left<=o.left+2)continue;const u="underscore"===d?a+2:a;e.drawLine(t,{x1:Bt(r+o.left),y1:Bt(u),x2:Bt(r+c.left),y2:Bt(u),stroke:i,lineWidth:Bt("heavy"===d?1.5:1),dashArray:"dot"===d||"middleDot"===d?[1,3]:"hyphen"===d?[5,3]:void 0})}}function ab(e,t){const n=Zr(Ja(e));if(!n)return e;const o=Math.max(0,Math.min(1,t));return qa(255+(n[0]-255)*o,255+(n[1]-255)*o,255+(n[2]-255)*o)}function ib(e,t,n){const{writer:o,pageIndex:r,baselineY:a,fontSizePt:i,mainColor:s,gradientShadingName:l,styles:c,baseTextOptions:d}=e,u=Bt(1);if(c.emboss||c.imprint){const e=c.imprint?1:-1;o.drawText(r,{...d,x:Bt(t)+u*e,y:Bt(a)+u*e,text:n,color:"#BFBFBF"})}if(c.glow){const e=c.glow,i=.5*Bt(e.radiusPt*Ar),s=ab(e.color,.4*(e.alpha??.5)),l=[[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 l)o.drawText(r,{...d,x:Bt(t)+c,y:Bt(a)+u,text:n,color:s})}if(c.textShadow){const e=c.textShadow,i=e.dirDeg*Math.PI/180,s=Bt(e.distPt*Ar);o.drawText(r,{...d,x:Bt(t)+Math.cos(i)*s,y:Bt(a)+Math.sin(i)*s,text:n,color:e.color})}else c.shadow&&o.drawText(r,{...d,x:Bt(t)+u,y:Bt(a)+u,text:n,color:"#808080"});if(c.reflection){const e=c.reflection,l=ab(s,.6*((e.startAlpha+e.endAlpha)/2));o.drawText(r,{...d,x:Bt(t),y:Bt(a)+Bt(e.distPt*Ar)+i,text:n,color:l})}const p=c.textOutline;o.drawText(r,{...d,x:Bt(t),y:Bt(a),text:n,color:s,...l?{gradientShadingName:l}:p?{renderMode:2,strokeColor:p.color??s,strokeWidth:p.widthPt}:{renderMode:c.outline?1:0}})}async function sb(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),s=Ee({object:Po(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 Jh(e.writer,e.pageIndex,e.document,r,Bt(s.x),Bt(s.y),Bt(s.width),Bt(s.height))}}}function lb(e,t,n,o,r,a,i,s){const l=eb(n,o,i.fontSize??14.6667);if(!l)return;const c=a+x(s,n.top,n.height),d=r+l.left,u=r+l.right,p="underline"===s?i.underlineColor??i.color??"#000000":i.color??"#000000";if("strike"!==s)return"doubleStrike"===s?(e.drawLine(t,{x1:Bt(d),y1:Bt(c-Te),x2:Bt(u),y2:Bt(c-Te),stroke:p,lineWidth:Bt(1)}),void e.drawLine(t,{x1:Bt(d),y1:Bt(c+Te),x2:Bt(u),y2:Bt(c+Te),stroke:p,lineWidth:Bt(1)})):void ob(e,t,d,u,c,p,i.underlineStyle);e.drawLine(t,{x1:Bt(d),y1:Bt(c),x2:Bt(u),y2:Bt(c),stroke:p,lineWidth:Bt(1)})}async function cb(e,t,n,r,a,i,s,l,c,d){if(a.opaque){const n=r.slots.find(e=>e.offset===a.startOffset);if(!n)return;const o=s+n.left,i=l+r.top+r.height-a.opaque.height,c=a.opaque.width,d=a.opaque.height;for(const[r,a,s,l]of[[o,i,o+c,i],[o+c,i,o+c,i+d],[o+c,i+d,o,i+d],[o,i+d,o,i],[o,i,o+c,i+d]])e.drawLine(t,{x1:Bt(r),y1:Bt(a),x2:Bt(s),y2:Bt(l),stroke:"#64748b",lineWidth:.75});return}if(a.image){if(a.image.floating)return;const n=r.slots.find(e=>e.offset===a.startOffset)??r.slots.find(e=>e.offset>=a.startOffset);if(!n)return;return void(await Jh(e,t,i,a.image,Bt(s+n.left),Bt(l+r.top+r.height-a.image.height),Bt(a.image.width),Bt(a.image.height)))}if(a.textBox){if(a.textBox.floating)return;const n=r.slots.find(e=>e.offset===a.startOffset)??r.slots.find(e=>e.offset>=a.startOffset);if(!n)return;return void(await _h(e,a.textBox,{document:i,fontRegistry:c,pageIndex:t},s+n.left,l+r.top+r.height-a.textBox.height,a.textBox.width,a.textBox.height,d))}if(a.math){const d=r.slots.find(e=>e.offset===a.startOffset)??r.slots.find(e=>e.offset>=a.startOffset);if(!d)return;const u=Ra(a.styles,n.style?.styleId,i.styles),p=c.resolveFontFace({fontFamily:"Cambria Math",bold:!1,italic:!1});return void e.drawText(t,{x:Bt(s+d.left),y:Bt(l+r.top+r.height*It),text:o(a.math),fontSize:to(u),color:u.color??"#000000",fontResourceName:p.writerResourceName})}const u=Ra(a.styles,n.style?.styleId,i.styles);if(u.hidden)return;const p=c.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=to(u),f=(u.baselineShift??0)*Ar,m=Xr(n.style,i.styles),h=ao(m.textAlignment,u.fontSize??14.6667,r.height),b=l+r.top+r.height*It-f+h,y=Qh(r,a),v=y.map(e=>jn(e.char,u)).join("");if(0===y.length||0===v.length)return void rb(e,t,r,a,s,b,u.color??"#000000");!function(e,t,n,o,r,a,i){if(!i.link)return;const s=eb(n,o,i.fontSize??14.6667);if(!s||s.right<=s.left)return;const l=i.link.startsWith("#");e.addLinkAnnotation(t,{x:Bt(r+s.left),y:Bt(a+n.top),width:Bt(s.right-s.left),height:Bt(n.height),...l?{destName:i.link.slice(1)}:{uri:i.link}})}(e,t,r,a,s,l,u),function(e,t,n,o,r,a,i){if(!i.shading)return;const s=tb(n,o,i,r,a,2,4);s&&e.drawRect(t,{...s,fill:i.shading})}(e,t,r,a,s,l,u),function(e,t,n,o,r,a,i){if(!i.highlight)return;const s=tb(n,o,i,r,a,2,4);s&&e.drawRect(t,{...s,fill:i.highlight})}(e,t,r,a,s,l,u),function(e,t,n,o,r,a,i){const s=i.textBorder;if(!s||"none"===s.type||s.width<=0)return;const l=tb(n,o,i,r,a,1,2);l&&e.drawRect(t,{...l,stroke:s.color,lineWidth:Bt(Math.max(.5,s.width*Ar))})}(e,t,r,a,s,l,u),rb(e,t,r,a,s,b,u.color??"#000000");const x=Xr(n.style,i.styles).align??"left",w=Vt(u,to(u)),S={fontSize:g,bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName,characterSpacing:u.characterSpacing??0,horizontalScale:u.characterScale??100,fontFeatures:w};!function(e,t,n,o,r,a,i){const s="justify"===i?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=[])," "!==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 l of s){let t=[],r=!1;const a=()=>{if(0===t.length)return;const a=t.map(e=>jn(e.char,o)).join("");if(a.length>0){const o=r?.8*e.fontSizePt:e.fontSizePt;ib({...e,fontSizePt:o,baseTextOptions:{...e.baseTextOptions,fontSize:o}},n+t[0].left,a)}t=[]};for(const e of l){const n=Boolean(o.smallCaps&&Sn(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&&ib(e,n+t.left,"-")}}({writer:e,pageIndex:t,baselineY:b,fontSizePt:g,mainColor:"solid"===u.textFill?.type?u.textFill.color:"gradient"===u.textFill?.type&&u.textFill.stops[0]?u.textFill.stops[0].color:u.color??"#000000",gradientShadingName:nb(e,t,r,a,s,l,u),styles:u,baseTextOptions:S},y,s,u,r,a,x),u.underline&&lb(e,t,r,a,s,l,u,"underline"),u.strike&&lb(e,t,r,a,s,l,u,"strike"),u.doubleStrike&&lb(e,t,r,a,s,l,u,"doubleStrike"),u.emphasisMark&&function(e,t,n,o,r,a,i){const s=i.emphasisMark;if(!s||"none"===s)return;const l=Tt[s];if(!l)return;const c=Qh(n,o),d="underDot"===s,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],s=a?(o.left+a.left)/2:o.left+.25*n.height;e.drawText(t,{x:Bt(r+s-.25*u),y:Bt(p),text:l,fontSize:Bt(u),color:i.color??"#000000"})}}(e,t,r,a,s,l,u)}function db(e,t,n,o,r,a,i,s,l){if(0!==o.index)return;const c=ir(n,l);if(!c)return;const d=o.slots[0];if(!d)return;const u=Ra(void 0,n.style?.styleId,r.styles),p=s.resolveFontFace({fontFamily:u.fontFamily,bold:u.bold,italic:u.italic}),g=ge(n,r.styles),f=to(u),m=c.length*f*.62*Ar,h=tt(n,r.styles,d.left,m);e.drawText(t,{x:Bt(a+Math.max(0,h||g)),y:Bt(i+o.top+o.height*It),text:c,fontSize:f,color:u.color??"#000000",bold:u.bold,italic:u.italic,fontResourceName:p.writerResourceName})}function ub(e,t,n,o,r,a,i){const s=[[n.borderTop,"top"],[n.borderRight,"right"],[n.borderBottom,"bottom"],[n.borderLeft,"left"]],l=s.some(([e])=>e&&"none"!==e.type&&e.width>0)||null!=n.borderBar&&"none"!==n.borderBar.type&&n.borderBar.width>0;if(!n.shading&&!l)return;let c=0;for(const h of o)c=Math.max(c,h.top+h.height);if(c<=0)return;const d=Pt(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:Bt(p),y:Bt(a),width:Bt(Math.max(0,g-p)),height:Bt(u),fill:n.shading});for(const[h,b]of s){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:Bt(n),y1:Bt(o),x2:Bt(r),y2:Bt(i),stroke:h.color,lineWidth:h.width,dashArray:Kh(h.type)})}const m=n.borderBar;m&&"none"!==m.type&&m.width>0&&e.drawLine(t,{x1:Bt(p),y1:Bt(a),x2:Bt(p),y2:Bt(f),stroke:m.color,lineWidth:m.width,dashArray:Kh(m.type)})}async function pb(e,t,n,o,r,a,i,s,l,c){for(const d of o){for(const n of d.barTabPositionsPx??[])e.drawLine(t,{x1:Bt(a+n),y1:Bt(i+d.top),x2:Bt(a+n),y2:Bt(i+d.top+d.height),stroke:"#000000",lineWidth:Bt(1)});db(e,t,n,d,r,a,i,s,l);for(const o of d.fragments)await cb(e,t,n,d,o,r,a,i,s,c)}}function gb(e,t,n,o,r,a,i){"none"===n.type||n.width<=0||e.drawLine(t,{x1:Bt(o),y1:Bt(r),x2:Bt(a),y2:Bt(i),stroke:n.color,lineWidth:Bt(n.width),dashArray:Kh(n.type)})}function fb(e,t,n,o,r){const a=o+n.left,i=r+n.top,s=a+n.width,l=i+n.height;gb(e,t,n.borders.top,a,i,s,i),gb(e,t,n.borders.right,s,i,s,l),gb(e,t,n.borders.bottom,a,l,s,l),gb(e,t,n.borders.left,a,i,a,l),n.borders.topLeftToBottomRight&&gb(e,t,n.borders.topLeftToBottomRight,a,i,s,l),n.borders.topRightToBottomLeft&&gb(e,t,n.borders.topRightToBottomLeft,s,i,a,l)}async function mb(e,t,n,o,r,a,i,s,l,c){if("table"!==n.sourceBlock.type)return;const d=n.sourceBlock,u=n.tableSegment?da(d,n.tableSegment):d;if(0===u.rows.length)return;const p=Q({table:u,state:{document:o},pageIndex:0,originX:0,originY:0,contentWidth:i,estimatedHeight:n.estimatedHeight});for(const g of p.cells)g.shading&&e.drawRect(t,{x:Bt(r+g.left),y:Bt(a+g.top),width:Bt(g.width),height:Bt(g.height),fill:g.shading});for(const g of p.cells)if(fb(e,t,g,r,a),g.revision){const n="insert"===g.revision.type?"#059669":"delete"===g.revision.type?"#dc2626":"#d97706";e.drawRect(t,{x:Bt(r+g.left+1),y:Bt(a+g.top+1),width:Bt(Math.max(0,g.width-2)),height:Bt(Math.max(0,g.height-2)),stroke:n,lineWidth:Bt(2)})}for(const g of p.cells)for(const n of g.paragraphs)await pb(e,t,n.paragraph,n.lines,o,r+n.originX,a+n.originY,s,l,c)}var hb={drawParagraph:pb,drawTableBlock:mb};async function bb(e,t,n,o,r,a,i,s,l,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=Xr(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+Pt(n).top;ub(e,t,n,f.layout.lines,r,g,i),c&&(await sb({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"behind"}),await Xh({writer:e,document:o,fontRegistry:s,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:hb,layer:"behind"})),await pb(e,t,f.sourceBlock,f.layout.lines,o,r,m,s,l,hb),c&&(await sb({writer:e,pageIndex:t,lines:f.layout.lines,document:o,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:m,layer:"front"}),await Xh({writer:e,document:o,fontRegistry:s,pageIndex:t,lines:f.layout.lines,pageSettings:c,contentLeft:r,contentTop:u,contentWidth:i,paragraphTop:g,drawers:hb,layer:"front"}));break}case"table":if(f.sourceBlock.style?.floating&&c){const n=oe(f.sourceBlock,i),a=B({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 mb(e,t,{...f,estimatedHeight:a.height},o,a.x,a.y,i,s,l,hb);break}await mb(e,t,f,o,r,p,i,s,l,hb);break;default:dr(f.sourceBlock,"block")}if("paragraph"===f.sourceBlock.type&&f.layout){const s=n[g+1];if("paragraph"===s?.sourceBlock.type&&s.layout&&s.sourceBlock.id!==f.sourceBlock.id){const n=Xr(f.sourceBlock.style,o.styles),l=Xr(s.sourceBlock.style,o.styles);if(Lt(n,l)){const o=p+(0===f.layout.startOffset&&p>a?n.spacingBefore??0:0)+Pt(n).top;let s=0;for(const e of f.layout.lines)s=Math.max(s,e.top+e.height);const l=o+s,c=r+(n.indentLeft??0),d=r+i-(n.indentRight??0),u=n.borderBetween;e.drawLine(t,{x1:Bt(c),y1:Bt(l),x2:Bt(d),y2:Bt(l),stroke:u.color,lineWidth:u.width,dashArray:Kh(u.type)})}}}p+=Math.max(0,f.estimatedHeight)}}async function yb(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 s=r?.watermark;if("text"===s?.kind&&s.text)e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawText(t,{x:n/2,y:o/2,text:s.text,fontSize:s.fontSize??48,color:s.color??"#94a3b8"}),e.restoreGraphicsState(t);else if("image"===s?.kind&&s.src&&i){const r={src:s.src,width:360,height:180},a=await Zh(e,i,r);if(a){const i=s.scale??1,l=r.width*i,c=r.height*i;e.saveGraphicsState(t),e.rotateAbout(t,n/2,o/2,s.rotation??-45),e.setOpacity(t,s.opacity??.25),e.drawImage(t,{resourceName:a,x:(n-l)/2,y:(o-c)/2,width:l,height:c}),e.restoreGraphicsState(t)}}}var vb=[{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 xb(e,t,n){return`${e.toLowerCase()}:${t?"bold":"regular"}${n?"italic":""}`}function wb(e){return e.replace(/[^A-Za-z0-9_]/g,"")}var Sb=class{faces=/* @__PURE__ */new Map;fallbackFamily="Helvetica";constructor(){for(const e of vb)this.registerFontFace(e)}registerFontFace(e){this.faces.set(xb(e.family,e.bold,e.italic),e)}resolveFontFace(e){const t=Io(e.fontFamily),n=Boolean(e.bold),o=Boolean(e.italic);return this.faces.get(xb(t,n,o))??this.faces.get(xb(this.fallbackFamily,n,o))??this.faces.get(xb(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(Io).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(st)){const e=await uo(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 Zt(e.families);for(const n of t){const e=`Remote${wb(n.postscriptName||n.family)}`;this.registerFontFace({key:xb(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 Wt){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 uo(t);if(!o)continue;const a="bold"===e||"bolditalic"===e,i="italic"===e||"bolditalic"===e,s=`${wb(n.family)}${e[0].toUpperCase()}${e.slice(1)}`,l={key:`${n.family.toLowerCase()}:${e}`,family:n.family,bold:a,italic:i,writerResourceName:s,pdfResource:{kind:"unicode",resourceName:s,family:n.family,fontData:o}};this.registerFontFace(l),r.push(l)}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}},Ib="%PDF-1.4\n% Oasis PDF\n",Cb=[{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 Tb(e){return Number.isFinite(e)?Number(e.toFixed(3)).toString():"0"}function kb(e){return Math.max(0,e).toString(16).padStart(4,"0").slice(-4).toUpperCase()}function Pb(e,t){if(!e)return t;const n=Zr(Ja(e));return n?[n[0]/255,n[1]/255,n[2]/255]:t}function Rb(e,t,n){const[o,r,a]=Pb(e,n);return`${Tb(o)} ${Tb(r)} ${Tb(a)} ${t}`}function Mb(e,t){return(e&&e.trim().length>0?e:t).replaceAll(" ","_").replace(/[^A-Za-z0-9_.+-]/g,"")}var Ob=/* @__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 Ab(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:Ob.get(t)??63}(e).toString(16).padStart(2,"0").toUpperCase()).join("")}function Bb(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(kb).join("")}function Db(e,t=[]){const n=new TextEncoder,o=n.encode(["<< /Length "+e.byteLength,...t,">>"].join(" ")+"\nstream\n"),r=n.encode("\nendstream"),a=new Uint8Array(o.length+e.length+r.length);return a.set(o),a.set(e,o.length),a.set(r,o.length+e.length),a}function Fb(e,t=[]){return Db(Se(e,{level:9}),["/Filter /FlateDecode",...t])}function Eb(e,t){const n=[...new Set(t)].sort((e,t)=>e-t),o=[];let r=-1,a=-2,i=[];const s=()=>{i.length&&o.push(r+" ["+i.join(" ")+"]")};for(const l of n)(l!==a+1||r<0)&&(s(),r=l,i=[]),i.push(Tb(e[l]??0)),a=l;return s(),o.join(" ")}function Lb(e){return kb(e)}function Nb(e){return`% OasisText ${Bb(Array.from(e).map(e=>e.codePointAt(0)??65533))}`}function zb(e){return e&&0!==e.length?`[${e.map(e=>Tb(e)).join(" ")}] 0 d`:null}var $b=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(Rb(e.fill,"rg",[1,1,1])),e.stroke){n.push(Rb(e.stroke,"RG",[0,0,0])),n.push(`${Tb(e.lineWidth??1)} w`);const t=zb(e.dashArray);t&&n.push(t)}n.push([Tb(e.x),Tb(t.height-e.y-e.height),Tb(e.width),Tb(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=zb(e.dashArray),o=["q",Rb(e.stroke,"RG",[0,0,0])];n&&o.push(n),o.push(`${Tb(e.lineWidth??1)} w`,`${Tb(e.x1)} ${Tb(t.height-e.y1)} m`,`${Tb(e.x2)} ${Tb(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(Rb(e.fill,"rg",[1,1,1])),e.stroke&&(o.push(Rb(e.stroke,"RG",[0,0,0])),o.push(`${Tb(e.lineWidth??1)} w`));for(const r of e.segments)switch(r.type){case"move":o.push(`${Tb(r.x)} ${Tb(n(r.y))} m`);break;case"line":o.push(`${Tb(r.x)} ${Tb(n(r.y))} l`);break;case"cubic":o.push(`${Tb(r.x1)} ${Tb(n(r.y1))} ${Tb(r.x2)} ${Tb(n(r.y2))} ${Tb(r.x)} ${Tb(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),s=Math.sin(a),l=e-e*i+r*s,c=r-e*s-r*i;o.commands.push(`${Tb(i)} ${Tb(s)} ${Tb(-s)} ${Tb(i)} ${Tb(l)} ${Tb(c)} cm`)}clipRect(e,t,n,o){const r=this.page;n<=0||o<=0||r.commands.push(`${Tb(e)} ${Tb(r.height-t-o)} ${Tb(n)} ${Tb(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(`${Tb(r.x)} ${Tb(n(r.y))} m`);break;case"line":o.push(`${Tb(r.x)} ${Tb(n(r.y))} l`);break;case"cubic":o.push(`${Tb(r.x1)} ${Tb(n(r.y1))} ${Tb(r.x2)} ${Tb(n(r.y2))} ${Tb(r.x)} ${Tb(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):`<${Ab(e.text)}> Tj`;null!==o&&(e.gradientShadingName?this.emitGradientTextBlock(t,o,e,e.gradientShadingName):this.emitTextBlock(t,o,e))}textSetupCommands(e,t){return[`/${e} ${Tb(t.fontSize??12)} Tf`,...t.horizontalScale&&t.horizontalScale>0&&100!==t.horizontalScale?[`${Tb(t.horizontalScale)} Tz`]:[],...t.characterSpacing&&0!==t.characterSpacing?[`${Tb(t.characterSpacing)} Tc`]:[]]}emitTextBlock(e,t,n){const o=this.page;o.commands.push([Nb(n.text),"BT",Rb(n.color,"rg",[0,0,0]),...n.renderMode&&0!==n.renderMode?[Rb(n.strokeColor??n.color,"RG",[0,0,0]),`${Tb(n.strokeWidth??Math.max(.3,.03*(n.fontSize??12)))} w`,`${n.renderMode} Tr`]:[],...this.textSetupCommands(e,n),`${Tb(n.x)} ${Tb(o.height-n.y)} Td`,t,"ET"].join("\n"))}emitGradientTextBlock(e,t,n,o){const r=this.page;r.commands.push([Nb(n.text),"q","BT",...this.textSetupCommands(e,n),"7 Tr",`${Tb(n.x)} ${Tb(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,s=r?.right??0,l=r?.bottom??0;if(r&&(a>0||i>0||s>0||l>0))return void this.drawCroppedImage(e,n,o,{left:a,top:i,right:s,bottom:l});if(0===o)return void t.commands.push(["q",[Tb(e.width),"0","0",Tb(e.height),Tb(e.x),Tb(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",[Tb(p),Tb(g),Tb(f),Tb(m),Tb(h),Tb(b),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}drawCroppedImage(e,t,n,o){const r=this.page,{width:a,height:i}=e,s=a/Math.max(1e-4,1-o.left-o.right),l=i/Math.max(1e-4,1-o.top-o.bottom),c=-o.left*s,d=-o.bottom*l,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",[Tb(h),Tb(b),Tb(y),Tb(v),Tb(x),Tb(w),"cm"].join(" "),`0 0 ${Tb(a)} ${Tb(i)} re W n`,[Tb(s),"0","0",Tb(l),Tb(c),Tb(d),"cm"].join(" "),`/${e.resourceName} Do`,"Q"].join("\n"))}};function Hb(e,t,n){if(e.seek(t),1!==e.u16())return null;const o=e.u16();return n(e,t+e.u32(),o)}function Wb(e,t){const n=new Array(t);for(let o=0;o<t;o+=1)n[o]=e.u16();return n}function Ub(e,t,n){const o=new Array(t);for(let r=0;r<t;r+=1)o[r]=n+e.u16();return o}function jb(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 Vb(e,t){e.seek(t);const n=e.u16();if(1===n){const t=e.u16(),n=e.u16(),o=Wb(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 Kb(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:Wb(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(),s=e.u16(),l=[];65535!==i&&l.push(i);for(let c=0;c<s;c+=1)l.push(e.u16());return l}(e,t),i=/* @__PURE__ */new Map;for(const s of a){const e=r[s];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 _b(e,t,n){return e.seek(t),Ub(e,e.u16(),t).map(t=>{e.seek(t);const o=e.u16();e.skip(2);const r=Ub(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 Xb(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 Gb(e,t){if(e.seek(t),1!==e.u16())return null;const n=t+e.u16(),o=e.u16(),r=Ub(e,o,t).map(t=>(e.seek(t),Wb(e,e.u16())));return{coverage:jb(e,n),sets:r}}function qb(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 Yb(e,t,n,o){for(const r of n)o.applyLookupIndexAt(r.lookupListIndex,e,t+r.sequenceIndex)}function Zb(e,t){e.seek(t);const n=e.u16();return Ub(e,n,t).map(t=>(e.seek(t),{backtrack:Wb(e,e.u16()),input:Wb(e,Math.max(0,e.u16()-1)),lookahead:Wb(e,e.u16()),records:qb(e,e.u16())}))}function Jb(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 Yb(t,n,i.records,o),e}}}return null}function Qb(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=jb(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=Wb(e,t),r=jb(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=Gb(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 s=n.codePoints,l=i.map((e,t)=>({id:e,codePoints:0===t?s:[]}));return e.splice(t,1,...l),i.length}}}(e,t);case 3:return function(e,t){const n=Gb(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=Ub(e,o,t).map(t=>(e.seek(t),Ub(e,e.u16(),t).map(t=>{e.seek(t);const n=e.u16(),o=e.u16();return{ligatureGlyph:n,components:Wb(e,Math.max(0,o-1))}}))),a=jb(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=Ub(e,e.u16(),t),o=Ub(e,e.u16(),t),r=Ub(e,e.u16(),t),a=qb(e,e.u16()),i=n.map(t=>jb(e,t)),s=o.map(t=>jb(e,t)),l=r.map(t=>jb(e,t));return{apply(e,t,n){if(0===s.length)return null;if(t+s.length>e.length)return null;for(let o=0;o<s.length;o+=1)if(s[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<l.length;o+=1){const n=e[t+s.length+o];if(!n||l[o](n.id)<0)return null}return Yb(e,t,a,n),s.length}}}if(1===n){const n=t+e.u16(),o=e.u16(),r=Ub(e,o,t),a=jb(e,n),i=r.map(t=>Zb(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:Jb(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(),s=new Array(i);for(let g=0;g<i;g+=1){const n=e.u16();s[g]=0===n?0:t+n}const l=jb(e,n),c=Vb(e,o),d=Vb(e,r),u=Vb(e,a),p=s.map(t=>0===t?[]:Zb(e,t));return{apply(e,t,n){const o=e[t];if(!o)return null;if(l(o.id)<0)return null;const r=d(o.id),a=p[r];return a?Jb(a,e,t,n,{backtrack:c,input:d,lookahead:u}):null}}}return null}(e,t);case 7:return Hb(e,t,Qb);default:return null}}var ey=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new qn(t),{featureToLookups:o,lookupListOffset:r}=Kb(n),a=_b(n,r,Qb);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}collectLookupIndices(e){return Xb(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 ty(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 ny(e){let t=0;for(let n=0;n<8;n+=1)e&1<<n&&(t+=1);return 2*t}function oy(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=ty(e,e.u16()),n=jb(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=ny(t),a=e.tell(),i=new Array(n);for(let o=0;o<n;o+=1)e.seek(a+o*r),i[o]=ty(e,t);const s=jb(e,o);return{apply(e,t,o){const r=s(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(),s=Ub(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=ty(e,r),i=ty(e,a);o.set(t,{secondGlyph:t,value1XAdvance:n,value2XAdvance:i})}return o}),l=jb(e,o);return{apply(e,t,n){const o=e[n+1];if(void 0===o)return null;const r=l(e[n]);if(r<0||r>=s.length)return null;const a=s[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(),s=t+e.u16(),l=e.u16(),c=e.u16(),d=ny(r),u=d+ny(a),p=e.tell(),g=new Array(l*c),f=new Array(l*c);for(let t=0;t<l;t+=1)for(let n=0;n<c;n+=1){const o=(t*c+n)*u;e.seek(p+o),g[t*c+n]=ty(e,r),e.seek(p+o+d),f[t*c+n]=ty(e,a)}const m=jb(e,o),h=Vb(e,n),b=Vb(e,s);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),s=b(r);if(a>=l||s>=c)return null;const d=a*c+s,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 Hb(e,t,oy);default:return null}}var ry=class e{lookups;featureToLookups;constructor(e,t){this.lookups=e,this.featureToLookups=t}static parse(t){try{const n=new qn(t),{featureToLookups:o,lookupListOffset:r}=Kb(n),a=_b(n,r,oy);return new e(a,o)}catch{return null}}hasAnyFeature(e){return e.some(e=>this.featureToLookups.has(e))}position(e,t,n){const o=Xb(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}}}},ay=/* @__PURE__ */new Set(["kern"]),iy=class{font;gsub;gpos;constructor(e){this.font=e;const t=e.getRawTableData("GSUB");this.gsub=t?ey.parse(t):null;const n=e.getRawTableData("GPOS");this.gpos=n?ry.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=>!ay.has(e))??[],r=t?.filter(e=>ay.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=[],s=[];let l=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}),s.push({xAdvance:o}),l+=o}return{glyphs:i,positions:s,advanceWidth:l}}},sy=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 ly(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function cy(e,t){return ly(e).getUint16(t)}function dy(e,t){return ly(e).getInt16(t)}function uy(e,t,n){ly(e).setUint16(t,n,!1)}function py(e,t,n){ly(e).setUint32(t,n,!1)}function gy(e){return e+3&-4}function fy(e){const t=e.reduce((e,t)=>e+gy(t.byteLength),0),n=new Uint8Array(t);let o=0;for(const r of e)n.set(r,o),o+=gy(r.byteLength);return n}function my(e,t){const n=[],o=ly(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 hy(e,t){const n=e[t],o=e[t+1];return void 0===n||void 0===o?null:{start:n,end:o}}function by(e,t){if(e.byteLength<10||dy(e,0)>=0)return;let n=10,o=0;do{if(n+4>e.byteLength)throw new Error("Truncated composite glyph");o=cy(e,n),t(cy(e,n+2),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 yy(e,t,n){const o=/* @__PURE__ */new Map;for(const h of t.values())for(const t of h){if(!Number.isInteger(t)||t<=0||t>1114111||t>=55296&&t<=57343)continue;const r=n.get(e.glyphForCodePoint(t));r&&o.set(t,r)}const r=[...o].sort(([e],[t])=>e-t),a=[];for(const[h,b]of r){const e=a[a.length-1];e&&h===e.end+1&&b===e.gid+h-e.start?e.end=h:a.push({start:h,end:h,gid:b})}const i=new Uint8Array(16+12*a.length);uy(i,0,12),py(i,4,i.length),py(i,12,a.length),a.forEach((e,t)=>{const n=16+12*t;py(i,n,e.start),py(i,n+4,e.end),py(i,n+8,e.gid)});const s=a.filter(e=>e.start<65535).map(e=>({...e,end:Math.min(e.end,65534)}));s.push({start:65535,end:65535,gid:0});const l=s.length,c=16+8*l,d=c<=65535?new Uint8Array(c):null;if(d){const e=2**Math.floor(Math.log2(l));uy(d,0,4),uy(d,2,c),uy(d,6,2*l),uy(d,8,2*e),uy(d,10,Math.log2(e)),uy(d,12,2*l-2*e),s.forEach((e,t)=>{uy(d,14+2*t,e.end),uy(d,16+2*l+2*t,e.start),uy(d,16+4*l+2*t,e.gid-e.start&65535)})}if(d&&r.every(([e])=>e<65535)){const e=new Uint8Array(12+d.length);return uy(e,2,1),uy(e,4,3),uy(e,6,1),py(e,8,12),e.set(d,12),e}const u=d?2:1,p=4+8*u,g=new Uint8Array(p+(d?.length??0)+i.length);uy(g,2,u),d&&(uy(g,4,3),uy(g,6,1),py(g,8,p),g.set(d,p));const f=d?12:4,m=p+(d?.length??0);return uy(g,f,3),uy(g,f+2,10),py(g,f+4,m),g.set(i,m),g}function vy(e,t,n,o){const r=e.getRawTableData("glyf"),a=e.getRawTableData("loca"),i=e.getRawTableData("head"),s=e.getRawTableData("hhea"),l=e.getRawTableData("maxp");if(!(r&&a&&i&&s&&l))throw new Error("Missing required TrueType tables for subsetting");const c=my(a,cy(i,50)),d=[],u=[];let p=0;for(const x of t){d.push(p);const e=hy(c,x);if(!e||e.end<e.start||e.end>r.length)throw new Error("Invalid glyph range");if(e.end===e.start)continue;const t=r.slice(e.start,e.end);by(t,(e,o)=>{const r=n.get(e);if(void 0===r)throw new Error("Missing composite dependency");uy(t,o,r)}),u.push(t),p+=gy(t.length)}d.push(p);const g=function(e){const t=e.every(e=>e%2==0&&e<=131070),n=new Uint8Array(e.length*(t?2:4));return e.forEach((e,o)=>{t?uy(n,2*o,e/2):py(n,4*o,e)}),{data:n,format:t?0:1}}(d),f=function(e,t,n){const o=e.getRawTableData("hmtx"),r=cy(n,34);if(!o||r<1||r>e.glyphCount)throw new Error("Invalid source hmtx");const a=t.map(t=>e.advanceWidthForGlyph(t));let i=a.length;for(;i>1&&a[i-1]===a[i-2];)i--;const s=new Uint8Array(4*i+2*(t.length-i));return t.forEach((e,t)=>{const n=e<r?4*e+2:4*r+2*(e-r),l=t<i?4*t+2:4*i+2*(t-i);t<i&&uy(s,4*t,a[t]),ly(s).setInt16(l,dy(o,n))}),{data:s,longCount:i}}(e,t,s),m=i.slice();py(m,8,0),uy(m,50,g.format);const h=s.slice();uy(h,34,f.longCount);const b=l.slice();uy(b,4,t.length);const y={cmap:yy(e,o,n),head:m,hhea:h,maxp:b,hmtx:f.data,loca:g.data,glyf:fy(u)};for(const x of["OS/2","name","cvt ","fpgm","prep","gasp"]){const t=e.getRawTableData(x);t&&(y[x]=t)}const v=e.getRawTableData("post");return v&&v.length>=32&&(y.post=v.slice(0,32),py(y.post,0,196608)),y}var xy=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=my(o,cy(r,50)),i=/* @__PURE__ */new Set([0,...t]),s=Array.from(i);for(;s.length>0;){const t=s.pop(),o=hy(a,t);if(!o||t>=e.glyphCount||o.end<o.start||o.end>n.byteLength)throw new Error("Invalid subset glyph range");o.end!==o.start&&by(n.slice(o.start,o.end),e=>{i.has(e)||(i.add(e),s.push(e))})}return Array.from(i).sort((e,t)=>e-t)}(e,o),a=new Map(r.map((e,t)=>[e,t])),i=vy(e,r,a,n),s=yo(65536,new Map(Object.entries(i).map(([e,t])=>[e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3),t]))).ttf,l=[],c=[];for(const d of r)l[d]=e.advanceWidthForGlyph(d)/e.unitsPerEm*1e3,c[d]=n.get(d)??[0];return{fontFile:s,widths:l,unicode:c,encodeGlyph:e=>a.get(e)??0}}};var wy=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 iy(e);return{program:e,layouter:t.hasShaping?t:new sy(e),subsetter:new xy}}(function(e){const t=yt.decodeSync(e);return Pn.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?`<${Lb(e.glyphId)}>`:`<${Lb(e.glyphId)}> ${Tb(t)}`}).join(" ")}] TJ`:`<${r.map(e=>Lb(e.glyphId)).join("")}> Tj`}buildFontObjects(e){const t=Array.from(this.fontResources.values()).filter(e=>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=n.fontFile,r=t(Fb(o,[`/Length1 ${o.byteLength}`])),a=e.font.program.metadata,i=a.familyClass>>8||0;let s=4;a.isFixedPitch&&(s|=1),i>=1&&i<=7&&(s|=2),10===i&&(s|=8),a.macStyleItalic&&(s|=64);const l=`${Mb(`${e.resource.resourceName}AAAAAA`,"OASISF").slice(0,6).padEnd(6,"A")}+${Mb(a.postscriptName,e.resource.family)}`,c=a.bbox,d=t(["<< /Type /FontDescriptor",`/FontName /${l}`,`/Flags ${s}`,`/FontBBox [${[c.minX*e.scale,c.minY*e.scale,c.maxX*e.scale,c.maxY*e.scale].map(Tb).join(" ")}]`,`/ItalicAngle ${Tb(a.italicAngle)}`,`/Ascent ${Tb(a.ascent*e.scale)}`,`/Descent ${Tb(a.descent*e.scale)}`,`/CapHeight ${Tb(a.capHeight*e.scale)}`,`/XHeight ${Tb(a.xHeight*e.scale)}`,"/StemV 0",`/FontFile2 ${r} 0 R`,">>"].join("\n")),u=[...e.usedGlyphs.keys()],p=Math.max(0,...u),g=new Uint8Array(2*(p+1)),f=new DataView(g.buffer);for(const v of u)f.setUint16(2*v,n.encodeGlyph(v));const m=u.every(e=>n.encodeGlyph(e)===e)?"/Identity":t(Fb(g))+" 0 R",h=t(["<< /Type /Font","/Subtype /CIDFontType2",`/BaseFont /${l}`,"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>",`/FontDescriptor ${d} 0 R`,`/W [${Eb(n.widths,e.usedGlyphs.keys())}]`,`/CIDToGIDMap ${m}`,">>"].filter(Boolean).join("\n")),b=function(e){const t=[...e].filter(([e,t])=>e>=0&&e<=65535&&t.length>0).sort(([e],[t])=>e-t).map(([e,t])=>"<"+kb(e)+"> <"+Bb([...t])+">"),n=[];for(let o=0;o<t.length;o+=100){const e=t.slice(o,o+100);n.push(e.length+" beginbfchar",...e,"endbfchar")}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,"endcmap","CMapName currentdict /CMap defineresource pop","end","end",""].join("\n")}(new Map([...e.usedGlyphs].map(([e,t])=>[e,t.codePoints]))),y=t(Fb((new TextEncoder).encode(b)));return t(["<< /Type /Font","/Subtype /Type0",`/BaseFont /${l}`,"/Encoding /Identity-H",`/DescendantFonts [${h} 0 R]`,`/ToUnicode ${y} 0 R`,">>"].join("\n"))}},Sy=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(Db(e.data,["/Filter /DCTDecode","/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,"/ColorSpace /DeviceRGB","/BitsPerComponent 8"]))}},Iy=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 Cy(e[0].rgb,e[1].rgb);const t=[];for(let r=0;r<e.length-1;r+=1)t.push(Cy(e[r].rgb,e[r+1].rgb));const n=e.slice(1,-1).map(e=>Tb(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:Pb(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(Tb).join(" ")}]`,"/Domain [0 1]",`/Function ${n} 0 R`,"/Extend [true true]",">>"].join("\n"))}};function Cy(e,t){return["<< /FunctionType 2","/Domain [0 1]",`/C0 [${e.map(Tb).join(" ")}]`,`/C1 [${t.map(Tb).join(" ")}]`,"/N 1",">>"].join("\n")}var Ty=new TextEncoder;function ky(e){return"string"==typeof e?(t=e,(new TextEncoder).encode(t).byteLength):e.length;var t}function Py(e){return Fb(Ty.encode(e))}function Ry(e){return e.replace(/[\\()]/g,e=>`\\${e}`)}function My(e){return`<FEFF${Bb(Array.from(e).map(e=>e.codePointAt(0)??63))}>`}function Oy(e){const t=[];if(e.title&&t.push(`/Title ${My(e.title)}`),e.author&&t.push(`/Author ${My(e.author)}`),e.subject&&t.push(`/Subject ${My(e.subject)}`),e.keywords&&t.push(`/Keywords ${My(e.keywords)}`),e.producer&&t.push(`/Producer (${Ry(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 Ay(e){return e.children.reduce((e,t)=>e+1+Ay(t),0)}function By(e,t,n,o,r=[],a=[],i){const s=[],l=e=>{const t=s.length+1;return s.push({id:t,body:e}),t},c=l(""),d=l(""),{resourceXml:u}=t.buildFontObjects(l),p=n.buildImageObjects(l),g=o.buildShadingObjects(l),f=/* @__PURE__ */new Map;for(const M of e)for(const[e,t]of M.graphicsStateOpacities??[])f.has(e)||f.set(e,l(`<< /Type /ExtGState /ca ${Tb(t)} /CA ${Tb(t)} >>`));const m=[];for(const M of e){const e=l(Py(`${M.commands.join("\n")}\n`)),t=Array.from(M.imageResourceNames).map(e=>{const t=p.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),n=t?` /XObject << ${t} >>`:"",o=Array.from(M.shadingResourceNames).map(e=>{const t=g.get(e);return t?`/${e} ${t} 0 R`:""}).filter(Boolean).join(" "),r=o?` /Shading << ${o} >>`:"",a=Array.from(M.graphicsStateOpacities?.keys()??[]).map(e=>`/${e} ${f.get(e)} 0 R`).join(" "),i=a?` /ExtGState << ${a} >>`:"",s=M.annotations.map(e=>{const t=e.x,n=e.x+e.width,o=M.height-e.y-e.height,r=M.height-e.y,a=void 0!==e.destName?`/A << /Type /Action /S /GoTo /D (${Ry(e.destName)}) >>`:`/A << /Type /Action /S /URI /URI (${Ry(e.uri??"")}) >>`;return l(["<< /Type /Annot /Subtype /Link",`/Rect [${Tb(t)} ${Tb(o)} ${Tb(n)} ${Tb(r)}]`,"/Border [0 0 0]",a,">>"].join("\n"))}),c=s.length>0?`\n/Annots [${s.map(e=>`${e} 0 R`).join(" ")}]`:"",h=l(["<< /Type /Page",`/Parent ${d} 0 R`,`/MediaBox [0 0 ${Tb(M.width)} ${Tb(M.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=l(`<< /Dests ${l(`<< /Names [${b.map(t=>{const n=m[t.pageIndex],o=e[t.pageIndex].height-t.y;return`(${Ry(t.name)}) [${n} 0 R /XYZ ${Tb(t.x)} ${Tb(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=l("");const e=t=>t.map(t=>{const n=l("");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,l=r<e.length-1?e[r+1]:void 0,c=["<< /Title "+My(o.title),`/Parent ${t} 0 R`,i?`/Prev ${i.id} 0 R`:"",l?`/Next ${l.id} 0 R`:"",`/Dest (${Ry(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 ${Ay(o)}`)),c.push(">>"),s[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;s[y-1].body=["<< /Type /Outlines",`/First ${t[0]} 0 R`,`/Last ${t[t.length-1]} 0 R`,`/Count ${o}`,">>"].join("\n")}let w;if(s[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"),s[d-1].body=["<< /Type /Pages",`/Kids [${m.map(e=>`${e} 0 R`).join(" ")}]`,`/Count ${m.length}`,">>"].join("\n"),i){const e=Oy(i);e&&(w=l(e))}const S=[Ib];let I=ky(Ib);const C=[0],T=e=>{S.push(e),I+=ky(e)};for(const M of s)C[M.id]=I,T(`${M.id} 0 obj\n`),T(M.body),T("\nendobj\n");const k=I;let P=`xref\n0 ${s.length+1}\n`;P+="0000000000 65535 f \n";for(const M of s)P+=`${String(C[M.id]??0).padStart(10,"0")} 00000 n \n`;T(P);const R=void 0!==w?` /Info ${w} 0 R`:"";return T(["trailer",`<< /Size ${s.length+1} /Root ${c} 0 R${R} >>`,"startxref",String(k),"%%EOF",""].join("\n")),function(e){const t=e.reduce((e,t)=>e+ky(t),0),n=new Uint8Array(t);let o=0;for(const r of e){const e="string"==typeof r?Ty.encode(r):r;n.set(e,o),o+=e.length}return n}(S)}var Dy=class{pages=[];streams=[];fonts;images=new Sy;shadings=new Iy;namedDestinations=[];outlineItems=[];documentInfo;constructor(e=Cb){this.fonts=new wy(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 $b(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}),By(this.pages,this.fonts,this.images,this.shadings,this.namedDestinations,this.outlineItems,this.documentInfo)}};function Fy(e,t,n,o,r){if(0!==o.size||0!==r.size)return(a,i)=>{const s=Bt(i),l=Bt(n);for(const n of o.get(a)??[])e.addNamedDestination({name:n,pageIndex:t,x:l,y:s});const c=r.get(a);if(c){const n=`__oasis_heading_${a}`;e.addNamedDestination({name:n,pageIndex:t,x:l,y:s}),e.addOutlineItem({title:c.title,level:c.level,destName:n})}}}async function Ey(e){e=la(e);const t=new Sb,n=Bn(e);await t.loadBundledUnicodeFaces({families:n}),await t.loadRemoteWebFontFaces({families:n});const o=new Dy(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=N(e),a=function(e){return Yo(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),s=new Map(We(e).map(e=>[e.id,{level:e.level,title:e.text}]));for(const l of r.pages){const n=Math.max(1,Bt(l.pageSettings.width)),r=Math.max(1,Bt(l.pageSettings.height)),c=o.addPage({width:n,height:r});await yb(o,c,n,r,e.design,e.sections?.[l.sectionIndex??0]?.pageBorder,e);const d=l.pageSettings.margins.left+l.pageSettings.margins.gutter,u=Va(l.pageSettings);await bb(o,c,l.headerBlocks,e,d,l.headerTop??Za(l.pageSettings),u,t,a,l.pageSettings);const p=l.bodyTop??ca(l.pageSettings);if(l.blocks.some(e=>void 0!==e.columnIndex)){const n=Vr(l.pageSettings),r=/* @__PURE__ */new Map;for(const e of l.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 bb(o,c,u,e,r.left,p,r.width,t,a,l.pageSettings,Fy(o,c,r.left,i,s))}}else await bb(o,c,l.blocks,e,d,p,u,t,a,l.pageSettings,Fy(o,c,d,i,s));await bb(o,c,l.footerBlocks,e,d,l.footerTop??l.bodyBottom??l.pageSettings.height,u,t,a,l.pageSettings),l.footnoteBlocks&&l.footnoteBlocks.length>0&&void 0!==l.footnoteTop&&(void 0!==l.footnoteSeparatorTop&&o.drawLine(c,{x1:Bt(d),y1:Bt(l.footnoteSeparatorTop+.5),x2:Bt(d+Math.min(180,.35*u)),y2:Bt(l.footnoteSeparatorTop+.5),stroke:"#64748b",lineWidth:Bt(1)}),await Ny(o,c,l.footnoteBlocks,l.footnoteReferenceIds??[],e,d,l.footnoteTop,u,t,a))}if(0===o.getPageCount()){const t=o.addPage({width:612,height:792});await yb(o,t,612,792,e.design,void 0,e)}return o.toArrayBuffer()}async function Ly(e){const t=await Ey(e);return new Blob([t],{type:"application/pdf"})}async function Ny(e,t,n,o,r,a,i,s,l,c){let d=i;const u=/* @__PURE__ */new Set,p=new Map(o.map(e=>[e,sa(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=Ra(void 0,n?.style?.styleId,r.styles),s=l.resolveFontFace({fontFamily:i.fontFamily,bold:i.bold,italic:i.italic});e.drawText(t,{x:Bt(a),y:Bt(d+12),text:o,fontSize:to(i),color:i.color??"#000000",bold:i.bold,italic:i.italic,fontResourceName:s.writerResourceName})}u.add(n)}await bb(e,t,[g],r,a+24,d,Math.max(24,s-24),l,c),d+=Math.max(0,g.estimatedHeight)+2}}function zy(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function $y(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 Hy(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 Wy(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 Uy(e){return function(e){const t=Nr(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;let r=0,a=0;for(const i of t){const t=Xr(i.style,e.styles);o.set(t.align,(o.get(t.align)??0)+1);for(const o of i.runs){const t=Ra(o.styles,i.style?.styleId,e.styles),s=t.fontFamily??"<null>";n.set(s,(n.get(s)??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=Xr(t.style,e.styles),r=t.runs[0],a=Ra(r?.styles,t.style?.styleId,e.styles);return{index:n,textLength:Ua(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 jy(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 Vy(e){return e?e.behindDoc?"behind":e.wrap&&"none"!==e.wrap?e.wrap:"front":"inline"}function Ky(e,t){return{...e,positionV:{...e.positionV??{},relativeFrom:t?"page":"paragraph"}}}function _y(e){return"page"===e?.positionV?.relativeFrom}function Xy(e){return ci(e,e=>"image"===e.kind)}function Gy(e,t,n){return ov(e,e=>({...e,width:Math.max(24,Math.round(t)),height:Math.max(24,Math.round(n))}))}function qy(e){return!e||!Number.isFinite(e)||e<0?0:Math.min(e,.99)}function Yy(e,t){return ov(e,e=>{const n={...e},o=function(e){if(!e)return;const t=qy(e.left),n=qy(e.top),o=qy(e.right),r=qy(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 Zy(e,t){const n=Xy(e),o=n&&Uo(n.run);return o?Yy(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=qy(a.left),s=qy(a.top),l=qy(a.right),c=qy(a.bottom),d=o/r;if(d>n){const e=r*n,t=(o-e)/o*Math.max(0,1-i-l);return{crop:{...a,left:i+t/2,right:l+t/2},width:e}}if(d<n){const e=o/n,t=(r-e)/r*Math.max(0,1-s-c);return{crop:{...a,top:s+t/2,bottom:c+t/2},height:e}}return{crop:e.crop??null}}(o,t)):e}function Jy(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 Qy(e){return ov(e,e=>{const t={...e};return delete t.crop,delete t.cropFit,delete t.cropShape,t})}function ev(e){if(!Number.isFinite(e))return;const t=(Math.round(e)%360+360)%360;return 0===t?void 0:t}function tv(e,t,n=90){const o=Xy(e);if(!o||!Uo(o.run))return e;const r="right"===t?-n:n,a=ev(function(e){const t=Xy(e);return(t&&Uo(t.run))?.rotation??0}(e)+r);return ov(e,e=>({...e,rotation:a}))}function nv(e,t){const n=function(e){const t=Xy(e),n=t&&Uo(t.run);return n?{flipH:Boolean(n.flipH),flipV:Boolean(n.flipV)}:null}(e);return n?ov(e,"horizontal"===t?e=>({...e,flipH:!n.flipH}):e=>({...e,flipV:!n.flipV})):e}function ov(e,t){const n=Xy(e);if(!n||!Uo(n.run))return e;const o=zo(e),{paragraphIndex:r,run:a}=n,i=o.map((e,n)=>n!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id===a.id&&"image"===e.kind?{...e,image:t(e.image)}:Oo(e))});return ro(e,i,C(i,ya(e)))}function rv(e,t){return ov(e,e=>{const n=t(e.floating);if(n)return{...e,floating:n};const{floating:o,...r}=e;return r})}function av(e,n){const o=Xy(e);if(!o)return e;const r=zo(e),{paragraphIndex:a,offset:i,run:s}=o,l=jo(r,n.paragraphId);if(l<0)return e;const c=r[l],d=ia(c,n),u=l===a&&d>i?d-1:d;if(l===a&&u===i)return e;const p=e=>To(e,[...t(e,0,i),...t(e,i+1,xa(e))]),g=(e,t)=>G(e,Math.max(0,Math.min(t,xa(e))),[Lr("",ue(e,t),Uo(s))]),f=r.map((e,t)=>t===a&&t===l?g(p(e),u):t===a?p(e):t===l?g(e,u):yr([e])[0]),m=f[l],h=Math.max(0,Math.min(u+1,xa(m)));return ro(e,f,E(na(m,h)))}function iv(e,t,n,o=0){const r=Va(Ia(t));if(!n)return r;const a=ye(t,n,o);return null!==a&&Number.isFinite(a)&&a>0?Math.min(r,a):r}function sv(e){return{insertImageFromFile:async(t,n)=>{e.logger.info(`image insert:start name="${t.name}" type=${t.type} size=${t.size}`);const o=await Hy(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,s=a.naturalHeight||300,l=e.state(),c=n?.paragraphId??l.selection.focus.paragraphId,d=iv(e.surfaceRef(),l.document,c,l.activeSectionIndex??0),u=i>d?d/i:1,p=Math.max(24,Math.round(i*u)),g=Math.max(24,Math.round(s*u));e.logger.info(`image insert:decoded natural=${i}x${s} fitted=${p}x${g} maxWidth=${d}`),e.applyTransactionalState(e=>function(e,t){const n=fr(e.selection)?e:Z(e),{paragraph:o,index:r,offset:a}=te(n),i=Lr("",ue(o,a),t),s=G(o,a,[i]),l=zo(n).map((e,t)=>t===r?s:Er(e));return ro(n,l,E(na(s,a+1)))}(n?ii(e,{anchor:n,focus:n}):e,{src:r,width:p,height:g,intrinsicWidth:i,intrinsicHeight:s}),{mergeKey:Pp})}}}var lv={"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 cv(e){return function(e){const[t,n]=vn(null),o=(e,t)=>{const[n,o]=lv[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=X(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 Hy(t);e.logger.info("import:phase",{phase:"reading-file",durationMs:gt(e.now()-a,2)});let s=null,l=-1,c=0;const d=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!==s;if(!(a||void 0!==r&&(l<0||r-l>=1)||o-c>=40))return;s=t,l=r??l,c=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",Uy(d));const u=e.now();e.setImportPhase("preparing-fonts"),await r,await e.prepareDocumentFonts(d),e.logger.info("import:phase",{phase:"preparing-fonts",durationMs:gt(e.now()-u,2)}),e.setImportPhase("applying-editor-state"),e.resetEditorChromeState(),e.applyState(Cr(d));const p=e.now();e.setImportPhase("stabilizing-layout"),await e.stabilizeLayoutAfterImport(),e.logger.info("import:phase",{phase:"stabilizing-layout",durationMs:gt(e.now()-p,2)});const g=ka(d).reduce((e,t)=>e+(t.header?.length??0)+t.blocks.length+(t.footer?.length??0),0),f=Ur(d).length;e.setImportPhase("done"),e.logger.info("import:done",{format:n.id,blocks:g,paragraphs:f,durationMs:gt(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}),s=sv({state:e.state,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,logger:e.logger}),l=function(e){const t=e.download??zy,n=e.print??$y;let o=!1;return{handleExportDocx:async()=>{const n=await jd(e.document());return t(n,"oasis-editor.docx"),e.focusInput(),n},handleExportPdf:async()=>{const n=await Ly(e.document());return t(n,"oasis-editor.pdf"),e.focusInput(),n},handlePrint:async()=>{const t=await Ly(e.document());if(!o){o=!0;try{await n(t)}finally{o=!1}}return e.focusInput(),t},exportDocxBlob:()=>jd(e.document()),exportPdfBlob:()=>Ly(e.document())}}({document:()=>e.state().document,focusInput:e.focusInput}),c=async t=>{e.isReadOnly()||await i.handleImportFile(t)},d=async(e,t)=>{await s.insertImageFromFile(e,t)},u=async t=>{e.isReadOnly()||t&&(await d(t),e.focusInput())};return{importProgress:t,handleImportFile:c,handleExportDocx:async()=>l.handleExportDocx(),handleExportPdf:async()=>l.handleExportPdf(),handlePrint:async()=>l.handlePrint(),exportDocxBlob:l.exportDocxBlob,exportPdfBlob:l.exportPdfBlob,insertImageFromFile:d,handleInsertImage:u}}(e)}function dv(e,t){return e.paragraph.runs.map(e=>e.text).join("")[t]??""}function uv(e){return" "===e||"\t"===e||"\n"===e}function pv(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 gv(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=gv(n.blocks,t);if(e)return e}}return null}function fv(e,t){const n=ya(t),o=[],r=e.surfaceRect,a=new Map(zo(t).map((e,t)=>[e.id,t]));let i=null,s=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&&(s={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 l=(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(l&&c&&l.tableId===c.tableId&&(l.rowIndex!==c.rowIndex||l.cellIndex!==c.cellIndex)){const n=function(e,t){for(const n of za(e))for(const e of[n.blocks,n.header,n.firstPageHeader,n.evenPageHeader,n.footer,n.firstPageFooter,n.evenPageFooter]){const n=gv(e,t);if(n)return n}for(const n of Object.values(e.footnotes?.items??{})){const e=gv(n.blocks,t);if(e)return e}return null}(t.document,l.tableId);if(n){const t=Kr(n),a=t.find(e=>e.rowIndex===l.rowIndex&&e.cellIndex===l.cellIndex),i=t.find(e=>e.rowIndex===c.rowIndex&&e.cellIndex===c.cellIndex);if(a&&i){d=!0;const s=Math.min(a.visualRowIndex,i.visualRowIndex),l=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<=l&&e.visualRowIndex+e.rowSpan-1>=s,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||s))for(const w of e.paragraphs){const e=pv(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&&uv(dv(w,e));)e+=1;for(;a>e&&uv(dv(w,a-1));)a-=1;if(e>=a)continue;const s=n.slots.find(t=>t.offset===e),l=n.slots.find(e=>e.offset===a)??n.slots[n.slots.length-1];if(!s||!l)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:s.left-r.left+1,top:d-r.top,width:Math.max(1,l.left-s.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 s of o){const e=Math.abs(t-s.offset);e<a&&(r=s,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?ia(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&&!s};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:s,selectedTableBox:v}}function mv(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)mv(n.blocks,t);else t.push(n.id)}function hv(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 bv(e){return e.cells.flatMap(e=>e.blocks)}function yv(e){return e.rows.flatMap(bv)}function vv(e){return{id:e.id,type:e.type,author:e.author,date:e.date}}function xv(e){return{id:e.id,type:"property",author:e.author,date:e.date}}function wv(e){const t=[];return e.style?.revision&&t.push(vv(e.style.revision)),e.style?.propertyRevision&&t.push(xv(e.style.propertyRevision)),t}function Sv(e){const t=[];return e.style?.revision&&t.push(vv(e.style.revision)),e.style?.propertyRevision&&t.push(xv(e.style.propertyRevision)),e.propertyExceptionsRevision&&t.push(xv(e.propertyExceptionsRevision)),t}function Iv(e){const t=[];return e.style?.revision&&t.push(xv(e.style.revision)),e.gridRevision&&t.push({id:e.gridRevision.id,type:"grid",author:e.gridRevision.author,date:e.gridRevision.date}),t}function Cv(e){const t=[],n=/* @__PURE__ */new Set,o=(e,o,r,a,i,s)=>{if(n.has(e.id))return;n.add(e.id);const l=[];mv(s,l),t.push({...e,scope:o,tableId:r,rowIndex:a,cellIndex:i,paragraphIds:l,snippet:hv(s)})},r=e=>{if(e)for(const t of e)if("paragraph"!==t.type){for(const e of Iv(t))o(e,"table",t.id,void 0,void 0,yv(t));t.rows.forEach((e,n)=>{for(const r of Sv(e))o(r,"row",t.id,n,void 0,bv(e));e.cells.forEach((e,a)=>{for(const r of wv(e))o(r,"cell",t.id,n,a,e.blocks);r(e.blocks)})})}};for(const a of za(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 Tv(e){const t=[],n=/* @__PURE__ */new Set;return za(e.document).forEach((e,o)=>{const r=e.propertyRevision;if(!r||n.has(r.id))return;n.add(r.id);const a=[];mv(e.blocks,a);const i=hv(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 kv={insertions:"showMarkupInsertions",deletions:"showMarkupDeletions",comments:"showMarkupComments",formatting:"showMarkupFormatting"};function Pv(e,t){return e[kv[t]]??!0}function Rv(e,t){return"boolean"==typeof t.allAuthors?Bv(e,t.allAuthors?void 0:[]):"string"==typeof t.author?function(e,t,n){const o=e.markupAuthors??[...n],r=Dv(o.includes(t)?o.filter(e=>e!==t):[...o,t]),a=Dv(n);return Bv(e,r.length===a.length&&r.every((e,t)=>e===a[t])?void 0:r)}(e,t.author,Ev(e)):t.section?function(e,t){const n=kv[t],o=!(e[n]??!0);return e[n]===o?e:{...e,[n]:o}}(e,t.section):e}function Mv(e,t){return e.markupAuthors?.includes(t)??!0}function Ov(e,t,n){return!("insert"===t&&!Pv(e,"insertions"))&&(!("delete"===t&&!Pv(e,"deletions"))&&(!("property"===t&&!Pv(e,"formatting"))&&Mv(e,n)))}function Av(e){const t=/* @__PURE__ */new Map;for(const n of Cv(e))if(Ov(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 Tv(e))Ov(e,n.type,n.author)&&t.push(...n.paragraphIds);return t}(e))t.has(n)||t.set(n,null);for(const n of Nr(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,s=t.styles?.propertyRevision;let l=!1;!a||"insert"!==a.type&&"delete"!==a.type?s&&(l=Ov(e,"property",s.author)):l=Ov(e,a.type,a.author),l&&(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 Bv(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 Dv(e){return[...new Set(e)].sort()}function Fv(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 Ev(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 Fv(r,t)},r=Nr(e.document);for(const l of r)Fv(l,t);for(const l of za(e.document)){for(const e of[l.blocks,l.header,l.firstPageHeader,l.evenPageHeader,l.footer,l.firstPageFooter,l.evenPageFooter])o(e);n(l.propertyRevision?.author)}const a=e.document.footnotes?.items??{};for(const l of Object.values(a))o(l.blocks);const i=e.document.endnotes?.items??{};for(const l of Object.values(i))o(l.blocks);const s=e.document.comments?.items??{};for(const l of Object.values(s)){const e=l.author??l.authorId;e&&t.add(e)}return[...t].sort((e,t)=>e.localeCompare(t))}function Lv(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,s=r.styles?.propertyRevision;let l,c,d;if(!i||"insert"!==i.type&&"delete"!==i.type?s&&(l=s.id,c="property",d=s.author):(l=i.id,c=i.type,d=i.author),void 0!==l&&void 0!==c&&void 0!==d&&Ov(t,c,d)&&a>e){const t=n.at(-1);t&&t.revisionId===l&&t.type===c&&t.end===e?t.end=a:n.push({start:e,end:a,revisionId:l,type:c})}}return n}function Nv(e,t){const n=e.surfaceRect,o=[];for(const r of e.paragraphs){const e=Lv(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),s=t.slots.find(e=>e.offset===a)??t.slots[t.slots.length-1];i&&s&&o.push({revisionId:r.revisionId,type:r.type,left:i.left-n.left,top:t.top-n.top,width:Math.max(1,s.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 Cv(t)){if(!Ov(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)),s=Math.min(...e.map(e=>e.top)),l=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:s-n.top,width:l-r,height:c-s})}return a}(e,t)),o.push(...function(e,t){const{surfaceRect:n}=e,o=[];for(const r of Tv(t)){if(!Ov(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)),s=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:s-a})}}return o}(e,t)),o}function zv(e,t){const{surfaceRect:n}=e,o=e.paragraphs,r=/* @__PURE__ */new Map;for(const c of o){const e=c.left+c.width,t=r.get(c.pageIndex);(void 0===t||e>t)&&r.set(c.pageIndex,e)}const a=/* @__PURE__ */new Map;for(const c of e.pages??[]){const e=c.left+c.width,t=r.get(c.index)??e-Math.min(96,c.width),o=Math.max(0,e-t),i=Math.min(168,Math.max(84,o-16));a.set(c.index,{left:e-8-i-n.left,width:i})}const i=[];for(const c 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 Nr(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 Cv(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 Tv(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(!Ov(t,c.type,c.author))continue;const e=new Set(c.paragraphIds);let r;for(const t of o)e.has(t.paragraphId)&&(!r||t.top<r.top)&&(r=t);if(!r||!a.has(r.pageIndex))continue;const s=r.lines[0];i.push({descriptor:c,pageIndex:r.pageIndex,top:(s?s.top:r.top)-n.top})}i.sort((e,t)=>e.pageIndex-t.pageIndex||e.top-t.top);const s=/* @__PURE__ */new Map,l=[];for(const c of i){const e=s.get(c.pageIndex)??-1/0,t=Math.max(c.top,e+6);s.set(c.pageIndex,t+58);const n=a.get(c.pageIndex),o=c.descriptor;l.push({revisionId:o.id,type:o.type,variant:"balloon",left:n.left,top:t,width:n.width,height:58,author:o.author,date:o.date,snippet:o.snippet})}return l}var $v={composeMeasuredParagraphLines:e=>Ye.composeMeasuredParagraphLines(e),resolveRenderedLineHeightPx:(e,t)=>Ye.resolveRenderedLineHeightPx(e,t)};function Hv(e,t){return(e?.length??0)===(t?.length??0)&&(t??[]).every((t,n)=>e?.[n]===t)}function Wv(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 Uv(){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&&Hv(e.tableSegment?.startRowCellBlockStarts,t.tableSegment?.startRowCellBlockStarts)&&Hv(e.tableSegment?.endRowCellBlockEnds,t.tableSegment?.endRowCellBlockEnds)&&Wv(e.tableSegment?.startRowCellBlockPositions,t.tableSegment?.startRowCellBlockPositions)&&Wv(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 jv(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 Vv(e){return function(e){const[t,o]=vn({}),[r,a]=vn({}),[i,s]=vn({left:0,top:0,height:28}),[l,c]=vn([]),[d,u]=vn([]),[p,g]=vn([]),[m,h]=vn([]),[b,y]=vn(null),[v,x]=vn(null),[w,S]=vn(null),[I,C]=vn({left:0,top:0,height:28,visible:!1}),[T,P]=vn(null),R=Uv(),M=Mt(()=>{k();const t=void 0===(n=e.state.reviewDisplayMode)||"all"===n?null:"original"===n?"original":"final";var n;return null===t?e.state.document:Rn(e.state.document,t).document}),O=Mt(()=>(k(),R(N(M(),void 0,t(),r(),{measurer:$v})))),A=f();let B=0;const D=(t="selection")=>{const n=e.surfaceRef();if(!n)return c([]),u([]),g([]),h([]),y(null),x(null),S(null),void C(e=>({...e,visible:!1}));const o=A.getCanvasLayoutSnapshot({surface:n,state:e.state,documentLayout:O(),zoomFactor:e.zoomFactor?.()});if(!o)return c([]),u([]),g([]),h([]),y(null),x(null),S(null),void C(e=>({...e,visible:!1}));const r=e.state.reviewDisplayMode??"all";if("all"!==r)return c([]),y(null),x(null),S(null),C({left:0,top:0,height:28,visible:!1}),s({left:0,top:0,height:28}),u([]),g([]),void h("simple"===r&&!1!==e.state.showRevisionMarkup?function(e,t){const n=Av(t);if(0===n.size)return[];const o=e.surfaceRect,r=/* @__PURE__ */new Map;for(const s of e.paragraphs){const e=r.get(s.pageIndex);(void 0===e||s.left<e)&&r.set(s.pageIndex,s.left)}const a=/* @__PURE__ */new Map;for(const s of e.pages??[]){const e=r.get(s.index),t=void 0===e?0:e-s.left;a.set(s.index,s.left+(t>0?.5*t:12)-o.left)}const i=[];for(const s of e.paragraphs){const e=n.get(s.paragraphId);if(void 0===e)continue;const t=a.get(s.pageIndex)??s.left-o.left-12,r=s.lines;if(0===r.length){i.push({paragraphId:s.paragraphId,left:t,top:s.top-o.top,height:Math.max(1,s.height)});continue}const l=null===e?r:r.filter(t=>e.some(e=>e.start<t.endOffset&&e.end>t.startOffset)),c=l.length>0?l:[r[0]];for(const n of c)i.push({paragraphId:s.paragraphId,left:t,top:n.top-o.top,height:Math.max(1,n.height)})}return i}(o,e.state):[]);const a=fv(o,e.state);h([]),c(a.selectionBoxes),g(!1===e.state.showRevisionMarkup?[]:[...Nv(o,e.state),...zv(o,e.state)]),u(function(e,t){const n=t.document.comments;if(!n||0===n.order.length||!Pv(t,"comments"))return[];const o=e.surfaceRect,r=new Map(zo(t).map((e,t)=>[e.id,t])),a=[];for(const i of n.order){const s=n.items[i];if(!s?.start||!s?.end||!Mv(t,s.author))continue;const l=r.get(s.start.paragraphId),c=r.get(s.end.paragraphId);if(void 0!==l&&void 0!==c)for(const t of e.paragraphs){const e=r.get(t.paragraphId);if(void 0===e||e<l||e>c)continue;const n=e===l?s.start.offset:0,d=e===c?s.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),s=r.slots.find(e=>e.offset===t)??r.slots[r.slots.length-1];n&&s&&a.push({commentId:i,left:n.left-o.left,top:r.top-o.top,width:Math.max(1,s.left-n.left),height:r.height})}}}return a}(o,e.state)),y(a.selectedImageBox),x(a.selectedTextBoxBox),S(a.selectedTableBox),s(a.inputBox),C(a.caretBox)},F=(e="selection")=>{const t=++B;queueMicrotask(()=>{t===B&&D(e)})},E=(e="content-change")=>(F(e),!1),L=(e,t={})=>(t.paragraphIds&&t.paragraphIds.length>0&&(a(e=>jv(e,t.paragraphIds??[])),de()),F(e),t.resolveWhenDone?Promise.resolve():null),z=t=>{if(!e.isImporting?.()){if(t.dirtyAll||t.structureChanged)o({}),a({}),de();else if((t.dirtyParagraphIds?.length??0)>0){const e=t.dirtyParagraphIds??[];a(t=>jv(t,e)),de()}F("content-change")}},$=async()=>{o({}),a({}),de(),await new Promise(e=>{var t;t=()=>e(),"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>t()):globalThis.setTimeout(t,16)}),F("import")};n(()=>{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,F("selection")}),n(()=>{e.state.document,e.state.activeSectionIndex,e.state.activeZone,e.isImporting?.()||F("content-change")}),n(()=>{e.state.showRevisionMarkup,e.state.showMarkupInsertions,e.state.showMarkupDeletions,e.state.showMarkupComments,e.state.showMarkupFormatting,e.state.markupAuthors,F("content-change")}),n(()=>{e.state.reviewDisplayMode,F("content-change")}),n(()=>{const t=e.viewportRef();if(!t)return;const n=()=>{F("scroll")},o=()=>{F("resize")};t.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",o),Tn(()=>{t.removeEventListener("scroll",n),window.removeEventListener("resize",o)})});const H=()=>P(null),W=()=>{B+=1,A.clear()};return{measuredBlockHeights:t,measuredParagraphLayouts:r,documentLayout:O,canvasSnapshotProvider:A,inputBox:i,selectionBoxes:l,commentHighlights:d,revisionMarkupBoxes:p,changeBarBoxes:m,selectedImageBox:b,selectedTextBoxBox:v,selectedTableBox:w,caretBox:I,preferredColumnX:T,setPreferredColumnX:P,clearPreferredColumn:H,requestInputBoxSync:F,scheduleDeferredLayoutMeasurement:L,stabilizeLayoutAfterImport:$,syncMeasuredLayoutMetrics:E,syncInputBox:D,setMeasuredBlockHeights:o,setMeasuredParagraphLayouts:a,applyInvalidation:z,onCleanupHook:W}}(e)}function Kv(e){return Array.isArray(e)?e.map(Kv):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Kv(t)])):e}function _v(e){const{builtinStyle:t,customStyle:n,...o}=e;return JSON.stringify(Kv(o))}var Xv=new Map(Object.values(pr).flatMap(e=>{const t=U(e);return t?[[e.id,{key:t,signature:_v(e)}]]:[]}));function Gv(e){if(!0===e.customStyle||void 0!==e.builtinStyle)return;const t=Xv.get(e.id);return t?.signature===_v(e)?t.key:void 0}function qv(e,t,o){const[r,a]=vn("Initial"),[i,s]=vn(!1),l=()=>o.enabled??!1,c=o.persistence,d=D(async e=>{if(l()&&i()){a("Saving...");try{const t=JSON.parse(JSON.stringify(qt(e)));await c.saveDocument(t),a("Saved")}catch(t){o.logger?.error("persistence:autosave failed",t),a("Error")}}},1e3);return n(dt(()=>e.document,e=>{l()&&i()&&d(e)},{defer:!0})),_n(async()=>{if(!l())return s(!0),void a("Saved");try{const e=await c.loadDocument();e&&t(function(e){if(e.sourcePackage||!e.styles)return e;let t;for(const[n,o]of Object.entries(e.styles)){const r=Gv(o);r&&(t??={...e.styles},t[n]={...o,builtinStyle:r})}return t?{...e,styles:t}:e}(e))}catch(e){o.logger?.error("persistence:load failed",e)}finally{s(!0),a("Saved")}}),{status:r}}function Yv(e,t){const n=Math.max(0,249),o=Math.max(0,e.length-n);return[...e.slice(o),t]}function Zv(e){return function(e){const t=(e,t)=>{const n=ka(e.document),o=Math.max(0,Math.min(lr(e),n.length-1)),r=Sr(e),a=n[o];if(!a)return e;const i=[...n],s={...a},l=Da("");if("header"===r){const e=[...a.header??[]];t<0?e.unshift(l):e.push(l),s.header=e}else if("footer"===r){const e=[...a.footer??[]];t<0?e.unshift(l):e.push(l),s.footer=e}else{const e=[...a.blocks];t<0?e.unshift(l):e.push(l),s.blocks=e}return i[o]=s,{...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:Yv(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:Yv(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=zo(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=zo(r),i=n<0?a[0]:a[a.length-1];if(!i)return!1;const s=na(i,n<0?xa(i):0);return e.applyTransactionalState(()=>av(r,s),{mergeKey:Mp}),e.focusInput(),!0}const s=r[i],l=n<0?xa(s):0;return e.applyTransactionalState(e=>av(e,na(s,l)),{mergeKey:Mp}),e.focusInput(),!0},a=t=>{const n=e.stateSnapshot();e.applyHistoryState({...n,document:{...n.document,sections:n.document.sections?.map(Rt)},selection:{anchor:{...t.anchor},focus:{...t.focus}}})};return{performUndo:n,performRedo:o,moveSelectedImageByParagraph:r,applySelectionPreservingStructure:a}}(e)}function Jv(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"),s=i.objectStore(t).put(o,n);s.onerror=()=>{a(/* @__PURE__ */new Error(`Failed to put item in ${t}: ${s.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 Qv(e){return function(e){const[t,n]=vn([]),[o,r]=vn([]);let a={undoStack:[],redoStack:[],lastTransactionMeta:null};const i=()=>{n(a.undoStack),r(a.redoStack)},s=t=>{e.commitState(e.cloneState(t))},l=(t,n)=>{const o=e.stateSnapshot(),r=K("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:Yv(e.undoStack,t),redoStack:[],lastTransactionMeta:o?.mergeKey?{mergeKey:o.mergeKey,timestamp:r}:null}}(a,o,0,n),i();const s=K("txn:invalidate",()=>function(e,t){if(e===t||e.document===t.document)return{};const n=e=>ka(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=zo(e),r=zo(t),a=/* @__PURE__ */new Map;for(const s of o)a.set(s.id,s);const i=[];for(const s of r){const e=a.get(s.id);if(!e){i.push(s.id);continue}if(e===s)continue;if(e.runs.length!==s.runs.length){i.push(s.id);continue}let t=!1;for(let n=0;n<e.runs.length;n+=1){const o=e.runs[n],r=s.runs[n];if(o===r)continue;if(o.id!==r.id||o.text!==r.text){t=!0;break}const a=Uo(o),i=Uo(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(s.id)}return{dirtyParagraphIds:i}}(o,r),0);e.applyLayoutInvalidation(s),K("txn:setState",()=>e.commitState(r),0)};return{undoStack:t,redoStack:o,applyTransactionalState:l,applyHistoryState:s,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 ex(e){let t=e.state.document,o=e.state.selection;n(()=>{const n=e.state.document,r=e.state.selection,a=n!==t,i=r!==o;var s;if(t=n,o=r,e.state.activeSectionIndex,e.state.activeZone,s=e.state,mp&&(yp={anchor:{paragraphId:s.selection.anchor.paragraphId,runId:s.selection.anchor.runId,offset:s.selection.anchor.offset},focus:{paragraphId:s.selection.focus.paragraphId,runId:s.selection.focus.runId,offset:s.selection.focus.offset},activeZone:s.activeZone??"main",activeSectionIndex:s.activeSectionIndex??0}),e.isImportInProgress())return;const l=e.cloneState(e.getStateSnapshot());e.getOnStateChange()?.(l),a&&(e.emit("change",l),e.emit("documentChange",l.document)),i&&e.emit("selectionChange",l.selection)})}function tx(e){return function(e){const{documentOptions:t,logger:n,runtimeClient:o,state:r,commitState:a,getStateSnapshot:i,applyState:s,cloneState:l,isReadOnly:c,focusInput:d,surfaceRef:u,viewportRef:p,zoomFactor:g,getImageOps:f}=e,m=cv({state:()=>r,applyState:s,applyTransactionalState:(e,t)=>U(e,t),isReadOnly:c,surfaceRef:()=>u()??null,stabilizeLayoutAfterImport:async()=>{await D()},resetEditorChromeState:()=>q(),focusInput:d,requestLocalFontAccess:it,prepareDocumentFonts:async e=>{await Kt(e,{remoteWebFonts:t().remoteWebFonts})},logger:n}),h=()=>"done"!==m.importProgress()?.phase&&"error"!==m.importProgress()?.phase&&null!==m.importProgress(),{measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:I,revisionMarkupBoxes:C,changeBarBoxes:T,selectedImageBox:k,selectedTextBoxBox:P,selectedTableBox:R,caretBox:M,preferredColumnX:O,setPreferredColumnX:A,clearPreferredColumn:B,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:F,setMeasuredParagraphLayouts:E,applyInvalidation:L,onCleanupHook:N}=Vv({state:r,surfaceRef:u,viewportRef:p,isImporting:h,zoomFactor:g}),z=Jv({key:t().persistenceKey}),{status:$}=qv(r,e=>{n.info("persistence:loaded",{docId:e.id});const t=Cr(e);a(t),q()},{enabled:t().persistenceEnabled??!1,persistence:t().persistence??z,logger:n}),{undoStack:H,redoStack:W,applyTransactionalState:U,applyHistoryState:j,resetTransactionGrouping:V,updateHistoryState:K,getHistoryState:_,clearHistory:X}=Qv({stateSnapshot:i,commitState:a,cloneState:l,applyLayoutInvalidation:L}),G=Zv({state:()=>r,stateSnapshot:i,applyHistoryState:j,applyTransactionalState:U,focusInput:d,clearPreferredColumn:B,imageOps:f,updateHistoryState:K,getHistoryState:_}),q=()=>{B(),F({}),E({}),de(),x.clear(),X()};return ex({state:r,isImportInProgress:h,cloneState:l,getStateSnapshot:i,getOnStateChange:()=>t().onStateChange,emit:o.emit}),{docIO:m,isImportInProgress:h,measuredBlockHeights:b,measuredParagraphLayouts:y,documentLayout:v,canvasSnapshotProvider:x,inputBox:w,selectionBoxes:S,commentHighlights:I,revisionMarkupBoxes:C,changeBarBoxes:T,selectedImageBox:k,selectedTextBoxBox:P,selectedTableBox:R,caretBox:M,preferredColumnX:O,setPreferredColumnX:A,clearPreferredColumn:B,stabilizeLayoutAfterImport:D,setMeasuredBlockHeights:F,setMeasuredParagraphLayouts:E,applyLayoutInvalidation:L,onCleanupHook:N,fallbackPersistence:z,persistenceStatus:$,undoStack:H,redoStack:W,applyTransactionalState:U,applyHistoryState:j,resetTransactionGrouping:V,updateHistoryState:K,getHistoryState:_,clearHistory:X,historyActions:G,resetEditorChromeState:q}}(e)}function nx(e){return ci(e,e=>"textBox"===e.kind)}function ox(e,t){const n=nx(e);if(!n||!Fo(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=zo(e).map((e,t)=>t!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Oo(e))});return ro(e,i,C(i,ya(e)))}function rx(e,t){const n=nx(e);if(!n||!Fo(n.run))return e;const{paragraphIndex:o,run:r}=n,a=zo(e).map((e,n)=>n!==o?Er(e):{...Er(e),runs:e.runs.map(e=>{if(e.id!==r.id||"textBox"!==e.kind)return Oo(e);const n=t(e.textBox.floating),o={...e.textBox};return n?o.floating=n:delete o.floating,{...e,textBox:o}})});return ro(e,a,C(a,ya(e)))}function ax(e,t,n,o={}){const r=nx(e),a=r&&Fo(r.run);if(!r||!a)return e;const i=o.handleDirection??"se",s=i.includes("n")||i.includes("s"),l=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=zo(e).map((e,t)=>t!==p?Er(e):{...Er(e),runs:e.runs.map(e=>{if(e.id!==g.id||"textBox"!==e.kind)return Oo(e);const t=e.textBox,n={...t,width:d,height:u};return s&&t.body?.autoFit&&(n.body={...t.body,autoFit:!1}),t.floating&&(n.floating=function(e,t,n,o,r){let a=e;if(o&&0!==t){const n=e.positionH;n?.align||(a={...a,positionH:{...n??{},offset:(n?.offset??0)-t*tr}})}if(r&&0!==n){const e=a.positionV;e?.align||(a={...a,positionV:{...e??{},offset:(e?.offset??0)-n*tr}})}return a}(t.floating,f,m,l,c)),{...e,textBox:n}})});return ro(e,h,C(h,ya(e)))}var ix=e=>e.cells.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),sx=e=>e.rows.reduce((e,t)=>Math.max(e,ix(t)),0),lx=(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 cx(e){if(!e)return null;for(const t of e.blocks){const e=oa(t)[0];if(e)return e}return null}var dx=e=>{for(const t of e.rows)for(const e of t.cells){if("continue"===e.vMerge)continue;const t=cx(e);if(t)return t}return null};function ux(e,t){return e.some(e=>oa(e).some(e=>e.id===t))}var px=(e,t,n)=>{const o=Fa(e,t);if(!o)return{kind:"outside"};const r=$r(e,t,o.sectionIndex);if(!r)return{kind:"outside"};const a=function(e,t,n){for(const o of e){if(!ux(o,n))continue;const e=Bo(o,t),r=e?.[e.length-1]?.table;if(r)return r}return null}(function(e,t){const n=Fa(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=za(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{kind:"blocked"};const i=a.rows.filter(e=>!e.style?.hidden).flatMap(e=>e.cells.filter(e=>"continue"!==e.vMerge&&e.blocks.length>0)),s=i.findIndex(e=>function(e,t){return e.blocks.some(e=>oa(e).some(e=>e.id===t))}(e,t));if(-1===s)return{kind:"blocked"};const l=s+n;if(l<0)return{kind:"beforeFirst"};if(l>=i.length)return{kind:"afterLast"};const c=i[l],d=c.blocks.every(e=>"paragraph"===e.type),u=c.blocks.flatMap(oa),p=d?u[0]:c.blocks.find(e=>"paragraph"===e.type)??u[0];if(!p)return{kind:"blocked"};const g=d?u[u.length-1]:p;return{kind:"adjacent",selection:{anchor:na(p,0),focus:na(g,xa(g))}}},gx=(e,t,n)=>{const o=px(e,t,n);return"adjacent"===o.kind?o.selection.anchor:null};function fx(e,t){return Boolean(e?.some(e=>oa(e).some(e=>e.id===t)))}function mx(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])=>fx(e,o))?.[0]??"header":"footer"===n?[["footer",t.footer],["firstPageFooter",t.firstPageFooter],["evenPageFooter",t.evenPageFooter]].find(([,e])=>fx(e,o))?.[0]??"footer":"blocks"}function hx(e){const t=Fa(e.document,e.selection.focus.paragraphId);return"footnote"===t?.zone?t.footnoteId:e.activeFootnoteId}function bx(e,t){if("footnote"===t){const t=hx(e);return t?e.document.footnotes?.items[t]?.blocks??[]:[]}const n=ka(e.document),o=lr(e),r=n[Math.max(0,Math.min(o,n.length-1))];if(!r)return[];const a=mx(e,r,t);return"blocks"===a?r.blocks:r[a]??[]}var yx=(e,t,n="main")=>{if("footnote"===n){const n=hx(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=lr(e),r=ka(e.document),a=Math.max(0,Math.min(o,r.length-1)),i=r[a];if(!i)return e;const s=mx(e,i,n),l=[...r];return l[a]="blocks"===s?{...i,blocks:t}:{...i,[s]:t},{...e,document:{...e.document,sections:l}}};function vx(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function xx(e,t){const n=Bo(e,t.tablePath),o=n?.[n.length-1];return o?{tableBlock:o.table,targetCell:o.cell,location:vx(t),targetBlocks:e}:null}function wx(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]=pn(a),xx(i,n)}var Sx=(e,t,n)=>{const o=Fa(e.document,e.selection.focus.paragraphId),r=Fa(e.document,e.selection.anchor.paragraphId);if(!o||!r)return n(e);if(o.zone!==r.zone||o.sectionIndex!==r.sectionIndex||o.footnoteId!==r.footnoteId)return e;const a=$r(e.document,e.selection.focus.paragraphId,lr(e)),i=o.zone;let s,l;if(a){const n=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?xx(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 s={...i,cells:[...i.cells]};a.rows[e.rowIndex]=s;const l=s.cells[e.cellIndex];if(!l)break;const c={...l,blocks:[...l.blocks]};s.cells[e.cellIndex]=c,o=c.blocks}return n}(r,n.tablePath),n):null}(e,t,a);if(!n)return e;s=n.targetBlocks,l=n.targetCell.blocks}else{const o=t(e,i);if(o.length&&o.every(e=>"paragraph"===e.type)&&o.some(t=>t.id===e.selection.anchor.paragraphId)&&o.some(t=>t.id===e.selection.focus.paragraphId))return n(e);s=[...o],l=s}const c=function(e,t){const n=e.findIndex(e=>"paragraph"===e.type&&e.id===t.anchor.paragraphId),o=e.findIndex(e=>"paragraph"===e.type&&e.id===t.focus.paragraphId);if(n<0||o<0)return null;let r=Math.min(n,o),a=Math.max(n,o)+1;if(e.slice(r,a).some(e=>"paragraph"!==e.type))return null;for(;r>0&&"paragraph"===e[r-1]?.type;)r--;for(;a<e.length&&"paragraph"===e[a]?.type;)a++;return{start:r,end:a}}(l,e.selection);if(!c)return e;const d=Eo(l.slice(c.start,c.end).map(e=>"paragraph"===e.type?Er(e):e),e.document.pageSettings,void 0,e.document.styles,void 0,e.document.assets),u={...e,activeSectionIndex:0,activeZone:"main",document:{...d,settings:e.document.settings},selection:{anchor:{...e.selection.anchor},focus:{...e.selection.focus}}},p=n(u),g=ka(p.document)[0]?.blocks??[];if(p===u&&JSON.stringify(g)===JSON.stringify(l.slice(c.start,c.end))&&JSON.stringify(p.selection)===JSON.stringify(e.selection))return e;l.splice(c.start,c.end-c.start,...g);const f=yx(e,s,i),m=zo(e),h=zo(f),b=e.document.bookmarks,y=e.document.comments;return{...f,document:{...f.document,...b?{bookmarks:mn(b,m,h)}:{},...y?{comments:An(y,m,h)}:{}},selection:p.selection}};function Ix(e,t){const n=$r(e.document,e.selection.focus.paragraphId,lr(e));return n?wx(e,t,n):null}function Cx(e,t,n,o){const r=yx(e,t,n);return o?{...r,selection:{anchor:na(o,0),focus:na(o,0)}}:r}function Tx(e,t,n,o){const r=t.getTargetBlocks(e,n),a=Bo(r,o);return a?.[a.length-1]?.table??null}function kx(e,t){const n=$r(e.document,e.selection.focus.paragraphId,lr(e)),o=n?.tablePath[n.tablePath.length-1];if(!n||!o)return null;const r=Tx(e,t,n.zone,n.tablePath);return r?{table:r,rowIndex:o.rowIndex,cellIndex:o.cellIndex}:null}function Px(e){return function(e){const t=t=>{const n=e.resolveHorizontalTableCellRange(t);return Boolean(n&&n.endCellIndex>n.startCellIndex)},n=t=>{const n=kx(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=Tx(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=kx(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),s=t=>null!==kx(t,e),l=t=>{const n=kx(t,e);return Boolean(n&&sx(n.table)>1)};return{canMergeSelectedTableCells:t,canSplitSelectedTableCell:n,canMergeSelectedTableRows:o,canMergeSelectedTable:r,canSplitSelectedTableCellVertically:a,canSplitSelectedTable:i,canEditSelectedTableRow:s,canEditSelectedTableColumn:l}}(e)}function Rx(e,t){return e.visualRowIndex!==t.visualRowIndex?e.visualRowIndex-t.visualRowIndex:e.visualColumnIndex!==t.visualColumnIndex?e.visualColumnIndex-t.visualColumnIndex:0}function Mx(e){return e.blocks.flatMap(oa)}function Ox(e){const t=e.tablePath[e.tablePath.length-1];return t?{...e,rowIndex:t.rowIndex,cellIndex:t.cellIndex}:e}function Ax(e,t){return function(e,t){const n=e.selection,o=lr(e),r=$r(e.document,n.anchor.paragraphId,o),a=$r(e.document,n.focus.paragraphId,o);if(!r||!a||r.zone!==a.zone||!function(e,t){if(0===e.length||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],r=t[n];if(o.tableBlockIndex!==r.tableBlockIndex)return!1;if(n<e.length-1&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))return!1}return!0}(r.tablePath,a.tablePath))return null;const i=t.getTargetBlocks(e,r.zone),s=Bo(i,r.tablePath),l=Bo(i,a.tablePath),c=s?.[s.length-1],d=l?.[l.length-1];if(!c||!d||c.table!==d.table)return null;const u=Ox(r),p=Ox(a),g=c.table,f=Kr(g),m=f.find(e=>e.rowIndex===u.rowIndex&&e.cellIndex===u.cellIndex),h=f.find(e=>e.rowIndex===p.rowIndex&&e.cellIndex===p.cellIndex);return m&&h?{anchorLocation:u,focusLocation:p,anchorCell:m,focusCell:h,tableBlock:g,tableLayout:f}:null}(e,t)}function Bx(e){return function(e){const t=t=>{const n=t.selection,o=Ax(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),s=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}..${s}]`);const l=Rx(o.anchorCell,o.focusCell)<=0?o.anchorLocation:o.focusLocation,c=Rx(o.anchorCell,o.focusCell)<=0?o.focusLocation:o.anchorLocation,d=o.tableBlock.rows[l.rowIndex]?.cells[l.cellIndex],u=o.tableBlock.rows[c.rowIndex]?.cells[c.cellIndex],p=d?Mx(d)[0]:void 0,g=u?Mx(u):[],f=g[g.length-1];return p&&f?{anchor:na(p,0),focus:na(f,xa(f))}:null},n=t=>{const n=Ax(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),s=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:s,zone:n.anchorLocation.zone}},o=t=>{const n=Ax(t,e);if(!n||n.anchorCell.visualRowIndex!==n.focusCell.visualRowIndex)return null;const o=Rx(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=Ax(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 Dx(e){if(e)for(const t of e.blocks){const e=oa(t)[0];if(e)return e}}function Fx(e,t,n){const o=n.tablePath[n.tablePath.length-1];return o?wx(e,t.getTargetBlocks,{blockIndex:n.blockIndex,rowIndex:o.rowIndex,cellIndex:o.cellIndex,paragraphIndex:0,tablePath:n.tablePath,zone:n.zone}):null}function Ex(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=>pn(e))}),n=n=>{const o=e.resolveHorizontalTableCellRange(n);if(!o)return n;const r=Fx(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,s=a.rows[o.rowIndex];if(!s)return n;const l=s.cells.slice(o.startCellIndex,o.endCellIndex+1);if(l.length<2)return n;const c=n.trackChangesEnabled?qg():void 0,d={...l[0],colSpan:l.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0),blocks:l.flatMap(e=>e.blocks.map(e=>pn(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:"horizontal",currentCellCount:1,previousCells:l.map(t)}}:{}};s.cells.splice(o.startCellIndex,l.length,d);const u=Dx(d);return u?Cx(n,i,o.zone,u):n},o=n=>{const o=e.resolveVerticalTableCellRange(n);if(!o)return n;const r=Fx(n,e,o);if(!r)return n;const{tableBlock:a,targetBlocks:i}=r,s=[];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;s.push(r)}if(s.length<2)return n;const l=Math.max(1,s[0].colSpan??1);if(!s.every(e=>Math.max(1,e.colSpan??1)===l))return n;const c=n.trackChangesEnabled?qg():void 0,d={...s[0],rowSpan:s.length,vMerge:"restart",blocks:s.flatMap(e=>e.blocks.map(e=>pn(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:"vertical",currentCellCount:1,previousCells:s.map(t)}}:{}};a.rows[o.startRowIndex].cells[o.cellIndex]=d;for(let e=o.startRowIndex+1;e<=o.endRowIndex;e+=1){const t=vr([Da("")],l);t.blocks=[],t.vMerge="continue",a.rows[e].cells[o.cellIndex]=t}const u=Dx(d);return u?Cx(n,i,o.zone,u):n},r=t=>e.canMergeSelectedTableCells(t)?n(t):e.canMergeSelectedTableRows(t)?o(t):t,a=n=>{const o=Ix(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex]?.cells[a.cellIndex],l=Math.max(1,s?.rowSpan??1);if(!s||l<=1||"restart"!==s.vMerge)return n;const c=t(s),d=n.trackChangesEnabled?qg():void 0,u=Math.max(1,s.colSpan??1);s.rowSpan=void 0,s.vMerge=void 0,d&&(s.style={...s.style??{},revision:{...d,type:"merge",previous:{colSpan:c.colSpan,rowSpan:c.rowSpan,vMerge:c.vMerge}}},s.mergeRevisionState={revisionId:d.id,orientation:"vertical",currentCellCount:1,previousCells:[c,...Array.from({length:l-1},(e,n)=>{const o=r.rows[a.rowIndex+n+1]?.cells[a.cellIndex];return o?t(o):vr([],u)})]});for(let e=1;e<l;e+=1){const t=r.rows[a.rowIndex+e];if(!t)break;const n=vr([Da("")],u);t.cells[a.cellIndex]=n}const p=Dx(s);return p?Cx(n,i,a.zone,p):n},i=n=>{const o=Ix(n,e.getTargetBlocks);if(!o)return n;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex],l=s?.cells[a.cellIndex],c=Math.max(1,l?.colSpan??1);if(!s||!l||c<=1)return n;const d=t(l),u=n.trackChangesEnabled?qg():void 0,p=[{...l,colSpan:void 0,blocks:l.blocks.map(e=>pn(e)),...u?{style:{...l.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},()=>vr([Da("")]))];s.cells.splice(a.cellIndex,1,...p);const g=Dx(p[0]);return g?Cx(n,i,a.zone,g):n},s=t=>e.canSplitSelectedTableCellVertically(t)?a(t):e.canSplitSelectedTableCell(t)?i(t):t;return{mergeSelectedTableCells:n,mergeSelectedTableRows:o,mergeSelectedTable:r,splitSelectedTableCellVertically:a,splitSelectedTableCell:i,splitSelectedTable:s}}(e)}function Lx(e,t){e.style={...e.style??{},revision:{...qg(),type:t}}}function Nx(e){if(!e)return null;for(const t of e.blocks){const e=oa(t)[0];if(e)return e}return null}function zx(e,t,n){const o=Nx(t);if(o)return o;if(n)for(const r of n.cells){if("continue"===r.vMerge)continue;const e=Nx(r);if(e)return e}return dx(e)}function $x(e){return function(e){const t=(t,n)=>{const o=Ix(t,e.getTargetBlocks);if(!o)return t;const{tableBlock:r,location:a,targetBlocks:i}=o,s=r.rows[a.rowIndex];if(!s)return t;const l=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=Kr(r),n=e.find(e=>e.rowIndex===a.rowIndex&&e.cellIndex===a.cellIndex),o=e.filter(e=>e.rowIndex===a.rowIndex),s=o.length>0?o:e.filter(e=>e.rowIndex===Math.max(0,a.rowIndex-1));c=Ao(s.map(t=>{const n=e.find(e=>e.visualColumnIndex===t.visualColumnIndex&&e.visualRowIndex<l&&e.visualRowIndex+e.rowSpan>l);if(n){n.cell.rowSpan=Math.max(1,n.cell.rowSpan??1)+1,n.cell.vMerge="restart";const e=vr([Da("")],t.colSpan);return e.blocks=[],e.vMerge="continue",e}return vr([Da("")],t.colSpan)})),t.trackChangesEnabled&&Lx(c,"insert"),r.rows.splice(l,0,c);const d=n?.visualColumnIndex??a.cellIndex,u=zx(r,lx(c,d),c);return Cx(t,i,a.zone,u)}c=Ao(s.cells.map(e=>vr([Da("")],Math.max(1,e.colSpan??1)))),t.trackChangesEnabled&&Lx(c,"insert"),r.rows.splice(l,0,c);const d=zx(r,c.cells[Math.min(a.cellIndex,c.cells.length-1)],c);return Cx(t,i,a.zone,d)},n=t=>{const n=Ix(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,targetBlocks:r,location:a}=n,i=o.rows[o.rows.length-1];if(!i||!i.cells.length)return t;const s=i.cells.map(e=>{const t=vr([Da("")],Math.max(1,e.colSpan??1));if(e.style){const{revision:n,...o}=e.style;t.style=o}return t}),l=Math.max(o.gridCols?.length??0,sx(o));for(let e=s.reduce((e,t)=>e+Math.max(1,t.colSpan??1),0);e<l;e++)s.push(vr([Da("")]));const c=Ao(s);return t.trackChangesEnabled&&Lx(c,"insert"),o.rows.push(c),Cx(t,r,a.zone,Nx(s[0]))},o=t=>{const n=Ix(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 Lx(i,"delete"),Cx(t,a,r.zone,null);if(i.cells.some(e=>"continue"!==e.vMerge&&Math.max(1,e.rowSpan??1)>1))return t;const s=o.rows.some(e=>e.cells.some(e=>Math.max(1,e.rowSpan??1)>1||void 0!==e.vMerge)),l=s?Kr(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex):null;if(s){const e=Kr(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=zx(o,c?lx(c,Math.min(l?.visualColumnIndex??r.cellIndex,Math.max(0,ix(c)-1))):null);return Cx(t,a,r.zone,d)},r=(t,n)=>{const o=Ix(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=Kr(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=vr([Da("")]);t.trackChangesEnabled&&Lx(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:{...qg(),type:"merge",previous:{colSpan:i.colSpan}}}}:{}}),a=!0):e.push(i),r+=n}if(!a){const n=vr([Da("")]);t.trackChangesEnabled&&Lx(n,"insert"),e.push(n)}n.cells=e}const s=r.rows[a.rowIndex],l=zx(r,s?lx(s,o):null);return Cx(t,i,a.zone,l)}const s=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=vr([Da("")]);t.trackChangesEnabled&&Lx(n,"insert"),e.cells.splice(s,0,n)}const l=r.rows[a.rowIndex]?.cells[s],c=zx(r,l);return Cx(t,i,a.zone,c)},a=t=>{const n=Ix(t,e.getTargetBlocks);if(!n)return t;const{tableBlock:o,location:r,targetBlocks:a}=n;if(sx(o)<=1)return t;if(t.trackChangesEnabled){const e=Kr(o).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex)?.visualColumnIndex??r.cellIndex;for(const t of o.rows){const n=lx(t,e);n&&Lx(n,"delete")}return Cx(t,a,r.zone,null)}if(o.rows.some(e=>e.cells.some(e=>Math.max(1,e.colSpan??1)>1))){const e=Kr(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=zx(o,n&&lx(n,Math.min(e,Math.max(0,ix(n)-1))));return Cx(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],s=i?.cells[Math.min(r.cellIndex,i.cells.length-1)],l=zx(o,s);return Cx(t,a,r.zone,l)};return{insertSelectedTableRow:t,appendTableRowForTab:n,deleteSelectedTableRow:o,insertSelectedTableColumn:r,deleteSelectedTableColumn:a}}(e)}function Hx(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:s,cells:l,zone:c}=a;e.logger?.info(`${o}: multi-cell selection in table block ${i} at depth ${s.length} (${l.length} cells) in zone ${c}`);const d=[],u=[];for(const e of l){const t=e.cell.blocks.flatMap(oa);d.push(...t),u.push(t.length)}if(0===d.length)return r;const p={...r,activeSectionIndex:0,activeZone:"main",document:{...Eo(d,r.document.pageSettings,void 0,r.document.styles,void 0,r.document.assets),settings:r.document.settings},selection:{anchor:na(d[0],0),focus:na(d[d.length-1],xa(d[d.length-1]))}},g=n(p);if(g===p)return r;const f=zo(g);if(f.length!==d.length)return r;const m=s[s.length-1];if(!m)return r;const h=wx(r,e.getTargetBlocks,{blockIndex:i,rowIndex:m.rowIndex,cellIndex:m.cellIndex,paragraphIndex:0,tablePath:s,zone:c});if(!h)return r;let b=0;for(let e=0;e<l.length;e+=1){const t=l[e],n=u[e]??0,o=f.slice(b,b+n);b+=n;const r=h.tableBlock.rows[t.rowIndex]?.cells[t.cellIndex];r&&(r.blocks=kt(r.blocks,o))}return yx(r,h.targetBlocks,c)})};return{withExpandedTableCellSelection:t,applySelectionAwareTextCommand:e=>{n(e,"applySelectionAwareTextCommand")},applySelectionAwareParagraphCommand:e=>{n(e,"applySelectionAwareParagraphCommand")}}}(e)}function Wx(e){return function(e){const t=bx,{resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}=Bx({getTargetBlocks:t,logger:e.logger}),{canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g}=Px({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a}),{mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v}=Ex({getTargetBlocks:t,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canMergeSelectedTableRows:l,canSplitSelectedTableCell:s,canSplitSelectedTableCellVertically:d}),{insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:S,insertSelectedTableColumn:I,deleteSelectedTableColumn:C}=$x({getTargetBlocks:t}),T=(e,n)=>Sx(e,t,n),{withExpandedTableCellSelection:k,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R}=Hx({applyTransactionalState:e.applyTransactionalState,applySelectionToStatePreservingStructure:e.applySelectionToStatePreservingStructure,getTargetBlocks:t,resolveTableCellRangeSelection:n,resolveSelectedTableCells:o,logger:e.logger}),M=(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?qg():void 0,a=[];for(let b=0;b<t;b+=1){const e=[];for(let r=0;r<n;r+=1)e.push({...vr([Da("")]),style:{width:o}});const t=Ao(e);r&&(t.style={revision:{...r,type:"insert"}}),a.push(t)}const i={...Wr(a),style:{width:"100%"}},s=Xa(e,e.selection.focus),l=za(e.document),c=lr(e),d=Sr(e),u=e=>{const t=e.findIndex(e=>e.id===s.paragraphId||"paragraph"!==e.type&&oa(e).some(e=>e.id===s.paragraphId));return-1===t?{nextBlocks:e,found:!1}:{nextBlocks:[...e.slice(0,t+1),i,...e.slice(t+1)],found:!0}},p=l[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=[...l];m[c]=g;const h=i.rows[0].cells[0].blocks[0];return"paragraph"!==h.type?e:{...e,document:{...e.document,sections:m},selection:E(na(h,0))}}(e,t,n),{mergeKey:Rp}),e.focusInput()};return{resolveTableCellRangeSelection:n,resolveHorizontalTableCellRange:r,resolveVerticalTableCellRange:a,canMergeSelectedTableCells:i,canSplitSelectedTableCell:s,canMergeSelectedTableRows:l,canMergeSelectedTable:c,canSplitSelectedTableCellVertically:d,canSplitSelectedTable:u,canEditSelectedTableRow:p,canEditSelectedTableColumn:g,mergeSelectedTableCells:f,mergeSelectedTableRows:m,mergeSelectedTable:h,splitSelectedTableCellVertically:b,splitSelectedTableCell:y,splitSelectedTable:v,insertSelectedTableRow:x,appendTableRowForTab:w,deleteSelectedTableRow:S,insertSelectedTableColumn:I,deleteSelectedTableColumn:C,getRowVisualWidth:ix,getTableVisualWidth:sx,findCellAtVisualColumn:lx,findFirstNavigableParagraphInTable:dx,updateBlocksInCurrentSection:yx,resolveAdjacentTableCellPosition:gx,resolveTableTabTarget:px,applyTableAwareParagraphEdit:T,withExpandedTableCellSelection:k,applySelectionAwareTextCommand:P,applySelectionAwareParagraphCommand:R,insertTableCommand:M}}(e)}function Ux(){let e=null;return{claim:t=>{e=t.pointerId??null},owns:t=>null===e||t.pointerId===e,release:()=>{e=null}}}function jx(e,t){let n=null;const o=(e,t,n)=>{const o=zo(e).find(e=>e.id===t);return o?{anchor:na(o,n),focus:na(o,n+1)}:null},r=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),a=Ux(),i=i=>{if(!a.owns(i))return;const s=n;if(!s)return;const l=t.zoomFactor?.()??1,c=(i.clientX-s.startClientX)/l,d=(i.clientY-s.startClientY)/l,u=e.getMaxWidth(t.state,s.paragraphId),{width:p,height:g}=O(s,c,d,i.shiftKey,u),f=o(t.state,s.paragraphId,s.paragraphOffset);f?t.applyState(e.applyResize(r(t.state,f),p,g,s.handleDirection)):t.logger.warn(`${e.label} resize:missing paragraph`,s)},s=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Yv(n.undoStack,t.cloneState(e.initialState)),redoStack:[]})),l(),t.focusInput()},l=()=>{n=null,a.release(),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)};return{start:(l,c,d,u,p)=>{const g=o(p,l,c);if(!g)return;const f=e.getSelected(r(p,g));f&&(n={paragraphId:l,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",s),window.addEventListener("pointercancel",s))},stop:l}}function Vx(e,t){let n=null;const o=Ux(),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 s=((e,t,n)=>{const o=zo(e).find(e=>e.id===t);return o?{anchor:na(o,n),focus:na(o,n+1)}:null})(t.state,a.paragraphId,a.paragraphOffset);s?t.applyState(e.applyRotate(((e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}))(t.state,s),i)):t.logger.warn(`${e.label} rotate:missing paragraph`,a)},a=()=>{const e=n;e&&t.updateHistoryState(n=>({...n,undoStack:Yv(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,s,l)=>{const c=s.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(l)},o.claim(s),window.addEventListener("pointermove",r),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)},stop:i}}function Kx(e,t){return Math.max(1e-4,1-e-t)}function _x(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 Xx(e){let t=null;const n=(e,t,n)=>{const o=zo(e).find(e=>e.id===t);return o?{anchor:na(o,n),focus:na(o,n+1)}:null},o=(e,t)=>({...e,selection:{anchor:{...t.anchor},focus:{...t.focus}}}),r=Ux(),a=a=>{if(!r.owns(a))return;const i=t;if(!i)return;const s=e.zoomFactor?.()??1,l=(a.clientX-i.startClientX)/s,c=(a.clientY-i.startClientY)/s,d="move"===i.mode?function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=Kx(a,s)/o,d=Kx(i,l)/r,u=1-a-s,p=1-i-l,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,l,c):function(e,t,n){const{startWidth:o,startHeight:r}=e,a=e.startCrop.left??0,i=e.startCrop.top??0,s=e.startCrop.right??0,l=e.startCrop.bottom??0,c=Kx(a,s)/o,d=Kx(i,l)/r,u=Be(e.handleDirection,"x"),p=Be(e.handleDirection,"y");let g=a,f=s,m=o;if(0!==u)if(u<0){m=Ue(o-t,24,o+a/c);const e=_x(a,s,a-(m-o)*c,s);g=e.near,f=e.far}else{m=Ue(o+t,24,o+s/c);const e=_x(a,s,a,s-(m-o)*c);g=e.near,f=e.far}let h=i,b=l,y=r;if(0!==p)if(p<0){y=Ue(r-n,24,r+i/d);const e=_x(i,l,i-(y-r)*d,l);h=e.near,b=e.far}else{y=Ue(r+n,24,r+l/d);const e=_x(i,l,i,l-(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,l,c),u=n(e.state,i.paragraphId,i.paragraphOffset);u?e.applyState(Yy(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:Yv(t.undoStack,e.cloneState(n.initialState)),redoStack:[]})),s(),e.focusInput()},s=()=>{t=null,r.release(),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)},l=(s,l,c,d,u,p)=>{const g=n(u,s,l);if(!g)return;const f=Xy(o(u,g)),m=f&&Uo(f.run);if(!m)return;const h={...m.crop??{}};t={paragraphId:s,paragraphOffset:l,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)=>l(e,t,n,o,r,"handle"),startMove:(e,t,n,o)=>l(e,t,"se",n,o,"move"),stop:s}}function Gx(e){return function(e){const[t,o]=vn(!1),[r,a]=vn(!1),[i,s]=vn(null);n(()=>{r()&&!h(e.state)&&a(!1)});const l=()=>{h(e.state)?a(e=>!e):a(!1)},[c,d]=vn({x:0,y:0}),[u,p]=vn(null);let g=null,f=null,m=null;const h=e=>{const t=ya(e);if(t.isCollapsed||t.startIndex!==t.endIndex||t.endParagraphOffset-t.startParagraphOffset!==1)return null;const n=zo(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:Ea(e.document,r.image.src)}}return null},b=(t,n)=>e.resolvePositionAtSurfacePoint(t,n),y=()=>{m||(m=document.createElement("style"),m.setAttribute("data-oasis-image-drag-cursor",""),m.textContent="*, *::before, *::after { cursor: grabbing !important; }",document.head.appendChild(m))},v=()=>{m&&(m.remove(),m=null),document.body.style.cursor=""},x=Ux(),w=()=>{v(),f=null,g=null,o(!1),s(null),p(null),x.release(),window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P)},S=()=>{w()},I=jx({label:"image",getSelected:e=>h(e),applyResize:(e,t,n)=>Gy(e,t,n),getMaxWidth:(t,n)=>iv(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}),C=Vx({label:"image",applyRotate:(e,t)=>function(e,t){const n=ev(t);return ov(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=Xx({state:e.state,applyState:e.applyState,updateHistoryState:e.updateHistoryState,cloneState:e.cloneState,focusInput:e.focusInput,logger:e.logger,zoomFactor:e.zoomFactor}),k=t=>{if(!x.owns(t))return;let n=g;if(!n){const r=f;if(!r)return;if(Math.abs(t.clientX-r.startClientX)+Math.abs(t.clientY-r.startClientY)<4)return;n={paragraphId:r.paragraphId,paragraphOffset:r.paragraphOffset,src:r.src,width:r.width,height:r.height,offsetX:r.offsetX,offsetY:r.offsetY},g=n,f=null,o(!0),y(),e.logger.info(`image drag:start ${n.paragraphId}@${n.paragraphOffset} client=(${t.clientX},${t.clientY})`)}d({x:t.clientX,y:t.clientY}),s({...n}),p(b(t.clientX,t.clientY))},P=t=>{if(!x.owns(t))return;const n=g;if(n||f){if(n){const o=b(t.clientX,t.clientY);o?(e.logger.info(`image drag:done ${n.paragraphId} -> ${o.paragraphId}:${o.runId}[${o.offset}]`),e.applyTransactionalState(e=>av(e,o),{mergeKey:Mp})):e.logger.warn(`image drag:cancel ${n.paragraphId} no target at (${t.clientX},${t.clientY})`)}w(),e.focusInput()}else e.focusInput()},R=(t,n,r,a)=>{const i=r.currentTarget,l=a?{left:a.left,top:a.top,width:a.width,height:a.height}:i?.getBoundingClientRect();if(!l)return;const c=h(e.state);f={paragraphId:t,paragraphOffset:n,startClientX:r.clientX,startClientY:r.clientY,src:c?.src??"",width:c?.width??l.width,height:c?.height??l.height,offsetX:r.clientX-l.left,offsetY:r.clientY-l.top},g=null,d({x:r.clientX,y:r.clientY}),o(!1),s(null),p(null),x.claim(r),window.addEventListener("pointermove",k),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P)},M=(t,n,o)=>{o.preventDefault(),o.stopPropagation();const r=Nr(e.state.document).find(e=>e.id===t);r&&e.applyState(ii(e.state,{anchor:na(r,n),focus:na(r,n+1)})),R(t,n,o),e.focusInputAfterPointerSelection()},O=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),I.start(t,n,o,r,e.state)},A=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),C.start(t,n,o,e.state)},B=(t,n,o,r)=>{r.preventDefault(),r.stopPropagation(),T.start(t,n,o,r,e.state)},D=(t,n,o)=>{o.preventDefault(),o.stopPropagation(),T.startMove(t,n,o,e.state)};return{dragging:t,cropMode:r,setCropMode:a,toggleCropMode:l,draggedImageInfo:i,mousePos:c,dropTargetPos:u,getSelectedImageInfo:h,startImageDrag:R,stopImageDrag:S,stopImageResize:I.stop,stopImageRotate:C.stop,stopImageCrop:T.stop,handleImagePointerDown:M,handleImageResizeHandlePointerDown:O,handleImageRotateHandlePointerDown:A,handleImageCropHandlePointerDown:B,handleImageCropBodyPointerDown:D}}(e)}function qx(e){return function(e){const t=e=>{const t=nx(e),n=t&&Fo(t.run);return n?{width:n.width,height:l(n,e,0)}:null},n=jx({label:"text box",getSelected:t,applyResize:(e,t,n,o)=>ax(e,t,n,{handleDirection:o}),getMaxWidth:(n,o)=>{const r=iv(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=Vx({label:"text box",applyRotate:(e,t)=>ox(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 Yx(e){return function(e){const[t,o]=vn(void 0),r=()=>{o(void 0)};n(()=>{fr(e.state().selection)||r()});const a=(e,t)=>{o(n=>{const o={...n??{}};return null==t||""===t?delete o[e]:o[e]=t,Object.keys(o).length>0?o:void 0})},i=(e,t)=>{o(n=>{const o={...n??{}};return o[e]=t,"superscript"===e&&t&&(o.subscript=!1),"subscript"===e&&t&&(o.superscript=!1),o})},s=()=>{const n=kn(e.state()),o=t();return fr(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(fr(e.state().selection))return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),a(t,n),void e.focusInput();e.commandsController().applyValueStyleCommand(t,n)},c=t=>{if(fr(e.state().selection)){const n=!s()[t];return e.logger.info(`setPendingStyle:${t}=${JSON.stringify(n)}`),e.clearPreferredColumn(),e.resetTransactionGrouping(),i(t,n),void e.focusInput()}e.commandsController().applyBooleanStyleCommand(t)},d=t=>{if(fr(e.state().selection))return e.clearPreferredColumn(),e.resetTransactionGrouping(),o(e=>({...e,underline:null!==t,underlineStyle:"single"===t?null:t})),void e.focusInput();e.commandsController().applyUnderlineStyleCommand(t)};return{pendingCaretTextStyle:t,clearPendingCaretTextStyle:r,toolbarStyleState:s,applyToolbarValueStyleCommand:l,applyToolbarUnderlineStyleCommand:d,applyToolbarBooleanStyleCommand:c}}(e)}function Zx(e,t,n={}){if(!t)return[];const o=[],r=Nr(e),{matchCase:a=!1,wholeWord:i=!1}=n,s=a?"g":"gi";let l=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i&&(l=`\\b${l}\\b`);const c=new RegExp(l,s);return r.forEach((e,t)=>{const n=Ua(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:na(e,n),focus:na(e,a),paragraphIndex:t}),r.index===c.lastIndex&&c.lastIndex++}}),o}function Jx(e,t,n,o={}){const r=Zx(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=ii(a,{anchor:e.anchor,focus:e.focus}),a=Bu(a,n)}return a}function Qx(e,t,n,o,r,a){const i=e+n,s=t+o;return(a<t?t-a:a>s?a-s:0)*un+(r<e?e-r:r>i?r-i:0)}function ew(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,s=e.slots[0].height;for(const l of e.slots){const e=n<l.top?l.top-n:n>l.top+l.height?n-(l.top+l.height):0,c=Math.abs(t-l.left),d=e*un+c;d<r&&(r=d,o=l.offset,a=l.left,i=l.top,s=l.height)}return{offset:o,score:r,slotLeft:a,slotTop:i,slotHeight:s}}function tw(e,t,n){let o=e.startOffset,r=Number.POSITIVE_INFINITY;for(const a of e.lines){const{offset:e,score:i}=ew(a,t,n);i<r&&(r=i,o=e)}return Math.max(e.startOffset,Math.min(o,e.endOffset))}function nw(e,t,n){return e>=n.left&&e<=n.left+n.width&&t>=n.top&&t<=n.top+n.height}function ow(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,s=a.top+(e.clientY-a.top)/r,l=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=Qx(a.left,a.top,a.width,a.height,t,n);e<r&&(r=e,o=a)}return o}(t.pages,i,s);if(!l)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"}(l,s),d=function(e,t,n,o,r,a){for(let i=e.floatingTextBoxes.length-1;i>=0;i-=1){const s=e.floatingTextBoxes[i];if(s.pageIndex===t&&s.zone===n&&(!s.behindDoc||a)&&o>=s.left&&o<=s.left+s.width&&r>=s.top&&r<=s.top+s.height)return s}return null}(t,l.index,c,i,s,o);if(d){const e=t.paragraphsById.get(d.paragraphId)??[],n=e.find(e=>e.pageIndex===l.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=na(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 s=e.floatingImages[i];if(s.pageIndex===t&&s.zone===n&&(!s.behindDoc||a)&&nw(o,r,s))return s}for(const i of e.inlineImages)if(i.pageIndex===t&&i.zone===n&&nw(o,r,i))return i;return null}(t,l.index,c,i,s,o);if(u){const e=t.paragraphsById.get(u.paragraphId)??[],n=e.find(e=>e.pageIndex===l.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=na(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:s,score:l,slotLeft:c,slotTop:d,slotHeight:u}=ew(e,t,n);(!o||l<o.score)&&(o={paragraph:i,offset:s,score:l,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=Qx(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:tw(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===l.index&&e.zone===c),i,s);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,l.index,c,i,s);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=na(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 rw(e){return function(e){const t=(t,n,o={})=>{const r=e.surfaceRef();if(!r)return null;const a=e.state(),i=e.zoomFactor(),s=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:r,state:a,documentLayout:e.documentLayout(),zoomFactor:i});if(function(e){mp&&(bp=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)}(s),!s)return wp(null),null;const l=ow({snapshot:s,state:a,clientX:t,clientY:n,pierce:o.pierce??!1,zoomFactor:i});return wp(l),l};return{resolveSurfaceHitAtPoint:t}}(e)}var aw=[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1}],iw=/* @__PURE__ */new Map;function sw(){return aw.map(e=>({...e}))}var lw=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];function cw(e,t,n){const[o,r]=e,[a,i]=t,[s,l]=n,c=s-a,d=l-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 dw(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 l=1;l<e.length-1;l+=1){const t=cw(e[l],r,a);t>n&&(n=t,o=l)}if(n<=t)return[r,a];const i=dw(e.slice(0,o+1),t),s=dw(e.slice(o),t);return[...i.slice(0,-1),...s]}function uw(e,t,n){let o=0;for(let l=0;l<e.length;l+=1)1===e[l]&&(o+=1);if(t<=0||n<=0||0===o||o/(t*n)>=.985)return sw();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 s=r,l=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]=lw[n],d=s+r,u=l+a;if(o(d,u)){i.push([s,l]),c=(n+4)%8,s=d,l=u,e=!0;break}}if(!e){i.push([s,l]);break}if(s===r&&l===a&&i.length>1)break}return i}(e,t,n);if(r.length<3)return sw();const a=.012*Math.max(t,n);let i=dw(r,a),s=a;for(;i.length>40;)s*=1.6,i=dw(r,s);return i.length<3?sw():i.map(([e,o])=>({x:Math.min(1,Math.max(0,e/t)),y:Math.min(1,Math.max(0,o/n))}))}function pw(e){const t=e.src,n=iw.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 s=i.getContext("2d",{willReadFrequently:!0});if(!s)return null;let l;s.drawImage(e,0,0,r,a);try{l=s.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)l[4*u+3]>=128&&(c[u]=1,d+=1);return{mask:c,width:r,height:a,foreground:d}}(e);if(!o)return sw();const r=uw(o.mask,o.width,o.height);return iw.set(t,r),r.map(e=>({...e}))}function gw(e){const{state:t,resetTransactionGrouping:n,applyTransactionalState:o,focusInput:r}=e,a=()=>Xy(t())?"image":nx(t())?"textBox":null,i=(e,t)=>{const i=a();i&&(n(),o(e=>t(e,i),{mergeKey:e}),r())},s=(e,n)=>{const r=Ea(t().document,n),a=t=>{const n=pw(t);o(t=>function(e,t,n){const o=zo(e);let r=!1;const a=o.map(e=>e.runs.some(e=>e.id===t&&"image"===e.kind)?{...Er(e),runs:e.runs.map(e=>{if(e.id!==t||"image"!==e.kind)return Oo(e);r=!0;const o={...e.image};return n&&n.length>0?o.wrapPolygon=n:delete o.wrapPolygon,{...e,image:o}})}:Er(e));return r?ro(e,a,C(a,ya(e))):e}(t,e,n),{mergeKey:Hp})},i=an(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=Xy(e),n=t&&Uo(t.run);return n?Vy(n.floating):null}(t()):"textBox"===e?function(e){const t=nx(e),n=t&&Fo(t.run);return n?Vy(n.floating):null}(t()):null},fixedPosition:()=>{const e=a();return"image"===e?function(e){const t=Xy(e),n=t&&Uo(t.run);return _y(n?.floating)}(t()):"textBox"===e&&function(e){const t=nx(e),n=t&&Fo(t.run);return _y(n?.floating)}(t())},setPreset:e=>{if(i(Rg,(t,n)=>"image"===n?function(e,t){return rv(e,e=>jy(e,t))}(t,e):function(e,t){return rx(e,e=>jy(e,t))}(t,e)),"tight"===e||"through"===e){const e=Xy(t()),n=e&&Uo(e.run);n&&!n.wrapPolygon&&s(e.run.id,n.src)}},setFixedPosition:e=>i(Mg,(t,n)=>"image"===n?function(e,t){return rv(e,e=>e?Ky(e,t):e)}(t,e):function(e,t){return rx(e,e=>e?Ky(e,t):e)}(t,e))}}function fw(e){return function(e){let t=0;Hn()&&Tn(()=>{t++});const n=n=>{if(t++,e.onNativeClipboardStart?.(),Tu(e.state()))return n.preventDefault(),void(n.clipboardData&&function(e,t){try{const n=Iu(e);return t.setData(yu,n.token),!!Array.from(t.types).includes("application/x-oasis-chart-token")&&n.confirm()}catch{return!1}}(e.stateSnapshot?.()??e.state(),n.clipboardData)?e.onNativeClipboardSuccess?.():e.onNativeClipboardIssue?.("copy","unsupported"));const o=ai(e.state());if(0!==o.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",ku(e.state()))}catch{return}e.onNativeClipboardSuccess?.()}},o=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();if(Tu(e.state()))return n.preventDefault(),void e.onNativeClipboardIssue?.("cut","unsupported");const o=ai(e.state());if(0!==o.length&&(n.preventDefault(),n.clipboardData)){try{n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",ku(e.state()))}catch{return}e.onNativeClipboardSuccess?.(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Lu(e))),e.focusInput()}},r=n=>{const o=++t;if(e.isReadOnly())return void n.preventDefault();const r=e.consumePasteMode?.(),a=e.clipboardRequestGeneration?.(),i=()=>o!==t||e.clipboardRequestGeneration?.()!==a,s=Array.from(n.clipboardData?.types??[]).filter(xu);if(n.clipboardData&&s.length){n.preventDefault();const t=e.forcePlainTextPaste();e.setForcePlainTextPaste(!1);const o=1===s.length?Cu(n.clipboardData.getData(s[0])):void 0,a=e.stateSnapshot?.();return t||r&&"rich"!==r||!o||!a?void e.onNativeClipboardIssue?.("paste","unsupported"):(n.currentTarget.value="",(async()=>{let t;try{t=await bu(a,o)}catch{return void(i()||e.isReadOnly()||e.onNativeClipboardIssue?.("paste","unsupported"))}if(i()||e.isReadOnly())return;if(e.stateSnapshot?.()!==a)return void e.onNativeClipboardIssue?.("paste","document-changed");let n=!1;e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(o=>i()||e.isReadOnly()||o!==a?o:(n=!0,t)),n?(e.onNativeClipboardSuccess?.(),e.focusInput()):e.onNativeClipboardIssue?.("paste","document-changed")})())}if(e.forcePlainTextPaste()||"text"===r){e.setForcePlainTextPaste(!1);const t=n.clipboardData?.getData("text/plain")??"";return 0===t.length?void n.preventDefault():(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>Fu(e,t))),n.currentTarget.value="",void e.focusInput())}const l="merge"!==r?Wy(n.clipboardData):null;if(l)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.insertImageFromFile(l),n.currentTarget.value="",void e.focusInput();const c=Yu(n.clipboardData?.getData("text/html")??""),d="merge"===r?qu(e.state(),c):c;if(d.length>0)return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Pu(e,d))),n.currentTarget.value="",void e.focusInput();const u=n.clipboardData?.getData("text/plain")??"";0!==u.length&&(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Fu(e,u))),n.currentTarget.value="",e.focusInput())},a=n=>{if(t++,e.onNativeClipboardStart?.(),e.isReadOnly())return void n.preventDefault();const o=Wy(n.dataTransfer);if(!o)return;n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping();const r=e.resolvePositionAtSurfacePoint(n.clientX,n.clientY)??e.state().selection.focus;e.insertImageFromFile(o,r),e.focusInput()};return{handleCopy:n,handleCut:o,handlePaste:r,handleDrop:a}}(e)}var mw=/* @__PURE__ */new WeakMap;function hw(e,t){return function(e){return ka(e.document).flatMap(e=>[...e.header??[],...e.blocks,...e.footer??[]])}(e).find(e=>"table"===e.type&&e.id===t)??null}function bw(e,t,n,o,r){const a=o.getCanvasLayoutSnapshot({surface:e,state:t,documentLayout:n,zoomFactor:r});if(!a)return[];const i=mw.get(a);if(i)return i;const s=/* @__PURE__ */new Map,l=/* @__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=s.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),s.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=l.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)):l.set(g,{left:i,top:u,right:c,bottom:p})}for(const[d,u]of s.entries())for(const e of u.values()){const t=l.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 s.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 mw.set(a,c),c}function yw(e,t,n,o,r,a){const i=bw(t,n,o,r,a);if(0===i.length)return null;let s=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&&(!s||n<s.distance)&&(s={geometry:d,cell:t,side:"left",distance:n});const o=Math.abs(e.clientX-t.right);o<=4&&(!s||o<s.distance)&&(s={geometry:d,cell:t,side:"right",distance:o})}if(o){const n=Math.abs(e.clientY-t.top);n<=4&&(!s||n<s.distance)&&(s={geometry:d,cell:t,side:"top",distance:n});const o=Math.abs(e.clientY-t.bottom);o<=4&&(!s||o<s.distance)&&(s={geometry:d,cell:t,side:"bottom",distance:o})}}if(!s)return null;const l=hw(n,s.geometry.tableId);if(!l)return null;const c=Kr(l).find(e=>e.rowIndex===s.cell.rowIndex&&e.cellIndex===s.cell.cellIndex);return c?{tableId:s.geometry.tableId,rowIndex:s.cell.rowIndex,cellIndex:s.cell.cellIndex,side:s.side,rect:s.cell,tableNode:l,layoutEntry:c,tableGeometry:s.geometry}:null}var vw=1/.75;function xw(e){return.75*e}function ww(e){return e*vw}var Sw=Cf;function Iw(e){return("number"==typeof e.style?.padding&&Number.isFinite(e.style.padding)?2*Math.max(0,ww(e.style.padding)):Math.max(0,(void 0!==e.style?.paddingLeft?ww(e.style.paddingLeft):7.2)+(void 0!==e.style?.paddingRight?ww(e.style.paddingRight):7.2)))+(e.style?.borderLeft?Math.max(0,ww(e.style.borderLeft.width)):1)+(e.style?.borderRight?Math.max(0,ww(e.style.borderRight.width)):1)}function Cw(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 s=0;s<o;s+=1){const n=Sw(e.rows[s]?.style?.height);if(null!==n){a[s]=Math.max(1,ww(n));continue}const o=t.find(e=>e.rowIndex===s&&1===e.rowSpan);if(o){const e=i.get(`${o.rowIndex}:${o.cellIndex}`);e&&(a[s]=Math.max(1,e.height))}}return a}function Tw(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 l=0;l<o;l+=1)a[l]=Math.max(1,ww(e.gridCols[l]));else for(const l of t){if(1!==l.colSpan)continue;const e=i.get(`${l.rowIndex}:${l.cellIndex}`);e&&(a[l.visualColumnIndex]=Math.max(1,e.width))}const s={};for(let l=0;l<o;l+=1)s[l]=Math.max(10,xw(a[l]));return{widthsPt:s,maxColumnIndex:r}}function kw(e,t,n){if("row"!==t.type)return e;const o=t.initialRowHeightPx??ww(10),r=Math.max(ww(10),t.minRowHeightPx??ww(10)),a=Math.max(10,xw(Math.max(r,o+n)));return function(e,t,n,o){return If(e,t,{[n]:o})}(e,t.tableId,t.index,a)}function Pw(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 Rw=null;function Mw(e,t){Rw=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 Ow(e){e&&Rw!==e||(Rw=null,document.body.classList.remove("oasis-editor-hover-col-resize"),document.body.classList.remove("oasis-editor-hover-row-resize"))}function Aw(e,t){Mw(e,t)}function Bw(e){return"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(e):globalThis.setTimeout(e,16)}function Dw(e){"undefined"==typeof window||"function"!=typeof window.cancelAnimationFrame?globalThis.clearTimeout(e):window.cancelAnimationFrame(e)}function Fw(e){const[t,n]=vn(null);let o=null,r=null,a=null,i=null;const s={},l=()=>{o=null;const n=r;if(r=null,!n||t())return;const a=e.surfaceRef();if(!a)return void Ow();const i=yw(n,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());i?Mw("left"===i.side||"right"===i.side,s):Ow()},c=Ux(),d=e=>{c.owns(e)&&t()&&(i={clientX:e.clientX,clientY:e.clientY},null===a&&(a=Bw(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:Pw(e.viewportRef)})},p=()=>{r=null,i=null,null!==o&&(Dw(o),o=null),null!==a&&(Dw(a),a=null),n(null),Ow(s),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?kw(e,o,a):function(e,t,n){if("column"!==t.type)return e;const o=xw(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??{},s=a[t.index]??10,l=Math.max(10,xw(i[t.index]??ww(10)));if(t.resizeFromLeftEdge){const n=Math.max(0,t.initialTableIndentLeftPt??0);let r=Math.max(l,s-o),i=s-r;n+i<0&&(i=-n,r=s-i),a[t.index]=r;const c=Object.values(a).reduce((e,t)=>e+t,0),d=Math.max(0,n+i);return Tf(e,t.tableId,a,c,d)}let c=Math.max(l,s+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,xw(i[e]??ww(10)));let r=n-(c-s);r<o&&(r=o,c=s+(n-o),c=Math.max(l,c)),a[t.index]=c,a[e]=r}const u=Object.values(a).reduce((e,t)=>e+t,0),p=hw(e,t.tableId),g=Sw(p?.style?.width),f=d?u:null!==g?g:void 0;return Tf(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=Bw(l))))},handlePointerDown:t=>{r=null,null!==o&&(Dw(o),o=null),Ow();const a=e.surfaceRef();if(!a)return!1;const i=yw(t,a,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.());if(!i)return!1;const l=e.state(),u=Kr(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}=Tw(i.tableNode,u,i.tableGeometry),m=function(e,t,n,o){const r=ww(10),a={},i=new Map(o.cells.map(e=>[`${e.rowIndex}:${e.cellIndex}`,e]));for(const s of n){if(1!==s.colSpan)continue;if(!i.get(`${s.rowIndex}:${s.cellIndex}`))continue;const n=t.rows[s.rowIndex]?.cells[s.cellIndex];if(!n)continue;const o=s.visualColumnIndex,l=a[o]??r,c=n.blocks.reduce((t,n)=>"paragraph"!==n.type?t:Math.max(t,Ke(n,e.document.styles)),1);a[o]=Math.max(l,c+Iw(n)+12,r)}return a}(l,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:Sw(i.tableNode.style?.indentLeft)??0,guideBounds:Pw(e.viewportRef)}),Aw(!0,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0}const p=Cw(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 ww(10);const a=ww(10);let i=a;for(let s=0;s<r.cells.length;s+=1){if(!r.cells[s])continue;const e=t.find(e=>e.rowIndex===o&&e.cellIndex===s);if(!e||1!==e.rowSpan)continue;const a=n.cells.find(e=>e.rowIndex===o&&e.cellIndex===s);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:Pw(e.viewportRef)}),Aw(!1,s),c.claim(t),window.addEventListener("pointermove",d),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),t.preventDefault(),t.stopPropagation(),!0},stop:p}}var Ew=null;function Lw(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=ww(10),s=e.rowHeightsPx.length>0?Math.min(...e.rowHeightsPx):i,l=s>0?i/s:0;return{scaleX:Math.max(a,t),scaleY:Math.max(l,n)}}function Nw(e){const[t,n]=vn(null);let o=null,r=null;const a={},i=Ux(),s=e=>{i.owns(e)&&t()&&(r={clientX:e.clientX,clientY:e.clientY},null===o&&(o=Bw(l)))},l=()=>{o=null;const e=r;r=null,e&&n(t=>t?{...t,currentClientX:e.clientX,currentClientY:e.clientY}:null)},c=()=>{r=null,null!==o&&(Dw(o),o=null),n(null),i.release(),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d),Ew===a&&(Ew=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}=Lw(t);e.applyTransactionalState(e=>function(e,t,n,o){const r={};for(const l of Object.keys(t.widthsPt)){const e=Number(l);r[e]=Math.max(10,t.widthsPt[e]*n)}const a=Object.values(r).reduce((e,t)=>e+t,0),i=Tf(e,t.tableId,r,a),s={};return t.rowHeightsPx.forEach((e,t)=>{s[t]=Math.max(10,xw(e*o))}),If(i,t.tableId,s)}(e,t,r,a))}}c()};return{resizing:t,previewRect:()=>{const e=t();if(!e)return null;const{scaleX:n,scaleY:o}=Lw(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 l=bw(r,e.state(),e.documentLayout(),e.canvasSnapshotProvider,e.zoomFactor?.()).find(e=>e.tableId===t),c=hw(e.state(),t);if(!l||!c)return;const u=Kr(c),{widthsPt:p}=Tw(c,u,l),g=Cw(c,u,l),f=Object.values(p).reduce((e,t)=>e+t,0);n({tableId:t,bounds:{left:l.bounds.left,top:l.bounds.top,width:Math.max(1,l.bounds.width),height:Math.max(1,l.bounds.height)},startClientX:o.clientX,startClientY:o.clientY,currentClientX:o.clientX,currentClientY:o.clientY,widthsPt:p,totalWidthPt:f,rowHeightsPx:g}),Ew=a,document.body.style.cursor="nwse-resize",i.claim(o),window.addEventListener("pointermove",s),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),o.preventDefault(),o.stopPropagation()},stop:c}}var zw=null;function $w(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=$w(n.blocks,t,!0,!1);if(e)return e}}return null}function Hw(e,t){for(const n of za(e)){for(const e of[n.blocks,n.header,n.footer]){const n=$w(e,t,!1,!0);if(n)return n}for(const e of[n.firstPageHeader,n.evenPageHeader,n.firstPageFooter,n.evenPageFooter]){const n=$w(e,t,!1,!1);if(n)return n}}for(const n of Object.values(e.footnotes?.items??{})){const e=$w(n.blocks,t,!1,!1);if(e)return e}for(const n of Object.values(e.endnotes?.items??{})){const e=$w(n.blocks,t,!1,!1);if(e)return e}return null}function Ww(e){return function(e){const[t,n]=vn(!1),[o,r]=vn(null),[a,i]=vn(null),[s,l]=vn(0),[c,d]=vn(0),[u,p]=vn({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=Ux(),v=()=>{f=null,null!==g&&(Dw(g),g=null),n(!1),r(null),i(null),y.release(),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I),zw===m&&(zw=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=Hw(e,n);return Boolean(o?.table&&oa(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-s())<=4)return;n(!0),zw=m,document.body.style.cursor="grabbing"}f={clientX:e.clientX,clientY:e.clientY},null===g&&(g=Bw(x))}},I=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=Hw(e.document,o),a=r?.table;if(a?.style?.floating){const t=a.style.floating;return xf(e,o,"floating",{...t,x:(t.x??0)+(n.clientX-c())*Qa,y:(t.y??0)+(n.clientY-s())*Qa,xAlign:void 0,yAlign:void 0})}return r&&!r.nested&&r.movableTopLevelStory&&t?S(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}),l(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",I),window.addEventListener("pointercancel",I)},stop:v}}(e)}var Uw=e=>"touch"===e.pointerType;function jw(e,t){if(!e||0===e.length){const e=$a(t);return{paragraph:e,blocks:[e]}}const n=e[0];return{paragraph:"paragraph"===n.type?n:oa(n)[0]??null,blocks:e}}function Vw(e,t,n){const o=Nr(e.document).filter(t=>{const o=Fa(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:na(t,0),end:a?na(a,0):na(t,Ua(t).length)}}function Kw(e){return function(e){let t=null,n=null,o=null,r=0,a=0,i=0,s=0,l=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?Fa(o.document,r.paragraphId)?.footnoteId:void 0,s="footnote"===n&&i!==t.activeFootnoteId;if(!a&&!s)return void e.applyState(o);let l=o.document,c=t.activeSectionIndex??0;if(!l.sections||0===l.sections.length){const e=$a("header"),t=$a("footer");l={...l,sections:[{id:"section:1",blocks:[],pageSettings:Yr(l.pageSettings??Aa),header:[e],footer:[t]}]},c=0}const d=l.sections,u=d[c];let p=u.header,g=u.footer,f=null;if("header"===n){const e=jw(p,"header");f=e.paragraph,p=e.blocks}else if("footer"===n){const e=jw(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},l={...l,sections:e}}const m=r||(f?na(f,0):o.selection.anchor);e.applyState({...o,document:l,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=lr(n),a=rr(n.document,o.anchor.paragraphId,r),i=rr(n.document,o.focus.paragraphId,r),s=a?`b${a.blockIndex}r${a.rowIndex}c${a.cellIndex}`:"",l=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}] [${s}→${l}]`)},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(Fa(i.document,t.paragraphId)?.sectionIndex!==Fa(i.document,a.paragraphId)?.sectionIndex)return;const s=ii(i,{anchor:t,focus:a.position});b(i,a.zone,s,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&&(F(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=na(r,o.textBox.startOffset),i=na(r,o.textBox.endOffset);b(n,o.zone,ii(n,{anchor:a,focus:i}),a),x(),e.focusInputAfterPointerSelection()},M=(n,o,r)=>{const a=e.getParagraphById(n.document,o.image.paragraphId);if(!a)return void e.focusInputAfterPointerSelection();t=null;const i=na(a,o.image.startOffset),s=na(a,o.image.endOffset);b(n,o.zone,ii(n,{anchor:i,focus:s}),i),x(),Uw(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()},O=(n,o,r)=>{t=n.selection.anchor,b(n,o.zone,ii(n,{anchor:n.selection.anchor,focus:o.position}),o.position),w(r),e.focusInputAfterPointerSelection()},A=(n,o,r)=>{t=null;const a=Vw(n,r,o.zone);b(n,o.zone,ii(n,{anchor:a.start,focus:a.end}),a.start),x(),e.focusInputAfterPointerSelection()},B=(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=na(r,o.paragraphOffset);return b(n,o.zone,ii(n,{anchor:t,focus:t}),t),x(),void e.openEquationDialog(i.math,i.id)}const s=wn(Ua(r),o.paragraphOffset),l=na(r,s.start),c=na(r,s.end);b(n,o.zone,ii(n,{anchor:l,focus:c}),l),x(),e.focusInputAfterPointerSelection()},D=(n,o,r,a)=>{if(e.imageOps.stopImageDrag(),e.imageOps.stopImageResize(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!o)return void e.focusInputAfterPointerSelection();if(!Uw(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?M(n,o,a):a.shiftKey&&o.resolvedFromParagraph?O(n,o,a.pointerId):r>=3&&i?A(n,o,i):2===r&&i?B(n,o,i):o.resolvedFromParagraph?(t=o.position,b(n,o.zone,{...n,selection:{anchor:{...o.position},focus:{...o.position}}},o.position),Uw(a)||w(a.pointerId),e.focusInputAfterPointerSelection()):e.focusInputAfterPointerSelection():P(n,o,r)},F=(t,n,o)=>{D(e.state(),t,n,o),e.focusInputSync()},E=()=>{const n=f;if(!n)return;n.longPressHandle=null,n.longPressFired=!0;const o=n.hit;if(!o?.resolvedFromParagraph)return;const r=e.state(),a=e.getParagraphById(r.document,o.paragraphId);if(!a)return;const i=wn(Ua(a),o.paragraphOffset),s=na(a,i.start),l=na(a,i.end);b(r,o.zone,ii(r,{anchor:s,focus:l}),s),t=s,e.focusInputSync()},L=t=>{if(0!==t.button)return;const n=Date.now(),o=Math.hypot(t.clientX-i,t.clientY-s);r=n-a<=450&&o<=((e,t)=>Uw(e)?20:t)(t,6)&&t.button===l?r+1:1,a=n,i=t.clientX,s=t.clientY,l=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,Uw(t))return v(),f={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,startedAt:n,hit:h,clickDetail:g,longPressHandle:setTimeout(E,500),longPressFired:!1},void w(t.pointerId);t.preventDefault(),D(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 s=Vw(o,i,a.zone);b(o,a.zone,ii(o,{anchor:s.start,focus:s.end}),s.start),x(),e.focusInputAfterPointerSelection()},z=(e,t)=>{0===t.button&&(Uw(t)||t.preventDefault(),L(t))};return{handleSurfacePointerDown:L,handleSurfaceClick:N,handleSurfaceDblClick:e=>{e.preventDefault()},handleParagraphPointerDown:z,stopDragging:x}}(e)}function _w(e){return function(e){const[n,o]=vn(!1);let r,a=0,i="",s=null;const l=()=>{a=0,i="",r=void 0},c=(n,o)=>{if(!o&&n===i)return;if(0===a&&0===n.length)return void(o&&l());const c=a,d=Gr(r);e.clearPreferredColumn(),e.applyTransactionalState(o=>e.applyTableAwareParagraphEdit(o,e=>{const o=function(e,n){if(n<=0)return e;const{paragraph:o,index:r,offset:a}=te(e);if(a<n)return e;const i=zo(e),s=a-n;if(ze(e,o,s,a))return e;const l=To(o,z(o)?je(o,s,a,()=>null):[...t(o,0,s),...t(o,a,xa(o))],ue(o,s)),c=i.map((e,t)=>t===r?l:e);return ro(e,c,E(na(l,s)))}(e,c);return n.length>0?Bu(o,n,d):o}),{mergeKey:kp}),o?(l(),s=n.length>0?n:null):(a=n.length,i=n)},d=t=>{if(R("input:text"),e.isReadOnly())return e.logger.debug(`input:readonly ignored value=${JSON.stringify(t.currentTarget.value)}`),t.currentTarget.value="",void l();const o=t.currentTarget.value;if(0===o.length)return;if(n())return e.logger.debug(`input:composing buffer=${JSON.stringify(o)}`),void c(o,!1);if(null!==s){const n=o===s;if(s=null,n)return e.logger.debug(`input:suppressed text=${JSON.stringify(o)}`),void(t.currentTarget.value="")}const r=e.state(),a=r.selection,i=zo(r).find(e=>e.id===a.anchor.paragraphId)?.runs.find(e=>e.id===a.anchor.runId),d=i?{bold:i.styles?.bold,italic:i.styles?.italic,underline:i.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=Gr(e.pendingCaretTextStyle());e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Bu(e,o,u)),{mergeKey:Tp}),t.currentTarget.value="",e.focusInput(),He("input:text")},u=()=>{e.logger.debug("input:composition start"),l(),s=null,r=Gr(e.pendingCaretTextStyle()),o(!0)},p=t=>{e.isReadOnly()||c(t.data??"",!1)},g=t=>{if(o(!1),e.isReadOnly())return t.currentTarget.value="",void l();const n=t.data??t.currentTarget.value,r=e.state().selection;e.logger.info(`input:composition end ${JSON.stringify(n)} (len=${n.length}) at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}]`),c(n,!0),t.currentTarget.value="",e.focusInput()};return{handleTextInput:d,handleCompositionStart:u,handleCompositionUpdate:p,handleCompositionEnd:g,composing:n}}(e)}var Xw="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 Gw(e,t){const n=ya(e);if(n.isCollapsed)return!1;const o=zo(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=ia(a,t);return!(r===n.startIndex&&i<n.startParagraphOffset)&&!(r===n.endIndex&&i>n.endParagraphOffset)}function qw(e,t,n,o,r,a){if(n.zone===Sr(e))return r(e,e=>Au(e,t,{copy:o}));if(o||n.tableCellAnchorPosition||!["main","header","footer"].includes(n.zone))return e;if("main"!==n.zone&&"header"!==n.zone&&"footer"!==n.zone)return e;try{return function(e,t){const n=e.document.sourcePackage,o=Sr(e);if(!n||1!==e.document.sections?.length||e.trackChangesEnabled||e.document.opaqueRelocationIntent||e.document.opaqueDeletionIntents?.length)throw Error("Relocation requires a single-section source-backed document without pending opaque edits or tracked changes");if("main"!==o&&"header"!==o&&"footer"!==o)throw Error("Unsupported source zone");if(o===t.zone||"main"!==o&&e.activeHeaderFooterStory&&"default"!==e.activeHeaderFooterStory)throw Error("Only distinct default stories are supported");if(e.document.bookmarks?.order.length||e.document.comments?.order.length)throw Error("Cross-story anchors are not supported");const r=ci(e,e=>"opaque"===e.kind);if(!r||"opaque"!==r.run.kind||"inline"!==r.run.opaque.placement||r.run.revision||r.run.sdtWrappers?.length)throw Error("Select exactly one unwrapped inline opaque object");const a=Wa(n,o),i=Wa(n,t.zone),s=r.run.opaque.signature,l=(n.opaqueObjects??[]).filter(e=>e.signature===s),c=1===l.length?l[0]:void 0;if(!c||c.ownerPath!==a)throw Error("Ambiguous source identity");const d=va(n,c,i),u=e.document.sections[0],p="main"===o?u.blocks:u[o],g="main"===t.zone?u.blocks:u[t.zone];if(!p?.some(e=>"paragraph"===e.type&&e.id===r.paragraph.id)||!g?.some(e=>"paragraph"===e.type&&e.id===t.paragraphId))throw Error("Only top-level paragraphs of existing stories are supported");const f={...e,activeSectionIndex:0,activeZone:t.zone,activeHeaderFooterStory:"default"},m=zo(f).find(e=>e.id===t.paragraphId);if(!m||!Number.isInteger(t.offset)||t.offset<0||t.offset>xa(m))throw Error("Invalid destination offset");const h={...Z(e),activeZone:t.zone,activeSectionIndex:0,activeHeaderFooterStory:"default"},b=zo(h),y=b.find(e=>e.id===t.paragraphId);if(!y)throw Error("Destination unavailable after deletion");const v=Oo(r.run);if("opaque"!==v.kind)throw Error("Invalid cloned object");const x=G(y,t.offset,[{...v,opaque:d.destinationRun}]),w=ro(h,b.map(e=>e.id===x.id?x:e),{anchor:na(x,t.offset),focus:na(x,t.offset+1)});return{...w,document:{...w.document,opaqueRelocationIntent:{ownerPath:c.ownerPath,ordinal:c.ordinal,signature:c.signature,destinationOwner:i}}}}(e,{zone:n.zone,paragraphId:n.paragraphId,offset:n.paragraphOffset})}catch(i){return a?.(i),e}}function Yw(e){return function(e){const[t,n]=vn(!1),[o,r]=vn(null),[a,i]=vn(!1),[s,l]=vn(null),[c,d]=vn(null);let u=null,p=null,g=null,f=null;const m=()=>{p&&(p.remove(),p=null)},h=()=>{p||(p=document.createElement("style"),p.setAttribute("data-oasis-text-drag-cursor",""),p.textContent=`*, *::before, *::after { cursor: ${Xw} !important; }`,document.head.appendChild(p))},b=Ux(),y=()=>{e.logger?.info("text-drag:stop",{dragging:t(),dropTarget:o()?`${o().paragraphId}:${o().runId}[${o().offset}]`:null,copyMode:a()}),u=null,g=null,f=null,n(!1),r(null),i(!1),l(null),d(null),m(),b.release(),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)},v=o=>{if(!b.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),h()}l({x:o.clientX,y:o.clientY});const s=e.resolveSurfaceHitAtPoint(o.clientX,o.clientY,{forDrag:!0});if(f=s?.resolvedFromParagraph?s:null,!s?.resolvedFromParagraph)return e.logger?.debug("text-drag:hit-miss",{x:o.clientX,y:o.clientY}),r(null),void d(null);const c=s.tableCellAnchorPosition??s.position,p=`${c.paragraphId}:${c.runId}[${c.offset}]|${s.zone}|src=${s.tableCellAnchorPosition?"cell-anchor":"hit"}`;p!==g&&(e.logger?.info("text-drag:target",{x:o.clientX,y:o.clientY,zone:s.zone,resolvedFromParagraph:s.resolvedFromParagraph,paragraphId:s.paragraphId,paragraphOffset:s.paragraphOffset,hitPosition:`${s.position.paragraphId}:${s.position.runId}[${s.position.offset}]`,target:`${c.paragraphId}:${c.runId}[${c.offset}]`,source:s.tableCellAnchorPosition?"tableCellAnchorPosition":"position"}),g=p),r(c),d(s.caretViewport??null)},x=n=>{if(b.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}),"pointercancel"!==n.type){if(t()&&o()&&f){const t=o(),r=n.ctrlKey||n.metaKey,a=f;e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(n=>qw(n,t,a,r,e.applyTableAwareParagraphEdit,t=>e.logger?.warn?.("text-drag:relocation-rejected",t)),{mergeKey:r?Yp:Zp}),e.logger?.info("text-drag:apply",{mode:r?"copy":"move",destination:`${t.paragraphId}:${t.runId}[${t.offset}]`})}else if(u){const t=u.position,n=e.state(),o=Gw(r=n,i=t)?ii(r,{anchor:i,focus:i}):r;o!==n&&e.applyState(o),e.logger?.info("text-drag:collapse",{at:`${t.paragraphId}:${t.runId}[${t.offset}]`})}var r,i;y(),e.focusInputAfterPointerSelection()}else y()},w=(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):Gw(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},l({x:t.clientX,y:t.clientY}),i(t.ctrlKey||t.metaKey),r(null),f=null,d(o.caretViewport??null),n(!1),b.claim(t),window.addEventListener("pointermove",v),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),!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:s,caretViewport:c,tryStartTextDrag:w,stopDrag:y}}(e)}function Zw(e){return e.blocks.flatMap(oa)}function Jw(e,t){if(!e)return;const n=Zw(e);return"start"===t?n[0]:n[n.length-1]}function Qw(e){return function(e){const t=(t,n)=>{const o=e.state(),r=zo(o).find(e=>e.id===o.selection.focus.paragraphId);if(!r)return!1;const a="start"===t?0:Ua(r).length,i=na(r,a);return e.clearPreferredColumn(),e.applyState(ii(o,{anchor:n?o.selection.anchor:i,focus:i})),!0},n=(t,n)=>{const o=e.state(),r=zo(o);if(0===r.length)return!1;const a="start"===t?r[0]:r[r.length-1],i="start"===t?0:Ua(a).length,s=na(a,i);return e.clearPreferredColumn(),e.applyState(ii(o,{anchor:n?o.selection.anchor:s,focus:s})),!0},o=(t,n)=>{const o=e.state(),r=zo(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId),i=r[a];if(!i)return!1;const s=Ua(i),l=ia(i,o.selection.focus),c=s.length;if(!n&&!fr(o.selection))return e.clearPreferredColumn(),e.applyState("left"===t?si(o):li(o)),!0;let d=i,u=l;"left"===t?0===l&&a>0?(d=r[a-1],u=Ua(d).length):u=Qn(s,l):l===c&&a<r.length-1?(d=r[a+1],u=0):u=Ot(s,l);const p=na(d,u);return e.clearPreferredColumn(),e.applyState(ii(o,{anchor:n?o.selection.anchor:p,focus:p})),!0},r=e=>a(e,!1),a=(t,n)=>{const o=e.state(),r=zo(o),a=r.findIndex(e=>e.id===o.selection.focus.paragraphId);if(-1===a)return!1;const i=e.surfaceRef(),s=i?.getBoundingClientRect()??null,l=e.preferredColumnX(),c=null===l?e.caretBox().left+(s?.left??0):l,d=i?e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:i,state:o,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()}):null;let u=a+t;const p=$r(o.document,o.selection.focus.paragraphId,lr(o)),f=p?.tablePath[p.tablePath.length-1];if(p&&f){const e=bx(o,p.zone),n=Bo(e,p.tablePath),a=n?.[n.length-1]?.table;if(a){const e=Kr(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&&Zw(e.cell).length>0&&"continue"!==e.cell.vMerge);if(0===o.length)continue;const i=o.map(e=>{const t=Jw(e.cell,"start")?.id,n=t?d?.paragraphs.find(e=>e.paragraphId===t&&e.tableCell&&e.tableCell.tableId===a.id)?.tableCell:null,o=n?.left??c,r=n?n.left+n.width:c;return{entry:e,distance:c<o?o-c:c>r?c-r:0}}).sort((e,t)=>e.distance-t.distance)[0]?.entry;if(!i)continue;const s=Jw(i.cell,t<0?"end":"start");u=s?r.findIndex(e=>e.id===s.id):-1;break}}else if(t<0){const e=Jw(a.rows[0]?.cells[0],"start");e&&(u=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=Jw(t,"end");n&&(u=r.findIndex(e=>e.id===n.id)+1)}}}if(u<0||u>=r.length)return!1;const m=r[u];let h=0;const b=d?g(d,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(c-t.left)<Math.abs(c-e.left)?t:e,n.slots[0]).offset:0}else h=Math.min(ia(m,o.selection.focus),Ua(m).length);return e.setPreferredColumnX(c),e.resetTransactionGrouping(),e.applyTransactionalState(e=>ii(e,{anchor:n?e.selection.anchor:na(m,h),focus:na(m,h)})),e.focusInput(),!0},i=()=>{const t=e.state();if(!fr(t.selection))return!1;const n=e.surfaceRef(),o=e.caretBox();if(!n||!o.visible)return!1;const r=zo(t).find(e=>e.id===t.selection.focus.paragraphId);if(!r)return!1;const a=ia(r,t.selection.focus);if(a<=0)return!1;const i=e.canvasSnapshotProvider.getCanvasLayoutSnapshot({surface:n,state:t,documentLayout:e.documentLayout(),zoomFactor:e.zoomFactor?.()});return!!i&&function(e,t,n){if(t<=0||!Number.isFinite(n))return!1;const o=e.filter(e=>e.startOffset<=t&&e.endOffset>=t&&n>=e.top-.5&&n<e.top+e.height-.5);return 1===o.length&&o[0].startOffset===t}(g(i,r.id).flatMap(e=>e.lines),a,o.top+i.surfaceRect.top+Math.min(1,o.height/2))};return{isCaretAtWrappedLineStart:i,moveSelectionToParagraphBoundary:t,moveSelectionToDocumentBoundary:n,moveSelectionByWord:o,moveVerticalByBlock:r,moveVerticalSelection:a}}(e)}function eS(e){return function(e){const[t,n]=vn(null),o=(t,o)=>{const r=zo(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 za(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 s=o.currentTarget.getBoundingClientRect(),l=e.surfaceRef()?.getBoundingClientRect();if(!l)return;const c=e.zoomFactor?.()??1;n({revisionId:a.id,author:a.author,date:a.date,type:a.type,left:(s.left-l.left)/c,top:(s.top-l.top)/c})};return{hoveredRevision:t,handleRevisionMouseEnter:o,handleRevisionMouseLeave:()=>{n(null)}}}(e)}function tS(e){const n=zo(e);if(!n.length)return null;const o=ya(e,n),r=n[o.startIndex];if(!r)return null;const a=(o.isCollapsed?[]:t(r,o.startParagraphOffset,o.startIndex===o.endIndex?o.endParagraphOffset:xa(r))).find(e=>"text"===e.kind&&e.text.length>0),i=function(e){const t=Gr(e);if(t)return delete t.link,delete t.propertyRevision,Object.keys(t).length>0?t:void 0}(Ra(a?a.styles:ue(r,o.startParagraphOffset),r.style?.styleId,e.document.styles)),s=o.isCollapsed||0===o.startParagraphOffset&&(o.endIndex>o.startIndex||o.endParagraphOffset===xa(r));return{text:i,paragraph:s?ma(r.style):void 0,list:s&&r.list?{...r.list}:void 0,copyParagraph:s}}function nS(e,n){const o=zo(e);if(!o.length)return e;const r=ya(e,o);if(r.isCollapsed)return e;let a=!1;const i=o.map((e,o)=>{if(o<r.startIndex||o>r.endIndex)return e;const i=o===r.startIndex?r.startParagraphOffset:0,s=o===r.endIndex?r.endParagraphOffset:xa(e),l=n.copyParagraph&&function(e,t,n){return(t>n.startIndex||0===n.startParagraphOffset)&&(t<n.endIndex||n.endParagraphOffset===xa(e))}(e,o,r),c=l?ma(n.paragraph):e.style,d=l?n.list?{...n.list}:void 0:e.list,u=l&&(JSON.stringify(c)!==JSON.stringify(e.style)||JSON.stringify(d)!==JSON.stringify(e.list)),p=i<s&&t(e,i,s).some(e=>{if("text"!==e.kind||0===e.text.length)return!1;const t=Gr(n.text)??{};void 0!==e.styles?.link&&(t.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(t.propertyRevision=e.styles.propertyRevision);const o=Object.keys(t).length?t:void 0;return!wa(e.styles,o)});if(!u&&!p)return e;a=!0;let g=p?le(e,i,s,e=>{if("text"!==e.kind)return e;const t=Gr(n.text)??{};return void 0!==e.styles?.link&&(t.link=e.styles.link),void 0!==e.styles?.propertyRevision&&(t.propertyRevision=e.styles.propertyRevision),{...e,styles:Object.keys(t).length?t:void 0}}):e;return l&&(g={...g,style:c,list:d}),g});return a?ro(e,i,C(i,r)):e}function oS(e){const t=zo(e);if(!t.length)return"";const n=ya(e,t);return[e.activeSectionIndex??0,e.activeZone??"main",n.start.paragraphId,n.startParagraphOffset,n.end.paragraphId,n.endParagraphOffset].join(":")}function rS(e){const[t,o]=vn(null);let r=null,a=null,i="";const s=()=>{r=null,a=null,i="",o(null)};Hn()&&(n(()=>{t()&&(e.isReadOnly()||e.state().document!==a)&&s()}),Tn(s));const l=()=>!e.isReadOnly()&&zo(e.state()).length>0,c=t=>{if(!l())return!1;const n=e.state(),s=tS(n);return!!s&&(r=s,a=n.document,i=oS(n),o(t),e.focusInput(),!0)};return{mode:t,canCapture:l,armOnce:()=>c("once"),armContinuous:()=>c("continuous"),cancel:s,applyToSelection:n=>{if(!r||!t())return!1;if(e.isReadOnly()||e.state().document!==a)return s(),!1;const o=e.state();if(oS(o)===i)return!1;const l=function(e,t){const n=zo(e);if(0===n.length)return null;const o=ya(e,n);if(!o.isCollapsed)return e;if(!t)return null;const r=n[o.startIndex];if(!r)return null;const a=wn(Ua(r),o.startParagraphOffset);return a.end<=a.start?null:{...e,selection:{anchor:na(r,a.start),focus:na(r,a.end)}}}(o,"pointer"===n);if(!l)return!1;e.clearPreferredColumn(),e.resetTransactionGrouping();let c=!1;return et(()=>{e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==a)return t;const n=e.applyTableAwareParagraphEdit({...t,selection:l.selection},e=>nS(e,r));return c=n.document!==t.document,n}),"once"===t()?s():c&&(a=e.state().document)}),c&&e.focusInput(),c}}}function aS(e){return function(e){const{state:t,logger:o,isReadOnly:r,applyState:a,cloneState:i,focusInput:s,focusInputAfterPointerSelection:l,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=()=>Xy(t),P=()=>nx(t),R=gw({state:()=>t,resetTransactionGrouping:v,applyTransactionalState:b,focusInput:s}),M=rw({state:()=>t,surfaceRef:()=>d()??null,viewportRef:()=>u()??null,documentLayout:C,canvasSnapshotProvider:T,zoomFactor:p}).resolveSurfaceHitAtPoint,O=function(e){const[t,o]=vn(""),[r,a]=vn(""),[i,s]=vn({matchCase:!1,wholeWord:!1}),[l,c]=vn([]),[d,u]=vn(-1),[p,g]=vn(!1);n(dt([()=>e.state.document,t,i],([e,t,n])=>{const o=Zx(e,t,n);c(o),0===o.length?u(-1):(d()>=o.length||-1===d())&&u(0)}));const f=t=>{const n=l()[t];n&&e.applyState(ii(e.state,{anchor:n.anchor,focus:n.focus}))};return{searchTerm:t,setSearchTerm:o,replaceTerm:r,setReplaceTerm:a,findOptions:i,setFindOptions:s,matches:l,currentIndex:d,findNext:()=>{const e=l().length;if(0===e)return;const t=(d()+1)%e;u(t),f(t)},findPrevious:()=>{const e=l().length;if(0===e)return;const t=(d()-1+e)%e;u(t),f(t)},replace:()=>{if(0===l().length||-1===d())return;const t=l()[d()];e.applyTransactionalState(e=>Bu(ii(e,{anchor:t.anchor,focus:t.focus}),r()),{mergeKey:Kp})},replaceAll:()=>{const n=t();0!==n.length&&(e.applyTransactionalState(e=>Jx(e,n,r(),i()),{mergeKey:_p}),g(!1),e.focusInput())},isOpen:p,setIsOpen:g}}({state:t,applyState:a,applyTransactionalState:b,focusInput:s}),A=Wx({applyTransactionalState:b,applySelectionToStatePreservingStructure:(e,t)=>({...e,document:io(e).document,selection:t}),focusInput:s,logger:o}),B=rS({state:()=>t,isReadOnly:r,applyTransactionalState:b,applyTableAwareParagraphEdit:A.applyTableAwareParagraphEdit,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:s}),D=(e,t)=>M(e,t)?.position??null,F=Gx({state:t,surfaceRef:d,resolvePositionAtSurfacePoint:D,applyState:a,applyTransactionalState:b,updateHistoryState:x,focusInput:s,focusInputAfterPointerSelection:l,cloneState:i,logger:o,zoomFactor:p}),E=qx({state:t,surfaceRef:d,applyState:a,updateHistoryState:x,focusInput:s,cloneState:i,logger:o,zoomFactor:p}),L=Yx({state:()=>t,commandsController:h,clearPreferredColumn:y,resetTransactionGrouping:v,focusInput:s,logger:o}),N=function(e){const t=()=>e.state,n=Fw({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,viewportRef:e.viewportRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),o=Nw({state:t,applyTransactionalState:e.applyTransactionalState,surfaceRef:e.surfaceRef,zoomFactor:e.zoomFactor,documentLayout:e.documentLayout,canvasSnapshotProvider:e.canvasSnapshotProvider}),r=Ww({state:t,applyTransactionalState:e.applyTransactionalState,resolvePositionAtSurfacePoint:e.resolvePositionAtSurfacePoint,focusInput:e.focusInput}),a=eS({state:t,surfaceRef:()=>e.surfaceRef()??null,zoomFactor:e.zoomFactor}),i=Yw({state:t,isReadOnly:e.isReadOnly,resolveSurfaceHitAtPoint:e.resolveSurfaceHitAtPoint,applyTransactionalState:e.applyTransactionalState,applyState:e.applyState,applyTableAwareParagraphEdit:e.tableOps.applyTableAwareParagraphEdit,clearPreferredColumn:e.clearPreferredColumn,resetTransactionGrouping:e.resetTransactionGrouping,focusInputAfterPointerSelection:e.focusInputAfterPointerSelection,logger:e.logger}),s=Kw({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:xr,textDrag:{tryStartTextDrag:i.tryStartTextDrag},logger:e.logger,openEquationDialog:e.openEquationDialog}),l=_w({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=Qw({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}=fw({state:t,stateSnapshot:e.getStateSnapshot,onNativeClipboardIssue:e.clipboardActions?.reportNativeIssue,isReadOnly:e.isReadOnly,forcePlainTextPaste:e.getForcePlainTextPaste,consumePasteMode:e.clipboardActions?.consumePasteMode,onNativeClipboardSuccess:e.clipboardActions?.dismiss,onNativeClipboardStart:e.clipboardActions?.dismiss,clipboardRequestGeneration:e.clipboardActions?.requestGeneration,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:s,textInput:l,navigation:c,handleCopy:d,handleCut:u,handlePaste:p,handleDrop:g}}({state:t,getStateSnapshot:e.getStateSnapshot,applyState:a,applyTransactionalState:b,isReadOnly:r,logger:o,focusInput:s,focusInputAfterPointerSelection:l,focusInputSync:c,clearPreferredColumn:y,resetTransactionGrouping:v,surfaceRef:d,viewportRef:u,caretBox:()=>w(),preferredColumnX:()=>S(),setPreferredColumnX:I,zoomFactor:p,documentLayout:C,canvasSnapshotProvider:T,resolveSurfaceHitAtPoint:M,resolvePositionAtSurfacePoint:D,tableOps:A,imageOps:F,styleController:L,formatPainter:B,getForcePlainTextPaste:f,setForcePlainTextPaste:m,clipboardActions:e.clipboardActions,insertImageFromFile:g,openEquationDialog:e.openEquationDialog}),z=e=>{0===e.button&&(L.clearPendingCaretTextStyle(),e.preventDefault(),s())};return{selectedImageRun:k,selectedTextBoxRun:P,layoutOptionsOverlay:R,fr:O,resolveSurfaceHitAtPoint:M,resolvePositionAtSurfacePoint:D,tableOps:A,imageOps:F,textBoxOps:E,styleController:L,formatPainter:B,onEditorPointerDown:z,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 iS(e){if("main"!==(e.activeZone??"main"))return e;const t=fr(e.selection)?e:Z(e),{paragraph:n,index:o,offset:r}=te(t),a=qo(),i=function(e){const t=e.footnotes,n=t?.settings?.numberFormat??"decimal";let o=(t?.settings?.startAt??1)-1;const r=/* @__PURE__ */new Set;for(const{run:a}of Ca(e)){const e=Ko(a);e&&!e.customMark&&(r.has(e.footnoteId)||(r.add(e.footnoteId),o+=1))}return Ba(o+1,n)}(t.document),s=ra(a.id,i),l=G(n,r,[s]),c=zo(t).map((e,t)=>t===o?l:e),d=na(l,r+i.length),u=ro(t,c,_o(d)),p=function(e){return e||{items:{}}}(u.document.footnotes),g={...u.document,footnotes:{...p,items:{...p.items,[a.id]:a}}},f=pa(g),m=a.blocks.flatMap(oa).find(Boolean);return m?{...u,document:f,selection:_o(na(m,0)),activeZone:"footnote",activeFootnoteId:a.id}:{...u,document:f}}function sS(e){if(!e)return;const{propertyRevision:t,...n}=e;return Object.keys(n).length>0?n:void 0}function lS(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 l=0;l<i.length;l+=1){const e=i[l];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[l+t];n&&(n.cells[o]=e)})}}}const s=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:lS(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===s.length?[]:[{...e,style:o,gridCols:r,gridRevision:a,rows:s}]})}function cS(e,t,n){const o=za(e.document).map(e=>({...e,blocks:lS(e.blocks,t,n),header:e.header?lS(e.header,t,n):void 0,firstPageHeader:e.firstPageHeader?lS(e.firstPageHeader,t,n):void 0,evenPageHeader:e.evenPageHeader?lS(e.evenPageHeader,t,n):void 0,footer:e.footer?lS(e.footer,t,n):void 0,firstPageFooter:e.firstPageFooter?lS(e.firstPageFooter,t,n):void 0,evenPageFooter:e.evenPageFooter?lS(e.evenPageFooter,t,n):void 0}));return{...e,document:{...e.document,sections:o}}}function dS(e,t,n){const o=za(e.document),r=o.findIndex(e=>e.propertyRevision?.id===t);if(-1===r)return e;const a=o[r],i=a.propertyRevision,s=[...o];if(n)s[r]={...a,propertyRevision:void 0};else{const e=structuredClone(i.previous);s[r]={...a,pageSettings:e.pageSettings,pageBorder:e.pageBorder,pageNumbering:e.pageNumbering,verticalAlignment:e.verticalAlignment,bidi:e.bidi,propertyRevision:void 0};const t=s[r+1];t&&(s[r+1]={...t,breakType:e.nextBreakType})}return{...e,document:{...e.document,sections:s}}}function uS(e,t){const n=zo(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:sS(e.styles)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:To(e,n)});return dS(cS(ro(e,n,C(n,ya(e))),t,!0),t,!0)}function pS(e,t){const n=zo(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:sS(n.previous)}:e});return n.length===e.runs.length&&n.every((t,n)=>t===e.runs[n])?e:To(e,n)});return dS(cS(ro(e,n,C(n,ya(e))),t,!1),t,!1)}function gS(e,t){return"paragraph"===e.type?t.has(e.id):e.rows.some(e=>e.cells.some(e=>e.blocks.some(e=>gS(e,t))))}function fS(e,t,n){for(const o of e)if("paragraph"!==o.type){gS(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=>gS(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),fS(e.blocks,t,n)}}}function mS(e){const n=ya(e),o=zo(e),r=/* @__PURE__ */new Set;for(let i=n.startIndex;i<=n.endIndex;i+=1){const e=o[i],a=i===n.startIndex?n.startParagraphOffset:0,s=i===n.endIndex?n.endParagraphOffset:xa(e),l=t(e,a,s);for(const t of l)t.revision?.id&&r.add(t.revision.id),t.styles?.propertyRevision?.id&&r.add(t.styles.propertyRevision.id)}const a=new Set(o.slice(n.startIndex,n.endIndex+1).map(e=>e.id));for(const t of za(e.document))for(const e of[t.blocks,t.header,t.firstPageHeader,t.evenPageHeader,t.footer,t.firstPageFooter,t.evenPageFooter])e&&fS(e,a,r);for(const t of Tv(e))t.paragraphIds.some(e=>a.has(e))&&r.add(t.id);return r}function hS(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 za(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 bS(e){return hS(e).size>0}function yS(e,t){if(!bS(e))return e;const n=Yn(e.document,t);if(!n.changed)return e;const o=zo({...e,document:n.document}),r=C(o,ya(e));return{...e,document:n.document,selection:r}}function vS(e){const n=ya(e),o=zo(e);if(n.isCollapsed){const e=o[n.startIndex];return e?Qe(e,n.startParagraphOffset)?.href??null:null}const r=o.slice(n.startIndex,n.endIndex+1).flatMap((e,o)=>{const r=n.startIndex+o,a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:xa(e);return t(e,a,i)}).filter(e=>e.text.length>0&&"image"!==e.kind);if(0===r.length)return null;const a=r[0]?.styles?.link;return a&&r.every(e=>e.styles?.link===a)?a:null}function xS(e){const t=ya(e),n=zo(e).map((e,n)=>{if(n<t.startIndex||n>t.endIndex)return Er(e);if(!e.list)return Er(e);const o=e.list.level??0;return o<=0?d(e):De(e,o-1)});return ro(e,n,C(n,t))}function wS(e){return function(e){const{state:n,logger:o,applyState:r,applyTransactionalState:a,applySelectionAwareTextCommand:s,applySelectionAwareParagraphCommand:l,applyTableAwareParagraphEdit:c,focusInput:u,clearPreferredColumn:p,resetTransactionGrouping:g,toolbarStyleState:f,selectionCollapsed:m,selectedImageRun:h}=e,b=e=>{p(),g(),r(e),u()},y=e=>{p(),g(),s(e),u()},x=e=>{p(),g(),l(e),u()},w=(e,t)=>{p(),g(),a(e,t),u()},S=()=>{const e=ya(n);return zo(n).slice(e.startIndex,e.endIndex+1)},I=()=>S().some(e=>Boolean(e.list)),T=()=>{const e=n.selection.focus.paragraphId;return zo(n).find(t=>t.id===e)??null},k=()=>{const e=T();return!!e?.list&&(p(),g(),m()&&0===Ua(e).length?l(e=>function(e){const t=ya(e),n=zo(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Er(e):d(e));return ro(e,n,C(n,t))}(e)):a(e=>c(e,e=>function(e){if(Fn(e))return e;const t=fr(e.selection)?e:Z(e),{paragraph:n,index:o,offset:r}=te(t);if(Fn(t))return e;const{beforeRuns:a,afterRuns:i}=he(n,r),s=To(n,a,ue(n,r)),l=i.length>0?To(Re(n,[]),i):(()=>{const e=Da("");return e.style=n.style?{...n.style}:void 0,e.list=Hr(n.list),e})(),c=zo(t),d=[...yr(c.slice(0,o)),s,l,...yr(c.slice(o+1))];return ro(t,d,E(na(l,0)))}(e)),{mergeKey:Op}),u(),!0)},P=()=>{const e=n.selection,t=lr(n),o=rr(n.document,e.anchor.paragraphId,t),r=rr(n.document,e.focus.paragraphId,t);return o&&r&&o.blockIndex===r.blockIndex?` [table b${o.blockIndex} r${o.rowIndex}:c${o.cellIndex}→r${r.rowIndex}:c${r.cellIndex}]`:""},R=e=>{if(m())return;const t=n.selection;o.info(`toggleStyle:${e} at ${t.anchor.paragraphId}:${t.anchor.runId}[${t.anchor.offset}..${t.focus.offset}]${P()}`),y(t=>$u(t,e))},M=e=>{m()||y(t=>function(e,t){const n=ya(e);if(n.isCollapsed||Fn(e))return e;const o=zo(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:xa(o);return le(o,a,i,n=>{let r=ea(zu(e,o,n.styles,"underline",null!==t),"underlineStyle","single"===t?null:t);return"single"!==t&&null!==t||!Ra(r,o.style?.styleId,e.document.styles).underlineStyle||(r={...r,underlineStyle:t}),{...n,styles:r}})});return ro(e,o,C(o,n))}(t,e))},O=(e,t)=>{if(m())return;const r=n.selection;o.info(`setStyle:${e}=${JSON.stringify(t)} at ${r.anchor.paragraphId}:${r.anchor.runId}[${r.anchor.offset}..${r.focus.offset}]${P()}`),y(n=>Hu(n,e,t))},A=(e,t)=>{x(n=>ae(n,e,t))},B=e=>{const t=!f()[e];A(e,"widowControl"===e?t:!!t||null)},D=()=>{w(e=>c(e,e=>go(e)))},F=()=>"main"===(n.activeZone??"main"),L=()=>{F()&&w(e=>iS(e))},N=e=>{const t=vS(n);m()&&!t||w(t=>function(e,t){const n=ya(e);if(!n.isCollapsed)return Hu(e,"link",t);const o=zo(e)[n.startIndex];if(!o)return e;const r=Qe(o,n.startParagraphOffset);if(!r)return e;const a=Hu(ii(e,{anchor:na(o,r.startOffset),focus:na(o,r.endOffset)}),"link",t),i=zo(a)[n.startIndex];return i?{...a,selection:{anchor:na(i,r.startOffset),focus:na(i,r.endOffset)}}:a}(t,e),{mergeKey:Ap})},z=()=>{const t=vS(n)??"";m()&&!t||e.openLinkDialog(t)},$=()=>e.openFontDialog(),H=t=>e.openParagraphDialog(t),W=()=>{N(null)},U=()=>{const t=h();if(!t)return;const n=Uo(t.run)?.alt??"";e.openImageAltDialog(n)},j=t=>{h()&&w(n=>function(e,t,n){const o=Xy(e);if(!o||!Uo(o.run))return e;const r=zo(e),a=o.paragraphIndex+1,i=a<r.length&&Sa(r[a])?jr(r[a],t,n):ta(t,n,1),s=a<r.length&&Sa(r[a])?[...yr(r.slice(0,a)),i,...yr(r.slice(a+1))]:[...yr(r.slice(0,a)),i,...yr(r.slice(a))],l=ua(s),c=l[a]??i;return ro(e,l,E(na(c,aa(c))))}(n,t,e.imageCaptionLabel()),{mergeKey:Dp})},V=()=>{h()&&e.openImageCaptionDialog(function(e){const t=Xy(e);if(!t||!Uo(t.run))return null;const n=zo(e);return Oa(n[t.paragraphIndex+1])}(n)??"")};return{applyBooleanStyleCommand:R,applyToggleCharacterBorderCommand:()=>{m()||y(e=>function(e){const n=ya(e);if(n.isCollapsed||Fn(e))return e;const o=zo(e),r=o.slice(n.startIndex,n.endIndex+1).flatMap((e,o)=>{const r=n.startIndex+o,a=r===n.startIndex?n.startParagraphOffset:0,i=r===n.endIndex?n.endParagraphOffset:xa(e);return t(e,a,i)}).filter(e=>e.text.length>0);if(0===r.length)return e;const a=!r.every(e=>Boolean(e.styles?.textBorder)),i=o.map((e,t)=>{if(t<n.startIndex||t>n.endIndex)return e;const o=t===n.startIndex?n.startParagraphOffset:0,r=t===n.endIndex?n.endParagraphOffset:xa(e);return le(e,o,r,e=>({...e,styles:ju(e.styles,a)}))});return ro(e,i,C(i,n))}(e))},applyValueStyleCommand:O,applyUnderlineStyleCommand:M,applyChangeTextCaseCommand:e=>{m()||y(t=>_u(t,e))},applyClearFormattingCommand:()=>{m()||y(e=>function(e){const t=ya(e);if(t.isCollapsed||Fn(e))return e;const n=zo(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:xa(e);return le(e,o,r,e=>{const t=e.styles?.link,n=null!=t&&""!==t?{link:t}:{};return{...e,styles:n}})});return ro(e,n,C(n,t))}(e))},applyParagraphStyleCommand:A,toggleParagraphFlagCommand:B,applyParagraphListCommand:e=>{x(t=>function(e,t){const n=ya(e),o=zo(e),r=n.startIndex,a=n.endIndex,i=o.slice(r,a+1),s=i.length>0&&i.every(e=>e.list?.kind===t),l=o.map((e,n)=>{if(n<r||n>a)return Er(e);const o=Er(e);return s?(delete o.list,o):(o.list={kind:t,level:e.list?.level??0,format:e.list?.format,startAt:e.list?.startAt},o)});return ro(e,l,C(l,n))}(t,e))},handleListFormatChange:e=>{x(t=>function(e,t){const n=ya(e),o=zo(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Er(e):e.list?{...Er(e),list:{...e.list,format:t||void 0}}:Er(e));return ro(e,o,C(o,n))}(t,e))},handleListStartAtChange:e=>{x(t=>function(e,t){const n=ya(e),o=zo(e).map((e,o)=>o<n.startIndex||o>n.endIndex?Er(e):e.list?{...Er(e),list:{...e.list,startAt:null!==t?t:void 0}}:Er(e));return ro(e,o,C(o,n))}(t,e))},applyInsertSectionBreakCommand:e=>{b(Ce(n,e))},applyInsertPageBreakCommand:D,canInsertFootnoteCommand:F,applyInsertFootnoteCommand:L,handleStyleChange:e=>{x(t=>v(t,e||null))},applyUpdateSectionSettingsCommand:(e,t)=>{b(i(n,e,t))},applyToggleTrackChangesCommand:()=>{b(function(e){return{...e,trackChangesEnabled:!e.trackChangesEnabled}}(n))},applyToggleRevisionMarkupCommand:()=>{b(function(e){return{...e,showRevisionMarkup:!(e.showRevisionMarkup??!0)}}(n))},applySetReviewDisplayModeCommand:e=>{b(function(e,t){return(e.reviewDisplayMode??"all")===(t??"all")?e:{...e,reviewDisplayMode:t}}(n,e))},applyShowMarkupCommand:e=>{b(Rv(n,e))},applyToggleShowMarginsCommand:()=>{r({...n,showMargins:!n.showMargins}),u()},applyToggleShowParagraphMarksCommand:()=>{r({...n,showParagraphMarks:!n.showParagraphMarks}),u()},applyAcceptRevisionsCommand:()=>{w(e=>function(e){let t=e;for(const n of mS(e))t=uS(t,n);return t}(e))},applyRejectRevisionsCommand:()=>{w(e=>function(e){let t=e;for(const n of mS(e))t=pS(t,n);return t}(e))},applyAcceptAllRevisionsCommand:()=>{w(e=>function(e){return yS(e,"accept")}(e))},applyRejectAllRevisionsCommand:()=>{w(e=>function(e){return yS(e,"reject")}(e))},applyLinkCommand:N,promptForLink:z,openFontDialog:$,openParagraphDialog:H,openStylesDialog:()=>{o.warn("stylesDialog not yet implemented")},openPageSetupDialog:()=>{o.warn("pageSetupDialog not yet implemented")},removeLinkCommand:W,applyImageAltCommand:e=>{h()&&w(t=>function(e,t){return ov(e,e=>({...e,alt:t??void 0}))}(t,e),{mergeKey:Bp})},promptForImageAlt:U,applyImageCaptionCommand:j,promptForImageCaption:V,applyImageWidthCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||w(t=>function(e,t){const n=Xy(e),o=n&&Uo(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*No));return Gy(e,r,r*(o.height/o.width))}(t,e),{mergeKey:Fp})},applyImageHeightCmCommand:e=>{!h()||!Number.isFinite(e)||e<=0||w(t=>function(e,t){const n=Xy(e),o=n&&Uo(n.run);if(!o||!Number.isFinite(t)||t<=0)return e;const r=Math.max(24,Math.round(t*No));return Gy(e,r*(o.width/o.height),r)}(t,e),{mergeKey:Fp})},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&&w(e=>"reset"===t?Qy(e):Zy(e,t),{mergeKey:Ep})},applyImageCropShapeCommand:e=>{h()&&w(t=>function(e,t){const n=t?.trim();return ov(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:Ep})},applyImageCropFillCommand:()=>{h()&&w(e=>function(e){const t=Xy(e),n=t&&Uo(t.run);return n?ov(Yy(e,{crop:Jy(n)}),e=>({...e,cropFit:"fill"})):e}(e),{mergeKey:Ep})},applyImageCropFitCommand:()=>{h()&&w(e=>function(e){return ov(e,e=>{const t={...e,cropFit:"fit"};return delete t.crop,t})}(e),{mergeKey:Ep})},resetImageCropCommand:()=>{h()&&w(e=>Qy(e),{mergeKey:Ep})},applyImageBorderCommand:e=>{h()&&w(t=>function(e,t){return ov(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()&&w(t=>nv(t,e),{mergeKey:Lp})},rotateImageCommand:e=>{h()&&w(t=>tv(t,e),{mergeKey:Np})},applyImageTransparencyCommand:e=>{h()&&w(t=>function(e,t){return null===Xy(e)?e:ov(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:zp})},resetImageCommand:()=>{h()&&w(e=>function(e){return null===Xy(e)?e:ov(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:$p})},handleListTab:e=>!rr(n.document,n.selection.focus.paragraphId,lr(n))&&(!!I()&&(x(t=>"indent"===e?function(e){const t=ya(e),n=zo(e).map((e,n)=>n<t.startIndex||n>t.endIndex?Er(e):e.list?De(e,(e.list.level??0)+1):Er(e));return ro(e,n,C(n,t))}(t):xS(t)),!0)),handleListEnter:k,handleListBoundaryBackspace:e=>{const t=T();return!(!t?.list||!m())&&(0===ia(t,n.selection.focus)&&(p(),g(),l(e=>xS(e)),e.currentTarget.value="",u(),!0))}}}(e)}function SS(e){return{fontFamily:e.fontFamily??"",fontSize:ct(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 IS(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 CS(e){return function(e){const t=wS({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:()=>fr(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:SS(e.toolbarStyleState())})},openParagraphDialog:t=>{e.setParagraphDialog({isOpen:!0,initial:{...IS(e.toolbarStyleState()),defaultTabStop:e.state.document.settings?.defaultTabStop??36,...void 0!==t?{tabsOnly:!0,selectedTabPosition:t}:{}}})},imageCaptionLabel:()=>e.locale().startsWith("en")?"Figure":"Figura"});return{commandsController:t,keyboardCommandsController:{...t,applyBooleanStyleCommand:t=>e.applyBooleanStyleCommand(t)}}}(e)}function TS(e){return()=>{e.isDirty()?e.requestConfirmation():e.resetDocument()}}function kS(e){const t=e.document.settings?.defaultTabStop;return("number"==typeof t&&Number.isFinite(t)&&t>0?t:36)*Ar}function PS(e,t){const n=zo(e);if(!n.length)return e;const o=ya(e,n),r=kS(e);let a=!1;const i=n.map((n,i)=>{if(i<o.startIndex||i>o.endIndex)return n;if(n.list){const e=n.list.level??0,o=Math.max(0,Math.min(8,e+t));return o===e?n:(a=!0,De(n,o))}const s=Xr(n.style,e.document.styles).indentLeft??0;if(t<0&&s<=0)return n;const l=t<0?Math.max(0,s-r):s+r;return l!==s&&Number.isFinite(l)?(a=!0,{...n,style:{...n.style,indentLeft:l}}):n});return a?ro(e,i,e.selection):e}function RS(e,t){const n=zo(e);if(!n.length)return e;const o=ya(e,n);if(!o.isCollapsed||0!==o.startParagraphOffset)return e;const r=n[o.startIndex];if(!r||r.list)return e;const a=Xr(r.style,e.document.styles),i=a.indentFirstLine??0,s=a.indentHanging??0;if(t>0&&(0!==i||0!==s))return PS(e,1);if(t<0&&i<=0)return e;const l=t>0?kS(e):Math.max(0,i-kS(e)),c=n.map((e,t)=>t===o.startIndex?{...e,style:{...e.style,indentFirstLine:l,indentHanging:0}}:e);return ro(e,c,e.selection)}function MS(e){const t=zo(e);if(!t.length)return null;const n=ya(e,t);if(!n.isCollapsed||0!==n.startParagraphOffset)return null;const o=t[n.startIndex];if(!o||o.list)return null;const r=Xr(o.style,e.document.styles);return(r.indentLeft??0)>0?"paragraph":(r.indentFirstLine??0)>0&&(r.indentHanging??0)<=0?"firstLine":null}function OS(e){const t=MS(e);return"paragraph"===t?PS(e,-1):"firstLine"===t?RS(e,-1):e}var AS=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}},BS=[{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=zo(t);if(0===n.length)return!1;const o=n[0],r=n[n.length-1];return e.clearPreferredColumn(),e.applyState(ii(t,{anchor:na(o,0),focus:na(r,Ua(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=>go(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=>Bu(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=>Du(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=>on(e))),e.focusInput()),!0)}];function DS(e){return function(e){const t=new AS;BS.forEach(e=>t.register(e));const n=n=>{if(n.defaultPrevented)return;const o=e.state();if(e.isReadOnly()){const e=n.key,t=e.toLowerCase(),o="Tab"===e||"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(),!fr(o.selection))return e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Lu(e))),n.currentTarget.value="",void e.focusInput();const t=zo(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===ia(r,o.selection.focus))return e.applySelectionAwareParagraphCommand(e=>xS(e)),n.currentTarget.value="",void e.focusInput();const a=ia(r,o.selection.focus),i=Ua(r),s="Backspace"===n.key?Qn(i,a):Ot(i,a);return"Backspace"===n.key?0===a||s===a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Lu(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(ii(t,{anchor:na(r,s),focus:na(r,a)}),e=>Lu(e))):a>=i.length?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Nu(e))):s>a?e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(ii(t,{anchor:na(r,a),focus:na(r,s)}),e=>Lu(e))):e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Nu(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.altKey||n.ctrlKey||n.metaKey||!MS(o)?(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Lu(e))),n.currentTarget.value="",void e.focusInput()):(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),!1!==e.canExecuteCommand?.("outdent")&&e.applySelectionAwareParagraphCommand(OS),n.currentTarget.value="",void e.focusInput());case"Delete":return n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),e.applyTransactionalState(t=>e.applyTableAwareParagraphEdit(t,e=>Nu(e))),n.currentTarget.value="",void e.focusInput();case"Tab":return void function(e,t,n){const o=t.selection.focus.paragraphId,r=Fa(t.document,o),a=!!r&&Boolean($r(t.document,o,r.sectionIndex)),i=zo(t);if(!i.length)return;const s=ya(t,i),l=i[s.startIndex];if(!l)return;const c=!s.isCollapsed&&(s.startIndex!==s.endIndex||0===s.startParagraphOffset&&s.endParagraphOffset===xa(l)),d=Xr(l.style,t.document.styles),u=s.isCollapsed&&0===s.startParagraphOffset&&!l.list,p=e.autoTabIndentEnabled?.()??!0,g=function(e){if(e.alt||e.ctrl||e.meta){const t=!e.meta&&!e.shift&&(e.ctrl&&!e.alt||e.isMac&&e.alt&&!e.ctrl);return e.inTable&&t?"insertLiteralTab":"passThrough"}return e.inTable?"navigateCell":e.reverseFirstLineIndent||!e.shift&&e.autoIndentAtStart?"changeFirstLineIndent":e.shift||e.wholeParagraphs||e.atListStart||e.atWrappedLineStart?"changeParagraphIndent":"insertLiteralTab"}({inTable:a,shift:n.shiftKey,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,isMac:e.isMacPlatform?.()??!1,atWrappedLineStart:p&&s.isCollapsed&&s.startParagraphOffset>0&&!a&&!n.shiftKey&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&(e.isCaretAtWrappedLineStart?.()??!1),wholeParagraphs:c,atListStart:Boolean(l.list)&&s.isCollapsed&&0===s.startParagraphOffset,autoIndentAtStart:p&&u&&Ua(l).length>0,reverseFirstLineIndent:n.shiftKey&&p&&u&&(d.indentLeft??0)<=0&&(d.indentFirstLine??0)>0});if("passThrough"!==g){switch(n.preventDefault(),e.clearPreferredColumn(),e.resetTransactionGrouping(),g){case"insertLiteralTab":{const t=Gr(e.pendingCaretTextStyle?.());e.applyTransactionalState(n=>e.applyTableAwareParagraphEdit(n,e=>Bu(e,"\t",t)));break}case"navigateCell":{const r=n.shiftKey?-1:1,a=e.resolveTableTabTarget?.(t.document,o,r);if("adjacent"===a?.kind)e.applySelectionPreservingStructure(a.selection);else if("afterLast"===a?.kind&&1===r&&e.appendTableRowForTab&&!1!==e.canExecuteCommand?.("tableInsertRowAfter"))e.applyTransactionalState(e.appendTableRowForTab);else if(!a){const n=e.resolveAdjacentTableCellPosition(t.document,o,r);n&&e.applySelectionPreservingStructure({anchor:n,focus:n})}break}case"changeFirstLineIndent":case"changeParagraphIndent":{const t=n.shiftKey?"outdent":"indent";if(!1===e.canExecuteCommand?.(t))break;e.applySelectionAwareParagraphCommand(e=>"changeFirstLineIndent"===g?RS(e,n.shiftKey?-1:1):PS(e,n.shiftKey?-1:1));break}}n.currentTarget.value="",e.focusInput()}}(e,o,n);case"ArrowLeft":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(oi(o,-1))):(e.clearPreferredColumn(),e.applyState(si(o))),void e.focusInput();case"ArrowRight":return n.preventDefault(),e.resetTransactionGrouping(),n.shiftKey?(e.clearPreferredColumn(),e.applyState(function(e){return oi(e,1)}(o))):(e.clearPreferredColumn(),e.applyState(li(o))),void e.focusInput();case"ArrowUp":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(-1,!0)||(e.applyState(function(e){return ri(e,-1)}(o)),e.focusInput()):e.moveVerticalByBlock(-1)||(e.applyState(function(e){return ni(e,-1)}(o)),e.focusInput()));case"ArrowDown":return n.preventDefault(),e.resetTransactionGrouping(),void(n.shiftKey?e.moveVerticalSelection(1,!0)||(e.applyState(function(e){return ri(e,1)}(o)),e.focusInput()):e.moveVerticalByBlock(1)||(e.applyState(function(e){return ni(e,1)}(o)),e.focusInput()));default:return}}};return{handleKeyDown:n,registry:t}}(e)}var FS=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Escape"];var ES={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"}},LS={oasis:{color:"#0f766e",heading:"#115e59"},office:{color:"#4472c4",heading:"#2f5597"},monochrome:{color:"#374151",heading:"#111827"},warm:{color:"#c2410c",heading:"#9a3412"}},NS={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 zS(e,t){const n={...e.document.design??{},...t};return{...e,document:{...e.document,design:n}}}function $S(e,t){return function(e,t){const n=ES[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 HS(e){return null==e||""===e?null:!0===e||"true"===e||1===e}function WS(e){return null==e||""===e?null:"string"==typeof e?e:String(e)}function US(e){return null!=e&&""!==e?Number(e):null}function jS({gate:e,style:t,selection:n,history:o,formatting:r,dialog:a,link:i,command:s,valueCommand:l,actionCommand:c}){const d=t.state;return{selectAll:s("selectAll",r.selectAll),selectWord:s("selectWord",r.selectWord),selectSentence:s("selectSentence",r.selectSentence),selectParagraph:s("selectParagraph",r.selectParagraph),selectCollapse:c("selectCollapse",e=>{const t=e??{};r.selectCollapse(Boolean(t.end))}),selectText:l("selectText",e=>{const t=e??{};return r.selectText(t.text??"",null==t.occurrence?1:Number(t.occurrence))},()=>""),selectRange:c("selectRange",e=>{const t=e??{};t.anchor&&t.focus&&r.selectRange(t.anchor,t.focus)}),insertFootnote:s("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:US(t.startAt)}:{},...void 0!==t.restart?{restart:t.restart}:{}})},()=>({value:r.getNoteOptions("footnote")})),insertTableOfContents:s("insertTableOfContents",r.insertTableOfContents),updateTableOfContents:s("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:s("pastePlainText",r.pastePlainText),formatPainter:s("formatPainter",r.formatPainterOnce,()=>({isEnabled:e.isCommandEnabled("formatPainter")&&r.canCaptureFormatPainter(),isActive:null!==r.formatPainterMode()})),formatPainterContinuous:s("formatPainterContinuous",r.formatPainterContinuous,()=>({isEnabled:e.isCommandEnabled("formatPainterContinuous")&&r.canCaptureFormatPainter(),isActive:"continuous"===r.formatPainterMode()})),cancelFormatPainter:s("cancelFormatPainter",r.cancelFormatPainter,()=>({isEnabled:null!==r.formatPainterMode()})),bold:s("bold",r.bold,()=>({isActive:Boolean(d().bold)})),italic:s("italic",r.italic,()=>({isActive:Boolean(d().italic)})),underline:s("underline",r.underline,()=>({isActive:Boolean(d().underline)})),doubleUnderline:s("doubleUnderline",r.doubleUnderline,()=>({isActive:"double"===d().underlineStyle})),wordUnderline:s("wordUnderline",r.wordUnderline,()=>({isActive:"words"===d().underlineStyle})),strike:s("strike",r.strike,()=>({isActive:Boolean(d().strike)})),doubleStrike:s("doubleStrike",r.doubleStrike,()=>({isActive:Boolean(d().doubleStrike)})),smallCaps:s("smallCaps",r.smallCaps,()=>({isActive:Boolean(d().smallCaps)})),allCaps:s("allCaps",r.allCaps,()=>({isActive:Boolean(d().allCaps)})),hidden:s("hidden",r.hidden,()=>({isActive:Boolean(d().hidden)})),noProof:s("noProof",r.noProof,()=>({isActive:Boolean(d().noProof)})),webHidden:s("webHidden",r.webHidden,()=>({isActive:Boolean(d().webHidden)})),specVanish:s("specVanish",r.specVanish,()=>({isActive:Boolean(d().specVanish)})),contextualAlternates:s("contextualAlternates",r.contextualAlternates,()=>({isActive:Boolean(d().contextualAlternates)})),characterBorder:s("characterBorder",r.toggleCharacterBorder,()=>({isActive:Boolean(d().characterBorder)})),shadow:s("shadow",r.shadow,()=>({isActive:Boolean(d().shadow)})),emboss:s("emboss",r.emboss,()=>({isActive:Boolean(d().emboss)})),engrave:s("engrave",r.engrave,()=>({isActive:Boolean(d().imprint)})),outline:s("outline",r.outline,()=>({isActive:Boolean(d().outline)})),superscript:s("superscript",r.superscript,()=>({isActive:Boolean(d().superscript)})),subscript:s("subscript",r.subscript,()=>({isActive:Boolean(d().subscript)})),link:s("link",()=>(i.prompt(),!0),()=>({isEnabled:e.isCommandEnabled("link")&&i.canPrompt(),isActive:Boolean(d().link)})),alignLeft:s("alignLeft",r.alignLeft,()=>({isActive:"left"===d().align})),alignCenter:s("alignCenter",r.alignCenter,()=>({isActive:"center"===d().align})),alignRight:s("alignRight",r.alignRight,()=>({isActive:"right"===d().align})),alignJustify:s("alignJustify",r.alignJustify,()=>({isActive:"justify"===d().align})),orderedList:s("orderedList",r.orderedList,()=>({isActive:"ordered"===d().listKind})),bulletList:s("bulletList",r.bulletList,()=>({isActive:"bullet"===d().listKind})),find:s("find",r.find),replace:s("replace",r.replace),replaceAll:c("replaceAll",e=>{const t=e??{};"string"==typeof t.search&&t.search.length>0&&r.replaceAll(t)}),setReviewDisplayMode:l("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:s("toggleTrackChanges",r.toggleTrackChanges,()=>({isActive:r.isTrackChangesEnabled()})),toggleRevisionMarkup:s("toggleRevisionMarkup",r.toggleRevisionMarkup,()=>({isActive:r.areRevisionMarkupVisible()})),showMarkupOptions:l("showMarkupOptions",()=>!1,()=>r.showMarkupOptions()),applyShowMarkup:c("applyShowMarkup",e=>{r.applyShowMarkup(e??{})}),toggleOutlinePanel:s("toggleOutlinePanel",r.toggleOutlinePanel,()=>({isActive:r.areOutlineVisible()})),toggleRevisionsPanel:s("toggleRevisionsPanel",r.toggleRevisionsPanel,()=>({isActive:r.areRevisionsPanelVisible()})),acceptRevisions:s("acceptRevisions",r.acceptRevisions,()=>({isEnabled:e.isCommandEnabled("acceptRevisions")&&r.hasRevisionsInSelection()})),rejectRevisions:s("rejectRevisions",r.rejectRevisions,()=>({isEnabled:e.isCommandEnabled("rejectRevisions")&&r.hasRevisionsInSelection()})),acceptAllRevisions:s("acceptAllRevisions",r.acceptAllRevisions,()=>({isEnabled:e.isCommandEnabled("acceptAllRevisions")&&r.hasRevisionsInDocument()})),rejectAllRevisions:s("rejectAllRevisions",r.rejectAllRevisions,()=>({isEnabled:e.isCommandEnabled("rejectAllRevisions")&&r.hasRevisionsInDocument()})),requestAcceptAllRevisions:s("requestAcceptAllRevisions",()=>(a.requestAcceptAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestAcceptAllRevisions")&&r.hasRevisionsInDocument()})),requestRejectAllRevisions:s("requestRejectAllRevisions",()=>(a.requestRejectAllRevisions(),!0),()=>({isEnabled:e.isCommandEnabled("requestRejectAllRevisions")&&r.hasRevisionsInDocument()})),nextRevision:s("nextRevision",r.navigateRevisionNext,()=>({isEnabled:e.isCommandEnabled("nextRevision")&&r.hasNavigableRevisions()})),previousRevision:s("previousRevision",r.navigateRevisionPrevious,()=>({isEnabled:e.isCommandEnabled("previousRevision")&&r.hasNavigableRevisions()})),newComment:s("newComment",r.newComment,()=>({isEnabled:e.isCommandEnabled("newComment")&&r.canCreateComment()})),replyComment:s("replyComment",r.replyComment,()=>({isEnabled:e.isCommandEnabled("replyComment")&&r.canReplyToComment()})),toggleCommentsPanel:s("toggleCommentsPanel",r.toggleCommentsPanel,()=>({isEnabled:e.isCommandEnabled("toggleCommentsPanel"),isActive:r.isCommentsPanelOpen()})),editComment:s("editComment",r.editComment,()=>({isEnabled:e.isCommandEnabled("editComment")&&r.canEditComment()})),nextComment:s("nextComment",r.navigateCommentNext,()=>({isEnabled:e.isCommandEnabled("nextComment")&&r.hasNavigableComments()})),previousComment:s("previousComment",r.navigateCommentPrevious,()=>({isEnabled:e.isCommandEnabled("previousComment")&&r.hasNavigableComments()})),resolveComment:s("resolveComment",r.resolveSelectedComment,()=>({isEnabled:e.isCommandEnabled("resolveComment")&&r.canManageSelectedComment()&&!r.isSelectedCommentResolved()})),reopenComment:s("reopenComment",r.reopenSelectedComment,()=>({isEnabled:e.isCommandEnabled("reopenComment")&&r.canManageSelectedComment()&&r.isSelectedCommentResolved()})),deleteComment:s("deleteComment",r.deleteSelectedComment,()=>({isEnabled:e.isCommandEnabled("deleteComment")&&r.canDeleteSelectedComment()})),toggleShowMargins:s("toggleShowMargins",r.toggleShowMargins,()=>({isActive:r.areMarginsVisible()})),toggleShowParagraphMarks:s("toggleShowParagraphMarks",r.toggleShowParagraphMarks,()=>({isActive:r.areParagraphMarksVisible()})),togglePreciseFonts:s("togglePreciseFonts",r.togglePreciseFonts,()=>(_t(),{isActive:hn()})),undo:s("undo",o.undo,()=>({isEnabled:e.isCommandEnabled("undo")&&o.canUndo()})),redo:s("redo",o.redo,()=>({isEnabled:e.isCommandEnabled("redo")&&o.canRedo()})),pageBreak:s("pageBreak",r.pageBreak),lineBreak:s("lineBreak",r.lineBreak),columnBreak:s("columnBreak",r.columnBreak),splitBlock:s("splitBlock",r.splitBlock),insertNonBreakingSpace:s("insertNonBreakingSpace",()=>r.insertSpecialChar("nbsp")),insertNonBreakingHyphen:s("insertNonBreakingHyphen",()=>r.insertSpecialChar("nbHyphen")),insertOptionalHyphen:s("insertOptionalHyphen",()=>r.insertSpecialChar("optionalHyphen")),insertEmDash:s("insertEmDash",()=>r.insertSpecialChar("emDash")),insertEllipsis:s("insertEllipsis",()=>r.insertSpecialChar("ellipsis")),insertCopyright:s("insertCopyright",()=>r.insertSpecialChar("copyright")),insertRegistered:s("insertRegistered",()=>r.insertSpecialChar("registered")),insertTrademark:s("insertTrademark",()=>r.insertSpecialChar("trademark")),setFontFamily:l("setFontFamily",e=>r.setFontFamily(e||null),()=>d().fontFamily),setFontSize:l("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=Kn(t);return null!==n&&r.setFontSize(n)},()=>ct(d().fontSize)),increaseFontSize:s("increaseFontSize",r.increaseFontSize),decreaseFontSize:s("decreaseFontSize",r.decreaseFontSize),growFont1:s("growFont1",r.growFont1),shrinkFont1:s("shrinkFont1",r.shrinkFont1),changeTextCase:c("changeTextCase",e=>{r.changeTextCase(e??"sentence")},()=>({isEnabled:e.isCommandEnabled("changeTextCase")&&!n.isCollapsed()})),clearFormatting:s("clearFormatting",r.clearFormatting),setColor:l("setColor",e=>r.setColor(e??null),()=>d().color||null),setHighlight:l("setHighlight",e=>r.setHighlight(e??null),()=>d().highlight||null),setTextShading:l("setTextShading",e=>r.setTextShading(e??null),()=>d().textShading||null),setStyleId:l("setStyleId",e=>r.setStyleId(String(e)),()=>{const e=d();return e.mixedParagraphStyles?"":e.styleId||"normal"}),setCharacterStyleId:l("setCharacterStyleId",e=>r.setCharacterStyleId(String(e)),()=>d().characterStyleId||""),applyUnderlineStyle:l("applyUnderlineStyle",e=>(r.applyUnderlineStyle(e),!0),()=>d().underlineStyle),setUnderlineStyle:l("setUnderlineStyle",e=>(r.setUnderlineStyle(e||null),!0),()=>d().underlineStyle),setUnderlineColor:l("setUnderlineColor",e=>r.setUnderlineColor(e||null),()=>d().underlineColor),setCharacterScale:l("setCharacterScale",e=>r.setCharacterScale(US(e)),()=>d().characterScale),setCharacterSpacing:l("setCharacterSpacing",e=>r.setCharacterSpacing(US(e)),()=>d().characterSpacing),setRunSnapToGrid:l("setRunSnapToGrid",e=>r.setRunSnapToGrid(HS(e)),()=>d().snapToGrid),setFitText:l("setFitText",e=>r.setFitText(US(e)),()=>d().fitText),setBaselineShift:l("setBaselineShift",e=>r.setBaselineShift(US(e)),()=>d().baselineShift),setEmphasisMark:l("setEmphasisMark",e=>r.setEmphasisMark(e||null),()=>d().emphasisMark),setTextEffect:l("setTextEffect",e=>r.setTextEffect(e||null),()=>d().textEffect),setKerning:l("setKerning",e=>r.setKerning(US(e)),()=>d().kerningThreshold),setLigatures:l("setLigatures",e=>r.setLigatures(e||null),()=>d().ligatures),setNumberSpacing:l("setNumberSpacing",e=>r.setNumberSpacing(e||null),()=>d().numberSpacing),setNumberForm:l("setNumberForm",e=>r.setNumberForm(e||null),()=>d().numberForm),setStylisticSet:l("setStylisticSet",e=>r.setStylisticSet(US(e)),()=>d().stylisticSet)}}function VS({gate:e,style:t,document:n,link:o,image:r,browser:a,actionCommand:i}){const s=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(s().link),isActive:Boolean(s().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 KS({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(HS(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(US(e)),!0),()=>a().spacingAfter),setSpacingBefore:o("setSpacingBefore",e=>(t.setSpacingBefore(US(e)),!0),()=>a().spacingBefore),setContextualSpacing:o("setContextualSpacing",e=>(t.setContextualSpacing(HS(e)),!0),()=>a().contextualSpacing),setLineRule:o("setLineRule",e=>(t.setLineRule(WS(e)),!0),()=>a().lineRule),setTextDirection:o("setTextDirection",e=>(t.setTextDirection(WS(e)),!0),()=>a().textDirection),setSuppressAutoHyphens:o("setSuppressAutoHyphens",e=>(t.setSuppressAutoHyphens(HS(e)),!0),()=>a().suppressAutoHyphens),setSuppressLineNumbers:o("setSuppressLineNumbers",e=>(t.setSuppressLineNumbers(HS(e)),!0),()=>a().suppressLineNumbers),setKinsoku:o("setKinsoku",e=>(t.setKinsoku(HS(e)),!0),()=>a().kinsoku),setOverflowPunct:o("setOverflowPunct",e=>(t.setOverflowPunct(HS(e)),!0),()=>a().overflowPunct),setWordWrap:o("setWordWrap",e=>(t.setWordWrap(HS(e)),!0),()=>a().wordWrap),setAutoSpaceDE:o("setAutoSpaceDE",e=>(t.setAutoSpaceDE(HS(e)),!0),()=>a().autoSpaceDE),setAutoSpaceDN:o("setAutoSpaceDN",e=>(t.setAutoSpaceDN(HS(e)),!0),()=>a().autoSpaceDN),setAdjustRightInd:o("setAdjustRightInd",e=>(t.setAdjustRightInd(HS(e)),!0),()=>a().adjustRightInd),setTopLinePunct:o("setTopLinePunct",e=>(t.setTopLinePunct(HS(e)),!0),()=>a().topLinePunct),setPageBreakBefore:o("setPageBreakBefore",e=>(t.setPageBreakBefore(HS(e)),!0),()=>a().pageBreakBefore),setKeepWithNext:o("setKeepWithNext",e=>(t.setKeepWithNext(HS(e)),!0),()=>a().keepWithNext),setKeepLinesTogether:o("setKeepLinesTogether",e=>(t.setKeepLinesTogether(HS(e)),!0),()=>a().keepLinesTogether),setWidowControl:o("setWidowControl",e=>(t.setWidowControl(HS(e)),!0),()=>a().widowControl),setMirrorIndents:o("setMirrorIndents",e=>(t.setMirrorIndents(HS(e)),!0),()=>a().mirrorIndents),setIndentLeft:o("setIndentLeft",e=>(t.setIndentLeft(US(e)),!0),()=>a().indentLeft),setIndentRight:o("setIndentRight",e=>(t.setIndentRight(US(e)),!0),()=>a().indentRight),setIndentFirstLine:o("setIndentFirstLine",e=>(t.setIndentFirstLine(US(e)),!0),()=>a().indentFirstLine),setIndentHanging:o("setIndentHanging",e=>(t.setIndentHanging(US(e)),!0),()=>a().indentHanging),setSpecialIndent:r("setSpecialIndent",e=>{const n=e??{};t.setSpecialIndent(n.kind??"none",US(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(US(e)),!0),()=>a().lineHeight),setListFormat:r("setListFormat",e=>t.setListFormat(String(e))),setListStartAt:r("setListStartAt",e=>t.setListStartAt(US(e))),setListLevel:r("setListLevel",e=>t.setListLevel(US(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=jt(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 _S({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 XS({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 GS({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 qS({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(HS(e))),tableSetCellFitText:n("tableSetCellFitText",e=>t.setCellFitText(HS(e))),tableSetRowHeight:n("tableSetRowHeight",e=>t.setActiveTableRowHeight(e??{height:null}),()=>({isEnabled:e.isCommandEnabled("tableSetRowHeight")&&t.canSetActiveTableRowHeight()})),tableSetBreakAcrossPages:o("tableSetBreakAcrossPages",e=>(t.setActiveTableRowBreakAcrossPages(HS(e)),!0),()=>({isEnabled:e.isCommandEnabled("tableSetBreakAcrossPages")&&t.canSetActiveTableRowBreakAcrossPages()})),tableSetHeaderRow:o("tableSetHeaderRow",e=>(t.setActiveTableRowHeader(HS(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(US(e)),()=>({isEnabled:e.isCommandEnabled("tableSetCellSpacing")&&t.canSetCellSpacing()})),tableSetTableIndent:n("tableSetTableIndent",e=>t.setTableIndent(US(e)),()=>({isEnabled:e.isCommandEnabled("tableSetTableIndent")&&t.canSetTableIndent()})),tableSetAlignment:n("tableSetAlignment",e=>t.setTableAlignment(WS(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 YS({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 ZS({dialog:e,actionCommand:t}){return{openFontDialog:t("openFontDialog",()=>{e.openFontDialog()}),openParagraphDialog:t("openParagraphDialog",t=>{const n="number"==typeof t&&Number.isFinite(t)?t:void 0;e.openParagraphDialog(n)})}}var JS=/* @__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"]),QS=/* @__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"]),eI=/* @__PURE__ */new WeakMap;function tI(e){return{isCommandEnabled:t=>"openSymbolDialog"===t||("openEquationDialog"===t||("repeatLastAction"===t?!e.isReadOnly()&&e.canRepeatLastAction():(!QS.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=eI.get(n);r||(r=/* @__PURE__ */new WeakMap,eI.set(n,r));const a=r.get(o);if(void 0!==a)return a;const i=null!==ci(t,e=>"image"===e.kind||"textBox"===e.kind);return r.set(o,i),i}(e))&&((JS.has(t)||!e.isReadOnly())&&("insertFootnote"!==t||e.commandsController.canInsertFootnoteCommand()))))}}function nI(e){return{state:()=>e.styleController.toolbarStyleState()}}function oI(e){return{isCollapsed:()=>fr(e.state().selection)}}function rI(e){return{canUndo:()=>e.undoStack().length>0,canRedo:()=>e.redoStack().length>0,undo:()=>(e.historyActions.performUndo(),!0),redo:()=>(e.historyActions.performRedo(),!0)}}var aI={nbsp:" ",nbHyphen:"‑",optionalHyphen:"­",emDash:"—",ellipsis:"…",copyright:"©",registered:"®",trademark:"™"};function iI(e){return/\p{L}|\p{N}/u.test(e)}function sI(e){return"."===e||"!"===e||"?"===e}function lI(e,t){return na(e,t)}function cI(e,t,n,o){return e-n||t-o}function dI(e,t){const n=zo(e),o=n[t.startIndex],r=n[t.endIndex];return o&&r?{...e,selection:{anchor:lI(o,t.startOffset),focus:lI(r,t.endOffset)}}:e}function uI(e,t,n){if(!t.length)return null;const o=zo(e),r=new Map(o.map((e,t)=>[e.id,t])),a="next"===n?ya(e,o).end:ya(e,o).start,i=r.get(a.paragraphId);if(void 0===i)return null;const s=o[i],l=ia(s,a);return("next"===n?t.find(e=>cI(e.startIndex,e.startOffset,i,l)>0):[...t].reverse().find(e=>cI(e.startIndex,e.startOffset,i,l)<0))??("next"===n?t[0]:t[t.length-1])}function pI(e){const t=zo(e),n=[],o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(const a of[...Cv(e),...Tv(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 gI(e,t){const n=uI(e,pI(e),t);return n?dI(e,n):e}function fI(e){const t=zo(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),s=n.get(e.end.paragraphId);if(void 0===i||void 0===s)continue;const l=t[i],c=t[s],d=Math.max(0,Math.min(e.start.offset,l.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)));cI(i,d,s,u)>0||r.push({id:a,startIndex:i,startOffset:d,endIndex:s,endOffset:u})}return r.sort((e,t)=>cI(e.startIndex,e.startOffset,t.startIndex,t.startOffset))}function mI(e,t){const n=uI(e,fI(e),t);return n?dI(e,n):e}function hI(e){const t=fI(e);if(!t.length)return null;const n=ya(e),o=t.find(e=>0===cI(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)&&0===cI(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset))??t.find(e=>cI(e.startIndex,e.startOffset,n.startIndex,n.startParagraphOffset)<=0&&cI(e.endIndex,e.endOffset,n.endIndex,n.endParagraphOffset)>=0);return o?e.document.comments?.items[o.id]??null:null}function bI(e,t){const n=pI(e).find(e=>e.id===t);return n?dI(e,n):e}var yI=e=>Math.round(e/Jo*96);function vI(e,t=3){const n=[];for(const o of Nr(e.document)){const e=Ae(o.style?.styleId);if(null===e||e>t)continue;const r=Ua(o).trim();r&&n.push({id:o.id,level:e,text:r})}return n}function xI(e){const t=zr(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 wI(e,t){const n=Da("");return n.runs=e,t&&(n.style=t),n}function SI(e,t,n){const o=void 0!==t?String(t):"";return wI([xI({text:`${e.text}\t${o}`})],{tabs:[{position:n,type:"right",leader:"dot"}],spacingAfter:yI(40),indentLeft:yI(397*(e.level-1))})}function II(e){const{width:t,margins:n}=e.pageSettings,o=Math.max(0,t-n.left-n.right);return gt(o*Qa,2)}function CI(e,t,n,o){const r=za(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:E(na(o,0))}}function TI(e,t=()=>{},n=3){if("main"!==Sr(e))return e;const o=lr(e),r=za(e.document)[o];if(!r)return e;const a=function(e,t,n){const o=e.map(e=>SI(e,t(e.id),n));return[wI([xI({text:"",fieldChar:{kind:"begin"}}),xI({text:"",fieldInstruction:' TOC \\o "1-3" \\h \\z \\u '}),xI({text:"",fieldChar:{kind:"separate"}})]),...o,wI([xI({text:"",fieldChar:{kind:"end"}})])]}(vI(e,n),t,II(r)),i=Xa(e,e.selection.focus),s=r.blocks.findIndex(e=>e.id===i.paragraphId||"paragraph"!==e.type&&oa(e).some(e=>e.id===i.paragraphId)),l=-1===s?r.blocks.length:s+1;return CI(e,o,[...r.blocks.slice(0,l),...a,...r.blocks.slice(l)],a[0])}function kI(e){let t=0,n="",o=-1,r=-1,a=!1;for(let i=0;i<e.length;i+=1){const s=e[i];if("paragraph"===s.type)for(const e of s.runs){const s=_a(e),l=kr(e);if("begin"===s?.kind)t+=1,1===t&&(r=i,n="",a=!1,o=-1);else if(1===t&&void 0!==l)n+=l,/\bTOC\b/i.test(n)&&(a=!0);else if("separate"===s?.kind)1===t&&(o=i);else if("end"===s?.kind){if(1===t&&a)return{startBlockIndex:o>=0?o:r,endBlockIndex:i};t=Math.max(0,t-1)}}}return null}function PI(e){const t=t=>{const n=Number(e.styleController.toolbarStyleState().fontSize),o=Number.isFinite(n)&&n>0?Gt(n):11,r="increase"===t?Cn(o):xt(o);return e.styleController.applyToolbarValueStyleCommand("fontSize",$n(r)),!0},n=e=>{const t=N(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=Nr(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:na(n,0),focus:na(o,Ua(o).length)}}),e.focusInput(),!0},selectWord:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=te(e),o=Ua(t);let r=n,a=n;for(;r>0&&iI(o[r-1]);)r-=1;for(;a<o.length&&iI(o[a]);)a+=1;return ii(e,{anchor:na(t,r),focus:na(t,a)})}(e.state())),e.focusInput(),!0),selectSentence:()=>!e.isReadOnly()&&(e.applyState(function(e){const{paragraph:t,offset:n}=te(e),o=Ua(t);let r=n;for(;r>0&&!sI(o[r-1]);)r-=1;for(;r<o.length&&/\s/u.test(o[r]);)r+=1;let a=n;for(;a<o.length&&!sI(o[a]);)a+=1;return a<o.length&&(a+=1),ii(e,{anchor:na(t,r),focus:na(t,Math.min(a,o.length))})}(e.state())),e.focusInput(),!0),selectParagraph:()=>!e.isReadOnly()&&(e.applyState(function(e){const t=zo(e),n=ya(e),o=t[n.startIndex],r=t[n.endIndex];return o&&r?ii(e,{anchor:na(o,0),focus:na(r,xa(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=zo(e),a=Pr(r,n,o),i=t?a<=0?o:n:a<=0?n:o;return ii(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=Zx(e.document,t)[Math.max(1,n)-1];return o?ii(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 ii(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=>Bu(e,t,o))),e.focusInput(),!0},insertEquation:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){if(Fn(e))return e;const n=fr(e.selection)?e:Z(e),{paragraph:o,index:r,offset:a}=te(n),i=ue(o,a),s={id:`run:${Math.random().toString(36).slice(2,9)}`,text:"",styles:i,kind:"math",math:t},l=G(o,a,[s]),c=zo(n).map((e,t)=>t===r?l:e);return ro(n,c,E(na(l,a+1)))}(e,t))),e.focusInput(),!0),updateEquation:(t,n)=>(e.applyTransactionalState(e=>function(e,t,n){let o=!1;const r=zo(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?ro(e,r,e.selection):e}(e,t,n)),e.focusInput(),!0),hasTableOfContents:()=>function(e){const t=za(e.document)[lr(e)];return!!t&&null!==kI(t.blocks)}(e.state()),hasRevisionsInSelection:()=>mS(e.state()).size>0,hasRevisionsInDocument:()=>bS(e.state()),hasNavigableRevisions:()=>pI(e.state()).length>0,hasNavigableComments:()=>{return(t=e.state(),fI(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=gI(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateRevisionPrevious:()=>{const t=e.state(),n=gI(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentNext:()=>{const t=e.state(),n=mI(t,"next");return n!==t&&(e.applyState(n),e.focusInput(),!0)},navigateCommentPrevious:()=>{const t=e.state(),n=mI(t,"previous");return n!==t&&(e.applyState(n),e.focusInput(),!0)},hasSelectedComment:()=>null!==hI(e.state()),isSelectedCommentResolved:()=>Boolean(hI(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=>TI(e,n(e))),e.focusInput(),!0),updateTableOfContents:()=>(e.applyTransactionalState(e=>function(e,t=()=>{},n=3){const o=lr(e),r=za(e.document)[o];if(!r)return e;const a=kI(r.blocks);if(!a)return e;const i=vI(e,n).map(e=>SI(e,t(e.id),II(r)));return CI(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=>Jx(e,t.search,t.replace,{matchCase:t.matchCase,wholeWord:t.wholeWord}),{mergeKey:_p}),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:Pv(e,"insertions"),deletions:Pv(e,"deletions"),comments:Pv(e,"comments"),formatting:Pv(e,"formatting"),allAuthors:t,visibleAuthors:e.markupAuthors??[],knownAuthors:Ev(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:()=>(bt(),!0),pageBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>go(e))),e.focusInput(),!0),lineBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Bu(e,"\n"))),e.focusInput(),!0),columnBreak:()=>(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>Du(e))),e.focusInput(),!0),splitBlock:()=>(e.commandsController.handleListEnter()||(e.applyTransactionalState(t=>e.tableOps.applyTableAwareParagraphEdit(t,e=>on(e))),e.focusInput()),!0),insertSpecialChar:t=>(e.applyTransactionalState(n=>e.tableOps.applyTableAwareParagraphEdit(n,e=>function(e,t){return Bu(e,aI[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=>Wu(e,1)),e.focusInput(),!0),shrinkFont1:()=>(e.applyTransactionalState(e=>Wu(e,-1)),e.focusInput(),!0),changeTextCase:t=>(e.commandsController.applyChangeTextCaseCommand(t),!0),clearFormatting:()=>fr(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 RI(e,t){const n=nx(e),o=n&&Fo(n.run);if(!n||!o)return e;const{paragraphIndex:r,run:a}=n,i=zo(e).map((e,n)=>n!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id===a.id&&"textBox"===e.kind?{...e,textBox:{...e.textBox,shape:t(e.textBox.shape??{})}}:Oo(e))});return ro(e,i,C(i,ya(e)))}function MI(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 OI(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*tr),align:void 0},positionV:{...a,offset:(a.offset??0)+Math.round(n*tr)}}}function AI(e,t){const n=ci(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=zo(e).map((e,t)=>t!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id!==a.id?Oo(e):"image"===e.kind?{...e,image:{...e.image,rotation:o}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,rotation:o}}:Oo(e))});return ro(e,i,C(i,ya(e)))}function BI(e,t,n=90){return DI(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 DI(e,t){const n=nx(e);if(!n||!Fo(n.run))return e;const{paragraphIndex:o,run:r}=n,a=zo(e).map((e,n)=>n!==o?Er(e):{...Er(e),runs:e.runs.map(e=>e.id===r.id&&"textBox"===e.kind?{...e,textBox:t(e.textBox)}:Oo(e))});return ro(e,a,C(a,ya(e)))}function FI(e,t){return DI(e,e=>({...e,body:t(e.body??{})}))}var EI={normal:"toolbar.style.builtin.normal",heading1:"toolbar.style.builtin.heading1",heading2:"toolbar.style.builtin.heading2",heading3:"toolbar.style.builtin.heading3",heading4:"toolbar.style.builtin.heading4",heading5:"toolbar.style.builtin.heading5",heading6:"toolbar.style.builtin.heading6",heading7:"toolbar.style.builtin.heading7",heading8:"toolbar.style.builtin.heading8",heading9:"toolbar.style.builtin.heading9",title:"toolbar.style.builtin.title",subtitle:"toolbar.style.builtin.subtitle",caption:"toolbar.style.builtin.caption",quote:"toolbar.style.builtin.quote",emphasis:"toolbar.style.builtin.emphasis",strong:"toolbar.style.builtin.strong",header:"toolbar.style.builtin.header",footer:"toolbar.style.builtin.footer",footnoteText:"toolbar.style.builtin.footnoteText",footnoteReference:"toolbar.style.builtin.footnoteReference"};function LI(e,t=!0){const n=U(e)??(t?Gv(e):void 0);return n?EI[n]:void 0}function NI(e){return{documentStyles:()=>{const t=e.state().document,n=t?.styles??{},o=/* @__PURE__ */new Set;for(const e of Nr(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=Qr(e.id,n),a="table"===e.type?Go(e.id,n).tableStyle:void 0,i=a?.conditionalFormats?.wholeTable,s=a?.conditionalFormats?.firstRow,l=a?.conditionalFormats?.band1Horz,c=i?.borders?.borderBottom??a?.borders?.borderBottom;return{id:e.id,name:e.name,labelKey:LI(e,!t.sourcePackage),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:s?.shading,bandFill:l?.shading,borderColor:c?.color,headerColor:s?.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:()=>Qf(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:n=>e.applyTransactionalState(e=>function(e,n){if(!n.trim())return e;const o=wt(n),r=ka(o)[0]?.blocks??[];if(0===r.length)return e;if(r.every(e=>"paragraph"===e.type))return Pu(e,r.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 a=fr(e.selection)?e:Z(e),{paragraph:i,offset:s}=te(a),l=t(i,0,s),c=t(i,s,xa(i)),d=Da(""),u={...i,runs:l.length?l:Da("").runs},p={...i,id:d.id,runs:c.length?c:d.runs},g=[...s>0?[u]:[],...r,...c.length||"table"===r[r.length-1]?.type?[p]:[]];let f=!1;const m=e=>{let t=!1;const n=e.flatMap(e=>{if("paragraph"===e.type&&e.id===i.id)return f=!0,t=!0,g;if("table"!==e.type)return[e];let n=!1;const o=e.rows.map(e=>{let t=!1;const o=e.cells.map(e=>{const n=m(e.blocks);return n===e.blocks?e:(t=!0,{...e,blocks:n})});return t?(n=!0,{...e,cells:o}):e});return n?(t=!0,[{...e,rows:o}]):[e]});return t?n:e},h=a.activeZone??"main";let b=a.document;if("footnote"===h&&a.activeFootnoteId&&a.document.footnotes?.items[a.activeFootnoteId]){const e=a.document.footnotes,t=e.items[a.activeFootnoteId],n=m(t.blocks);f&&(b={...a.document,footnotes:{...e,items:{...e.items,[a.activeFootnoteId]:{...t,blocks:n}}}})}else{const t=ka(a.document),n=Math.max(0,Math.min(a.activeSectionIndex??0,t.length-1)),o=t[n];if(!o)return e;const r="header"===h?"header":"footer"===h?"footer":"blocks",i=m(o[r]??[]);if(f){const e=[...t];e[n]={...o,[r]:i},b={...a.document,sections:e}}}if(!f)return e;const y=r[r.length-1],v="paragraph"!==y.type||c.length?na(p,0):na(y,xa(y));return{...a,document:b,selection:E(v)}}(e,n)),insertShape:t=>e.applyTransactionalState(e=>function(e,t){const n=fr(e.selection)?e:Z(e),{paragraph:o,index:r,offset:a}=te(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),s={width:150,height:100,blocks:[Da("")],shape:{preset:t,fill:i.fill,borderColor:i.border,borderWidthPt:1},floating:jy(void 0,"front")},l=Lr("",ue(o,a),void 0,s),c=G(o,a,[l]),d=zo(n).map((e,t)=>t===r?c:Er(e));return ro(n,d,E(na(c,a+1)))}(e,t)),setShapeFill:t=>e.applyTransactionalState(e=>function(e,t){return RI(e,e=>({...e,fill:t??void 0}))}(e,t),{mergeKey:Og}),setShapeOutline:t=>e.applyTransactionalState(e=>{return n=t,RI(e,e=>({...e,borderColor:n??void 0}));var n},{mergeKey:Ag}),setShapeOutlineWidth:t=>e.applyTransactionalState(e=>function(e,t){return RI(e,e=>({...e,borderWidthPt:Math.max(0,t)}))}(e,t),{mergeKey:Bg}),alignFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=zo(e).map((e,n)=>n!==o?Er(e):{...Er(e),runs:e.runs.map(e=>e.id!==r.id?Oo(e):"image"===e.kind?{...e,image:{...e.image,floating:MI(e.image.floating,t)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:MI(e.textBox.floating,t)}}:Oo(e))});return ro(e,a,C(a,ya(e)))}(e,t),{mergeKey:Dg}),reorderFloatingObject:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(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=zo(e).map((e,t)=>t!==o?Er(e):{...Er(e),runs:e.runs.map(e=>e.id!==r.id?Oo(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)}}:Oo(e))});return ro(e,i,C(i,ya(e)))}(e,t),{mergeKey:Fg}),nudgeFloatingObject:(t,n)=>e.applyTransactionalState(e=>function(e,t,n){const o=ci(e,e=>"image"===e.kind||"textBox"===e.kind);if(!o)return e;const{paragraphIndex:r,run:a}=o,i=zo(e).map((e,o)=>o!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id!==a.id?Oo(e):"image"===e.kind?{...e,image:{...e.image,floating:OI(e.image.floating,t,n)}}:"textBox"===e.kind?{...e,textBox:{...e.textBox,floating:OI(e.textBox.floating,t,n)}}:Oo(e))});return ro(e,i,C(i,ya(e)))}(e,t,n),{mergeKey:Eg}),setFloatingFixedPosition:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const{paragraphIndex:o,run:r}=n,a=zo(e).map((e,n)=>n!==o?Er(e):{...Er(e),runs:e.runs.map(e=>{if(e.id!==r.id)return Oo(e);if("image"===e.kind){const n=e.image.floating;return{...e,image:{...e.image,floating:n?Ky(n,t):n}}}if("textBox"===e.kind){const n=e.textBox.floating;return{...e,textBox:{...e.textBox,floating:n?Ky(n,t):n}}}return Oo(e)})});return ro(e,a,C(a,ya(e)))}(e,t),{mergeKey:Lg}),setFloatingRotation:t=>e.applyTransactionalState(e=>AI(e,t),{mergeKey:Ng}),setFloatingWrapPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(e,e=>"image"===e.kind||"textBox"===e.kind);if(!n)return e;const o=e=>jy(e,t),{paragraphIndex:r,run:a}=n,i=zo(e).map((e,t)=>t!==r?Er(e):{...Er(e),runs:e.runs.map(e=>{if(e.id!==a.id)return Oo(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 Oo(e)})});return ro(e,i,C(i,ya(e)))}(e,t),{mergeKey:zg}),setFloatingWrapText:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(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=zo(e).map((e,t)=>t!==r?Er(e):{...Er(e),runs:e.runs.map(e=>e.id!==a.id?Oo(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)}}:Oo(e))});return ro(e,i,C(i,ya(e)))}(e,t),{mergeKey:$g}),setFloatingPositionPreset:t=>e.applyTransactionalState(e=>function(e,t){const n=ci(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:s,run:l}=n,c=zo(e).map((e,t)=>t!==s?Er(e):{...Er(e),runs:e.runs.map(e=>{if(e.id!==l.id)return Oo(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 Oo(e)})});return ro(e,c,C(c,ya(e)))}(e,t),{mergeKey:Hg}),setShapePreset:t=>e.applyTransactionalState(e=>function(e,t){return RI(e,e=>({...e,preset:t}))}(e,t),{mergeKey:Wg}),setTextBoxTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n="horz"===t?"horz":"vert"===t?"vert":"vert270"===t?"vert270":"wordArtVert";return FI(e,e=>({...e,vert:n}))}(e,t),{mergeKey:Ug}),setTextBoxVerticalAlign:t=>e.applyTransactionalState(e=>function(e,t){const n="b"===t?"b":"ctr"===t?"ctr":"t";return FI(e,e=>({...e,anchor:n}))}(e,t),{mergeKey:jg}),setTextBoxAlt:t=>e.applyTransactionalState(e=>function(e,t){return DI(e,e=>({...e,alt:t??void 0}))}(e,t),{mergeKey:Vg}),rotateTextBox:t=>e.applyTransactionalState(e=>BI(e,t),{mergeKey:Kg}),getTextBoxSizeCm:()=>function(e){const t=nx(e),n=t&&Fo(t.run);return n?{width:n.width/No,height:n.height/No}:null}(e.state()),isTextBoxSelected:()=>null!==nx(e.state()),setTextBoxWidthCm:t=>e.applyTransactionalState(e=>function(e,t){return DI(e,e=>({...e,width:Math.max(24,Math.round(t*No))}))}(e,t),{mergeKey:_g}),setTextBoxHeightCm:t=>e.applyTransactionalState(e=>function(e,t){return DI(e,e=>({...e,height:Math.max(24,Math.round(t*No))}))}(e,t),{mergeKey:Xg})}}function zI(e){return{prompt:()=>e.commandsController.promptForLink(),remove:()=>e.commandsController.removeLinkCommand(),canPrompt:()=>!fr(e.state().selection)||Boolean(e.styleController.toolbarStyleState().link)}}function $I(e){return{promptAlt:()=>e.commandsController.promptForImageAlt(),promptCaption:()=>e.commandsController.promptForImageCaption(),isSelected:()=>Boolean(e.selectedImageRun()),getSizeCm:()=>function(e){const t=Xy(e),n=t&&Uo(t.run);return n?{width:n.width/No,height:n.height/No}: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=Xy(e);return(t&&Uo(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=Xy(e);return(t&&Uo(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=Xy(e),n=t&&Uo(t.run);return n?n.transparency??0:null}(e.state()),setTransparency:t=>e.commandsController.applyImageTransparencyCommand(t),reset:()=>e.commandsController.resetImageCommand(),canReset:()=>null!==Xy(e.state())}}function HI(e){const t=e.clipboardActions??tp({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 WI(e,t){const n=Sr(e),o=za(e.document);if("header"===n||"footer"===n){const r=lr(e),a=o[r];if(!a)return e;const i=e.activeHeaderFooterStory??"default",s=Fr(a,n,i,t),l=[...o];return l[r]=s,{...e,document:{...e.document,sections:l}}}if("main"===n){const n=lr(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 UI(e,t){return null!==VI(e,t)}function jI(e,t){const n=VI(e,t);if(!n)return e;const{nextBlocks:o}=n,r=WI(e,o),a=o.flatMap(oa);return{...r,selection:KI(e.selection,a)}}function VI(e,t){const n=Sr(e);if("footnote"===n)return null;const o=ei(e,n);if(0===o.length)return null;const r=ya(e),a=function(e,t,n,o){const r=/* @__PURE__ */new Set;for(let s=n;s<=o;s+=1){const e=t[s];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 s=a;s<=i;s+=1)if("paragraph"!==e[s].type)return null;return{lo:a,hi:i}}(o,function(e){const t=[];return e.forEach((e,n)=>{oa(e).forEach(()=>{t.push(n)})}),t}(o),r.startIndex,r.endIndex);if(!a)return null;const{lo:i,hi:s}=a,l=o.slice(i,s+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),...l,e,...o.slice(s+1)]}else{if(s===o.length-1)return null;const e=o[s+1];if("paragraph"!==e.type)return null;c=[...o.slice(0,i),e,...l,...o.slice(s+2)]}return{nextBlocks:c}}function KI(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 na(r,Math.min(e.offset,xa(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function _I(e,t){const n=function(e){const t=Sr(e);if("footnote"===t)return null;const n=ei(e,t);if(0===n.length)return null;const o=ya(e),r=/* @__PURE__ */new Set;for(let s=o.startIndex;s<=o.endIndex;s+=1){let e=0,t=-1;for(let o=0;o<n.length;o+=1){const r=oa(n[o]).length;if(s<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 s=a;s<=i;s+=1)if("paragraph"!==n[s].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:XI(Ua(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 s=[...a.slice(0,o),...i.map(e=>e.block),...a.slice(r+1)],l=WI(e,s),c=s.flatMap(oa);return{...l,selection:GI(e.selection,c)}}function XI(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)/.exec(t)?.[1];return{num:void 0===n?void 0:Number(n),text:e}}function GI(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 na(r,Math.min(e.offset,xa(r)))};return{anchor:o(e.anchor),focus:o(e.focus)}}function qI(e,t){const n=ya(e),o=zo(e);let r=1;for(let s=0;s<n.startIndex;s+=1){const e=Ae(o[s]?.style?.styleId);null!==e&&(r=e)}let a=!1;const i=o.map((e,o)=>{if(o<n.startIndex||o>n.endIndex)return Er(e);const i=Ae(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?Er(e):(a=!0,De(e,o))}if(null!==i){const n=t?Math.max(1,i-1):Math.min(9,i+1);if(n===i)return Er(e);a=!0;const o=Er(e);return o.style={...e.style??{},styleId:`heading${n}`,outlineLevel:void 0},o}if(!t)return Er(e);a=!0;const s=Er(e);return s.style={...e.style??{},styleId:`heading${r}`,outlineLevel:void 0},s});return a?ro(e,i,C(i,n)):e}var YI=["align","spacingBefore","spacingAfter","lineHeight","lineRule","indentLeft","indentRight","indentFirstLine","indentHanging","mirrorIndents","contextualSpacing","outlineLevel","shading","borderTop","borderRight","borderBottom","borderLeft","tabs","pageBreakBefore","keepWithNext","keepLinesTogether","widowControl","bidi"];var ZI=/* @__PURE__ */new Set(["auto","exact","atLeast"]);var JI=/* @__PURE__ */new Set(["lrTb","tbRl","btLr","lrTbV","tbRlV"]);var QI={width:1.5,type:"solid",color:"#000000"};function eC(e,t){const n=t.text??Ua(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 tC(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=ya(e),o=zo(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 ZI.has(t)?t:a})();if(a===i)return e;r=!0;const s=void 0===i?(()=>{const{lineRule:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},lineRule:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setTextDirection:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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:JI.has(t)?t:a;if(a===i)return e;r=!0;const s=void 0===i?(()=>{const{textDirection:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},textDirection:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setSuppressAutoHyphens:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{suppressAutoHyphens:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressAutoHyphens:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setSuppressLineNumbers:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{suppressLineNumbers:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},suppressLineNumbers:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setKinsoku:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{kinsoku:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},kinsoku:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setOverflowPunct:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{overflowPunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},overflowPunct:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setWordWrap:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{wordWrap:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},wordWrap:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setAutoSpaceDE:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{autoSpaceDE:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDE:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setAutoSpaceDN:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{autoSpaceDN:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},autoSpaceDN:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setAdjustRightInd:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{adjustRightInd:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},adjustRightInd:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setTopLinePunct:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{topLinePunct:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},topLinePunct:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setPageBreakBefore:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{pageBreakBefore:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},pageBreakBefore:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setKeepWithNext:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{keepWithNext:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepWithNext:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setKeepLinesTogether:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{keepLinesTogether:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},keepLinesTogether:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setWidowControl:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{widowControl:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},widowControl:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setContextualSpacing:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{contextualSpacing:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},contextualSpacing:i};return{...Er(e),style:s}});return r?ro(e,a,C(a,n)):e}(e,t)),setMirrorIndents:t=>e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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 s=void 0===i?(()=>{const{mirrorIndents:t,...n}=e.style??{};return Object.keys(n).length>0?n:void 0})():{...e.style??{},mirrorIndents:i};return{...Er(e),style:s}});return r?ro(e,a,C(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=ae(e,"indentFirstLine",null);return n=ae(n,"indentHanging",null),"firstLine"===t?n=ae(n,"indentFirstLine",o):"hanging"===t&&(n=ae(n,"indentHanging",o)),n},{mergeKey:Wp}),e.focusInput()},setShading:t=>e.commandsController.applyParagraphStyleCommand("shading",t),applyBorders:()=>{const t={width:1,type:"solid",color:"#000000"};e.applyTransactionalState(e=>{let n=ae(e,"borderTop",t);return n=ae(n,"borderRight",t),n=ae(n,"borderBottom",t),n=ae(n,"borderLeft",t),n},{mergeKey:Up}),e.focusInput()},addHorizontalLine:()=>{e.applyTransactionalState(e=>ae(e,"borderBottom",QI),{mergeKey:Up}),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=ya(e),o=Math.min(8,Math.max(0,Math.round(t))),r=zo(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,De(e,o)):e);return a?ro(e,i,C(i,n)):e}(e,t)),e.focusInput()},outdent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>PS(e,-1)),e.focusInput()},indent:()=>{e.clearPreferredColumn(),e.resetTransactionGrouping(),e.tableOps.applySelectionAwareParagraphCommand(e=>PS(e,1)),e.focusInput()},moveParagraphsUp:()=>{UI(e.state(),"up")?(e.applyTransactionalState(e=>jI(e,"up"),{mergeKey:jp}),e.focusInput()):e.focusInput()},moveParagraphsDown:()=>{UI(e.state(),"down")?(e.applyTransactionalState(e=>jI(e,"down"),{mergeKey:Vp}),e.focusInput()):e.focusInput()},canMoveParagraphsUp:()=>UI(e.state(),"up"),canMoveParagraphsDown:()=>UI(e.state(),"down"),promote:()=>{e.applyTransactionalState(e=>qI(e,!0)),e.focusInput()},demote:()=>{e.applyTransactionalState(e=>qI(e,!1)),e.focusInput()},resetParagraphFormatting:()=>{e.applyTransactionalState(e=>function(e){const t=ya(e),n=zo(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||YI.every(e=>!(e in r)))return e;o=!0;const a=Er(e),i=r.styleId?{styleId:r.styleId}:{};return a.style=Object.keys(i).length>0?i:void 0,a});return o?ro(e,r,C(r,t)):e}(e)),e.focusInput()},setTabStops:t=>{e.resetTransactionGrouping(),e.applyTransactionalState(e=>dn(e,t),{mergeKey:Gp}),e.focusInput()},setOutlineLevel:t=>{e.applyTransactionalState(e=>function(e,t){const n=ya(e),o=zo(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=Er(e);return i.style=Object.keys(o).length>0?o:void 0,i});return a?ro(e,i,C(i,n)):e}(e,t)),e.focusInput()},setBidi:t=>e.commandsController.applyParagraphStyleCommand("bidi",t),setParagraphAlign:t=>{e.applyTransactionalState(e=>function(e,t){return ae(e,"align",t)}(e,t))},sortParagraphs:(t=!1)=>e.applyTransactionalState(e=>_I(e,t)),hasDropCap:()=>function(e){const t=ya(e);return zo(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=ya(e),o=zo(e),r=n.startIndex,a=n.endIndex,i="none"===t.type||0===t.lines||void 0!==t.text&&0===t.text.length,s=o.map((e,n)=>n<r||n>a?Er(e):i?{...Er(e),dropCap:void 0}:{...Er(e),dropCap:eC(e,{...t,type:"margin"===t.type?"margin":"drop"})});return ro(e,s,C(s,n))}(e,t)),e.focusInput()}}}function nC(e){const t=za(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(lr(e),t.length-1))}}function oC(e,t){const{sections:n,sectionIndex:o}=nC(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 rC(e,t,n="default"){const o=Qo(t,n);return oC(e,e=>e[o]?e:{...e,[o]:[$a(t)]})}function aC(e,t,n="default"){const o=Qo(t,n),r=oC(e,e=>e[o]?{...e,[o]:void 0}:e);return r===e?e:Sr(r)===t?cC(r):r}function iC(e,t,n="default"){const o=rC(e,t,n),{sections:r,sectionIndex:a}=nC(o),i=(r[a][Qo(t,n)]??[]).flatMap(oa).find(Boolean);return i?{...o,selection:_o(na(i,0)),activeSectionIndex:a,activeZone:t,activeHeaderFooterStory:n}:o}function sC(e){const{sections:t,sectionIndex:n}=nC(e),o=t[n];return Boolean(o&&(o.firstPageHeader||o.firstPageFooter))}function lC(e){const{sections:t,sectionIndex:n}=nC(e),o=t[n];return Boolean(o&&(o.evenPageHeader||o.evenPageFooter))}function cC(e){const{sections:t,sectionIndex:n}=nC(e),o=(t[n]?.blocks??[]).flatMap(oa).find(Boolean);return o?{...e,selection:_o(na(o,0)),activeSectionIndex:n,activeZone:"main",activeHeaderFooterStory:void 0}:{...e,activeZone:"main",activeHeaderFooterStory:void 0}}function dC(e){return function(e,n){const o=fr(e.selection)?e:Z(e),{paragraph:r,index:a,offset:i}=te(o),s=t(r,0,i),l=t(r,i,xa(r)),c={id:`run:field:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:{type:n},styles:ue(r,i)},d=To(r,[...s,c,...l]),u=zo(o),p=[...yr(u.slice(0,a)),d,...yr(u.slice(a+1))];return ro(o,p,E(na(d,i+c.text.length)))}(e,"PAGE")}function uC(e,t,n,o){return{id:n,text:"1",kind:"field",field:o&&"decimal"!==o?{type:e,format:o}:{type:e},styles:t}}function pC(e,t){const n=Math.random().toString(36).slice(2,9);return"xOfY"===e?[{id:`run:page-of:${n}`,text:"Page ",kind:"text"},uC("PAGE",void 0,`run:page-field:${n}`,t),{id:`run:page-of:${n}`,text:" of ",kind:"text"},uC("NUMPAGES",void 0,`run:page-field:${n}`,t)]:[uC("PAGE",void 0,`run:page-field:${n}`,t)]}function gC(e,n="page",o){return function(e,n){const o=fr(e.selection)?e:Z(e),{paragraph:r,index:a,offset:i}=te(o),s=ue(r,i),l=n.map((e,t)=>e.styles?e:{...e,styles:s,id:`${e.id}:${t}`}),c=To(r,[...t(r,0,i),...l,...t(r,i,xa(r))]),d=zo(o),u=[...yr(d.slice(0,a)),c,...yr(d.slice(a+1))],p=l.reduce((e,t)=>e+t.text.length,0);return ro(o,u,E(na(c,i+p)))}(e,pC(n,o))}function fC(e){const t=za(e.document);return{sections:t,sectionIndex:Math.max(0,Math.min(lr(e),t.length-1))}}function mC(e,t,n={}){const{kind:o="page",format:r,align:a="center"}=n;if("current"===t)return gC(e,o,r);const i="top"===t?"header":"footer",s=Qo(i,"default"),{sections:l,sectionIndex:c}=fC(e);if(0===l.length)return e;const d={id:ar("paragraph"),type:"paragraph",runs:pC(o,r),style:{styleId:i,align:a}},u={...l[c],[s]:[d]},p=[...l];return p[c]=u,{...e,document:{...e.document,sections:p},selection:_o(na(d,0)),activeSectionIndex:c,activeZone:i}}function hC(e){const t={isLandscape:()=>{const t=lr(e.state());return"landscape"===(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.orientation},setOrientation:t=>{const n=lr(e.state()),o=e.state().document.sections?.[n]??e.state().document;o&&e.commandsController.applyUpdateSectionSettingsCommand(n,{pageSettings:{...o.pageSettings,orientation:t}})},toggleOrientation:()=>{const n=lr(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=lr(e.state());return(e.state().document.sections?.[t]??e.state().document)?.pageSettings?.margins},setPageMargins:t=>{const n=lr(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=>mt(e,t)),e.focusInput()},getPageNumbering:()=>{const t=lr(e.state());return e.state().document.sections?.[t]?.pageNumbering},setPageNumbering:t=>{e.applyTransactionalState(e=>function(e,t){const{sections:n,sectionIndex:o}=fC(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 i(e,o,{pageNumbering:r})}(e,t)),e.focusInput()},getPaperSize:()=>gn(e.state()),setPaperSize:t=>{e.applyTransactionalState(e=>ho(e,t)),e.focusInput()},setPaperSizePreset:t=>{e.applyTransactionalState(e=>xe(e,t)),e.focusInput()},getColumns:()=>Mn(e.state()),setColumns:t=>{e.applyTransactionalState(e=>xo(e,t)),e.focusInput()},getVerticalAlign:()=>rt(e.state()),setVerticalAlign:t=>{e.applyTransactionalState(e=>m(e,t)),e.focusInput()},getSectionStart:()=>{const t=lr(e.state());return e.state().document.sections?.[t]?.breakType},setSectionStart:t=>{const n=lr(e.state());(e.state().document.sections?.[n]??e.state().document)&&e.commandsController.applyUpdateSectionSettingsCommand(n,{breakType:t})},getBidi:()=>zt(e.state()),setBidi:t=>{e.applyTransactionalState(e=>so(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 bC(e){const t=t=>{e.applyTransactionalState(t),e.focusInput()};return{editHeader:()=>t(e=>iC(e,"header")),editFooter:()=>t(e=>iC(e,"footer")),editFirstPageHeader:()=>t(e=>iC(e,"header","firstPage")),editEvenPageHeader:()=>t(e=>iC(e,"header","evenPage")),editFirstPageFooter:()=>t(e=>iC(e,"footer","firstPage")),editEvenPageFooter:()=>t(e=>iC(e,"footer","evenPage")),insertPageNumber:()=>t(e=>dC(e)),insertPageNumberXOfY:()=>t(e=>gC(e,"xOfY")),placePageNumberTop:()=>t(e=>mC(e,"top")),placePageNumberBottom:()=>t(e=>mC(e,"bottom")),exit:()=>t(e=>function(e){return cC(e)}(e)),isInHeaderFooter:()=>{const t=e.state().activeZone;return"header"===t||"footer"===t},getDifferentFirstPage:()=>sC(e.state()),setDifferentFirstPage:e=>t(t=>function(e,t){if(sC(e)===t)return e;let n=e;return t?(n=rC(n,"header","firstPage"),n=rC(n,"footer","firstPage"),n):(n=aC(n,"header","firstPage"),aC(n,"footer","firstPage"))}(t,e)),getDifferentOddEven:()=>lC(e.state()),setDifferentOddEven:e=>t(t=>function(e,t){if(lC(e)===t)return e;let n=e;return t?(n=rC(n,"header","evenPage"),n=rC(n,"footer","evenPage"),n):(n=aC(n,"header","evenPage"),aC(n,"footer","evenPage"))}(t,e))}}function yC(e){const t=e.document.bookmarks;return t?t.order.map(e=>t.items[e]).filter(e=>Boolean(e)):[]}function vC(e){return{insert:t=>{e.applyTransactionalState(e=>function(e,t){const{start:n,end:o,isCollapsed:r}=ya(e),a=e.document.bookmarks,i=a?.order??[],s=t&&t.trim().length>0?t.trim():`Bookmark${i.length+1}`,l={id:Mr(),name:s,start:{paragraphId:n.paragraphId,offset:n.offset},...r?{}:{end:{paragraphId:o.paragraphId,offset:o.offset}}},c={items:{...a?.items??{},[l.id]:l},order:[...i,l.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:()=>yC(e.state()).map(e=>({id:e.id,name:e.name}))}}var xC=["January","February","March","April","May","June","July","August","September","October","November","December"],wC=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function SC(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 s=e.getHours();switch(t){case"d":n+=i.length>=4?wC[e.getDay()]:3===i.length?wC[e.getDay()].slice(0,3):2===i.length?o(e.getDate()):String(e.getDate());break;case"M":n+=i.length>=4?xC[e.getMonth()]:3===i.length?xC[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(s);break;case"h":n+=i.length>=2?o(s%12==0?12:s%12):String(s%12==0?12:s%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+=s<12?"am":"pm",r+=5;continue}n+=t}r+=i.length}return n}function IC(e,n){const o=n.type??"REF";if(!function(e,t){return yC(e).find(e=>e.name===t)}(e,n.bookmark))return e;const r=fr(e.selection)?e:Z(e),{paragraph:a,index:i,offset:s}=te(r),l=ue(a,s),c={type:o,bookmark:n.bookmark},d={id:`run:${o.toLowerCase()}:${Math.random().toString(36).slice(2,9)}`,text:"1",kind:"field",field:c,styles:l},u=To(a,[...t(a,0,s),d,...t(a,s,xa(a))]),p=zo(r),g=[...yr(p.slice(0,i)),u,...yr(p.slice(i+1))];return ro(r,g,E(na(u,s+d.text.length)))}function CC(e){return{insertDate:()=>{e.applyTransactionalState(e=>function(e,n={}){const o=(n.dateFormat??"M/d/yyyy").trim(),r=n.value??/* @__PURE__ */new Date,a=fr(e.selection)?e:Z(e),{paragraph:i,index:s,offset:l}=te(a),c=ue(i,l),d=o.length>0&&"M/d/yyyy"!==o?{type:"DATE",dateFormat:o}:{type:"DATE"},u={id:`run:date:${Math.random().toString(36).slice(2,9)}`,text:SC(r,o),kind:"field",field:d,styles:c},p=To(i,[...t(i,0,l),u,...t(i,l,xa(i))]),g=zo(a),f=[...yr(g.slice(0,s)),p,...yr(g.slice(s+1))],m=u.text.length;return ro(a,f,E(na(p,l+m)))}(e)),e.focusInput()},insertDateTime:t=>{e.applyTransactionalState(e=>function(e,t="M/d/yyyy",n=/* @__PURE__ */new Date){const o=SC(n,t);return 0===o.length?e:Bu(e,o)}(e,t)),e.focusInput()},insertCrossReference:t=>{e.applyTransactionalState(e=>IC(e,t)),e.focusInput()}}}function TC(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=lr(e),n=$r(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=za(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=Bo(o,n.tablePath);return r?.[r.length-1]?.table??null},i=e=>{const t=a(e);if(!t)return null;const n=br(t,e.document.styles);return{...r,...n.tblLook??{}}};return{insideTable:()=>Boolean($r(e.state().document,e.state().selection.focus.paragraphId,lr(e.state()))),selectionLabel:()=>{const t=e.state();if(ya(t).isCollapsed)return null;const n=lr(t),o=$r(t.document,t.selection.anchor.paragraphId,n),r=$r(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 s=e.selectionBoxes().length;return 0===s?null:`Table selection: ${s} cell${1===s?"":"s"}`},getTblLook:()=>{const t=i(e.state());return t?{firstRow:t.firstRow,lastRow:t.lastRow,firstCol:t.firstCol,lastCol:t.lastCol,bandedRows:!t.noHBand,bandedCols:!t.noVBand}:null},toggleTblLook:e=>o(t=>{const n=i(t);if(!n)return t;const o={...n};switch(e){case"firstRow":o.firstRow=!n.firstRow;break;case"lastRow":o.lastRow=!n.lastRow;break;case"firstCol":o.firstCol=!n.firstCol;break;case"lastCol":o.lastCol=!n.lastCol;break;case"bandedRows":o.noHBand=!n.noHBand;break;case"bandedCols":o.noVBand=!n.noVBand}return vf(t,"tblLook",o)},Tg),getStyleId:()=>a(e.state())?.style?.styleId??null,setStyleId:e=>o(t=>vf(t,"styleId",e||null),kg),getLayout:()=>a(e.state())?.style?.layout??null,toggleAutoFit:()=>o(e=>vf(e,"layout","autofit"===a(e)?.style?.layout?"fixed":"autofit"),Pg),canSetAutoFit:()=>null!==tf(e.state()),setAutoFit:e=>o(t=>function(e,t){const n="fixed"===t?"fixed":"autofit";return gf(e,o=>{let r=o.style;e.trackChangesEnabled&&!r?.revision&&(r={...r??{},revision:{...qg(),type:"property",previous:{...r??{}}}});let a=Yg(r,"layout",n);return"window"===t?a=Yg(a,"width","100%"):"contents"===t&&(a=Yg(a,"width",null)),{...o,style:a}})}(t,e),xg),distributeColumns:()=>o(e=>gf(e,e=>{const t=Kr(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),s=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:s,style:{...e.style??{},width:r}}}),Pg),distributeRows:()=>o(e=>gf(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}}),Pg),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!==tf(e.state()),convertToText:()=>o(e=>kf(e),gg),canConvertToTable:()=>{return!tf(t=e.state())&&null!==df(t);var t},convertToTable:()=>o(e=>Pf(e),fg),canSplitTableAtRow:()=>function(e){const t=tf(e);if(!t)return!1;const n=cf(e);if(!n)return!1;const o=sf(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=tf(e);if(!t)return e;const n=cf(e);if(!n)return e;const o=sf(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),s={...o,rows:a},l=Wr(i),c=pf(e,[s,Da(""),l]);if(c===e)return e;const d=l.rows[0]?.cells[0]?.blocks.find(e=>"paragraph"===e.type);return d?{...c,selection:E(na(d,0))}:e}(e),mg),canSortTable:()=>function(e){const t=tf(e);if(!t)return!1;const n=cf(e);if(!n)return!1;const o=sf(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=>Mf(t,e),"ascending"===e?hg:bg),canDeleteTable:()=>null!==tf(e.state()),deleteTable:()=>o(e=>function(e){const t=tf(e);if(!t)return e;const n=cf(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=Da(""),n=pf(e,[t]);return n===e?e:{...n,selection:E(na(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=pf(e,[]);if(a===e)return e;if(r){const e=zo(a).find(e=>e.id===r);if(e)return{...a,selection:E(na(e,0))}}return a}(e),yg),canToggleRepeatHeaderRows:()=>function(e){const t=tf(e);if(!t)return!1;const n=cf(e);if(!n)return!1;const o=sf(n,t.loc.tablePath);return null!==o&&o.rows.length>0}(e.state()),isRepeatHeaderRowsActive:()=>function(e){const t=tf(e);if(!t)return!1;const n=cf(e);if(!n)return!1;const o=sf(n,t.loc.tablePath);return!(!o||0===o.rows.length)&&Af(o.rows[0])}(e.state()),toggleRepeatHeaderRows:()=>o(e=>function(e){const t=tf(e);if(!t)return e;const n=cf(e);if(!n)return e;const o=sf(n,t.loc.tablePath);if(!o||0===o.rows.length)return e;const r=Af(o.rows[0]);return gf(e,e=>({...e,rows:e.rows.map((e,t)=>0!==t?e:r?{...e,isHeader:void 0}:{...e,isHeader:!0})}))}(e),wg),merge:()=>o(t=>e.tableOps.mergeSelectedTable(t),Jp),split:()=>o(t=>e.tableOps.splitSelectedTable(t),Qp),insertColumnBefore:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,-1),eg),insertColumnAfter:()=>o(t=>e.tableOps.insertSelectedTableColumn(t,1),eg),deleteColumn:()=>o(t=>e.tableOps.deleteSelectedTableColumn(t),tg),insertRowBefore:()=>o(t=>e.tableOps.insertSelectedTableRow(t,-1),ng),insertRowAfter:()=>o(t=>e.tableOps.insertSelectedTableRow(t,1),ng),deleteRow:()=>o(t=>e.tableOps.deleteSelectedTableRow(t),og),canDeleteCell:()=>Kf(e.state()),deleteCell:()=>o(e=>_f(e),vg),cellShading:e=>o(t=>bf(t,"shading",e||null),rg),cellBorders:()=>o(e=>yf(e,{width:1,type:"solid",color:"#64748b"}),ag),cellNoBorders:()=>o(e=>yf(e,{width:0,type:"none",color:"transparent"}),ag),applyBorderPreset:e=>o(t=>function(e,t,n=ff){const o=hf(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 s=(e,t,o=n)=>{if(!e)return;const a=r.get(e.cell.id)??{};a[t]=o,r.set(e.cell.id,a)},l=(e,t,o,r,a=n)=>{s(e,t,a),o&&o.cell.id!==e?.cell.id&&s(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 s=o.startCol;s<=o.endCol;s+=1){const o=i.get(`${n}:${s}`);o&&a.has(o.cell.id)&&l(o,"top"===e?"borderTop":"borderBottom",i.get(`${r}:${s}`),"top"===e?"borderBottom":"borderTop",t)}return}const r="left"===e?o.startCol:o.endCol,s=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)&&l(o,"left"===e?"borderLeft":"borderRight",i.get(`${n}:${s}`),"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)&&l(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)&&l(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"])s(e,t,mf);c("top",mf),c("right",mf),c("bottom",mf),c("left",mf);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)s(e,"borderTopLeftToBottomRight");break;case"diagonalUp":for(const e of o.selectedEntries)s(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 oa(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:{...qg(),type:"property",previous:{...o??{}}}});for(const[e,r]of Object.entries(n))o=Yg(o,e,r);return{...t,style:o}},f=za(e.document).map(e=>({...e,blocks:Et(e.blocks,p,g),header:e.header?Et(e.header,p,g):void 0,footer:e.footer?Et(e.footer,p,g):void 0}));return{...e,document:{...e.document,sections:f}}}(t,e),ag),isDrawingBorders:()=>t,toggleDrawingBorders:()=>{t=!t,e.applyState({...e.state()})},isShowingGridlines:()=>n,toggleGridlines:()=>{n=!n,e.applyState({...e.state()})},width100:()=>o(e=>vf(e,"width","100%"),ig),alignLeft:()=>o(e=>bf(e,"horizontalAlign","left"),sg),alignCenter:()=>o(e=>bf(e,"horizontalAlign","center"),sg),alignRight:()=>o(e=>bf(e,"horizontalAlign","right"),sg),setCellAlignment:e=>o(t=>{return n=t,o=e.horizontal,r=e.vertical,bf(bf(n,"horizontalAlign",o),"verticalAlign",r);var n,o,r},lg),getCellAlignmentState:()=>function(e){const t=hf(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=>bf(t,"verticalAlign",e),cg),setCellTextDirection:e=>o(t=>bf(t,"textDirection",e),dg),setCellWidth:e=>o(t=>function(e,t){return bf(e,"width",t)}(t,e),ug),setCellNoWrap:e=>o(t=>function(e,t){return bf(e,"noWrap",t)}(t,e),ug),setCellFitText:e=>o(t=>function(e,t){return bf(e,"fitText",t)}(t,e),ug),canSetCellMargins:()=>null!==tf(e.state()),setCellMargins:e=>o(t=>function(e,t){let n=e;return void 0!==t.top&&(n=bf(n,"paddingTop",t.top)),void 0!==t.right&&(n=bf(n,"paddingRight",t.right)),void 0!==t.bottom&&(n=bf(n,"paddingBottom",t.bottom)),void 0!==t.left&&(n=bf(n,"paddingLeft",t.left)),n}(t,e),Sg),canSetCellSpacing:()=>Bf(e.state()),setCellSpacing:e=>o(t=>function(e,t){return Bf(e)?vf(e,"cellSpacing",null===t||t<0?null===t?null:0:Math.round(2*t)/2):e}(t,e),Sg),canSetTableIndent:()=>Df(e.state()),setTableIndent:e=>o(t=>function(e,t){return Df(e)?null===t||t<0||Number.isNaN(t)||!Number.isFinite(t)?vf(e,"indentLeft",null):vf(e,"indentLeft",Math.round(2*t)/2):e}(t,e),Sg),canSetTableAlignment:()=>null!==tf(e.state()),setTableAlignment:e=>o(t=>Ef(t,e),Sg),canEvaluateTableFormula:()=>null!==tf(e.state()),evaluateTableFormula:e=>o(t=>zf(t,e),Ig),canSelectTable:()=>null!==tf(e.state()),selectTablePart:t=>e.applyState(jf(e.state(),t)),canSetActiveTableRowHeight:()=>null!==tf(e.state()),setActiveTableRowHeight:e=>o(t=>function(e,t){let n=e;return n=wf(n,"height",t.height),void 0!==t.heightRule&&(n=wf(n,"heightRule",t.heightRule)),n}(t,e),Cg),canSetActiveTableRowBreakAcrossPages:()=>Lf(e.state()),setActiveTableRowBreakAcrossPages:e=>o(t=>function(e,t){return Lf(e)?wf(e,"cantSplit",null===t?null:!t):e}(t,e),Cg),canSetActiveTableRowHeader:()=>null!==tf(e.state()),setActiveTableRowHeader:e=>o(t=>Sf(t,e),wg),canSetActiveTableColumnWidth:()=>null!==tf(e.state()),setActiveTableColumnWidth:e=>o(t=>function(e,t){const n=tf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=sf(Qg(e.document,o,r.zone),r.tablePath);if(!a)return e;const i=Kr(a).find(e=>e.rowIndex===r.rowIndex&&e.cellIndex===r.cellIndex);if(!i)return e;const s=i.visualColumnIndex;return null===t?e:Tf(e,a.id,{[s]:t})}(t,e),pg),canSetActiveTableWidth:()=>null!==tf(e.state()),setActiveTableWidth:e=>o(t=>function(e,t){const n=tf(e);if(!n)return e;const{activeSectionIndex:o,loc:r}=n,a=sf(Qg(e.document,o,r.zone),r.tablePath);return a?xf(e,a.id,"width",t):e}(t,e),ig),insert:(t,n)=>e.tableOps.insertTableCommand(t,n)}}function kC(e){const t=t=>e.applyTransactionalState(t);return{applyTheme:e=>t(t=>$S(t,e)),setColorScheme:e=>t(t=>function(e,t){const n=LS[t]??LS.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]=NS[t]??NS.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=>zS(t,{effectsId:e,themeData:{...t.document.design?.themeData??{},sourceXml:void 0,effectsXml:void 0}})),setPageColor:e=>t(t=>function(e,t){return zS(e,{pageColor:t})}(t,e)),setWatermark:e=>t(t=>function(e,t){return zS(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 PC(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:{...jS({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}),...VS({gate:e.gate,style:e.style,document:e.document,link:e.link,image:e.image,browser:e.browser,actionCommand:r}),...KS({style:e.style,paragraph:e.paragraph,section:e.section,valueCommand:o,actionCommand:r}),...ZS({dialog:e.dialog,actionCommand:r}),..._S({gate:e.gate,headerFooter:e.headerFooter,command:t,actionCommand:r}),...qS({gate:e.gate,table:e.table,actionCommand:r,valueCommand:o}),...YS({design:e.design,actionCommand:r}),...XS({bookmark:e.bookmark,actionCommand:r}),...GS({fields:e.fields,actionCommand:r})}}}({gate:tI(e),style:nI(e),selection:oI(e),history:rI(e),formatting:PI(e),document:NI(e),link:zI(e),image:$I(e),browser:HI(e),paragraph:tC(e),section:hC(e),headerFooter:bC(e),table:TC(e),design:kC(e),bookmark:vC(e),fields:CC(e),dialog:{openFontDialog:e.openFontDialog,openParagraphDialog:e.openParagraphDialog,requestAcceptAllRevisions:e.requestAcceptAllRevisions,requestRejectAllRevisions:e.requestRejectAllRevisions}})}var RC=[{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:"tableOfContents"},{id:"insert_toc_update",path:"Insert/Update Table of Contents",labelKey:"menu.insert.updateToc",command:"updateTableOfContents",icon:"updateTableOfContents"},{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 MC(e){const t=PC(e.essentials),{runtimePlugins:n,toolbarRegistry:o,menuRegistry:a,dispose:i}=function(e){const t=[e.essentialsPlugin,...e.externalPlugins??[]],n=[],o=[],r=ft(),a=new Jt;for(const i of Zn(e.t))r.register(i);for(const i of RC)a.register(i);for(const i of t){for(const e of i.toolbar??[]){const t={type:"button",id:e.id,testId:e.id,command:e.command,iconName:e.icon,tab:e.tab??"plugins",group:e.group??"general",groupLabel:e.groupLabel,row:e.row??1,ribbonSize:e.ribbonSize,ribbonGroupResize:e.ribbonGroupResize,ribbonGroupLayout:e.ribbonGroupLayout,ribbonGroupGrid:e.ribbonGroupGrid,order:e.order};r.register(t),n.push(e.id)}for(const e of i.menubar??[])a.register({id:e.id,path:e.path,command:e.command,icon:e.icon,shortcut:e.shortcut}),o.push(e.id)}return e.customizeToolbar?.(r),e.customizeMenubar?.(a),{runtimePlugins:t,toolbarRegistry:r,menuRegistry:a,dispose:()=>{for(const e of n)r.remove(e);for(const e of o)a.unregister(e)}}}({essentialsPlugin:t,externalPlugins:e.externalPlugins,t:e.t,customizeToolbar:e.customizeToolbar,customizeMenubar:e.customizeMenubar}),l=function(e){const[t,n]=vn(!1),[o,a]=vn(new r({doc:e.initialDocument}));let i=!1;const l=e=>{const t=s(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:l,toolbarHost:()=>({commands:{execute:(e,t)=>{const n=en(e,t);return o().commands.execute(n.name,n.payload)},canExecute:(e,t)=>{const n=en(e,t);return o().commands.canExecute(n.name,n.payload)},state:l},focusEditor:e.focusEditor}),initialize:async()=>{try{const t=await r.create({doc:e.initialDocument,plugins:e.runtimePlugins});if(e.onExecuted&&(t.commands.onExecuted=e.onExecuted),i)return void(await t.destroy());const s=o();a(t),await s.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()=>{i=!0,await o().destroy()}}}({initialDocument:e.initialDocument,runtimePlugins:n,focusEditor:e.focusEditor,logger:e.logger,onExecuted:e.onExecuted,onReady:e.onReady,onSettled:e.onSettled,onError:e.onError});return _n(()=>{l.initialize()}),Tn(()=>{l.dispose(),i()}),{toolbarRegistry:o,menuRegistry:a,runtimeReady:l.runtimeReady,runtimeEditor:l.runtimeEditor,commandStateOf:l.commandStateOf,toolbarHost:l.toolbarHost}}var OC=/* @__PURE__ */new Set(["undo","redo","repeatLastAction","find","replace","replaceAll","print","newDocument","saveDocument","insertHtml","insertImageFromFile","openSymbolDialog","openEquationDialog","openCommandSearch","importDocument","exportDocx","exportPdf"]);function AC(e,t){let n=null;return{lastCommand:()=>n?.command??null,record:(e,t)=>{(function(e){return!OC.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 BC(e){return function(e){const{document:t,interaction:o,runtimeClient:r}=e,{commandsController:a,keyboardCommandsController:i}=CS({state:e.state,logger:e.logger,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,focusInput:e.focusInput,selectedImageRun:o.selectedImageRun,tableOps:o.tableOps,toolbarStyleState:o.styleController.toolbarStyleState,applyBooleanStyleCommand:e=>o.styleController.applyToolbarBooleanStyleCommand(e),locale:e.locale,setLinkDialog:e.setLinkDialog,setImageAltDialog:e.setImageAltDialog,setImageCaptionDialog:e.setImageCaptionDialog,setFontDialog:e.setFontDialog,setParagraphDialog:e.setParagraphDialog});let s;const l=AC((e,t)=>{if(!s)throw new Error("repeat tracking used before ready");return s().commands.execute(e,t)},(e,t)=>!!s&&s().commands.canExecute(e,t)),c=()=>{l.execute()},d=()=>l.canExecute(),{runtimeReady:u,runtimeEditor:p,commandStateOf:g,toolbarHost:f,toolbarRegistry:m,menuRegistry:h}=MC({essentials:{clipboardActions:e.clipboardActions,state:()=>e.state,isReadOnly:e.isReadOnly,forcePlainTextPaste:{get:e.getForcePlainTextPaste,set:e.setForcePlainTextPaste},undoStack:t.undoStack,redoStack:t.redoStack,commandsController:a,keyboardCommandsController:i,historyActions:t.historyActions,styleController:o.styleController,formatPainter:o.formatPainter,commentComposer:e.commentComposer,tableOps:o.tableOps,docIO:t.docIO,importInputRef:e.importInputRef,imageInputRef:e.imageInputRef,selectedImageRun:o.selectedImageRun,imageCropMode:{isActive:o.imageOps.cropMode,toggle:o.imageOps.toggleCropMode},selectionBoxes:t.selectionBoxes,focusInput:e.focusInput,clearPreferredColumn:t.clearPreferredColumn,resetTransactionGrouping:t.resetTransactionGrouping,applyState:e.applyState,applyTransactionalState:t.applyTransactionalState,findReplace:{setIsOpen:o.fr.setIsOpen},newDocument:TS({isDirty:()=>r.isDirty(),resetDocument:()=>r.resetDocument(),requestConfirmation:()=>e.setNewDocumentDialog({isOpen:!0})}),saveDocument:()=>{r.save().catch(t=>e.logger.error("document:save failed",t))},openSymbolDialog:()=>e.setSymbolDialog({isOpen:!0}),openCommandSearch:()=>e.setCommandSearchOpen(!0),repeatLastAction:c,canRepeatLastAction:d,openTablePropertiesDialog:t=>{const n=em(e.state,t??"table");n&&e.setTablePropertiesDialog({isOpen:!0,initial:n})},openEquationDialog:()=>{const t=e.state.selection.focus,n=Nr(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:a.openFontDialog,openParagraphDialog:a.openParagraphDialog,requestAcceptAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"accept",count:hS(e.state).size})},requestRejectAllRevisions:()=>{e.setRevisionBulkDialog({isOpen:!0,action:"reject",count:hS(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=>{s=()=>t,r.resolveReady(t),e.runtimeOptions().onReady?.(r)},onSettled:()=>{e.setInitialLoading(!1)},onError:e=>r.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(Cr(e)),t.resetEditorChromeState(),t.focusInput()},applyTransactionalState:t.applyTransactionalState,resetDocument:()=>{let e=Ho();try{const t=globalThis.localStorage?.getItem("oasis-design-default");if(t){const n=JSON.parse(t);n.themeId&&(e=$S(e,n.themeId)),e=zS(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})})(r,{runtimeReady:u,runtimeEditor:p,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:m,menuRegistry:h}),n(()=>{if(!u())return;e.state.document,e.state.selection,e.state.activeSectionIndex,e.state.activeZone;const t=e.cloneState(e.getStateSnapshot());p().dispatch(()=>t)});const{handleKeyDown:b}=function(e){const{state:t,isReadOnly:n,logger:o,focusInput:r,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:s,applyTransactionalState:l,setForcePlainTextPaste:c,selectedImageRun:d,commandsController:u,tableOps:p,navigation:g,historyActions:f,styleController:m,findReplace:h,commandSearch:b,runtimeEditor:y}=e,{handleKeyDown:v}=DS({state:t,isReadOnly:n,clearPreferredColumn:a,resetTransactionGrouping:i,applyState:s,applyTransactionalState:l,applyTableAwareParagraphEdit:p.applyTableAwareParagraphEdit,applySelectionAwareParagraphCommand:p.applySelectionAwareParagraphCommand,focusInput:r,commandsController:u,pendingCaretTextStyle:m.pendingCaretTextStyle,autoTabIndentEnabled:bo,isMacPlatform:()=>"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),isCaretAtWrappedLineStart:g.isCaretAtWrappedLineStart,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,resolveTableTabTarget:p.resolveTableTabTarget,appendTableRowForTab:p.appendTableRowForTab,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=>{FS.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}]`),R("input-to-layout"),v(e),He("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:o.selectedImageRun,commandsController:i,tableOps:o.tableOps,navigation:o.navigation,historyActions:t.historyActions,styleController:o.styleController,findReplace:o.fr,commandSearch:e.commandSearch,runtimeEditor:p});return{commandsController:a,runtimeReady:u,runtimeEditor:p,commandStateOf:g,toolbarHost:f,toolbarRegistry:m,menuRegistry:h,handleKeyDown:b}}(e)}function DC(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 FC(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=DC(e,n.commentId)??DC(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 EC(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 LC(e,t,n){if(!t?.items[n])return!1;if(!e||e.canModerate)return!0;if(!EC(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),!EC(e,t.items[i]))return!1;r.push(i)}}return!0}function NC(e){const[t,n]=vn(null),[o,r]=vn(""),[i,s]=vn(!1),l=()=>e.access?.(),c=()=>{const e=l()?.identity;return e?.id.trim()&&e.displayName.trim()?{id:e.id.trim(),displayName:e.displayName.trim()}:null},d=()=>!(e.isReadOnly()||l()&&null===c()),u=()=>d()&&null!==ot(e.state()),p=t=>d()&&Boolean(e.state().document.comments?.items[t]),g=()=>d()&&null!==hI(e.state()),f=t=>!e.isReadOnly()&&EC(l(),e.state().document.comments?.items[t]),m=()=>{const t=hI(e.state());return null!==t&&f(t.id)},h=t=>!e.isReadOnly()&&LC(l(),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)=>FC(e,t,{id:ar("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||!LC(l(),r.document.comments,t))return r;const a=function(e,t){const n=e.document.comments;if(!n?.items[t])return e;const o=/* @__PURE__ */new Set([t]),r=[t],a=/* @__PURE__ */new Map;for(const s of Object.values(n.items)){if(!s.parentId)continue;const e=a.get(s.parentId)??[];e.push(s.id),a.set(s.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||!EC(l(),a.document.comments?.items[t]))return a;const i=function(e,t,n){const o=e.document.comments,r=o?.items[t];return o&&r&&Boolean(r.resolved)!==n?{...e,document:{...e.document,comments:{...o,items:{...o.items,[t]:{...r,resolved:n}}}}}:e}(a,t,n);return r=i.document!==a.document,r?v(a,i,n?"comment-resolved":"comment-reopened",t):i}),r};return{draft:t,lastAuthor:o,panelOpen:i,togglePanel:()=>(s(!i()),!0),closePanel:()=>{s(!1)},canCreate:u,canReply:g,canReplyId:p,canEdit:m,canEditId:f,canDeleteId:h,canDeleteSelected:()=>{const t=hI(e.state());return null!==t&&h(t.id)},deleteSelected:()=>{const t=hI(e.state());return!!t&&I(t.id)},deleteById:I,canResolveId:b,canResolveSelected:()=>{const t=hI(e.state());return null!==t&&b(t.id)},resolveSelected:t=>{const n=hI(e.state());return!!n&&C(n.id,t)},resolveById:C,authorName:()=>c()?.displayName??o(),authorLocked:()=>void 0!==l(),openNew:()=>!!u()&&(n({mode:"new",snapshot:e.state()}),!0),openReply:()=>{if(!g())return!1;const t=hI(e.state());return!!t&&x(t.id)},openReplyToId:x,openEdit:()=>{if(!m())return!1;const t=hI(e.state());return!!t&&w(t.id)},openEditToId:w,close:S,submit:(n,o)=>{const i=t();if(!i||e.isReadOnly())return!1;if("edit"===i.mode&&!f(i.commentId))return!1;if("edit"!==i.mode&&!d())return!1;const s="edit"===i.mode?i.commentAuthor?.trim()??"":c()?.displayName??n.trim(),u=o.trim();if(!s||!u||e.state().document!==i.snapshot.document)return!1;if("edit"===i.mode&&i.commentText===u)return S(),!0;const p="edit"===i.mode?null:{id:ar("comment"),author:s,...c()?{authorId:c().id}:{},text:u,date:Date.now()};let g=!1;return e.applyTransactionalState(t=>{if(e.isReadOnly()||t.document!==i.snapshot.document)return t;if("edit"===i.mode&&!EC(l(),t.document.comments?.items[i.commentId]))return t;if("edit"!==i.mode&&!d())return t;const n="edit"===i.mode?Xe(t,i.commentId,u):"reply"===i.mode?a(t,i.parentId,p):me({...t,selection:i.snapshot.selection,activeSectionIndex:i.snapshot.activeSectionIndex,activeZone:i.snapshot.activeZone,activeFootnoteId:i.snapshot.activeFootnoteId},p);return g=n.document!==t.document,g?v(t,n,"new"===i.mode?"comment-created":"reply"===i.mode?"comment-replied":"comment-edited","edit"===i.mode?i.commentId:p.id,s,"reply"===i.mode?i.parentId:void 0):n}),g&&("edit"!==i.mode&&r(s),S()),g}}}var zC=/*#__PURE__*/En("<div class=oasis-review-comments-filters role=group>"),$C=/*#__PURE__*/En("<div class=oasis-review-comments-list>"),HC=/*#__PURE__*/En("<div class=oasis-review-activity-list data-testid=review-activity-list role=list>"),WC=/*#__PURE__*/En("<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>"),UC=/*#__PURE__*/En("<div class=oasis-review-thread-replies>"),jC=/*#__PURE__*/En("<div class=oasis-review-thread><div class=oasis-review-thread-header></div><div class=oasis-review-thread-actions>"),VC=/*#__PURE__*/En("<div class=oasis-review-reply><div class=oasis-review-thread-actions>"),KC=/*#__PURE__*/En("<div class=oasis-review-activity-entry role=listitem data-testid=review-activity-entry><div class=oasis-review-activity-heading>");function _C(e){const t=T(),[n,o]=vn("all"),[r,a]=vn(!1),[i,s]=vn(""),[l,c]=vn(null),[d,p]=vn(null),g=()=>e.state().document.comments,f=Mt(()=>{const e=g();if(!e)return[];const t=i().trim().toLocaleLowerCase();return e.order.map(t=>e.items[t]).filter(t=>Boolean(t&&(!t.parentId||!e.items[t.parentId]))).filter(o=>("open"!==n()||!o.resolved)&&(!("resolved"===n()&&!o.resolved)&&(!t||[o,...Je(e.items,o.id)].some(e=>(e.text+" "+e.author).toLocaleLowerCase().includes(t)))))}),m=e=>Je(g()?.items??{},e),h=Mt(()=>{const t=i().trim().toLocaleLowerCase();return[...e.state().document.reviewActivity??[]].filter(e=>!t||(e.actorName+" "+e.targetAuthor+" "+e.kind).toLocaleLowerCase().includes(t)).reverse()}),b=t=>Number.isFinite(t)?new Date(t).toLocaleString(e.locale?.()??"pt-BR"):"",y=t=>{d()===t?e.composer.deleteById(t)&&(p(null),l()===t&&c(null)):p(t)};return v=WC(),x=v.firstChild,w=x.nextSibling,u(x,pe(_,{as:"strong",get children(){return t("review.commentsPanel")}}),null),u(x,pe(Un,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-comments-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),u(w,pe(Un,{size:"sm",variant:"ghost",get"aria-pressed"(){return!r()},onClick:()=>{a(!1)},"data-testid":"review-show-discussions",get children(){return t("review.commentsPanel")}}),null),u(w,pe(Un,{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),u(v,pe(_,{as:"p",get children(){return Fe(()=>!!r())()?`${t("review.activity.title")}: ${e.state().document.reviewActivity?.length??0}`:`${t("review.discussionCount")}: ${g()?.order.length??0}`}}),null),u(v,pe(vo,{get label(){return Fe(()=>!!r())()?t("review.activity.search"):t("review.searchComments")},get value(){return i()},onChange:s,"data-testid":"review-comments-search"}),null),u(v,pe(Ve,{get when(){return!r()},get children(){return[(a=zC(),u(a,pe(Un,{size:"sm",variant:"ghost",get"aria-pressed"(){return"all"===n()},onClick:()=>{o("all")},get children(){return t("review.filterAll")}}),null),u(a,pe(Un,{size:"sm",variant:"ghost",get"aria-pressed"(){return"open"===n()},onClick:()=>{o("open")},get children(){return t("review.filterOpen")}}),null),u(a,pe(Un,{size:"sm",variant:"ghost",get"aria-pressed"(){return"resolved"===n()},onClick:()=>{o("resolved")},get children(){return t("review.filterResolved")}}),null),Jn(()=>Me(a,"aria-label",t("review.filterComments"))),a),(r=$C(),u(r,pe(Ve,{get when(){return 0===f().length},get children(){return pe(_,{as:"p",get children(){return t("review.noComments")}})}}),null),u(r,pe(qe,{get each(){return f()},children:n=>{return o=jC(),r=o.firstChild,a=r.nextSibling,u(r,pe(_,{as:"strong",get children(){return n.author||"—"}}),null),u(r,pe(_,{as:"span",get children(){return Fe(()=>!!n.resolved)()?t("review.filterResolved"):t("review.filterOpen")}}),null),u(o,pe(_,{as:"p",get children(){return n.text}}),a),u(a,pe(Un,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-comment-navigate",get children(){return t("review.goToComment")}}),null),u(a,pe(Ve,{get when(){return e.composer.canEditId(n.id)},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-comment-edit",get children(){return t("toolbar.editComment")}})}}),null),u(a,pe(Ve,{get when(){return e.composer.canResolveId(n.id)},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{e.composer.resolveById(n.id,!n.resolved)},"data-testid":"review-comment-resolve",get children(){return Fe(()=>!!n.resolved)()?t("toolbar.reopenComment"):t("toolbar.resolveComment")}})}}),null),u(a,pe(Ve,{get when(){return e.composer.canReplyId(n.id)},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},"data-testid":"review-comment-reply",get children(){return t("toolbar.replyComment")}})}}),null),u(a,pe(Ve,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[pe(Un,{size:"sm",variant:"ghost",onClick:()=>y(n.id),"data-testid":"review-comment-delete",get children(){return Fe(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),pe(Ve,{get when(){return d()===n.id},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),u(o,pe(Ve,{get when(){return m(n.id).length>0},get children(){return pe(Un,{size:"sm",variant:"ghost",get"aria-expanded"(){return l()===n.id},"data-testid":"review-toggle-replies",onClick:()=>{c(l()===n.id?null:n.id)},get children(){return Fe(()=>l()===n.id)()?t("comment.showFewerReplies"):`${t("comment.showAllReplies")} (${m(n.id).length})`}})}}),null),u(o,pe(Ve,{get when(){return l()===n.id},get children(){var o=UC();return u(o,pe(qe,{get each(){return m(n.id)},children:n=>{return o=VC(),r=o.firstChild,u(o,pe(_,{as:"strong",get children(){return n.author||"—"}}),r),u(o,pe(_,{as:"p",get children(){return n.text}}),r),u(r,pe(Ve,{get when(){return e.composer.canEditId(n.id)},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openEditToId(n.id)},"data-testid":"review-reply-edit",get children(){return t("toolbar.editComment")}})}}),null),u(r,pe(Ve,{get when(){return e.composer.canReplyId(n.id)},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{e.composer.openReplyToId(n.id)},get children(){return t("toolbar.replyComment")}})}}),null),u(r,pe(Ve,{get when(){return e.composer.canDeleteId(n.id)},get children(){return[pe(Un,{size:"sm",variant:"ghost",onClick:()=>y(n.id),"data-testid":"review-reply-delete",get children(){return Fe(()=>d()===n.id)()?t("review.confirmDelete"):t("toolbar.deleteComment")}}),pe(Ve,{get when(){return d()===n.id},get children(){return pe(Un,{size:"sm",variant:"ghost",onClick:()=>{p(null)},get children(){return t("generic.cancel")}})}})]}}),null),Jn(()=>Me(o,"data-comment-id",n.id)),o;var o,r}})),o}}),null),Jn(()=>Me(o,"data-comment-id",n.id)),o;var o,r,a}}),null),r)];var r,a}}),null),u(v,pe(Ve,{get when(){return r()},get children(){var n=HC();return u(n,pe(Ve,{get when(){return 0===h().length},get children(){return pe(_,{as:"p",get children(){return t("review.activity.empty")}})}}),null),u(n,pe(qe,{get each(){return h()},children:n=>{return o=KC(),r=o.firstChild,u(r,pe(_,{as:"strong",get children(){return n.actorName}}),null),u(r,pe(_,{as:"span",get children(){return b(n.timestamp)}}),null),u(o,pe(_,{as:"p",get children(){return[Fe(()=>(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))," — ",Fe(()=>n.targetAuthor),Fe(()=>Fe(()=>!!(n.affectedCount&&n.affectedCount>1))()?` (${n.affectedCount})`:"")]}}),null),u(o,pe(Ve,{get when(){return Boolean(g()?.items[n.commentId])},get children(){return pe(Un,{size:"sm",variant:"ghost","data-testid":"review-activity-navigate",onClick:()=>e.onNavigate(n.commentId),get children(){return t("review.goToComment")}})}}),null),Jn(()=>Me(o,"data-activity-kind",n.kind)),o;var o,r}}),null),Jn(()=>Me(n,"aria-label",t("review.activity.title"))),n}}),null),Jn(e=>{var n=t("review.commentsPanel"),o=t("review.displayMode");return n!==e.e&&Me(v,"aria-label",e.e=n),o!==e.t&&Me(w,"aria-label",e.t=o),e},{e:void 0,t:void 0}),v;var v,x,w}var XC="oasis-reviewing-pane-v1",GC={open:!1,scrollTop:0};function qC(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:0}function YC(){const e=function(){try{const e=globalThis.localStorage?.getItem(XC);if(!e)return GC;if("true"===e)return{open:!0,scrollTop:0};if("false"===e)return{open:!1,scrollTop:0};const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))return GC;const n=t;return{open:!0===n.open,scrollTop:qC(n.scrollTop)}}catch{return GC}}(),[t,n]=vn(e.open),[o,r]=vn(e.scrollTop),a=()=>{!function(e){try{globalThis.localStorage?.setItem(XC,JSON.stringify(e))}catch{}}({open:t(),scrollTop:o()})},i=e=>{n(e),a()};return{open:()=>t(),toggle:()=>(i(!t()),!0),close:()=>{i(!1)},scrollTop:()=>o(),setScrollTop:e=>{const t=qC(e);t!==o()&&(r(t),a())}}}var ZC=/*#__PURE__*/En("<ul class=oasis-review-revisions-list data-testid=review-revisions-list>"),JC=/*#__PURE__*/En("<div class=oasis-review-revision-footer>"),QC=/*#__PURE__*/En('<div role=region class="oasis-review-comments-panel oasis-review-revisions-panel"data-testid=review-revisions-panel><div class=oasis-review-comments-heading>'),eT=/*#__PURE__*/En("<li class=oasis-review-revision-item><div class=oasis-review-revision-body></div><div class=oasis-review-revision-actions>");function tT(e,t){const n=zo(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 nT(e){const t=T(),o=Mt(()=>{const t=e.state(),n=zo(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(Cv(t).map(e=>[e.id,e])),i=new Map(Tv(t).map(e=>[e.id,e]));return pI(t).map(e=>{const n=r.get(e.id),s=a.get(e.id),l=i.get(e.id);return{id:e.id,type:n?.type??s?.type??l?.type??"insert",author:o.get(e.id)??s?.author??l?.author??"—",date:n?.date??s?.date??l?.date,snippet:tT(t,e.id)||s?.snippet||l?.snippet||"",section:void 0!==l}})}),r=Mt(()=>{const t=e.state();return o().filter(e=>Ov(t,e.type,e.author))});let a,i=!1;const s=()=>{const t=a,n=e.scrollTop;!t||"number"!=typeof n||n<=0||t.scrollHeight<=t.clientHeight||(t.scrollTop=n,i=!0,t.scrollTop!==n&&e.onScroll?.(t.scrollTop))};n(()=>{r().length,i||queueMicrotask(s)});return l=QC(),c=l.firstChild,u(c,pe(_,{as:"strong",get children(){return t("review.reviewingPane")}}),null),u(c,pe(Un,{size:"sm",variant:"ghost",get onClick(){return e.onClose},"data-testid":"review-revisions-close",get"aria-label"(){return t("generic.close")},children:"✕"}),null),u(l,pe(_,{as:"p",get children(){return[Fe(()=>t("review.revisionCount")),": ",Fe(()=>r().length)]}}),null),u(l,pe(Ve,{get when(){return o().length-r().length>0},get children(){return pe(_,{as:"p",class:"oasis-review-revisions-filtered","data-testid":"review-revisions-filtered",get children(){return t("review.revisionsHiddenByShowMarkup")}})}}),null),u(l,pe(Ve,{get when(){return r().length>0},get fallback(){return pe(_,{as:"p",get children(){return t("review.noRevisions")}})},get children(){var n=ZC();return n.addEventListener("scroll",t=>{e.onScroll?.(t.currentTarget.scrollTop)}),$(e=>{a=e,queueMicrotask(s)},n),u(n,pe(qe,{get each(){return r()},children:n=>{return o=eT(),r=o.firstChild,a=r.nextSibling,u(r,pe(_,{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[pe(Ze,{get name(){return"delete"===(e=n.type)?"minus":"insert"===e?"plus":"pencil";var e}}),pe(_,{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),u(r,pe(_,{as:"p",get children(){return n.snippet||"—"}}),null),u(r,pe(_,{as:"span",get children(){return n.author}}),null),u(a,pe(Un,{size:"sm",variant:"ghost",onClick:()=>e.onNavigate(n.id),"data-testid":"review-revision-navigate",get children(){return t("review.goToComment")}}),null),u(a,pe(Un,{size:"sm",variant:"ghost",onClick:()=>e.onAccept(n.id),"data-testid":"review-revision-accept",get children(){return t("toolbar.accept")}}),null),u(a,pe(Un,{size:"sm",variant:"ghost",onClick:()=>e.onReject(n.id),"data-testid":"review-revision-reject",get children(){return t("toolbar.reject")}}),null),Jn(e=>{var t=n.id,r=n.section?"true":void 0;return t!==e.e&&Me(o,"data-comment-id",e.e=t),r!==e.t&&Me(o,"data-revision-section",e.t=r),e},{e:void 0,t:void 0}),o;var o,r,a}})),n}}),null),u(l,pe(Ve,{get when(){return r().length>0},get children(){var n=JC();return u(n,pe(Un,{size:"sm",variant:"ghost",get onClick(){return e.onRejectAll},"data-testid":"review-revisions-reject-all",get children(){return t("toolbar.rejectAll")}}),null),u(n,pe(Un,{size:"sm",variant:"primary",get onClick(){return e.onAcceptAll},"data-testid":"review-revisions-accept-all",get children(){return t("toolbar.acceptAll")}}),null),n}}),null),Jn(()=>Me(l,"aria-label",t("review.reviewingPane"))),l;var l,c}var oT=/*#__PURE__*/En('<div class="oasis-editor-shell oasis-editor-app">');function rT(e={}){const t=e.runtime?.client??ut(),[n,o]=vn({}),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}),s=e=>(o(t=>({...t,...e,toolbar:{...t.toolbar??{},...e.toolbar??{}}})),{...i(),...e}),l=()=>e.runtime??{};xp();const d=L(()=>r().locale??"pt-BR"),p=fe("app"),{state:g,commitState:f,getStateSnapshot:m}=function(e){const t=e.initialState?io(e.initialState):e.initialDocument?Cr(e.initialDocument):Ho();let n=t;const[o,r]=vn(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=Br(e===a?n:e);n=t,r(t)},getStateSnapshot:()=>n}}({initialDocument:a().initialDocument,initialState:a().initialState}),h=e=>{f(e)},y=io;let v=!1;const{showChrome:x,showTitleBar:w,showMenubar:S,showToolbar:I,showOutline:C,showRuler:T,toggleOutline:k,toolbarView:P,toolbarLayout:R,isReadOnly:M,useComposedShell:O,loadingOptions:A,loadingLabel:B,shellComponent:D}=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?c:"balloon"===e?sn:nn}}}({ui:r,documentOptions:a,updateUiState:s,state:()=>g}),E=function(){const[e,t]=vn(!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,z=E.setFocused,$=E.focusInput,W=E.focusInputAfterPointerSelection,U=E.focusInputSync,[j,K]=vn(!1!==r().loading),_=F(),{linkDialog:X,setLinkDialog:G,imageAltDialog:q,setImageAltDialog:Y,imageCaptionDialog:Z,setImageCaptionDialog:Q,contextMenu:ee,setContextMenu:te,fontDialog:ne,setFontDialog:oe,paragraphDialog:re,setParagraphDialog:ae,tablePropertiesDialog:ie,setTablePropertiesDialog:se,revisionBulkDialog:le,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:ge,symbolDialog:me,setSymbolDialog:he,equationDialog:be,setEquationDialog:ye}=function(){const[e,t]=vn({isOpen:!1}),[n,o]=vn({isOpen:!1}),[r,a]=vn({isOpen:!1}),[i,s]=vn({isOpen:!1,initialHref:""}),[l,c]=vn({isOpen:!1,initialAlt:""}),[d,u]=vn({isOpen:!1,initialCaption:""}),[p,g]=vn({isOpen:!1,x:0,y:0}),[f,m]=vn({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]=vn({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]=vn({isOpen:!1,action:"accept",count:0}),[x,w]=vn({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:s,imageAltDialog:l,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}}(),[ve,xe]=vn(!1),Se=()=>E.viewportRef,Ie=()=>E.surfaceRef,Ce=tx({documentOptions:a,logger:p,runtimeClient:t,state:g,commitState:f,getStateSnapshot:m,applyState:h,cloneState:y,isReadOnly:M,focusInput:$,surfaceRef:Ie,viewportRef:Se,zoomFactor:_.zoomFactor,getImageOps:()=>Qe.imageOps}),{docIO:Te,measuredBlockHeights:ke,measuredParagraphLayouts:Pe,documentLayout:Re,canvasSnapshotProvider:Ae,inputBox:Be,selectionBoxes:De,commentHighlights:Ee,revisionMarkupBoxes:Le,changeBarBoxes:Ne,selectedImageBox:ze,selectedTextBoxBox:$e,selectedTableBox:He,caretBox:We,preferredColumnX:Ue,setPreferredColumnX:je,clearPreferredColumn:Ke,onCleanupHook:Xe,persistenceStatus:Ge,applyTransactionalState:qe,resetTransactionGrouping:Ye,updateHistoryState:Ze}=Ce,Je=tp({state:()=>g,stateSnapshot:m,isReadOnly:M,applyTransactionalState:qe,applyTableAwareParagraphEdit:(e,t)=>Qe.tableOps.applyTableAwareParagraphEdit(e,t),clearPreferredColumn:Ke,resetTransactionGrouping:Ye,focusInput:$}),Qe=aS({clipboardActions:Je,state:g,getStateSnapshot:m,logger:p,isReadOnly:M,applyState:h,cloneState:y,focusInput:$,focusInputAfterPointerSelection:W,focusInputSync:U,surfaceRef:Ie,viewportRef:Se,zoomFactor:_.zoomFactor,insertImageFromFile:Te.insertImageFromFile,getForcePlainTextPaste:()=>v,setForcePlainTextPaste:e=>{v=e},getCommandsController:()=>Tt.commandsController,applyTransactionalState:qe,clearPreferredColumn:Ke,resetTransactionGrouping:Ye,updateHistoryState:Ze,caretBox:We,preferredColumnX:Ue,setPreferredColumnX:je,measuredBlockHeights:ke,measuredParagraphLayouts:Pe,documentLayout:Re,canvasSnapshotProvider:Ae,openEquationDialog:(e,t)=>{ye({isOpen:!0,initial:e,targetRunId:t})}}),{layoutOptionsOverlay:et,fr:tt,tableOps:ot,imageOps:rt,textBoxOps:at,styleController:it,onEditorPointerDown:st,tableResize:lt,tableCornerResize:ct,tableDrag:dt,revisionController:gt,textDrag:ft,surfaceEventsWithTextDrag:mt,textInput:ht,handleCopy:bt,handleCut:yt,handlePaste:vt,handleDrop:xt}=Qe,[wt,St]=vn(!1),It=YC(),Ct=NC({state:()=>g,isReadOnly:M,applyTransactionalState:qe,focusInput:$,access:()=>l().review}),Tt=BC({commandSearch:{isOpen:wt,setIsOpen:e=>{St(e)}},setCommandSearchOpen:St,clipboardActions:Je,document:Ce,interaction:Qe,commentComposer:Ct,state:g,logger:p,isReadOnly:M,focusInput:$,applyState:h,getStateSnapshot:m,cloneState:y,setFocused:z,setInitialLoading:K,getForcePlainTextPaste:()=>v,setForcePlainTextPaste:e=>{v=e},locale:()=>r().locale??"pt-BR",translator:d,runtimeClient:t,runtimeOptions:l,documentOptions:a,getUiState:i,updateUiState:s,zoom:_,importInputRef:()=>E.importInputRef,imageInputRef:()=>E.imageInputRef,setLinkDialog:G,setImageAltDialog:Y,setImageCaptionDialog:Q,setNewDocumentDialog:ge,setSymbolDialog:he,setEquationDialog:ye,setTablePropertiesDialog:se,setFontDialog:oe,setParagraphDialog:ae,setRevisionBulkDialog:de,toggleOutline:k,isOutlineVisible:C,toggleRevisionsPanel:()=>{It.toggle()},revisionsPanelVisible:It.open}),{commandsController:kt,runtimeReady:Pt,runtimeEditor:Rt,toolbarHost:Mt,toolbarRegistry:Ot,menuRegistry:At,handleKeyDown:Bt}=Tt,Dt=()=>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=fp(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=gp(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}(Ot.getOrdered(),At.getItems(),d),Ft=e=>{try{return!1!==Rt().commands.canExecute(e)}catch{return!1}},{computeFontFamilyOptions:Et,computeFontSizeOptions:Lt,applyFontDialogValues:Nt,applyParagraphDialogValues:zt,setParagraphDialogDefault:$t,applyTablePropertiesDialogValues:Wt,buildContextMenuItems:Ut,handleEditorContextMenu:jt,closeContextMenu:Vt}=rm({clipboardActions:Je,state:()=>g,selection:()=>g.selection,toolbarStyleState:it.toolbarStyleState,isReadOnly:M,t:d,logger:p,setFontDialog:oe,setParagraphDialog:ae,setTablePropertiesDialog:se,setContextMenu:te,clearPreferredColumn:Ke,resetTransactionGrouping:Ye,applyTransactionalState:qe,applyTableAwareParagraphEdit:ot.applyTableAwareParagraphEdit,focusInput:$,promptForLink:kt.promptForLink,tableOps:ot}),{layout:Kt,overlays:_t,refs:Xt,surfaceHandlers:Gt,inputHandlers:qt,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,pageGutter:t.pageGutter,initialZoomMode:t.initialZoomMode,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:Re,remoteWebFonts:a().remoteWebFonts,pageGutter:r().pageGutter,initialZoomMode:r().zoom?.initialMode,viewportHeight:r().viewportHeight,className:r().class,style:r().style,zoomPercent:_.zoomPercent,setZoomPercent:_.setZoomPercent,zoomFactor:_.zoomFactor},overlays:{selectionBoxes:De,commentHighlights:Ee,revisionMarkupBoxes:Le,changeBarBoxes:Ne,onReplyToComment:e=>{Ct.openReplyToId(e)},onEditComment:e=>{Ct.openEditToId(e)},canEditComment:Ct.canEditId,canReplyComment:Ct.canReplyId,selectedImageBox:ze,selectedTextBoxBox:$e,selectedTableBox:He,layoutOptions:et,caretBox:We,inputBox:Be,hoveredRevision:gt.hoveredRevision,focused:N,showCaret:()=>function(e,t){if(!t.visible||!fr(e.selection))return!1;const n=lr(e),o=rr(e.document,e.selection.anchor.paragraphId,n),r=rr(e.document,e.selection.focus.paragraphId,n);return!(o&&r&&o.blockIndex===r.blockIndex&&(o.rowIndex!==r.rowIndex||o.cellIndex!==r.cellIndex))}(g,We()),importProgress:Te.importProgress,imageCropMode:rt.cropMode},refs:{focusController:E},files:{handleImportFile:Te.handleImportFile,handleInsertImage:Te.handleInsertImage},surface:{surfaceEvents:mt,tableResize:lt,tableCornerResize:ct,tableDrag:dt,revisionController:gt,handleDrop:xt,onEditorPointerDown:st,handleImagePointerDown:rt.handleImagePointerDown,handleImageResizeHandlePointerDown:rt.handleImageResizeHandlePointerDown,handleTextBoxResizeHandlePointerDown:at.handleTextBoxResizeHandlePointerDown,handleImageRotateHandlePointerDown:rt.handleImageRotateHandlePointerDown,handleImageCropHandlePointerDown:rt.handleImageCropHandlePointerDown,handleImageCropBodyPointerDown:rt.handleImageCropBodyPointerDown,handleTextBoxRotateHandlePointerDown:at.handleTextBoxRotateHandlePointerDown,handleEditorContextMenu:jt},input:{textInput:ht,setFocused:z,handleCopy:bt,handleCut:yt,handlePaste:vt,handleKeyDown:e=>{if("Escape"===e.key&&Qe.formatPainter.mode())return Qe.formatPainter.cancel(),void e.preventDefault();Bt(e)},handleKeyUp:e=>{Qe.formatPainter.mode()&&(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Shift"].includes(e.key)||(e.ctrlKey||e.metaKey)&&"a"===e.key.toLowerCase())&&Qe.formatPainter.applyToSelection("keyboard")}}});return _n(()=>{_e(),H(),Oe(),Ln(()=>Ie()??null),Ht(),(r().showWelcome??!0)&&!we()&&co()&&xe(!0)}),Tn(()=>{Xe(),mt.stopDragging(),ft.stopDrag(),lt.stop(),ct.stop(),dt.stop(),rt.stopImageDrag(),rt.stopImageResize(),rt.stopImageCrop(),at.stopTextBoxResize(),nt()}),pe(ce,{translator:d,get children(){var e=oT();return u(e,pe(Ve,{get when(){return Fe(()=>!(O()||!x()))()&&I()},get children(){return pe(b,{host:Mt,registry:Ot,get showFileGroup(){return!!Fe(()=>"ribbon"===P())()||!S()},get view(){return P()},get layout(){return R()}})}}),null),u(e,pe(rp,{get notice(){return Je.notice},onDismiss:()=>{Je.dismiss(),$()}}),null),u(e,pe(Ve,{get when(){return Ct.panelOpen()},get children(){return pe(_C,{state:()=>g,composer:Ct,locale:()=>r().locale??"pt-BR",get onClose(){return Ct.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 s=zo(e),l=s.find(e=>e.id===a.paragraphId),c=s.find(e=>e.id===i.paragraphId);return l&&c?{...e,selection:{anchor:na(l,a.offset),focus:na(c,i.offset)}}:e}(g,e);t!==g&&(h(t),$())}})}}),null),u(e,pe(Ve,{get when(){return It.open()},get children(){return pe(nT,{state:()=>g,get onClose(){return It.close},get scrollTop(){return It.scrollTop()},get onScroll(){return It.setScrollTop},onNavigate:e=>{const t=bI(g,e);t!==g&&(h(t),$())},onAccept:e=>{const t=bI(g,e);t!==g&&(h(t),kt.applyAcceptRevisionsCommand(),$())},onReject:e=>{const t=bI(g,e);t!==g&&(h(t),kt.applyRejectRevisionsCommand(),$())},onAcceptAll:()=>Rt().commands.execute("requestAcceptAllRevisions"),onRejectAll:()=>Rt().commands.execute("requestRejectAllRevisions")})}}),null),u(e,pe(pp,{get isOpen(){return wt()},get entries(){return Dt()},isEnabled:Ft,onExecute:e=>{Rt().commands.execute(e.command,e.payload),St(!1),$()},onClose:()=>{St(!1),$()}}),null),u(e,pe(Hh,{commentComposer:Ct,dialogs:{linkDialog:X,setLinkDialog:G,imageAltDialog:q,setImageAltDialog:Y,imageCaptionDialog:Z,setImageCaptionDialog:Q,contextMenu:ee,setContextMenu:te,fontDialog:ne,setFontDialog:oe,paragraphDialog:re,setParagraphDialog:ae,tablePropertiesDialog:ie,setTablePropertiesDialog:se,revisionBulkDialog:le,setRevisionBulkDialog:de,newDocumentDialog:ue,setNewDocumentDialog:ge,symbolDialog:me,setSymbolDialog:he,equationDialog:be,setEquationDialog:ye},findReplace:tt,fontFamilyOptions:Et,fontSizeOptions:Lt,contextMenuItems:Ut,focusInput:$,get applyLinkCommand(){return kt.applyLinkCommand},get applyImageAltCommand(){return kt.applyImageAltCommand},get applyImageCaptionCommand(){return kt.applyImageCaptionCommand},applyFontDialogValues:Nt,applyParagraphDialogValues:zt,setParagraphDialogDefault:$t,applyTablePropertiesDialogValues:Wt,confirmNewDocument:()=>t.resetDocument(),applyBulkRevisions:e=>{Rt().commands.execute("accept"===e?"acceptAllRevisions":"rejectAllRevisions"),$()},insertSymbol:(e,t)=>{Rt().commands.execute("insertText",{text:e,fontFamily:t}),$()},applyEquation:(e,t)=>{t?Rt().commands.execute("updateEquation",{runId:t,expression:e}):Rt().commands.execute("insertEquation",e),$()},closeContextMenu:Vt}),null),u(e,pe(Uh,{useComposedShell:O,shellComponent:D,runtime:{state:()=>g,toolbarHost:Mt,runtimeEditor:Rt,persistenceStatus:Ge,toolbarRegistry:Ot,menuRegistry:At},chrome:{showChrome:x,showTitleBar:w,showMenubar:S,showToolbar:I,showOutline:C,showRuler:T,toolbarView:P,toolbarLayout:R},view:{isReadOnly:M,viewportHeight:()=>r().viewportHeight,measuredBlockHeights:ke,measuredParagraphLayouts:Pe,documentLayout:Re,layout:Kt,overlays:_t,refs:Xt,surfaceHandlers:Gt,inputHandlers:qt,fileHandlers:Yt}}),null),u(e,pe(dm,{state:g,get surfaceRef(){return Ie()},documentLayout:Re,snapshotProvider:Ae,get zoomFactor(){return _.zoomFactor},tableResize:lt,tableCornerResize:ct,imageOps:rt,tableDrag:dt,textDrag:ft}),null),u(e,pe(Ve,{get when(){return j()||!Pt()},get children(){return pe(J,{get label(){return B()},get class(){return A()?.class},get style(){return A()?.style}})}}),null),u(e,pe(Vh,{get isOpen(){return Fe(()=>!(!ve()||j()))()&&Pt()},onClose:()=>xe(!1)}),null),Jn(t=>{var n=r().theme??"light",o=!!O(),a=!!M(),i=!("two-line"!==r().toolbar?.ribbonStyle),s=!("simplified"!==r().toolbar?.ribbonStyle),l=!(null===Qe.formatPainter.mode()),c={"--oasis-editor-gutter-x":`${pt(r().pageGutter)}px`,...void 0!==r().pageGutter?{"--oasis-editor-gutter-top":`${pt(r().pageGutter)}px`,"--oasis-editor-gutter-bottom":`${pt(r().pageGutter)}px`}:{}};return n!==t.e&&Me(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-two-line",t.o=i),s!==t.i&&e.classList.toggle("oasis-editor-ribbon-simplified",t.i=s),l!==t.n&&e.classList.toggle("oasis-editor-format-painter-active",t.n=l),t.s=V(e,c,t.s),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),e}})}export{rT as OasisEditorApp};